@machhub-dev/node-red-nodes 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +373 -0
- package/dist/lib/config/machhub-env-loader.js +93 -0
- package/dist/lib/enums/data.enums.js +12 -0
- package/dist/lib/errors/errors.js +15 -0
- package/dist/lib/models/collections.model.js +2 -0
- package/dist/lib/models/machine.models.js +2 -0
- package/dist/lib/models/product.models.js +2 -0
- package/dist/lib/models/recordId.models.js +11 -0
- package/dist/lib/services/http.api.services.js +152 -0
- package/dist/lib/services/http.service.js +188 -0
- package/dist/lib/services/mqtt.service.js +234 -0
- package/dist/nodes/bulk-tag-write.html +91 -0
- package/dist/nodes/bulk-tag-write.js +118 -0
- package/dist/nodes/collections.html +508 -0
- package/dist/nodes/collections.js +241 -0
- package/dist/nodes/dbquery.html +131 -0
- package/dist/nodes/dbquery.js +83 -0
- package/dist/nodes/machhub-config.html +39 -0
- package/dist/nodes/machhub-config.js +15 -0
- package/dist/nodes/tag-read.html +194 -0
- package/dist/nodes/tag-read.js +133 -0
- package/dist/nodes/tag-write.html +162 -0
- package/dist/nodes/tag-write.js +110 -0
- package/node_modules/@babel/runtime/LICENSE +22 -0
- package/node_modules/@babel/runtime/README.md +19 -0
- package/node_modules/@babel/runtime/helpers/AwaitValue.js +4 -0
- package/node_modules/@babel/runtime/helpers/OverloadYield.js +4 -0
- package/node_modules/@babel/runtime/helpers/applyDecoratedDescriptor.js +9 -0
- package/node_modules/@babel/runtime/helpers/applyDecs.js +236 -0
- package/node_modules/@babel/runtime/helpers/applyDecs2203.js +184 -0
- package/node_modules/@babel/runtime/helpers/applyDecs2203R.js +191 -0
- package/node_modules/@babel/runtime/helpers/applyDecs2301.js +222 -0
- package/node_modules/@babel/runtime/helpers/applyDecs2305.js +133 -0
- package/node_modules/@babel/runtime/helpers/applyDecs2311.js +124 -0
- package/node_modules/@babel/runtime/helpers/arrayLikeToArray.js +6 -0
- package/node_modules/@babel/runtime/helpers/arrayWithHoles.js +4 -0
- package/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js +5 -0
- package/node_modules/@babel/runtime/helpers/assertClassBrand.js +5 -0
- package/node_modules/@babel/runtime/helpers/assertThisInitialized.js +5 -0
- package/node_modules/@babel/runtime/helpers/asyncGeneratorDelegate.js +24 -0
- package/node_modules/@babel/runtime/helpers/asyncIterator.js +45 -0
- package/node_modules/@babel/runtime/helpers/asyncToGenerator.js +26 -0
- package/node_modules/@babel/runtime/helpers/awaitAsyncGenerator.js +5 -0
- package/node_modules/@babel/runtime/helpers/callSuper.js +7 -0
- package/node_modules/@babel/runtime/helpers/checkInRHS.js +6 -0
- package/node_modules/@babel/runtime/helpers/checkPrivateRedeclaration.js +4 -0
- package/node_modules/@babel/runtime/helpers/classApplyDescriptorDestructureSet.js +10 -0
- package/node_modules/@babel/runtime/helpers/classApplyDescriptorGet.js +4 -0
- package/node_modules/@babel/runtime/helpers/classApplyDescriptorSet.js +7 -0
- package/node_modules/@babel/runtime/helpers/classCallCheck.js +4 -0
- package/node_modules/@babel/runtime/helpers/classCheckPrivateStaticAccess.js +5 -0
- package/node_modules/@babel/runtime/helpers/classCheckPrivateStaticFieldDescriptor.js +4 -0
- package/node_modules/@babel/runtime/helpers/classExtractFieldDescriptor.js +5 -0
- package/node_modules/@babel/runtime/helpers/classNameTDZError.js +4 -0
- package/node_modules/@babel/runtime/helpers/classPrivateFieldDestructureSet.js +7 -0
- package/node_modules/@babel/runtime/helpers/classPrivateFieldGet.js +7 -0
- package/node_modules/@babel/runtime/helpers/classPrivateFieldGet2.js +5 -0
- package/node_modules/@babel/runtime/helpers/classPrivateFieldInitSpec.js +5 -0
- package/node_modules/@babel/runtime/helpers/classPrivateFieldLooseBase.js +5 -0
- package/node_modules/@babel/runtime/helpers/classPrivateFieldLooseKey.js +5 -0
- package/node_modules/@babel/runtime/helpers/classPrivateFieldSet.js +7 -0
- package/node_modules/@babel/runtime/helpers/classPrivateFieldSet2.js +5 -0
- package/node_modules/@babel/runtime/helpers/classPrivateGetter.js +5 -0
- package/node_modules/@babel/runtime/helpers/classPrivateMethodGet.js +5 -0
- package/node_modules/@babel/runtime/helpers/classPrivateMethodInitSpec.js +5 -0
- package/node_modules/@babel/runtime/helpers/classPrivateMethodSet.js +4 -0
- package/node_modules/@babel/runtime/helpers/classPrivateSetter.js +5 -0
- package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldDestructureSet.js +7 -0
- package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecGet.js +7 -0
- package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecSet.js +7 -0
- package/node_modules/@babel/runtime/helpers/classStaticPrivateMethodGet.js +5 -0
- package/node_modules/@babel/runtime/helpers/classStaticPrivateMethodSet.js +4 -0
- package/node_modules/@babel/runtime/helpers/construct.js +10 -0
- package/node_modules/@babel/runtime/helpers/createClass.js +13 -0
- package/node_modules/@babel/runtime/helpers/createForOfIteratorHelper.js +50 -0
- package/node_modules/@babel/runtime/helpers/createForOfIteratorHelperLoose.js +19 -0
- package/node_modules/@babel/runtime/helpers/createSuper.js +16 -0
- package/node_modules/@babel/runtime/helpers/decorate.js +250 -0
- package/node_modules/@babel/runtime/helpers/defaults.js +9 -0
- package/node_modules/@babel/runtime/helpers/defineAccessor.js +8 -0
- package/node_modules/@babel/runtime/helpers/defineEnumerableProperties.js +12 -0
- package/node_modules/@babel/runtime/helpers/defineProperty.js +10 -0
- package/node_modules/@babel/runtime/helpers/dispose.js +28 -0
- package/node_modules/@babel/runtime/helpers/esm/AwaitValue.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/OverloadYield.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/applyDecoratedDescriptor.js +9 -0
- package/node_modules/@babel/runtime/helpers/esm/applyDecs.js +236 -0
- package/node_modules/@babel/runtime/helpers/esm/applyDecs2203.js +184 -0
- package/node_modules/@babel/runtime/helpers/esm/applyDecs2203R.js +191 -0
- package/node_modules/@babel/runtime/helpers/esm/applyDecs2301.js +222 -0
- package/node_modules/@babel/runtime/helpers/esm/applyDecs2305.js +133 -0
- package/node_modules/@babel/runtime/helpers/esm/applyDecs2311.js +124 -0
- package/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +6 -0
- package/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/assertClassBrand.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js +24 -0
- package/node_modules/@babel/runtime/helpers/esm/asyncIterator.js +45 -0
- package/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js +26 -0
- package/node_modules/@babel/runtime/helpers/esm/awaitAsyncGenerator.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/callSuper.js +7 -0
- package/node_modules/@babel/runtime/helpers/esm/checkInRHS.js +6 -0
- package/node_modules/@babel/runtime/helpers/esm/checkPrivateRedeclaration.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorDestructureSet.js +10 -0
- package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorGet.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorSet.js +7 -0
- package/node_modules/@babel/runtime/helpers/esm/classCallCheck.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticAccess.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticFieldDescriptor.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/classExtractFieldDescriptor.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classNameTDZError.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldDestructureSet.js +7 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js +7 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet2.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldInitSpec.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseBase.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldLooseKey.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js +7 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet2.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateGetter.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateMethodGet.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateMethodInitSpec.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateMethodSet.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/classPrivateSetter.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldDestructureSet.js +7 -0
- package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecGet.js +7 -0
- package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecSet.js +7 -0
- package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodGet.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodSet.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/construct.js +10 -0
- package/node_modules/@babel/runtime/helpers/esm/createClass.js +13 -0
- package/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js +50 -0
- package/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelperLoose.js +19 -0
- package/node_modules/@babel/runtime/helpers/esm/createSuper.js +16 -0
- package/node_modules/@babel/runtime/helpers/esm/decorate.js +250 -0
- package/node_modules/@babel/runtime/helpers/esm/defaults.js +9 -0
- package/node_modules/@babel/runtime/helpers/esm/defineAccessor.js +8 -0
- package/node_modules/@babel/runtime/helpers/esm/defineEnumerableProperties.js +12 -0
- package/node_modules/@babel/runtime/helpers/esm/defineProperty.js +10 -0
- package/node_modules/@babel/runtime/helpers/esm/dispose.js +28 -0
- package/node_modules/@babel/runtime/helpers/esm/extends.js +10 -0
- package/node_modules/@babel/runtime/helpers/esm/get.js +11 -0
- package/node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js +6 -0
- package/node_modules/@babel/runtime/helpers/esm/identity.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/importDeferProxy.js +27 -0
- package/node_modules/@babel/runtime/helpers/esm/inherits.js +14 -0
- package/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +5 -0
- package/node_modules/@babel/runtime/helpers/esm/initializerDefineProperty.js +9 -0
- package/node_modules/@babel/runtime/helpers/esm/initializerWarningHelper.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/instanceof.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/interopRequireDefault.js +6 -0
- package/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js +27 -0
- package/node_modules/@babel/runtime/helpers/esm/isNativeFunction.js +8 -0
- package/node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js +9 -0
- package/node_modules/@babel/runtime/helpers/esm/iterableToArray.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js +28 -0
- package/node_modules/@babel/runtime/helpers/esm/jsx.js +22 -0
- package/node_modules/@babel/runtime/helpers/esm/maybeArrayLike.js +9 -0
- package/node_modules/@babel/runtime/helpers/esm/newArrowCheck.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/nullishReceiverError.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/objectSpread.js +14 -0
- package/node_modules/@babel/runtime/helpers/esm/objectSpread2.js +23 -0
- package/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js +13 -0
- package/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +10 -0
- package/node_modules/@babel/runtime/helpers/esm/package.json +3 -0
- package/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js +8 -0
- package/node_modules/@babel/runtime/helpers/esm/readOnlyError.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js +304 -0
- package/node_modules/@babel/runtime/helpers/esm/set.js +22 -0
- package/node_modules/@babel/runtime/helpers/esm/setFunctionName.js +12 -0
- package/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +6 -0
- package/node_modules/@babel/runtime/helpers/esm/skipFirstGeneratorNext.js +7 -0
- package/node_modules/@babel/runtime/helpers/esm/slicedToArray.js +8 -0
- package/node_modules/@babel/runtime/helpers/esm/superPropBase.js +6 -0
- package/node_modules/@babel/runtime/helpers/esm/superPropGet.js +9 -0
- package/node_modules/@babel/runtime/helpers/esm/superPropSet.js +6 -0
- package/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js +8 -0
- package/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteralLoose.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/tdz.js +4 -0
- package/node_modules/@babel/runtime/helpers/esm/temporalRef.js +6 -0
- package/node_modules/@babel/runtime/helpers/esm/temporalUndefined.js +2 -0
- package/node_modules/@babel/runtime/helpers/esm/toArray.js +8 -0
- package/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js +8 -0
- package/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +12 -0
- package/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +7 -0
- package/node_modules/@babel/runtime/helpers/esm/toSetter.js +10 -0
- package/node_modules/@babel/runtime/helpers/esm/typeof.js +10 -0
- package/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js +9 -0
- package/node_modules/@babel/runtime/helpers/esm/using.js +12 -0
- package/node_modules/@babel/runtime/helpers/esm/usingCtx.js +59 -0
- package/node_modules/@babel/runtime/helpers/esm/wrapAsyncGenerator.js +69 -0
- package/node_modules/@babel/runtime/helpers/esm/wrapNativeSuper.js +27 -0
- package/node_modules/@babel/runtime/helpers/esm/wrapRegExp.js +51 -0
- package/node_modules/@babel/runtime/helpers/esm/writeOnlyError.js +4 -0
- package/node_modules/@babel/runtime/helpers/extends.js +10 -0
- package/node_modules/@babel/runtime/helpers/get.js +11 -0
- package/node_modules/@babel/runtime/helpers/getPrototypeOf.js +6 -0
- package/node_modules/@babel/runtime/helpers/identity.js +4 -0
- package/node_modules/@babel/runtime/helpers/importDeferProxy.js +27 -0
- package/node_modules/@babel/runtime/helpers/inherits.js +14 -0
- package/node_modules/@babel/runtime/helpers/inheritsLoose.js +5 -0
- package/node_modules/@babel/runtime/helpers/initializerDefineProperty.js +9 -0
- package/node_modules/@babel/runtime/helpers/initializerWarningHelper.js +4 -0
- package/node_modules/@babel/runtime/helpers/instanceof.js +4 -0
- package/node_modules/@babel/runtime/helpers/interopRequireDefault.js +6 -0
- package/node_modules/@babel/runtime/helpers/interopRequireWildcard.js +27 -0
- package/node_modules/@babel/runtime/helpers/isNativeFunction.js +8 -0
- package/node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js +9 -0
- package/node_modules/@babel/runtime/helpers/iterableToArray.js +4 -0
- package/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js +28 -0
- package/node_modules/@babel/runtime/helpers/jsx.js +22 -0
- package/node_modules/@babel/runtime/helpers/maybeArrayLike.js +9 -0
- package/node_modules/@babel/runtime/helpers/newArrowCheck.js +4 -0
- package/node_modules/@babel/runtime/helpers/nonIterableRest.js +4 -0
- package/node_modules/@babel/runtime/helpers/nonIterableSpread.js +4 -0
- package/node_modules/@babel/runtime/helpers/nullishReceiverError.js +4 -0
- package/node_modules/@babel/runtime/helpers/objectDestructuringEmpty.js +4 -0
- package/node_modules/@babel/runtime/helpers/objectSpread.js +14 -0
- package/node_modules/@babel/runtime/helpers/objectSpread2.js +23 -0
- package/node_modules/@babel/runtime/helpers/objectWithoutProperties.js +13 -0
- package/node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js +10 -0
- package/node_modules/@babel/runtime/helpers/possibleConstructorReturn.js +8 -0
- package/node_modules/@babel/runtime/helpers/readOnlyError.js +4 -0
- package/node_modules/@babel/runtime/helpers/regeneratorRuntime.js +304 -0
- package/node_modules/@babel/runtime/helpers/set.js +22 -0
- package/node_modules/@babel/runtime/helpers/setFunctionName.js +12 -0
- package/node_modules/@babel/runtime/helpers/setPrototypeOf.js +6 -0
- package/node_modules/@babel/runtime/helpers/skipFirstGeneratorNext.js +7 -0
- package/node_modules/@babel/runtime/helpers/slicedToArray.js +8 -0
- package/node_modules/@babel/runtime/helpers/superPropBase.js +6 -0
- package/node_modules/@babel/runtime/helpers/superPropGet.js +9 -0
- package/node_modules/@babel/runtime/helpers/superPropSet.js +6 -0
- package/node_modules/@babel/runtime/helpers/taggedTemplateLiteral.js +8 -0
- package/node_modules/@babel/runtime/helpers/taggedTemplateLiteralLoose.js +4 -0
- package/node_modules/@babel/runtime/helpers/tdz.js +4 -0
- package/node_modules/@babel/runtime/helpers/temporalRef.js +6 -0
- package/node_modules/@babel/runtime/helpers/temporalUndefined.js +2 -0
- package/node_modules/@babel/runtime/helpers/toArray.js +8 -0
- package/node_modules/@babel/runtime/helpers/toConsumableArray.js +8 -0
- package/node_modules/@babel/runtime/helpers/toPrimitive.js +12 -0
- package/node_modules/@babel/runtime/helpers/toPropertyKey.js +7 -0
- package/node_modules/@babel/runtime/helpers/toSetter.js +10 -0
- package/node_modules/@babel/runtime/helpers/typeof.js +10 -0
- package/node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js +9 -0
- package/node_modules/@babel/runtime/helpers/using.js +12 -0
- package/node_modules/@babel/runtime/helpers/usingCtx.js +59 -0
- package/node_modules/@babel/runtime/helpers/wrapAsyncGenerator.js +69 -0
- package/node_modules/@babel/runtime/helpers/wrapNativeSuper.js +27 -0
- package/node_modules/@babel/runtime/helpers/wrapRegExp.js +51 -0
- package/node_modules/@babel/runtime/helpers/writeOnlyError.js +4 -0
- package/node_modules/@babel/runtime/package.json +1056 -0
- package/node_modules/@babel/runtime/regenerator/index.js +15 -0
- package/node_modules/@types/ace/LICENSE +21 -0
- package/node_modules/@types/ace/README.md +15 -0
- package/node_modules/@types/ace/index.d.ts +3135 -0
- package/node_modules/@types/ace/package.json +30 -0
- package/node_modules/@types/body-parser/LICENSE +21 -0
- package/node_modules/@types/body-parser/README.md +15 -0
- package/node_modules/@types/body-parser/index.d.ts +95 -0
- package/node_modules/@types/body-parser/package.json +58 -0
- package/node_modules/@types/connect/LICENSE +21 -0
- package/node_modules/@types/connect/README.md +15 -0
- package/node_modules/@types/connect/index.d.ts +91 -0
- package/node_modules/@types/connect/package.json +32 -0
- package/node_modules/@types/cors/LICENSE +21 -0
- package/node_modules/@types/cors/README.md +75 -0
- package/node_modules/@types/cors/index.d.ts +56 -0
- package/node_modules/@types/cors/package.json +32 -0
- package/node_modules/@types/express/LICENSE +21 -0
- package/node_modules/@types/express/README.md +15 -0
- package/node_modules/@types/express/index.d.ts +128 -0
- package/node_modules/@types/express/package.json +45 -0
- package/node_modules/@types/express-serve-static-core/LICENSE +21 -0
- package/node_modules/@types/express-serve-static-core/README.md +15 -0
- package/node_modules/@types/express-serve-static-core/index.d.ts +1295 -0
- package/node_modules/@types/express-serve-static-core/package.json +50 -0
- package/node_modules/@types/http-errors/LICENSE +21 -0
- package/node_modules/@types/http-errors/README.md +15 -0
- package/node_modules/@types/http-errors/index.d.ts +77 -0
- package/node_modules/@types/http-errors/package.json +30 -0
- package/node_modules/@types/jquery/JQuery.d.ts +13372 -0
- package/node_modules/@types/jquery/JQueryStatic.d.ts +13944 -0
- package/node_modules/@types/jquery/LICENSE +21 -0
- package/node_modules/@types/jquery/README.md +15 -0
- package/node_modules/@types/jquery/dist/jquery.slim.d.ts +3 -0
- package/node_modules/@types/jquery/index.d.ts +7 -0
- package/node_modules/@types/jquery/legacy.d.ts +204 -0
- package/node_modules/@types/jquery/misc.d.ts +7364 -0
- package/node_modules/@types/jquery/package.json +132 -0
- package/node_modules/@types/mime/LICENSE +21 -0
- package/node_modules/@types/mime/Mime.d.ts +10 -0
- package/node_modules/@types/mime/README.md +15 -0
- package/node_modules/@types/mime/index.d.ts +31 -0
- package/node_modules/@types/mime/lite.d.ts +7 -0
- package/node_modules/@types/mime/package.json +30 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/node_modules/@types/node/assert.d.ts +1040 -0
- package/node_modules/@types/node/async_hooks.d.ts +541 -0
- package/node_modules/@types/node/buffer.d.ts +2293 -0
- package/node_modules/@types/node/child_process.d.ts +1544 -0
- package/node_modules/@types/node/cluster.d.ts +578 -0
- package/node_modules/@types/node/console.d.ts +452 -0
- package/node_modules/@types/node/constants.d.ts +19 -0
- package/node_modules/@types/node/crypto.d.ts +4451 -0
- package/node_modules/@types/node/dgram.d.ts +596 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- package/node_modules/@types/node/dns/promises.d.ts +476 -0
- package/node_modules/@types/node/dns.d.ts +865 -0
- package/node_modules/@types/node/dom-events.d.ts +124 -0
- package/node_modules/@types/node/domain.d.ts +170 -0
- package/node_modules/@types/node/events.d.ts +931 -0
- package/node_modules/@types/node/fs/promises.d.ts +1264 -0
- package/node_modules/@types/node/fs.d.ts +4390 -0
- package/node_modules/@types/node/globals.d.ts +510 -0
- package/node_modules/@types/node/globals.global.d.ts +1 -0
- package/node_modules/@types/node/http.d.ts +1921 -0
- package/node_modules/@types/node/http2.d.ts +2418 -0
- package/node_modules/@types/node/https.d.ts +550 -0
- package/node_modules/@types/node/index.d.ts +90 -0
- package/node_modules/@types/node/inspector.d.ts +2746 -0
- package/node_modules/@types/node/module.d.ts +301 -0
- package/node_modules/@types/node/net.d.ts +999 -0
- package/node_modules/@types/node/os.d.ts +495 -0
- package/node_modules/@types/node/package.json +217 -0
- package/node_modules/@types/node/path.d.ts +200 -0
- package/node_modules/@types/node/perf_hooks.d.ts +941 -0
- package/node_modules/@types/node/process.d.ts +1913 -0
- package/node_modules/@types/node/punycode.d.ts +117 -0
- package/node_modules/@types/node/querystring.d.ts +153 -0
- package/node_modules/@types/node/readline/promises.d.ts +150 -0
- package/node_modules/@types/node/readline.d.ts +540 -0
- package/node_modules/@types/node/repl.d.ts +430 -0
- package/node_modules/@types/node/sea.d.ts +153 -0
- package/node_modules/@types/node/sqlite.d.ts +213 -0
- package/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/node_modules/@types/node/stream/web.d.ts +367 -0
- package/node_modules/@types/node/stream.d.ts +1707 -0
- package/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/test.d.ts +2006 -0
- package/node_modules/@types/node/timers/promises.d.ts +97 -0
- package/node_modules/@types/node/timers.d.ts +240 -0
- package/node_modules/@types/node/tls.d.ts +1220 -0
- package/node_modules/@types/node/trace_events.d.ts +197 -0
- package/node_modules/@types/node/tty.d.ts +208 -0
- package/node_modules/@types/node/url.d.ts +969 -0
- package/node_modules/@types/node/util.d.ts +2298 -0
- package/node_modules/@types/node/v8.d.ts +808 -0
- package/node_modules/@types/node/vm.d.ts +922 -0
- package/node_modules/@types/node/wasi.d.ts +181 -0
- package/node_modules/@types/node/worker_threads.d.ts +712 -0
- package/node_modules/@types/node/zlib.d.ts +539 -0
- package/node_modules/@types/node-red/LICENSE +21 -0
- package/node_modules/@types/node-red/README.md +15 -0
- package/node_modules/@types/node-red/index.d.ts +241 -0
- package/node_modules/@types/node-red/package.json +52 -0
- package/node_modules/@types/node-red__editor-api/LICENSE +21 -0
- package/node_modules/@types/node-red__editor-api/README.md +65 -0
- package/node_modules/@types/node-red__editor-api/index.d.ts +46 -0
- package/node_modules/@types/node-red__editor-api/package.json +33 -0
- package/node_modules/@types/node-red__editor-client/LICENSE +21 -0
- package/node_modules/@types/node-red__editor-client/README.md +15 -0
- package/node_modules/@types/node-red__editor-client/index.d.ts +1738 -0
- package/node_modules/@types/node-red__editor-client/package.json +36 -0
- package/node_modules/@types/node-red__registry/LICENSE +21 -0
- package/node_modules/@types/node-red__registry/README.md +15 -0
- package/node_modules/@types/node-red__registry/index.d.ts +452 -0
- package/node_modules/@types/node-red__registry/package.json +34 -0
- package/node_modules/@types/node-red__runtime/LICENSE +21 -0
- package/node_modules/@types/node-red__runtime/README.md +15 -0
- package/node_modules/@types/node-red__runtime/index.d.ts +1458 -0
- package/node_modules/@types/node-red__runtime/package.json +36 -0
- package/node_modules/@types/node-red__util/LICENSE +21 -0
- package/node_modules/@types/node-red__util/README.md +15 -0
- package/node_modules/@types/node-red__util/index.d.ts +557 -0
- package/node_modules/@types/node-red__util/package.json +34 -0
- package/node_modules/@types/passport/LICENSE +21 -0
- package/node_modules/@types/passport/README.md +15 -0
- package/node_modules/@types/passport/index.d.ts +921 -0
- package/node_modules/@types/passport/package.json +57 -0
- package/node_modules/@types/qs/LICENSE +21 -0
- package/node_modules/@types/qs/README.md +15 -0
- package/node_modules/@types/qs/index.d.ts +80 -0
- package/node_modules/@types/qs/package.json +65 -0
- package/node_modules/@types/range-parser/LICENSE +21 -0
- package/node_modules/@types/range-parser/README.md +53 -0
- package/node_modules/@types/range-parser/index.d.ts +34 -0
- package/node_modules/@types/range-parser/package.json +25 -0
- package/node_modules/@types/readable-stream/LICENSE +21 -0
- package/node_modules/@types/readable-stream/README.md +15 -0
- package/node_modules/@types/readable-stream/index.d.ts +677 -0
- package/node_modules/@types/readable-stream/package.json +38 -0
- package/node_modules/@types/send/LICENSE +21 -0
- package/node_modules/@types/send/README.md +15 -0
- package/node_modules/@types/send/index.d.ts +225 -0
- package/node_modules/@types/send/package.json +33 -0
- package/node_modules/@types/serve-static/LICENSE +21 -0
- package/node_modules/@types/serve-static/README.md +15 -0
- package/node_modules/@types/serve-static/index.d.ts +107 -0
- package/node_modules/@types/serve-static/package.json +39 -0
- package/node_modules/@types/sizzle/LICENSE +21 -0
- package/node_modules/@types/sizzle/README.md +15 -0
- package/node_modules/@types/sizzle/index.d.ts +91 -0
- package/node_modules/@types/sizzle/package.json +25 -0
- package/node_modules/@types/ws/LICENSE +21 -0
- package/node_modules/@types/ws/README.md +15 -0
- package/node_modules/@types/ws/index.d.mts +21 -0
- package/node_modules/@types/ws/index.d.ts +401 -0
- package/node_modules/@types/ws/package.json +71 -0
- package/node_modules/abort-controller/LICENSE +21 -0
- package/node_modules/abort-controller/README.md +98 -0
- package/node_modules/abort-controller/browser.js +13 -0
- package/node_modules/abort-controller/browser.mjs +11 -0
- package/node_modules/abort-controller/dist/abort-controller.d.ts +43 -0
- package/node_modules/abort-controller/dist/abort-controller.js +127 -0
- package/node_modules/abort-controller/dist/abort-controller.js.map +1 -0
- package/node_modules/abort-controller/dist/abort-controller.mjs +118 -0
- package/node_modules/abort-controller/dist/abort-controller.mjs.map +1 -0
- package/node_modules/abort-controller/dist/abort-controller.umd.js +5 -0
- package/node_modules/abort-controller/dist/abort-controller.umd.js.map +1 -0
- package/node_modules/abort-controller/package.json +97 -0
- package/node_modules/abort-controller/polyfill.js +21 -0
- package/node_modules/abort-controller/polyfill.mjs +19 -0
- package/node_modules/base64-js/LICENSE +21 -0
- package/node_modules/base64-js/README.md +34 -0
- package/node_modules/base64-js/base64js.min.js +1 -0
- package/node_modules/base64-js/index.d.ts +3 -0
- package/node_modules/base64-js/index.js +150 -0
- package/node_modules/base64-js/package.json +47 -0
- package/node_modules/bl/.github/dependabot.yml +16 -0
- package/node_modules/bl/.github/workflows/test-and-release.yml +61 -0
- package/node_modules/bl/BufferList.d.ts +418 -0
- package/node_modules/bl/BufferList.js +400 -0
- package/node_modules/bl/CHANGELOG.md +142 -0
- package/node_modules/bl/LICENSE.md +13 -0
- package/node_modules/bl/README.md +247 -0
- package/node_modules/bl/bl.js +84 -0
- package/node_modules/bl/index.d.ts +88 -0
- package/node_modules/bl/package.json +123 -0
- package/node_modules/bl/test/convert.js +21 -0
- package/node_modules/bl/test/indexOf.js +492 -0
- package/node_modules/bl/test/isBufferList.js +32 -0
- package/node_modules/bl/test/test.js +948 -0
- package/node_modules/buffer/AUTHORS.md +73 -0
- package/node_modules/buffer/LICENSE +21 -0
- package/node_modules/buffer/README.md +410 -0
- package/node_modules/buffer/index.d.ts +194 -0
- package/node_modules/buffer/index.js +2106 -0
- package/node_modules/buffer/package.json +93 -0
- package/node_modules/buffer-from/LICENSE +21 -0
- package/node_modules/buffer-from/index.js +72 -0
- package/node_modules/buffer-from/package.json +19 -0
- package/node_modules/buffer-from/readme.md +69 -0
- package/node_modules/commist/.github/workflows/ci.yml +27 -0
- package/node_modules/commist/LICENSE +21 -0
- package/node_modules/commist/README.md +113 -0
- package/node_modules/commist/example.js +26 -0
- package/node_modules/commist/index.js +155 -0
- package/node_modules/commist/leven.js +91 -0
- package/node_modules/commist/package.json +28 -0
- package/node_modules/commist/test.js +368 -0
- package/node_modules/concat-stream/LICENSE +24 -0
- package/node_modules/concat-stream/index.js +144 -0
- package/node_modules/concat-stream/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- package/node_modules/concat-stream/node_modules/readable-stream/GOVERNANCE.md +136 -0
- package/node_modules/concat-stream/node_modules/readable-stream/LICENSE +47 -0
- package/node_modules/concat-stream/node_modules/readable-stream/README.md +106 -0
- package/node_modules/concat-stream/node_modules/readable-stream/errors-browser.js +127 -0
- package/node_modules/concat-stream/node_modules/readable-stream/errors.js +116 -0
- package/node_modules/concat-stream/node_modules/readable-stream/experimentalWarning.js +17 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_duplex.js +126 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_passthrough.js +37 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_readable.js +1027 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_transform.js +190 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js +641 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/node_modules/concat-stream/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/node_modules/concat-stream/node_modules/readable-stream/package.json +68 -0
- package/node_modules/concat-stream/node_modules/readable-stream/readable-browser.js +9 -0
- package/node_modules/concat-stream/node_modules/readable-stream/readable.js +16 -0
- package/node_modules/concat-stream/package.json +55 -0
- package/node_modules/concat-stream/readme.md +102 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +60 -0
- package/node_modules/debug/src/browser.js +271 -0
- package/node_modules/debug/src/common.js +274 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/event-target-shim/LICENSE +22 -0
- package/node_modules/event-target-shim/README.md +293 -0
- package/node_modules/event-target-shim/dist/event-target-shim.js +871 -0
- package/node_modules/event-target-shim/dist/event-target-shim.js.map +1 -0
- package/node_modules/event-target-shim/dist/event-target-shim.mjs +862 -0
- package/node_modules/event-target-shim/dist/event-target-shim.mjs.map +1 -0
- package/node_modules/event-target-shim/dist/event-target-shim.umd.js +6 -0
- package/node_modules/event-target-shim/dist/event-target-shim.umd.js.map +1 -0
- package/node_modules/event-target-shim/index.d.ts +399 -0
- package/node_modules/event-target-shim/package.json +82 -0
- package/node_modules/events/.airtap.yml +15 -0
- package/node_modules/events/.github/FUNDING.yml +12 -0
- package/node_modules/events/.travis.yml +18 -0
- package/node_modules/events/History.md +118 -0
- package/node_modules/events/LICENSE +22 -0
- package/node_modules/events/Readme.md +50 -0
- package/node_modules/events/events.js +497 -0
- package/node_modules/events/package.json +37 -0
- package/node_modules/events/security.md +10 -0
- package/node_modules/events/tests/add-listeners.js +111 -0
- package/node_modules/events/tests/check-listener-leaks.js +101 -0
- package/node_modules/events/tests/common.js +104 -0
- package/node_modules/events/tests/errors.js +13 -0
- package/node_modules/events/tests/events-list.js +28 -0
- package/node_modules/events/tests/events-once.js +234 -0
- package/node_modules/events/tests/index.js +64 -0
- package/node_modules/events/tests/legacy-compat.js +16 -0
- package/node_modules/events/tests/listener-count.js +37 -0
- package/node_modules/events/tests/listeners-side-effects.js +56 -0
- package/node_modules/events/tests/listeners.js +168 -0
- package/node_modules/events/tests/max-listeners.js +47 -0
- package/node_modules/events/tests/method-names.js +35 -0
- package/node_modules/events/tests/modify-in-emit.js +90 -0
- package/node_modules/events/tests/num-args.js +60 -0
- package/node_modules/events/tests/once.js +83 -0
- package/node_modules/events/tests/prepend.js +31 -0
- package/node_modules/events/tests/remove-all-listeners.js +133 -0
- package/node_modules/events/tests/remove-listeners.js +212 -0
- package/node_modules/events/tests/set-max-listeners-side-effects.js +31 -0
- package/node_modules/events/tests/special-event-names.js +45 -0
- package/node_modules/events/tests/subclass.js +66 -0
- package/node_modules/events/tests/symbols.js +25 -0
- package/node_modules/fast-unique-numbers/LICENSE +21 -0
- package/node_modules/fast-unique-numbers/README.md +51 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/add-unique-number.d.ts +3 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/add-unique-number.d.ts.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/add-unique-number.js +8 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/add-unique-number.js.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/cache.d.ts +3 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/cache.d.ts.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/cache.js +7 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/cache.js.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/generate-unique-number.d.ts +3 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/generate-unique-number.d.ts.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/generate-unique-number.js +46 -0
- package/node_modules/fast-unique-numbers/build/es2019/factories/generate-unique-number.js.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/module.d.ts +5 -0
- package/node_modules/fast-unique-numbers/build/es2019/module.d.ts.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/module.js +14 -0
- package/node_modules/fast-unique-numbers/build/es2019/module.js.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/add-unique-number-factory.d.ts +4 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/add-unique-number-factory.d.ts.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/add-unique-number-factory.js +2 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/add-unique-number-factory.js.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/add-unique-number-function.d.ts +2 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/add-unique-number-function.d.ts.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/add-unique-number-function.js +2 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/add-unique-number-function.js.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/cache-factory.d.ts +3 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/cache-factory.d.ts.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/cache-factory.js +2 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/cache-factory.js.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/cache-function.d.ts +2 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/cache-function.d.ts.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/cache-function.js +2 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/cache-function.js.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/generate-unique-number-factory.d.ts +4 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/generate-unique-number-factory.d.ts.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/generate-unique-number-factory.js +2 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/generate-unique-number-factory.js.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/generate-unique-number-function.d.ts +2 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/generate-unique-number-function.d.ts.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/generate-unique-number-function.js +2 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/generate-unique-number-function.js.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/index.d.ts +7 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/index.d.ts.map +1 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/index.js +7 -0
- package/node_modules/fast-unique-numbers/build/es2019/types/index.js.map +1 -0
- package/node_modules/fast-unique-numbers/build/es5/bundle.js +76 -0
- package/node_modules/fast-unique-numbers/build/node/factories/add-unique-number.js +14 -0
- package/node_modules/fast-unique-numbers/build/node/factories/cache.js +13 -0
- package/node_modules/fast-unique-numbers/build/node/factories/generate-unique-number.js +52 -0
- package/node_modules/fast-unique-numbers/build/node/module.js +34 -0
- package/node_modules/fast-unique-numbers/build/node/types/add-unique-number-factory.js +5 -0
- package/node_modules/fast-unique-numbers/build/node/types/add-unique-number-function.js +5 -0
- package/node_modules/fast-unique-numbers/build/node/types/cache-factory.js +5 -0
- package/node_modules/fast-unique-numbers/build/node/types/cache-function.js +5 -0
- package/node_modules/fast-unique-numbers/build/node/types/generate-unique-number-factory.js +5 -0
- package/node_modules/fast-unique-numbers/build/node/types/generate-unique-number-function.js +5 -0
- package/node_modules/fast-unique-numbers/build/node/types/index.js +71 -0
- package/node_modules/fast-unique-numbers/package.json +94 -0
- package/node_modules/fast-unique-numbers/src/factories/add-unique-number.ts +11 -0
- package/node_modules/fast-unique-numbers/src/factories/cache.ts +9 -0
- package/node_modules/fast-unique-numbers/src/factories/generate-unique-number.ts +55 -0
- package/node_modules/fast-unique-numbers/src/module.ts +17 -0
- package/node_modules/fast-unique-numbers/src/tsconfig.json +6 -0
- package/node_modules/fast-unique-numbers/src/types/add-unique-number-factory.ts +4 -0
- package/node_modules/fast-unique-numbers/src/types/add-unique-number-function.ts +1 -0
- package/node_modules/fast-unique-numbers/src/types/cache-factory.ts +3 -0
- package/node_modules/fast-unique-numbers/src/types/cache-function.ts +1 -0
- package/node_modules/fast-unique-numbers/src/types/generate-unique-number-factory.ts +7 -0
- package/node_modules/fast-unique-numbers/src/types/generate-unique-number-function.ts +1 -0
- package/node_modules/fast-unique-numbers/src/types/index.ts +6 -0
- package/node_modules/help-me/.github/workflows/ci.yml +28 -0
- package/node_modules/help-me/LICENSE +22 -0
- package/node_modules/help-me/README.md +66 -0
- package/node_modules/help-me/doc/hello.txt +1 -0
- package/node_modules/help-me/doc/help.txt +5 -0
- package/node_modules/help-me/example.js +18 -0
- package/node_modules/help-me/fixture/basic/hello.txt +1 -0
- package/node_modules/help-me/fixture/basic/help.txt +1 -0
- package/node_modules/help-me/fixture/dir/a/b.txt +0 -0
- package/node_modules/help-me/fixture/no-ext/hello +1 -0
- package/node_modules/help-me/fixture/sameprefix/hello world.txt +1 -0
- package/node_modules/help-me/fixture/sameprefix/hello.txt +1 -0
- package/node_modules/help-me/fixture/shortnames/abcde fghi lmno.txt +1 -0
- package/node_modules/help-me/fixture/shortnames/abcde hello.txt +1 -0
- package/node_modules/help-me/fixture/shortnames/hello world.txt +1 -0
- package/node_modules/help-me/help-me.js +134 -0
- package/node_modules/help-me/package.json +36 -0
- package/node_modules/help-me/test.js +316 -0
- package/node_modules/ieee754/LICENSE +11 -0
- package/node_modules/ieee754/README.md +51 -0
- package/node_modules/ieee754/index.d.ts +10 -0
- package/node_modules/ieee754/index.js +85 -0
- package/node_modules/ieee754/package.json +52 -0
- package/node_modules/inherits/LICENSE +16 -0
- package/node_modules/inherits/README.md +42 -0
- package/node_modules/inherits/inherits.js +9 -0
- package/node_modules/inherits/inherits_browser.js +27 -0
- package/node_modules/inherits/package.json +29 -0
- package/node_modules/js-sdsl/CHANGELOG.md +211 -0
- package/node_modules/js-sdsl/LICENSE +21 -0
- package/node_modules/js-sdsl/README.md +296 -0
- package/node_modules/js-sdsl/README.zh-CN.md +298 -0
- package/node_modules/js-sdsl/dist/cjs/container/ContainerBase/index.d.ts +206 -0
- package/node_modules/js-sdsl/dist/cjs/container/ContainerBase/index.js +40 -0
- package/node_modules/js-sdsl/dist/cjs/container/ContainerBase/index.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/HashContainer/Base/index.d.ts +29 -0
- package/node_modules/js-sdsl/dist/cjs/container/HashContainer/Base/index.js +188 -0
- package/node_modules/js-sdsl/dist/cjs/container/HashContainer/Base/index.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/HashContainer/HashMap.d.ts +49 -0
- package/node_modules/js-sdsl/dist/cjs/container/HashContainer/HashMap.js +125 -0
- package/node_modules/js-sdsl/dist/cjs/container/HashContainer/HashMap.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/HashContainer/HashSet.d.ts +39 -0
- package/node_modules/js-sdsl/dist/cjs/container/HashContainer/HashSet.js +94 -0
- package/node_modules/js-sdsl/dist/cjs/container/HashContainer/HashSet.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/OtherContainer/PriorityQueue.d.ts +79 -0
- package/node_modules/js-sdsl/dist/cjs/container/OtherContainer/PriorityQueue.js +118 -0
- package/node_modules/js-sdsl/dist/cjs/container/OtherContainer/PriorityQueue.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/OtherContainer/Queue.d.ts +22 -0
- package/node_modules/js-sdsl/dist/cjs/container/OtherContainer/Queue.js +52 -0
- package/node_modules/js-sdsl/dist/cjs/container/OtherContainer/Queue.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/OtherContainer/Stack.d.ts +22 -0
- package/node_modules/js-sdsl/dist/cjs/container/OtherContainer/Stack.js +42 -0
- package/node_modules/js-sdsl/dist/cjs/container/OtherContainer/Stack.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/RandomIterator.d.ts +9 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/RandomIterator.js +58 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/RandomIterator.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/index.d.ts +67 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/index.js +16 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Base/index.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Deque.d.ts +58 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Deque.js +338 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Deque.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/LinkList.d.ts +58 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/LinkList.js +330 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/LinkList.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Vector.d.ts +40 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Vector.js +158 -0
- package/node_modules/js-sdsl/dist/cjs/container/SequentialContainer/Vector.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/TreeIterator.d.ts +18 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/TreeIterator.js +80 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/TreeIterator.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/TreeNode.d.ts +47 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/TreeNode.js +115 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/TreeNode.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/index.d.ts +58 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/index.js +514 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/Base/index.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/OrderedMap.d.ts +62 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/OrderedMap.js +127 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/OrderedMap.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/OrderedSet.d.ts +54 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/OrderedSet.js +107 -0
- package/node_modules/js-sdsl/dist/cjs/container/TreeContainer/OrderedSet.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/index.d.ts +21 -0
- package/node_modules/js-sdsl/dist/cjs/index.js +102 -0
- package/node_modules/js-sdsl/dist/cjs/index.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/utils/checkObject.d.ts +1 -0
- package/node_modules/js-sdsl/dist/cjs/utils/checkObject.js +13 -0
- package/node_modules/js-sdsl/dist/cjs/utils/checkObject.js.map +1 -0
- package/node_modules/js-sdsl/dist/cjs/utils/throwError.d.ts +1 -0
- package/node_modules/js-sdsl/dist/cjs/utils/throwError.js +12 -0
- package/node_modules/js-sdsl/dist/cjs/utils/throwError.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/ContainerBase/index.d.ts +206 -0
- package/node_modules/js-sdsl/dist/esm/container/ContainerBase/index.js +68 -0
- package/node_modules/js-sdsl/dist/esm/container/ContainerBase/index.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.d.ts +29 -0
- package/node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.js +201 -0
- package/node_modules/js-sdsl/dist/esm/container/HashContainer/Base/index.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.d.ts +49 -0
- package/node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.js +248 -0
- package/node_modules/js-sdsl/dist/esm/container/HashContainer/HashMap.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.d.ts +39 -0
- package/node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.js +223 -0
- package/node_modules/js-sdsl/dist/esm/container/HashContainer/HashSet.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.d.ts +79 -0
- package/node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.js +171 -0
- package/node_modules/js-sdsl/dist/esm/container/OtherContainer/PriorityQueue.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.d.ts +22 -0
- package/node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.js +69 -0
- package/node_modules/js-sdsl/dist/esm/container/OtherContainer/Queue.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.d.ts +22 -0
- package/node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.js +59 -0
- package/node_modules/js-sdsl/dist/esm/container/OtherContainer/Stack.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.d.ts +9 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.js +78 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/RandomIterator.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.d.ts +67 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.js +33 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Base/index.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.d.ts +58 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.js +498 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Deque.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.d.ts +58 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.js +456 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/LinkList.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.d.ts +40 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.js +323 -0
- package/node_modules/js-sdsl/dist/esm/container/SequentialContainer/Vector.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeIterator.d.ts +18 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeIterator.js +98 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeIterator.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.d.ts +47 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js +132 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.d.ts +58 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.js +600 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/index.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.d.ts +62 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.js +265 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedMap.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.d.ts +54 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.js +245 -0
- package/node_modules/js-sdsl/dist/esm/container/TreeContainer/OrderedSet.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/index.d.ts +21 -0
- package/node_modules/js-sdsl/dist/esm/index.js +20 -0
- package/node_modules/js-sdsl/dist/esm/index.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/utils/checkObject.d.ts +1 -0
- package/node_modules/js-sdsl/dist/esm/utils/checkObject.js +5 -0
- package/node_modules/js-sdsl/dist/esm/utils/checkObject.js.map +1 -0
- package/node_modules/js-sdsl/dist/esm/utils/throwError.d.ts +1 -0
- package/node_modules/js-sdsl/dist/esm/utils/throwError.js +4 -0
- package/node_modules/js-sdsl/dist/esm/utils/throwError.js.map +1 -0
- package/node_modules/js-sdsl/dist/umd/js-sdsl.js +3154 -0
- package/node_modules/js-sdsl/dist/umd/js-sdsl.min.js +8 -0
- package/node_modules/js-sdsl/dist/umd/js-sdsl.min.js.map +1 -0
- package/node_modules/js-sdsl/package.json +166 -0
- package/node_modules/jsonata/LICENSE +19 -0
- package/node_modules/jsonata/README.md +70 -0
- package/node_modules/jsonata/jsonata-es5.js +9867 -0
- package/node_modules/jsonata/jsonata-es5.min.js +1 -0
- package/node_modules/jsonata/jsonata.d.ts +53 -0
- package/node_modules/jsonata/jsonata.js +7541 -0
- package/node_modules/jsonata/jsonata.min.js +1 -0
- package/node_modules/jsonata/package.json +62 -0
- package/node_modules/lru-cache/LICENSE +15 -0
- package/node_modules/lru-cache/README.md +331 -0
- package/node_modules/lru-cache/dist/commonjs/index.d.ts +1277 -0
- package/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/index.js +1546 -0
- package/node_modules/lru-cache/dist/commonjs/index.js.map +1 -0
- package/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
- package/node_modules/lru-cache/dist/commonjs/index.min.js.map +7 -0
- package/node_modules/lru-cache/dist/commonjs/package.json +3 -0
- package/node_modules/lru-cache/dist/esm/index.d.ts +1277 -0
- package/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -0
- package/node_modules/lru-cache/dist/esm/index.js +1542 -0
- package/node_modules/lru-cache/dist/esm/index.js.map +1 -0
- package/node_modules/lru-cache/dist/esm/index.min.js +2 -0
- package/node_modules/lru-cache/dist/esm/index.min.js.map +7 -0
- package/node_modules/lru-cache/dist/esm/package.json +3 -0
- package/node_modules/lru-cache/package.json +116 -0
- package/node_modules/minimist/.eslintrc +29 -0
- package/node_modules/minimist/.github/FUNDING.yml +12 -0
- package/node_modules/minimist/.nycrc +14 -0
- package/node_modules/minimist/CHANGELOG.md +298 -0
- package/node_modules/minimist/LICENSE +18 -0
- package/node_modules/minimist/README.md +121 -0
- package/node_modules/minimist/example/parse.js +4 -0
- package/node_modules/minimist/index.js +263 -0
- package/node_modules/minimist/package.json +75 -0
- package/node_modules/minimist/test/all_bool.js +34 -0
- package/node_modules/minimist/test/bool.js +177 -0
- package/node_modules/minimist/test/dash.js +43 -0
- package/node_modules/minimist/test/default_bool.js +37 -0
- package/node_modules/minimist/test/dotted.js +24 -0
- package/node_modules/minimist/test/kv_short.js +32 -0
- package/node_modules/minimist/test/long.js +33 -0
- package/node_modules/minimist/test/num.js +38 -0
- package/node_modules/minimist/test/parse.js +209 -0
- package/node_modules/minimist/test/parse_modified.js +11 -0
- package/node_modules/minimist/test/proto.js +64 -0
- package/node_modules/minimist/test/short.js +69 -0
- package/node_modules/minimist/test/stop_early.js +17 -0
- package/node_modules/minimist/test/unknown.js +104 -0
- package/node_modules/minimist/test/whitespace.js +10 -0
- package/node_modules/mqtt/CONTRIBUTING.md +27 -0
- package/node_modules/mqtt/LICENSE.md +15 -0
- package/node_modules/mqtt/README.md +960 -0
- package/node_modules/mqtt/build/bin/mqtt.d.ts +2 -0
- package/node_modules/mqtt/build/bin/mqtt.js +30 -0
- package/node_modules/mqtt/build/bin/mqtt.js.map +1 -0
- package/node_modules/mqtt/build/bin/pub.d.ts +2 -0
- package/node_modules/mqtt/build/bin/pub.js +147 -0
- package/node_modules/mqtt/build/bin/pub.js.map +1 -0
- package/node_modules/mqtt/build/bin/sub.d.ts +2 -0
- package/node_modules/mqtt/build/bin/sub.js +121 -0
- package/node_modules/mqtt/build/bin/sub.js.map +1 -0
- package/node_modules/mqtt/build/index.d.ts +3 -0
- package/node_modules/mqtt/build/index.js +32 -0
- package/node_modules/mqtt/build/index.js.map +1 -0
- package/node_modules/mqtt/build/lib/BufferedDuplex.d.ts +20 -0
- package/node_modules/mqtt/build/lib/BufferedDuplex.js +78 -0
- package/node_modules/mqtt/build/lib/BufferedDuplex.js.map +1 -0
- package/node_modules/mqtt/build/lib/KeepaliveManager.d.ts +21 -0
- package/node_modules/mqtt/build/lib/KeepaliveManager.js +73 -0
- package/node_modules/mqtt/build/lib/KeepaliveManager.js.map +1 -0
- package/node_modules/mqtt/build/lib/TypedEmitter.d.ts +19 -0
- package/node_modules/mqtt/build/lib/TypedEmitter.js +13 -0
- package/node_modules/mqtt/build/lib/TypedEmitter.js.map +1 -0
- package/node_modules/mqtt/build/lib/client.d.ts +235 -0
- package/node_modules/mqtt/build/lib/client.js +1211 -0
- package/node_modules/mqtt/build/lib/client.js.map +1 -0
- package/node_modules/mqtt/build/lib/connect/ali.d.ts +3 -0
- package/node_modules/mqtt/build/lib/connect/ali.js +108 -0
- package/node_modules/mqtt/build/lib/connect/ali.js.map +1 -0
- package/node_modules/mqtt/build/lib/connect/index.d.ts +10 -0
- package/node_modules/mqtt/build/lib/connect/index.js +192 -0
- package/node_modules/mqtt/build/lib/connect/index.js.map +1 -0
- package/node_modules/mqtt/build/lib/connect/tcp.d.ts +3 -0
- package/node_modules/mqtt/build/lib/connect/tcp.js +18 -0
- package/node_modules/mqtt/build/lib/connect/tcp.js.map +1 -0
- package/node_modules/mqtt/build/lib/connect/tls.d.ts +3 -0
- package/node_modules/mqtt/build/lib/connect/tls.js +38 -0
- package/node_modules/mqtt/build/lib/connect/tls.js.map +1 -0
- package/node_modules/mqtt/build/lib/connect/ws.d.ts +4 -0
- package/node_modules/mqtt/build/lib/connect/ws.js +217 -0
- package/node_modules/mqtt/build/lib/connect/ws.js.map +1 -0
- package/node_modules/mqtt/build/lib/connect/wx.d.ts +6 -0
- package/node_modules/mqtt/build/lib/connect/wx.js +115 -0
- package/node_modules/mqtt/build/lib/connect/wx.js.map +1 -0
- package/node_modules/mqtt/build/lib/default-message-id-provider.d.ts +16 -0
- package/node_modules/mqtt/build/lib/default-message-id-provider.js +24 -0
- package/node_modules/mqtt/build/lib/default-message-id-provider.js.map +1 -0
- package/node_modules/mqtt/build/lib/get-timer.d.ts +8 -0
- package/node_modules/mqtt/build/lib/get-timer.js +53 -0
- package/node_modules/mqtt/build/lib/get-timer.js.map +1 -0
- package/node_modules/mqtt/build/lib/handlers/ack.d.ts +48 -0
- package/node_modules/mqtt/build/lib/handlers/ack.js +131 -0
- package/node_modules/mqtt/build/lib/handlers/ack.js.map +1 -0
- package/node_modules/mqtt/build/lib/handlers/auth.d.ts +3 -0
- package/node_modules/mqtt/build/lib/handlers/auth.js +30 -0
- package/node_modules/mqtt/build/lib/handlers/auth.js.map +1 -0
- package/node_modules/mqtt/build/lib/handlers/connack.d.ts +3 -0
- package/node_modules/mqtt/build/lib/handlers/connack.js +47 -0
- package/node_modules/mqtt/build/lib/handlers/connack.js.map +1 -0
- package/node_modules/mqtt/build/lib/handlers/index.d.ts +3 -0
- package/node_modules/mqtt/build/lib/handlers/index.js +68 -0
- package/node_modules/mqtt/build/lib/handlers/index.js.map +1 -0
- package/node_modules/mqtt/build/lib/handlers/publish.d.ts +3 -0
- package/node_modules/mqtt/build/lib/handlers/publish.js +106 -0
- package/node_modules/mqtt/build/lib/handlers/publish.js.map +1 -0
- package/node_modules/mqtt/build/lib/handlers/pubrel.d.ts +3 -0
- package/node_modules/mqtt/build/lib/handlers/pubrel.js +25 -0
- package/node_modules/mqtt/build/lib/handlers/pubrel.js.map +1 -0
- package/node_modules/mqtt/build/lib/is-browser.d.ts +4 -0
- package/node_modules/mqtt/build/lib/is-browser.js +27 -0
- package/node_modules/mqtt/build/lib/is-browser.js.map +1 -0
- package/node_modules/mqtt/build/lib/shared.d.ts +23 -0
- package/node_modules/mqtt/build/lib/shared.js +41 -0
- package/node_modules/mqtt/build/lib/shared.js.map +1 -0
- package/node_modules/mqtt/build/lib/store.d.ts +24 -0
- package/node_modules/mqtt/build/lib/store.js +80 -0
- package/node_modules/mqtt/build/lib/store.js.map +1 -0
- package/node_modules/mqtt/build/lib/topic-alias-recv.d.ts +9 -0
- package/node_modules/mqtt/build/lib/topic-alias-recv.js +24 -0
- package/node_modules/mqtt/build/lib/topic-alias-recv.js.map +1 -0
- package/node_modules/mqtt/build/lib/topic-alias-send.d.ts +13 -0
- package/node_modules/mqtt/build/lib/topic-alias-send.js +53 -0
- package/node_modules/mqtt/build/lib/topic-alias-send.js.map +1 -0
- package/node_modules/mqtt/build/lib/unique-message-id-provider.d.ts +11 -0
- package/node_modules/mqtt/build/lib/unique-message-id-provider.js +26 -0
- package/node_modules/mqtt/build/lib/unique-message-id-provider.js.map +1 -0
- package/node_modules/mqtt/build/lib/validations.d.ts +2 -0
- package/node_modules/mqtt/build/lib/validations.js +32 -0
- package/node_modules/mqtt/build/lib/validations.js.map +1 -0
- package/node_modules/mqtt/build/mqtt.d.ts +12 -0
- package/node_modules/mqtt/build/mqtt.js +51 -0
- package/node_modules/mqtt/build/mqtt.js.map +1 -0
- package/node_modules/mqtt/build/tsconfig.build.tsbuildinfo +1 -0
- package/node_modules/mqtt/dist/mqtt.esm.js +10 -0
- package/node_modules/mqtt/dist/mqtt.js +21678 -0
- package/node_modules/mqtt/dist/mqtt.min.js +10 -0
- package/node_modules/mqtt/help/help.txt +8 -0
- package/node_modules/mqtt/help/publish.txt +26 -0
- package/node_modules/mqtt/help/subscribe.txt +26 -0
- package/node_modules/mqtt/package.json +171 -0
- package/node_modules/mqtt/src/bin/mqtt.ts +39 -0
- package/node_modules/mqtt/src/bin/pub.ts +174 -0
- package/node_modules/mqtt/src/bin/sub.ts +146 -0
- package/node_modules/mqtt/src/index.ts +4 -0
- package/node_modules/mqtt/src/lib/BufferedDuplex.ts +115 -0
- package/node_modules/mqtt/src/lib/KeepaliveManager.ts +112 -0
- package/node_modules/mqtt/src/lib/TypedEmitter.ts +71 -0
- package/node_modules/mqtt/src/lib/client.ts +2371 -0
- package/node_modules/mqtt/src/lib/connect/ali.ts +127 -0
- package/node_modules/mqtt/src/lib/connect/index.ts +288 -0
- package/node_modules/mqtt/src/lib/connect/tcp.ts +22 -0
- package/node_modules/mqtt/src/lib/connect/tls.ts +54 -0
- package/node_modules/mqtt/src/lib/connect/ws.ts +303 -0
- package/node_modules/mqtt/src/lib/connect/wx.ts +142 -0
- package/node_modules/mqtt/src/lib/default-message-id-provider.ts +99 -0
- package/node_modules/mqtt/src/lib/get-timer.ts +40 -0
- package/node_modules/mqtt/src/lib/handlers/ack.ts +159 -0
- package/node_modules/mqtt/src/lib/handlers/auth.ts +44 -0
- package/node_modules/mqtt/src/lib/handlers/connack.ts +55 -0
- package/node_modules/mqtt/src/lib/handlers/index.ts +74 -0
- package/node_modules/mqtt/src/lib/handlers/publish.ts +183 -0
- package/node_modules/mqtt/src/lib/handlers/pubrel.ts +27 -0
- package/node_modules/mqtt/src/lib/is-browser.ts +46 -0
- package/node_modules/mqtt/src/lib/shared.ts +87 -0
- package/node_modules/mqtt/src/lib/store.ts +166 -0
- package/node_modules/mqtt/src/lib/topic-alias-recv.ts +48 -0
- package/node_modules/mqtt/src/lib/topic-alias-send.ts +96 -0
- package/node_modules/mqtt/src/lib/unique-message-id-provider.ts +64 -0
- package/node_modules/mqtt/src/lib/validations.ts +46 -0
- package/node_modules/mqtt/src/mqtt.ts +28 -0
- package/node_modules/mqtt-packet/.github/workflows/ci.yml +27 -0
- package/node_modules/mqtt-packet/CONTRIBUTING.md +27 -0
- package/node_modules/mqtt-packet/LICENSE.md +13 -0
- package/node_modules/mqtt-packet/README.md +491 -0
- package/node_modules/mqtt-packet/benchmarks/generate.js +26 -0
- package/node_modules/mqtt-packet/benchmarks/generateNet.js +50 -0
- package/node_modules/mqtt-packet/benchmarks/parse.js +19 -0
- package/node_modules/mqtt-packet/benchmarks/writeToStream.js +48 -0
- package/node_modules/mqtt-packet/constants.js +291 -0
- package/node_modules/mqtt-packet/generate.js +57 -0
- package/node_modules/mqtt-packet/mqtt.js +3 -0
- package/node_modules/mqtt-packet/numbers.js +59 -0
- package/node_modules/mqtt-packet/package.json +48 -0
- package/node_modules/mqtt-packet/packet.js +13 -0
- package/node_modules/mqtt-packet/parser.js +809 -0
- package/node_modules/mqtt-packet/test.js +3177 -0
- package/node_modules/mqtt-packet/testRandom.js +86 -0
- package/node_modules/mqtt-packet/types/index.d.ts +257 -0
- package/node_modules/mqtt-packet/writeToStream.js +1127 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +37 -0
- package/node_modules/ms/readme.md +60 -0
- package/node_modules/number-allocator/.github/workflows/nodejs.yml +33 -0
- package/node_modules/number-allocator/CHANGELOG.md +47 -0
- package/node_modules/number-allocator/LICENSE +21 -0
- package/node_modules/number-allocator/README.md +203 -0
- package/node_modules/number-allocator/index.js +7 -0
- package/node_modules/number-allocator/karma.conf.js +63 -0
- package/node_modules/number-allocator/lib/number-allocator.js +249 -0
- package/node_modules/number-allocator/package.json +69 -0
- package/node_modules/number-allocator/test/test.js +337 -0
- package/node_modules/number-allocator/test/typescript/test.ts +24 -0
- package/node_modules/number-allocator/test/typescript/tsconfig.json +14 -0
- package/node_modules/number-allocator/types/index.d.ts +1 -0
- package/node_modules/number-allocator/types/lib/number-allocator.d.ts +65 -0
- package/node_modules/process/.eslintrc +21 -0
- package/node_modules/process/LICENSE +22 -0
- package/node_modules/process/README.md +26 -0
- package/node_modules/process/browser.js +184 -0
- package/node_modules/process/index.js +2 -0
- package/node_modules/process/package.json +27 -0
- package/node_modules/process/test.js +199 -0
- package/node_modules/process-nextick-args/index.js +45 -0
- package/node_modules/process-nextick-args/license.md +19 -0
- package/node_modules/process-nextick-args/package.json +25 -0
- package/node_modules/process-nextick-args/readme.md +18 -0
- package/node_modules/readable-stream/LICENSE +47 -0
- package/node_modules/readable-stream/README.md +116 -0
- package/node_modules/readable-stream/lib/_stream_duplex.js +4 -0
- package/node_modules/readable-stream/lib/_stream_passthrough.js +4 -0
- package/node_modules/readable-stream/lib/_stream_readable.js +4 -0
- package/node_modules/readable-stream/lib/_stream_transform.js +4 -0
- package/node_modules/readable-stream/lib/_stream_writable.js +4 -0
- package/node_modules/readable-stream/lib/internal/streams/add-abort-signal.js +52 -0
- package/node_modules/readable-stream/lib/internal/streams/buffer_list.js +157 -0
- package/node_modules/readable-stream/lib/internal/streams/compose.js +194 -0
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +290 -0
- package/node_modules/readable-stream/lib/internal/streams/duplex.js +143 -0
- package/node_modules/readable-stream/lib/internal/streams/duplexify.js +378 -0
- package/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +284 -0
- package/node_modules/readable-stream/lib/internal/streams/from.js +98 -0
- package/node_modules/readable-stream/lib/internal/streams/lazy_transform.js +51 -0
- package/node_modules/readable-stream/lib/internal/streams/legacy.js +89 -0
- package/node_modules/readable-stream/lib/internal/streams/operators.js +457 -0
- package/node_modules/readable-stream/lib/internal/streams/passthrough.js +39 -0
- package/node_modules/readable-stream/lib/internal/streams/pipeline.js +471 -0
- package/node_modules/readable-stream/lib/internal/streams/readable.js +1288 -0
- package/node_modules/readable-stream/lib/internal/streams/state.js +39 -0
- package/node_modules/readable-stream/lib/internal/streams/transform.js +180 -0
- package/node_modules/readable-stream/lib/internal/streams/utils.js +329 -0
- package/node_modules/readable-stream/lib/internal/streams/writable.js +817 -0
- package/node_modules/readable-stream/lib/internal/validators.js +530 -0
- package/node_modules/readable-stream/lib/ours/browser.js +35 -0
- package/node_modules/readable-stream/lib/ours/errors.js +341 -0
- package/node_modules/readable-stream/lib/ours/index.js +65 -0
- package/node_modules/readable-stream/lib/ours/primordials.js +107 -0
- package/node_modules/readable-stream/lib/ours/util.js +200 -0
- package/node_modules/readable-stream/lib/stream/promises.js +43 -0
- package/node_modules/readable-stream/lib/stream.js +141 -0
- package/node_modules/readable-stream/package.json +86 -0
- package/node_modules/regenerator-runtime/LICENSE +21 -0
- package/node_modules/regenerator-runtime/README.md +31 -0
- package/node_modules/regenerator-runtime/package.json +19 -0
- package/node_modules/regenerator-runtime/path.js +11 -0
- package/node_modules/regenerator-runtime/runtime.js +761 -0
- package/node_modules/reinterval/.npmignore +27 -0
- package/node_modules/reinterval/.travis.yml +20 -0
- package/node_modules/reinterval/LICENSE +22 -0
- package/node_modules/reinterval/README.md +60 -0
- package/node_modules/reinterval/index.js +57 -0
- package/node_modules/reinterval/package.json +32 -0
- package/node_modules/reinterval/tests/test.js +52 -0
- package/node_modules/rfdc/.github/workflows/ci.yml +21 -0
- package/node_modules/rfdc/LICENSE +15 -0
- package/node_modules/rfdc/default.js +3 -0
- package/node_modules/rfdc/index.d.ts +13 -0
- package/node_modules/rfdc/index.js +198 -0
- package/node_modules/rfdc/index.test-d.ts +13 -0
- package/node_modules/rfdc/package.json +73 -0
- package/node_modules/rfdc/readme.md +181 -0
- package/node_modules/rfdc/test/index.js +306 -0
- package/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/safe-buffer/index.js +62 -0
- package/node_modules/safe-buffer/package.json +37 -0
- package/node_modules/split2/LICENSE +13 -0
- package/node_modules/split2/README.md +85 -0
- package/node_modules/split2/bench.js +27 -0
- package/node_modules/split2/index.js +141 -0
- package/node_modules/split2/package.json +39 -0
- package/node_modules/split2/test.js +409 -0
- package/node_modules/string_decoder/LICENSE +48 -0
- package/node_modules/string_decoder/README.md +47 -0
- package/node_modules/string_decoder/lib/string_decoder.js +296 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/index.js +65 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/package.json +51 -0
- package/node_modules/string_decoder/package.json +34 -0
- package/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/node_modules/tslib/LICENSE.txt +12 -0
- package/node_modules/tslib/README.md +164 -0
- package/node_modules/tslib/SECURITY.md +41 -0
- package/node_modules/tslib/modules/index.d.ts +37 -0
- package/node_modules/tslib/modules/index.js +68 -0
- package/node_modules/tslib/modules/package.json +3 -0
- package/node_modules/tslib/package.json +47 -0
- package/node_modules/tslib/tslib.d.ts +453 -0
- package/node_modules/tslib/tslib.es6.html +1 -0
- package/node_modules/tslib/tslib.es6.js +379 -0
- package/node_modules/tslib/tslib.es6.mjs +378 -0
- package/node_modules/tslib/tslib.html +1 -0
- package/node_modules/tslib/tslib.js +429 -0
- package/node_modules/typedarray/.travis.yml +4 -0
- package/node_modules/typedarray/LICENSE +35 -0
- package/node_modules/typedarray/example/tarray.js +4 -0
- package/node_modules/typedarray/index.js +630 -0
- package/node_modules/typedarray/package.json +55 -0
- package/node_modules/typedarray/readme.markdown +61 -0
- package/node_modules/typedarray/test/server/undef_globals.js +19 -0
- package/node_modules/typedarray/test/tarray.js +10 -0
- package/node_modules/undici-types/LICENSE +21 -0
- package/node_modules/undici-types/README.md +6 -0
- package/node_modules/undici-types/agent.d.ts +31 -0
- package/node_modules/undici-types/api.d.ts +43 -0
- package/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/node_modules/undici-types/cache.d.ts +36 -0
- package/node_modules/undici-types/client.d.ts +108 -0
- package/node_modules/undici-types/connector.d.ts +34 -0
- package/node_modules/undici-types/content-type.d.ts +21 -0
- package/node_modules/undici-types/cookies.d.ts +28 -0
- package/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/node_modules/undici-types/dispatcher.d.ts +255 -0
- package/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/node_modules/undici-types/errors.d.ts +149 -0
- package/node_modules/undici-types/eventsource.d.ts +63 -0
- package/node_modules/undici-types/fetch.d.ts +209 -0
- package/node_modules/undici-types/file.d.ts +39 -0
- package/node_modules/undici-types/filereader.d.ts +54 -0
- package/node_modules/undici-types/formdata.d.ts +108 -0
- package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici-types/global-origin.d.ts +7 -0
- package/node_modules/undici-types/handlers.d.ts +15 -0
- package/node_modules/undici-types/header.d.ts +4 -0
- package/node_modules/undici-types/index.d.ts +71 -0
- package/node_modules/undici-types/interceptors.d.ts +15 -0
- package/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/node_modules/undici-types/mock-client.d.ts +25 -0
- package/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/node_modules/undici-types/package.json +55 -0
- package/node_modules/undici-types/patch.d.ts +71 -0
- package/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/node_modules/undici-types/pool.d.ts +39 -0
- package/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/node_modules/undici-types/readable.d.ts +60 -0
- package/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/node_modules/undici-types/util.d.ts +18 -0
- package/node_modules/undici-types/webidl.d.ts +222 -0
- package/node_modules/undici-types/websocket.d.ts +152 -0
- package/node_modules/util-deprecate/History.md +16 -0
- package/node_modules/util-deprecate/LICENSE +24 -0
- package/node_modules/util-deprecate/README.md +53 -0
- package/node_modules/util-deprecate/browser.js +67 -0
- package/node_modules/util-deprecate/node.js +6 -0
- package/node_modules/util-deprecate/package.json +27 -0
- package/node_modules/worker-timers/LICENSE +21 -0
- package/node_modules/worker-timers/README.md +79 -0
- package/node_modules/worker-timers/build/es2019/factories/load-or-return-broker.d.ts +2 -0
- package/node_modules/worker-timers/build/es2019/factories/load-or-return-broker.d.ts.map +1 -0
- package/node_modules/worker-timers/build/es2019/factories/load-or-return-broker.js +15 -0
- package/node_modules/worker-timers/build/es2019/factories/load-or-return-broker.js.map +1 -0
- package/node_modules/worker-timers/build/es2019/module.d.ts +6 -0
- package/node_modules/worker-timers/build/es2019/module.d.ts.map +1 -0
- package/node_modules/worker-timers/build/es2019/module.js +9 -0
- package/node_modules/worker-timers/build/es2019/module.js.map +1 -0
- package/node_modules/worker-timers/build/es2019/worker/worker.d.ts +2 -0
- package/node_modules/worker-timers/build/es2019/worker/worker.d.ts.map +1 -0
- package/node_modules/worker-timers/build/es2019/worker/worker.js +3 -0
- package/node_modules/worker-timers/build/es2019/worker/worker.js.map +1 -0
- package/node_modules/worker-timers/build/es5/bundle.js +50 -0
- package/node_modules/worker-timers/package.json +106 -0
- package/node_modules/worker-timers/src/factories/load-or-return-broker.ts +19 -0
- package/node_modules/worker-timers/src/module.ts +13 -0
- package/node_modules/worker-timers/src/tsconfig.json +6 -0
- package/node_modules/worker-timers/src/worker/worker.ts +2 -0
- package/node_modules/worker-timers-broker/LICENSE +21 -0
- package/node_modules/worker-timers-broker/README.md +5 -0
- package/node_modules/worker-timers-broker/build/es2019/guards/call-notification.d.ts +3 -0
- package/node_modules/worker-timers-broker/build/es2019/guards/call-notification.d.ts.map +1 -0
- package/node_modules/worker-timers-broker/build/es2019/guards/call-notification.js +4 -0
- package/node_modules/worker-timers-broker/build/es2019/guards/call-notification.js.map +1 -0
- package/node_modules/worker-timers-broker/build/es2019/guards/clear-response.d.ts +3 -0
- package/node_modules/worker-timers-broker/build/es2019/guards/clear-response.d.ts.map +1 -0
- package/node_modules/worker-timers-broker/build/es2019/guards/clear-response.js +4 -0
- package/node_modules/worker-timers-broker/build/es2019/guards/clear-response.js.map +1 -0
- package/node_modules/worker-timers-broker/build/es2019/module.d.ts +7 -0
- package/node_modules/worker-timers-broker/build/es2019/module.d.ts.map +1 -0
- package/node_modules/worker-timers-broker/build/es2019/module.js +142 -0
- package/node_modules/worker-timers-broker/build/es2019/module.js.map +1 -0
- package/node_modules/worker-timers-broker/build/es5/bundle.js +162 -0
- package/node_modules/worker-timers-broker/package.json +84 -0
- package/node_modules/worker-timers-broker/src/guards/call-notification.ts +5 -0
- package/node_modules/worker-timers-broker/src/guards/clear-response.ts +5 -0
- package/node_modules/worker-timers-broker/src/module.ts +173 -0
- package/node_modules/worker-timers-broker/src/tsconfig.json +6 -0
- package/node_modules/worker-timers-worker/LICENSE +21 -0
- package/node_modules/worker-timers-worker/README.md +5 -0
- package/node_modules/worker-timers-worker/build/es2019/helpers/timer.d.ts +5 -0
- package/node_modules/worker-timers-worker/build/es2019/helpers/timer.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/helpers/timer.js +50 -0
- package/node_modules/worker-timers-worker/build/es2019/helpers/timer.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/broker-event.d.ts +5 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/broker-event.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/broker-event.js +2 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/broker-event.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/call-notification.d.ts +10 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/call-notification.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/call-notification.js +2 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/call-notification.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/clear-request.d.ts +10 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/clear-request.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/clear-request.js +2 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/clear-request.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/clear-response.d.ts +5 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/clear-response.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/clear-response.js +2 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/clear-response.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/error-notification.d.ts +8 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/error-notification.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/error-notification.js +2 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/error-notification.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/error-response.d.ts +8 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/error-response.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/error-response.js +2 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/error-response.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/index.d.ts +9 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/index.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/index.js +9 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/index.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/set-notification.d.ts +12 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/set-notification.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/set-notification.js +2 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/set-notification.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/worker-event.d.ts +5 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/worker-event.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/worker-event.js +2 -0
- package/node_modules/worker-timers-worker/build/es2019/interfaces/worker-event.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/module.d.ts +3 -0
- package/node_modules/worker-timers-worker/build/es2019/module.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/module.js +50 -0
- package/node_modules/worker-timers-worker/build/es2019/module.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/types/broker-message.d.ts +3 -0
- package/node_modules/worker-timers-worker/build/es2019/types/broker-message.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/types/broker-message.js +2 -0
- package/node_modules/worker-timers-worker/build/es2019/types/broker-message.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/types/index.d.ts +4 -0
- package/node_modules/worker-timers-worker/build/es2019/types/index.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/types/index.js +4 -0
- package/node_modules/worker-timers-worker/build/es2019/types/index.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/types/timer-type.d.ts +2 -0
- package/node_modules/worker-timers-worker/build/es2019/types/timer-type.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/types/timer-type.js +2 -0
- package/node_modules/worker-timers-worker/build/es2019/types/timer-type.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/types/worker-message.d.ts +3 -0
- package/node_modules/worker-timers-worker/build/es2019/types/worker-message.d.ts.map +1 -0
- package/node_modules/worker-timers-worker/build/es2019/types/worker-message.js +2 -0
- package/node_modules/worker-timers-worker/build/es2019/types/worker-message.js.map +1 -0
- package/node_modules/worker-timers-worker/build/es5/bundle.js +117 -0
- package/node_modules/worker-timers-worker/package.json +91 -0
- package/node_modules/worker-timers-worker/src/helpers/timer.ts +68 -0
- package/node_modules/worker-timers-worker/src/interfaces/broker-event.ts +5 -0
- package/node_modules/worker-timers-worker/src/interfaces/call-notification.ts +13 -0
- package/node_modules/worker-timers-worker/src/interfaces/clear-request.ts +13 -0
- package/node_modules/worker-timers-worker/src/interfaces/clear-response.ts +5 -0
- package/node_modules/worker-timers-worker/src/interfaces/error-notification.ts +9 -0
- package/node_modules/worker-timers-worker/src/interfaces/error-response.ts +9 -0
- package/node_modules/worker-timers-worker/src/interfaces/index.ts +8 -0
- package/node_modules/worker-timers-worker/src/interfaces/set-notification.ts +17 -0
- package/node_modules/worker-timers-worker/src/interfaces/worker-event.ts +5 -0
- package/node_modules/worker-timers-worker/src/module.ts +54 -0
- package/node_modules/worker-timers-worker/src/tsconfig.json +6 -0
- package/node_modules/worker-timers-worker/src/types/broker-message.ts +3 -0
- package/node_modules/worker-timers-worker/src/types/index.ts +3 -0
- package/node_modules/worker-timers-worker/src/types/timer-type.ts +1 -0
- package/node_modules/worker-timers-worker/src/types/worker-message.ts +3 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +13 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +18 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +514 -0
- package/node_modules/ws/lib/receiver.js +706 -0
- package/node_modules/ws/lib/sender.js +602 -0
- package/node_modules/ws/lib/stream.js +159 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +540 -0
- package/node_modules/ws/lib/websocket.js +1388 -0
- package/node_modules/ws/package.json +69 -0
- package/node_modules/ws/wrapper.mjs +8 -0
- package/package.json +51 -0
|
@@ -0,0 +1,2371 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module dependencies
|
|
3
|
+
*/
|
|
4
|
+
import TopicAliasRecv from './topic-alias-recv'
|
|
5
|
+
import mqttPacket, {
|
|
6
|
+
IAuthPacket,
|
|
7
|
+
IConnackPacket,
|
|
8
|
+
IDisconnectPacket,
|
|
9
|
+
IPublishPacket,
|
|
10
|
+
ISubscribePacket,
|
|
11
|
+
ISubscription,
|
|
12
|
+
IUnsubscribePacket,
|
|
13
|
+
Packet,
|
|
14
|
+
QoS,
|
|
15
|
+
ISubackPacket,
|
|
16
|
+
IConnectPacket,
|
|
17
|
+
} from 'mqtt-packet'
|
|
18
|
+
import DefaultMessageIdProvider, {
|
|
19
|
+
IMessageIdProvider,
|
|
20
|
+
} from './default-message-id-provider'
|
|
21
|
+
import { DuplexOptions, Writable } from 'readable-stream'
|
|
22
|
+
import clone from 'rfdc/default'
|
|
23
|
+
import * as validations from './validations'
|
|
24
|
+
import _debug from 'debug'
|
|
25
|
+
import Store, { IStore } from './store'
|
|
26
|
+
import handlePacket from './handlers'
|
|
27
|
+
import { ClientOptions } from 'ws'
|
|
28
|
+
import { ClientRequestArgs } from 'http'
|
|
29
|
+
import {
|
|
30
|
+
DoneCallback,
|
|
31
|
+
ErrorWithReasonCode,
|
|
32
|
+
GenericCallback,
|
|
33
|
+
IStream,
|
|
34
|
+
MQTTJS_VERSION,
|
|
35
|
+
StreamBuilder,
|
|
36
|
+
TimerVariant,
|
|
37
|
+
VoidCallback,
|
|
38
|
+
nextTick,
|
|
39
|
+
} from './shared'
|
|
40
|
+
import TopicAliasSend from './topic-alias-send'
|
|
41
|
+
import { TypedEventEmitter } from './TypedEmitter'
|
|
42
|
+
import KeepaliveManager from './KeepaliveManager'
|
|
43
|
+
import isBrowser, { isWebWorker } from './is-browser'
|
|
44
|
+
import { Timer } from './get-timer'
|
|
45
|
+
|
|
46
|
+
const setImmediate =
|
|
47
|
+
globalThis.setImmediate ||
|
|
48
|
+
(((...args: any[]) => {
|
|
49
|
+
const callback = args.shift()
|
|
50
|
+
nextTick(() => {
|
|
51
|
+
callback(...args)
|
|
52
|
+
})
|
|
53
|
+
}) as typeof globalThis.setImmediate)
|
|
54
|
+
|
|
55
|
+
const defaultConnectOptions: IClientOptions = {
|
|
56
|
+
keepalive: 60,
|
|
57
|
+
reschedulePings: true,
|
|
58
|
+
protocolId: 'MQTT',
|
|
59
|
+
protocolVersion: 4,
|
|
60
|
+
reconnectPeriod: 1000,
|
|
61
|
+
connectTimeout: 30 * 1000,
|
|
62
|
+
clean: true,
|
|
63
|
+
resubscribe: true,
|
|
64
|
+
writeCache: true,
|
|
65
|
+
timerVariant: 'auto',
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type BaseMqttProtocol =
|
|
69
|
+
| 'wss'
|
|
70
|
+
| 'ws'
|
|
71
|
+
| 'mqtt'
|
|
72
|
+
| 'mqtts'
|
|
73
|
+
| 'tcp'
|
|
74
|
+
| 'ssl'
|
|
75
|
+
| 'wx'
|
|
76
|
+
| 'wxs'
|
|
77
|
+
| 'ali'
|
|
78
|
+
| 'alis'
|
|
79
|
+
|
|
80
|
+
// create a type that allows all MqttProtocol + `+unix` string
|
|
81
|
+
export type MqttProtocolWithUnix = `${BaseMqttProtocol}+unix`
|
|
82
|
+
|
|
83
|
+
export type MqttProtocol = BaseMqttProtocol | MqttProtocolWithUnix
|
|
84
|
+
|
|
85
|
+
export type StorePutCallback = () => void
|
|
86
|
+
|
|
87
|
+
export interface ISecureClientOptions {
|
|
88
|
+
/**
|
|
89
|
+
* optional private keys in PEM format
|
|
90
|
+
*/
|
|
91
|
+
key?: string | string[] | Buffer | Buffer[] | any[]
|
|
92
|
+
keyPath?: string
|
|
93
|
+
/**
|
|
94
|
+
* optional cert chains in PEM format
|
|
95
|
+
*/
|
|
96
|
+
cert?: string | string[] | Buffer | Buffer[]
|
|
97
|
+
certPath?: string
|
|
98
|
+
/**
|
|
99
|
+
* Optionally override the trusted CA certificates in PEM format
|
|
100
|
+
*/
|
|
101
|
+
ca?: string | string[] | Buffer | Buffer[]
|
|
102
|
+
caPaths?: string | string[]
|
|
103
|
+
|
|
104
|
+
rejectUnauthorized?: boolean
|
|
105
|
+
/**
|
|
106
|
+
* optional alpn's
|
|
107
|
+
*/
|
|
108
|
+
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type AckHandler = (
|
|
112
|
+
topic: string,
|
|
113
|
+
message: Buffer,
|
|
114
|
+
packet: any,
|
|
115
|
+
cb: (error: Error | number, code?: number) => void,
|
|
116
|
+
) => void
|
|
117
|
+
|
|
118
|
+
export interface IClientOptions extends ISecureClientOptions {
|
|
119
|
+
/** CLIENT PROPERTIES */
|
|
120
|
+
|
|
121
|
+
/** Encoding to use. Example 'binary' */
|
|
122
|
+
encoding?: BufferEncoding
|
|
123
|
+
/** Set browser buffer size. Default to 512KB */
|
|
124
|
+
browserBufferSize?: number
|
|
125
|
+
/** used in ws protocol to set `objectMode` */
|
|
126
|
+
binary?: boolean
|
|
127
|
+
/** Used on ali protocol */
|
|
128
|
+
my?: any
|
|
129
|
+
/** Manually call `connect` after creating client instance */
|
|
130
|
+
manualConnect?: boolean
|
|
131
|
+
/** Custom auth packet properties */
|
|
132
|
+
authPacket?: Partial<IAuthPacket>
|
|
133
|
+
/** Disable/Enable writeToStream.cacheNumbers */
|
|
134
|
+
writeCache?: boolean
|
|
135
|
+
/** Should be set to `host` */
|
|
136
|
+
servername?: string
|
|
137
|
+
/** The default protocol to use when using `servers` and no protocol is specified */
|
|
138
|
+
defaultProtocol?: MqttProtocol
|
|
139
|
+
/** Support clientId passed in the query string of the url */
|
|
140
|
+
query?: Record<string, string>
|
|
141
|
+
/** Auth string in the format <username>:<password> */
|
|
142
|
+
auth?: string
|
|
143
|
+
/** Custom ack handler */
|
|
144
|
+
customHandleAcks?: AckHandler
|
|
145
|
+
/** Broker port */
|
|
146
|
+
port?: number
|
|
147
|
+
/** Broker host. Does NOT include port */
|
|
148
|
+
host?: string
|
|
149
|
+
/** @deprecated use `host instead */
|
|
150
|
+
hostname?: string
|
|
151
|
+
/** Set to true if the connection is to a unix socket */
|
|
152
|
+
unixSocket?: boolean
|
|
153
|
+
/** Websocket `path` added as suffix or Unix socket path when `unixSocket` option is true */
|
|
154
|
+
path?: string
|
|
155
|
+
/** The `MqttProtocol` to use */
|
|
156
|
+
protocol?: MqttProtocol
|
|
157
|
+
|
|
158
|
+
/** Websocket options */
|
|
159
|
+
wsOptions?: ClientOptions | ClientRequestArgs | DuplexOptions
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 1000 milliseconds, interval between two reconnections
|
|
163
|
+
*/
|
|
164
|
+
reconnectPeriod?: number
|
|
165
|
+
/**
|
|
166
|
+
* 30 * 1000 milliseconds, time to wait before a CONNACK is received
|
|
167
|
+
*/
|
|
168
|
+
connectTimeout?: number
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* a Store for the incoming packets
|
|
172
|
+
*/
|
|
173
|
+
incomingStore?: IStore
|
|
174
|
+
/**
|
|
175
|
+
* a Store for the outgoing packets
|
|
176
|
+
*/
|
|
177
|
+
outgoingStore?: IStore
|
|
178
|
+
|
|
179
|
+
/** Enable/Disable queue for QoS 0 packets */
|
|
180
|
+
queueQoSZero?: boolean
|
|
181
|
+
|
|
182
|
+
/** Custom log function, default uses `debug` */
|
|
183
|
+
log?: (...args: any[]) => void
|
|
184
|
+
|
|
185
|
+
/** automatically use topic alias */
|
|
186
|
+
autoUseTopicAlias?: boolean
|
|
187
|
+
|
|
188
|
+
/** automatically assign topic alias */
|
|
189
|
+
autoAssignTopicAlias?: boolean
|
|
190
|
+
|
|
191
|
+
/** Set to false to disable ping reschedule. When enabled ping messages are rescheduled on each message sent */
|
|
192
|
+
reschedulePings?: boolean
|
|
193
|
+
|
|
194
|
+
/** List of broker servers. On each reconnect try the next server will be used */
|
|
195
|
+
servers?: Array<{
|
|
196
|
+
host: string
|
|
197
|
+
port: number
|
|
198
|
+
protocol?:
|
|
199
|
+
| 'wss'
|
|
200
|
+
| 'ws'
|
|
201
|
+
| 'mqtt'
|
|
202
|
+
| 'mqtts'
|
|
203
|
+
| 'tcp'
|
|
204
|
+
| 'ssl'
|
|
205
|
+
| 'wx'
|
|
206
|
+
| 'wxs'
|
|
207
|
+
}>
|
|
208
|
+
/**
|
|
209
|
+
* true, set to false to disable re-subscribe functionality
|
|
210
|
+
*/
|
|
211
|
+
resubscribe?: boolean
|
|
212
|
+
|
|
213
|
+
/** when defined this function will be called to transform the url string generated by MqttClient from provided options */
|
|
214
|
+
transformWsUrl?: (
|
|
215
|
+
url: string,
|
|
216
|
+
options: IClientOptions,
|
|
217
|
+
client: MqttClient,
|
|
218
|
+
) => string
|
|
219
|
+
|
|
220
|
+
/** when defined this function will be called to create the Websocket instance, used to add custom protocols or websocket implementations */
|
|
221
|
+
createWebsocket?: (
|
|
222
|
+
url: string,
|
|
223
|
+
websocketSubProtocols: string[],
|
|
224
|
+
options: IClientOptions,
|
|
225
|
+
) => any
|
|
226
|
+
|
|
227
|
+
/** Custom message id provider */
|
|
228
|
+
messageIdProvider?: IMessageIdProvider
|
|
229
|
+
|
|
230
|
+
/** When using websockets, this is the timeout used when writing to socket. Default 1000 (1s) */
|
|
231
|
+
browserBufferTimeout?: number
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* When using websockets, this sets the `objectMode` option.
|
|
235
|
+
* When in objectMode, streams can push Strings and Buffers
|
|
236
|
+
* as well as any other JavaScript object.
|
|
237
|
+
* Another major difference is that when in objectMode,
|
|
238
|
+
* the internal buffering algorithm counts objects rather than bytes.
|
|
239
|
+
* This means if we have a Transform stream with the highWaterMark option set to 5,
|
|
240
|
+
* the stream will only buffer a maximum of 5 objects internally
|
|
241
|
+
*/
|
|
242
|
+
objectMode?: boolean
|
|
243
|
+
|
|
244
|
+
/** CONNECT PACKET PROPERTIES */
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* 'mqttjs_' + Math.random().toString(16).substr(2, 8)
|
|
248
|
+
*/
|
|
249
|
+
clientId?: string
|
|
250
|
+
/**
|
|
251
|
+
* 3=MQTT 3.1 4=MQTT 3.1.1 5=MQTT 5.0. Defaults to 4
|
|
252
|
+
*/
|
|
253
|
+
protocolVersion?: IConnectPacket['protocolVersion']
|
|
254
|
+
/**
|
|
255
|
+
* 'MQTT'
|
|
256
|
+
*/
|
|
257
|
+
protocolId?: IConnectPacket['protocolId']
|
|
258
|
+
/**
|
|
259
|
+
* true, set to false to receive QoS 1 and 2 messages while offline
|
|
260
|
+
*/
|
|
261
|
+
clean?: boolean
|
|
262
|
+
/**
|
|
263
|
+
* 60 seconds, set to 0 to disable
|
|
264
|
+
*/
|
|
265
|
+
keepalive?: number
|
|
266
|
+
/**
|
|
267
|
+
* the username required by your broker, if any
|
|
268
|
+
*/
|
|
269
|
+
username?: string
|
|
270
|
+
/**
|
|
271
|
+
* the password required by your broker, if any
|
|
272
|
+
*/
|
|
273
|
+
password?: Buffer | string
|
|
274
|
+
/**
|
|
275
|
+
* a message that will sent by the broker automatically when the client disconnect badly.
|
|
276
|
+
*/
|
|
277
|
+
will?: IConnectPacket['will']
|
|
278
|
+
/** see `connect` packet: https://github.com/mqttjs/mqtt-packet/blob/master/types/index.d.ts#L65 */
|
|
279
|
+
properties?: IConnectPacket['properties']
|
|
280
|
+
/**
|
|
281
|
+
* @description 'auto', set to 'native' or 'worker' if you're having issues with 'auto' detection
|
|
282
|
+
* or pass a custom timer object
|
|
283
|
+
*/
|
|
284
|
+
timerVariant?: TimerVariant | Timer
|
|
285
|
+
/**
|
|
286
|
+
* false, set to true to force the use of native WebSocket if you're having issues with the detection
|
|
287
|
+
*/
|
|
288
|
+
forceNativeWebSocket?: boolean
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export interface IClientPublishOptions {
|
|
292
|
+
/**
|
|
293
|
+
* the QoS
|
|
294
|
+
*/
|
|
295
|
+
qos?: QoS
|
|
296
|
+
/**
|
|
297
|
+
* the retain flag
|
|
298
|
+
*/
|
|
299
|
+
retain?: boolean
|
|
300
|
+
/**
|
|
301
|
+
* whether or not mark a message as duplicate
|
|
302
|
+
*/
|
|
303
|
+
dup?: boolean
|
|
304
|
+
/*
|
|
305
|
+
* MQTT 5.0 properties object
|
|
306
|
+
*/
|
|
307
|
+
properties?: IPublishPacket['properties']
|
|
308
|
+
/**
|
|
309
|
+
* callback called when message is put into `outgoingStore`
|
|
310
|
+
*/
|
|
311
|
+
cbStorePut?: StorePutCallback
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export interface IClientReconnectOptions {
|
|
315
|
+
/**
|
|
316
|
+
* a Store for the incoming packets
|
|
317
|
+
*/
|
|
318
|
+
incomingStore?: Store
|
|
319
|
+
/**
|
|
320
|
+
* a Store for the outgoing packets
|
|
321
|
+
*/
|
|
322
|
+
outgoingStore?: Store
|
|
323
|
+
}
|
|
324
|
+
export interface IClientSubscribeProperties {
|
|
325
|
+
/*
|
|
326
|
+
* MQTT 5.0 properties object of subscribe
|
|
327
|
+
* */
|
|
328
|
+
properties?: ISubscribePacket['properties']
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export interface IClientSubscribeOptions extends IClientSubscribeProperties {
|
|
332
|
+
/**
|
|
333
|
+
* the QoS
|
|
334
|
+
*/
|
|
335
|
+
qos: QoS
|
|
336
|
+
/*
|
|
337
|
+
* no local flag
|
|
338
|
+
* */
|
|
339
|
+
nl?: boolean
|
|
340
|
+
/*
|
|
341
|
+
* Retain As Published flag
|
|
342
|
+
* */
|
|
343
|
+
rap?: boolean
|
|
344
|
+
/*
|
|
345
|
+
* Retain Handling option
|
|
346
|
+
* */
|
|
347
|
+
rh?: number
|
|
348
|
+
}
|
|
349
|
+
export interface ISubscriptionRequest extends IClientSubscribeOptions {
|
|
350
|
+
/**
|
|
351
|
+
* is a subscribed to topic
|
|
352
|
+
*/
|
|
353
|
+
topic: string
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface ISubscriptionGrant
|
|
357
|
+
extends Omit<ISubscriptionRequest, 'qos' | 'properties'> {
|
|
358
|
+
/**
|
|
359
|
+
* is the granted qos level on it, may return 128 on error
|
|
360
|
+
*/
|
|
361
|
+
qos: QoS | 128
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export type ISubscriptionMap = {
|
|
365
|
+
/**
|
|
366
|
+
* object which has topic names as object keys and as value the options, like {'test1': {qos: 0}, 'test2': {qos: 2}}.
|
|
367
|
+
*/
|
|
368
|
+
[topic: string]: IClientSubscribeOptions
|
|
369
|
+
} & {
|
|
370
|
+
resubscribe?: boolean
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export interface IClientUnsubscribeProperties {
|
|
374
|
+
/*
|
|
375
|
+
* MQTT 5.0 properties object for unsubscribe
|
|
376
|
+
* */
|
|
377
|
+
properties?: IUnsubscribePacket['properties']
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export { IConnackPacket, IDisconnectPacket, IPublishPacket, Packet }
|
|
381
|
+
export type OnConnectCallback = (packet: IConnackPacket) => void
|
|
382
|
+
export type OnDisconnectCallback = (packet: IDisconnectPacket) => void
|
|
383
|
+
export type ClientSubscribeCallback = (
|
|
384
|
+
err: Error | null,
|
|
385
|
+
granted?: ISubscriptionGrant[],
|
|
386
|
+
packet?: ISubackPacket,
|
|
387
|
+
) => void
|
|
388
|
+
export type OnMessageCallback = (
|
|
389
|
+
topic: string,
|
|
390
|
+
payload: Buffer,
|
|
391
|
+
packet: IPublishPacket,
|
|
392
|
+
) => void
|
|
393
|
+
export type OnPacketCallback = (packet: Packet) => void
|
|
394
|
+
export type OnCloseCallback = () => void
|
|
395
|
+
export type OnErrorCallback = (error: Error | ErrorWithReasonCode) => void
|
|
396
|
+
export type PacketCallback = (
|
|
397
|
+
error?: Error | ErrorWithReasonCode,
|
|
398
|
+
packet?: Packet,
|
|
399
|
+
) => any
|
|
400
|
+
export type CloseCallback = (error?: Error) => void
|
|
401
|
+
|
|
402
|
+
export interface MqttClientEventCallbacks {
|
|
403
|
+
connect: OnConnectCallback
|
|
404
|
+
message: OnMessageCallback
|
|
405
|
+
packetsend: OnPacketCallback
|
|
406
|
+
packetreceive: OnPacketCallback
|
|
407
|
+
disconnect: OnDisconnectCallback
|
|
408
|
+
error: OnErrorCallback
|
|
409
|
+
close: OnCloseCallback
|
|
410
|
+
end: VoidCallback
|
|
411
|
+
reconnect: VoidCallback
|
|
412
|
+
offline: VoidCallback
|
|
413
|
+
outgoingEmpty: VoidCallback
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* MqttClient constructor
|
|
418
|
+
*
|
|
419
|
+
* @param {Stream} stream - stream
|
|
420
|
+
* @param {Object} [options] - connection options
|
|
421
|
+
* (see Connection#connect)
|
|
422
|
+
*/
|
|
423
|
+
export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbacks> {
|
|
424
|
+
public static VERSION = MQTTJS_VERSION
|
|
425
|
+
|
|
426
|
+
/** Public fields */
|
|
427
|
+
|
|
428
|
+
/** It's true when client is connected to broker */
|
|
429
|
+
public connected: boolean
|
|
430
|
+
|
|
431
|
+
public disconnecting: boolean
|
|
432
|
+
|
|
433
|
+
public disconnected: boolean
|
|
434
|
+
|
|
435
|
+
public reconnecting: boolean
|
|
436
|
+
|
|
437
|
+
public incomingStore: IStore
|
|
438
|
+
|
|
439
|
+
public outgoingStore: IStore
|
|
440
|
+
|
|
441
|
+
public options: IClientOptions
|
|
442
|
+
|
|
443
|
+
public queueQoSZero: boolean
|
|
444
|
+
|
|
445
|
+
public _reconnectCount: number
|
|
446
|
+
|
|
447
|
+
public log: (...args: any[]) => void
|
|
448
|
+
|
|
449
|
+
public messageIdProvider: IMessageIdProvider
|
|
450
|
+
|
|
451
|
+
public outgoing: Record<
|
|
452
|
+
number,
|
|
453
|
+
{ volatile: boolean; cb: (err: Error, packet?: Packet) => void }
|
|
454
|
+
>
|
|
455
|
+
|
|
456
|
+
public messageIdToTopic: Record<number, string[]>
|
|
457
|
+
|
|
458
|
+
public noop: (error?: any) => void
|
|
459
|
+
|
|
460
|
+
public keepaliveManager: KeepaliveManager
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* The connection to the Broker. In browsers env this also have `socket` property
|
|
464
|
+
* set to the `WebSocket` instance.
|
|
465
|
+
*/
|
|
466
|
+
public stream: IStream
|
|
467
|
+
|
|
468
|
+
public queue: { packet: Packet; cb: PacketCallback }[]
|
|
469
|
+
|
|
470
|
+
/* Private fields */
|
|
471
|
+
|
|
472
|
+
/** Function used to build the stream */
|
|
473
|
+
private streamBuilder: StreamBuilder
|
|
474
|
+
|
|
475
|
+
private _resubscribeTopics: ISubscriptionMap
|
|
476
|
+
|
|
477
|
+
private connackTimer: NodeJS.Timeout
|
|
478
|
+
|
|
479
|
+
private reconnectTimer: NodeJS.Timeout
|
|
480
|
+
|
|
481
|
+
private _storeProcessing: boolean
|
|
482
|
+
|
|
483
|
+
/** keep a reference of packets that have been successfully processed from outgoing store */
|
|
484
|
+
private _packetIdsDuringStoreProcessing: Record<number, boolean>
|
|
485
|
+
|
|
486
|
+
private _storeProcessingQueue: {
|
|
487
|
+
invoke: () => any
|
|
488
|
+
cbStorePut?: DoneCallback
|
|
489
|
+
callback: GenericCallback<any>
|
|
490
|
+
}[]
|
|
491
|
+
|
|
492
|
+
private _firstConnection: boolean
|
|
493
|
+
|
|
494
|
+
private topicAliasRecv: TopicAliasRecv
|
|
495
|
+
|
|
496
|
+
private topicAliasSend: TopicAliasSend
|
|
497
|
+
|
|
498
|
+
private _deferredReconnect: () => void
|
|
499
|
+
|
|
500
|
+
private connackPacket: IConnackPacket
|
|
501
|
+
|
|
502
|
+
public static defaultId() {
|
|
503
|
+
return `mqttjs_${Math.random().toString(16).substr(2, 8)}`
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
constructor(streamBuilder: StreamBuilder, options: IClientOptions) {
|
|
507
|
+
super()
|
|
508
|
+
|
|
509
|
+
this.options = options || {}
|
|
510
|
+
|
|
511
|
+
// Defaults
|
|
512
|
+
for (const k in defaultConnectOptions) {
|
|
513
|
+
if (typeof this.options[k] === 'undefined') {
|
|
514
|
+
this.options[k] = defaultConnectOptions[k]
|
|
515
|
+
} else {
|
|
516
|
+
this.options[k] = options[k]
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
this.log = this.options.log || _debug('mqttjs:client')
|
|
521
|
+
this.noop = this._noop.bind(this)
|
|
522
|
+
|
|
523
|
+
this.log('MqttClient :: version:', MqttClient.VERSION)
|
|
524
|
+
|
|
525
|
+
if (isWebWorker) {
|
|
526
|
+
this.log('MqttClient :: environment', 'webworker')
|
|
527
|
+
} else {
|
|
528
|
+
this.log(
|
|
529
|
+
'MqttClient :: environment',
|
|
530
|
+
isBrowser ? 'browser' : 'node',
|
|
531
|
+
)
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
this.log('MqttClient :: options.protocol', options.protocol)
|
|
535
|
+
this.log(
|
|
536
|
+
'MqttClient :: options.protocolVersion',
|
|
537
|
+
options.protocolVersion,
|
|
538
|
+
)
|
|
539
|
+
this.log('MqttClient :: options.username', options.username)
|
|
540
|
+
this.log('MqttClient :: options.keepalive', options.keepalive)
|
|
541
|
+
this.log(
|
|
542
|
+
'MqttClient :: options.reconnectPeriod',
|
|
543
|
+
options.reconnectPeriod,
|
|
544
|
+
)
|
|
545
|
+
this.log(
|
|
546
|
+
'MqttClient :: options.rejectUnauthorized',
|
|
547
|
+
options.rejectUnauthorized,
|
|
548
|
+
)
|
|
549
|
+
this.log(
|
|
550
|
+
'MqttClient :: options.properties.topicAliasMaximum',
|
|
551
|
+
options.properties
|
|
552
|
+
? options.properties.topicAliasMaximum
|
|
553
|
+
: undefined,
|
|
554
|
+
)
|
|
555
|
+
|
|
556
|
+
this.options.clientId =
|
|
557
|
+
typeof options.clientId === 'string'
|
|
558
|
+
? options.clientId
|
|
559
|
+
: MqttClient.defaultId()
|
|
560
|
+
|
|
561
|
+
this.log('MqttClient :: clientId', this.options.clientId)
|
|
562
|
+
|
|
563
|
+
this.options.customHandleAcks =
|
|
564
|
+
options.protocolVersion === 5 && options.customHandleAcks
|
|
565
|
+
? options.customHandleAcks
|
|
566
|
+
: (...args) => {
|
|
567
|
+
args[3](null, 0)
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// Disable pre-generated write cache if requested. Will allocate buffers on-the-fly instead. WARNING: This can affect write performance
|
|
571
|
+
if (!this.options.writeCache) {
|
|
572
|
+
mqttPacket.writeToStream.cacheNumbers = false
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
this.streamBuilder = streamBuilder
|
|
576
|
+
|
|
577
|
+
this.messageIdProvider =
|
|
578
|
+
typeof this.options.messageIdProvider === 'undefined'
|
|
579
|
+
? new DefaultMessageIdProvider()
|
|
580
|
+
: this.options.messageIdProvider
|
|
581
|
+
|
|
582
|
+
// Inflight message storages
|
|
583
|
+
this.outgoingStore = options.outgoingStore || new Store()
|
|
584
|
+
this.incomingStore = options.incomingStore || new Store()
|
|
585
|
+
|
|
586
|
+
// Should QoS zero messages be queued when the connection is broken?
|
|
587
|
+
this.queueQoSZero =
|
|
588
|
+
options.queueQoSZero === undefined ? true : options.queueQoSZero
|
|
589
|
+
|
|
590
|
+
// map of subscribed topics to support reconnection
|
|
591
|
+
this._resubscribeTopics = {}
|
|
592
|
+
|
|
593
|
+
// map of a subscribe messageId and a topic
|
|
594
|
+
this.messageIdToTopic = {}
|
|
595
|
+
|
|
596
|
+
// Keepalive manager, setup in _setupKeepaliveManager
|
|
597
|
+
this.keepaliveManager = null
|
|
598
|
+
// Is the client connected?
|
|
599
|
+
this.connected = false
|
|
600
|
+
// Are we disconnecting?
|
|
601
|
+
this.disconnecting = false
|
|
602
|
+
// Are we reconnecting?
|
|
603
|
+
this.reconnecting = false
|
|
604
|
+
// Packet queue
|
|
605
|
+
this.queue = []
|
|
606
|
+
// connack timer
|
|
607
|
+
this.connackTimer = null
|
|
608
|
+
// Reconnect timer
|
|
609
|
+
this.reconnectTimer = null
|
|
610
|
+
// Is processing store?
|
|
611
|
+
this._storeProcessing = false
|
|
612
|
+
// Packet Ids are put into the store during store processing
|
|
613
|
+
this._packetIdsDuringStoreProcessing = {}
|
|
614
|
+
// Store processing queue
|
|
615
|
+
this._storeProcessingQueue = []
|
|
616
|
+
|
|
617
|
+
// Inflight callbacks
|
|
618
|
+
this.outgoing = {}
|
|
619
|
+
|
|
620
|
+
// True if connection is first time.
|
|
621
|
+
this._firstConnection = true
|
|
622
|
+
|
|
623
|
+
if (options.properties && options.properties.topicAliasMaximum > 0) {
|
|
624
|
+
if (options.properties.topicAliasMaximum > 0xffff) {
|
|
625
|
+
this.log(
|
|
626
|
+
'MqttClient :: options.properties.topicAliasMaximum is out of range',
|
|
627
|
+
)
|
|
628
|
+
} else {
|
|
629
|
+
this.topicAliasRecv = new TopicAliasRecv(
|
|
630
|
+
options.properties.topicAliasMaximum,
|
|
631
|
+
)
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
// Send queued packets
|
|
636
|
+
this.on('connect', () => {
|
|
637
|
+
const { queue } = this
|
|
638
|
+
|
|
639
|
+
const deliver = () => {
|
|
640
|
+
const entry = queue.shift()
|
|
641
|
+
this.log('deliver :: entry %o', entry)
|
|
642
|
+
let packet = null
|
|
643
|
+
|
|
644
|
+
if (!entry) {
|
|
645
|
+
this._resubscribe()
|
|
646
|
+
return
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
packet = entry.packet
|
|
650
|
+
this.log('deliver :: call _sendPacket for %o', packet)
|
|
651
|
+
let send = true
|
|
652
|
+
if (packet.messageId && packet.messageId !== 0) {
|
|
653
|
+
if (!this.messageIdProvider.register(packet.messageId)) {
|
|
654
|
+
send = false
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if (send) {
|
|
658
|
+
this._sendPacket(packet, (err) => {
|
|
659
|
+
if (entry.cb) {
|
|
660
|
+
entry.cb(err)
|
|
661
|
+
}
|
|
662
|
+
deliver()
|
|
663
|
+
})
|
|
664
|
+
} else {
|
|
665
|
+
this.log(
|
|
666
|
+
'messageId: %d has already used. The message is skipped and removed.',
|
|
667
|
+
packet.messageId,
|
|
668
|
+
)
|
|
669
|
+
deliver()
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
this.log('connect :: sending queued packets')
|
|
674
|
+
deliver()
|
|
675
|
+
})
|
|
676
|
+
|
|
677
|
+
this.on('close', () => {
|
|
678
|
+
this.log('close :: connected set to `false`')
|
|
679
|
+
this.connected = false
|
|
680
|
+
|
|
681
|
+
this.log('close :: clearing connackTimer')
|
|
682
|
+
clearTimeout(this.connackTimer)
|
|
683
|
+
|
|
684
|
+
this._destroyKeepaliveManager()
|
|
685
|
+
|
|
686
|
+
if (this.topicAliasRecv) {
|
|
687
|
+
this.topicAliasRecv.clear()
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
this.log('close :: calling _setupReconnect')
|
|
691
|
+
this._setupReconnect()
|
|
692
|
+
})
|
|
693
|
+
|
|
694
|
+
if (!this.options.manualConnect) {
|
|
695
|
+
this.log('MqttClient :: setting up stream')
|
|
696
|
+
this.connect()
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* @param packet the packet received by the broker
|
|
702
|
+
* @return the auth packet to be returned to the broker
|
|
703
|
+
* @api public
|
|
704
|
+
*/
|
|
705
|
+
public handleAuth(packet: IAuthPacket, callback: PacketCallback) {
|
|
706
|
+
callback()
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Handle messages with backpressure support, one at a time.
|
|
711
|
+
* Override at will.
|
|
712
|
+
*
|
|
713
|
+
* @param Packet packet the packet
|
|
714
|
+
* @param Function callback call when finished
|
|
715
|
+
* @api public
|
|
716
|
+
*/
|
|
717
|
+
public handleMessage(packet: IPublishPacket, callback: DoneCallback) {
|
|
718
|
+
callback()
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* _nextId
|
|
723
|
+
* @return unsigned int
|
|
724
|
+
*/
|
|
725
|
+
private _nextId() {
|
|
726
|
+
return this.messageIdProvider.allocate()
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* getLastMessageId
|
|
731
|
+
* @return unsigned int
|
|
732
|
+
*/
|
|
733
|
+
public getLastMessageId() {
|
|
734
|
+
return this.messageIdProvider.getLastAllocated()
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Setup the event handlers in the inner stream, sends `connect` and `auth` packets
|
|
739
|
+
*/
|
|
740
|
+
public connect() {
|
|
741
|
+
const writable = new Writable()
|
|
742
|
+
const parser = mqttPacket.parser(this.options)
|
|
743
|
+
|
|
744
|
+
let completeParse = null
|
|
745
|
+
const packets = []
|
|
746
|
+
|
|
747
|
+
this.log('connect :: calling method to clear reconnect')
|
|
748
|
+
this._clearReconnect()
|
|
749
|
+
|
|
750
|
+
if (this.disconnected && !this.reconnecting) {
|
|
751
|
+
this.incomingStore = this.options.incomingStore || new Store()
|
|
752
|
+
this.outgoingStore = this.options.outgoingStore || new Store()
|
|
753
|
+
this.disconnecting = false
|
|
754
|
+
this.disconnected = false
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
this.log(
|
|
758
|
+
'connect :: using streamBuilder provided to client to create stream',
|
|
759
|
+
)
|
|
760
|
+
this.stream = this.streamBuilder(this)
|
|
761
|
+
|
|
762
|
+
parser.on('packet', (packet) => {
|
|
763
|
+
this.log('parser :: on packet push to packets array.')
|
|
764
|
+
packets.push(packet)
|
|
765
|
+
})
|
|
766
|
+
|
|
767
|
+
const work = () => {
|
|
768
|
+
this.log('work :: getting next packet in queue')
|
|
769
|
+
const packet = packets.shift()
|
|
770
|
+
|
|
771
|
+
if (packet) {
|
|
772
|
+
this.log('work :: packet pulled from queue')
|
|
773
|
+
handlePacket(this, packet, nextTickWork)
|
|
774
|
+
} else {
|
|
775
|
+
this.log('work :: no packets in queue')
|
|
776
|
+
const done = completeParse
|
|
777
|
+
completeParse = null
|
|
778
|
+
this.log('work :: done flag is %s', !!done)
|
|
779
|
+
if (done) done()
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
const nextTickWork = () => {
|
|
784
|
+
if (packets.length) {
|
|
785
|
+
nextTick(work)
|
|
786
|
+
} else {
|
|
787
|
+
const done = completeParse
|
|
788
|
+
completeParse = null
|
|
789
|
+
done()
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
writable._write = (buf, enc, done) => {
|
|
794
|
+
completeParse = done
|
|
795
|
+
this.log('writable stream :: parsing buffer')
|
|
796
|
+
parser.parse(buf)
|
|
797
|
+
work()
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
const streamErrorHandler = (error) => {
|
|
801
|
+
this.log('streamErrorHandler :: error', error.message)
|
|
802
|
+
// error.code will only be set on NodeJS env, browser don't allow to detect errors on sockets
|
|
803
|
+
// also emitting errors on browsers seems to create issues
|
|
804
|
+
if (error.code) {
|
|
805
|
+
// handle error
|
|
806
|
+
this.log('streamErrorHandler :: emitting error')
|
|
807
|
+
this.emit('error', error)
|
|
808
|
+
} else {
|
|
809
|
+
this.noop(error)
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
this.log('connect :: pipe stream to writable stream')
|
|
814
|
+
this.stream.pipe(writable)
|
|
815
|
+
|
|
816
|
+
// Suppress connection errors
|
|
817
|
+
this.stream.on('error', streamErrorHandler)
|
|
818
|
+
|
|
819
|
+
// Echo stream close
|
|
820
|
+
this.stream.on('close', () => {
|
|
821
|
+
this.log('(%s)stream :: on close', this.options.clientId)
|
|
822
|
+
this._flushVolatile()
|
|
823
|
+
this.log('stream: emit close to MqttClient')
|
|
824
|
+
this.emit('close')
|
|
825
|
+
})
|
|
826
|
+
|
|
827
|
+
// Send a connect packet
|
|
828
|
+
this.log('connect: sending packet `connect`')
|
|
829
|
+
|
|
830
|
+
const connectPacket: IConnectPacket = {
|
|
831
|
+
cmd: 'connect',
|
|
832
|
+
protocolId: this.options.protocolId,
|
|
833
|
+
protocolVersion: this.options.protocolVersion,
|
|
834
|
+
clean: this.options.clean,
|
|
835
|
+
clientId: this.options.clientId,
|
|
836
|
+
keepalive: this.options.keepalive,
|
|
837
|
+
username: this.options.username,
|
|
838
|
+
password: this.options.password as Buffer,
|
|
839
|
+
properties: this.options.properties,
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
if (this.options.will) {
|
|
843
|
+
connectPacket.will = {
|
|
844
|
+
...this.options.will,
|
|
845
|
+
payload: this.options.will?.payload as Buffer,
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
if (this.topicAliasRecv) {
|
|
850
|
+
if (!connectPacket.properties) {
|
|
851
|
+
connectPacket.properties = {}
|
|
852
|
+
}
|
|
853
|
+
if (this.topicAliasRecv) {
|
|
854
|
+
connectPacket.properties.topicAliasMaximum =
|
|
855
|
+
this.topicAliasRecv.max
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
// avoid message queue
|
|
859
|
+
this._writePacket(connectPacket)
|
|
860
|
+
|
|
861
|
+
// Echo connection errors
|
|
862
|
+
parser.on('error', this.emit.bind(this, 'error'))
|
|
863
|
+
|
|
864
|
+
// auth
|
|
865
|
+
if (this.options.properties) {
|
|
866
|
+
if (
|
|
867
|
+
!this.options.properties.authenticationMethod &&
|
|
868
|
+
this.options.properties.authenticationData
|
|
869
|
+
) {
|
|
870
|
+
this.end(() =>
|
|
871
|
+
this.emit(
|
|
872
|
+
'error',
|
|
873
|
+
new Error('Packet has no Authentication Method'),
|
|
874
|
+
),
|
|
875
|
+
)
|
|
876
|
+
return this
|
|
877
|
+
}
|
|
878
|
+
if (
|
|
879
|
+
this.options.properties.authenticationMethod &&
|
|
880
|
+
this.options.authPacket &&
|
|
881
|
+
typeof this.options.authPacket === 'object'
|
|
882
|
+
) {
|
|
883
|
+
const authPacket: IAuthPacket = {
|
|
884
|
+
cmd: 'auth',
|
|
885
|
+
reasonCode: 0,
|
|
886
|
+
...this.options.authPacket,
|
|
887
|
+
}
|
|
888
|
+
this._writePacket(authPacket)
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// many drain listeners are needed for qos 1 callbacks if the connection is intermittent
|
|
893
|
+
this.stream.setMaxListeners(1000)
|
|
894
|
+
|
|
895
|
+
clearTimeout(this.connackTimer)
|
|
896
|
+
this.connackTimer = setTimeout(() => {
|
|
897
|
+
this.log(
|
|
898
|
+
'!!connectTimeout hit!! Calling _cleanUp with force `true`',
|
|
899
|
+
)
|
|
900
|
+
this.emit('error', new Error('connack timeout'))
|
|
901
|
+
this._cleanUp(true)
|
|
902
|
+
}, this.options.connectTimeout)
|
|
903
|
+
|
|
904
|
+
return this
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* publish - publish <message> to <topic>
|
|
909
|
+
*
|
|
910
|
+
* @param {String} topic - topic to publish to
|
|
911
|
+
* @param {String, Buffer} message - message to publish
|
|
912
|
+
* @param {Object} [opts] - publish options, includes:
|
|
913
|
+
* {Number} qos - qos level to publish on
|
|
914
|
+
* {Boolean} retain - whether or not to retain the message
|
|
915
|
+
* {Boolean} dup - whether or not mark a message as duplicate
|
|
916
|
+
* {Function} cbStorePut - function(){} called when message is put into `outgoingStore`
|
|
917
|
+
* @param {Function} [callback] - function(err){}
|
|
918
|
+
* called when publish succeeds or fails
|
|
919
|
+
* @returns {MqttClient} this - for chaining
|
|
920
|
+
* @api public
|
|
921
|
+
*
|
|
922
|
+
* @example client.publish('topic', 'message');
|
|
923
|
+
* @example
|
|
924
|
+
* client.publish('topic', 'message', {qos: 1, retain: true, dup: true});
|
|
925
|
+
* @example client.publish('topic', 'message', console.log);
|
|
926
|
+
*/
|
|
927
|
+
public publish(topic: string, message: string | Buffer): MqttClient
|
|
928
|
+
public publish(
|
|
929
|
+
topic: string,
|
|
930
|
+
message: string | Buffer,
|
|
931
|
+
callback?: PacketCallback,
|
|
932
|
+
): MqttClient
|
|
933
|
+
public publish(
|
|
934
|
+
topic: string,
|
|
935
|
+
message: string | Buffer,
|
|
936
|
+
opts?: IClientPublishOptions,
|
|
937
|
+
callback?: PacketCallback,
|
|
938
|
+
): MqttClient
|
|
939
|
+
public publish(
|
|
940
|
+
topic: string,
|
|
941
|
+
message: string | Buffer,
|
|
942
|
+
opts?: IClientPublishOptions | DoneCallback,
|
|
943
|
+
callback?: PacketCallback,
|
|
944
|
+
): MqttClient {
|
|
945
|
+
this.log('publish :: message `%s` to topic `%s`', message, topic)
|
|
946
|
+
const { options } = this
|
|
947
|
+
|
|
948
|
+
// .publish(topic, payload, cb);
|
|
949
|
+
if (typeof opts === 'function') {
|
|
950
|
+
callback = opts as DoneCallback
|
|
951
|
+
opts = null
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
opts = opts || {}
|
|
955
|
+
|
|
956
|
+
// default opts
|
|
957
|
+
const defaultOpts: IClientPublishOptions = {
|
|
958
|
+
qos: 0,
|
|
959
|
+
retain: false,
|
|
960
|
+
dup: false,
|
|
961
|
+
}
|
|
962
|
+
opts = { ...defaultOpts, ...opts }
|
|
963
|
+
|
|
964
|
+
const { qos, retain, dup, properties, cbStorePut } = opts
|
|
965
|
+
|
|
966
|
+
if (this._checkDisconnecting(callback)) {
|
|
967
|
+
return this
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
const publishProc = () => {
|
|
971
|
+
let messageId = 0
|
|
972
|
+
if (qos === 1 || qos === 2) {
|
|
973
|
+
messageId = this._nextId()
|
|
974
|
+
if (messageId === null) {
|
|
975
|
+
this.log('No messageId left')
|
|
976
|
+
return false
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
const packet: IPublishPacket = {
|
|
980
|
+
cmd: 'publish',
|
|
981
|
+
topic,
|
|
982
|
+
payload: message,
|
|
983
|
+
qos,
|
|
984
|
+
retain,
|
|
985
|
+
messageId,
|
|
986
|
+
dup,
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
if (options.protocolVersion === 5) {
|
|
990
|
+
packet.properties = properties
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
this.log('publish :: qos', qos)
|
|
994
|
+
switch (qos) {
|
|
995
|
+
case 1:
|
|
996
|
+
case 2:
|
|
997
|
+
// Add to callbacks
|
|
998
|
+
this.outgoing[packet.messageId] = {
|
|
999
|
+
volatile: false,
|
|
1000
|
+
cb: callback || this.noop,
|
|
1001
|
+
}
|
|
1002
|
+
this.log('MqttClient:publish: packet cmd: %s', packet.cmd)
|
|
1003
|
+
this._sendPacket(packet, undefined, cbStorePut)
|
|
1004
|
+
break
|
|
1005
|
+
default:
|
|
1006
|
+
this.log('MqttClient:publish: packet cmd: %s', packet.cmd)
|
|
1007
|
+
this._sendPacket(packet, callback, cbStorePut)
|
|
1008
|
+
break
|
|
1009
|
+
}
|
|
1010
|
+
return true
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
if (
|
|
1014
|
+
this._storeProcessing ||
|
|
1015
|
+
this._storeProcessingQueue.length > 0 ||
|
|
1016
|
+
!publishProc()
|
|
1017
|
+
) {
|
|
1018
|
+
this._storeProcessingQueue.push({
|
|
1019
|
+
invoke: publishProc,
|
|
1020
|
+
cbStorePut: opts.cbStorePut,
|
|
1021
|
+
callback,
|
|
1022
|
+
})
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
return this
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
public publishAsync(
|
|
1029
|
+
topic: string,
|
|
1030
|
+
message: string | Buffer,
|
|
1031
|
+
): Promise<Packet | undefined>
|
|
1032
|
+
public publishAsync(
|
|
1033
|
+
topic: string,
|
|
1034
|
+
message: string | Buffer,
|
|
1035
|
+
opts?: IClientPublishOptions,
|
|
1036
|
+
): Promise<Packet | undefined>
|
|
1037
|
+
public publishAsync(
|
|
1038
|
+
topic: string,
|
|
1039
|
+
message: string | Buffer,
|
|
1040
|
+
opts?: IClientPublishOptions,
|
|
1041
|
+
): Promise<Packet | undefined> {
|
|
1042
|
+
return new Promise((resolve, reject) => {
|
|
1043
|
+
this.publish(topic, message, opts, (err, packet) => {
|
|
1044
|
+
if (err) {
|
|
1045
|
+
reject(err)
|
|
1046
|
+
} else {
|
|
1047
|
+
resolve(packet)
|
|
1048
|
+
}
|
|
1049
|
+
})
|
|
1050
|
+
})
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* subscribe - subscribe to <topic>
|
|
1055
|
+
*
|
|
1056
|
+
* @param {String, Array, Object} topic - topic(s) to subscribe to, supports objects in the form {'topic': qos}
|
|
1057
|
+
* @param {Object} [opts] - optional subscription options, includes:
|
|
1058
|
+
* {Number} qos - subscribe qos level
|
|
1059
|
+
* @param {Function} [callback] - function(err, granted){} where:
|
|
1060
|
+
* {Error} err - subscription error (none at the moment!)
|
|
1061
|
+
* {Array} granted - array of {topic: 't', qos: 0}
|
|
1062
|
+
* @returns {MqttClient} this - for chaining
|
|
1063
|
+
* @api public
|
|
1064
|
+
* @example client.subscribe('topic');
|
|
1065
|
+
* @example client.subscribe('topic', {qos: 1});
|
|
1066
|
+
* @example client.subscribe({'topic': {qos: 0}, 'topic2': {qos: 1}}, console.log);
|
|
1067
|
+
* @example client.subscribe('topic', console.log);
|
|
1068
|
+
*/
|
|
1069
|
+
public subscribe(
|
|
1070
|
+
topicObject: string | string[] | ISubscriptionMap,
|
|
1071
|
+
): MqttClient
|
|
1072
|
+
public subscribe(
|
|
1073
|
+
topicObject: string | string[] | ISubscriptionMap,
|
|
1074
|
+
callback?: ClientSubscribeCallback,
|
|
1075
|
+
): MqttClient
|
|
1076
|
+
public subscribe(
|
|
1077
|
+
topicObject: string | string[] | ISubscriptionMap,
|
|
1078
|
+
opts?: IClientSubscribeOptions | IClientSubscribeProperties,
|
|
1079
|
+
): MqttClient
|
|
1080
|
+
public subscribe(
|
|
1081
|
+
topicObject: string | string[] | ISubscriptionMap,
|
|
1082
|
+
opts?: IClientSubscribeOptions | IClientSubscribeProperties,
|
|
1083
|
+
callback?: ClientSubscribeCallback,
|
|
1084
|
+
): MqttClient
|
|
1085
|
+
public subscribe(
|
|
1086
|
+
topicObject: string | string[] | ISubscriptionMap,
|
|
1087
|
+
opts?:
|
|
1088
|
+
| IClientSubscribeOptions
|
|
1089
|
+
| IClientSubscribeProperties
|
|
1090
|
+
| ClientSubscribeCallback,
|
|
1091
|
+
callback?: ClientSubscribeCallback,
|
|
1092
|
+
): MqttClient {
|
|
1093
|
+
const version = this.options.protocolVersion
|
|
1094
|
+
|
|
1095
|
+
if (typeof opts === 'function') {
|
|
1096
|
+
callback = opts
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
callback = callback || this.noop
|
|
1100
|
+
|
|
1101
|
+
// force re-subscribe on reconnect. This is only true
|
|
1102
|
+
// when provided `topicObject` is `this._resubscribeTopics`
|
|
1103
|
+
let resubscribe = false
|
|
1104
|
+
let topicsList = []
|
|
1105
|
+
|
|
1106
|
+
if (typeof topicObject === 'string') {
|
|
1107
|
+
topicObject = [topicObject]
|
|
1108
|
+
topicsList = topicObject
|
|
1109
|
+
} else if (Array.isArray(topicObject)) {
|
|
1110
|
+
topicsList = topicObject
|
|
1111
|
+
} else if (typeof topicObject === 'object') {
|
|
1112
|
+
resubscribe = topicObject.resubscribe
|
|
1113
|
+
delete topicObject.resubscribe
|
|
1114
|
+
topicsList = Object.keys(topicObject)
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
// validate topics
|
|
1118
|
+
const invalidTopic = validations.validateTopics(topicsList)
|
|
1119
|
+
if (invalidTopic !== null) {
|
|
1120
|
+
setImmediate(callback, new Error(`Invalid topic ${invalidTopic}`))
|
|
1121
|
+
return this
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
if (this._checkDisconnecting(callback)) {
|
|
1125
|
+
this.log('subscribe: discconecting true')
|
|
1126
|
+
return this
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
const defaultOpts: Partial<IClientSubscribeOptions> = {
|
|
1130
|
+
qos: 0,
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
if (version === 5) {
|
|
1134
|
+
defaultOpts.nl = false
|
|
1135
|
+
defaultOpts.rap = false
|
|
1136
|
+
defaultOpts.rh = 0
|
|
1137
|
+
}
|
|
1138
|
+
opts = { ...defaultOpts, ...opts } as IClientSubscribeOptions
|
|
1139
|
+
|
|
1140
|
+
const properties = opts.properties
|
|
1141
|
+
|
|
1142
|
+
const subs: ISubscriptionRequest[] = []
|
|
1143
|
+
|
|
1144
|
+
const parseSub = (
|
|
1145
|
+
topic: string,
|
|
1146
|
+
subOptions?: IClientSubscribeOptions,
|
|
1147
|
+
) => {
|
|
1148
|
+
// subOptions is defined only when providing a subs map, use opts otherwise
|
|
1149
|
+
subOptions = (subOptions || opts) as IClientSubscribeOptions
|
|
1150
|
+
if (
|
|
1151
|
+
!Object.prototype.hasOwnProperty.call(
|
|
1152
|
+
this._resubscribeTopics,
|
|
1153
|
+
topic,
|
|
1154
|
+
) ||
|
|
1155
|
+
this._resubscribeTopics[topic].qos < subOptions.qos ||
|
|
1156
|
+
resubscribe
|
|
1157
|
+
) {
|
|
1158
|
+
const currentOpts: ISubscription & IClientSubscribeProperties =
|
|
1159
|
+
{
|
|
1160
|
+
topic,
|
|
1161
|
+
qos: subOptions.qos,
|
|
1162
|
+
}
|
|
1163
|
+
if (version === 5) {
|
|
1164
|
+
currentOpts.nl = subOptions.nl
|
|
1165
|
+
currentOpts.rap = subOptions.rap
|
|
1166
|
+
currentOpts.rh = subOptions.rh
|
|
1167
|
+
// use opts.properties
|
|
1168
|
+
currentOpts.properties = properties
|
|
1169
|
+
}
|
|
1170
|
+
this.log(
|
|
1171
|
+
'subscribe: pushing topic `%s` and qos `%s` to subs list',
|
|
1172
|
+
currentOpts.topic,
|
|
1173
|
+
currentOpts.qos,
|
|
1174
|
+
)
|
|
1175
|
+
subs.push(currentOpts)
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
if (Array.isArray(topicObject)) {
|
|
1180
|
+
// array of topics
|
|
1181
|
+
topicObject.forEach((topic) => {
|
|
1182
|
+
this.log('subscribe: array topic %s', topic)
|
|
1183
|
+
parseSub(topic)
|
|
1184
|
+
})
|
|
1185
|
+
} else {
|
|
1186
|
+
// object topic --> subOptions (no properties)
|
|
1187
|
+
Object.keys(topicObject).forEach((topic) => {
|
|
1188
|
+
this.log(
|
|
1189
|
+
'subscribe: object topic %s, %o',
|
|
1190
|
+
topic,
|
|
1191
|
+
topicObject[topic],
|
|
1192
|
+
)
|
|
1193
|
+
parseSub(topic, topicObject[topic])
|
|
1194
|
+
})
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
if (!subs.length) {
|
|
1198
|
+
callback(null, [])
|
|
1199
|
+
return this
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
const subscribeProc = () => {
|
|
1203
|
+
const messageId = this._nextId()
|
|
1204
|
+
if (messageId === null) {
|
|
1205
|
+
this.log('No messageId left')
|
|
1206
|
+
return false
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
const packet: ISubscribePacket = {
|
|
1210
|
+
cmd: 'subscribe',
|
|
1211
|
+
subscriptions: subs,
|
|
1212
|
+
// qos: 1,
|
|
1213
|
+
// retain: false,
|
|
1214
|
+
// dup: false,
|
|
1215
|
+
messageId,
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
if (properties) {
|
|
1219
|
+
packet.properties = properties
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// subscriptions to resubscribe to in case of disconnect
|
|
1223
|
+
if (this.options.resubscribe) {
|
|
1224
|
+
this.log('subscribe :: resubscribe true')
|
|
1225
|
+
const topics = []
|
|
1226
|
+
subs.forEach((sub) => {
|
|
1227
|
+
if (this.options.reconnectPeriod > 0) {
|
|
1228
|
+
const topic: IClientSubscribeOptions = { qos: sub.qos }
|
|
1229
|
+
if (version === 5) {
|
|
1230
|
+
topic.nl = sub.nl || false
|
|
1231
|
+
topic.rap = sub.rap || false
|
|
1232
|
+
topic.rh = sub.rh || 0
|
|
1233
|
+
topic.properties = sub.properties
|
|
1234
|
+
}
|
|
1235
|
+
this._resubscribeTopics[sub.topic] = topic
|
|
1236
|
+
topics.push(sub.topic)
|
|
1237
|
+
}
|
|
1238
|
+
})
|
|
1239
|
+
this.messageIdToTopic[packet.messageId] = topics
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
this.outgoing[packet.messageId] = {
|
|
1243
|
+
volatile: true,
|
|
1244
|
+
cb(err, packet2: ISubackPacket) {
|
|
1245
|
+
if (!err) {
|
|
1246
|
+
const { granted } = packet2
|
|
1247
|
+
for (let i = 0; i < granted.length; i += 1) {
|
|
1248
|
+
subs[i].qos = granted[i] as QoS
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
callback(err, subs, packet2)
|
|
1253
|
+
},
|
|
1254
|
+
}
|
|
1255
|
+
this.log('subscribe :: call _sendPacket')
|
|
1256
|
+
this._sendPacket(packet)
|
|
1257
|
+
return true
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
if (
|
|
1261
|
+
this._storeProcessing ||
|
|
1262
|
+
this._storeProcessingQueue.length > 0 ||
|
|
1263
|
+
!subscribeProc()
|
|
1264
|
+
) {
|
|
1265
|
+
this._storeProcessingQueue.push({
|
|
1266
|
+
invoke: subscribeProc,
|
|
1267
|
+
callback,
|
|
1268
|
+
})
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
return this
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
public subscribeAsync(
|
|
1275
|
+
topicObject: string | string[] | ISubscriptionMap,
|
|
1276
|
+
): Promise<ISubscriptionGrant[]>
|
|
1277
|
+
public subscribeAsync(
|
|
1278
|
+
topicObject: string | string[] | ISubscriptionMap,
|
|
1279
|
+
opts?: IClientSubscribeOptions | IClientSubscribeProperties,
|
|
1280
|
+
): Promise<ISubscriptionGrant[]>
|
|
1281
|
+
public subscribeAsync(
|
|
1282
|
+
topicObject: string | string[] | ISubscriptionMap,
|
|
1283
|
+
opts?: IClientSubscribeOptions | IClientSubscribeProperties,
|
|
1284
|
+
): Promise<ISubscriptionGrant[]> {
|
|
1285
|
+
return new Promise((resolve, reject) => {
|
|
1286
|
+
this.subscribe(topicObject, opts, (err, granted) => {
|
|
1287
|
+
if (err) {
|
|
1288
|
+
reject(err)
|
|
1289
|
+
} else {
|
|
1290
|
+
resolve(granted)
|
|
1291
|
+
}
|
|
1292
|
+
})
|
|
1293
|
+
})
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
/**
|
|
1297
|
+
* unsubscribe - unsubscribe from topic(s)
|
|
1298
|
+
*
|
|
1299
|
+
* @param {String, Array} topic - topics to unsubscribe from
|
|
1300
|
+
* @param {Object} [opts] - optional subscription options, includes:
|
|
1301
|
+
* {Object} properties - properties of unsubscribe packet
|
|
1302
|
+
* @param {Function} [callback] - callback fired on unsuback
|
|
1303
|
+
* @returns {MqttClient} this - for chaining
|
|
1304
|
+
* @api public
|
|
1305
|
+
* @example client.unsubscribe('topic');
|
|
1306
|
+
* @example client.unsubscribe('topic', console.log);
|
|
1307
|
+
*/
|
|
1308
|
+
public unsubscribe(topic: string | string[]): MqttClient
|
|
1309
|
+
public unsubscribe(
|
|
1310
|
+
topic: string | string[],
|
|
1311
|
+
opts?: IClientUnsubscribeProperties,
|
|
1312
|
+
): MqttClient
|
|
1313
|
+
public unsubscribe(
|
|
1314
|
+
topic: string | string[],
|
|
1315
|
+
callback?: PacketCallback,
|
|
1316
|
+
): MqttClient
|
|
1317
|
+
public unsubscribe(
|
|
1318
|
+
topic: string | string[],
|
|
1319
|
+
opts?: IClientUnsubscribeProperties,
|
|
1320
|
+
callback?: PacketCallback,
|
|
1321
|
+
): MqttClient
|
|
1322
|
+
public unsubscribe(
|
|
1323
|
+
topic: string | string[],
|
|
1324
|
+
opts?: IClientUnsubscribeProperties | PacketCallback,
|
|
1325
|
+
callback?: PacketCallback,
|
|
1326
|
+
): MqttClient {
|
|
1327
|
+
if (typeof topic === 'string') {
|
|
1328
|
+
topic = [topic]
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
if (typeof opts === 'function') {
|
|
1332
|
+
callback = opts
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
callback = callback || this.noop
|
|
1336
|
+
|
|
1337
|
+
const invalidTopic = validations.validateTopics(topic)
|
|
1338
|
+
if (invalidTopic !== null) {
|
|
1339
|
+
setImmediate(callback, new Error(`Invalid topic ${invalidTopic}`))
|
|
1340
|
+
return this
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
if (this._checkDisconnecting(callback)) {
|
|
1344
|
+
return this
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
const unsubscribeProc = () => {
|
|
1348
|
+
const messageId = this._nextId()
|
|
1349
|
+
if (messageId === null) {
|
|
1350
|
+
this.log('No messageId left')
|
|
1351
|
+
return false
|
|
1352
|
+
}
|
|
1353
|
+
const packet: IUnsubscribePacket = {
|
|
1354
|
+
cmd: 'unsubscribe',
|
|
1355
|
+
// qos: 1,
|
|
1356
|
+
messageId,
|
|
1357
|
+
unsubscriptions: [],
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
if (typeof topic === 'string') {
|
|
1361
|
+
packet.unsubscriptions = [topic]
|
|
1362
|
+
} else if (Array.isArray(topic)) {
|
|
1363
|
+
packet.unsubscriptions = topic
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
if (this.options.resubscribe) {
|
|
1367
|
+
packet.unsubscriptions.forEach((topic2) => {
|
|
1368
|
+
delete this._resubscribeTopics[topic2]
|
|
1369
|
+
})
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
if (typeof opts === 'object' && opts.properties) {
|
|
1373
|
+
packet.properties = opts.properties
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
this.outgoing[packet.messageId] = {
|
|
1377
|
+
volatile: true,
|
|
1378
|
+
cb: callback,
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
this.log('unsubscribe: call _sendPacket')
|
|
1382
|
+
this._sendPacket(packet)
|
|
1383
|
+
|
|
1384
|
+
return true
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
if (
|
|
1388
|
+
this._storeProcessing ||
|
|
1389
|
+
this._storeProcessingQueue.length > 0 ||
|
|
1390
|
+
!unsubscribeProc()
|
|
1391
|
+
) {
|
|
1392
|
+
this._storeProcessingQueue.push({
|
|
1393
|
+
invoke: unsubscribeProc,
|
|
1394
|
+
callback,
|
|
1395
|
+
})
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
return this
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
public unsubscribeAsync(
|
|
1402
|
+
topic: string | string[],
|
|
1403
|
+
): Promise<Packet | undefined>
|
|
1404
|
+
public unsubscribeAsync(
|
|
1405
|
+
topic: string | string[],
|
|
1406
|
+
opts?: IClientUnsubscribeProperties,
|
|
1407
|
+
): Promise<Packet | undefined>
|
|
1408
|
+
public unsubscribeAsync(
|
|
1409
|
+
topic: string | string[],
|
|
1410
|
+
opts?: IClientUnsubscribeProperties,
|
|
1411
|
+
): Promise<Packet | undefined> {
|
|
1412
|
+
return new Promise((resolve, reject) => {
|
|
1413
|
+
this.unsubscribe(topic, opts, (err, packet) => {
|
|
1414
|
+
if (err) {
|
|
1415
|
+
reject(err)
|
|
1416
|
+
} else {
|
|
1417
|
+
resolve(packet)
|
|
1418
|
+
}
|
|
1419
|
+
})
|
|
1420
|
+
})
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
/**
|
|
1424
|
+
* end - close connection
|
|
1425
|
+
*
|
|
1426
|
+
* @returns {MqttClient} this - for chaining
|
|
1427
|
+
* @param {Boolean} force - do not wait for all in-flight messages to be acked
|
|
1428
|
+
* @param {Object} opts - added to the disconnect packet
|
|
1429
|
+
* @param {Function} cb - called when the client has been closed
|
|
1430
|
+
*
|
|
1431
|
+
* @api public
|
|
1432
|
+
*/
|
|
1433
|
+
public end(cb?: DoneCallback): MqttClient
|
|
1434
|
+
public end(force?: boolean): MqttClient
|
|
1435
|
+
public end(opts?: Partial<IDisconnectPacket>, cb?: DoneCallback): MqttClient
|
|
1436
|
+
public end(force?: boolean, cb?: DoneCallback): MqttClient
|
|
1437
|
+
public end(
|
|
1438
|
+
force?: boolean,
|
|
1439
|
+
opts?: Partial<IDisconnectPacket>,
|
|
1440
|
+
cb?: DoneCallback,
|
|
1441
|
+
): MqttClient
|
|
1442
|
+
public end(
|
|
1443
|
+
force?: boolean | Partial<IDisconnectPacket> | DoneCallback,
|
|
1444
|
+
opts?: Partial<IDisconnectPacket> | DoneCallback,
|
|
1445
|
+
cb?: DoneCallback,
|
|
1446
|
+
): MqttClient {
|
|
1447
|
+
this.log('end :: (%s)', this.options.clientId)
|
|
1448
|
+
|
|
1449
|
+
if (force == null || typeof force !== 'boolean') {
|
|
1450
|
+
cb = cb || (opts as DoneCallback)
|
|
1451
|
+
opts = force as Partial<IDisconnectPacket>
|
|
1452
|
+
force = false
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
if (typeof opts !== 'object') {
|
|
1456
|
+
cb = cb || opts
|
|
1457
|
+
opts = null
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
this.log('end :: cb? %s', !!cb)
|
|
1461
|
+
|
|
1462
|
+
if (!cb || typeof cb !== 'function') {
|
|
1463
|
+
cb = this.noop
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
const closeStores = () => {
|
|
1467
|
+
this.log('end :: closeStores: closing incoming and outgoing stores')
|
|
1468
|
+
this.disconnected = true
|
|
1469
|
+
this.incomingStore.close((e1) => {
|
|
1470
|
+
this.outgoingStore.close((e2) => {
|
|
1471
|
+
this.log('end :: closeStores: emitting end')
|
|
1472
|
+
this.emit('end')
|
|
1473
|
+
if (cb) {
|
|
1474
|
+
const err = e1 || e2
|
|
1475
|
+
this.log(
|
|
1476
|
+
'end :: closeStores: invoking callback with args',
|
|
1477
|
+
)
|
|
1478
|
+
cb(err)
|
|
1479
|
+
}
|
|
1480
|
+
})
|
|
1481
|
+
})
|
|
1482
|
+
if (this._deferredReconnect) {
|
|
1483
|
+
this._deferredReconnect()
|
|
1484
|
+
} else if (
|
|
1485
|
+
this.options.reconnectPeriod === 0 ||
|
|
1486
|
+
this.options.manualConnect
|
|
1487
|
+
) {
|
|
1488
|
+
this.disconnecting = false
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
const finish = () => {
|
|
1493
|
+
// defer closesStores of an I/O cycle,
|
|
1494
|
+
// just to make sure things are
|
|
1495
|
+
// ok for websockets
|
|
1496
|
+
this.log(
|
|
1497
|
+
'end :: (%s) :: finish :: calling _cleanUp with force %s',
|
|
1498
|
+
this.options.clientId,
|
|
1499
|
+
force,
|
|
1500
|
+
)
|
|
1501
|
+
this._cleanUp(
|
|
1502
|
+
<boolean>force,
|
|
1503
|
+
() => {
|
|
1504
|
+
this.log(
|
|
1505
|
+
'end :: finish :: calling process.nextTick on closeStores',
|
|
1506
|
+
)
|
|
1507
|
+
// const boundProcess = nextTick.bind(null, closeStores)
|
|
1508
|
+
nextTick(closeStores)
|
|
1509
|
+
},
|
|
1510
|
+
opts,
|
|
1511
|
+
)
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
if (this.disconnecting) {
|
|
1515
|
+
cb()
|
|
1516
|
+
return this
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
this._clearReconnect()
|
|
1520
|
+
|
|
1521
|
+
this.disconnecting = true
|
|
1522
|
+
|
|
1523
|
+
if (!force && Object.keys(this.outgoing).length > 0) {
|
|
1524
|
+
// wait 10ms, just to be sure we received all of it
|
|
1525
|
+
this.log(
|
|
1526
|
+
'end :: (%s) :: calling finish in 10ms once outgoing is empty',
|
|
1527
|
+
this.options.clientId,
|
|
1528
|
+
)
|
|
1529
|
+
this.once('outgoingEmpty', setTimeout.bind(null, finish, 10))
|
|
1530
|
+
} else {
|
|
1531
|
+
this.log(
|
|
1532
|
+
'end :: (%s) :: immediately calling finish',
|
|
1533
|
+
this.options.clientId,
|
|
1534
|
+
)
|
|
1535
|
+
finish()
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
return this
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
public endAsync(): Promise<void>
|
|
1542
|
+
public endAsync(force?: boolean): Promise<void>
|
|
1543
|
+
public endAsync(opts?: Partial<IDisconnectPacket>): Promise<void>
|
|
1544
|
+
public endAsync(
|
|
1545
|
+
force?: boolean,
|
|
1546
|
+
opts?: Partial<IDisconnectPacket>,
|
|
1547
|
+
): Promise<void>
|
|
1548
|
+
public endAsync(
|
|
1549
|
+
force?: boolean | Partial<IDisconnectPacket>,
|
|
1550
|
+
opts?: Partial<IDisconnectPacket>,
|
|
1551
|
+
): Promise<void> {
|
|
1552
|
+
return new Promise((resolve, reject) => {
|
|
1553
|
+
this.end(force as boolean, opts, (err) => {
|
|
1554
|
+
if (err) {
|
|
1555
|
+
reject(err)
|
|
1556
|
+
} else {
|
|
1557
|
+
resolve()
|
|
1558
|
+
}
|
|
1559
|
+
})
|
|
1560
|
+
})
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
/**
|
|
1564
|
+
* removeOutgoingMessage - remove a message in outgoing store
|
|
1565
|
+
* the outgoing callback will be called withe Error('Message removed') if the message is removed
|
|
1566
|
+
*
|
|
1567
|
+
* @param {Number} messageId - messageId to remove message
|
|
1568
|
+
* @returns {MqttClient} this - for chaining
|
|
1569
|
+
* @api public
|
|
1570
|
+
*
|
|
1571
|
+
* @example client.removeOutgoingMessage(client.getLastAllocated());
|
|
1572
|
+
*/
|
|
1573
|
+
public removeOutgoingMessage(messageId: number): MqttClient {
|
|
1574
|
+
if (this.outgoing[messageId]) {
|
|
1575
|
+
const { cb } = this.outgoing[messageId]
|
|
1576
|
+
this._removeOutgoingAndStoreMessage(messageId, () => {
|
|
1577
|
+
cb(new Error('Message removed'))
|
|
1578
|
+
})
|
|
1579
|
+
}
|
|
1580
|
+
return this
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
/**
|
|
1584
|
+
* reconnect - connect again using the same options as connect()
|
|
1585
|
+
*
|
|
1586
|
+
* @param {Object} [opts] - optional reconnect options, includes:
|
|
1587
|
+
* {Store} incomingStore - a store for the incoming packets
|
|
1588
|
+
* {Store} outgoingStore - a store for the outgoing packets
|
|
1589
|
+
* if opts is not given, current stores are used
|
|
1590
|
+
* @returns {MqttClient} this - for chaining
|
|
1591
|
+
*
|
|
1592
|
+
* @api public
|
|
1593
|
+
*/
|
|
1594
|
+
public reconnect(
|
|
1595
|
+
opts?: Pick<IClientOptions, 'incomingStore' | 'outgoingStore'>,
|
|
1596
|
+
): MqttClient {
|
|
1597
|
+
this.log('client reconnect')
|
|
1598
|
+
const f = () => {
|
|
1599
|
+
if (opts) {
|
|
1600
|
+
this.options.incomingStore = opts.incomingStore
|
|
1601
|
+
this.options.outgoingStore = opts.outgoingStore
|
|
1602
|
+
} else {
|
|
1603
|
+
this.options.incomingStore = null
|
|
1604
|
+
this.options.outgoingStore = null
|
|
1605
|
+
}
|
|
1606
|
+
this.incomingStore = this.options.incomingStore || new Store()
|
|
1607
|
+
this.outgoingStore = this.options.outgoingStore || new Store()
|
|
1608
|
+
this.disconnecting = false
|
|
1609
|
+
this.disconnected = false
|
|
1610
|
+
this._deferredReconnect = null
|
|
1611
|
+
this._reconnect()
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
if (this.disconnecting && !this.disconnected) {
|
|
1615
|
+
this._deferredReconnect = f
|
|
1616
|
+
} else {
|
|
1617
|
+
f()
|
|
1618
|
+
}
|
|
1619
|
+
return this
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
/**
|
|
1623
|
+
* PRIVATE METHODS
|
|
1624
|
+
* =====================
|
|
1625
|
+
* */
|
|
1626
|
+
|
|
1627
|
+
/**
|
|
1628
|
+
* Flush all outgoing messages marked as `volatile` in `outgoing` queue. Volatile messages
|
|
1629
|
+
* typically are subscription and unsubscription requests.
|
|
1630
|
+
*/
|
|
1631
|
+
private _flushVolatile() {
|
|
1632
|
+
if (this.outgoing) {
|
|
1633
|
+
this.log(
|
|
1634
|
+
'_flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function',
|
|
1635
|
+
)
|
|
1636
|
+
Object.keys(this.outgoing).forEach((messageId) => {
|
|
1637
|
+
if (
|
|
1638
|
+
this.outgoing[messageId].volatile &&
|
|
1639
|
+
typeof this.outgoing[messageId].cb === 'function'
|
|
1640
|
+
) {
|
|
1641
|
+
this.outgoing[messageId].cb(new Error('Connection closed'))
|
|
1642
|
+
delete this.outgoing[messageId]
|
|
1643
|
+
}
|
|
1644
|
+
})
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
/**
|
|
1649
|
+
* Flush all outgoing messages
|
|
1650
|
+
*/
|
|
1651
|
+
private _flush() {
|
|
1652
|
+
if (this.outgoing) {
|
|
1653
|
+
this.log('_flush: queue exists? %b', !!this.outgoing)
|
|
1654
|
+
Object.keys(this.outgoing).forEach((messageId) => {
|
|
1655
|
+
if (typeof this.outgoing[messageId].cb === 'function') {
|
|
1656
|
+
this.outgoing[messageId].cb(new Error('Connection closed'))
|
|
1657
|
+
// This is suspicious. Why do we only delete this if we have a callback?
|
|
1658
|
+
// If this is by-design, then adding no as callback would cause this to get deleted unintentionally.
|
|
1659
|
+
delete this.outgoing[messageId]
|
|
1660
|
+
}
|
|
1661
|
+
})
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
private _removeTopicAliasAndRecoverTopicName(packet: IPublishPacket) {
|
|
1666
|
+
let alias: number | undefined
|
|
1667
|
+
|
|
1668
|
+
if (packet.properties) {
|
|
1669
|
+
alias = packet.properties.topicAlias
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
let topic = packet.topic.toString()
|
|
1673
|
+
|
|
1674
|
+
this.log(
|
|
1675
|
+
'_removeTopicAliasAndRecoverTopicName :: alias %d, topic %o',
|
|
1676
|
+
alias,
|
|
1677
|
+
topic,
|
|
1678
|
+
)
|
|
1679
|
+
|
|
1680
|
+
if (topic.length === 0) {
|
|
1681
|
+
// restore topic from alias
|
|
1682
|
+
if (typeof alias === 'undefined') {
|
|
1683
|
+
return new Error('Unregistered Topic Alias')
|
|
1684
|
+
}
|
|
1685
|
+
topic = this.topicAliasSend.getTopicByAlias(alias)
|
|
1686
|
+
if (typeof topic === 'undefined') {
|
|
1687
|
+
return new Error('Unregistered Topic Alias')
|
|
1688
|
+
}
|
|
1689
|
+
packet.topic = topic
|
|
1690
|
+
}
|
|
1691
|
+
if (alias) {
|
|
1692
|
+
delete packet.properties.topicAlias
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
private _checkDisconnecting(callback?: GenericCallback<any>) {
|
|
1697
|
+
if (this.disconnecting) {
|
|
1698
|
+
if (callback && callback !== this.noop) {
|
|
1699
|
+
callback(new Error('client disconnecting'))
|
|
1700
|
+
} else {
|
|
1701
|
+
this.emit('error', new Error('client disconnecting'))
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
return this.disconnecting
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
/**
|
|
1708
|
+
* _reconnect - implement reconnection
|
|
1709
|
+
* @api private
|
|
1710
|
+
*/
|
|
1711
|
+
private _reconnect() {
|
|
1712
|
+
this.log('_reconnect: emitting reconnect to client')
|
|
1713
|
+
this.emit('reconnect')
|
|
1714
|
+
if (this.connected) {
|
|
1715
|
+
this.end(() => {
|
|
1716
|
+
this.connect()
|
|
1717
|
+
})
|
|
1718
|
+
this.log('client already connected. disconnecting first.')
|
|
1719
|
+
} else {
|
|
1720
|
+
this.log('_reconnect: calling connect')
|
|
1721
|
+
this.connect()
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
/**
|
|
1726
|
+
* _setupReconnect - setup reconnect timer
|
|
1727
|
+
*/
|
|
1728
|
+
private _setupReconnect() {
|
|
1729
|
+
if (
|
|
1730
|
+
!this.disconnecting &&
|
|
1731
|
+
!this.reconnectTimer &&
|
|
1732
|
+
this.options.reconnectPeriod > 0
|
|
1733
|
+
) {
|
|
1734
|
+
if (!this.reconnecting) {
|
|
1735
|
+
this.log('_setupReconnect :: emit `offline` state')
|
|
1736
|
+
this.emit('offline')
|
|
1737
|
+
this.log('_setupReconnect :: set `reconnecting` to `true`')
|
|
1738
|
+
this.reconnecting = true
|
|
1739
|
+
}
|
|
1740
|
+
this.log(
|
|
1741
|
+
'_setupReconnect :: setting reconnectTimer for %d ms',
|
|
1742
|
+
this.options.reconnectPeriod,
|
|
1743
|
+
)
|
|
1744
|
+
this.reconnectTimer = setInterval(() => {
|
|
1745
|
+
this.log('reconnectTimer :: reconnect triggered!')
|
|
1746
|
+
this._reconnect()
|
|
1747
|
+
}, this.options.reconnectPeriod)
|
|
1748
|
+
} else {
|
|
1749
|
+
this.log('_setupReconnect :: doing nothing...')
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
/**
|
|
1754
|
+
* _clearReconnect - clear the reconnect timer
|
|
1755
|
+
*/
|
|
1756
|
+
private _clearReconnect() {
|
|
1757
|
+
this.log('_clearReconnect : clearing reconnect timer')
|
|
1758
|
+
if (this.reconnectTimer) {
|
|
1759
|
+
clearInterval(this.reconnectTimer)
|
|
1760
|
+
this.reconnectTimer = null
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
/**
|
|
1765
|
+
* _cleanUp - clean up on connection end
|
|
1766
|
+
* @api private
|
|
1767
|
+
*/
|
|
1768
|
+
private _cleanUp(forced: boolean, done?: DoneCallback, opts = {}) {
|
|
1769
|
+
if (done) {
|
|
1770
|
+
this.log('_cleanUp :: done callback provided for on stream close')
|
|
1771
|
+
this.stream.on('close', done)
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
this.log('_cleanUp :: forced? %s', forced)
|
|
1775
|
+
if (forced) {
|
|
1776
|
+
if (this.options.reconnectPeriod === 0 && this.options.clean) {
|
|
1777
|
+
this._flush()
|
|
1778
|
+
}
|
|
1779
|
+
this.log(
|
|
1780
|
+
'_cleanUp :: (%s) :: destroying stream',
|
|
1781
|
+
this.options.clientId,
|
|
1782
|
+
)
|
|
1783
|
+
this.stream.destroy()
|
|
1784
|
+
} else {
|
|
1785
|
+
const packet: IDisconnectPacket = { cmd: 'disconnect', ...opts }
|
|
1786
|
+
this.log(
|
|
1787
|
+
'_cleanUp :: (%s) :: call _sendPacket with disconnect packet',
|
|
1788
|
+
this.options.clientId,
|
|
1789
|
+
)
|
|
1790
|
+
this._sendPacket(packet, () => {
|
|
1791
|
+
this.log(
|
|
1792
|
+
'_cleanUp :: (%s) :: destroying stream',
|
|
1793
|
+
this.options.clientId,
|
|
1794
|
+
)
|
|
1795
|
+
setImmediate(() => {
|
|
1796
|
+
this.stream.end(() => {
|
|
1797
|
+
this.log(
|
|
1798
|
+
'_cleanUp :: (%s) :: stream destroyed',
|
|
1799
|
+
this.options.clientId,
|
|
1800
|
+
)
|
|
1801
|
+
// once stream is closed the 'close' event will fire and that will
|
|
1802
|
+
// emit client `close` event and call `done` callback if done is provided
|
|
1803
|
+
})
|
|
1804
|
+
})
|
|
1805
|
+
})
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
if (!this.disconnecting && !this.reconnecting) {
|
|
1809
|
+
this.log(
|
|
1810
|
+
'_cleanUp :: client not disconnecting/reconnecting. Clearing and resetting reconnect.',
|
|
1811
|
+
)
|
|
1812
|
+
this._clearReconnect()
|
|
1813
|
+
this._setupReconnect()
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
this._destroyKeepaliveManager()
|
|
1817
|
+
|
|
1818
|
+
if (done && !this.connected) {
|
|
1819
|
+
this.log(
|
|
1820
|
+
'_cleanUp :: (%s) :: removing stream `done` callback `close` listener',
|
|
1821
|
+
this.options.clientId,
|
|
1822
|
+
)
|
|
1823
|
+
this.stream.removeListener('close', done)
|
|
1824
|
+
done()
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
private _storeAndSend(
|
|
1829
|
+
packet: Packet,
|
|
1830
|
+
cb: DoneCallback,
|
|
1831
|
+
cbStorePut: DoneCallback,
|
|
1832
|
+
) {
|
|
1833
|
+
this.log(
|
|
1834
|
+
'storeAndSend :: store packet with cmd %s to outgoingStore',
|
|
1835
|
+
packet.cmd,
|
|
1836
|
+
)
|
|
1837
|
+
let storePacket = packet
|
|
1838
|
+
let err: Error | undefined
|
|
1839
|
+
if (storePacket.cmd === 'publish') {
|
|
1840
|
+
// The original packet is for sending.
|
|
1841
|
+
// The cloned storePacket is for storing to resend on reconnect.
|
|
1842
|
+
// Topic Alias must not be used after disconnected.
|
|
1843
|
+
storePacket = clone(packet)
|
|
1844
|
+
err = this._removeTopicAliasAndRecoverTopicName(
|
|
1845
|
+
storePacket as IPublishPacket,
|
|
1846
|
+
)
|
|
1847
|
+
if (err) {
|
|
1848
|
+
return cb && cb(err)
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
this.outgoingStore.put(storePacket, (err2) => {
|
|
1852
|
+
if (err2) {
|
|
1853
|
+
return cb && cb(err2)
|
|
1854
|
+
}
|
|
1855
|
+
cbStorePut()
|
|
1856
|
+
this._writePacket(packet, cb)
|
|
1857
|
+
})
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
private _applyTopicAlias(packet: Packet) {
|
|
1861
|
+
if (this.options.protocolVersion === 5) {
|
|
1862
|
+
if (packet.cmd === 'publish') {
|
|
1863
|
+
let alias: number
|
|
1864
|
+
if (packet.properties) {
|
|
1865
|
+
alias = packet.properties.topicAlias
|
|
1866
|
+
}
|
|
1867
|
+
const topic = packet.topic.toString()
|
|
1868
|
+
if (this.topicAliasSend) {
|
|
1869
|
+
if (alias) {
|
|
1870
|
+
if (topic.length !== 0) {
|
|
1871
|
+
// register topic alias
|
|
1872
|
+
this.log(
|
|
1873
|
+
'applyTopicAlias :: register topic: %s - alias: %d',
|
|
1874
|
+
topic,
|
|
1875
|
+
alias,
|
|
1876
|
+
)
|
|
1877
|
+
if (!this.topicAliasSend.put(topic, alias)) {
|
|
1878
|
+
this.log(
|
|
1879
|
+
'applyTopicAlias :: error out of range. topic: %s - alias: %d',
|
|
1880
|
+
topic,
|
|
1881
|
+
alias,
|
|
1882
|
+
)
|
|
1883
|
+
return new Error(
|
|
1884
|
+
'Sending Topic Alias out of range',
|
|
1885
|
+
)
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
} else if (topic.length !== 0) {
|
|
1889
|
+
if (this.options.autoAssignTopicAlias) {
|
|
1890
|
+
alias = this.topicAliasSend.getAliasByTopic(topic)
|
|
1891
|
+
if (alias) {
|
|
1892
|
+
packet.topic = ''
|
|
1893
|
+
packet.properties = {
|
|
1894
|
+
...packet.properties,
|
|
1895
|
+
topicAlias: alias,
|
|
1896
|
+
}
|
|
1897
|
+
this.log(
|
|
1898
|
+
'applyTopicAlias :: auto assign(use) topic: %s - alias: %d',
|
|
1899
|
+
topic,
|
|
1900
|
+
alias,
|
|
1901
|
+
)
|
|
1902
|
+
} else {
|
|
1903
|
+
alias = this.topicAliasSend.getLruAlias()
|
|
1904
|
+
this.topicAliasSend.put(topic, alias)
|
|
1905
|
+
packet.properties = {
|
|
1906
|
+
...packet.properties,
|
|
1907
|
+
topicAlias: alias,
|
|
1908
|
+
}
|
|
1909
|
+
this.log(
|
|
1910
|
+
'applyTopicAlias :: auto assign topic: %s - alias: %d',
|
|
1911
|
+
topic,
|
|
1912
|
+
alias,
|
|
1913
|
+
)
|
|
1914
|
+
}
|
|
1915
|
+
} else if (this.options.autoUseTopicAlias) {
|
|
1916
|
+
alias = this.topicAliasSend.getAliasByTopic(topic)
|
|
1917
|
+
if (alias) {
|
|
1918
|
+
packet.topic = ''
|
|
1919
|
+
packet.properties = {
|
|
1920
|
+
...packet.properties,
|
|
1921
|
+
topicAlias: alias,
|
|
1922
|
+
}
|
|
1923
|
+
this.log(
|
|
1924
|
+
'applyTopicAlias :: auto use topic: %s - alias: %d',
|
|
1925
|
+
topic,
|
|
1926
|
+
alias,
|
|
1927
|
+
)
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
} else if (alias) {
|
|
1932
|
+
this.log(
|
|
1933
|
+
'applyTopicAlias :: error out of range. topic: %s - alias: %d',
|
|
1934
|
+
topic,
|
|
1935
|
+
alias,
|
|
1936
|
+
)
|
|
1937
|
+
return new Error('Sending Topic Alias out of range')
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
private _noop(err?: Error) {
|
|
1944
|
+
this.log('noop ::', err)
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
/** Writes the packet to stream and emits events */
|
|
1948
|
+
private _writePacket(packet: Packet, cb?: DoneCallback) {
|
|
1949
|
+
this.log('_writePacket :: packet: %O', packet)
|
|
1950
|
+
this.log('_writePacket :: emitting `packetsend`')
|
|
1951
|
+
|
|
1952
|
+
this.emit('packetsend', packet)
|
|
1953
|
+
|
|
1954
|
+
this.log('_writePacket :: writing to stream')
|
|
1955
|
+
const result = mqttPacket.writeToStream(
|
|
1956
|
+
packet,
|
|
1957
|
+
this.stream,
|
|
1958
|
+
this.options,
|
|
1959
|
+
)
|
|
1960
|
+
this.log('_writePacket :: writeToStream result %s', result)
|
|
1961
|
+
if (!result && cb && cb !== this.noop) {
|
|
1962
|
+
this.log(
|
|
1963
|
+
'_writePacket :: handle events on `drain` once through callback.',
|
|
1964
|
+
)
|
|
1965
|
+
this.stream.once('drain', cb)
|
|
1966
|
+
} else if (cb) {
|
|
1967
|
+
this.log('_writePacket :: invoking cb')
|
|
1968
|
+
cb()
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
/**
|
|
1973
|
+
* _sendPacket - send or queue a packet
|
|
1974
|
+
* @param {Object} packet - packet options
|
|
1975
|
+
* @param {Function} cb - callback when the packet is sent
|
|
1976
|
+
* @param {Function} cbStorePut - called when message is put into outgoingStore
|
|
1977
|
+
* @param {Boolean} noStore - send without put to the store
|
|
1978
|
+
* @api private
|
|
1979
|
+
*/
|
|
1980
|
+
private _sendPacket(
|
|
1981
|
+
packet: Packet,
|
|
1982
|
+
cb?: DoneCallback,
|
|
1983
|
+
cbStorePut?: DoneCallback,
|
|
1984
|
+
noStore?: boolean,
|
|
1985
|
+
) {
|
|
1986
|
+
this.log('_sendPacket :: (%s) :: start', this.options.clientId)
|
|
1987
|
+
cbStorePut = cbStorePut || this.noop
|
|
1988
|
+
cb = cb || this.noop
|
|
1989
|
+
|
|
1990
|
+
const err = this._applyTopicAlias(packet)
|
|
1991
|
+
if (err) {
|
|
1992
|
+
cb(err)
|
|
1993
|
+
return
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
if (!this.connected) {
|
|
1997
|
+
// allow auth packets to be sent while authenticating with the broker (mqtt5 enhanced auth)
|
|
1998
|
+
if (packet.cmd === 'auth') {
|
|
1999
|
+
this._writePacket(packet, cb)
|
|
2000
|
+
return
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
this.log(
|
|
2004
|
+
'_sendPacket :: client not connected. Storing packet offline.',
|
|
2005
|
+
)
|
|
2006
|
+
this._storePacket(packet, cb, cbStorePut)
|
|
2007
|
+
return
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
// If "noStore" is true, the message is sent without being recorded in the store.
|
|
2011
|
+
// Messages that have not received puback or pubcomp remain in the store after disconnection
|
|
2012
|
+
// and are resent from the store upon reconnection.
|
|
2013
|
+
// For resend upon reconnection, "noStore" is set to true. This is because the message is already stored in the store.
|
|
2014
|
+
// This is to avoid interrupting other processes while recording to the store.
|
|
2015
|
+
if (noStore) {
|
|
2016
|
+
this._writePacket(packet, cb)
|
|
2017
|
+
return
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
switch (packet.cmd) {
|
|
2021
|
+
case 'publish':
|
|
2022
|
+
break
|
|
2023
|
+
case 'pubrel':
|
|
2024
|
+
this._storeAndSend(packet, cb, cbStorePut)
|
|
2025
|
+
return
|
|
2026
|
+
default:
|
|
2027
|
+
this._writePacket(packet, cb)
|
|
2028
|
+
return
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
switch (packet.qos) {
|
|
2032
|
+
case 2:
|
|
2033
|
+
case 1:
|
|
2034
|
+
this._storeAndSend(packet, cb, cbStorePut)
|
|
2035
|
+
break
|
|
2036
|
+
/**
|
|
2037
|
+
* no need of case here since it will be caught by default
|
|
2038
|
+
* and jshint comply that before default it must be a break
|
|
2039
|
+
* anyway it will result in -1 evaluation
|
|
2040
|
+
*/
|
|
2041
|
+
case 0:
|
|
2042
|
+
/* falls through */
|
|
2043
|
+
default:
|
|
2044
|
+
this._writePacket(packet, cb)
|
|
2045
|
+
break
|
|
2046
|
+
}
|
|
2047
|
+
this.log('_sendPacket :: (%s) :: end', this.options.clientId)
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
/**
|
|
2051
|
+
* _storePacket - queue a packet
|
|
2052
|
+
* @param {Object} packet - packet options
|
|
2053
|
+
* @param {Function} cb - callback when the packet is sent
|
|
2054
|
+
* @param {Function} cbStorePut - called when message is put into outgoingStore
|
|
2055
|
+
* @api private
|
|
2056
|
+
*/
|
|
2057
|
+
private _storePacket(
|
|
2058
|
+
packet: Packet,
|
|
2059
|
+
cb: DoneCallback,
|
|
2060
|
+
cbStorePut: DoneCallback,
|
|
2061
|
+
) {
|
|
2062
|
+
this.log('_storePacket :: packet: %o', packet)
|
|
2063
|
+
this.log('_storePacket :: cb? %s', !!cb)
|
|
2064
|
+
cbStorePut = cbStorePut || this.noop
|
|
2065
|
+
|
|
2066
|
+
let storePacket = packet
|
|
2067
|
+
if (storePacket.cmd === 'publish') {
|
|
2068
|
+
// The original packet is for sending.
|
|
2069
|
+
// The cloned storePacket is for storing to resend on reconnect.
|
|
2070
|
+
// Topic Alias must not be used after disconnected.
|
|
2071
|
+
storePacket = clone(packet)
|
|
2072
|
+
const err = this._removeTopicAliasAndRecoverTopicName(
|
|
2073
|
+
storePacket as IPublishPacket,
|
|
2074
|
+
)
|
|
2075
|
+
if (err) {
|
|
2076
|
+
return cb && cb(err)
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
const qos = (storePacket as IPublishPacket).qos || 0
|
|
2081
|
+
// check that the packet is not a qos of 0, or that the command is not a publish
|
|
2082
|
+
if ((qos === 0 && this.queueQoSZero) || storePacket.cmd !== 'publish') {
|
|
2083
|
+
this.queue.push({ packet: storePacket, cb })
|
|
2084
|
+
} else if (qos > 0) {
|
|
2085
|
+
cb = this.outgoing[storePacket.messageId]
|
|
2086
|
+
? this.outgoing[storePacket.messageId].cb
|
|
2087
|
+
: null
|
|
2088
|
+
this.outgoingStore.put(storePacket, (err) => {
|
|
2089
|
+
if (err) {
|
|
2090
|
+
return cb && cb(err)
|
|
2091
|
+
}
|
|
2092
|
+
cbStorePut()
|
|
2093
|
+
})
|
|
2094
|
+
} else if (cb) {
|
|
2095
|
+
cb(new Error('No connection to broker'))
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
/**
|
|
2100
|
+
* _setupKeepaliveManager - setup the keepalive manager
|
|
2101
|
+
*/
|
|
2102
|
+
private _setupKeepaliveManager() {
|
|
2103
|
+
this.log(
|
|
2104
|
+
'_setupKeepaliveManager :: keepalive %d (seconds)',
|
|
2105
|
+
this.options.keepalive,
|
|
2106
|
+
)
|
|
2107
|
+
|
|
2108
|
+
if (!this.keepaliveManager && this.options.keepalive) {
|
|
2109
|
+
this.keepaliveManager = new KeepaliveManager(
|
|
2110
|
+
this,
|
|
2111
|
+
this.options.timerVariant,
|
|
2112
|
+
)
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
private _destroyKeepaliveManager() {
|
|
2117
|
+
if (this.keepaliveManager) {
|
|
2118
|
+
this.log('_destroyKeepaliveManager :: destroying keepalive manager')
|
|
2119
|
+
this.keepaliveManager.destroy()
|
|
2120
|
+
this.keepaliveManager = null
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
/**
|
|
2125
|
+
* Reschedule the ping interval
|
|
2126
|
+
*/
|
|
2127
|
+
public reschedulePing(force = false) {
|
|
2128
|
+
if (
|
|
2129
|
+
this.keepaliveManager &&
|
|
2130
|
+
this.options.keepalive &&
|
|
2131
|
+
(force || this.options.reschedulePings)
|
|
2132
|
+
) {
|
|
2133
|
+
this._reschedulePing()
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
/**
|
|
2138
|
+
* Mostly needed for test purposes
|
|
2139
|
+
*/
|
|
2140
|
+
private _reschedulePing() {
|
|
2141
|
+
this.log('_reschedulePing :: rescheduling ping')
|
|
2142
|
+
this.keepaliveManager.reschedule()
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
public sendPing() {
|
|
2146
|
+
this.log('_sendPing :: sending pingreq')
|
|
2147
|
+
this._sendPacket({ cmd: 'pingreq' })
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
public onKeepaliveTimeout() {
|
|
2151
|
+
this.emit('error', new Error('Keepalive timeout'))
|
|
2152
|
+
this.log('onKeepaliveTimeout :: calling _cleanUp with force true')
|
|
2153
|
+
this._cleanUp(true)
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
/**
|
|
2157
|
+
* _resubscribe
|
|
2158
|
+
* @api private
|
|
2159
|
+
*/
|
|
2160
|
+
private _resubscribe() {
|
|
2161
|
+
this.log('_resubscribe')
|
|
2162
|
+
const _resubscribeTopicsKeys = Object.keys(this._resubscribeTopics)
|
|
2163
|
+
if (
|
|
2164
|
+
!this._firstConnection &&
|
|
2165
|
+
// Only resubscribe in case of clean connection or if the server does not have a stored session.
|
|
2166
|
+
// The Session Present flag is available since v3.1.1
|
|
2167
|
+
// https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349254
|
|
2168
|
+
(this.options.clean ||
|
|
2169
|
+
(this.options.protocolVersion >= 4 &&
|
|
2170
|
+
!this.connackPacket.sessionPresent)) &&
|
|
2171
|
+
_resubscribeTopicsKeys.length > 0
|
|
2172
|
+
) {
|
|
2173
|
+
if (this.options.resubscribe) {
|
|
2174
|
+
if (this.options.protocolVersion === 5) {
|
|
2175
|
+
this.log('_resubscribe: protocolVersion 5')
|
|
2176
|
+
for (
|
|
2177
|
+
let topicI = 0;
|
|
2178
|
+
topicI < _resubscribeTopicsKeys.length;
|
|
2179
|
+
topicI++
|
|
2180
|
+
) {
|
|
2181
|
+
const resubscribeTopic: ISubscriptionMap = {}
|
|
2182
|
+
resubscribeTopic[_resubscribeTopicsKeys[topicI]] =
|
|
2183
|
+
this._resubscribeTopics[
|
|
2184
|
+
_resubscribeTopicsKeys[topicI]
|
|
2185
|
+
]
|
|
2186
|
+
resubscribeTopic.resubscribe = true
|
|
2187
|
+
this.subscribe(resubscribeTopic, {
|
|
2188
|
+
properties:
|
|
2189
|
+
resubscribeTopic[_resubscribeTopicsKeys[topicI]]
|
|
2190
|
+
.properties,
|
|
2191
|
+
})
|
|
2192
|
+
}
|
|
2193
|
+
} else {
|
|
2194
|
+
this._resubscribeTopics.resubscribe = true
|
|
2195
|
+
this.subscribe(this._resubscribeTopics)
|
|
2196
|
+
}
|
|
2197
|
+
} else {
|
|
2198
|
+
this._resubscribeTopics = {}
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
this._firstConnection = false
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
/**
|
|
2206
|
+
* _onConnect
|
|
2207
|
+
*
|
|
2208
|
+
* @api private
|
|
2209
|
+
*/
|
|
2210
|
+
private _onConnect(packet: IConnackPacket) {
|
|
2211
|
+
if (this.disconnected) {
|
|
2212
|
+
this.emit('connect', packet)
|
|
2213
|
+
return
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
this.connackPacket = packet
|
|
2217
|
+
this.messageIdProvider.clear()
|
|
2218
|
+
this._setupKeepaliveManager()
|
|
2219
|
+
|
|
2220
|
+
this.connected = true
|
|
2221
|
+
|
|
2222
|
+
/** check if there are packets in outgoing store and stream them */
|
|
2223
|
+
const startStreamProcess = () => {
|
|
2224
|
+
let outStore = this.outgoingStore.createStream()
|
|
2225
|
+
|
|
2226
|
+
/** destroy the outgoing store stream */
|
|
2227
|
+
const remove = () => {
|
|
2228
|
+
outStore.destroy()
|
|
2229
|
+
outStore = null
|
|
2230
|
+
this._flushStoreProcessingQueue()
|
|
2231
|
+
clearStoreProcessing()
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
/** stop store processing and clear packets id processed */
|
|
2235
|
+
const clearStoreProcessing = () => {
|
|
2236
|
+
this._storeProcessing = false
|
|
2237
|
+
this._packetIdsDuringStoreProcessing = {}
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
this.once('close', remove)
|
|
2241
|
+
outStore.on('error', (err) => {
|
|
2242
|
+
clearStoreProcessing()
|
|
2243
|
+
this._flushStoreProcessingQueue()
|
|
2244
|
+
this.removeListener('close', remove)
|
|
2245
|
+
this.emit('error', err)
|
|
2246
|
+
})
|
|
2247
|
+
|
|
2248
|
+
/** Read next packet in outgoing store and send it */
|
|
2249
|
+
const storeDeliver = () => {
|
|
2250
|
+
// edge case, we wrapped this twice
|
|
2251
|
+
if (!outStore) {
|
|
2252
|
+
return
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
const packet2 = outStore.read(1)
|
|
2256
|
+
|
|
2257
|
+
let cb: PacketCallback
|
|
2258
|
+
|
|
2259
|
+
if (!packet2) {
|
|
2260
|
+
// read when data is available in the future
|
|
2261
|
+
outStore.once('readable', storeDeliver)
|
|
2262
|
+
return
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
this._storeProcessing = true
|
|
2266
|
+
|
|
2267
|
+
// Skip already processed store packets
|
|
2268
|
+
if (this._packetIdsDuringStoreProcessing[packet2.messageId]) {
|
|
2269
|
+
storeDeliver()
|
|
2270
|
+
return
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
// Avoid unnecessary stream read operations when disconnected
|
|
2274
|
+
if (!this.disconnecting && !this.reconnectTimer) {
|
|
2275
|
+
cb = this.outgoing[packet2.messageId]
|
|
2276
|
+
? this.outgoing[packet2.messageId].cb
|
|
2277
|
+
: null
|
|
2278
|
+
this.outgoing[packet2.messageId] = {
|
|
2279
|
+
volatile: false,
|
|
2280
|
+
cb(err, status) {
|
|
2281
|
+
// Ensure that the original callback passed in to publish gets invoked
|
|
2282
|
+
if (cb) {
|
|
2283
|
+
cb(err, status)
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
storeDeliver()
|
|
2287
|
+
},
|
|
2288
|
+
}
|
|
2289
|
+
this._packetIdsDuringStoreProcessing[packet2.messageId] =
|
|
2290
|
+
true
|
|
2291
|
+
if (this.messageIdProvider.register(packet2.messageId)) {
|
|
2292
|
+
this._sendPacket(packet2, undefined, undefined, true)
|
|
2293
|
+
} else {
|
|
2294
|
+
this.log(
|
|
2295
|
+
'messageId: %d has already used.',
|
|
2296
|
+
packet2.messageId,
|
|
2297
|
+
)
|
|
2298
|
+
}
|
|
2299
|
+
} else if (outStore.destroy) {
|
|
2300
|
+
outStore.destroy()
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
outStore.on('end', () => {
|
|
2305
|
+
let allProcessed = true
|
|
2306
|
+
for (const id in this._packetIdsDuringStoreProcessing) {
|
|
2307
|
+
if (!this._packetIdsDuringStoreProcessing[id]) {
|
|
2308
|
+
allProcessed = false
|
|
2309
|
+
break
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
this.removeListener('close', remove)
|
|
2313
|
+
if (allProcessed) {
|
|
2314
|
+
clearStoreProcessing()
|
|
2315
|
+
this._invokeAllStoreProcessingQueue()
|
|
2316
|
+
this.emit('connect', packet)
|
|
2317
|
+
} else {
|
|
2318
|
+
startStreamProcess()
|
|
2319
|
+
}
|
|
2320
|
+
})
|
|
2321
|
+
storeDeliver()
|
|
2322
|
+
}
|
|
2323
|
+
// start flowing
|
|
2324
|
+
startStreamProcess()
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
private _invokeStoreProcessingQueue() {
|
|
2328
|
+
// If _storeProcessing is true, the message is resending.
|
|
2329
|
+
// During resend, processing is skipped to prevent new messages from interrupting. #1635
|
|
2330
|
+
if (!this._storeProcessing && this._storeProcessingQueue.length > 0) {
|
|
2331
|
+
const f = this._storeProcessingQueue[0]
|
|
2332
|
+
if (f && f.invoke()) {
|
|
2333
|
+
this._storeProcessingQueue.shift()
|
|
2334
|
+
return true
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
return false
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
private _invokeAllStoreProcessingQueue() {
|
|
2341
|
+
while (this._invokeStoreProcessingQueue()) {
|
|
2342
|
+
/* empty */
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
private _flushStoreProcessingQueue() {
|
|
2347
|
+
for (const f of this._storeProcessingQueue) {
|
|
2348
|
+
if (f.cbStorePut) f.cbStorePut(new Error('Connection closed'))
|
|
2349
|
+
if (f.callback) f.callback(new Error('Connection closed'))
|
|
2350
|
+
}
|
|
2351
|
+
this._storeProcessingQueue.splice(0)
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
/**
|
|
2355
|
+
* _removeOutgoingAndStoreMessage
|
|
2356
|
+
* @param {Number} messageId - messageId to remove message
|
|
2357
|
+
* @param {Function} cb - called when the message removed
|
|
2358
|
+
* @api private
|
|
2359
|
+
*/
|
|
2360
|
+
private _removeOutgoingAndStoreMessage(
|
|
2361
|
+
messageId: number,
|
|
2362
|
+
cb: PacketCallback,
|
|
2363
|
+
) {
|
|
2364
|
+
delete this.outgoing[messageId]
|
|
2365
|
+
this.outgoingStore.del({ messageId }, (err, packet) => {
|
|
2366
|
+
cb(err, packet)
|
|
2367
|
+
this.messageIdProvider.deallocate(messageId)
|
|
2368
|
+
this._invokeStoreProcessingQueue()
|
|
2369
|
+
})
|
|
2370
|
+
}
|
|
2371
|
+
}
|