peerpigeon 1.1.2 โ 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +9011 -0
- package/dist/index.d.cts +2027 -0
- package/dist/index.d.ts +2027 -0
- package/dist/index.js +8944 -0
- package/package.json +53 -86
- package/LICENSE +0 -21
- package/README.md +0 -317
- package/cli.js +0 -1382
- package/dist/peerpigeon-browser.js +0 -13322
- package/dist/peerpigeon-browser.js.map +0 -7
- package/docs/API_DOCUMENTATION.md +0 -1976
- package/docs/BINARY_IMPLEMENTATION_SUMMARY.md +0 -304
- package/docs/BINARY_MESSAGES.md +0 -332
- package/docs/BOOTSTRAP_HUBS.md +0 -319
- package/docs/BROADCAST_STREAMING.md +0 -388
- package/docs/CLI_README.md +0 -371
- package/docs/CLOUD_DEPLOYMENT.md +0 -132
- package/docs/CUSTOM_HUB_NAMESPACES.md +0 -182
- package/docs/CUSTOM_NAMESPACE_IMPLEMENTATION.md +0 -187
- package/docs/DOCUMENTATION_REORGANIZATION.md +0 -172
- package/docs/HUB_P2P_MESH.md +0 -358
- package/docs/HUB_QUICK_REF.md +0 -108
- package/docs/HUB_SCRIPTS.md +0 -341
- package/docs/HUB_SYSTEM.md +0 -599
- package/docs/LOCAL_TESTING.md +0 -135
- package/docs/MIGRATION_COMPLETE.md +0 -93
- package/docs/NETWORK_NAMESPACES.md +0 -212
- package/docs/PIGEONRTC_MIGRATION.md +0 -280
- package/docs/README.md +0 -108
- package/docs/SELECTIVE_STREAMING_GUIDE.md +0 -427
- package/docs/STREAMING_API.md +0 -542
- package/docs/STREAMING_IMPLEMENTATION_SUMMARY.md +0 -286
- package/docs/TEST_CLEANUP_COMPLETE.md +0 -80
- package/examples/binary-message-demo.html +0 -496
- package/examples/bootstrap-hub-example.js +0 -292
- package/examples/broadcast-stream-demo.html +0 -539
- package/examples/browser/vanilla/README.md +0 -278
- package/examples/browser/vanilla/app.js +0 -2478
- package/examples/browser/vanilla/index.html +0 -603
- package/examples/browser/vanilla/minimal/README.md +0 -55
- package/examples/browser/vanilla/minimal/index.html +0 -75
- package/examples/browser/vanilla/minimal/minimal.js +0 -234
- package/examples/browser/vanilla/peerpigeon-browser.js +0 -13322
- package/examples/browser/vanilla/pigeonlogo.svg +0 -51
- package/examples/browser/vanilla/styles.css +0 -998
- package/examples/browser/vanilla/test-bundle.html +0 -35
- package/examples/browser/vue/EXPRESS_SOLUTION.md +0 -183
- package/examples/browser/vue/ICE_DEBUG.md +0 -171
- package/examples/browser/vue/IMPLEMENTATION.md +0 -218
- package/examples/browser/vue/QUICK_START.md +0 -149
- package/examples/browser/vue/README.md +0 -303
- package/examples/browser/vue/dist/assets/index-DJmfz_4i.js +0 -57
- package/examples/browser/vue/dist/assets/index-zmUJURg4.css +0 -1
- package/examples/browser/vue/dist/index.html +0 -32
- package/examples/browser/vue/dist/peerpigeon-browser.js +0 -13322
- package/examples/browser/vue/dist/pigeonlogo.svg +0 -51
- package/examples/browser/vue/index.html +0 -31
- package/examples/browser/vue/node_modules/.package-lock.json +0 -1305
- package/examples/browser/vue/node_modules/.vue-global-types/vue_99_0.d.ts +0 -136
- package/examples/browser/vue/node_modules/@babel/helper-string-parser/LICENSE +0 -22
- package/examples/browser/vue/node_modules/@babel/helper-string-parser/README.md +0 -19
- package/examples/browser/vue/node_modules/@babel/helper-string-parser/lib/index.js +0 -295
- package/examples/browser/vue/node_modules/@babel/helper-string-parser/lib/index.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/helper-string-parser/package.json +0 -31
- package/examples/browser/vue/node_modules/@babel/helper-validator-identifier/LICENSE +0 -22
- package/examples/browser/vue/node_modules/@babel/helper-validator-identifier/README.md +0 -19
- package/examples/browser/vue/node_modules/@babel/helper-validator-identifier/lib/identifier.js +0 -70
- package/examples/browser/vue/node_modules/@babel/helper-validator-identifier/lib/identifier.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/helper-validator-identifier/lib/index.js +0 -57
- package/examples/browser/vue/node_modules/@babel/helper-validator-identifier/lib/index.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/helper-validator-identifier/lib/keyword.js +0 -35
- package/examples/browser/vue/node_modules/@babel/helper-validator-identifier/lib/keyword.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/helper-validator-identifier/package.json +0 -31
- package/examples/browser/vue/node_modules/@babel/parser/CHANGELOG.md +0 -1073
- package/examples/browser/vue/node_modules/@babel/parser/LICENSE +0 -19
- package/examples/browser/vue/node_modules/@babel/parser/README.md +0 -19
- package/examples/browser/vue/node_modules/@babel/parser/bin/babel-parser.js +0 -15
- package/examples/browser/vue/node_modules/@babel/parser/lib/index.js +0 -14595
- package/examples/browser/vue/node_modules/@babel/parser/lib/index.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/parser/package.json +0 -50
- package/examples/browser/vue/node_modules/@babel/parser/typings/babel-parser.d.ts +0 -239
- package/examples/browser/vue/node_modules/@babel/types/LICENSE +0 -22
- package/examples/browser/vue/node_modules/@babel/types/README.md +0 -19
- package/examples/browser/vue/node_modules/@babel/types/lib/asserts/assertNode.js +0 -16
- package/examples/browser/vue/node_modules/@babel/types/lib/asserts/assertNode.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/asserts/generated/index.js +0 -1251
- package/examples/browser/vue/node_modules/@babel/types/lib/asserts/generated/index.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/ast-types/generated/index.js +0 -3
- package/examples/browser/vue/node_modules/@babel/types/lib/ast-types/generated/index.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/flow/createFlowUnionType.js +0 -18
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/flow/createFlowUnionType.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/flow/createTypeAnnotationBasedOnTypeof.js +0 -31
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/flow/createTypeAnnotationBasedOnTypeof.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/generated/index.js +0 -29
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/generated/index.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/generated/lowercase.js +0 -2896
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/generated/lowercase.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/generated/uppercase.js +0 -274
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/generated/uppercase.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/productions.js +0 -12
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/productions.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/react/buildChildren.js +0 -24
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/react/buildChildren.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js +0 -22
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/typescript/createTSUnionType.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/validateNode.js +0 -21
- package/examples/browser/vue/node_modules/@babel/types/lib/builders/validateNode.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/clone/clone.js +0 -12
- package/examples/browser/vue/node_modules/@babel/types/lib/clone/clone.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/clone/cloneDeep.js +0 -12
- package/examples/browser/vue/node_modules/@babel/types/lib/clone/cloneDeep.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/clone/cloneDeepWithoutLoc.js +0 -12
- package/examples/browser/vue/node_modules/@babel/types/lib/clone/cloneDeepWithoutLoc.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/clone/cloneNode.js +0 -107
- package/examples/browser/vue/node_modules/@babel/types/lib/clone/cloneNode.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/clone/cloneWithoutLoc.js +0 -12
- package/examples/browser/vue/node_modules/@babel/types/lib/clone/cloneWithoutLoc.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/addComment.js +0 -15
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/addComment.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/addComments.js +0 -22
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/addComments.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/inheritInnerComments.js +0 -12
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/inheritInnerComments.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/inheritLeadingComments.js +0 -12
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/inheritLeadingComments.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/inheritTrailingComments.js +0 -12
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/inheritTrailingComments.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/inheritsComments.js +0 -17
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/inheritsComments.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/removeComments.js +0 -15
- package/examples/browser/vue/node_modules/@babel/types/lib/comments/removeComments.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/constants/generated/index.js +0 -60
- package/examples/browser/vue/node_modules/@babel/types/lib/constants/generated/index.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/constants/index.js +0 -33
- package/examples/browser/vue/node_modules/@babel/types/lib/constants/index.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/ensureBlock.js +0 -14
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/ensureBlock.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/gatherSequenceExpressions.js +0 -66
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/gatherSequenceExpressions.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toBindingIdentifierName.js +0 -14
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toBindingIdentifierName.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toBlock.js +0 -29
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toBlock.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toComputedKey.js +0 -14
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toComputedKey.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toExpression.js +0 -28
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toExpression.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toIdentifier.js +0 -25
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toIdentifier.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toKeyAlias.js +0 -38
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toKeyAlias.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toSequenceExpression.js +0 -20
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toSequenceExpression.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toStatement.js +0 -39
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/toStatement.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/valueToNode.js +0 -89
- package/examples/browser/vue/node_modules/@babel/types/lib/converters/valueToNode.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/core.js +0 -1659
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/core.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/deprecated-aliases.js +0 -11
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/deprecated-aliases.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/experimental.js +0 -126
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/experimental.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/flow.js +0 -495
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/flow.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/index.js +0 -100
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/index.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/jsx.js +0 -157
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/jsx.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/misc.js +0 -33
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/misc.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/placeholders.js +0 -27
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/placeholders.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/typescript.js +0 -528
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/typescript.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/utils.js +0 -292
- package/examples/browser/vue/node_modules/@babel/types/lib/definitions/utils.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/index-legacy.d.ts +0 -2797
- package/examples/browser/vue/node_modules/@babel/types/lib/index.d.ts +0 -3308
- package/examples/browser/vue/node_modules/@babel/types/lib/index.js +0 -584
- package/examples/browser/vue/node_modules/@babel/types/lib/index.js.flow +0 -2650
- package/examples/browser/vue/node_modules/@babel/types/lib/index.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/appendToMemberExpression.js +0 -15
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/appendToMemberExpression.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js +0 -65
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/flow/removeTypeDuplicates.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/inherits.js +0 -28
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/inherits.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/prependToMemberExpression.js +0 -17
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/prependToMemberExpression.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/removeProperties.js +0 -24
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/removeProperties.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/removePropertiesDeep.js +0 -14
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/removePropertiesDeep.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/typescript/removeTypeDuplicates.js +0 -66
- package/examples/browser/vue/node_modules/@babel/types/lib/modifications/typescript/removeTypeDuplicates.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/retrievers/getAssignmentIdentifiers.js +0 -48
- package/examples/browser/vue/node_modules/@babel/types/lib/retrievers/getAssignmentIdentifiers.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/retrievers/getBindingIdentifiers.js +0 -102
- package/examples/browser/vue/node_modules/@babel/types/lib/retrievers/getBindingIdentifiers.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/retrievers/getFunctionName.js +0 -63
- package/examples/browser/vue/node_modules/@babel/types/lib/retrievers/getFunctionName.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/retrievers/getOuterBindingIdentifiers.js +0 -13
- package/examples/browser/vue/node_modules/@babel/types/lib/retrievers/getOuterBindingIdentifiers.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/traverse/traverse.js +0 -50
- package/examples/browser/vue/node_modules/@babel/types/lib/traverse/traverse.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/traverse/traverseFast.js +0 -40
- package/examples/browser/vue/node_modules/@babel/types/lib/traverse/traverseFast.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/utils/deprecationWarning.js +0 -44
- package/examples/browser/vue/node_modules/@babel/types/lib/utils/deprecationWarning.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/utils/inherit.js +0 -13
- package/examples/browser/vue/node_modules/@babel/types/lib/utils/inherit.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js +0 -40
- package/examples/browser/vue/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/utils/shallowEqual.js +0 -17
- package/examples/browser/vue/node_modules/@babel/types/lib/utils/shallowEqual.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/buildMatchMemberExpression.js +0 -13
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/buildMatchMemberExpression.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/generated/index.js +0 -2797
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/generated/index.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/is.js +0 -27
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/is.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isBinding.js +0 -27
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isBinding.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isBlockScoped.js +0 -13
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isBlockScoped.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isImmutable.js +0 -21
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isImmutable.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isLet.js +0 -17
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isLet.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isNode.js +0 -12
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isNode.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isNodesEquivalent.js +0 -57
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isNodesEquivalent.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isPlaceholderType.js +0 -15
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isPlaceholderType.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isReferenced.js +0 -96
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isReferenced.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isScope.js +0 -18
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isScope.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isSpecifierDefault.js +0 -14
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isSpecifierDefault.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isType.js +0 -17
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isType.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isValidES3Identifier.js +0 -13
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isValidES3Identifier.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isValidIdentifier.js +0 -18
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isValidIdentifier.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isVar.js +0 -19
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/isVar.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/matchesPattern.js +0 -44
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/matchesPattern.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/react/isCompatTag.js +0 -11
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/react/isCompatTag.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/react/isReactComponent.js +0 -11
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/react/isReactComponent.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/validate.js +0 -42
- package/examples/browser/vue/node_modules/@babel/types/lib/validators/validate.js.map +0 -1
- package/examples/browser/vue/node_modules/@babel/types/package.json +0 -39
- package/examples/browser/vue/node_modules/@esbuild/darwin-arm64/README.md +0 -3
- package/examples/browser/vue/node_modules/@esbuild/darwin-arm64/bin/esbuild +0 -0
- package/examples/browser/vue/node_modules/@esbuild/darwin-arm64/package.json +0 -20
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/LICENSE +0 -19
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/README.md +0 -264
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +0 -423
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +0 -6
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +0 -464
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map +0 -6
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/package.json +0 -63
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/src/scopes.ts +0 -345
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts +0 -111
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/src/strings.ts +0 -65
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/src/vlq.ts +0 -55
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts +0 -50
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts.map +0 -1
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts +0 -50
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts.map +0 -1
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts +0 -9
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts.map +0 -1
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts +0 -9
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts.map +0 -1
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts +0 -16
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/strings.d.cts.map +0 -1
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts +0 -16
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts.map +0 -1
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts +0 -7
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts.map +0 -1
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts +0 -7
- package/examples/browser/vue/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts.map +0 -1
- package/examples/browser/vue/node_modules/@rollup/rollup-darwin-arm64/README.md +0 -3
- package/examples/browser/vue/node_modules/@rollup/rollup-darwin-arm64/package.json +0 -22
- package/examples/browser/vue/node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node +0 -0
- package/examples/browser/vue/node_modules/@types/estree/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@types/estree/README.md +0 -15
- package/examples/browser/vue/node_modules/@types/estree/flow.d.ts +0 -167
- package/examples/browser/vue/node_modules/@types/estree/index.d.ts +0 -694
- package/examples/browser/vue/node_modules/@types/estree/package.json +0 -27
- package/examples/browser/vue/node_modules/@types/web-bluetooth/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@types/web-bluetooth/README.md +0 -15
- package/examples/browser/vue/node_modules/@types/web-bluetooth/index.d.ts +0 -193
- package/examples/browser/vue/node_modules/@types/web-bluetooth/package.json +0 -40
- package/examples/browser/vue/node_modules/@vitejs/plugin-vue/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vitejs/plugin-vue/README.md +0 -278
- package/examples/browser/vue/node_modules/@vitejs/plugin-vue/dist/index.cjs +0 -3105
- package/examples/browser/vue/node_modules/@vitejs/plugin-vue/dist/index.d.cts +0 -113
- package/examples/browser/vue/node_modules/@vitejs/plugin-vue/dist/index.d.mts +0 -111
- package/examples/browser/vue/node_modules/@vitejs/plugin-vue/dist/index.d.ts +0 -113
- package/examples/browser/vue/node_modules/@vitejs/plugin-vue/dist/index.mjs +0 -3090
- package/examples/browser/vue/node_modules/@vitejs/plugin-vue/package.json +0 -50
- package/examples/browser/vue/node_modules/@vue/compiler-core/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vue/compiler-core/README.md +0 -1
- package/examples/browser/vue/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js +0 -6864
- package/examples/browser/vue/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +0 -6741
- package/examples/browser/vue/node_modules/@vue/compiler-core/dist/compiler-core.d.ts +0 -1096
- package/examples/browser/vue/node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js +0 -5814
- package/examples/browser/vue/node_modules/@vue/compiler-core/index.js +0 -7
- package/examples/browser/vue/node_modules/@vue/compiler-core/package.json +0 -58
- package/examples/browser/vue/node_modules/@vue/compiler-dom/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vue/compiler-dom/README.md +0 -1
- package/examples/browser/vue/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js +0 -934
- package/examples/browser/vue/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +0 -689
- package/examples/browser/vue/node_modules/@vue/compiler-dom/dist/compiler-dom.d.ts +0 -45
- package/examples/browser/vue/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +0 -6623
- package/examples/browser/vue/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +0 -14
- package/examples/browser/vue/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +0 -690
- package/examples/browser/vue/node_modules/@vue/compiler-dom/dist/compiler-dom.global.js +0 -6790
- package/examples/browser/vue/node_modules/@vue/compiler-dom/dist/compiler-dom.global.prod.js +0 -14
- package/examples/browser/vue/node_modules/@vue/compiler-dom/index.js +0 -7
- package/examples/browser/vue/node_modules/@vue/compiler-dom/package.json +0 -57
- package/examples/browser/vue/node_modules/@vue/compiler-sfc/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vue/compiler-sfc/README.md +0 -80
- package/examples/browser/vue/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +0 -25084
- package/examples/browser/vue/node_modules/@vue/compiler-sfc/dist/compiler-sfc.d.ts +0 -485
- package/examples/browser/vue/node_modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +0 -50571
- package/examples/browser/vue/node_modules/@vue/compiler-sfc/package.json +0 -67
- package/examples/browser/vue/node_modules/@vue/compiler-ssr/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vue/compiler-ssr/README.md +0 -1
- package/examples/browser/vue/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +0 -1411
- package/examples/browser/vue/node_modules/@vue/compiler-ssr/dist/compiler-ssr.d.ts +0 -4
- package/examples/browser/vue/node_modules/@vue/compiler-ssr/package.json +0 -34
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/api/api.js +0 -2
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/api/app.js +0 -2
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/api/component.js +0 -2
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/api/context.js +0 -2
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/api/hooks.js +0 -2
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/api/index.js +0 -22
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/api/util.js +0 -2
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/const.js +0 -5
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/env.js +0 -17
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/index.js +0 -45
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/plugin.js +0 -2
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/proxy.js +0 -111
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/cjs/time.js +0 -28
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/api.d.ts +0 -108
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/api.js +0 -1
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/app.d.ts +0 -1
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/app.js +0 -1
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/component.d.ts +0 -78
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/component.js +0 -1
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/context.d.ts +0 -5
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/context.js +0 -1
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/hooks.d.ts +0 -180
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/hooks.js +0 -1
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/index.d.ts +0 -6
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/index.js +0 -6
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/util.d.ts +0 -4
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/api/util.js +0 -1
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/const.d.ts +0 -2
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/const.js +0 -2
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/env.d.ts +0 -15
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/env.js +0 -12
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/index.d.ts +0 -18
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/index.js +0 -27
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/plugin.d.ts +0 -47
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/plugin.js +0 -1
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/proxy.d.ts +0 -20
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/proxy.js +0 -107
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/time.d.ts +0 -2
- package/examples/browser/vue/node_modules/@vue/devtools-api/lib/esm/time.js +0 -23
- package/examples/browser/vue/node_modules/@vue/devtools-api/package.json +0 -37
- package/examples/browser/vue/node_modules/@vue/reactivity/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vue/reactivity/README.md +0 -19
- package/examples/browser/vue/node_modules/@vue/reactivity/dist/reactivity.cjs.js +0 -1963
- package/examples/browser/vue/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +0 -1807
- package/examples/browser/vue/node_modules/@vue/reactivity/dist/reactivity.d.ts +0 -757
- package/examples/browser/vue/node_modules/@vue/reactivity/dist/reactivity.esm-browser.js +0 -1961
- package/examples/browser/vue/node_modules/@vue/reactivity/dist/reactivity.esm-browser.prod.js +0 -5
- package/examples/browser/vue/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js +0 -1920
- package/examples/browser/vue/node_modules/@vue/reactivity/dist/reactivity.global.js +0 -2017
- package/examples/browser/vue/node_modules/@vue/reactivity/dist/reactivity.global.prod.js +0 -5
- package/examples/browser/vue/node_modules/@vue/reactivity/index.js +0 -7
- package/examples/browser/vue/node_modules/@vue/reactivity/package.json +0 -55
- package/examples/browser/vue/node_modules/@vue/runtime-core/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vue/runtime-core/README.md +0 -28
- package/examples/browser/vue/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js +0 -8586
- package/examples/browser/vue/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +0 -6732
- package/examples/browser/vue/node_modules/@vue/runtime-core/dist/runtime-core.d.ts +0 -1839
- package/examples/browser/vue/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +0 -8515
- package/examples/browser/vue/node_modules/@vue/runtime-core/index.js +0 -7
- package/examples/browser/vue/node_modules/@vue/runtime-core/package.json +0 -52
- package/examples/browser/vue/node_modules/@vue/runtime-dom/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vue/runtime-dom/README.md +0 -13
- package/examples/browser/vue/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js +0 -1851
- package/examples/browser/vue/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +0 -1703
- package/examples/browser/vue/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +0 -1409
- package/examples/browser/vue/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-browser.js +0 -12499
- package/examples/browser/vue/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-browser.prod.js +0 -6
- package/examples/browser/vue/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +0 -1892
- package/examples/browser/vue/node_modules/@vue/runtime-dom/dist/runtime-dom.global.js +0 -12550
- package/examples/browser/vue/node_modules/@vue/runtime-dom/dist/runtime-dom.global.prod.js +0 -6
- package/examples/browser/vue/node_modules/@vue/runtime-dom/index.js +0 -7
- package/examples/browser/vue/node_modules/@vue/runtime-dom/package.json +0 -60
- package/examples/browser/vue/node_modules/@vue/server-renderer/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vue/server-renderer/README.md +0 -178
- package/examples/browser/vue/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js +0 -1151
- package/examples/browser/vue/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +0 -879
- package/examples/browser/vue/node_modules/@vue/server-renderer/dist/server-renderer.d.ts +0 -65
- package/examples/browser/vue/node_modules/@vue/server-renderer/dist/server-renderer.esm-browser.js +0 -8488
- package/examples/browser/vue/node_modules/@vue/server-renderer/dist/server-renderer.esm-browser.prod.js +0 -5
- package/examples/browser/vue/node_modules/@vue/server-renderer/dist/server-renderer.esm-bundler.js +0 -1088
- package/examples/browser/vue/node_modules/@vue/server-renderer/index.js +0 -7
- package/examples/browser/vue/node_modules/@vue/server-renderer/package.json +0 -55
- package/examples/browser/vue/node_modules/@vue/shared/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vue/shared/README.md +0 -3
- package/examples/browser/vue/node_modules/@vue/shared/dist/shared.cjs.js +0 -612
- package/examples/browser/vue/node_modules/@vue/shared/dist/shared.cjs.prod.js +0 -604
- package/examples/browser/vue/node_modules/@vue/shared/dist/shared.d.ts +0 -334
- package/examples/browser/vue/node_modules/@vue/shared/dist/shared.esm-bundler.js +0 -536
- package/examples/browser/vue/node_modules/@vue/shared/index.js +0 -7
- package/examples/browser/vue/node_modules/@vue/shared/package.json +0 -47
- package/examples/browser/vue/node_modules/@vueuse/core/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vueuse/core/README.md +0 -124
- package/examples/browser/vue/node_modules/@vueuse/core/index.cjs +0 -7660
- package/examples/browser/vue/node_modules/@vueuse/core/index.d.cts +0 -5382
- package/examples/browser/vue/node_modules/@vueuse/core/index.d.mts +0 -5382
- package/examples/browser/vue/node_modules/@vueuse/core/index.d.ts +0 -5382
- package/examples/browser/vue/node_modules/@vueuse/core/index.iife.js +0 -7780
- package/examples/browser/vue/node_modules/@vueuse/core/index.iife.min.js +0 -1
- package/examples/browser/vue/node_modules/@vueuse/core/index.mjs +0 -7486
- package/examples/browser/vue/node_modules/@vueuse/core/metadata.cjs +0 -1
- package/examples/browser/vue/node_modules/@vueuse/core/metadata.d.cts +0 -1
- package/examples/browser/vue/node_modules/@vueuse/core/metadata.d.mts +0 -1
- package/examples/browser/vue/node_modules/@vueuse/core/metadata.d.ts +0 -1
- package/examples/browser/vue/node_modules/@vueuse/core/metadata.mjs +0 -1
- package/examples/browser/vue/node_modules/@vueuse/core/package.json +0 -45
- package/examples/browser/vue/node_modules/@vueuse/metadata/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vueuse/metadata/index.cjs +0 -2638
- package/examples/browser/vue/node_modules/@vueuse/metadata/index.d.cts +0 -76
- package/examples/browser/vue/node_modules/@vueuse/metadata/index.d.mts +0 -76
- package/examples/browser/vue/node_modules/@vueuse/metadata/index.d.ts +0 -76
- package/examples/browser/vue/node_modules/@vueuse/metadata/index.json +0 -2584
- package/examples/browser/vue/node_modules/@vueuse/metadata/index.mjs +0 -2626
- package/examples/browser/vue/node_modules/@vueuse/metadata/package.json +0 -39
- package/examples/browser/vue/node_modules/@vueuse/shared/LICENSE +0 -21
- package/examples/browser/vue/node_modules/@vueuse/shared/index.cjs +0 -1695
- package/examples/browser/vue/node_modules/@vueuse/shared/index.d.cts +0 -1221
- package/examples/browser/vue/node_modules/@vueuse/shared/index.d.mts +0 -1221
- package/examples/browser/vue/node_modules/@vueuse/shared/index.d.ts +0 -1221
- package/examples/browser/vue/node_modules/@vueuse/shared/index.iife.js +0 -1816
- package/examples/browser/vue/node_modules/@vueuse/shared/index.iife.min.js +0 -1
- package/examples/browser/vue/node_modules/@vueuse/shared/index.mjs +0 -1575
- package/examples/browser/vue/node_modules/@vueuse/shared/package.json +0 -37
- package/examples/browser/vue/node_modules/csstype/LICENSE +0 -19
- package/examples/browser/vue/node_modules/csstype/README.md +0 -277
- package/examples/browser/vue/node_modules/csstype/index.d.ts +0 -21297
- package/examples/browser/vue/node_modules/csstype/index.js.flow +0 -6612
- package/examples/browser/vue/node_modules/csstype/package.json +0 -66
- package/examples/browser/vue/node_modules/entities/LICENSE +0 -11
- package/examples/browser/vue/node_modules/entities/lib/decode.d.ts +0 -211
- package/examples/browser/vue/node_modules/entities/lib/decode.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/decode.js +0 -536
- package/examples/browser/vue/node_modules/entities/lib/decode.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/decode_codepoint.d.ts +0 -19
- package/examples/browser/vue/node_modules/entities/lib/decode_codepoint.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/decode_codepoint.js +0 -76
- package/examples/browser/vue/node_modules/entities/lib/decode_codepoint.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/encode.d.ts +0 -22
- package/examples/browser/vue/node_modules/entities/lib/encode.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/encode.js +0 -77
- package/examples/browser/vue/node_modules/entities/lib/encode.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/escape.d.ts +0 -43
- package/examples/browser/vue/node_modules/entities/lib/escape.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/escape.js +0 -122
- package/examples/browser/vue/node_modules/entities/lib/escape.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/decode.d.ts +0 -211
- package/examples/browser/vue/node_modules/entities/lib/esm/decode.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/decode.js +0 -496
- package/examples/browser/vue/node_modules/entities/lib/esm/decode.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/decode_codepoint.d.ts +0 -19
- package/examples/browser/vue/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/decode_codepoint.js +0 -71
- package/examples/browser/vue/node_modules/entities/lib/esm/decode_codepoint.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/encode.d.ts +0 -22
- package/examples/browser/vue/node_modules/entities/lib/esm/encode.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/encode.js +0 -69
- package/examples/browser/vue/node_modules/entities/lib/esm/encode.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/escape.d.ts +0 -43
- package/examples/browser/vue/node_modules/entities/lib/esm/escape.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/escape.js +0 -116
- package/examples/browser/vue/node_modules/entities/lib/esm/escape.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +0 -3
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/decode-data-html.js +0 -7
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/decode-data-html.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +0 -3
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/decode-data-xml.js +0 -7
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/encode-html.d.ts +0 -8
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/encode-html.js +0 -10
- package/examples/browser/vue/node_modules/entities/lib/esm/generated/encode-html.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/index.d.ts +0 -96
- package/examples/browser/vue/node_modules/entities/lib/esm/index.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/index.js +0 -99
- package/examples/browser/vue/node_modules/entities/lib/esm/index.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/esm/package.json +0 -1
- package/examples/browser/vue/node_modules/entities/lib/generated/decode-data-html.d.ts +0 -3
- package/examples/browser/vue/node_modules/entities/lib/generated/decode-data-html.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/generated/decode-data-html.js +0 -9
- package/examples/browser/vue/node_modules/entities/lib/generated/decode-data-html.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/generated/decode-data-xml.d.ts +0 -3
- package/examples/browser/vue/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/generated/decode-data-xml.js +0 -9
- package/examples/browser/vue/node_modules/entities/lib/generated/decode-data-xml.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/generated/encode-html.d.ts +0 -8
- package/examples/browser/vue/node_modules/entities/lib/generated/encode-html.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/generated/encode-html.js +0 -12
- package/examples/browser/vue/node_modules/entities/lib/generated/encode-html.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/index.d.ts +0 -96
- package/examples/browser/vue/node_modules/entities/lib/index.d.ts.map +0 -1
- package/examples/browser/vue/node_modules/entities/lib/index.js +0 -126
- package/examples/browser/vue/node_modules/entities/lib/index.js.map +0 -1
- package/examples/browser/vue/node_modules/entities/package.json +0 -90
- package/examples/browser/vue/node_modules/entities/readme.md +0 -122
- package/examples/browser/vue/node_modules/esbuild/LICENSE.md +0 -21
- package/examples/browser/vue/node_modules/esbuild/README.md +0 -3
- package/examples/browser/vue/node_modules/esbuild/bin/esbuild +0 -0
- package/examples/browser/vue/node_modules/esbuild/install.js +0 -285
- package/examples/browser/vue/node_modules/esbuild/lib/main.d.ts +0 -705
- package/examples/browser/vue/node_modules/esbuild/lib/main.js +0 -2239
- package/examples/browser/vue/node_modules/esbuild/package.json +0 -46
- package/examples/browser/vue/node_modules/estree-walker/CHANGELOG.md +0 -92
- package/examples/browser/vue/node_modules/estree-walker/LICENSE +0 -7
- package/examples/browser/vue/node_modules/estree-walker/README.md +0 -48
- package/examples/browser/vue/node_modules/estree-walker/dist/esm/estree-walker.js +0 -333
- package/examples/browser/vue/node_modules/estree-walker/dist/esm/package.json +0 -1
- package/examples/browser/vue/node_modules/estree-walker/dist/umd/estree-walker.js +0 -344
- package/examples/browser/vue/node_modules/estree-walker/package.json +0 -37
- package/examples/browser/vue/node_modules/estree-walker/src/async.js +0 -118
- package/examples/browser/vue/node_modules/estree-walker/src/index.js +0 -35
- package/examples/browser/vue/node_modules/estree-walker/src/package.json +0 -1
- package/examples/browser/vue/node_modules/estree-walker/src/sync.js +0 -118
- package/examples/browser/vue/node_modules/estree-walker/src/walker.js +0 -61
- package/examples/browser/vue/node_modules/estree-walker/types/async.d.ts +0 -53
- package/examples/browser/vue/node_modules/estree-walker/types/index.d.ts +0 -56
- package/examples/browser/vue/node_modules/estree-walker/types/sync.d.ts +0 -53
- package/examples/browser/vue/node_modules/estree-walker/types/tsconfig.tsbuildinfo +0 -345
- package/examples/browser/vue/node_modules/estree-walker/types/walker.d.ts +0 -37
- package/examples/browser/vue/node_modules/fsevents/LICENSE +0 -22
- package/examples/browser/vue/node_modules/fsevents/README.md +0 -89
- package/examples/browser/vue/node_modules/fsevents/fsevents.d.ts +0 -46
- package/examples/browser/vue/node_modules/fsevents/fsevents.js +0 -83
- package/examples/browser/vue/node_modules/fsevents/fsevents.node +0 -0
- package/examples/browser/vue/node_modules/fsevents/package.json +0 -62
- package/examples/browser/vue/node_modules/magic-string/LICENSE +0 -7
- package/examples/browser/vue/node_modules/magic-string/README.md +0 -324
- package/examples/browser/vue/node_modules/magic-string/dist/magic-string.cjs.d.ts +0 -289
- package/examples/browser/vue/node_modules/magic-string/dist/magic-string.cjs.js +0 -1594
- package/examples/browser/vue/node_modules/magic-string/dist/magic-string.cjs.js.map +0 -1
- package/examples/browser/vue/node_modules/magic-string/dist/magic-string.es.d.mts +0 -289
- package/examples/browser/vue/node_modules/magic-string/dist/magic-string.es.mjs +0 -1588
- package/examples/browser/vue/node_modules/magic-string/dist/magic-string.es.mjs.map +0 -1
- package/examples/browser/vue/node_modules/magic-string/dist/magic-string.umd.js +0 -1682
- package/examples/browser/vue/node_modules/magic-string/dist/magic-string.umd.js.map +0 -1
- package/examples/browser/vue/node_modules/magic-string/package.json +0 -70
- package/examples/browser/vue/node_modules/nanoid/LICENSE +0 -20
- package/examples/browser/vue/node_modules/nanoid/README.md +0 -39
- package/examples/browser/vue/node_modules/nanoid/async/index.browser.cjs +0 -69
- package/examples/browser/vue/node_modules/nanoid/async/index.browser.js +0 -34
- package/examples/browser/vue/node_modules/nanoid/async/index.cjs +0 -71
- package/examples/browser/vue/node_modules/nanoid/async/index.d.ts +0 -56
- package/examples/browser/vue/node_modules/nanoid/async/index.js +0 -35
- package/examples/browser/vue/node_modules/nanoid/async/index.native.js +0 -26
- package/examples/browser/vue/node_modules/nanoid/async/package.json +0 -12
- package/examples/browser/vue/node_modules/nanoid/bin/nanoid.cjs +0 -55
- package/examples/browser/vue/node_modules/nanoid/index.browser.cjs +0 -72
- package/examples/browser/vue/node_modules/nanoid/index.browser.js +0 -34
- package/examples/browser/vue/node_modules/nanoid/index.cjs +0 -85
- package/examples/browser/vue/node_modules/nanoid/index.d.cts +0 -91
- package/examples/browser/vue/node_modules/nanoid/index.d.ts +0 -91
- package/examples/browser/vue/node_modules/nanoid/index.js +0 -45
- package/examples/browser/vue/node_modules/nanoid/nanoid.js +0 -1
- package/examples/browser/vue/node_modules/nanoid/non-secure/index.cjs +0 -34
- package/examples/browser/vue/node_modules/nanoid/non-secure/index.d.ts +0 -33
- package/examples/browser/vue/node_modules/nanoid/non-secure/index.js +0 -21
- package/examples/browser/vue/node_modules/nanoid/non-secure/package.json +0 -6
- package/examples/browser/vue/node_modules/nanoid/package.json +0 -89
- package/examples/browser/vue/node_modules/nanoid/url-alphabet/index.cjs +0 -7
- package/examples/browser/vue/node_modules/nanoid/url-alphabet/index.js +0 -3
- package/examples/browser/vue/node_modules/nanoid/url-alphabet/package.json +0 -6
- package/examples/browser/vue/node_modules/picocolors/LICENSE +0 -15
- package/examples/browser/vue/node_modules/picocolors/README.md +0 -21
- package/examples/browser/vue/node_modules/picocolors/package.json +0 -25
- package/examples/browser/vue/node_modules/picocolors/picocolors.browser.js +0 -4
- package/examples/browser/vue/node_modules/picocolors/picocolors.d.ts +0 -5
- package/examples/browser/vue/node_modules/picocolors/picocolors.js +0 -75
- package/examples/browser/vue/node_modules/picocolors/types.d.ts +0 -51
- package/examples/browser/vue/node_modules/pinia/LICENSE +0 -21
- package/examples/browser/vue/node_modules/pinia/README.md +0 -24
- package/examples/browser/vue/node_modules/pinia/dist/pinia.cjs +0 -2061
- package/examples/browser/vue/node_modules/pinia/dist/pinia.d.ts +0 -1074
- package/examples/browser/vue/node_modules/pinia/dist/pinia.esm-browser.js +0 -2036
- package/examples/browser/vue/node_modules/pinia/dist/pinia.iife.js +0 -2223
- package/examples/browser/vue/node_modules/pinia/dist/pinia.iife.prod.js +0 -7
- package/examples/browser/vue/node_modules/pinia/dist/pinia.mjs +0 -2044
- package/examples/browser/vue/node_modules/pinia/dist/pinia.prod.cjs +0 -846
- package/examples/browser/vue/node_modules/pinia/index.cjs +0 -7
- package/examples/browser/vue/node_modules/pinia/index.js +0 -7
- package/examples/browser/vue/node_modules/pinia/package.json +0 -96
- package/examples/browser/vue/node_modules/postcss/LICENSE +0 -20
- package/examples/browser/vue/node_modules/postcss/README.md +0 -29
- package/examples/browser/vue/node_modules/postcss/lib/at-rule.d.ts +0 -140
- package/examples/browser/vue/node_modules/postcss/lib/at-rule.js +0 -25
- package/examples/browser/vue/node_modules/postcss/lib/comment.d.ts +0 -68
- package/examples/browser/vue/node_modules/postcss/lib/comment.js +0 -13
- package/examples/browser/vue/node_modules/postcss/lib/container.d.ts +0 -483
- package/examples/browser/vue/node_modules/postcss/lib/container.js +0 -447
- package/examples/browser/vue/node_modules/postcss/lib/css-syntax-error.d.ts +0 -248
- package/examples/browser/vue/node_modules/postcss/lib/css-syntax-error.js +0 -133
- package/examples/browser/vue/node_modules/postcss/lib/declaration.d.ts +0 -151
- package/examples/browser/vue/node_modules/postcss/lib/declaration.js +0 -24
- package/examples/browser/vue/node_modules/postcss/lib/document.d.ts +0 -69
- package/examples/browser/vue/node_modules/postcss/lib/document.js +0 -33
- package/examples/browser/vue/node_modules/postcss/lib/fromJSON.d.ts +0 -9
- package/examples/browser/vue/node_modules/postcss/lib/fromJSON.js +0 -54
- package/examples/browser/vue/node_modules/postcss/lib/input.d.ts +0 -227
- package/examples/browser/vue/node_modules/postcss/lib/input.js +0 -265
- package/examples/browser/vue/node_modules/postcss/lib/lazy-result.d.ts +0 -190
- package/examples/browser/vue/node_modules/postcss/lib/lazy-result.js +0 -550
- package/examples/browser/vue/node_modules/postcss/lib/list.d.ts +0 -60
- package/examples/browser/vue/node_modules/postcss/lib/list.js +0 -58
- package/examples/browser/vue/node_modules/postcss/lib/map-generator.js +0 -368
- package/examples/browser/vue/node_modules/postcss/lib/no-work-result.d.ts +0 -46
- package/examples/browser/vue/node_modules/postcss/lib/no-work-result.js +0 -138
- package/examples/browser/vue/node_modules/postcss/lib/node.d.ts +0 -556
- package/examples/browser/vue/node_modules/postcss/lib/node.js +0 -449
- package/examples/browser/vue/node_modules/postcss/lib/parse.d.ts +0 -9
- package/examples/browser/vue/node_modules/postcss/lib/parse.js +0 -42
- package/examples/browser/vue/node_modules/postcss/lib/parser.js +0 -611
- package/examples/browser/vue/node_modules/postcss/lib/postcss.d.mts +0 -69
- package/examples/browser/vue/node_modules/postcss/lib/postcss.d.ts +0 -458
- package/examples/browser/vue/node_modules/postcss/lib/postcss.js +0 -101
- package/examples/browser/vue/node_modules/postcss/lib/postcss.mjs +0 -30
- package/examples/browser/vue/node_modules/postcss/lib/previous-map.d.ts +0 -81
- package/examples/browser/vue/node_modules/postcss/lib/previous-map.js +0 -144
- package/examples/browser/vue/node_modules/postcss/lib/processor.d.ts +0 -115
- package/examples/browser/vue/node_modules/postcss/lib/processor.js +0 -67
- package/examples/browser/vue/node_modules/postcss/lib/result.d.ts +0 -205
- package/examples/browser/vue/node_modules/postcss/lib/result.js +0 -42
- package/examples/browser/vue/node_modules/postcss/lib/root.d.ts +0 -87
- package/examples/browser/vue/node_modules/postcss/lib/root.js +0 -61
- package/examples/browser/vue/node_modules/postcss/lib/rule.d.ts +0 -126
- package/examples/browser/vue/node_modules/postcss/lib/rule.js +0 -27
- package/examples/browser/vue/node_modules/postcss/lib/stringifier.d.ts +0 -46
- package/examples/browser/vue/node_modules/postcss/lib/stringifier.js +0 -353
- package/examples/browser/vue/node_modules/postcss/lib/stringify.d.ts +0 -9
- package/examples/browser/vue/node_modules/postcss/lib/stringify.js +0 -11
- package/examples/browser/vue/node_modules/postcss/lib/symbols.js +0 -5
- package/examples/browser/vue/node_modules/postcss/lib/terminal-highlight.js +0 -70
- package/examples/browser/vue/node_modules/postcss/lib/tokenize.js +0 -266
- package/examples/browser/vue/node_modules/postcss/lib/warn-once.js +0 -13
- package/examples/browser/vue/node_modules/postcss/lib/warning.d.ts +0 -147
- package/examples/browser/vue/node_modules/postcss/lib/warning.js +0 -37
- package/examples/browser/vue/node_modules/postcss/package.json +0 -88
- package/examples/browser/vue/node_modules/rollup/LICENSE.md +0 -679
- package/examples/browser/vue/node_modules/rollup/README.md +0 -134
- package/examples/browser/vue/node_modules/rollup/dist/bin/rollup +0 -1912
- package/examples/browser/vue/node_modules/rollup/dist/es/getLogFilter.js +0 -64
- package/examples/browser/vue/node_modules/rollup/dist/es/package.json +0 -1
- package/examples/browser/vue/node_modules/rollup/dist/es/parseAst.js +0 -12
- package/examples/browser/vue/node_modules/rollup/dist/es/rollup.js +0 -17
- package/examples/browser/vue/node_modules/rollup/dist/es/shared/node-entry.js +0 -23920
- package/examples/browser/vue/node_modules/rollup/dist/es/shared/parseAst.js +0 -2086
- package/examples/browser/vue/node_modules/rollup/dist/es/shared/watch.js +0 -9297
- package/examples/browser/vue/node_modules/rollup/dist/getLogFilter.d.ts +0 -5
- package/examples/browser/vue/node_modules/rollup/dist/getLogFilter.js +0 -69
- package/examples/browser/vue/node_modules/rollup/dist/loadConfigFile.d.ts +0 -20
- package/examples/browser/vue/node_modules/rollup/dist/loadConfigFile.js +0 -29
- package/examples/browser/vue/node_modules/rollup/dist/native.js +0 -129
- package/examples/browser/vue/node_modules/rollup/dist/parseAst.d.ts +0 -4
- package/examples/browser/vue/node_modules/rollup/dist/parseAst.js +0 -22
- package/examples/browser/vue/node_modules/rollup/dist/rollup.d.ts +0 -1185
- package/examples/browser/vue/node_modules/rollup/dist/rollup.js +0 -127
- package/examples/browser/vue/node_modules/rollup/dist/shared/fsevents-importer.js +0 -37
- package/examples/browser/vue/node_modules/rollup/dist/shared/index.js +0 -9003
- package/examples/browser/vue/node_modules/rollup/dist/shared/loadConfigFile.js +0 -572
- package/examples/browser/vue/node_modules/rollup/dist/shared/parseAst.js +0 -2318
- package/examples/browser/vue/node_modules/rollup/dist/shared/rollup.js +0 -23842
- package/examples/browser/vue/node_modules/rollup/dist/shared/watch-cli.js +0 -542
- package/examples/browser/vue/node_modules/rollup/dist/shared/watch.js +0 -324
- package/examples/browser/vue/node_modules/rollup/package.json +0 -273
- package/examples/browser/vue/node_modules/source-map-js/LICENSE +0 -28
- package/examples/browser/vue/node_modules/source-map-js/README.md +0 -765
- package/examples/browser/vue/node_modules/source-map-js/lib/array-set.js +0 -121
- package/examples/browser/vue/node_modules/source-map-js/lib/base64-vlq.js +0 -140
- package/examples/browser/vue/node_modules/source-map-js/lib/base64.js +0 -67
- package/examples/browser/vue/node_modules/source-map-js/lib/binary-search.js +0 -111
- package/examples/browser/vue/node_modules/source-map-js/lib/mapping-list.js +0 -79
- package/examples/browser/vue/node_modules/source-map-js/lib/quick-sort.js +0 -132
- package/examples/browser/vue/node_modules/source-map-js/lib/source-map-consumer.d.ts +0 -1
- package/examples/browser/vue/node_modules/source-map-js/lib/source-map-consumer.js +0 -1188
- package/examples/browser/vue/node_modules/source-map-js/lib/source-map-generator.d.ts +0 -1
- package/examples/browser/vue/node_modules/source-map-js/lib/source-map-generator.js +0 -444
- package/examples/browser/vue/node_modules/source-map-js/lib/source-node.d.ts +0 -1
- package/examples/browser/vue/node_modules/source-map-js/lib/source-node.js +0 -413
- package/examples/browser/vue/node_modules/source-map-js/lib/util.js +0 -594
- package/examples/browser/vue/node_modules/source-map-js/package.json +0 -71
- package/examples/browser/vue/node_modules/source-map-js/source-map.d.ts +0 -104
- package/examples/browser/vue/node_modules/source-map-js/source-map.js +0 -8
- package/examples/browser/vue/node_modules/vite/LICENSE.md +0 -3423
- package/examples/browser/vue/node_modules/vite/README.md +0 -20
- package/examples/browser/vue/node_modules/vite/bin/openChrome.applescript +0 -95
- package/examples/browser/vue/node_modules/vite/bin/vite.js +0 -61
- package/examples/browser/vue/node_modules/vite/client.d.ts +0 -256
- package/examples/browser/vue/node_modules/vite/dist/client/client.mjs +0 -829
- package/examples/browser/vue/node_modules/vite/dist/client/env.mjs +0 -24
- package/examples/browser/vue/node_modules/vite/dist/node/chunks/dep-D-7KCb9p.js +0 -7960
- package/examples/browser/vue/node_modules/vite/dist/node/chunks/dep-D_zLpgQd.js +0 -67047
- package/examples/browser/vue/node_modules/vite/dist/node/chunks/dep-IQS-Za7F.js +0 -561
- package/examples/browser/vue/node_modules/vite/dist/node/chunks/dep-YkMKzX4u.js +0 -993
- package/examples/browser/vue/node_modules/vite/dist/node/chunks/dep-e9kYborm.js +0 -7004
- package/examples/browser/vue/node_modules/vite/dist/node/cli.js +0 -917
- package/examples/browser/vue/node_modules/vite/dist/node/constants.js +0 -113
- package/examples/browser/vue/node_modules/vite/dist/node/index.d.ts +0 -3627
- package/examples/browser/vue/node_modules/vite/dist/node/index.js +0 -261
- package/examples/browser/vue/node_modules/vite/dist/node/runtime.d.ts +0 -63
- package/examples/browser/vue/node_modules/vite/dist/node/runtime.js +0 -1066
- package/examples/browser/vue/node_modules/vite/dist/node/types.d-aGj9QkWt.d.ts +0 -281
- package/examples/browser/vue/node_modules/vite/dist/node-cjs/publicUtils.cjs +0 -6171
- package/examples/browser/vue/node_modules/vite/index.cjs +0 -60
- package/examples/browser/vue/node_modules/vite/index.d.cts +0 -6
- package/examples/browser/vue/node_modules/vite/package.json +0 -191
- package/examples/browser/vue/node_modules/vite/types/customEvent.d.ts +0 -39
- package/examples/browser/vue/node_modules/vite/types/hmrPayload.d.ts +0 -65
- package/examples/browser/vue/node_modules/vite/types/hot.d.ts +0 -36
- package/examples/browser/vue/node_modules/vite/types/import-meta.d.ts +0 -5
- package/examples/browser/vue/node_modules/vite/types/importGlob.d.ts +0 -75
- package/examples/browser/vue/node_modules/vite/types/importMeta.d.ts +0 -22
- package/examples/browser/vue/node_modules/vite/types/metadata.d.ts +0 -10
- package/examples/browser/vue/node_modules/vite/types/package.json +0 -4
- package/examples/browser/vue/node_modules/vue/LICENSE +0 -21
- package/examples/browser/vue/node_modules/vue/README.md +0 -62
- package/examples/browser/vue/node_modules/vue/compiler-sfc/index.browser.js +0 -1
- package/examples/browser/vue/node_modules/vue/compiler-sfc/index.browser.mjs +0 -1
- package/examples/browser/vue/node_modules/vue/compiler-sfc/index.d.mts +0 -1
- package/examples/browser/vue/node_modules/vue/compiler-sfc/index.d.ts +0 -1
- package/examples/browser/vue/node_modules/vue/compiler-sfc/index.js +0 -3
- package/examples/browser/vue/node_modules/vue/compiler-sfc/index.mjs +0 -3
- package/examples/browser/vue/node_modules/vue/compiler-sfc/package.json +0 -4
- package/examples/browser/vue/node_modules/vue/compiler-sfc/register-ts.js +0 -3
- package/examples/browser/vue/node_modules/vue/dist/vue.cjs.js +0 -80
- package/examples/browser/vue/node_modules/vue/dist/vue.cjs.prod.js +0 -66
- package/examples/browser/vue/node_modules/vue/dist/vue.d.mts +0 -7
- package/examples/browser/vue/node_modules/vue/dist/vue.d.ts +0 -7
- package/examples/browser/vue/node_modules/vue/dist/vue.esm-browser.js +0 -18392
- package/examples/browser/vue/node_modules/vue/dist/vue.esm-browser.prod.js +0 -12
- package/examples/browser/vue/node_modules/vue/dist/vue.esm-bundler.js +0 -71
- package/examples/browser/vue/node_modules/vue/dist/vue.global.js +0 -18272
- package/examples/browser/vue/node_modules/vue/dist/vue.global.prod.js +0 -12
- package/examples/browser/vue/node_modules/vue/dist/vue.runtime.esm-browser.js +0 -12522
- package/examples/browser/vue/node_modules/vue/dist/vue.runtime.esm-browser.prod.js +0 -6
- package/examples/browser/vue/node_modules/vue/dist/vue.runtime.esm-bundler.js +0 -26
- package/examples/browser/vue/node_modules/vue/dist/vue.runtime.global.js +0 -12574
- package/examples/browser/vue/node_modules/vue/dist/vue.runtime.global.prod.js +0 -6
- package/examples/browser/vue/node_modules/vue/index.js +0 -7
- package/examples/browser/vue/node_modules/vue/index.mjs +0 -1
- package/examples/browser/vue/node_modules/vue/jsx-runtime/index.d.ts +0 -25
- package/examples/browser/vue/node_modules/vue/jsx-runtime/index.js +0 -15
- package/examples/browser/vue/node_modules/vue/jsx-runtime/index.mjs +0 -12
- package/examples/browser/vue/node_modules/vue/jsx-runtime/package.json +0 -5
- package/examples/browser/vue/node_modules/vue/jsx.d.ts +0 -22
- package/examples/browser/vue/node_modules/vue/package.json +0 -112
- package/examples/browser/vue/node_modules/vue/server-renderer/index.d.mts +0 -1
- package/examples/browser/vue/node_modules/vue/server-renderer/index.d.ts +0 -1
- package/examples/browser/vue/node_modules/vue/server-renderer/index.js +0 -1
- package/examples/browser/vue/node_modules/vue/server-renderer/index.mjs +0 -1
- package/examples/browser/vue/node_modules/vue/server-renderer/package.json +0 -4
- package/examples/browser/vue/node_modules/vue-demi/LICENSE +0 -21
- package/examples/browser/vue/node_modules/vue-demi/README.md +0 -229
- package/examples/browser/vue/node_modules/vue-demi/bin/vue-demi-fix.js +0 -3
- package/examples/browser/vue/node_modules/vue-demi/bin/vue-demi-switch.js +0 -3
- package/examples/browser/vue/node_modules/vue-demi/lib/index.cjs +0 -29
- package/examples/browser/vue/node_modules/vue-demi/lib/index.d.ts +0 -22
- package/examples/browser/vue/node_modules/vue-demi/lib/index.iife.js +0 -126
- package/examples/browser/vue/node_modules/vue-demi/lib/index.mjs +0 -34
- package/examples/browser/vue/node_modules/vue-demi/lib/v2/index.cjs +0 -34
- package/examples/browser/vue/node_modules/vue-demi/lib/v2/index.d.ts +0 -33
- package/examples/browser/vue/node_modules/vue-demi/lib/v2/index.mjs +0 -49
- package/examples/browser/vue/node_modules/vue-demi/lib/v2.7/index.cjs +0 -60
- package/examples/browser/vue/node_modules/vue-demi/lib/v2.7/index.d.ts +0 -38
- package/examples/browser/vue/node_modules/vue-demi/lib/v2.7/index.mjs +0 -80
- package/examples/browser/vue/node_modules/vue-demi/lib/v3/index.cjs +0 -29
- package/examples/browser/vue/node_modules/vue-demi/lib/v3/index.d.ts +0 -22
- package/examples/browser/vue/node_modules/vue-demi/lib/v3/index.mjs +0 -34
- package/examples/browser/vue/node_modules/vue-demi/package.json +0 -47
- package/examples/browser/vue/node_modules/vue-demi/scripts/postinstall.js +0 -19
- package/examples/browser/vue/node_modules/vue-demi/scripts/switch-cli.js +0 -18
- package/examples/browser/vue/node_modules/vue-demi/scripts/utils.js +0 -62
- package/examples/browser/vue/node_modules/vue-router/LICENSE +0 -21
- package/examples/browser/vue/node_modules/vue-router/README.md +0 -111
- package/examples/browser/vue/node_modules/vue-router/dist/devtools-BLCumUwL.mjs +0 -1218
- package/examples/browser/vue/node_modules/vue-router/dist/experimental/index.d.mts +0 -38
- package/examples/browser/vue/node_modules/vue-router/dist/experimental/index.mjs +0 -754
- package/examples/browser/vue/node_modules/vue-router/dist/router-BbqN7H95.d.mts +0 -1928
- package/examples/browser/vue/node_modules/vue-router/dist/vue-router.cjs +0 -2797
- package/examples/browser/vue/node_modules/vue-router/dist/vue-router.d.mts +0 -393
- package/examples/browser/vue/node_modules/vue-router/dist/vue-router.esm-browser.js +0 -2743
- package/examples/browser/vue/node_modules/vue-router/dist/vue-router.esm-browser.prod.js +0 -6
- package/examples/browser/vue/node_modules/vue-router/dist/vue-router.esm-bundler.js +0 -2
- package/examples/browser/vue/node_modules/vue-router/dist/vue-router.global.js +0 -3040
- package/examples/browser/vue/node_modules/vue-router/dist/vue-router.global.prod.js +0 -6
- package/examples/browser/vue/node_modules/vue-router/dist/vue-router.mjs +0 -1557
- package/examples/browser/vue/node_modules/vue-router/dist/vue-router.prod.cjs +0 -23
- package/examples/browser/vue/node_modules/vue-router/index.js +0 -7
- package/examples/browser/vue/node_modules/vue-router/package.json +0 -154
- package/examples/browser/vue/node_modules/vue-router/vetur/attributes.json +0 -32
- package/examples/browser/vue/node_modules/vue-router/vetur/tags.json +0 -10
- package/examples/browser/vue/node_modules/vue-router/vue-router-auto-resolver.d.mts +0 -22
- package/examples/browser/vue/node_modules/vue-router/vue-router-auto-routes.d.ts +0 -4
- package/examples/browser/vue/node_modules/vue-router/vue-router-auto.d.ts +0 -1
- package/examples/browser/vue/node_modules/vue-router/vue-router.node.mjs +0 -2
- package/examples/browser/vue/package-lock.json +0 -1276
- package/examples/browser/vue/package.json +0 -23
- package/examples/browser/vue/public/peerpigeon-browser.js +0 -13322
- package/examples/browser/vue/public/pigeonlogo.svg +0 -51
- package/examples/browser/vue/src/App-simple.vue +0 -21
- package/examples/browser/vue/src/App.vue +0 -423
- package/examples/browser/vue/src/components/CryptoView.vue +0 -1661
- package/examples/browser/vue/src/components/DHTView.vue +0 -1281
- package/examples/browser/vue/src/components/DebugView.vue +0 -1783
- package/examples/browser/vue/src/components/MediaView.vue +0 -1197
- package/examples/browser/vue/src/components/MessagingView.vue +0 -803
- package/examples/browser/vue/src/components/NetworkView.vue +0 -930
- package/examples/browser/vue/src/components/StorageView.vue +0 -1376
- package/examples/browser/vue/src/components/TestingView.vue +0 -794
- package/examples/browser/vue/src/main.js +0 -11
- package/examples/browser/vue/src/router.js +0 -63
- package/examples/browser/vue/src/stores/peerpigeon.js +0 -1334
- package/examples/browser/vue/test-vue-restructured-2.log +0 -18
- package/examples/browser/vue/test-vue-restructured-3.log +0 -18
- package/examples/browser/vue/vite.config.js +0 -22
- package/examples/debug-configuration.js +0 -171
- package/examples/hub-example.js +0 -189
- package/examples/multi-hub-test.js +0 -186
- package/examples/nativescript/README.md +0 -73
- package/examples/nativescript/app.js +0 -152
- package/examples/nativescript/package.json +0 -27
- package/examples/node/README.md +0 -110
- package/examples/node/basic-storage-example.js +0 -90
- package/examples/node/package.json +0 -17
- package/examples/node/storage-spaces-test.js +0 -329
- package/examples/node/storage-test.js +0 -655
- package/examples/node/test-crypto-media.js +0 -137
- package/examples/node/test-crypto.js +0 -146
- package/examples/node/test-node.js +0 -152
- package/examples/programmatic-namespace-example.js +0 -108
- package/examples/selective-streaming-demo.html +0 -698
- package/examples/standard-events-demo.js +0 -126
- package/examples/stream-file-transfer-demo.html +0 -935
- package/index.js +0 -30
- package/server/index.js +0 -2147
- package/server/start.js +0 -52
- package/src/CleanupManager.js +0 -183
- package/src/ConnectionManager.js +0 -1286
- package/src/CryptoManager.js +0 -743
- package/src/DebugLogger.js +0 -204
- package/src/DistributedStorageManager.js +0 -1741
- package/src/EnvironmentDetector.js +0 -600
- package/src/EventEmitter.js +0 -106
- package/src/EvictionManager.js +0 -260
- package/src/GossipManager.js +0 -726
- package/src/LexicalStorageInterface.js +0 -332
- package/src/MediaManager.js +0 -276
- package/src/MeshOptimizer.js +0 -182
- package/src/PeerConnection.js +0 -1850
- package/src/PeerDiscovery.js +0 -329
- package/src/PeerPigeonMesh.js +0 -2502
- package/src/PigeonRTC-browser.js +0 -247
- package/src/SignalingClient.js +0 -395
- package/src/SignalingHandler.js +0 -589
- package/src/StorageManager.js +0 -107
- package/src/TimerUtils.js +0 -75
- package/src/WebDHT-Simple.js +0 -389
- package/src/WebDHT.js +0 -474
- package/src/browser-entry.js +0 -68
package/server/index.js
DELETED
|
@@ -1,2147 +0,0 @@
|
|
|
1
|
-
// PeerPigeon WebSocket Server - Node.js module
|
|
2
|
-
import { WebSocketServer, WebSocket } from 'ws';
|
|
3
|
-
import { createServer } from 'http';
|
|
4
|
-
import { EventEmitter } from 'events';
|
|
5
|
-
import { URL } from 'url';
|
|
6
|
-
import { PeerPigeonMesh } from '../src/PeerPigeonMesh.js';
|
|
7
|
-
|
|
8
|
-
// Inject WebSocket into global scope for use by SignalingClient in Node.js
|
|
9
|
-
// This is necessary for hub mesh initialization
|
|
10
|
-
if (typeof global !== 'undefined' && typeof global.WebSocket === 'undefined') {
|
|
11
|
-
global.WebSocket = WebSocket;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* PeerPigeon WebSocket signaling server
|
|
16
|
-
* Can be used programmatically or as a standalone server
|
|
17
|
-
*/
|
|
18
|
-
export class PeerPigeonServer extends EventEmitter {
|
|
19
|
-
constructor(options = {}) {
|
|
20
|
-
super();
|
|
21
|
-
|
|
22
|
-
this.port = options.port || 3000;
|
|
23
|
-
this.host = options.host || 'localhost';
|
|
24
|
-
this.maxConnections = options.maxConnections || 1000;
|
|
25
|
-
this.cleanupInterval = options.cleanupInterval || 30000; // 30 seconds
|
|
26
|
-
this.peerTimeout = options.peerTimeout || 300000; // 5 minutes
|
|
27
|
-
this.corsOrigin = options.corsOrigin || '*';
|
|
28
|
-
this.maxMessageSize = options.maxMessageSize || 1048576; // 1MB
|
|
29
|
-
this.maxPortRetries = options.maxPortRetries || 10; // Try up to 10 ports
|
|
30
|
-
this.verboseLogging = options.verboseLogging === true; // Default false, set true to enable verbose logs
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// Hub configuration
|
|
34
|
-
this.isHub = options.isHub || false; // Whether this server is a hub
|
|
35
|
-
this.hubMeshNamespace = options.hubMeshNamespace || 'pigeonhub-mesh'; // Reserved namespace for hubs (default: 'pigeonhub-mesh')
|
|
36
|
-
this.bootstrapHubs = options.bootstrapHubs || []; // URIs of bootstrap hubs to connect to
|
|
37
|
-
this.autoConnect = options.autoConnect !== false; // Auto-connect to bootstrap hubs (default: true)
|
|
38
|
-
this.reconnectInterval = options.reconnectInterval || 5000; // Reconnect interval in ms
|
|
39
|
-
this.maxReconnectAttempts = options.maxReconnectAttempts || 10; // Max reconnection attempts
|
|
40
|
-
this.hubMeshMaxPeers = options.hubMeshMaxPeers || 3; // Max P2P connections in hub mesh (for partial mesh)
|
|
41
|
-
this.hubMeshMinPeers = options.hubMeshMinPeers || 2; // Min P2P connections in hub mesh
|
|
42
|
-
this.meshMigrationDelay = options.meshMigrationDelay || 10000; // Delay before closing WS connections after mesh is ready (10s)
|
|
43
|
-
|
|
44
|
-
// Generate hub peer ID if this is a hub
|
|
45
|
-
this.hubPeerId = options.hubPeerId || (this.isHub ? this.generatePeerId() : null);
|
|
46
|
-
|
|
47
|
-
this.httpServer = null;
|
|
48
|
-
this.wss = null;
|
|
49
|
-
this.connections = new Map(); // peerId -> WebSocket
|
|
50
|
-
this.peerData = new Map(); // peerId -> peer info
|
|
51
|
-
this.networkPeers = new Map(); // networkName -> Set of peerIds
|
|
52
|
-
this.hubs = new Map(); // peerId -> hub info (for peers identified as hubs)
|
|
53
|
-
this.bootstrapConnections = new Map(); // bootstrapUri -> connection info
|
|
54
|
-
this.crossHubDiscoveredPeers = new Map(); // networkName -> Map(peerId -> peerData) for peers on other hubs
|
|
55
|
-
this.recentlyRelayedMessages = new Map(); // messageId -> timestamp (for deduplication)
|
|
56
|
-
this.relayedMessageTTL = 5000; // Keep relay records for 5 seconds
|
|
57
|
-
this.isRunning = false;
|
|
58
|
-
this.cleanupTimer = null;
|
|
59
|
-
this.startTime = null;
|
|
60
|
-
|
|
61
|
-
// Hub mesh P2P properties
|
|
62
|
-
this.hubMesh = null; // PeerPigeonMesh instance for hub-to-hub P2P connections
|
|
63
|
-
this.hubMeshReady = false; // Whether the P2P mesh is established
|
|
64
|
-
this.hubMeshPeers = new Map(); // hubPeerId -> { p2pConnected: boolean, wsConnection: WebSocket }
|
|
65
|
-
this.migratedToP2P = new Set(); // Set of hub peer IDs that have migrated from WS to P2P
|
|
66
|
-
this.migrationTimer = null; // Timer for WS disconnection after mesh establishment
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Validate peer ID format
|
|
71
|
-
*/
|
|
72
|
-
validatePeerId(peerId) {
|
|
73
|
-
return typeof peerId === 'string' && /^[a-fA-F0-9]{40}$/.test(peerId);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Generate a random peer ID (40 hex characters)
|
|
78
|
-
*/
|
|
79
|
-
generatePeerId() {
|
|
80
|
-
// Generate random hex string
|
|
81
|
-
const chars = '0123456789abcdef';
|
|
82
|
-
let peerId = '';
|
|
83
|
-
for (let i = 0; i < 40; i++) {
|
|
84
|
-
peerId += chars[Math.floor(Math.random() * 16)];
|
|
85
|
-
}
|
|
86
|
-
return peerId;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Create a simple hash of signal data for deduplication
|
|
91
|
-
*/
|
|
92
|
-
hashSignalData(data) {
|
|
93
|
-
if (!data) return 'null';
|
|
94
|
-
const str = JSON.stringify(data);
|
|
95
|
-
let hash = 0;
|
|
96
|
-
for (let i = 0; i < str.length; i++) {
|
|
97
|
-
const char = str.charCodeAt(i);
|
|
98
|
-
hash = ((hash << 5) - hash) + char;
|
|
99
|
-
hash = hash & hash; // Convert to 32bit integer
|
|
100
|
-
}
|
|
101
|
-
return hash.toString(16);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Check if a peer is registered as a hub
|
|
106
|
-
*/
|
|
107
|
-
isPeerHub(peerId) {
|
|
108
|
-
return this.hubs.has(peerId);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Register a peer as a hub
|
|
113
|
-
*/
|
|
114
|
-
registerHub(peerId, hubInfo = {}) {
|
|
115
|
-
this.hubs.set(peerId, {
|
|
116
|
-
peerId,
|
|
117
|
-
registeredAt: Date.now(),
|
|
118
|
-
lastActivity: Date.now(),
|
|
119
|
-
...hubInfo
|
|
120
|
-
});
|
|
121
|
-
console.log(`๐ข Registered hub: ${peerId.substring(0, 8)}... (${this.hubs.size} total hubs)`);
|
|
122
|
-
this.emit('hubRegistered', { peerId, totalHubs: this.hubs.size });
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Unregister a hub
|
|
127
|
-
*/
|
|
128
|
-
unregisterHub(peerId) {
|
|
129
|
-
if (this.hubs.delete(peerId)) {
|
|
130
|
-
console.log(`๐ข Unregistered hub: ${peerId.substring(0, 8)}... (${this.hubs.size} remaining hubs)`);
|
|
131
|
-
this.emit('hubUnregistered', { peerId, totalHubs: this.hubs.size });
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Get all connected hubs
|
|
137
|
-
*/
|
|
138
|
-
getConnectedHubs(excludePeerId = null) {
|
|
139
|
-
const hubList = [];
|
|
140
|
-
for (const [peerId, hubInfo] of this.hubs) {
|
|
141
|
-
if (peerId !== excludePeerId && this.connections.has(peerId)) {
|
|
142
|
-
hubList.push({ peerId, ...hubInfo });
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return hubList;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Find closest peers using XOR distance
|
|
150
|
-
*/
|
|
151
|
-
findClosestPeers(targetPeerId, allPeerIds, maxPeers = 3) {
|
|
152
|
-
if (!targetPeerId || !allPeerIds || allPeerIds.length === 0) {
|
|
153
|
-
return [];
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// XOR distance calculation (simplified)
|
|
157
|
-
const distances = allPeerIds.map(peerId => {
|
|
158
|
-
let distance = 0;
|
|
159
|
-
const minLength = Math.min(targetPeerId.length, peerId.length);
|
|
160
|
-
|
|
161
|
-
for (let i = 0; i < minLength; i++) {
|
|
162
|
-
const xor = parseInt(targetPeerId[i], 16) ^ parseInt(peerId[i], 16);
|
|
163
|
-
distance += xor;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return { peerId, distance };
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// Sort by distance and return closest peers
|
|
170
|
-
distances.sort((a, b) => a.distance - b.distance);
|
|
171
|
-
return distances.slice(0, maxPeers).map(item => item.peerId);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Get active peers in a network
|
|
176
|
-
*/
|
|
177
|
-
getActivePeers(excludePeerId = null, networkName = 'global') {
|
|
178
|
-
const peers = [];
|
|
179
|
-
const stalePeers = [];
|
|
180
|
-
|
|
181
|
-
// Get peers for the specific network
|
|
182
|
-
const networkPeerSet = this.networkPeers.get(networkName);
|
|
183
|
-
if (!networkPeerSet) {
|
|
184
|
-
return peers; // No peers in this network
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
for (const peerId of networkPeerSet) {
|
|
188
|
-
if (peerId !== excludePeerId) {
|
|
189
|
-
const connection = this.connections.get(peerId);
|
|
190
|
-
if (connection && connection.readyState === connection.OPEN) {
|
|
191
|
-
peers.push(peerId);
|
|
192
|
-
} else {
|
|
193
|
-
// Mark stale connections for cleanup
|
|
194
|
-
stalePeers.push(peerId);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// Clean up stale connections
|
|
200
|
-
stalePeers.forEach(peerId => {
|
|
201
|
-
if (this.verboseLogging) {
|
|
202
|
-
console.log(`๐งน Cleaning up stale connection: ${peerId.substring(0, 8)}...`);
|
|
203
|
-
}
|
|
204
|
-
this.cleanupPeer(peerId);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
return peers;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Try to start server on a specific port
|
|
212
|
-
*/
|
|
213
|
-
async tryPort(port, maxRetries = null) {
|
|
214
|
-
maxRetries = maxRetries !== null ? maxRetries : this.maxPortRetries;
|
|
215
|
-
|
|
216
|
-
return new Promise((resolve, reject) => {
|
|
217
|
-
const attemptPort = (currentPort, retriesLeft) => {
|
|
218
|
-
// Create HTTP server
|
|
219
|
-
this.httpServer = createServer((req, res) => {
|
|
220
|
-
// Handle CORS preflight
|
|
221
|
-
if (req.method === 'OPTIONS') {
|
|
222
|
-
res.writeHead(200, {
|
|
223
|
-
'Access-Control-Allow-Origin': this.corsOrigin,
|
|
224
|
-
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
|
|
225
|
-
'Access-Control-Allow-Headers': 'Content-Type, Authorization'
|
|
226
|
-
});
|
|
227
|
-
res.end();
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Health check endpoint
|
|
232
|
-
if (req.url === '/health') {
|
|
233
|
-
res.writeHead(200, {
|
|
234
|
-
'Content-Type': 'application/json',
|
|
235
|
-
'Access-Control-Allow-Origin': this.corsOrigin
|
|
236
|
-
});
|
|
237
|
-
res.end(JSON.stringify({
|
|
238
|
-
status: 'healthy',
|
|
239
|
-
timestamp: new Date().toISOString(),
|
|
240
|
-
uptime: process.uptime(),
|
|
241
|
-
isHub: this.isHub,
|
|
242
|
-
connections: this.connections.size,
|
|
243
|
-
peers: this.peerData.size,
|
|
244
|
-
hubs: this.hubs.size,
|
|
245
|
-
networks: this.networkPeers.size,
|
|
246
|
-
memory: process.memoryUsage()
|
|
247
|
-
}));
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// Hubs endpoint - list connected hubs
|
|
252
|
-
if (req.url === '/hubs') {
|
|
253
|
-
res.writeHead(200, {
|
|
254
|
-
'Content-Type': 'application/json',
|
|
255
|
-
'Access-Control-Allow-Origin': this.corsOrigin
|
|
256
|
-
});
|
|
257
|
-
res.end(JSON.stringify({
|
|
258
|
-
timestamp: new Date().toISOString(),
|
|
259
|
-
totalHubs: this.hubs.size,
|
|
260
|
-
hubs: this.getConnectedHubs()
|
|
261
|
-
}));
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Default response
|
|
266
|
-
res.writeHead(200, {
|
|
267
|
-
'Content-Type': 'text/plain',
|
|
268
|
-
'Access-Control-Allow-Origin': this.corsOrigin
|
|
269
|
-
});
|
|
270
|
-
res.end('PeerPigeon WebSocket Signaling Server');
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
// Create WebSocket server
|
|
274
|
-
this.wss = new WebSocketServer({
|
|
275
|
-
server: this.httpServer,
|
|
276
|
-
maxPayload: this.maxMessageSize
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
this.setupWebSocketHandlers();
|
|
280
|
-
|
|
281
|
-
// Handle port in use error
|
|
282
|
-
const errorHandler = (error) => {
|
|
283
|
-
if (error.code === 'EADDRINUSE') {
|
|
284
|
-
console.log(`โ ๏ธ Port ${currentPort} is already in use`);
|
|
285
|
-
|
|
286
|
-
// Clean up failed server
|
|
287
|
-
this.httpServer.removeAllListeners();
|
|
288
|
-
if (this.wss) {
|
|
289
|
-
this.wss.close();
|
|
290
|
-
}
|
|
291
|
-
this.httpServer = null;
|
|
292
|
-
this.wss = null;
|
|
293
|
-
|
|
294
|
-
if (retriesLeft > 0) {
|
|
295
|
-
const nextPort = currentPort + 1;
|
|
296
|
-
console.log(`๐ Trying port ${nextPort}...`);
|
|
297
|
-
attemptPort(nextPort, retriesLeft - 1);
|
|
298
|
-
} else {
|
|
299
|
-
reject(new Error(`Failed to find available port after ${maxRetries} attempts (tried ${port}-${currentPort})`));
|
|
300
|
-
}
|
|
301
|
-
} else {
|
|
302
|
-
console.error('โ HTTP server error:', error);
|
|
303
|
-
this.emit('error', error);
|
|
304
|
-
reject(error);
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
this.httpServer.once('error', errorHandler);
|
|
309
|
-
|
|
310
|
-
// Start HTTP server
|
|
311
|
-
this.httpServer.listen(currentPort, this.host, () => {
|
|
312
|
-
// Remove error handler after successful start
|
|
313
|
-
this.httpServer.removeListener('error', errorHandler);
|
|
314
|
-
|
|
315
|
-
// Update port to the actual port used
|
|
316
|
-
this.port = currentPort;
|
|
317
|
-
this.isRunning = true;
|
|
318
|
-
this.startTime = Date.now();
|
|
319
|
-
this.startCleanupTimer();
|
|
320
|
-
|
|
321
|
-
if (currentPort !== port) {
|
|
322
|
-
console.log(`โ
Port ${port} was in use, using port ${currentPort} instead`);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
const serverType = this.isHub ? '๐ข PeerPigeon Hub Server' : '๐ PeerPigeon WebSocket Server';
|
|
326
|
-
console.log(`${serverType} started on ws://${this.host}:${this.port}`);
|
|
327
|
-
if (this.isHub) {
|
|
328
|
-
console.log(`๐ Hub mesh namespace: ${this.hubMeshNamespace}`);
|
|
329
|
-
}
|
|
330
|
-
console.log(`๐ Max connections: ${this.maxConnections}`);
|
|
331
|
-
console.log(`๐งน Cleanup interval: ${this.cleanupInterval}ms`);
|
|
332
|
-
console.log(`โฐ Peer timeout: ${this.peerTimeout}ms`);
|
|
333
|
-
|
|
334
|
-
this.emit('started', { host: this.host, port: this.port });
|
|
335
|
-
resolve({ host: this.host, port: this.port });
|
|
336
|
-
|
|
337
|
-
// Add persistent error handler after successful start
|
|
338
|
-
this.httpServer.on('error', (error) => {
|
|
339
|
-
console.error('โ HTTP server error:', error);
|
|
340
|
-
this.emit('error', error);
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
attemptPort(port, maxRetries);
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Start the WebSocket server
|
|
351
|
-
*/
|
|
352
|
-
async start() {
|
|
353
|
-
if (this.isRunning) {
|
|
354
|
-
throw new Error('Server is already running');
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
try {
|
|
358
|
-
const result = await this.tryPort(this.port);
|
|
359
|
-
|
|
360
|
-
// If this is a hub, initialize hub mesh AFTER server is running, then connect to bootstrap hubs
|
|
361
|
-
if (this.isHub && this.autoConnect) {
|
|
362
|
-
// Give the server a moment to be fully ready for connections
|
|
363
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
364
|
-
|
|
365
|
-
await this.initializeHubMesh();
|
|
366
|
-
await this.connectToBootstrapHubs();
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
return result;
|
|
370
|
-
} catch (error) {
|
|
371
|
-
console.error('โ Failed to start server:', error);
|
|
372
|
-
throw error;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Initialize the hub P2P mesh
|
|
378
|
-
*/
|
|
379
|
-
async initializeHubMesh() {
|
|
380
|
-
if (!this.isHub || this.hubMesh) {
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
console.log(`๐ Initializing hub P2P mesh on namespace: ${this.hubMeshNamespace}`);
|
|
385
|
-
console.log(` Hub Peer ID: ${this.hubPeerId.substring(0, 8)}...`);
|
|
386
|
-
console.log(` Max P2P connections: ${this.hubMeshMaxPeers} (partial mesh with XOR routing)`);
|
|
387
|
-
|
|
388
|
-
// Create PeerPigeonMesh instance for hub-to-hub connections
|
|
389
|
-
this.hubMesh = new PeerPigeonMesh({
|
|
390
|
-
peerId: this.hubPeerId,
|
|
391
|
-
networkName: this.hubMeshNamespace,
|
|
392
|
-
maxPeers: this.hubMeshMaxPeers,
|
|
393
|
-
minPeers: this.hubMeshMinPeers,
|
|
394
|
-
autoConnect: true,
|
|
395
|
-
autoDiscovery: true,
|
|
396
|
-
xorRouting: true, // Use XOR routing for partial mesh
|
|
397
|
-
enableWebDHT: false, // Don't need DHT for hub mesh
|
|
398
|
-
enableCrypto: false // Hubs don't need encryption between themselves
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
// Initialize the mesh (required before connecting)
|
|
402
|
-
await this.hubMesh.init();
|
|
403
|
-
|
|
404
|
-
// Set up hub mesh event handlers
|
|
405
|
-
this.setupHubMeshEventHandlers();
|
|
406
|
-
|
|
407
|
-
// Connect to local signaling server (ourselves)
|
|
408
|
-
// Use 127.0.0.1 for localhost to avoid potential DNS issues
|
|
409
|
-
const host = this.host === '0.0.0.0' ? '127.0.0.1' : this.host;
|
|
410
|
-
const signalingUrl = `ws://${host}:${this.port}`;
|
|
411
|
-
|
|
412
|
-
console.log(`๐ Connecting hub mesh to local signaling: ${signalingUrl}`);
|
|
413
|
-
await this.hubMesh.connect(signalingUrl);
|
|
414
|
-
|
|
415
|
-
console.log(`โ
Hub mesh connected to local signaling`);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Set up event handlers for the hub P2P mesh
|
|
420
|
-
*/
|
|
421
|
-
setupHubMeshEventHandlers() {
|
|
422
|
-
if (!this.hubMesh) return;
|
|
423
|
-
|
|
424
|
-
// Track P2P connections to other hubs
|
|
425
|
-
this.hubMesh.addEventListener('peerConnected', (event) => {
|
|
426
|
-
const hubPeerId = event.peerId;
|
|
427
|
-
console.log(`๐ P2P connection established with hub: ${hubPeerId.substring(0, 8)}...`);
|
|
428
|
-
|
|
429
|
-
// Update hub peer tracking
|
|
430
|
-
if (!this.hubMeshPeers.has(hubPeerId)) {
|
|
431
|
-
this.hubMeshPeers.set(hubPeerId, { p2pConnected: false, wsConnection: null });
|
|
432
|
-
}
|
|
433
|
-
const hubInfo = this.hubMeshPeers.get(hubPeerId);
|
|
434
|
-
hubInfo.p2pConnected = true;
|
|
435
|
-
|
|
436
|
-
this.emit('hubP2PConnected', { hubPeerId });
|
|
437
|
-
|
|
438
|
-
// Check if we should migrate to P2P-only
|
|
439
|
-
this.checkMeshReadiness();
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
this.hubMesh.addEventListener('peerDisconnected', (event) => {
|
|
443
|
-
const hubPeerId = event.peerId;
|
|
444
|
-
console.log(`๐ P2P connection lost with hub: ${hubPeerId.substring(0, 8)}...`);
|
|
445
|
-
|
|
446
|
-
const hubInfo = this.hubMeshPeers.get(hubPeerId);
|
|
447
|
-
if (hubInfo) {
|
|
448
|
-
hubInfo.p2pConnected = false;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
this.migratedToP2P.delete(hubPeerId);
|
|
452
|
-
this.emit('hubP2PDisconnected', { hubPeerId });
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
// Handle messages from other hubs via P2P
|
|
456
|
-
this.hubMesh.addEventListener('messageReceived', (event) => {
|
|
457
|
-
this.handleHubP2PMessage(event.from, event.data);
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
// Track mesh status updates
|
|
461
|
-
this.hubMesh.addEventListener('peersUpdated', () => {
|
|
462
|
-
const connectedCount = this.hubMesh.connectionManager.getConnectedPeers().length;
|
|
463
|
-
console.log(`๐ Hub mesh status: ${connectedCount} P2P connections active`);
|
|
464
|
-
this.checkMeshReadiness();
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Check if the hub mesh is ready and trigger migration from WS to P2P
|
|
470
|
-
*/
|
|
471
|
-
checkMeshReadiness() {
|
|
472
|
-
if (!this.isHub || !this.hubMesh || this.hubMeshReady) {
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
const connectedP2PPeers = this.hubMesh.connectionManager.getConnectedPeers().length;
|
|
477
|
-
const discoveredHubs = this.hubs.size;
|
|
478
|
-
|
|
479
|
-
// Consider mesh ready if we have P2P connections to at least minPeers hubs
|
|
480
|
-
// OR if there are fewer than minPeers total hubs available
|
|
481
|
-
const isReady = connectedP2PPeers >= this.hubMeshMinPeers ||
|
|
482
|
-
(discoveredHubs < this.hubMeshMinPeers && connectedP2PPeers >= discoveredHubs);
|
|
483
|
-
|
|
484
|
-
if (isReady && !this.hubMeshReady) {
|
|
485
|
-
this.hubMeshReady = true;
|
|
486
|
-
console.log(`โ
Hub mesh is READY! ${connectedP2PPeers} P2P connections established`);
|
|
487
|
-
console.log(` Migrating to P2P-only immediately...`);
|
|
488
|
-
|
|
489
|
-
this.emit('hubMeshReady', {
|
|
490
|
-
p2pConnections: connectedP2PPeers,
|
|
491
|
-
totalHubs: discoveredHubs
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
// Migrate immediately from WebSocket to P2P-only
|
|
495
|
-
if (this.migrationTimer) {
|
|
496
|
-
clearTimeout(this.migrationTimer);
|
|
497
|
-
this.migrationTimer = null;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
// Use setImmediate to allow current processing to complete before migration
|
|
501
|
-
setImmediate(() => {
|
|
502
|
-
this.migrateToP2POnly();
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* Migrate from WebSocket connections to P2P-only for hub-to-hub communication
|
|
509
|
-
*/
|
|
510
|
-
migrateToP2POnly() {
|
|
511
|
-
if (!this.isHub || !this.hubMesh) {
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
console.log(`๐ MIGRATING to P2P-only hub mesh...`);
|
|
516
|
-
|
|
517
|
-
const p2pConnectedHubs = this.hubMesh.connectionManager.getConnectedPeers();
|
|
518
|
-
let migratedCount = 0;
|
|
519
|
-
let skippedCount = 0;
|
|
520
|
-
|
|
521
|
-
for (const hubPeerId of p2pConnectedHubs) {
|
|
522
|
-
// Check if this hub has both WS and P2P connections
|
|
523
|
-
const hubInfo = this.hubMeshPeers.get(hubPeerId);
|
|
524
|
-
if (!hubInfo || !hubInfo.p2pConnected) {
|
|
525
|
-
continue;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
// Check if we have a direct WebSocket connection to this hub (incoming)
|
|
529
|
-
const directWsConnection = this.connections.get(hubPeerId);
|
|
530
|
-
if (directWsConnection && directWsConnection.readyState === WebSocket.OPEN) {
|
|
531
|
-
console.log(`๐ Closing direct WebSocket to hub ${hubPeerId.substring(0, 8)}... (P2P active)`);
|
|
532
|
-
|
|
533
|
-
try {
|
|
534
|
-
directWsConnection.close(1000, 'Migrated to P2P mesh');
|
|
535
|
-
this.migratedToP2P.add(hubPeerId);
|
|
536
|
-
migratedCount++;
|
|
537
|
-
} catch (error) {
|
|
538
|
-
console.error(`โ Error closing WebSocket for hub ${hubPeerId.substring(0, 8)}...:`, error);
|
|
539
|
-
}
|
|
540
|
-
} else {
|
|
541
|
-
skippedCount++;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
// Also close ALL bootstrap WebSocket connections - we're on P2P mesh now
|
|
546
|
-
console.log(`๐ Closing ALL bootstrap WebSocket connections (P2P mesh active)...`);
|
|
547
|
-
let bootstrapClosed = 0;
|
|
548
|
-
|
|
549
|
-
for (const [uri, connInfo] of this.bootstrapConnections) {
|
|
550
|
-
if (connInfo.connected && connInfo.ws && connInfo.ws.readyState === WebSocket.OPEN) {
|
|
551
|
-
console.log(`๐ Closing bootstrap WebSocket: ${uri}`);
|
|
552
|
-
try {
|
|
553
|
-
connInfo.ws.close(1000, 'Migrated to P2P mesh');
|
|
554
|
-
connInfo.connected = false;
|
|
555
|
-
bootstrapClosed++;
|
|
556
|
-
} catch (error) {
|
|
557
|
-
console.error(`โ Error closing bootstrap WebSocket ${uri}:`, error);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
console.log(`โ
Migration complete:`);
|
|
563
|
-
console.log(` - ${migratedCount} direct hub WebSocket connections closed`);
|
|
564
|
-
console.log(` - ${bootstrapClosed} bootstrap WebSocket connections closed`);
|
|
565
|
-
console.log(` - ${skippedCount} connections already closed or non-existent`);
|
|
566
|
-
console.log(`๐ Hub mesh now operating on P2P (${p2pConnectedHubs.length} connections)`);
|
|
567
|
-
|
|
568
|
-
this.emit('hubMeshMigrated', {
|
|
569
|
-
migratedCount: migratedCount + bootstrapClosed,
|
|
570
|
-
p2pConnections: p2pConnectedHubs.length
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* Handle P2P messages from other hubs
|
|
576
|
-
*/
|
|
577
|
-
handleHubP2PMessage(fromHubPeerId, message) {
|
|
578
|
-
console.log(`๐จ P2P message from hub ${fromHubPeerId.substring(0, 8)}...: ${message.type || 'unknown'}`);
|
|
579
|
-
|
|
580
|
-
// Handle signaling relay through P2P mesh
|
|
581
|
-
if (message.type === 'client-signal-relay') {
|
|
582
|
-
this.handleClientSignalRelay(fromHubPeerId, message);
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
// Handle peer announcements through P2P mesh
|
|
587
|
-
if (message.type === 'peer-announce-relay') {
|
|
588
|
-
this.handlePeerAnnounceRelay(fromHubPeerId, message);
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// Default: log unknown message types
|
|
593
|
-
console.log(`โ ๏ธ Unknown P2P message type from hub: ${message.type}`);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Handle client signaling relay through P2P hub mesh
|
|
598
|
-
*/
|
|
599
|
-
handleClientSignalRelay(fromHubPeerId, message) {
|
|
600
|
-
const { targetPeerId, signalData } = message;
|
|
601
|
-
|
|
602
|
-
if (!targetPeerId || !signalData) {
|
|
603
|
-
console.log(`โ ๏ธ Invalid client signal relay from ${fromHubPeerId.substring(0, 8)}...`);
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
// Deduplicate relay: create hash from targetPeer + signal type + data hash
|
|
608
|
-
const relayHash = `${targetPeerId}:${signalData.type}:${this.hashSignalData(signalData.data)}`;
|
|
609
|
-
if (this.recentlyRelayedMessages.has(relayHash)) {
|
|
610
|
-
console.log(`๐ Duplicate P2P signal relay detected for ${targetPeerId.substring(0, 8)}..., ignoring`);
|
|
611
|
-
return;
|
|
612
|
-
}
|
|
613
|
-
this.recentlyRelayedMessages.set(relayHash, Date.now());
|
|
614
|
-
|
|
615
|
-
// Check if target peer is connected to this hub
|
|
616
|
-
const targetConnection = this.connections.get(targetPeerId);
|
|
617
|
-
if (targetConnection && targetConnection.readyState === WebSocket.OPEN) {
|
|
618
|
-
console.log(`๐ฅ Relaying signal to local client ${targetPeerId.substring(0, 8)}...`);
|
|
619
|
-
this.sendToConnection(targetConnection, signalData);
|
|
620
|
-
} else {
|
|
621
|
-
// Forward to other hubs via P2P if we have more connections
|
|
622
|
-
console.log(`๐ Client ${targetPeerId.substring(0, 8)}... not local, forwarding to other hubs`);
|
|
623
|
-
this.forwardSignalToHubMesh(targetPeerId, signalData, fromHubPeerId);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* Handle peer announcement relay through P2P hub mesh
|
|
629
|
-
*/
|
|
630
|
-
handlePeerAnnounceRelay(fromHubPeerId, message) {
|
|
631
|
-
const { peerId, networkName, peerData } = message;
|
|
632
|
-
|
|
633
|
-
if (!peerId || !networkName) {
|
|
634
|
-
console.log(`โ ๏ธ Invalid peer announce relay from ${fromHubPeerId.substring(0, 8)}...`);
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
console.log(`๐ฃ Peer ${peerId.substring(0, 8)}... announced via hub ${fromHubPeerId.substring(0, 8)}... on network: ${networkName}`);
|
|
639
|
-
|
|
640
|
-
// Forward to local clients in the same network
|
|
641
|
-
const localPeers = this.getActivePeers(null, networkName);
|
|
642
|
-
localPeers.forEach(localPeerId => {
|
|
643
|
-
const localConnection = this.connections.get(localPeerId);
|
|
644
|
-
if (localConnection) {
|
|
645
|
-
this.sendToConnection(localConnection, {
|
|
646
|
-
type: 'peer-discovered',
|
|
647
|
-
data: peerData,
|
|
648
|
-
networkName,
|
|
649
|
-
fromPeerId: 'system',
|
|
650
|
-
targetPeerId: localPeerId,
|
|
651
|
-
timestamp: Date.now()
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
/**
|
|
658
|
-
* Forward signaling message to hub mesh via P2P
|
|
659
|
-
*/
|
|
660
|
-
forwardSignalToHubMesh(targetPeerId, signalData, excludeHubPeerId = null) {
|
|
661
|
-
if (!this.hubMesh) {
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
const connectedHubConnections = this.hubMesh.connectionManager.getConnectedPeers();
|
|
666
|
-
const connectedHubs = connectedHubConnections
|
|
667
|
-
.map(conn => conn.peerId)
|
|
668
|
-
.filter(hubId => hubId !== excludeHubPeerId);
|
|
669
|
-
|
|
670
|
-
if (connectedHubs.length === 0) {
|
|
671
|
-
console.log(`โ ๏ธ No other hubs available in P2P mesh for forwarding`);
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
const relayMessage = {
|
|
676
|
-
type: 'client-signal-relay',
|
|
677
|
-
targetPeerId,
|
|
678
|
-
signalData,
|
|
679
|
-
timestamp: Date.now()
|
|
680
|
-
};
|
|
681
|
-
|
|
682
|
-
// Use XOR routing to find closest hubs
|
|
683
|
-
const closestHubs = this.findClosestPeers(targetPeerId, connectedHubs, 2);
|
|
684
|
-
|
|
685
|
-
closestHubs.forEach(hubPeerIdObj => {
|
|
686
|
-
const hubPeerId = typeof hubPeerIdObj === 'string' ? hubPeerIdObj : hubPeerIdObj.peerId;
|
|
687
|
-
console.log(`๐ค Forwarding signal to hub ${hubPeerId.substring(0, 8)}... via P2P`);
|
|
688
|
-
|
|
689
|
-
// Get the peer connection and send the message
|
|
690
|
-
const peerConnection = this.hubMesh.connectionManager.peers.get(hubPeerId);
|
|
691
|
-
if (peerConnection && peerConnection.sendMessage) {
|
|
692
|
-
peerConnection.sendMessage(relayMessage);
|
|
693
|
-
console.log(`โ
Sent signal via P2P to hub ${hubPeerId.substring(0, 8)}...`);
|
|
694
|
-
} else {
|
|
695
|
-
console.error(`โ No peer connection found for hub ${hubPeerId.substring(0, 8)}...`);
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/**
|
|
701
|
-
* Stop the WebSocket server
|
|
702
|
-
*/
|
|
703
|
-
async stop() {
|
|
704
|
-
if (!this.isRunning) {
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
return new Promise((resolve) => {
|
|
709
|
-
console.log('๐ Stopping PeerPigeon WebSocket server...');
|
|
710
|
-
|
|
711
|
-
// Stop migration timer if running
|
|
712
|
-
if (this.migrationTimer) {
|
|
713
|
-
clearTimeout(this.migrationTimer);
|
|
714
|
-
this.migrationTimer = null;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
// Disconnect hub mesh if this is a hub
|
|
718
|
-
if (this.isHub && this.hubMesh) {
|
|
719
|
-
console.log('๐ Disconnecting hub P2P mesh...');
|
|
720
|
-
this.hubMesh.disconnect();
|
|
721
|
-
this.hubMesh = null;
|
|
722
|
-
this.hubMeshReady = false;
|
|
723
|
-
this.hubMeshPeers.clear();
|
|
724
|
-
this.migratedToP2P.clear();
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
// Disconnect from bootstrap hubs if this is a hub
|
|
728
|
-
if (this.isHub) {
|
|
729
|
-
this.disconnectFromBootstrapHubs();
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
// Stop cleanup timer
|
|
733
|
-
if (this.cleanupTimer) {
|
|
734
|
-
clearInterval(this.cleanupTimer);
|
|
735
|
-
this.cleanupTimer = null;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
// Clear relay deduplication cache
|
|
739
|
-
this.recentlyRelayedMessages.clear();
|
|
740
|
-
|
|
741
|
-
// Close all WebSocket connections
|
|
742
|
-
for (const [peerId, ws] of this.connections) {
|
|
743
|
-
try {
|
|
744
|
-
ws.close(1000, 'Server shutting down');
|
|
745
|
-
} catch (error) {
|
|
746
|
-
console.error(`Error closing connection for ${peerId}:`, error);
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
// Close WebSocket server
|
|
751
|
-
if (this.wss) {
|
|
752
|
-
this.wss.close(() => {
|
|
753
|
-
console.log('โ
WebSocket server closed');
|
|
754
|
-
|
|
755
|
-
// Close HTTP server
|
|
756
|
-
if (this.httpServer) {
|
|
757
|
-
this.httpServer.close(() => {
|
|
758
|
-
console.log('โ
HTTP server closed');
|
|
759
|
-
this.isRunning = false;
|
|
760
|
-
this.emit('stopped');
|
|
761
|
-
resolve();
|
|
762
|
-
});
|
|
763
|
-
} else {
|
|
764
|
-
this.isRunning = false;
|
|
765
|
-
this.emit('stopped');
|
|
766
|
-
resolve();
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
} else {
|
|
770
|
-
this.isRunning = false;
|
|
771
|
-
this.emit('stopped');
|
|
772
|
-
resolve();
|
|
773
|
-
}
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* Connect to bootstrap hubs
|
|
779
|
-
*/
|
|
780
|
-
async connectToBootstrapHubs() {
|
|
781
|
-
if (!this.isHub) {
|
|
782
|
-
console.log('โ ๏ธ Not a hub, skipping bootstrap connections');
|
|
783
|
-
return;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
// If no bootstrap hubs specified, try default port 3000
|
|
787
|
-
let bootstrapUris = this.bootstrapHubs;
|
|
788
|
-
if (!bootstrapUris || bootstrapUris.length === 0) {
|
|
789
|
-
// Don't connect to ourselves
|
|
790
|
-
const defaultPort = 3000;
|
|
791
|
-
if (this.port !== defaultPort) {
|
|
792
|
-
bootstrapUris = [`ws://${this.host}:${defaultPort}`];
|
|
793
|
-
console.log(`๐ No bootstrap hubs specified, trying default: ws://${this.host}:${defaultPort}`);
|
|
794
|
-
} else {
|
|
795
|
-
console.log('โน๏ธ No bootstrap hubs to connect to (running on default port 3000)');
|
|
796
|
-
return;
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
console.log(`๐ Connecting to ${bootstrapUris.length} bootstrap hub(s)...`);
|
|
801
|
-
|
|
802
|
-
for (const uri of bootstrapUris) {
|
|
803
|
-
try {
|
|
804
|
-
await this.connectToHub(uri);
|
|
805
|
-
} catch (error) {
|
|
806
|
-
console.error(`โ Failed to connect to bootstrap hub ${uri}:`, error.message);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
/**
|
|
812
|
-
* Connect to a specific hub
|
|
813
|
-
*/
|
|
814
|
-
async connectToHub(uri, attemptNumber = 0) {
|
|
815
|
-
return new Promise((resolve, reject) => {
|
|
816
|
-
try {
|
|
817
|
-
// Parse URI to check if it's our own server
|
|
818
|
-
const url = new URL(uri);
|
|
819
|
-
const hubPort = parseInt(url.port) || 3000;
|
|
820
|
-
const hubHost = url.hostname;
|
|
821
|
-
|
|
822
|
-
// Don't connect to ourselves
|
|
823
|
-
if (hubHost === this.host && hubPort === this.port) {
|
|
824
|
-
console.log(`โ ๏ธ Skipping self-connection to ${uri}`);
|
|
825
|
-
resolve();
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
const wsUrl = `${uri}?peerId=${this.hubPeerId}`;
|
|
830
|
-
console.log(`๐ Connecting to hub: ${uri} (attempt ${attemptNumber + 1})`);
|
|
831
|
-
|
|
832
|
-
const ws = new WebSocket(wsUrl);
|
|
833
|
-
|
|
834
|
-
const connectionInfo = {
|
|
835
|
-
uri,
|
|
836
|
-
ws,
|
|
837
|
-
connected: false,
|
|
838
|
-
attemptNumber,
|
|
839
|
-
lastAttempt: Date.now(),
|
|
840
|
-
reconnectTimer: null
|
|
841
|
-
};
|
|
842
|
-
|
|
843
|
-
this.bootstrapConnections.set(uri, connectionInfo);
|
|
844
|
-
|
|
845
|
-
ws.on('open', () => {
|
|
846
|
-
console.log(`โ
Connected to bootstrap hub: ${uri}`);
|
|
847
|
-
connectionInfo.connected = true;
|
|
848
|
-
connectionInfo.attemptNumber = 0; // Reset attempt counter on success
|
|
849
|
-
|
|
850
|
-
// Announce this hub on the hub mesh
|
|
851
|
-
this.announceToHub(ws);
|
|
852
|
-
|
|
853
|
-
this.emit('bootstrapConnected', { uri });
|
|
854
|
-
resolve();
|
|
855
|
-
});
|
|
856
|
-
|
|
857
|
-
ws.on('message', (data) => {
|
|
858
|
-
try {
|
|
859
|
-
const message = JSON.parse(data.toString());
|
|
860
|
-
this.handleBootstrapMessage(uri, message);
|
|
861
|
-
} catch (error) {
|
|
862
|
-
console.error(`โ Error handling message from ${uri}:`, error);
|
|
863
|
-
}
|
|
864
|
-
});
|
|
865
|
-
|
|
866
|
-
ws.on('close', (code, reason) => {
|
|
867
|
-
console.log(`๐ Disconnected from bootstrap hub ${uri} (${code}: ${reason})`)
|
|
868
|
-
connectionInfo.connected = false;
|
|
869
|
-
|
|
870
|
-
this.emit('bootstrapDisconnected', { uri, code, reason });
|
|
871
|
-
|
|
872
|
-
// Attempt to reconnect
|
|
873
|
-
if (this.isRunning && attemptNumber < this.maxReconnectAttempts) {
|
|
874
|
-
connectionInfo.reconnectTimer = setTimeout(() => {
|
|
875
|
-
console.log(`๐ Reconnecting to ${uri}...`);
|
|
876
|
-
this.connectToHub(uri, attemptNumber + 1);
|
|
877
|
-
}, this.reconnectInterval);
|
|
878
|
-
} else if (attemptNumber >= this.maxReconnectAttempts) {
|
|
879
|
-
console.log(`โ Max reconnection attempts reached for ${uri}`);
|
|
880
|
-
this.bootstrapConnections.delete(uri);
|
|
881
|
-
}
|
|
882
|
-
});
|
|
883
|
-
|
|
884
|
-
ws.on('error', (error) => {
|
|
885
|
-
console.error(`โ WebSocket error for ${uri}:`, error.message);
|
|
886
|
-
|
|
887
|
-
// Only reject on first attempt, otherwise we'll retry
|
|
888
|
-
if (attemptNumber === 0) {
|
|
889
|
-
this.bootstrapConnections.delete(uri);
|
|
890
|
-
reject(error);
|
|
891
|
-
}
|
|
892
|
-
});
|
|
893
|
-
|
|
894
|
-
} catch (error) {
|
|
895
|
-
console.error(`โ Failed to create connection to ${uri}:`, error);
|
|
896
|
-
reject(error);
|
|
897
|
-
}
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
/**
|
|
902
|
-
* Announce this hub to a bootstrap hub
|
|
903
|
-
*/
|
|
904
|
-
announceToHub(ws) {
|
|
905
|
-
const announcement = {
|
|
906
|
-
type: 'announce',
|
|
907
|
-
networkName: this.hubMeshNamespace,
|
|
908
|
-
data: {
|
|
909
|
-
isHub: true,
|
|
910
|
-
port: this.port,
|
|
911
|
-
host: this.host,
|
|
912
|
-
capabilities: ['signaling', 'relay'],
|
|
913
|
-
timestamp: Date.now()
|
|
914
|
-
}
|
|
915
|
-
};
|
|
916
|
-
|
|
917
|
-
ws.send(JSON.stringify(announcement));
|
|
918
|
-
console.log(`๐ข Announced to bootstrap hub on ${this.hubMeshNamespace}`);
|
|
919
|
-
|
|
920
|
-
// Announce all existing local peers to the bootstrap hub
|
|
921
|
-
this.announceLocalPeersToHub(ws);
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
/**
|
|
925
|
-
* Announce all local peers to a bootstrap hub (including hub mesh peers for P2P discovery)
|
|
926
|
-
*/
|
|
927
|
-
announceLocalPeersToHub(ws) {
|
|
928
|
-
let totalAnnounced = 0;
|
|
929
|
-
|
|
930
|
-
console.log(`๐ก Announcing local peers to bootstrap hub (${this.networkPeers.size} networks)`);
|
|
931
|
-
|
|
932
|
-
// Iterate through all networks and announce their peers
|
|
933
|
-
for (const [networkName, peerSet] of this.networkPeers) {
|
|
934
|
-
console.log(` Network '${networkName}': ${peerSet.size} peers`);
|
|
935
|
-
|
|
936
|
-
for (const peerId of peerSet) {
|
|
937
|
-
const peerData = this.peerData.get(peerId);
|
|
938
|
-
|
|
939
|
-
// For hub mesh namespace, only announce our own hub mesh client (not other hubs)
|
|
940
|
-
if (networkName === this.hubMeshNamespace && peerId !== this.hubPeerId) {
|
|
941
|
-
console.log(` Skipping hub ${peerId.substring(0, 8)}... (not our mesh client)`);
|
|
942
|
-
continue;
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
// For other namespaces, skip hub peers
|
|
946
|
-
if (networkName !== this.hubMeshNamespace && peerData?.isHub) {
|
|
947
|
-
console.log(` Skipping hub peer ${peerId.substring(0, 8)}... in network ${networkName}`);
|
|
948
|
-
continue;
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
// Skip if not connected or not announced
|
|
952
|
-
const connection = this.connections.get(peerId);
|
|
953
|
-
if (!connection || connection.readyState !== WebSocket.OPEN || !peerData?.announced) {
|
|
954
|
-
console.log(` Skipping ${peerId.substring(0, 8)}... (not connected or not announced)`);
|
|
955
|
-
continue;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
console.log(` โ
Announcing ${peerId.substring(0, 8)}... from network '${networkName}'`);
|
|
959
|
-
|
|
960
|
-
// Send peer-discovered message to bootstrap hub
|
|
961
|
-
const peerAnnouncement = {
|
|
962
|
-
type: 'peer-discovered',
|
|
963
|
-
data: {
|
|
964
|
-
peerId,
|
|
965
|
-
isHub: networkName === this.hubMeshNamespace,
|
|
966
|
-
...peerData.data
|
|
967
|
-
},
|
|
968
|
-
networkName: networkName,
|
|
969
|
-
fromPeerId: 'system',
|
|
970
|
-
timestamp: Date.now()
|
|
971
|
-
};
|
|
972
|
-
|
|
973
|
-
try {
|
|
974
|
-
ws.send(JSON.stringify(peerAnnouncement));
|
|
975
|
-
totalAnnounced++;
|
|
976
|
-
} catch (error) {
|
|
977
|
-
console.error(`โ Error announcing peer ${peerId.substring(0, 8)}... to bootstrap:`, error.message);
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
if (totalAnnounced > 0) {
|
|
983
|
-
console.log(`๐ก Announced ${totalAnnounced} local peer(s) to bootstrap hub`);
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
/**
|
|
988
|
-
* Send all local peers to a connected hub (via peerId)
|
|
989
|
-
*/
|
|
990
|
-
sendLocalPeersToHub(hubPeerId) {
|
|
991
|
-
const hubConnection = this.connections.get(hubPeerId);
|
|
992
|
-
if (!hubConnection || hubConnection.readyState !== WebSocket.OPEN) {
|
|
993
|
-
console.log(`โ ๏ธ Cannot send peers to hub ${hubPeerId.substring(0, 8)}... - not connected`);
|
|
994
|
-
return;
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
let totalSent = 0;
|
|
998
|
-
|
|
999
|
-
// Iterate through all networks and send their peers
|
|
1000
|
-
for (const [networkName, peerSet] of this.networkPeers) {
|
|
1001
|
-
// Skip the hub mesh namespace
|
|
1002
|
-
if (networkName === this.hubMeshNamespace) {
|
|
1003
|
-
continue;
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
for (const peerId of peerSet) {
|
|
1007
|
-
const peerData = this.peerData.get(peerId);
|
|
1008
|
-
|
|
1009
|
-
// Skip hubs, only send regular peers
|
|
1010
|
-
if (peerData?.isHub) {
|
|
1011
|
-
continue;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
// Skip if not connected or not announced
|
|
1015
|
-
const connection = this.connections.get(peerId);
|
|
1016
|
-
if (!connection || connection.readyState !== WebSocket.OPEN || !peerData?.announced) {
|
|
1017
|
-
continue;
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
// Send peer-discovered message to the hub
|
|
1021
|
-
const peerAnnouncement = {
|
|
1022
|
-
type: 'peer-discovered',
|
|
1023
|
-
data: {
|
|
1024
|
-
peerId,
|
|
1025
|
-
isHub: false,
|
|
1026
|
-
...peerData.data
|
|
1027
|
-
},
|
|
1028
|
-
networkName: networkName,
|
|
1029
|
-
fromPeerId: 'system',
|
|
1030
|
-
targetPeerId: hubPeerId,
|
|
1031
|
-
timestamp: Date.now()
|
|
1032
|
-
};
|
|
1033
|
-
|
|
1034
|
-
try {
|
|
1035
|
-
this.sendToConnection(hubConnection, peerAnnouncement);
|
|
1036
|
-
totalSent++;
|
|
1037
|
-
} catch (error) {
|
|
1038
|
-
console.error(`โ Error sending peer ${peerId.substring(0, 8)}... to hub:`, error.message);
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
if (totalSent > 0) {
|
|
1044
|
-
console.log(`๐ก Sent ${totalSent} local peer(s) to hub ${hubPeerId.substring(0, 8)}...`);
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
/**
|
|
1049
|
-
* Handle messages from bootstrap hubs
|
|
1050
|
-
*/
|
|
1051
|
-
handleBootstrapMessage(uri, message) {
|
|
1052
|
-
const { type, data, fromPeerId, targetPeerId, networkName } = message;
|
|
1053
|
-
|
|
1054
|
-
switch (type) {
|
|
1055
|
-
case 'connected':
|
|
1056
|
-
console.log(`โ
Bootstrap hub acknowledged connection: ${uri}`);
|
|
1057
|
-
break;
|
|
1058
|
-
|
|
1059
|
-
case 'peer-discovered':
|
|
1060
|
-
if (data?.isHub) {
|
|
1061
|
-
// Hub discovered via bootstrap - DON'T forward to prevent loops
|
|
1062
|
-
// Hubs will discover each other via their local mesh namespace connections
|
|
1063
|
-
console.log(`๐ข Hub ${data.peerId?.substring(0, 8)}... seen via bootstrap ${uri} (not forwarding to prevent loop)`);
|
|
1064
|
-
this.emit('hubDiscovered', { peerId: data.peerId, via: uri, data });
|
|
1065
|
-
} else if (data?.peerId) {
|
|
1066
|
-
// Regular peer discovered on another hub - notify our local peers in same network
|
|
1067
|
-
const discoveredPeerId = data.peerId;
|
|
1068
|
-
const discoveredNetwork = networkName || 'global';
|
|
1069
|
-
|
|
1070
|
-
console.log(`๐ฅ Peer ${discoveredPeerId.substring(0, 8)}... discovered on another hub (network: ${discoveredNetwork})`);
|
|
1071
|
-
|
|
1072
|
-
// Cache for late joiners (so peers announcing later still learn about this peer)
|
|
1073
|
-
if (!this.crossHubDiscoveredPeers.has(discoveredNetwork)) {
|
|
1074
|
-
this.crossHubDiscoveredPeers.set(discoveredNetwork, new Map());
|
|
1075
|
-
}
|
|
1076
|
-
this.crossHubDiscoveredPeers.get(discoveredNetwork).set(discoveredPeerId, { ...data, cachedAt: Date.now() });
|
|
1077
|
-
|
|
1078
|
-
// Forward to all our local peers in the same network
|
|
1079
|
-
const localPeers = this.getActivePeers(null, discoveredNetwork);
|
|
1080
|
-
let forwardCount = 0;
|
|
1081
|
-
localPeers.forEach(localPeerId => {
|
|
1082
|
-
const localConnection = this.connections.get(localPeerId);
|
|
1083
|
-
if (localConnection) {
|
|
1084
|
-
this.sendToConnection(localConnection, {
|
|
1085
|
-
type: 'peer-discovered',
|
|
1086
|
-
data,
|
|
1087
|
-
networkName: discoveredNetwork,
|
|
1088
|
-
fromPeerId: 'system',
|
|
1089
|
-
targetPeerId: localPeerId,
|
|
1090
|
-
timestamp: Date.now()
|
|
1091
|
-
});
|
|
1092
|
-
forwardCount++;
|
|
1093
|
-
}
|
|
1094
|
-
});
|
|
1095
|
-
console.log(`๐ค Forwarded to ${forwardCount} local peer(s) in network '${discoveredNetwork}'`);
|
|
1096
|
-
}
|
|
1097
|
-
break;
|
|
1098
|
-
|
|
1099
|
-
case 'peer-disconnected':
|
|
1100
|
-
// Handle peer disconnection from another hub
|
|
1101
|
-
if (data?.peerId) {
|
|
1102
|
-
const disconnectedPeerId = data.peerId;
|
|
1103
|
-
const peerNetwork = networkName || 'global';
|
|
1104
|
-
|
|
1105
|
-
if (data?.isHub) {
|
|
1106
|
-
console.log(`๐ข Hub disconnected: ${disconnectedPeerId.substring(0, 8)}... from network: ${peerNetwork}`);
|
|
1107
|
-
} else {
|
|
1108
|
-
if (this.verboseLogging) {
|
|
1109
|
-
console.log(`๐ Remote peer disconnected: ${disconnectedPeerId.substring(0, 8)}... from network: ${peerNetwork}`);
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
// Remove from cross-hub discovered peers cache
|
|
1114
|
-
const cachedRemotePeers = this.crossHubDiscoveredPeers.get(peerNetwork);
|
|
1115
|
-
if (cachedRemotePeers && cachedRemotePeers.has(disconnectedPeerId)) {
|
|
1116
|
-
cachedRemotePeers.delete(disconnectedPeerId);
|
|
1117
|
-
console.log(`๐งน Cleaned up remote peer ${disconnectedPeerId.substring(0, 8)}... from cross-hub cache (network: ${peerNetwork})`);
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
// Notify local peers in the same network about the disconnection
|
|
1121
|
-
const activePeers = this.getActivePeers(null, peerNetwork);
|
|
1122
|
-
activePeers.forEach(localPeerId => {
|
|
1123
|
-
this.sendToConnection(this.connections.get(localPeerId), {
|
|
1124
|
-
type: 'peer-disconnected',
|
|
1125
|
-
data: {
|
|
1126
|
-
peerId: disconnectedPeerId,
|
|
1127
|
-
isHub: data?.isHub || false
|
|
1128
|
-
},
|
|
1129
|
-
networkName: peerNetwork,
|
|
1130
|
-
fromPeerId: 'system',
|
|
1131
|
-
targetPeerId: localPeerId,
|
|
1132
|
-
timestamp: Date.now()
|
|
1133
|
-
});
|
|
1134
|
-
});
|
|
1135
|
-
}
|
|
1136
|
-
break;
|
|
1137
|
-
|
|
1138
|
-
case 'offer':
|
|
1139
|
-
case 'answer':
|
|
1140
|
-
case 'ice-candidate':
|
|
1141
|
-
// Check if target peer is on this hub
|
|
1142
|
-
if (targetPeerId) {
|
|
1143
|
-
const targetConnection = this.connections.get(targetPeerId);
|
|
1144
|
-
if (targetConnection && targetConnection.readyState === WebSocket.OPEN) {
|
|
1145
|
-
// Forward to local peer
|
|
1146
|
-
console.log(`๐ฅ Received ${type} from ${fromPeerId?.substring(0, 8)}... for local peer ${targetPeerId.substring(0, 8)}...`);
|
|
1147
|
-
this.sendToConnection(targetConnection, message);
|
|
1148
|
-
} else {
|
|
1149
|
-
// Not our peer - check if we should relay
|
|
1150
|
-
|
|
1151
|
-
// CRITICAL: DO NOT relay via bootstrap WebSocket - this causes loops
|
|
1152
|
-
// Clients should signal directly through their hub, and hubs use P2P mesh
|
|
1153
|
-
if (this.verboseLogging) {
|
|
1154
|
-
console.log(`โญ๏ธ Skipping bootstrap relay of ${type} - not relaying client signaling via bootstrap`);
|
|
1155
|
-
}
|
|
1156
|
-
// Completely disable bootstrap relay to prevent loops
|
|
1157
|
-
break;
|
|
1158
|
-
}
|
|
1159
|
-
} else {
|
|
1160
|
-
console.log(`โ ๏ธ Received ${type} without targetPeerId via ${uri}`);
|
|
1161
|
-
}
|
|
1162
|
-
this.emit('bootstrapSignaling', { type, data, fromPeerId, targetPeerId, uri });
|
|
1163
|
-
break;
|
|
1164
|
-
|
|
1165
|
-
case 'pong':
|
|
1166
|
-
// Heartbeat response
|
|
1167
|
-
break;
|
|
1168
|
-
|
|
1169
|
-
default:
|
|
1170
|
-
console.log(`๐จ Received ${type} from bootstrap hub ${uri}`);
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
/**
|
|
1175
|
-
* Disconnect from all bootstrap hubs
|
|
1176
|
-
*/
|
|
1177
|
-
disconnectFromBootstrapHubs() {
|
|
1178
|
-
console.log(`๐ Disconnecting from ${this.bootstrapConnections.size} bootstrap hub(s)...`);
|
|
1179
|
-
|
|
1180
|
-
for (const [uri, info] of this.bootstrapConnections) {
|
|
1181
|
-
if (info.reconnectTimer) {
|
|
1182
|
-
clearTimeout(info.reconnectTimer);
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
if (info.ws && info.ws.readyState === WebSocket.OPEN) {
|
|
1186
|
-
info.ws.close(1000, 'Hub shutting down');
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
this.bootstrapConnections.clear();
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
/**
|
|
1194
|
-
* Setup WebSocket connection handlers
|
|
1195
|
-
*/
|
|
1196
|
-
setupWebSocketHandlers() {
|
|
1197
|
-
this.wss.on('connection', (ws, req) => {
|
|
1198
|
-
const url = new URL(req.url, `http://${req.headers.host}`);
|
|
1199
|
-
const peerId = url.searchParams.get('peerId');
|
|
1200
|
-
|
|
1201
|
-
// Validate peer ID
|
|
1202
|
-
if (!peerId || !this.validatePeerId(peerId)) {
|
|
1203
|
-
console.log('โ Invalid peer ID, closing connection');
|
|
1204
|
-
ws.close(1008, 'Invalid peerId format');
|
|
1205
|
-
return;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
// Check if peerId is already connected
|
|
1209
|
-
if (this.connections.has(peerId)) {
|
|
1210
|
-
const existingConnection = this.connections.get(peerId);
|
|
1211
|
-
if (existingConnection.readyState === existingConnection.OPEN) {
|
|
1212
|
-
console.log(`โ ๏ธ Peer ${peerId.substring(0, 8)}... already connected, closing duplicate`);
|
|
1213
|
-
ws.close(1008, 'Peer already connected');
|
|
1214
|
-
return;
|
|
1215
|
-
} else {
|
|
1216
|
-
// Clean up stale connection
|
|
1217
|
-
console.log(`๐ Replacing stale connection for ${peerId.substring(0, 8)}...`);
|
|
1218
|
-
this.cleanupPeer(peerId);
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
// Check connection limit
|
|
1223
|
-
if (this.connections.size >= this.maxConnections) {
|
|
1224
|
-
console.log('โ Maximum connections reached, closing connection');
|
|
1225
|
-
ws.close(1008, 'Maximum connections reached');
|
|
1226
|
-
return;
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
// Store connection
|
|
1230
|
-
this.connections.set(peerId, ws);
|
|
1231
|
-
this.peerData.set(peerId, {
|
|
1232
|
-
peerId,
|
|
1233
|
-
connectedAt: Date.now(),
|
|
1234
|
-
lastActivity: Date.now(),
|
|
1235
|
-
remoteAddress: req.socket.remoteAddress,
|
|
1236
|
-
connected: true
|
|
1237
|
-
});
|
|
1238
|
-
|
|
1239
|
-
// Set up connection metadata
|
|
1240
|
-
ws.connectedAt = Date.now();
|
|
1241
|
-
|
|
1242
|
-
console.log(`โ
Peer connected: ${peerId.substring(0, 8)}... (${this.connections.size} total)`);
|
|
1243
|
-
this.emit('peerConnected', { peerId, totalConnections: this.connections.size });
|
|
1244
|
-
|
|
1245
|
-
// Handle incoming messages
|
|
1246
|
-
ws.on('message', (data) => {
|
|
1247
|
-
try {
|
|
1248
|
-
this.handleMessage(peerId, data);
|
|
1249
|
-
} catch (error) {
|
|
1250
|
-
console.error(`โ Error handling message from ${peerId.substring(0, 8)}...:`, error);
|
|
1251
|
-
}
|
|
1252
|
-
});
|
|
1253
|
-
|
|
1254
|
-
// Handle connection close
|
|
1255
|
-
ws.on('close', (code, reason) => {
|
|
1256
|
-
this.handleDisconnection(peerId, code, reason);
|
|
1257
|
-
});
|
|
1258
|
-
|
|
1259
|
-
// Handle connection error
|
|
1260
|
-
ws.on('error', (error) => {
|
|
1261
|
-
console.error(`โ WebSocket error for ${peerId.substring(0, 8)}...:`, error);
|
|
1262
|
-
this.handleDisconnection(peerId, 1006, 'WebSocket error');
|
|
1263
|
-
});
|
|
1264
|
-
|
|
1265
|
-
// Send connected confirmation
|
|
1266
|
-
this.sendToConnection(ws, {
|
|
1267
|
-
type: 'connected',
|
|
1268
|
-
data: { peerId },
|
|
1269
|
-
fromPeerId: 'system',
|
|
1270
|
-
timestamp: Date.now()
|
|
1271
|
-
});
|
|
1272
|
-
});
|
|
1273
|
-
|
|
1274
|
-
this.wss.on('error', (error) => {
|
|
1275
|
-
console.error('โ WebSocket server error:', error);
|
|
1276
|
-
this.emit('error', error);
|
|
1277
|
-
});
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
/**
|
|
1281
|
-
* Handle incoming messages from peers
|
|
1282
|
-
*/
|
|
1283
|
-
handleMessage(peerId, data) {
|
|
1284
|
-
// Update last activity
|
|
1285
|
-
const peerInfo = this.peerData.get(peerId);
|
|
1286
|
-
if (peerInfo) {
|
|
1287
|
-
peerInfo.lastActivity = Date.now();
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
let message;
|
|
1291
|
-
try {
|
|
1292
|
-
message = JSON.parse(data.toString());
|
|
1293
|
-
} catch (error) {
|
|
1294
|
-
console.error(`โ Invalid JSON from ${peerId.substring(0, 8)}...:`, error);
|
|
1295
|
-
return;
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
const { type, data: messageData, targetPeerId, networkName, fromPeerId: originalFromPeerId } = message;
|
|
1299
|
-
|
|
1300
|
-
// Log message type
|
|
1301
|
-
if (this.verboseLogging) {
|
|
1302
|
-
console.log(`๐จ Received ${type} from ${peerId.substring(0, 8)}... in network: ${networkName || 'global'}`);
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
// Preserve the original fromPeerId if it exists (for relayed messages from other hubs)
|
|
1306
|
-
// Otherwise use the peerId of the connection
|
|
1307
|
-
const responseMessage = {
|
|
1308
|
-
type,
|
|
1309
|
-
data: messageData,
|
|
1310
|
-
fromPeerId: originalFromPeerId || peerId,
|
|
1311
|
-
targetPeerId,
|
|
1312
|
-
networkName: networkName || 'global',
|
|
1313
|
-
timestamp: Date.now()
|
|
1314
|
-
};
|
|
1315
|
-
|
|
1316
|
-
switch (type) {
|
|
1317
|
-
case 'announce':
|
|
1318
|
-
this.handleAnnounce(peerId, message, responseMessage);
|
|
1319
|
-
break;
|
|
1320
|
-
case 'goodbye':
|
|
1321
|
-
this.handleGoodbye(peerId, message, responseMessage);
|
|
1322
|
-
break;
|
|
1323
|
-
case 'offer':
|
|
1324
|
-
case 'answer':
|
|
1325
|
-
case 'ice-candidate':
|
|
1326
|
-
this.handleSignaling(peerId, message, responseMessage);
|
|
1327
|
-
break;
|
|
1328
|
-
case 'peer-discovered':
|
|
1329
|
-
// Handle peer discovery from other hubs
|
|
1330
|
-
this.handlePeerDiscovered(peerId, message);
|
|
1331
|
-
break;
|
|
1332
|
-
case 'ping':
|
|
1333
|
-
this.handlePing(peerId, message);
|
|
1334
|
-
break;
|
|
1335
|
-
case 'cleanup':
|
|
1336
|
-
this.handleCleanup(peerId, message);
|
|
1337
|
-
break;
|
|
1338
|
-
default:
|
|
1339
|
-
if (this.verboseLogging) {
|
|
1340
|
-
console.log(`โ ๏ธ Ignoring non-signaling message type '${type}' - peers should route their own messages`);
|
|
1341
|
-
}
|
|
1342
|
-
const connection = this.connections.get(peerId);
|
|
1343
|
-
if (connection && connection.readyState === WebSocket.OPEN) {
|
|
1344
|
-
this.sendToConnection(connection, {
|
|
1345
|
-
type: 'error',
|
|
1346
|
-
error: `Signaling server does not route '${type}' messages. Use WebRTC data channels for peer-to-peer communication.`,
|
|
1347
|
-
timestamp: Date.now()
|
|
1348
|
-
});
|
|
1349
|
-
}
|
|
1350
|
-
break;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
/**
|
|
1355
|
-
* Handle peer announcement
|
|
1356
|
-
*/
|
|
1357
|
-
handleAnnounce(peerId, message, responseMessage) {
|
|
1358
|
-
// Extract network name from the message
|
|
1359
|
-
const peerNetworkName = message.networkName || 'global';
|
|
1360
|
-
|
|
1361
|
-
// Detect if this peer is a hub
|
|
1362
|
-
const isHub = message.data?.isHub === true || peerNetworkName === this.hubMeshNamespace;
|
|
1363
|
-
|
|
1364
|
-
if (this.verboseLogging) {
|
|
1365
|
-
if (isHub) {
|
|
1366
|
-
console.log(`๐ข Hub announced: ${peerId.substring(0, 8)}... in network: ${peerNetworkName}`);
|
|
1367
|
-
} else {
|
|
1368
|
-
console.log(`๐ข Peer announced: ${peerId.substring(0, 8)}... in network: ${peerNetworkName}`);
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
// Update peer data with network information
|
|
1373
|
-
const peerInfo = this.peerData.get(peerId);
|
|
1374
|
-
if (peerInfo) {
|
|
1375
|
-
peerInfo.announced = true;
|
|
1376
|
-
peerInfo.announcedAt = Date.now();
|
|
1377
|
-
peerInfo.networkName = peerNetworkName;
|
|
1378
|
-
peerInfo.data = message.data;
|
|
1379
|
-
peerInfo.isHub = isHub;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
// Register as hub if applicable
|
|
1383
|
-
if (isHub) {
|
|
1384
|
-
this.registerHub(peerId, {
|
|
1385
|
-
networkName: peerNetworkName,
|
|
1386
|
-
data: message.data,
|
|
1387
|
-
connectedAt: peerInfo?.connectedAt || Date.now()
|
|
1388
|
-
});
|
|
1389
|
-
|
|
1390
|
-
// Track WebSocket connection with this hub
|
|
1391
|
-
const wsConnection = this.connections.get(peerId);
|
|
1392
|
-
if (wsConnection) {
|
|
1393
|
-
if (!this.hubMeshPeers.has(peerId)) {
|
|
1394
|
-
this.hubMeshPeers.set(peerId, { p2pConnected: false, wsConnection: null });
|
|
1395
|
-
}
|
|
1396
|
-
this.hubMeshPeers.get(peerId).wsConnection = wsConnection;
|
|
1397
|
-
console.log(`๐ Tracking hub ${peerId.substring(0, 8)}... WebSocket connection for migration`);
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
// CRITICAL: Forward hub announcement to local hub mesh for P2P discovery
|
|
1401
|
-
// When Hub A announces to Hub B, Hub B's hubMesh needs to know about Hub A
|
|
1402
|
-
if (this.isHub && this.hubMesh && peerId !== this.hubPeerId) {
|
|
1403
|
-
console.log(`๐ Forwarding hub ${peerId.substring(0, 8)}... to local hub mesh for P2P discovery`);
|
|
1404
|
-
|
|
1405
|
-
// Send peer-discovered to this hub's local signaling connection
|
|
1406
|
-
// This will trigger the hub mesh to discover and connect to the announcing hub
|
|
1407
|
-
const localConnection = this.connections.get(this.hubPeerId);
|
|
1408
|
-
if (localConnection && localConnection.readyState === WebSocket.OPEN) {
|
|
1409
|
-
this.sendToConnection(localConnection, {
|
|
1410
|
-
type: 'peer-discovered',
|
|
1411
|
-
data: {
|
|
1412
|
-
peerId,
|
|
1413
|
-
isHub: true,
|
|
1414
|
-
...message.data
|
|
1415
|
-
},
|
|
1416
|
-
networkName: this.hubMeshNamespace,
|
|
1417
|
-
fromPeerId: 'system',
|
|
1418
|
-
targetPeerId: this.hubPeerId,
|
|
1419
|
-
timestamp: Date.now()
|
|
1420
|
-
});
|
|
1421
|
-
console.log(`โ
Sent peer-discovered to local hub mesh for ${peerId.substring(0, 8)}...`);
|
|
1422
|
-
} else {
|
|
1423
|
-
console.log(`โ ๏ธ Local hub mesh connection not ready, cannot forward hub announcement`);
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
// When a new hub announces itself, send it all our local peers
|
|
1428
|
-
if (this.isHub) {
|
|
1429
|
-
console.log(`๐ก New hub connected, sending our local peers to ${peerId.substring(0, 8)}...`);
|
|
1430
|
-
this.sendLocalPeersToHub(peerId);
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
// Add peer to network tracking
|
|
1435
|
-
if (!this.networkPeers.has(peerNetworkName)) {
|
|
1436
|
-
this.networkPeers.set(peerNetworkName, new Set());
|
|
1437
|
-
}
|
|
1438
|
-
this.networkPeers.get(peerNetworkName).add(peerId);
|
|
1439
|
-
|
|
1440
|
-
// If this is a hub, broadcast this peer to other connected hubs
|
|
1441
|
-
// CRITICAL: Do NOT broadcast hub mesh peers (isHub=true) to prevent discovery loops
|
|
1442
|
-
if (this.isHub && !isHub) {
|
|
1443
|
-
// Check if there are any other hubs at all
|
|
1444
|
-
const hasOtherHubs = this.hubs.size > 0 || this.bootstrapConnections.size > 0;
|
|
1445
|
-
|
|
1446
|
-
// PRIORITY: Use P2P hub mesh if ready AND there are other hubs
|
|
1447
|
-
if (this.hubMesh && this.hubMeshReady && hasOtherHubs) {
|
|
1448
|
-
const p2pConnectedHubs = this.hubMesh.connectionManager.getConnectedPeers();
|
|
1449
|
-
if (p2pConnectedHubs.length > 0) {
|
|
1450
|
-
console.log(`๐ก Broadcasting peer ${peerId.substring(0, 8)}... to ${p2pConnectedHubs.length} P2P-connected hub(s) [MESH MODE]`);
|
|
1451
|
-
|
|
1452
|
-
const p2pRelayMessage = {
|
|
1453
|
-
type: 'peer-announce-relay',
|
|
1454
|
-
peerId,
|
|
1455
|
-
networkName: peerNetworkName,
|
|
1456
|
-
peerData: {
|
|
1457
|
-
peerId,
|
|
1458
|
-
isHub: false,
|
|
1459
|
-
...message.data
|
|
1460
|
-
},
|
|
1461
|
-
timestamp: Date.now()
|
|
1462
|
-
};
|
|
1463
|
-
|
|
1464
|
-
p2pConnectedHubs.forEach(hubPeerConnection => {
|
|
1465
|
-
try {
|
|
1466
|
-
const hubPeerId = hubPeerConnection.peerId;
|
|
1467
|
-
this.hubMesh.sendMessage(p2pRelayMessage, hubPeerId);
|
|
1468
|
-
} catch (error) {
|
|
1469
|
-
const hubPeerId = hubPeerConnection.peerId || 'unknown';
|
|
1470
|
-
console.error(`โ Error broadcasting to P2P hub ${hubPeerId.substring(0, 8)}...:`, error.message);
|
|
1471
|
-
}
|
|
1472
|
-
});
|
|
1473
|
-
}
|
|
1474
|
-
// When mesh is ready and we have other hubs, ONLY use P2P - skip WebSocket broadcast
|
|
1475
|
-
// (Fall through to peer list broadcast below)
|
|
1476
|
-
} else if (hasOtherHubs) {
|
|
1477
|
-
// Fallback: Use WebSocket connections (only when mesh NOT ready)
|
|
1478
|
-
const connectedHubs = [];
|
|
1479
|
-
|
|
1480
|
-
// 1. Add outgoing bootstrap connections
|
|
1481
|
-
for (const [uri, connInfo] of this.bootstrapConnections) {
|
|
1482
|
-
if (connInfo.connected && connInfo.ws.readyState === WebSocket.OPEN) {
|
|
1483
|
-
connectedHubs.push({ type: 'bootstrap', ws: connInfo.ws, id: uri });
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
// 2. Add incoming hub connections (hubs that connected to us)
|
|
1488
|
-
for (const [hubPeerId, hubInfo] of this.hubs) {
|
|
1489
|
-
// Skip self and the announcing hub
|
|
1490
|
-
if (hubPeerId === this.hubPeerId || hubPeerId === peerId) {
|
|
1491
|
-
continue;
|
|
1492
|
-
}
|
|
1493
|
-
const hubConnection = this.connections.get(hubPeerId);
|
|
1494
|
-
if (hubConnection && hubConnection.readyState === WebSocket.OPEN) {
|
|
1495
|
-
connectedHubs.push({ type: 'incoming', ws: hubConnection, id: hubPeerId });
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
if (connectedHubs.length > 0) {
|
|
1500
|
-
console.log(`๐ก Broadcasting peer ${peerId.substring(0, 8)}... to ${connectedHubs.length} WebSocket hub(s) [BOOTSTRAP MODE]`);
|
|
1501
|
-
const peerAnnouncement = {
|
|
1502
|
-
type: 'peer-discovered',
|
|
1503
|
-
data: {
|
|
1504
|
-
peerId,
|
|
1505
|
-
isHub: false,
|
|
1506
|
-
...message.data
|
|
1507
|
-
},
|
|
1508
|
-
networkName: peerNetworkName,
|
|
1509
|
-
fromPeerId: 'system',
|
|
1510
|
-
timestamp: Date.now()
|
|
1511
|
-
};
|
|
1512
|
-
|
|
1513
|
-
for (const hub of connectedHubs) {
|
|
1514
|
-
try {
|
|
1515
|
-
if (hub.type === 'bootstrap') {
|
|
1516
|
-
hub.ws.send(JSON.stringify(peerAnnouncement));
|
|
1517
|
-
} else {
|
|
1518
|
-
this.sendToConnection(hub.ws, peerAnnouncement);
|
|
1519
|
-
}
|
|
1520
|
-
} catch (error) {
|
|
1521
|
-
console.error(`โ Error broadcasting to hub ${hub.id}:`, error.message);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
// Get active peers in the same network
|
|
1529
|
-
const activePeers = this.getActivePeers(peerId, peerNetworkName);
|
|
1530
|
-
|
|
1531
|
-
// Validate peers
|
|
1532
|
-
const validatedPeers = [];
|
|
1533
|
-
for (const otherPeerId of activePeers) {
|
|
1534
|
-
const connection = this.connections.get(otherPeerId);
|
|
1535
|
-
if (connection && connection.readyState === connection.OPEN) {
|
|
1536
|
-
validatedPeers.push(otherPeerId);
|
|
1537
|
-
} else {
|
|
1538
|
-
console.log(`๐งน Found dead connection during announce: ${otherPeerId.substring(0, 8)}...`);
|
|
1539
|
-
this.cleanupPeer(otherPeerId);
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
const hubType = isHub ? 'hub' : 'peer';
|
|
1544
|
-
console.log(`๐ข Announcing ${hubType} ${peerId.substring(0, 8)}... to ${validatedPeers.length} validated peers in network: ${peerNetworkName}`);
|
|
1545
|
-
|
|
1546
|
-
// Send peer-discovered messages to validated peers only
|
|
1547
|
-
validatedPeers.forEach(otherPeerId => {
|
|
1548
|
-
const otherPeerData = this.peerData.get(otherPeerId);
|
|
1549
|
-
this.sendToConnection(this.connections.get(otherPeerId), {
|
|
1550
|
-
type: 'peer-discovered',
|
|
1551
|
-
data: {
|
|
1552
|
-
peerId,
|
|
1553
|
-
isHub,
|
|
1554
|
-
...message.data
|
|
1555
|
-
},
|
|
1556
|
-
networkName: peerNetworkName,
|
|
1557
|
-
fromPeerId: 'system',
|
|
1558
|
-
targetPeerId: otherPeerId,
|
|
1559
|
-
timestamp: Date.now()
|
|
1560
|
-
});
|
|
1561
|
-
});
|
|
1562
|
-
|
|
1563
|
-
// Send existing validated peers to the new peer (include their hub status)
|
|
1564
|
-
const newPeerConnection = this.connections.get(peerId);
|
|
1565
|
-
validatedPeers.forEach(existingPeerId => {
|
|
1566
|
-
const existingPeerData = this.peerData.get(existingPeerId);
|
|
1567
|
-
this.sendToConnection(newPeerConnection, {
|
|
1568
|
-
type: 'peer-discovered',
|
|
1569
|
-
data: {
|
|
1570
|
-
peerId: existingPeerId,
|
|
1571
|
-
isHub: existingPeerData?.isHub || false,
|
|
1572
|
-
...existingPeerData?.data
|
|
1573
|
-
},
|
|
1574
|
-
networkName: peerNetworkName,
|
|
1575
|
-
fromPeerId: 'system',
|
|
1576
|
-
targetPeerId: peerId,
|
|
1577
|
-
timestamp: Date.now()
|
|
1578
|
-
});
|
|
1579
|
-
});
|
|
1580
|
-
|
|
1581
|
-
// Include ALL cached cross-hub peers immediately (original behavior) to maximize candidate pool
|
|
1582
|
-
const cachedRemotePeers = this.crossHubDiscoveredPeers.get(peerNetworkName);
|
|
1583
|
-
if (cachedRemotePeers && newPeerConnection && newPeerConnection.readyState === newPeerConnection.OPEN) {
|
|
1584
|
-
let sentCount = 0;
|
|
1585
|
-
for (const [remotePeerId, remotePeerData] of cachedRemotePeers) {
|
|
1586
|
-
if (validatedPeers.includes(remotePeerId)) continue;
|
|
1587
|
-
this.sendToConnection(newPeerConnection, {
|
|
1588
|
-
type: 'peer-discovered',
|
|
1589
|
-
data: { peerId: remotePeerId, isHub: remotePeerData.isHub || false, ...remotePeerData },
|
|
1590
|
-
networkName: peerNetworkName,
|
|
1591
|
-
fromPeerId: 'system',
|
|
1592
|
-
targetPeerId: peerId,
|
|
1593
|
-
timestamp: Date.now()
|
|
1594
|
-
});
|
|
1595
|
-
sentCount++;
|
|
1596
|
-
}
|
|
1597
|
-
if (sentCount > 0) {
|
|
1598
|
-
console.log(`๐ฆ Sent ${sentCount} cached cross-hub peer(s) to late joiner ${peerId.substring(0,8)}... in network '${peerNetworkName}'`);
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
|
-
this.emit('peerAnnounced', { peerId, networkName: peerNetworkName, isHub });
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
/**
|
|
1606
|
-
* Handle peer goodbye
|
|
1607
|
-
*/
|
|
1608
|
-
handleGoodbye(peerId, message, responseMessage) {
|
|
1609
|
-
if (this.verboseLogging) {
|
|
1610
|
-
console.log(`๐ Peer goodbye: ${peerId.substring(0, 8)}...`);
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
// Broadcast to closest peers before removing peer data
|
|
1614
|
-
this.broadcastToClosestPeers(peerId, responseMessage);
|
|
1615
|
-
|
|
1616
|
-
// Remove peer
|
|
1617
|
-
this.cleanupPeer(peerId);
|
|
1618
|
-
this.emit('peerGoodbye', { peerId });
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
/**
|
|
1622
|
-
* Handle WebRTC signaling messages
|
|
1623
|
-
*/
|
|
1624
|
-
handleSignaling(peerId, message, responseMessage) {
|
|
1625
|
-
const targetPeerId = message.targetPeerId;
|
|
1626
|
-
const networkName = message.networkName || 'global';
|
|
1627
|
-
|
|
1628
|
-
if (this.verboseLogging) {
|
|
1629
|
-
console.log(`๐ SIGNALING DEBUG: Received ${message.type} from ${peerId.substring(0, 8)}... to ${targetPeerId?.substring(0, 8)}... in network '${networkName}'`);
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
|
-
if (!targetPeerId) {
|
|
1633
|
-
if (this.verboseLogging) {
|
|
1634
|
-
console.log(`โ No target peer ID in signaling message from ${peerId.substring(0, 8)}...`);
|
|
1635
|
-
}
|
|
1636
|
-
return;
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
|
-
const targetConnection = this.connections.get(targetPeerId);
|
|
1640
|
-
|
|
1641
|
-
// Only validate network if target peer is local (we have their data)
|
|
1642
|
-
if (targetConnection) {
|
|
1643
|
-
const targetPeerData = this.peerData.get(targetPeerId);
|
|
1644
|
-
const targetNetwork = targetPeerData?.networkName || 'global';
|
|
1645
|
-
|
|
1646
|
-
if (networkName !== targetNetwork) {
|
|
1647
|
-
if (this.verboseLogging) {
|
|
1648
|
-
console.log(`๐ซ Blocking ${message.type} from ${peerId.substring(0, 8)}... (network: ${networkName}) to ${targetPeerId.substring(0, 8)}... (network: ${targetNetwork}) - different networks`);
|
|
1649
|
-
}
|
|
1650
|
-
return;
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
// Target is local - forward directly
|
|
1654
|
-
if (this.verboseLogging) {
|
|
1655
|
-
console.log(`โ
Forwarding ${message.type} to LOCAL peer ${targetPeerId.substring(0, 8)}...`);
|
|
1656
|
-
}
|
|
1657
|
-
this.sendToConnection(targetConnection, responseMessage);
|
|
1658
|
-
} else {
|
|
1659
|
-
// Target peer not on this hub - relay to other hubs
|
|
1660
|
-
|
|
1661
|
-
// Create unique message ID for deduplication (include signal data hash)
|
|
1662
|
-
const dataHash = this.hashSignalData(message.data);
|
|
1663
|
-
const messageId = `${message.type}:${peerId}:${targetPeerId}:${dataHash}`;
|
|
1664
|
-
|
|
1665
|
-
// Check if we've already relayed this message recently
|
|
1666
|
-
if (this.recentlyRelayedMessages.has(messageId)) {
|
|
1667
|
-
if (this.verboseLogging) {
|
|
1668
|
-
console.log(`โญ๏ธ Skipping duplicate relay of ${message.type} (${messageId})`);
|
|
1669
|
-
}
|
|
1670
|
-
return;
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
// Mark message as relayed
|
|
1674
|
-
this.recentlyRelayedMessages.set(messageId, Date.now());
|
|
1675
|
-
|
|
1676
|
-
console.log(`๐ Target peer ${targetPeerId.substring(0, 8)}... NOT LOCAL, relaying to other hubs (network: ${networkName})`);
|
|
1677
|
-
|
|
1678
|
-
let relayed = false;
|
|
1679
|
-
|
|
1680
|
-
// Check if there are any other hubs at all
|
|
1681
|
-
const hasOtherHubs = this.hubs.size > 0 || this.bootstrapConnections.size > 0;
|
|
1682
|
-
|
|
1683
|
-
// PRIORITY: Try P2P hub mesh first if available and ready
|
|
1684
|
-
if (this.isHub && this.hubMesh && this.hubMeshReady && hasOtherHubs) {
|
|
1685
|
-
const p2pConnectedHubs = this.hubMesh.connectionManager.getConnectedPeers();
|
|
1686
|
-
if (p2pConnectedHubs.length > 0) {
|
|
1687
|
-
console.log(`๐ก Relaying ${message.type} through P2P hub mesh (${p2pConnectedHubs.length} hubs)`);
|
|
1688
|
-
this.forwardSignalToHubMesh(targetPeerId, responseMessage);
|
|
1689
|
-
relayed = true;
|
|
1690
|
-
} else {
|
|
1691
|
-
console.log(`โ ๏ธ Hub mesh ready but no P2P connections available`);
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
// CRITICAL: When mesh is ready AND we have other hubs, ONLY use P2P - do NOT fall back to WebSocket
|
|
1695
|
-
if (this.hubMeshReady && hasOtherHubs) {
|
|
1696
|
-
if (!relayed) {
|
|
1697
|
-
console.log(`โ FAILED TO RELAY via P2P: Mesh ready but no connections for ${targetPeerId.substring(0, 8)}...`);
|
|
1698
|
-
}
|
|
1699
|
-
return; // Exit early - no WebSocket fallback when mesh is ready and other hubs exist
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
// Fallback: Try relaying through WebSocket bootstrap hubs (ONLY if mesh not ready)
|
|
1704
|
-
if (!relayed && this.bootstrapConnections.size > 0) {
|
|
1705
|
-
console.log(`๐ Relaying ${message.type} through ${this.bootstrapConnections.size} WebSocket bootstrap connection(s)`);
|
|
1706
|
-
|
|
1707
|
-
for (const [uri, connInfo] of this.bootstrapConnections) {
|
|
1708
|
-
if (connInfo.connected && connInfo.ws.readyState === WebSocket.OPEN) {
|
|
1709
|
-
connInfo.ws.send(JSON.stringify(responseMessage));
|
|
1710
|
-
console.log(`โ
Relayed ${message.type} to bootstrap hub ${uri}`);
|
|
1711
|
-
relayed = true;
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
// Final fallback: Forward to WebSocket-connected hubs (ONLY if mesh not ready)
|
|
1717
|
-
if (!relayed && this.hubs.size > 0) {
|
|
1718
|
-
console.log(`๐ Forwarding ${message.type} to ${this.hubs.size} WebSocket-connected hub(s)`);
|
|
1719
|
-
|
|
1720
|
-
for (const [hubPeerId, hubInfo] of this.hubs) {
|
|
1721
|
-
const hubConnection = this.connections.get(hubPeerId);
|
|
1722
|
-
if (hubConnection && hubConnection.readyState === WebSocket.OPEN) {
|
|
1723
|
-
hubConnection.send(JSON.stringify(responseMessage));
|
|
1724
|
-
console.log(`โ
Forwarded ${message.type} to hub ${hubPeerId.substring(0, 8)}...`);
|
|
1725
|
-
relayed = true;
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
if (!relayed) {
|
|
1731
|
-
console.log(`โ FAILED TO RELAY: No hubs available for ${targetPeerId.substring(0, 8)}... (network: ${networkName})`);
|
|
1732
|
-
console.log(` - P2P hub mesh: ${this.hubMesh ? this.hubMesh.connectionManager.getConnectedPeers().length : 0}`);
|
|
1733
|
-
console.log(` - Bootstrap connections: ${this.bootstrapConnections.size}`);
|
|
1734
|
-
console.log(` - Connected hubs: ${this.hubs.size}`);
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
|
|
1739
|
-
/**
|
|
1740
|
-
* Handle ping messages
|
|
1741
|
-
*/
|
|
1742
|
-
handlePing(peerId, message) {
|
|
1743
|
-
const connection = this.connections.get(peerId);
|
|
1744
|
-
if (connection) {
|
|
1745
|
-
this.sendToConnection(connection, {
|
|
1746
|
-
type: 'pong',
|
|
1747
|
-
data: { timestamp: Date.now() },
|
|
1748
|
-
fromPeerId: 'system',
|
|
1749
|
-
targetPeerId: peerId,
|
|
1750
|
-
timestamp: Date.now()
|
|
1751
|
-
});
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
|
-
/**
|
|
1756
|
-
* Handle cleanup messages
|
|
1757
|
-
*/
|
|
1758
|
-
handleCleanup(peerId, message) {
|
|
1759
|
-
console.log(`๐งน Cleanup request from ${peerId.substring(0, 8)}...`);
|
|
1760
|
-
// Cleanup is handled by the cleanup timer
|
|
1761
|
-
// This is just for logging purposes
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
/**
|
|
1765
|
-
* Handle peer discovery messages from other hubs
|
|
1766
|
-
*/
|
|
1767
|
-
handlePeerDiscovered(fromHubPeerId, message) {
|
|
1768
|
-
const { data: messageData, networkName } = message;
|
|
1769
|
-
const discoveredPeerId = messageData?.peerId;
|
|
1770
|
-
|
|
1771
|
-
if (!discoveredPeerId || !networkName) {
|
|
1772
|
-
console.log(`โ ๏ธ Invalid peer-discovered message from ${fromHubPeerId.substring(0, 8)}...`);
|
|
1773
|
-
return;
|
|
1774
|
-
}
|
|
1775
|
-
|
|
1776
|
-
// Check if sender is a hub (either a regular hub or a hub via bootstrap)
|
|
1777
|
-
const senderPeerData = this.peerData.get(fromHubPeerId);
|
|
1778
|
-
const isFromHub = senderPeerData?.isHub ||
|
|
1779
|
-
senderPeerData?.networkName === this.hubMeshNamespace ||
|
|
1780
|
-
this.hubs.has(fromHubPeerId);
|
|
1781
|
-
|
|
1782
|
-
if (!isFromHub) {
|
|
1783
|
-
console.log(`โ ๏ธ Received peer-discovered from non-hub peer ${fromHubPeerId.substring(0, 8)}... - ignoring`);
|
|
1784
|
-
console.log(` Debug: isHub=${senderPeerData?.isHub}, networkName=${senderPeerData?.networkName}, inHubsMap=${this.hubs.has(fromHubPeerId)}`);
|
|
1785
|
-
return;
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
console.log(`๐ Received peer discovery from hub ${fromHubPeerId.substring(0, 8)}... - Peer ${discoveredPeerId.substring(0, 8)}... in network '${networkName}'`);
|
|
1789
|
-
|
|
1790
|
-
// Forward to all local CLIENT peers in the same network (exclude hubs)
|
|
1791
|
-
const localPeers = this.networkPeers.get(networkName);
|
|
1792
|
-
if (localPeers && localPeers.size > 0) {
|
|
1793
|
-
let forwardedCount = 0;
|
|
1794
|
-
for (const localPeerId of localPeers) {
|
|
1795
|
-
// Skip hubs - only forward to client peers
|
|
1796
|
-
const localPeerData = this.peerData.get(localPeerId);
|
|
1797
|
-
if (localPeerData?.isHub) {
|
|
1798
|
-
continue;
|
|
1799
|
-
}
|
|
1800
|
-
|
|
1801
|
-
const ws = this.connections.get(localPeerId);
|
|
1802
|
-
if (ws && ws.readyState === ws.OPEN) {
|
|
1803
|
-
ws.send(JSON.stringify({
|
|
1804
|
-
type: 'peer-discovered',
|
|
1805
|
-
data: messageData,
|
|
1806
|
-
networkName,
|
|
1807
|
-
fromPeerId: 'system',
|
|
1808
|
-
targetPeerId: localPeerId,
|
|
1809
|
-
timestamp: Date.now()
|
|
1810
|
-
}));
|
|
1811
|
-
forwardedCount++;
|
|
1812
|
-
}
|
|
1813
|
-
}
|
|
1814
|
-
console.log(`โ
Forwarded peer-discovered to ${forwardedCount} local peer(s) in network '${networkName}'`);
|
|
1815
|
-
} else {
|
|
1816
|
-
console.log(`โน๏ธ No local peers in network '${networkName}' to forward to`);
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
/**
|
|
1821
|
-
* Handle peer disconnection
|
|
1822
|
-
*/
|
|
1823
|
-
handleDisconnection(peerId, code, reason) {
|
|
1824
|
-
if (this.verboseLogging) {
|
|
1825
|
-
console.log(`โ Peer disconnected: ${peerId.substring(0, 8)}... (code: ${code}, reason: ${reason})`);
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
|
-
// Get peer info before cleanup
|
|
1829
|
-
const peerInfo = this.peerData.get(peerId);
|
|
1830
|
-
const networkName = peerInfo?.networkName || 'global';
|
|
1831
|
-
const isHub = peerInfo?.isHub || false;
|
|
1832
|
-
|
|
1833
|
-
// Notify other peers about disconnection
|
|
1834
|
-
this.broadcastToOthers(peerId, {
|
|
1835
|
-
type: 'peer-disconnected',
|
|
1836
|
-
data: {
|
|
1837
|
-
peerId,
|
|
1838
|
-
isHub,
|
|
1839
|
-
reason: reason?.toString() || 'disconnected',
|
|
1840
|
-
timestamp: Date.now()
|
|
1841
|
-
},
|
|
1842
|
-
fromPeerId: 'system',
|
|
1843
|
-
timestamp: Date.now()
|
|
1844
|
-
});
|
|
1845
|
-
|
|
1846
|
-
// Broadcast peer disconnection to other hubs so they can clean up their caches
|
|
1847
|
-
if (this.isHub) {
|
|
1848
|
-
const disconnectMessage = {
|
|
1849
|
-
type: 'peer-disconnected',
|
|
1850
|
-
data: {
|
|
1851
|
-
peerId,
|
|
1852
|
-
isHub,
|
|
1853
|
-
reason: reason?.toString() || 'disconnected',
|
|
1854
|
-
timestamp: Date.now()
|
|
1855
|
-
},
|
|
1856
|
-
networkName,
|
|
1857
|
-
fromPeerId: 'system',
|
|
1858
|
-
timestamp: Date.now()
|
|
1859
|
-
};
|
|
1860
|
-
|
|
1861
|
-
// Broadcast via P2P hub mesh if available
|
|
1862
|
-
if (this.hubMesh && this.hubMeshReady) {
|
|
1863
|
-
const p2pConnectedHubs = this.hubMesh.connectionManager.getConnectedPeers();
|
|
1864
|
-
if (p2pConnectedHubs.length > 0) {
|
|
1865
|
-
console.log(`๐ก Broadcasting peer disconnection to ${p2pConnectedHubs.length} hub(s) via P2P mesh`);
|
|
1866
|
-
this.hubMesh.sendMessage(disconnectMessage);
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
|
-
// Also broadcast to WebSocket-connected hubs (bootstrap and incoming)
|
|
1871
|
-
for (const [uri, connInfo] of this.bootstrapConnections) {
|
|
1872
|
-
if (connInfo.connected && connInfo.ws.readyState === WebSocket.OPEN) {
|
|
1873
|
-
connInfo.ws.send(JSON.stringify(disconnectMessage));
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
for (const [hubPeerId, hubInfo] of this.hubs) {
|
|
1878
|
-
if (hubPeerId !== peerId) {
|
|
1879
|
-
const hubConnection = this.connections.get(hubPeerId);
|
|
1880
|
-
if (hubConnection && hubConnection.readyState === WebSocket.OPEN) {
|
|
1881
|
-
hubConnection.send(JSON.stringify(disconnectMessage));
|
|
1882
|
-
}
|
|
1883
|
-
}
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
|
|
1887
|
-
// Remove peer
|
|
1888
|
-
this.cleanupPeer(peerId);
|
|
1889
|
-
this.emit('peerDisconnected', { peerId, code, reason, totalConnections: this.connections.size });
|
|
1890
|
-
}
|
|
1891
|
-
|
|
1892
|
-
/**
|
|
1893
|
-
* Remove peer from server with network cleanup
|
|
1894
|
-
*/
|
|
1895
|
-
cleanupPeer(peerId) {
|
|
1896
|
-
const wasConnected = this.connections.has(peerId);
|
|
1897
|
-
const peerInfo = this.peerData.get(peerId);
|
|
1898
|
-
const isHub = peerInfo?.isHub || false;
|
|
1899
|
-
|
|
1900
|
-
this.connections.delete(peerId);
|
|
1901
|
-
this.peerData.delete(peerId);
|
|
1902
|
-
|
|
1903
|
-
// Unregister hub if applicable
|
|
1904
|
-
if (isHub) {
|
|
1905
|
-
this.unregisterHub(peerId);
|
|
1906
|
-
}
|
|
1907
|
-
|
|
1908
|
-
// Remove from network tracking
|
|
1909
|
-
if (peerInfo && peerInfo.networkName) {
|
|
1910
|
-
const networkPeerSet = this.networkPeers.get(peerInfo.networkName);
|
|
1911
|
-
if (networkPeerSet) {
|
|
1912
|
-
networkPeerSet.delete(peerId);
|
|
1913
|
-
// Clean up empty network sets
|
|
1914
|
-
if (networkPeerSet.size === 0) {
|
|
1915
|
-
this.networkPeers.delete(peerInfo.networkName);
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
|
|
1919
|
-
// Remove from cross-hub discovered peers cache
|
|
1920
|
-
const cachedRemotePeers = this.crossHubDiscoveredPeers.get(peerInfo.networkName);
|
|
1921
|
-
if (cachedRemotePeers) {
|
|
1922
|
-
cachedRemotePeers.delete(peerId);
|
|
1923
|
-
if (this.verboseLogging) {
|
|
1924
|
-
console.log(`๐งน Removed peer ${peerId.substring(0, 8)}... from cross-hub cache for network: ${peerInfo.networkName}`);
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1929
|
-
if (wasConnected) {
|
|
1930
|
-
const peerType = isHub ? 'hub' : 'peer';
|
|
1931
|
-
if (this.verboseLogging) {
|
|
1932
|
-
console.log(`๐งน Cleaned up ${peerType}: ${peerId.substring(0, 8)}... from network: ${peerInfo?.networkName || 'unknown'}`);
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
// Notify other peers in the same network about disconnection
|
|
1936
|
-
if (peerInfo && peerInfo.networkName) {
|
|
1937
|
-
const activePeers = this.getActivePeers(null, peerInfo.networkName);
|
|
1938
|
-
activePeers.forEach(otherPeerId => {
|
|
1939
|
-
this.sendToConnection(this.connections.get(otherPeerId), {
|
|
1940
|
-
type: 'peer-disconnected',
|
|
1941
|
-
data: {
|
|
1942
|
-
peerId,
|
|
1943
|
-
isHub
|
|
1944
|
-
},
|
|
1945
|
-
networkName: peerInfo.networkName,
|
|
1946
|
-
fromPeerId: 'system',
|
|
1947
|
-
targetPeerId: otherPeerId,
|
|
1948
|
-
timestamp: Date.now()
|
|
1949
|
-
});
|
|
1950
|
-
});
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
/**
|
|
1956
|
-
* Remove peer from server (backwards compatibility)
|
|
1957
|
-
*/
|
|
1958
|
-
removePeer(peerId) {
|
|
1959
|
-
this.cleanupPeer(peerId);
|
|
1960
|
-
}
|
|
1961
|
-
|
|
1962
|
-
/**
|
|
1963
|
-
* Send message to specific connection
|
|
1964
|
-
*/
|
|
1965
|
-
sendToConnection(connection, message) {
|
|
1966
|
-
if (connection.readyState === connection.OPEN) {
|
|
1967
|
-
try {
|
|
1968
|
-
connection.send(JSON.stringify(message));
|
|
1969
|
-
return true;
|
|
1970
|
-
} catch (error) {
|
|
1971
|
-
console.error('โ Failed to send message:', error);
|
|
1972
|
-
return false;
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
return false;
|
|
1976
|
-
}
|
|
1977
|
-
|
|
1978
|
-
/**
|
|
1979
|
-
* Broadcast message to all peers except the sender
|
|
1980
|
-
*/
|
|
1981
|
-
broadcastToOthers(senderPeerId, message) {
|
|
1982
|
-
let sentCount = 0;
|
|
1983
|
-
for (const [peerId, connection] of this.connections) {
|
|
1984
|
-
if (peerId !== senderPeerId) {
|
|
1985
|
-
if (this.sendToConnection(connection, {
|
|
1986
|
-
...message,
|
|
1987
|
-
targetPeerId: peerId
|
|
1988
|
-
})) {
|
|
1989
|
-
sentCount++;
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
if (this.verboseLogging) {
|
|
1994
|
-
console.log(`๐ก Broadcast to ${sentCount} peers`);
|
|
1995
|
-
}
|
|
1996
|
-
return sentCount;
|
|
1997
|
-
}
|
|
1998
|
-
|
|
1999
|
-
/**
|
|
2000
|
-
* Broadcast message to closest peers in same network
|
|
2001
|
-
*/
|
|
2002
|
-
broadcastToClosestPeers(fromPeerId, message, maxPeers = 5) {
|
|
2003
|
-
const peerInfo = this.peerData.get(fromPeerId);
|
|
2004
|
-
const networkName = peerInfo?.networkName || 'global';
|
|
2005
|
-
const activePeers = this.getActivePeers(fromPeerId, networkName);
|
|
2006
|
-
const closestPeers = this.findClosestPeers(fromPeerId, activePeers, maxPeers);
|
|
2007
|
-
|
|
2008
|
-
if (this.verboseLogging) {
|
|
2009
|
-
console.log(`Broadcasting from ${fromPeerId.substring(0, 8)}... to ${closestPeers.length} closest peers in network: ${networkName}`);
|
|
2010
|
-
}
|
|
2011
|
-
|
|
2012
|
-
closestPeers.forEach(peerId => {
|
|
2013
|
-
this.sendToConnection(this.connections.get(peerId), message);
|
|
2014
|
-
});
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
/**
|
|
2018
|
-
* Start cleanup timer
|
|
2019
|
-
*/
|
|
2020
|
-
startCleanupTimer() {
|
|
2021
|
-
this.cleanupTimer = setInterval(() => {
|
|
2022
|
-
this.performCleanup();
|
|
2023
|
-
}, this.cleanupInterval);
|
|
2024
|
-
}
|
|
2025
|
-
|
|
2026
|
-
/**
|
|
2027
|
-
* Perform cleanup of inactive connections
|
|
2028
|
-
*/
|
|
2029
|
-
performCleanup() {
|
|
2030
|
-
const totalConnections = this.connections.size;
|
|
2031
|
-
|
|
2032
|
-
// Clean up all networks
|
|
2033
|
-
for (const [networkName] of this.networkPeers) {
|
|
2034
|
-
this.getActivePeers(null, networkName); // This will clean up stale connections
|
|
2035
|
-
}
|
|
2036
|
-
|
|
2037
|
-
const cleanedUp = totalConnections - this.connections.size;
|
|
2038
|
-
|
|
2039
|
-
if (cleanedUp > 0) {
|
|
2040
|
-
console.log(`๐งน Periodic cleanup: removed ${cleanedUp} stale connections, ${this.connections.size} active across ${this.networkPeers.size} networks`);
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
// Clean up old relayed message records
|
|
2044
|
-
const now = Date.now();
|
|
2045
|
-
let relayRecordsRemoved = 0;
|
|
2046
|
-
for (const [messageId, timestamp] of this.recentlyRelayedMessages) {
|
|
2047
|
-
if (now - timestamp > this.relayedMessageTTL) {
|
|
2048
|
-
this.recentlyRelayedMessages.delete(messageId);
|
|
2049
|
-
relayRecordsRemoved++;
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
|
-
if (relayRecordsRemoved > 0 && this.verboseLogging) {
|
|
2054
|
-
console.log(`๐งน Cleaned up ${relayRecordsRemoved} old relay records`);
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
|
|
2058
|
-
/**
|
|
2059
|
-
* Get server statistics
|
|
2060
|
-
*/
|
|
2061
|
-
getStats() {
|
|
2062
|
-
const bootstrapStats = {
|
|
2063
|
-
total: this.bootstrapConnections.size,
|
|
2064
|
-
connected: 0
|
|
2065
|
-
};
|
|
2066
|
-
|
|
2067
|
-
for (const [, info] of this.bootstrapConnections) {
|
|
2068
|
-
if (info.connected) {
|
|
2069
|
-
bootstrapStats.connected++;
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
|
|
2073
|
-
return {
|
|
2074
|
-
isRunning: this.isRunning,
|
|
2075
|
-
isHub: this.isHub,
|
|
2076
|
-
hubPeerId: this.hubPeerId,
|
|
2077
|
-
hubMeshNamespace: this.hubMeshNamespace,
|
|
2078
|
-
connections: this.connections.size,
|
|
2079
|
-
peers: this.peerData.size,
|
|
2080
|
-
hubs: this.hubs.size,
|
|
2081
|
-
networks: this.networkPeers.size,
|
|
2082
|
-
bootstrapHubs: bootstrapStats,
|
|
2083
|
-
maxConnections: this.maxConnections,
|
|
2084
|
-
uptime: this.isRunning && this.startTime ? Date.now() - this.startTime : 0,
|
|
2085
|
-
host: this.host,
|
|
2086
|
-
port: this.port
|
|
2087
|
-
};
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
/**
|
|
2091
|
-
* Get hub statistics
|
|
2092
|
-
*/
|
|
2093
|
-
getHubStats() {
|
|
2094
|
-
const connectedHubs = this.getConnectedHubs();
|
|
2095
|
-
const bootstrapHubsInfo = [];
|
|
2096
|
-
|
|
2097
|
-
for (const [uri, info] of this.bootstrapConnections) {
|
|
2098
|
-
bootstrapHubsInfo.push({
|
|
2099
|
-
uri,
|
|
2100
|
-
connected: info.connected,
|
|
2101
|
-
lastAttempt: info.lastAttempt,
|
|
2102
|
-
attemptNumber: info.attemptNumber
|
|
2103
|
-
});
|
|
2104
|
-
}
|
|
2105
|
-
|
|
2106
|
-
return {
|
|
2107
|
-
totalHubs: this.hubs.size,
|
|
2108
|
-
connectedHubs: connectedHubs.length,
|
|
2109
|
-
hubs: connectedHubs,
|
|
2110
|
-
bootstrapHubs: bootstrapHubsInfo
|
|
2111
|
-
};
|
|
2112
|
-
}
|
|
2113
|
-
|
|
2114
|
-
/**
|
|
2115
|
-
* Get list of connected peers
|
|
2116
|
-
*/
|
|
2117
|
-
getPeers() {
|
|
2118
|
-
return Array.from(this.peerData.values());
|
|
2119
|
-
}
|
|
2120
|
-
|
|
2121
|
-
/**
|
|
2122
|
-
* Get the current hub mesh namespace
|
|
2123
|
-
*/
|
|
2124
|
-
getHubMeshNamespace() {
|
|
2125
|
-
return this.hubMeshNamespace;
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
/**
|
|
2129
|
-
* Set the hub mesh namespace (only when server is not running)
|
|
2130
|
-
*/
|
|
2131
|
-
setHubMeshNamespace(namespace) {
|
|
2132
|
-
if (this.isRunning) {
|
|
2133
|
-
throw new Error('Cannot change hub mesh namespace while server is running. Stop the server first.');
|
|
2134
|
-
}
|
|
2135
|
-
|
|
2136
|
-
if (typeof namespace !== 'string' || namespace.trim().length === 0) {
|
|
2137
|
-
throw new Error('Hub mesh namespace must be a non-empty string');
|
|
2138
|
-
}
|
|
2139
|
-
|
|
2140
|
-
this.hubMeshNamespace = namespace.trim();
|
|
2141
|
-
console.log(`๐ Hub mesh namespace set to: ${this.hubMeshNamespace}`);
|
|
2142
|
-
return this.hubMeshNamespace;
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
|
-
|
|
2146
|
-
// For backwards compatibility and standalone usage
|
|
2147
|
-
export default PeerPigeonServer;
|