@ozdao/martyrs 0.2.475 → 0.2.477
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/{Media-sGk7Bp9b.mjs → Media-CecrG6g6.mjs} +1 -1
- package/dist/{Media-_vz04tII.js → Media-DmnrxIEI.js} +1 -1
- package/dist/_virtual/alignment-pattern.cjs +5 -0
- package/dist/_virtual/alignment-pattern.cjs.map +1 -0
- package/dist/_virtual/alignment-pattern.js +5 -0
- package/dist/_virtual/alignment-pattern.js.map +1 -0
- package/dist/_virtual/browser.cjs +8 -0
- package/dist/_virtual/browser.cjs.map +1 -0
- package/dist/_virtual/browser.js +8 -0
- package/dist/_virtual/browser.js.map +1 -0
- package/dist/_virtual/browser2.cjs +5 -0
- package/dist/_virtual/browser2.cjs.map +1 -0
- package/dist/_virtual/browser2.js +5 -0
- package/dist/_virtual/browser2.js.map +1 -0
- package/dist/_virtual/canvas.cjs +5 -0
- package/dist/_virtual/canvas.cjs.map +1 -0
- package/dist/_virtual/canvas.js +5 -0
- package/dist/_virtual/canvas.js.map +1 -0
- package/dist/_virtual/dijkstra.cjs +5 -0
- package/dist/_virtual/dijkstra.cjs.map +1 -0
- package/dist/_virtual/dijkstra.js +5 -0
- package/dist/_virtual/dijkstra.js.map +1 -0
- package/dist/_virtual/error-correction-code.cjs +5 -0
- package/dist/_virtual/error-correction-code.cjs.map +1 -0
- package/dist/_virtual/error-correction-code.js +5 -0
- package/dist/_virtual/error-correction-code.js.map +1 -0
- package/dist/_virtual/error-correction-level.cjs +5 -0
- package/dist/_virtual/error-correction-level.cjs.map +1 -0
- package/dist/_virtual/error-correction-level.js +5 -0
- package/dist/_virtual/error-correction-level.js.map +1 -0
- package/dist/_virtual/finder-pattern.cjs +5 -0
- package/dist/_virtual/finder-pattern.cjs.map +1 -0
- package/dist/_virtual/finder-pattern.js +5 -0
- package/dist/_virtual/finder-pattern.js.map +1 -0
- package/dist/_virtual/format-info.cjs +5 -0
- package/dist/_virtual/format-info.cjs.map +1 -0
- package/dist/_virtual/format-info.js +5 -0
- package/dist/_virtual/format-info.js.map +1 -0
- package/dist/_virtual/galois-field.cjs +5 -0
- package/dist/_virtual/galois-field.cjs.map +1 -0
- package/dist/_virtual/galois-field.js +5 -0
- package/dist/_virtual/galois-field.js.map +1 -0
- package/dist/_virtual/mask-pattern.cjs +5 -0
- package/dist/_virtual/mask-pattern.cjs.map +1 -0
- package/dist/_virtual/mask-pattern.js +5 -0
- package/dist/_virtual/mask-pattern.js.map +1 -0
- package/dist/_virtual/mode.cjs +5 -0
- package/dist/_virtual/mode.cjs.map +1 -0
- package/dist/_virtual/mode.js +5 -0
- package/dist/_virtual/mode.js.map +1 -0
- package/dist/_virtual/polynomial.cjs +5 -0
- package/dist/_virtual/polynomial.cjs.map +1 -0
- package/dist/_virtual/polynomial.js +5 -0
- package/dist/_virtual/polynomial.js.map +1 -0
- package/dist/_virtual/qrcode.cjs +5 -0
- package/dist/_virtual/qrcode.cjs.map +1 -0
- package/dist/_virtual/qrcode.js +5 -0
- package/dist/_virtual/qrcode.js.map +1 -0
- package/dist/_virtual/regex.cjs +5 -0
- package/dist/_virtual/regex.cjs.map +1 -0
- package/dist/_virtual/regex.js +5 -0
- package/dist/_virtual/regex.js.map +1 -0
- package/dist/_virtual/segments.cjs +5 -0
- package/dist/_virtual/segments.cjs.map +1 -0
- package/dist/_virtual/segments.js +5 -0
- package/dist/_virtual/segments.js.map +1 -0
- package/dist/_virtual/svg-tag.cjs +5 -0
- package/dist/_virtual/svg-tag.cjs.map +1 -0
- package/dist/_virtual/svg-tag.js +5 -0
- package/dist/_virtual/svg-tag.js.map +1 -0
- package/dist/_virtual/utils.cjs +5 -0
- package/dist/_virtual/utils.cjs.map +1 -0
- package/dist/_virtual/utils.js +5 -0
- package/dist/_virtual/utils.js.map +1 -0
- package/dist/_virtual/utils2.cjs +5 -0
- package/dist/_virtual/utils2.cjs.map +1 -0
- package/dist/_virtual/utils2.js +5 -0
- package/dist/_virtual/utils2.js.map +1 -0
- package/dist/_virtual/version-check.cjs +5 -0
- package/dist/_virtual/version-check.cjs.map +1 -0
- package/dist/_virtual/version-check.js +5 -0
- package/dist/_virtual/version-check.js.map +1 -0
- package/dist/_virtual/version.cjs +5 -0
- package/dist/_virtual/version.cjs.map +1 -0
- package/dist/_virtual/version.js +5 -0
- package/dist/_virtual/version.js.map +1 -0
- package/dist/globals.server.js +264 -55
- package/dist/globals.server.mjs +264 -55
- package/dist/{main-CqMtW7Hq.mjs → main-DmznvhMM.mjs} +267 -266
- package/dist/main-DxWqDgs1.js +11 -0
- package/dist/martyrs/node_modules/.pnpm/bignumber.js@9.2.1/node_modules/bignumber.js/bignumber.cjs +1336 -0
- package/dist/martyrs/node_modules/.pnpm/bignumber.js@9.2.1/node_modules/bignumber.js/bignumber.cjs.map +1 -0
- package/dist/martyrs/node_modules/.pnpm/bignumber.js@9.2.1/node_modules/bignumber.js/bignumber.js +1336 -0
- package/dist/martyrs/node_modules/.pnpm/bignumber.js@9.2.1/node_modules/bignumber.js/bignumber.js.map +1 -0
- package/dist/martyrs/src/components/Button/Button.vue2.cjs +5 -3
- package/dist/martyrs/src/components/Button/Button.vue2.cjs.map +1 -1
- package/dist/martyrs/src/components/Button/Button.vue2.js +6 -4
- package/dist/martyrs/src/components/Button/Button.vue2.js.map +1 -1
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue2.cjs → Dropdown.vue.cjs} +2 -2
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue2.js.map → Dropdown.vue.cjs.map} +1 -1
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue2.js → Dropdown.vue.js} +2 -2
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue.js.map +1 -0
- package/dist/martyrs/src/components/EmptyState/EmptyState.vue.cjs +3 -3
- package/dist/martyrs/src/components/EmptyState/EmptyState.vue.js +3 -3
- package/dist/martyrs/src/components/Feed/Feed.vue.cjs +2 -2
- package/dist/martyrs/src/components/Feed/Feed.vue.js +2 -2
- package/dist/martyrs/src/components/FieldBig/FieldBig.vue.cjs +3 -2
- package/dist/martyrs/src/components/FieldBig/FieldBig.vue.cjs.map +1 -1
- package/dist/martyrs/src/components/FieldBig/FieldBig.vue.js +3 -2
- package/dist/martyrs/src/components/FieldBig/FieldBig.vue.js.map +1 -1
- package/dist/martyrs/src/components/Loader/{Loader.vue.cjs → Loader.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Loader/Loader.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Loader/{Loader.vue.js → Loader.vue2.js} +2 -2
- package/dist/martyrs/src/components/Loader/{Loader.vue.cjs.map → Loader.vue2.js.map} +1 -1
- package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue2.cjs +1 -1
- package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue2.js +1 -1
- package/dist/martyrs/src/components/Popup/{Popup.vue.cjs → Popup.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Popup/Popup.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Popup/{Popup.vue.js → Popup.vue2.js} +2 -2
- package/dist/martyrs/src/components/Popup/{Popup.vue.cjs.map → Popup.vue2.js.map} +1 -1
- package/dist/martyrs/src/components/Select/Select.vue.cjs +10 -12
- package/dist/martyrs/src/components/Select/Select.vue.cjs.map +1 -1
- package/dist/martyrs/src/components/Select/Select.vue.js +10 -12
- package/dist/martyrs/src/components/Select/Select.vue.js.map +1 -1
- package/dist/martyrs/src/components/Slider/Slider.native.vue.cjs +1 -1
- package/dist/martyrs/src/components/Slider/Slider.native.vue.js +1 -1
- package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.cjs +1 -1
- package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/views/components/layouts/Auth.vue.cjs +1 -1
- package/dist/martyrs/src/modules/auth/views/components/layouts/Auth.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.cjs +2 -2
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js +2 -2
- package/dist/martyrs/src/modules/auth/views/router/users.cjs +14 -0
- package/dist/martyrs/src/modules/auth/views/router/users.cjs.map +1 -1
- package/dist/martyrs/src/modules/auth/views/router/users.js +14 -0
- package/dist/martyrs/src/modules/auth/views/router/users.js.map +1 -1
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.cjs +5 -5
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.js +5 -5
- package/dist/martyrs/src/modules/community/components/blocks/CardBlogpost.vue.js.map +1 -1
- package/dist/martyrs/src/modules/community/components/layouts/Community.vue.cjs +5 -5
- package/dist/martyrs/src/modules/community/components/layouts/Community.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/community/components/layouts/Community.vue.js +5 -5
- package/dist/martyrs/src/modules/community/components/layouts/Community.vue.js.map +1 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.cjs +2 -2
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.js +2 -2
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.cjs +3 -3
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js +3 -3
- package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js.map +1 -1
- package/dist/martyrs/src/modules/community/components/sections/HotPosts.vue.cjs +2 -2
- package/dist/martyrs/src/modules/community/components/sections/HotPosts.vue.js +2 -2
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.cjs +3 -3
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js +3 -3
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js.map +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEventTickets.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEventTickets.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/Events.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/pages/Events.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/sections/EventsHot.vue.cjs +2 -2
- package/dist/martyrs/src/modules/events/components/sections/EventsHot.vue.js +2 -2
- package/dist/martyrs/src/modules/events/components/sections/Feed.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/sections/Feed.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/sections/List.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/sections/List.vue.js +1 -1
- package/dist/martyrs/src/modules/gallery/components/pages/Gallery.vue.cjs +1 -1
- package/dist/martyrs/src/modules/gallery/components/pages/Gallery.vue.js +1 -1
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.cjs +90 -2
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.js +90 -2
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.cjs +32 -25
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js +32 -25
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.cjs +2 -2
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.js +2 -2
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs +2 -2
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js +2 -2
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.cjs +3 -3
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.js +3 -3
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/plugins/AlertDialog.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/plugins/AlertDialog.vue.js +1 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeatures.vue.cjs +13 -16
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeatures.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeatures.vue.js +13 -16
- package/dist/martyrs/src/modules/landing/components/sections/SectionFeatures.vue.js.map +1 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionMobileApp.vue.cjs +32 -35
- package/dist/martyrs/src/modules/landing/components/sections/SectionMobileApp.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/landing/components/sections/SectionMobileApp.vue.js +32 -35
- package/dist/martyrs/src/modules/landing/components/sections/SectionMobileApp.vue.js.map +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/layouts/Marketplace.vue.cjs +2 -2
- package/dist/martyrs/src/modules/marketplace/views/components/layouts/Marketplace.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/layouts/Marketplace.vue.js +2 -2
- package/dist/martyrs/src/modules/marketplace/views/components/layouts/Marketplace.vue.js.map +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.cjs +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.js +1 -1
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.cjs +5 -3
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.js +5 -3
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/AskToLogin.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/AskToLogin.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/AskToLogin.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/AskToLogin.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs +2 -2
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/pages/DepartmentEdit.vue.cjs +2 -2
- package/dist/martyrs/src/modules/organizations/components/pages/DepartmentEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/DetailsTabSection.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/DetailsTabSection.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.cjs +2 -2
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.js +2 -2
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/partials/SidebarPages.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/partials/SidebarPages.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/blocks/Images360.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/blocks/Images360.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/blocks/ImagesThumbnails.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/blocks/ImagesThumbnails.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.cjs +2 -2
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js +2 -2
- package/dist/martyrs/src/modules/products/components/pages/EditLeftover.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/EditLeftover.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductRecommmendation.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductRecommmendation.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/sections/EditProductInfo.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/sections/EditProductInfo.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/sections/PopularProducts.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/sections/PopularProducts.vue.js +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/RentsEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/RentsEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/reports/components/sections/FormReport.vue.cjs +1 -1
- package/dist/martyrs/src/modules/reports/components/sections/FormReport.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
- package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.cjs +1 -2
- package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.js +1 -2
- package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.js.map +1 -1
- package/dist/martyrs/src/modules/spots/components/sections/WorktimeEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/spots/components/sections/WorktimeEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardBalanceReplenished.vue.cjs +43 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardBalanceReplenished.vue.cjs.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardBalanceReplenished.vue.js +43 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardBalanceReplenished.vue.js.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardDeposit.vue.cjs +47 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardDeposit.vue.cjs.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardDeposit.vue.js +47 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CardDeposit.vue.js.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CashDeposit.vue.cjs +29 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CashDeposit.vue.cjs.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CashDeposit.vue.js +29 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CashDeposit.vue.js.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.cjs +89 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.cjs.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.js +89 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.js.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDepositProcessing.vue.cjs +135 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDepositProcessing.vue.cjs.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDepositProcessing.vue.js +135 -0
- package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDepositProcessing.vue.js.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.cjs +242 -0
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.cjs.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.js +242 -0
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.js.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/localization/wallet.json.cjs +9 -0
- package/dist/martyrs/src/modules/wallet/views/localization/wallet.json.cjs.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/localization/wallet.json.js +9 -0
- package/dist/martyrs/src/modules/wallet/views/localization/wallet.json.js.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/store/wallet.store.cjs +135 -0
- package/dist/martyrs/src/modules/wallet/views/store/wallet.store.cjs.map +1 -0
- package/dist/martyrs/src/modules/wallet/views/store/wallet.store.js +135 -0
- package/dist/martyrs/src/modules/wallet/views/store/wallet.store.js.map +1 -0
- package/dist/martyrs.cjs.js +1 -1
- package/dist/martyrs.css +1 -1
- package/dist/martyrs.es.js +1 -1
- package/dist/node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.cjs +106 -0
- package/dist/node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.cjs.map +1 -0
- package/dist/node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js +106 -0
- package/dist/node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.cjs +79 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js +79 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.cjs +14 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js +14 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.cjs +43 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js +43 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.cjs +85 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js +85 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.cjs +40 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js +40 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.cjs +34 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js +34 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.cjs +36 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js +36 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.cjs +367 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js +367 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.cjs +52 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js +52 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.cjs +25 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js +25 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.cjs +24 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js +24 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.cjs +38 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js +38 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.cjs +46 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js +46 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.cjs +149 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js +149 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.cjs +90 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js +90 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.cjs +41 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js +41 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.cjs +44 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js +44 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.cjs +279 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js +279 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.cjs +38 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js +38 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.cjs +33 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js +33 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.cjs +201 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js +201 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.cjs +84 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js +84 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.cjs +14 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js +14 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.cjs +107 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js +107 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.cjs +61 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js +61 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.cjs +64 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js +64 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.cjs +87 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.cjs.map +1 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js +87 -0
- package/dist/node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js.map +1 -0
- package/dist/style.css +26 -21
- package/package.json +1 -1
- package/src/components/Button/Button.vue +1 -1
- package/src/components/EmptyState/EmptyState.vue +3 -3
- package/src/components/FieldBig/FieldBig.vue +2 -2
- package/src/components/Select/Select.vue +4 -7
- package/src/modules/auth/views/router/users.js +11 -11
- package/src/modules/community/components/blocks/CardBlogpost.vue +5 -5
- package/src/modules/community/components/layouts/Community.vue +5 -4
- package/src/modules/community/components/pages/CreateBlogPost.vue +2 -2
- package/src/modules/events/components/pages/EditEvent.vue +1 -1
- package/src/modules/globals/controllers/classes/globals.websocket.js +336 -71
- package/src/modules/globals/controllers/classes/globals.websocket.ws.js +124 -0
- package/src/modules/globals/controllers/policies/globals.policies.js +1 -0
- package/src/modules/globals/views/classes/globals.websocket.js +121 -5
- package/src/modules/globals/views/classes/globals.websocket.ws.js +212 -0
- package/src/modules/globals/views/components/blocks/CardHeader.vue +11 -9
- package/src/modules/globals/views/components/partials/Header.vue +1 -1
- package/src/modules/globals/views/components/partials/Navigation.vue +1 -1
- package/src/modules/icons/entities/IconFile.vue +14 -0
- package/src/modules/icons/navigation/IconAttach.vue +14 -0
- package/src/modules/icons/navigation/IconDoubleCheck.vue +31 -0
- package/src/modules/icons/navigation/IconSend.vue +17 -0
- package/src/modules/landing/components/sections/SectionFeatures.vue +1 -1
- package/src/modules/landing/components/sections/SectionMobileApp.vue +4 -6
- package/src/modules/marketplace/views/components/layouts/Marketplace.vue +1 -3
- package/src/modules/notifications/components/elements/NotificationBadge.vue +4 -4
- package/src/modules/orders/components/pages/OrderCreate.vue +1 -1
- package/src/modules/orders/components/sections/AskToLogin.vue +2 -1
- package/src/modules/organizations/components/sections/Unit.vue +3 -3
- package/src/modules/spots/components/pages/SpotEdit.vue +0 -1
- package/src/modules/wallet/views/components/pages/Wallet.vue +10 -7
- package/src/styles/reset.scss +1 -1
- package/src/styles/typography.scss +23 -3
- package/dist/main-CsGkbSyK.js +0 -11
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue2.cjs.map +0 -1
- package/dist/martyrs/src/components/Loader/Loader.vue.js.map +0 -1
- package/dist/martyrs/src/components/Popup/Popup.vue.js.map +0 -1
|
@@ -14,12 +14,16 @@ class GlobalWebSocket {
|
|
|
14
14
|
this.userId = null;
|
|
15
15
|
this.connectPromise = null;
|
|
16
16
|
this.subscribedModules = /* @__PURE__ */ new Set();
|
|
17
|
+
this.rpcCallbacks = /* @__PURE__ */ new Map();
|
|
18
|
+
this.rpcTimeout = 3e4;
|
|
19
|
+
this.rpcIdCounter = 0;
|
|
17
20
|
}
|
|
18
21
|
initialize(options = {}) {
|
|
19
22
|
this.maxReconnectAttempts = options.maxReconnectAttempts || this.maxReconnectAttempts;
|
|
20
23
|
this.reconnectDelay = options.reconnectDelay || this.reconnectDelay;
|
|
21
24
|
this.baseUrl = options.wsUrl || this._getDefaultWsUrl();
|
|
22
25
|
this.pingIntervalTime = options.pingInterval || this.pingIntervalTime;
|
|
26
|
+
this.rpcTimeout = options.rpcTimeout || this.rpcTimeout;
|
|
23
27
|
}
|
|
24
28
|
_getDefaultWsUrl() {
|
|
25
29
|
if (typeof window === "undefined") return "/api/ws";
|
|
@@ -34,10 +38,12 @@ class GlobalWebSocket {
|
|
|
34
38
|
if (this.isConnected && ((_a = this.socket) == null ? void 0 : _a.readyState) === WebSocket.OPEN) {
|
|
35
39
|
return Promise.resolve(this.socket);
|
|
36
40
|
}
|
|
41
|
+
if (this.connectPromise) {
|
|
42
|
+
return this.connectPromise;
|
|
43
|
+
}
|
|
37
44
|
this.connectPromise = new Promise((resolve, reject) => {
|
|
38
45
|
this.disconnect();
|
|
39
|
-
|
|
40
|
-
this.socket = new WebSocket(wsUrl);
|
|
46
|
+
this.socket = new WebSocket(this.baseUrl);
|
|
41
47
|
this.socket.onopen = () => {
|
|
42
48
|
this._handleOpen();
|
|
43
49
|
resolve(this.socket);
|
|
@@ -74,8 +80,13 @@ class GlobalWebSocket {
|
|
|
74
80
|
clearInterval(this.pingInterval);
|
|
75
81
|
this.pingInterval = null;
|
|
76
82
|
}
|
|
83
|
+
for (const [id, { reject }] of this.rpcCallbacks.entries()) {
|
|
84
|
+
reject(new Error("WebSocket disconnected"));
|
|
85
|
+
this.rpcCallbacks.delete(id);
|
|
86
|
+
}
|
|
77
87
|
this.isConnected = false;
|
|
78
88
|
this.userId = null;
|
|
89
|
+
this.subscribedModules.clear();
|
|
79
90
|
}
|
|
80
91
|
async send(data) {
|
|
81
92
|
if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {
|
|
@@ -91,6 +102,51 @@ class GlobalWebSocket {
|
|
|
91
102
|
return false;
|
|
92
103
|
}
|
|
93
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Выполняет RPC вызов на сервере
|
|
107
|
+
* @param {string} module - Имя модуля
|
|
108
|
+
* @param {string} method - Имя метода
|
|
109
|
+
* @param {object} params - Параметры метода
|
|
110
|
+
* @param {object} [options] - Опции вызова
|
|
111
|
+
* @param {number} [options.timeout] - Таймаут в миллисекундах
|
|
112
|
+
* @returns {Promise<any>} - Результат вызова
|
|
113
|
+
*/
|
|
114
|
+
rpc(module2, method, params = {}, options = {}) {
|
|
115
|
+
var _a;
|
|
116
|
+
if (!this.isConnected || ((_a = this.socket) == null ? void 0 : _a.readyState) !== WebSocket.OPEN) {
|
|
117
|
+
return Promise.reject(new Error("WebSocket is not connected"));
|
|
118
|
+
}
|
|
119
|
+
if (!module2 || !method) {
|
|
120
|
+
return Promise.reject(new Error("Module and method are required"));
|
|
121
|
+
}
|
|
122
|
+
const id = `${++this.rpcIdCounter}`;
|
|
123
|
+
const timeout = options.timeout || this.rpcTimeout;
|
|
124
|
+
return new Promise((resolve, reject) => {
|
|
125
|
+
this.rpcCallbacks.set(id, {
|
|
126
|
+
resolve,
|
|
127
|
+
reject,
|
|
128
|
+
timeoutId: setTimeout(() => {
|
|
129
|
+
if (this.rpcCallbacks.has(id)) {
|
|
130
|
+
this.rpcCallbacks.delete(id);
|
|
131
|
+
reject(new Error(`RPC call to ${module2}.${method} timed out after ${timeout}ms`));
|
|
132
|
+
}
|
|
133
|
+
}, timeout)
|
|
134
|
+
});
|
|
135
|
+
this.send({
|
|
136
|
+
type: "rpc",
|
|
137
|
+
module: module2,
|
|
138
|
+
method,
|
|
139
|
+
params,
|
|
140
|
+
id
|
|
141
|
+
}).catch((err) => {
|
|
142
|
+
if (this.rpcCallbacks.has(id)) {
|
|
143
|
+
clearTimeout(this.rpcCallbacks.get(id).timeoutId);
|
|
144
|
+
this.rpcCallbacks.delete(id);
|
|
145
|
+
reject(err);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
94
150
|
addEventListener(eventType, callback, options = {}) {
|
|
95
151
|
const listenerId = `${options.module || "global"}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
96
152
|
if (!this.listeners[eventType]) this.listeners[eventType] = {};
|
|
@@ -119,6 +175,13 @@ class GlobalWebSocket {
|
|
|
119
175
|
this.subscribedModules.add(moduleName);
|
|
120
176
|
}
|
|
121
177
|
}
|
|
178
|
+
async unsubscribeModule(moduleName) {
|
|
179
|
+
if (!moduleName || !this.subscribedModules.has(moduleName)) return;
|
|
180
|
+
const success = await this.send({ type: "unsubscribe", module: moduleName });
|
|
181
|
+
if (success) {
|
|
182
|
+
this.subscribedModules.delete(moduleName);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
122
185
|
_resubscribeAllModules() {
|
|
123
186
|
for (const moduleName of this.subscribedModules) {
|
|
124
187
|
this.send({ type: "subscribe", module: moduleName });
|
|
@@ -137,8 +200,23 @@ class GlobalWebSocket {
|
|
|
137
200
|
this._notifyListeners("open", { isConnected: true });
|
|
138
201
|
}
|
|
139
202
|
_handleMessage(event) {
|
|
203
|
+
if (typeof event.data !== "string") {
|
|
204
|
+
console.warn("Received binary message, but only JSON is supported");
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
140
207
|
try {
|
|
141
208
|
const data = JSON.parse(event.data);
|
|
209
|
+
if (data.type === "rpc_response" && data.id && this.rpcCallbacks.has(data.id)) {
|
|
210
|
+
const { resolve, reject, timeoutId } = this.rpcCallbacks.get(data.id);
|
|
211
|
+
clearTimeout(timeoutId);
|
|
212
|
+
this.rpcCallbacks.delete(data.id);
|
|
213
|
+
if (data.error) {
|
|
214
|
+
reject(Object.assign(new Error(data.error.message), data.error));
|
|
215
|
+
} else {
|
|
216
|
+
resolve(data.result);
|
|
217
|
+
}
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
142
220
|
this._notifyListeners("message", data);
|
|
143
221
|
if (data.type) {
|
|
144
222
|
this._notifyListeners(data.type, data);
|
|
@@ -150,6 +228,11 @@ class GlobalWebSocket {
|
|
|
150
228
|
_handleError(error) {
|
|
151
229
|
console.error("WebSocket error:", error);
|
|
152
230
|
this._notifyListeners("error", { error });
|
|
231
|
+
for (const [id, { reject, timeoutId }] of this.rpcCallbacks.entries()) {
|
|
232
|
+
clearTimeout(timeoutId);
|
|
233
|
+
reject(new Error("WebSocket connection error"));
|
|
234
|
+
this.rpcCallbacks.delete(id);
|
|
235
|
+
}
|
|
153
236
|
}
|
|
154
237
|
_handleClose(event) {
|
|
155
238
|
this.isConnected = false;
|
|
@@ -157,6 +240,11 @@ class GlobalWebSocket {
|
|
|
157
240
|
clearInterval(this.pingInterval);
|
|
158
241
|
this.pingInterval = null;
|
|
159
242
|
}
|
|
243
|
+
for (const [id, { reject, timeoutId }] of this.rpcCallbacks.entries()) {
|
|
244
|
+
clearTimeout(timeoutId);
|
|
245
|
+
reject(new Error("WebSocket connection closed"));
|
|
246
|
+
this.rpcCallbacks.delete(id);
|
|
247
|
+
}
|
|
160
248
|
this._notifyListeners("close", { code: event.code, reason: event.reason });
|
|
161
249
|
if (event.code !== 1e3 && this.userId && this.reconnectAttempts < this.maxReconnectAttempts) {
|
|
162
250
|
this.reconnectAttempts++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.websocket.cjs","sources":["../../../../../../../src/modules/globals/views/classes/globals.websocket.js"],"sourcesContent":["class GlobalWebSocket {\n constructor() {\n this.socket = null;\n this.isConnected = false;\n this.reconnectAttempts = 0;\n this.maxReconnectAttempts = 5;\n this.reconnectDelay = 3000;\n this.baseUrl = null;\n this.pingInterval = null;\n this.pingIntervalTime = 30000;\n this.listeners = {};\n this.userId = null;\n this.connectPromise = null;\n this.subscribedModules = new Set(); // <--- ключевое изменение\n }\n\n initialize(options = {}) {\n this.maxReconnectAttempts = options.maxReconnectAttempts || this.maxReconnectAttempts;\n this.reconnectDelay = options.reconnectDelay || this.reconnectDelay;\n this.baseUrl = options.wsUrl || this._getDefaultWsUrl();\n this.pingIntervalTime = options.pingInterval || this.pingIntervalTime;\n }\n\n _getDefaultWsUrl() {\n if (typeof window === 'undefined') return '/api/ws';\n const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';\n const host = window.location.host;\n return `${protocol}//${host}/api/ws`;\n }\n\n connect(userId) {\n if (typeof window === 'undefined') return Promise.resolve(false);\n this.userId = userId;\n\n if (this.isConnected && this.socket?.readyState === WebSocket.OPEN) {\n return Promise.resolve(this.socket);\n }\n\n this.connectPromise = new Promise((resolve, reject) => {\n this.disconnect();\n\n const wsUrl = userId ? `${this.baseUrl}?userId=${encodeURIComponent(userId)}` : this.baseUrl;\n this.socket = new WebSocket(wsUrl);\n\n this.socket.onopen = () => {\n this._handleOpen();\n resolve(this.socket);\n };\n\n this.socket.onmessage = this._handleMessage.bind(this);\n this.socket.onerror = (err) => {\n this._handleError(err);\n reject(err);\n };\n this.socket.onclose = this._handleClose.bind(this);\n\n setTimeout(() => {\n if (!this.isConnected) {\n reject(new Error('WebSocket connection timeout'));\n }\n }, 10000);\n }).finally(() => {\n this.connectPromise = null;\n });\n\n return this.connectPromise;\n }\n\n disconnect() {\n if (typeof window === 'undefined') return;\n\n if (this.socket) {\n this.socket.onopen = null;\n this.socket.onmessage = null;\n this.socket.onerror = null;\n this.socket.onclose = null;\n if (this.socket.readyState === WebSocket.OPEN || this.socket.readyState === WebSocket.CONNECTING) {\n this.socket.close();\n }\n this.socket = null;\n }\n\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n this.isConnected = false;\n this.userId = null;\n }\n\n async send(data) {\n if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {\n console.error('Cannot send message: WebSocket is not connected');\n return false;\n }\n\n try {\n const msg = typeof data === 'string' ? data : JSON.stringify(data);\n this.socket.send(msg);\n return true;\n } catch (err) {\n console.error('Error sending message:', err);\n return false;\n }\n }\n\n addEventListener(eventType, callback, options = {}) {\n const listenerId = `${options.module || 'global'}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n if (!this.listeners[eventType]) this.listeners[eventType] = {};\n this.listeners[eventType][listenerId] = callback;\n return listenerId;\n }\n\n removeEventListener(eventType, listenerId) {\n if (this.listeners[eventType]?.[listenerId]) {\n delete this.listeners[eventType][listenerId];\n }\n }\n\n removeModuleListeners(moduleName) {\n Object.keys(this.listeners).forEach(eventType => {\n Object.keys(this.listeners[eventType]).forEach(listenerId => {\n if (listenerId.startsWith(`${moduleName}_`)) {\n delete this.listeners[eventType][listenerId];\n }\n });\n });\n }\n\n async subscribeModule(moduleName) {\n if (!moduleName || this.subscribedModules.has(moduleName)) return;\n const success = await this.send({ type: 'subscribe', module: moduleName });\n if (success) {\n this.subscribedModules.add(moduleName);\n }\n }\n\n _resubscribeAllModules() {\n for (const moduleName of this.subscribedModules) {\n this.send({ type: 'subscribe', module: moduleName });\n }\n }\n\n _handleOpen() {\n this.isConnected = true;\n this.reconnectAttempts = 0;\n\n this.pingInterval = setInterval(() => {\n if (this.socket?.readyState === WebSocket.OPEN) {\n this.socket.send(JSON.stringify({ type: 'ping' }));\n }\n }, this.pingIntervalTime);\n\n this._resubscribeAllModules(); // <--- ВАЖНО\n this._notifyListeners('open', { isConnected: true });\n }\n\n _handleMessage(event) {\n try {\n const data = JSON.parse(event.data);\n this._notifyListeners('message', data);\n if (data.type) {\n this._notifyListeners(data.type, data);\n }\n } catch (err) {\n console.error('WebSocket message error:', err);\n }\n }\n\n _handleError(error) {\n console.error('WebSocket error:', error);\n this._notifyListeners('error', { error });\n }\n\n _handleClose(event) {\n this.isConnected = false;\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n this._notifyListeners('close', { code: event.code, reason: event.reason });\n\n if (event.code !== 1000 && this.userId && this.reconnectAttempts < this.maxReconnectAttempts) {\n this.reconnectAttempts++;\n const delay = this.reconnectDelay * this.reconnectAttempts;\n setTimeout(() => {\n this.connect(this.userId).catch(err => {\n console.error('Reconnection failed:', err);\n });\n }, delay);\n }\n }\n\n _notifyListeners(eventType, data) {\n Object.values(this.listeners[eventType] || {}).forEach(fn => {\n try {\n fn(data);\n } catch (err) {\n console.error(`Listener for ${eventType} failed:`, err);\n }\n });\n }\n\n isSocketConnected() {\n return this.isConnected && this.socket?.readyState === WebSocket.OPEN;\n }\n}\n\nconst globalWebSocket = new GlobalWebSocket();\nexport default globalWebSocket;\n"],"names":[],"mappings":";;AAAA,MAAM,gBAAgB;AAAA,EACpB,cAAc;AACZ,SAAK,SAAS;AACd,SAAK,cAAc;AACnB,SAAK,oBAAoB;AACzB,SAAK,uBAAuB;AAC5B,SAAK,iBAAiB;AACtB,SAAK,UAAU;AACf,SAAK,eAAe;AACpB,SAAK,mBAAmB;AACxB,SAAK,YAAY,CAAE;AACnB,SAAK,SAAS;AACd,SAAK,iBAAiB;AACtB,SAAK,oBAAoB,oBAAI;EACjC;AAAA,EAEE,WAAW,UAAU,IAAI;AACvB,SAAK,uBAAuB,QAAQ,wBAAwB,KAAK;AACjE,SAAK,iBAAiB,QAAQ,kBAAkB,KAAK;AACrD,SAAK,UAAU,QAAQ,SAAS,KAAK,iBAAkB;AACvD,SAAK,mBAAmB,QAAQ,gBAAgB,KAAK;AAAA,EACzD;AAAA,EAEE,mBAAmB;AACjB,QAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,UAAM,WAAW,OAAO,SAAS,aAAa,WAAW,SAAS;AAClE,UAAM,OAAO,OAAO,SAAS;AAC7B,WAAO,GAAG,QAAQ,KAAK,IAAI;AAAA,EAC/B;AAAA,EAEE,QAAQ,QAAQ;;AACd,QAAI,OAAO,WAAW,YAAa,QAAO,QAAQ,QAAQ,KAAK;AAC/D,SAAK,SAAS;AAEd,QAAI,KAAK,iBAAe,UAAK,WAAL,mBAAa,gBAAe,UAAU,MAAM;AAClE,aAAO,QAAQ,QAAQ,KAAK,MAAM;AAAA,IACxC;AAEI,SAAK,iBAAiB,IAAI,QAAQ,CAAC,SAAS,WAAW;AACrD,WAAK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AA,MACF,GAAE,KAAK;AAAA,IACd;AAAA,EACA;AAAA,EAEE,iBAAiB,WAAW,MAAM;AAChC,WAAO,OAAO,KAAK,UAAU,SAAS,KAAK,CAAE,CAAA,EAAE,QAAQ,QAAM;AAC3D,UAAI;AACF,WAAG,IAAI;AAAA,MACR,SAAQ,KAAK;AACZ,gBAAQ,MAAM,gBAAgB,SAAS,YAAY,GAAG;AAAA,MAC9D;AAAA,IACA,CAAK;AAAA,EACL;AAAA,EAEE,oBAAoB;;AAClB,WAAO,KAAK,iBAAe,UAAK,WAAL,mBAAa,gBAAe,UAAU;AAAA,EACrE;AACA;AAEK,MAAC,kBAAkB,IAAI,gBAAe;;"}
|
|
1
|
+
{"version":3,"file":"globals.websocket.cjs","sources":["../../../../../../../src/modules/globals/views/classes/globals.websocket.js"],"sourcesContent":["class GlobalWebSocket {\n constructor() {\n this.socket = null;\n this.isConnected = false;\n this.reconnectAttempts = 0;\n this.maxReconnectAttempts = 5;\n this.reconnectDelay = 3000;\n this.baseUrl = null;\n this.pingInterval = null;\n this.pingIntervalTime = 30000;\n this.listeners = {};\n this.userId = null;\n this.connectPromise = null;\n this.subscribedModules = new Set();\n \n // RPC-специфичные свойства\n this.rpcCallbacks = new Map();\n this.rpcTimeout = 30000; // 30 секунд таймаут по умолчанию\n this.rpcIdCounter = 0;\n }\n\n initialize(options = {}) {\n this.maxReconnectAttempts = options.maxReconnectAttempts || this.maxReconnectAttempts;\n this.reconnectDelay = options.reconnectDelay || this.reconnectDelay;\n this.baseUrl = options.wsUrl || this._getDefaultWsUrl();\n this.pingIntervalTime = options.pingInterval || this.pingIntervalTime;\n this.rpcTimeout = options.rpcTimeout || this.rpcTimeout;\n }\n\n _getDefaultWsUrl() {\n if (typeof window === 'undefined') return '/api/ws';\n const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';\n const host = window.location.host;\n return `${protocol}//${host}/api/ws`;\n }\n\n connect(userId) {\n if (typeof window === 'undefined') return Promise.resolve(false);\n this.userId = userId;\n\n // Проверяем существующее соединение\n if (this.isConnected && this.socket?.readyState === WebSocket.OPEN) {\n return Promise.resolve(this.socket);\n }\n \n // Предотвращаем создание множества промисов при параллельных вызовах\n if (this.connectPromise) {\n return this.connectPromise;\n }\n\n this.connectPromise = new Promise((resolve, reject) => {\n this.disconnect();\n\n // Используем baseUrl без параметров, так как аутентификация через cookie\n this.socket = new WebSocket(this.baseUrl);\n\n this.socket.onopen = () => {\n this._handleOpen();\n resolve(this.socket);\n };\n\n this.socket.onmessage = this._handleMessage.bind(this);\n this.socket.onerror = (err) => {\n this._handleError(err);\n reject(err);\n };\n this.socket.onclose = this._handleClose.bind(this);\n\n setTimeout(() => {\n if (!this.isConnected) {\n reject(new Error('WebSocket connection timeout'));\n }\n }, 10000);\n }).finally(() => {\n this.connectPromise = null;\n });\n\n return this.connectPromise;\n }\n\n disconnect() {\n if (typeof window === 'undefined') return;\n\n if (this.socket) {\n this.socket.onopen = null;\n this.socket.onmessage = null;\n this.socket.onerror = null;\n this.socket.onclose = null;\n if (this.socket.readyState === WebSocket.OPEN || this.socket.readyState === WebSocket.CONNECTING) {\n this.socket.close();\n }\n this.socket = null;\n }\n\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n // Отменяем все ожидающие RPC вызовы\n for (const [id, { reject }] of this.rpcCallbacks.entries()) {\n reject(new Error('WebSocket disconnected'));\n this.rpcCallbacks.delete(id);\n }\n\n this.isConnected = false;\n this.userId = null;\n this.subscribedModules.clear(); // Очищаем подписки при отключении\n }\n\n async send(data) {\n if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {\n console.error('Cannot send message: WebSocket is not connected');\n return false;\n }\n\n try {\n const msg = typeof data === 'string' ? data : JSON.stringify(data);\n this.socket.send(msg);\n return true;\n } catch (err) {\n console.error('Error sending message:', err);\n return false;\n }\n }\n\n /**\n * Выполняет RPC вызов на сервере\n * @param {string} module - Имя модуля\n * @param {string} method - Имя метода\n * @param {object} params - Параметры метода\n * @param {object} [options] - Опции вызова\n * @param {number} [options.timeout] - Таймаут в миллисекундах\n * @returns {Promise<any>} - Результат вызова\n */\n rpc(module, method, params = {}, options = {}) {\n if (!this.isConnected || this.socket?.readyState !== WebSocket.OPEN) {\n return Promise.reject(new Error('WebSocket is not connected'));\n }\n \n if (!module || !method) {\n return Promise.reject(new Error('Module and method are required'));\n }\n \n // Генерируем уникальный ID для вызова\n const id = `${++this.rpcIdCounter}`;\n const timeout = options.timeout || this.rpcTimeout;\n \n return new Promise((resolve, reject) => {\n // Записываем информацию о вызове для последующей обработки ответа\n this.rpcCallbacks.set(id, {\n resolve,\n reject,\n timeoutId: setTimeout(() => {\n if (this.rpcCallbacks.has(id)) {\n this.rpcCallbacks.delete(id);\n reject(new Error(`RPC call to ${module}.${method} timed out after ${timeout}ms`));\n }\n }, timeout)\n });\n \n // Отправляем RPC запрос\n this.send({\n type: 'rpc',\n module,\n method,\n params,\n id\n }).catch(err => {\n if (this.rpcCallbacks.has(id)) {\n clearTimeout(this.rpcCallbacks.get(id).timeoutId);\n this.rpcCallbacks.delete(id);\n reject(err);\n }\n });\n });\n }\n\n addEventListener(eventType, callback, options = {}) {\n const listenerId = `${options.module || 'global'}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n if (!this.listeners[eventType]) this.listeners[eventType] = {};\n this.listeners[eventType][listenerId] = callback;\n return listenerId;\n }\n\n removeEventListener(eventType, listenerId) {\n if (this.listeners[eventType]?.[listenerId]) {\n delete this.listeners[eventType][listenerId];\n }\n }\n\n removeModuleListeners(moduleName) {\n Object.keys(this.listeners).forEach(eventType => {\n Object.keys(this.listeners[eventType]).forEach(listenerId => {\n if (listenerId.startsWith(`${moduleName}_`)) {\n delete this.listeners[eventType][listenerId];\n }\n });\n });\n }\n\n async subscribeModule(moduleName) {\n if (!moduleName || this.subscribedModules.has(moduleName)) return;\n const success = await this.send({ type: 'subscribe', module: moduleName });\n if (success) {\n this.subscribedModules.add(moduleName);\n }\n }\n\n async unsubscribeModule(moduleName) {\n if (!moduleName || !this.subscribedModules.has(moduleName)) return;\n const success = await this.send({ type: 'unsubscribe', module: moduleName });\n if (success) {\n this.subscribedModules.delete(moduleName);\n }\n }\n\n _resubscribeAllModules() {\n for (const moduleName of this.subscribedModules) {\n this.send({ type: 'subscribe', module: moduleName });\n }\n }\n\n _handleOpen() {\n this.isConnected = true;\n this.reconnectAttempts = 0;\n\n this.pingInterval = setInterval(() => {\n if (this.socket?.readyState === WebSocket.OPEN) {\n this.socket.send(JSON.stringify({ type: 'ping' }));\n }\n }, this.pingIntervalTime);\n\n this._resubscribeAllModules();\n this._notifyListeners('open', { isConnected: true });\n }\n\n _handleMessage(event) {\n // Проверка на типы сообщений - пропускаем бинарные сообщения\n if (typeof event.data !== 'string') {\n console.warn('Received binary message, but only JSON is supported');\n return;\n }\n \n try {\n const data = JSON.parse(event.data);\n \n // Обрабатываем ответы на RPC вызовы\n if (data.type === 'rpc_response' && data.id && this.rpcCallbacks.has(data.id)) {\n const { resolve, reject, timeoutId } = this.rpcCallbacks.get(data.id);\n clearTimeout(timeoutId);\n this.rpcCallbacks.delete(data.id);\n \n if (data.error) {\n reject(Object.assign(new Error(data.error.message), data.error));\n } else {\n resolve(data.result);\n }\n \n return;\n }\n \n // Обрабатываем обычные сообщения\n this._notifyListeners('message', data);\n if (data.type) {\n this._notifyListeners(data.type, data);\n }\n } catch (err) {\n console.error('WebSocket message error:', err);\n }\n }\n\n _handleError(error) {\n console.error('WebSocket error:', error);\n this._notifyListeners('error', { error });\n \n // Отменяем все RPC вызовы с ошибкой соединения\n for (const [id, { reject, timeoutId }] of this.rpcCallbacks.entries()) {\n clearTimeout(timeoutId);\n reject(new Error('WebSocket connection error'));\n this.rpcCallbacks.delete(id);\n }\n }\n\n _handleClose(event) {\n this.isConnected = false;\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n // Отменяем все RPC вызовы при закрытии соединения\n for (const [id, { reject, timeoutId }] of this.rpcCallbacks.entries()) {\n clearTimeout(timeoutId);\n reject(new Error('WebSocket connection closed'));\n this.rpcCallbacks.delete(id);\n }\n\n this._notifyListeners('close', { code: event.code, reason: event.reason });\n\n if (event.code !== 1000 && this.userId && this.reconnectAttempts < this.maxReconnectAttempts) {\n this.reconnectAttempts++;\n const delay = this.reconnectDelay * this.reconnectAttempts;\n setTimeout(() => {\n this.connect(this.userId).catch(err => {\n console.error('Reconnection failed:', err);\n });\n }, delay);\n }\n }\n\n _notifyListeners(eventType, data) {\n Object.values(this.listeners[eventType] || {}).forEach(fn => {\n try {\n fn(data);\n } catch (err) {\n console.error(`Listener for ${eventType} failed:`, err);\n }\n });\n }\n\n isSocketConnected() {\n return this.isConnected && this.socket?.readyState === WebSocket.OPEN;\n }\n}\n\nconst globalWebSocket = new GlobalWebSocket();\nexport default globalWebSocket;"],"names":["module"],"mappings":";;AAAA,MAAM,gBAAgB;AAAA,EACpB,cAAc;AACZ,SAAK,SAAS;AACd,SAAK,cAAc;AACnB,SAAK,oBAAoB;AACzB,SAAK,uBAAuB;AAC5B,SAAK,iBAAiB;AACtB,SAAK,UAAU;AACf,SAAK,eAAe;AACpB,SAAK,mBAAmB;AACxB,SAAK,YAAY,CAAE;AACnB,SAAK,SAAS;AACd,SAAK,iBAAiB;AACtB,SAAK,oBAAoB,oBAAI,IAAK;AAGlC,SAAK,eAAe,oBAAI,IAAK;AAC7B,SAAK,aAAa;AAClB,SAAK,eAAe;AAAA,EACxB;AAAA,EAEE,WAAW,UAAU,IAAI;AACvB,SAAK,uBAAuB,QAAQ,wBAAwB,KAAK;AACjE,SAAK,iBAAiB,QAAQ,kBAAkB,KAAK;AACrD,SAAK,UAAU,QAAQ,SAAS,KAAK,iBAAkB;AACvD,SAAK,mBAAmB,QAAQ,gBAAgB,KAAK;AACrD,SAAK,aAAa,QAAQ,cAAc,KAAK;AAAA,EACjD;AAAA,EAEE,mBAAmB;AACjB,QAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,UAAM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OAAQ,KAAK,UAAU,KAAK,oBAAoB,KAAK,sBAAsB;AAC5F,WAAK;AACL,YAAM,QAAQ,KAAK,iBAAiB,KAAK;AACzC,iBAAW,MAAM;AACf,aAAK,QAAQ,KAAK,MAAM,EAAE,MAAM,SAAO;AACrC,kBAAQ,MAAM,wBAAwB,GAAG;AAAA,QACnD,CAAS;AAAA,MACF,GAAE,KAAK;AAAA,IACd;AAAA,EACA;AAAA,EAEE,iBAAiB,WAAW,MAAM;AAChC,WAAO,OAAO,KAAK,UAAU,SAAS,KAAK,CAAE,CAAA,EAAE,QAAQ,QAAM;AAC3D,UAAI;AACF,WAAG,IAAI;AAAA,MACR,SAAQ,KAAK;AACZ,gBAAQ,MAAM,gBAAgB,SAAS,YAAY,GAAG;AAAA,MAC9D;AAAA,IACA,CAAK;AAAA,EACL;AAAA,EAEE,oBAAoB;;AAClB,WAAO,KAAK,iBAAe,UAAK,WAAL,mBAAa,gBAAe,UAAU;AAAA,EACrE;AACA;AAEK,MAAC,kBAAkB,IAAI,gBAAe;;"}
|
|
@@ -12,12 +12,16 @@ class GlobalWebSocket {
|
|
|
12
12
|
this.userId = null;
|
|
13
13
|
this.connectPromise = null;
|
|
14
14
|
this.subscribedModules = /* @__PURE__ */ new Set();
|
|
15
|
+
this.rpcCallbacks = /* @__PURE__ */ new Map();
|
|
16
|
+
this.rpcTimeout = 3e4;
|
|
17
|
+
this.rpcIdCounter = 0;
|
|
15
18
|
}
|
|
16
19
|
initialize(options = {}) {
|
|
17
20
|
this.maxReconnectAttempts = options.maxReconnectAttempts || this.maxReconnectAttempts;
|
|
18
21
|
this.reconnectDelay = options.reconnectDelay || this.reconnectDelay;
|
|
19
22
|
this.baseUrl = options.wsUrl || this._getDefaultWsUrl();
|
|
20
23
|
this.pingIntervalTime = options.pingInterval || this.pingIntervalTime;
|
|
24
|
+
this.rpcTimeout = options.rpcTimeout || this.rpcTimeout;
|
|
21
25
|
}
|
|
22
26
|
_getDefaultWsUrl() {
|
|
23
27
|
if (typeof window === "undefined") return "/api/ws";
|
|
@@ -32,10 +36,12 @@ class GlobalWebSocket {
|
|
|
32
36
|
if (this.isConnected && ((_a = this.socket) == null ? void 0 : _a.readyState) === WebSocket.OPEN) {
|
|
33
37
|
return Promise.resolve(this.socket);
|
|
34
38
|
}
|
|
39
|
+
if (this.connectPromise) {
|
|
40
|
+
return this.connectPromise;
|
|
41
|
+
}
|
|
35
42
|
this.connectPromise = new Promise((resolve, reject) => {
|
|
36
43
|
this.disconnect();
|
|
37
|
-
|
|
38
|
-
this.socket = new WebSocket(wsUrl);
|
|
44
|
+
this.socket = new WebSocket(this.baseUrl);
|
|
39
45
|
this.socket.onopen = () => {
|
|
40
46
|
this._handleOpen();
|
|
41
47
|
resolve(this.socket);
|
|
@@ -72,8 +78,13 @@ class GlobalWebSocket {
|
|
|
72
78
|
clearInterval(this.pingInterval);
|
|
73
79
|
this.pingInterval = null;
|
|
74
80
|
}
|
|
81
|
+
for (const [id, { reject }] of this.rpcCallbacks.entries()) {
|
|
82
|
+
reject(new Error("WebSocket disconnected"));
|
|
83
|
+
this.rpcCallbacks.delete(id);
|
|
84
|
+
}
|
|
75
85
|
this.isConnected = false;
|
|
76
86
|
this.userId = null;
|
|
87
|
+
this.subscribedModules.clear();
|
|
77
88
|
}
|
|
78
89
|
async send(data) {
|
|
79
90
|
if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {
|
|
@@ -89,6 +100,51 @@ class GlobalWebSocket {
|
|
|
89
100
|
return false;
|
|
90
101
|
}
|
|
91
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Выполняет RPC вызов на сервере
|
|
105
|
+
* @param {string} module - Имя модуля
|
|
106
|
+
* @param {string} method - Имя метода
|
|
107
|
+
* @param {object} params - Параметры метода
|
|
108
|
+
* @param {object} [options] - Опции вызова
|
|
109
|
+
* @param {number} [options.timeout] - Таймаут в миллисекундах
|
|
110
|
+
* @returns {Promise<any>} - Результат вызова
|
|
111
|
+
*/
|
|
112
|
+
rpc(module, method, params = {}, options = {}) {
|
|
113
|
+
var _a;
|
|
114
|
+
if (!this.isConnected || ((_a = this.socket) == null ? void 0 : _a.readyState) !== WebSocket.OPEN) {
|
|
115
|
+
return Promise.reject(new Error("WebSocket is not connected"));
|
|
116
|
+
}
|
|
117
|
+
if (!module || !method) {
|
|
118
|
+
return Promise.reject(new Error("Module and method are required"));
|
|
119
|
+
}
|
|
120
|
+
const id = `${++this.rpcIdCounter}`;
|
|
121
|
+
const timeout = options.timeout || this.rpcTimeout;
|
|
122
|
+
return new Promise((resolve, reject) => {
|
|
123
|
+
this.rpcCallbacks.set(id, {
|
|
124
|
+
resolve,
|
|
125
|
+
reject,
|
|
126
|
+
timeoutId: setTimeout(() => {
|
|
127
|
+
if (this.rpcCallbacks.has(id)) {
|
|
128
|
+
this.rpcCallbacks.delete(id);
|
|
129
|
+
reject(new Error(`RPC call to ${module}.${method} timed out after ${timeout}ms`));
|
|
130
|
+
}
|
|
131
|
+
}, timeout)
|
|
132
|
+
});
|
|
133
|
+
this.send({
|
|
134
|
+
type: "rpc",
|
|
135
|
+
module,
|
|
136
|
+
method,
|
|
137
|
+
params,
|
|
138
|
+
id
|
|
139
|
+
}).catch((err) => {
|
|
140
|
+
if (this.rpcCallbacks.has(id)) {
|
|
141
|
+
clearTimeout(this.rpcCallbacks.get(id).timeoutId);
|
|
142
|
+
this.rpcCallbacks.delete(id);
|
|
143
|
+
reject(err);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
92
148
|
addEventListener(eventType, callback, options = {}) {
|
|
93
149
|
const listenerId = `${options.module || "global"}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
94
150
|
if (!this.listeners[eventType]) this.listeners[eventType] = {};
|
|
@@ -117,6 +173,13 @@ class GlobalWebSocket {
|
|
|
117
173
|
this.subscribedModules.add(moduleName);
|
|
118
174
|
}
|
|
119
175
|
}
|
|
176
|
+
async unsubscribeModule(moduleName) {
|
|
177
|
+
if (!moduleName || !this.subscribedModules.has(moduleName)) return;
|
|
178
|
+
const success = await this.send({ type: "unsubscribe", module: moduleName });
|
|
179
|
+
if (success) {
|
|
180
|
+
this.subscribedModules.delete(moduleName);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
120
183
|
_resubscribeAllModules() {
|
|
121
184
|
for (const moduleName of this.subscribedModules) {
|
|
122
185
|
this.send({ type: "subscribe", module: moduleName });
|
|
@@ -135,8 +198,23 @@ class GlobalWebSocket {
|
|
|
135
198
|
this._notifyListeners("open", { isConnected: true });
|
|
136
199
|
}
|
|
137
200
|
_handleMessage(event) {
|
|
201
|
+
if (typeof event.data !== "string") {
|
|
202
|
+
console.warn("Received binary message, but only JSON is supported");
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
138
205
|
try {
|
|
139
206
|
const data = JSON.parse(event.data);
|
|
207
|
+
if (data.type === "rpc_response" && data.id && this.rpcCallbacks.has(data.id)) {
|
|
208
|
+
const { resolve, reject, timeoutId } = this.rpcCallbacks.get(data.id);
|
|
209
|
+
clearTimeout(timeoutId);
|
|
210
|
+
this.rpcCallbacks.delete(data.id);
|
|
211
|
+
if (data.error) {
|
|
212
|
+
reject(Object.assign(new Error(data.error.message), data.error));
|
|
213
|
+
} else {
|
|
214
|
+
resolve(data.result);
|
|
215
|
+
}
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
140
218
|
this._notifyListeners("message", data);
|
|
141
219
|
if (data.type) {
|
|
142
220
|
this._notifyListeners(data.type, data);
|
|
@@ -148,6 +226,11 @@ class GlobalWebSocket {
|
|
|
148
226
|
_handleError(error) {
|
|
149
227
|
console.error("WebSocket error:", error);
|
|
150
228
|
this._notifyListeners("error", { error });
|
|
229
|
+
for (const [id, { reject, timeoutId }] of this.rpcCallbacks.entries()) {
|
|
230
|
+
clearTimeout(timeoutId);
|
|
231
|
+
reject(new Error("WebSocket connection error"));
|
|
232
|
+
this.rpcCallbacks.delete(id);
|
|
233
|
+
}
|
|
151
234
|
}
|
|
152
235
|
_handleClose(event) {
|
|
153
236
|
this.isConnected = false;
|
|
@@ -155,6 +238,11 @@ class GlobalWebSocket {
|
|
|
155
238
|
clearInterval(this.pingInterval);
|
|
156
239
|
this.pingInterval = null;
|
|
157
240
|
}
|
|
241
|
+
for (const [id, { reject, timeoutId }] of this.rpcCallbacks.entries()) {
|
|
242
|
+
clearTimeout(timeoutId);
|
|
243
|
+
reject(new Error("WebSocket connection closed"));
|
|
244
|
+
this.rpcCallbacks.delete(id);
|
|
245
|
+
}
|
|
158
246
|
this._notifyListeners("close", { code: event.code, reason: event.reason });
|
|
159
247
|
if (event.code !== 1e3 && this.userId && this.reconnectAttempts < this.maxReconnectAttempts) {
|
|
160
248
|
this.reconnectAttempts++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.websocket.js","sources":["../../../../../../../src/modules/globals/views/classes/globals.websocket.js"],"sourcesContent":["class GlobalWebSocket {\n constructor() {\n this.socket = null;\n this.isConnected = false;\n this.reconnectAttempts = 0;\n this.maxReconnectAttempts = 5;\n this.reconnectDelay = 3000;\n this.baseUrl = null;\n this.pingInterval = null;\n this.pingIntervalTime = 30000;\n this.listeners = {};\n this.userId = null;\n this.connectPromise = null;\n this.subscribedModules = new Set(); // <--- ключевое изменение\n }\n\n initialize(options = {}) {\n this.maxReconnectAttempts = options.maxReconnectAttempts || this.maxReconnectAttempts;\n this.reconnectDelay = options.reconnectDelay || this.reconnectDelay;\n this.baseUrl = options.wsUrl || this._getDefaultWsUrl();\n this.pingIntervalTime = options.pingInterval || this.pingIntervalTime;\n }\n\n _getDefaultWsUrl() {\n if (typeof window === 'undefined') return '/api/ws';\n const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';\n const host = window.location.host;\n return `${protocol}//${host}/api/ws`;\n }\n\n connect(userId) {\n if (typeof window === 'undefined') return Promise.resolve(false);\n this.userId = userId;\n\n if (this.isConnected && this.socket?.readyState === WebSocket.OPEN) {\n return Promise.resolve(this.socket);\n }\n\n this.connectPromise = new Promise((resolve, reject) => {\n this.disconnect();\n\n const wsUrl = userId ? `${this.baseUrl}?userId=${encodeURIComponent(userId)}` : this.baseUrl;\n this.socket = new WebSocket(wsUrl);\n\n this.socket.onopen = () => {\n this._handleOpen();\n resolve(this.socket);\n };\n\n this.socket.onmessage = this._handleMessage.bind(this);\n this.socket.onerror = (err) => {\n this._handleError(err);\n reject(err);\n };\n this.socket.onclose = this._handleClose.bind(this);\n\n setTimeout(() => {\n if (!this.isConnected) {\n reject(new Error('WebSocket connection timeout'));\n }\n }, 10000);\n }).finally(() => {\n this.connectPromise = null;\n });\n\n return this.connectPromise;\n }\n\n disconnect() {\n if (typeof window === 'undefined') return;\n\n if (this.socket) {\n this.socket.onopen = null;\n this.socket.onmessage = null;\n this.socket.onerror = null;\n this.socket.onclose = null;\n if (this.socket.readyState === WebSocket.OPEN || this.socket.readyState === WebSocket.CONNECTING) {\n this.socket.close();\n }\n this.socket = null;\n }\n\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n this.isConnected = false;\n this.userId = null;\n }\n\n async send(data) {\n if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {\n console.error('Cannot send message: WebSocket is not connected');\n return false;\n }\n\n try {\n const msg = typeof data === 'string' ? data : JSON.stringify(data);\n this.socket.send(msg);\n return true;\n } catch (err) {\n console.error('Error sending message:', err);\n return false;\n }\n }\n\n addEventListener(eventType, callback, options = {}) {\n const listenerId = `${options.module || 'global'}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n if (!this.listeners[eventType]) this.listeners[eventType] = {};\n this.listeners[eventType][listenerId] = callback;\n return listenerId;\n }\n\n removeEventListener(eventType, listenerId) {\n if (this.listeners[eventType]?.[listenerId]) {\n delete this.listeners[eventType][listenerId];\n }\n }\n\n removeModuleListeners(moduleName) {\n Object.keys(this.listeners).forEach(eventType => {\n Object.keys(this.listeners[eventType]).forEach(listenerId => {\n if (listenerId.startsWith(`${moduleName}_`)) {\n delete this.listeners[eventType][listenerId];\n }\n });\n });\n }\n\n async subscribeModule(moduleName) {\n if (!moduleName || this.subscribedModules.has(moduleName)) return;\n const success = await this.send({ type: 'subscribe', module: moduleName });\n if (success) {\n this.subscribedModules.add(moduleName);\n }\n }\n\n _resubscribeAllModules() {\n for (const moduleName of this.subscribedModules) {\n this.send({ type: 'subscribe', module: moduleName });\n }\n }\n\n _handleOpen() {\n this.isConnected = true;\n this.reconnectAttempts = 0;\n\n this.pingInterval = setInterval(() => {\n if (this.socket?.readyState === WebSocket.OPEN) {\n this.socket.send(JSON.stringify({ type: 'ping' }));\n }\n }, this.pingIntervalTime);\n\n this._resubscribeAllModules(); // <--- ВАЖНО\n this._notifyListeners('open', { isConnected: true });\n }\n\n _handleMessage(event) {\n try {\n const data = JSON.parse(event.data);\n this._notifyListeners('message', data);\n if (data.type) {\n this._notifyListeners(data.type, data);\n }\n } catch (err) {\n console.error('WebSocket message error:', err);\n }\n }\n\n _handleError(error) {\n console.error('WebSocket error:', error);\n this._notifyListeners('error', { error });\n }\n\n _handleClose(event) {\n this.isConnected = false;\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n this._notifyListeners('close', { code: event.code, reason: event.reason });\n\n if (event.code !== 1000 && this.userId && this.reconnectAttempts < this.maxReconnectAttempts) {\n this.reconnectAttempts++;\n const delay = this.reconnectDelay * this.reconnectAttempts;\n setTimeout(() => {\n this.connect(this.userId).catch(err => {\n console.error('Reconnection failed:', err);\n });\n }, delay);\n }\n }\n\n _notifyListeners(eventType, data) {\n Object.values(this.listeners[eventType] || {}).forEach(fn => {\n try {\n fn(data);\n } catch (err) {\n console.error(`Listener for ${eventType} failed:`, err);\n }\n });\n }\n\n isSocketConnected() {\n return this.isConnected && this.socket?.readyState === WebSocket.OPEN;\n }\n}\n\nconst globalWebSocket = new GlobalWebSocket();\nexport default globalWebSocket;\n"],"names":[],"mappings":"AAAA,MAAM,gBAAgB;AAAA,EACpB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ACA,CAAK;AAAA,EACL;AAAA,EAEE,oBAAoB;AA7MtB;AA8MI,WAAO,KAAK,iBAAe,UAAK,WAAL,mBAAa,gBAAe,UAAU;AAAA,EACrE;AACA;AAEK,MAAC,kBAAkB,IAAI,gBAAe;"}
|
|
1
|
+
{"version":3,"file":"globals.websocket.js","sources":["../../../../../../../src/modules/globals/views/classes/globals.websocket.js"],"sourcesContent":["class GlobalWebSocket {\n constructor() {\n this.socket = null;\n this.isConnected = false;\n this.reconnectAttempts = 0;\n this.maxReconnectAttempts = 5;\n this.reconnectDelay = 3000;\n this.baseUrl = null;\n this.pingInterval = null;\n this.pingIntervalTime = 30000;\n this.listeners = {};\n this.userId = null;\n this.connectPromise = null;\n this.subscribedModules = new Set();\n \n // RPC-специфичные свойства\n this.rpcCallbacks = new Map();\n this.rpcTimeout = 30000; // 30 секунд таймаут по умолчанию\n this.rpcIdCounter = 0;\n }\n\n initialize(options = {}) {\n this.maxReconnectAttempts = options.maxReconnectAttempts || this.maxReconnectAttempts;\n this.reconnectDelay = options.reconnectDelay || this.reconnectDelay;\n this.baseUrl = options.wsUrl || this._getDefaultWsUrl();\n this.pingIntervalTime = options.pingInterval || this.pingIntervalTime;\n this.rpcTimeout = options.rpcTimeout || this.rpcTimeout;\n }\n\n _getDefaultWsUrl() {\n if (typeof window === 'undefined') return '/api/ws';\n const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';\n const host = window.location.host;\n return `${protocol}//${host}/api/ws`;\n }\n\n connect(userId) {\n if (typeof window === 'undefined') return Promise.resolve(false);\n this.userId = userId;\n\n // Проверяем существующее соединение\n if (this.isConnected && this.socket?.readyState === WebSocket.OPEN) {\n return Promise.resolve(this.socket);\n }\n \n // Предотвращаем создание множества промисов при параллельных вызовах\n if (this.connectPromise) {\n return this.connectPromise;\n }\n\n this.connectPromise = new Promise((resolve, reject) => {\n this.disconnect();\n\n // Используем baseUrl без параметров, так как аутентификация через cookie\n this.socket = new WebSocket(this.baseUrl);\n\n this.socket.onopen = () => {\n this._handleOpen();\n resolve(this.socket);\n };\n\n this.socket.onmessage = this._handleMessage.bind(this);\n this.socket.onerror = (err) => {\n this._handleError(err);\n reject(err);\n };\n this.socket.onclose = this._handleClose.bind(this);\n\n setTimeout(() => {\n if (!this.isConnected) {\n reject(new Error('WebSocket connection timeout'));\n }\n }, 10000);\n }).finally(() => {\n this.connectPromise = null;\n });\n\n return this.connectPromise;\n }\n\n disconnect() {\n if (typeof window === 'undefined') return;\n\n if (this.socket) {\n this.socket.onopen = null;\n this.socket.onmessage = null;\n this.socket.onerror = null;\n this.socket.onclose = null;\n if (this.socket.readyState === WebSocket.OPEN || this.socket.readyState === WebSocket.CONNECTING) {\n this.socket.close();\n }\n this.socket = null;\n }\n\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n // Отменяем все ожидающие RPC вызовы\n for (const [id, { reject }] of this.rpcCallbacks.entries()) {\n reject(new Error('WebSocket disconnected'));\n this.rpcCallbacks.delete(id);\n }\n\n this.isConnected = false;\n this.userId = null;\n this.subscribedModules.clear(); // Очищаем подписки при отключении\n }\n\n async send(data) {\n if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {\n console.error('Cannot send message: WebSocket is not connected');\n return false;\n }\n\n try {\n const msg = typeof data === 'string' ? data : JSON.stringify(data);\n this.socket.send(msg);\n return true;\n } catch (err) {\n console.error('Error sending message:', err);\n return false;\n }\n }\n\n /**\n * Выполняет RPC вызов на сервере\n * @param {string} module - Имя модуля\n * @param {string} method - Имя метода\n * @param {object} params - Параметры метода\n * @param {object} [options] - Опции вызова\n * @param {number} [options.timeout] - Таймаут в миллисекундах\n * @returns {Promise<any>} - Результат вызова\n */\n rpc(module, method, params = {}, options = {}) {\n if (!this.isConnected || this.socket?.readyState !== WebSocket.OPEN) {\n return Promise.reject(new Error('WebSocket is not connected'));\n }\n \n if (!module || !method) {\n return Promise.reject(new Error('Module and method are required'));\n }\n \n // Генерируем уникальный ID для вызова\n const id = `${++this.rpcIdCounter}`;\n const timeout = options.timeout || this.rpcTimeout;\n \n return new Promise((resolve, reject) => {\n // Записываем информацию о вызове для последующей обработки ответа\n this.rpcCallbacks.set(id, {\n resolve,\n reject,\n timeoutId: setTimeout(() => {\n if (this.rpcCallbacks.has(id)) {\n this.rpcCallbacks.delete(id);\n reject(new Error(`RPC call to ${module}.${method} timed out after ${timeout}ms`));\n }\n }, timeout)\n });\n \n // Отправляем RPC запрос\n this.send({\n type: 'rpc',\n module,\n method,\n params,\n id\n }).catch(err => {\n if (this.rpcCallbacks.has(id)) {\n clearTimeout(this.rpcCallbacks.get(id).timeoutId);\n this.rpcCallbacks.delete(id);\n reject(err);\n }\n });\n });\n }\n\n addEventListener(eventType, callback, options = {}) {\n const listenerId = `${options.module || 'global'}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n if (!this.listeners[eventType]) this.listeners[eventType] = {};\n this.listeners[eventType][listenerId] = callback;\n return listenerId;\n }\n\n removeEventListener(eventType, listenerId) {\n if (this.listeners[eventType]?.[listenerId]) {\n delete this.listeners[eventType][listenerId];\n }\n }\n\n removeModuleListeners(moduleName) {\n Object.keys(this.listeners).forEach(eventType => {\n Object.keys(this.listeners[eventType]).forEach(listenerId => {\n if (listenerId.startsWith(`${moduleName}_`)) {\n delete this.listeners[eventType][listenerId];\n }\n });\n });\n }\n\n async subscribeModule(moduleName) {\n if (!moduleName || this.subscribedModules.has(moduleName)) return;\n const success = await this.send({ type: 'subscribe', module: moduleName });\n if (success) {\n this.subscribedModules.add(moduleName);\n }\n }\n\n async unsubscribeModule(moduleName) {\n if (!moduleName || !this.subscribedModules.has(moduleName)) return;\n const success = await this.send({ type: 'unsubscribe', module: moduleName });\n if (success) {\n this.subscribedModules.delete(moduleName);\n }\n }\n\n _resubscribeAllModules() {\n for (const moduleName of this.subscribedModules) {\n this.send({ type: 'subscribe', module: moduleName });\n }\n }\n\n _handleOpen() {\n this.isConnected = true;\n this.reconnectAttempts = 0;\n\n this.pingInterval = setInterval(() => {\n if (this.socket?.readyState === WebSocket.OPEN) {\n this.socket.send(JSON.stringify({ type: 'ping' }));\n }\n }, this.pingIntervalTime);\n\n this._resubscribeAllModules();\n this._notifyListeners('open', { isConnected: true });\n }\n\n _handleMessage(event) {\n // Проверка на типы сообщений - пропускаем бинарные сообщения\n if (typeof event.data !== 'string') {\n console.warn('Received binary message, but only JSON is supported');\n return;\n }\n \n try {\n const data = JSON.parse(event.data);\n \n // Обрабатываем ответы на RPC вызовы\n if (data.type === 'rpc_response' && data.id && this.rpcCallbacks.has(data.id)) {\n const { resolve, reject, timeoutId } = this.rpcCallbacks.get(data.id);\n clearTimeout(timeoutId);\n this.rpcCallbacks.delete(data.id);\n \n if (data.error) {\n reject(Object.assign(new Error(data.error.message), data.error));\n } else {\n resolve(data.result);\n }\n \n return;\n }\n \n // Обрабатываем обычные сообщения\n this._notifyListeners('message', data);\n if (data.type) {\n this._notifyListeners(data.type, data);\n }\n } catch (err) {\n console.error('WebSocket message error:', err);\n }\n }\n\n _handleError(error) {\n console.error('WebSocket error:', error);\n this._notifyListeners('error', { error });\n \n // Отменяем все RPC вызовы с ошибкой соединения\n for (const [id, { reject, timeoutId }] of this.rpcCallbacks.entries()) {\n clearTimeout(timeoutId);\n reject(new Error('WebSocket connection error'));\n this.rpcCallbacks.delete(id);\n }\n }\n\n _handleClose(event) {\n this.isConnected = false;\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n // Отменяем все RPC вызовы при закрытии соединения\n for (const [id, { reject, timeoutId }] of this.rpcCallbacks.entries()) {\n clearTimeout(timeoutId);\n reject(new Error('WebSocket connection closed'));\n this.rpcCallbacks.delete(id);\n }\n\n this._notifyListeners('close', { code: event.code, reason: event.reason });\n\n if (event.code !== 1000 && this.userId && this.reconnectAttempts < this.maxReconnectAttempts) {\n this.reconnectAttempts++;\n const delay = this.reconnectDelay * this.reconnectAttempts;\n setTimeout(() => {\n this.connect(this.userId).catch(err => {\n console.error('Reconnection failed:', err);\n });\n }, delay);\n }\n }\n\n _notifyListeners(eventType, data) {\n Object.values(this.listeners[eventType] || {}).forEach(fn => {\n try {\n fn(data);\n } catch (err) {\n console.error(`Listener for ${eventType} failed:`, err);\n }\n });\n }\n\n isSocketConnected() {\n return this.isConnected && this.socket?.readyState === WebSocket.OPEN;\n }\n}\n\nconst globalWebSocket = new GlobalWebSocket();\nexport default globalWebSocket;"],"names":[],"mappings":"AAAA,MAAM,gBAAgB;AAAA,EACpB,cAAc;AACZ,SAAK,SAAS;AACd,SAAK,cAAc;AACnB,SAAK,oBAAoB;AACzB,SAAK,uBAAuB;AAC5B,SAAK,iBAAiB;AACtB,SAAK,UAAU;AACf,SAAK,eAAe;AACpB,SAAK,mBAAmB;AACxB,SAAK,YAAY,CAAE;AACnB,SAAK,SAAS;AACd,SAAK,iBAAiB;AACtB,SAAK,oBAAoB,oBAAI,IAAK;AAGlC,SAAK,eAAe,oBAAI,IAAK;AAC7B,SAAK,aAAa;AAClB,SAAK,eAAe;AAAA,EACxB;AAAA,EAEE,WAAW,UAAU,IAAI;AACvB,SAAK,uBAAuB,QAAQ,wBAAwB,KAAK;AACjE,SAAK,iBAAiB,QAAQ,kBAAkB,KAAK;AACrD,SAAK,UAAU,QAAQ,SAAS,KAAK,iBAAkB;AACvD,SAAK,mBAAmB,QAAQ,gBAAgB,KAAK;AACrD,SAAK,aAAa,QAAQ,cAAc,KAAK;AAAA,EACjD;AAAA,EAEE,mBAAmB;AACjB,QAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,UAAM,WAAW,OAAO,SAAS,aAAa,WAAW,SAAS;AAClE,UAAM,OAAO,OAAO,SAAS;AAC7B,WAAO,GAAG,QAAQ,KAAK,IAAI;AAAA,EAC/B;AAAA,EAEE,QAAQ,QAAQ;AApClB;AAqCI,QAAI,OAAO,WAAW,YAAa,QAAO,QAAQ,QAAQ,KAAK;AAC/D,SAAK,SAAS;AAGd,QAAI,KAAK,iBAAe,UAAK,WAAL,mB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,IACd;AAAA,EACA;AAAA,EAEE,iBAAiB,WAAW,MAAM;AAChC,WAAO,OAAO,KAAK,UAAU,SAAS,KAAK,CAAE,CAAA,EAAE,QAAQ,QAAM;AAC3D,UAAI;AACF,WAAG,IAAI;AAAA,MACR,SAAQ,KAAK;AACZ,gBAAQ,MAAM,gBAAgB,SAAS,YAAY,GAAG;AAAA,MAC9D;AAAA,IACA,CAAK;AAAA,EACL;AAAA,EAEE,oBAAoB;AAjUtB;AAkUI,WAAO,KAAK,iBAAe,UAAK,WAAL,mBAAa,gBAAe,UAAU;AAAA,EACrE;AACA;AAEK,MAAC,kBAAkB,IAAI,gBAAe;"}
|
|
@@ -3,12 +3,12 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
3
3
|
const vue = require("vue");
|
|
4
4
|
const vueRouter = require("vue-router");
|
|
5
5
|
const Tooltip = require("../../../../../components/Tooltip/Tooltip.vue.cjs");
|
|
6
|
-
const Dropdown = require("../../../../../components/Dropdown/Dropdown.
|
|
6
|
+
const Dropdown = require("../../../../../components/Dropdown/Dropdown.vue.cjs");
|
|
7
7
|
const PlaceholderUserpic = require("../../../../icons/placeholders/PlaceholderUserpic.vue.cjs");
|
|
8
8
|
const PlaceholderOrganizationPic = require("../../../../icons/placeholders/PlaceholderOrganizationPic.vue.cjs");
|
|
9
9
|
const IconEllipsis = require("../../../../icons/navigation/IconEllipsis.vue.cjs");
|
|
10
10
|
const FormReport = require("../../../../reports/components/sections/FormReport.vue.cjs");
|
|
11
|
-
;/* empty css
|
|
11
|
+
;/* empty css */
|
|
12
12
|
;/* empty css */
|
|
13
13
|
require("../../../../auth/views/store/auth.cjs");
|
|
14
14
|
require("../../../../organizations/store/memberships.cjs");
|
|
@@ -22,20 +22,24 @@ const _hoisted_3 = { class: "w-100 p-medium t-nowrap flex-nowrap flex-v-center f
|
|
|
22
22
|
const _hoisted_4 = ["src"];
|
|
23
23
|
const _hoisted_5 = {
|
|
24
24
|
key: 2,
|
|
25
|
-
class: "t-
|
|
25
|
+
class: "flex flex-nowrap t-medium w-100 o-hidden pos-relative"
|
|
26
26
|
};
|
|
27
27
|
const _hoisted_6 = {
|
|
28
|
-
key:
|
|
28
|
+
key: 0,
|
|
29
29
|
class: "mn-l-micro mn-r-micro"
|
|
30
30
|
};
|
|
31
31
|
const _hoisted_7 = {
|
|
32
32
|
key: 2,
|
|
33
|
-
class: "
|
|
33
|
+
class: "mn-l-micro mn-r-micro"
|
|
34
34
|
};
|
|
35
|
-
const _hoisted_8 = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const _hoisted_8 = {
|
|
36
|
+
key: 3,
|
|
37
|
+
class: "pos-relative w-max"
|
|
38
|
+
};
|
|
39
|
+
const _hoisted_9 = { key: 4 };
|
|
40
|
+
const _hoisted_10 = { class: "d-block mn-l-auto flex-nowrap flex flex-v-center" };
|
|
41
|
+
const _hoisted_11 = { class: "bg-black flex-column flex gap-thin pd-thin radius-small" };
|
|
42
|
+
const _hoisted_12 = ["onClick"];
|
|
39
43
|
const _sfc_main = {
|
|
40
44
|
__name: "CardHeader",
|
|
41
45
|
props: [
|
|
@@ -75,7 +79,7 @@ const _sfc_main = {
|
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
return (_ctx, _cache) => {
|
|
78
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
82
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
79
83
|
const _component_router_link = vue.resolveComponent("router-link");
|
|
80
84
|
return __props.owner ? (vue.openBlock(), vue.createElementBlock("header", _hoisted_1, [
|
|
81
85
|
vue.createElementVNode("div", _hoisted_2, [
|
|
@@ -84,7 +88,7 @@ const _sfc_main = {
|
|
|
84
88
|
key: 0,
|
|
85
89
|
loading: "lazy",
|
|
86
90
|
src: (_ctx.FILE_SERVER_URL || "") + __props.owner.target.profile.photo,
|
|
87
|
-
class: "radius-medium object-fit-cover mn-r-thin i-thin",
|
|
91
|
+
class: "radius-medium flex-child-default object-fit-cover mn-r-thin i-thin",
|
|
88
92
|
onClick: _cache[0] || (_cache[0] = vue.withModifiers(($event) => _ctx.$router.push({
|
|
89
93
|
name: __props.owner.type === "user" ? "User Profile" : "Organization",
|
|
90
94
|
params: {
|
|
@@ -94,7 +98,7 @@ const _sfc_main = {
|
|
|
94
98
|
}, null, 8, _hoisted_4)) : vue.createCommentVNode("", true),
|
|
95
99
|
!((_e = (_d = __props.owner.target) == null ? void 0 : _d.profile) == null ? void 0 : _e.photo) && __props.type !== "short" ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(__props.owner.type === "user" ? PlaceholderUserpic.default : PlaceholderOrganizationPic.default), {
|
|
96
100
|
key: 1,
|
|
97
|
-
class: "radius-medium cursor-pointer mn-r-thin i-thin",
|
|
101
|
+
class: "radius-medium flex-child-default cursor-pointer mn-r-thin i-thin",
|
|
98
102
|
onClick: _cache[1] || (_cache[1] = vue.withModifiers(($event) => _ctx.$router.push({
|
|
99
103
|
name: __props.owner.type === "user" ? "User Profile" : "Organization",
|
|
100
104
|
params: {
|
|
@@ -102,7 +106,7 @@ const _sfc_main = {
|
|
|
102
106
|
}
|
|
103
107
|
}), ["stop"]))
|
|
104
108
|
})) : vue.createCommentVNode("", true),
|
|
105
|
-
__props.type !== "short" ? (vue.openBlock(), vue.createElementBlock("
|
|
109
|
+
__props.type !== "short" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5, [
|
|
106
110
|
vue.createElementVNode("span", {
|
|
107
111
|
onClick: _cache[2] || (_cache[2] = vue.withModifiers(($event) => _ctx.$router.push({
|
|
108
112
|
name: __props.owner.type === "user" ? "User Profile" : "Organization",
|
|
@@ -110,10 +114,11 @@ const _sfc_main = {
|
|
|
110
114
|
_id: __props.owner.target._id
|
|
111
115
|
}
|
|
112
116
|
}), ["stop"])),
|
|
113
|
-
class: "cursor-pointer"
|
|
117
|
+
class: "cursor-pointer w-max t-trim"
|
|
114
118
|
}, vue.toDisplayString(((_g = (_f = __props.owner.target) == null ? void 0 : _f.profile) == null ? void 0 : _g.name) || ((_h = __props.creator.target) == null ? void 0 : _h.username) || "Anonymous"), 1),
|
|
115
|
-
!__props.creator.hidden && ((_j = (_i = __props.owner.target) == null ? void 0 : _i.profile) == null ? void 0 : _j.name) !== ((_l = (_k = __props.creator.target) == null ? void 0 : _k.profile) == null ? void 0 : _l.name) ? (vue.openBlock(), vue.createElementBlock("span",
|
|
116
|
-
|
|
119
|
+
!__props.creator.hidden && ((_j = (_i = __props.owner.target) == null ? void 0 : _i.profile) == null ? void 0 : _j.name) !== ((_l = (_k = __props.creator.target) == null ? void 0 : _k.profile) == null ? void 0 : _l.name) ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_6, "·")) : vue.createCommentVNode("", true),
|
|
120
|
+
!__props.creator.hidden && ((_n = (_m = __props.owner.target) == null ? void 0 : _m.profile) == null ? void 0 : _n.name) !== ((_p = (_o = __props.creator.target) == null ? void 0 : _o.profile) == null ? void 0 : _p.name) ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
121
|
+
key: 1,
|
|
117
122
|
onClick: _cache[3] || (_cache[3] = vue.withModifiers(($event) => {
|
|
118
123
|
var _a2;
|
|
119
124
|
return _ctx.$router.push({
|
|
@@ -123,10 +128,12 @@ const _sfc_main = {
|
|
|
123
128
|
}
|
|
124
129
|
});
|
|
125
130
|
}, ["stop"])),
|
|
126
|
-
class: "cursor-pointer"
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
class: "cursor-pointer w-max t-trim"
|
|
132
|
+
}, [
|
|
133
|
+
vue.createElementVNode("div", null, "by " + vue.toDisplayString(((_r = (_q = __props.creator.target) == null ? void 0 : _q.profile) == null ? void 0 : _r.name) || ((_s = __props.creator.target) == null ? void 0 : _s.username) || "Anonymous"), 1)
|
|
134
|
+
])) : vue.createCommentVNode("", true),
|
|
135
|
+
__props.date ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_7, "·")) : vue.createCommentVNode("", true),
|
|
136
|
+
__props.date ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_8, [
|
|
130
137
|
__props.date ? (vue.openBlock(), vue.createBlock(Tooltip.default, {
|
|
131
138
|
key: 0,
|
|
132
139
|
text: _ctx.formatDate(__props.date)
|
|
@@ -137,16 +144,16 @@ const _sfc_main = {
|
|
|
137
144
|
_: 1
|
|
138
145
|
}, 8, ["text"])) : vue.createCommentVNode("", true)
|
|
139
146
|
])) : vue.createCommentVNode("", true),
|
|
140
|
-
__props.dateFormatted ? (vue.openBlock(), vue.createElementBlock("span",
|
|
147
|
+
__props.dateFormatted ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_9, " · " + vue.toDisplayString(__props.dateFormatted), 1)) : vue.createCommentVNode("", true)
|
|
141
148
|
])) : vue.createCommentVNode("", true),
|
|
142
|
-
vue.createElementVNode("div",
|
|
149
|
+
vue.createElementVNode("div", _hoisted_10, [
|
|
143
150
|
__props.members ? (vue.openBlock(), vue.createBlock(PhotoStack.default, {
|
|
144
151
|
key: 0,
|
|
145
152
|
number: __props.members,
|
|
146
153
|
photos: __props.membersPhotos
|
|
147
154
|
}, null, 8, ["number", "photos"])) : vue.createCommentVNode("", true)
|
|
148
155
|
]),
|
|
149
|
-
__props.type !== "short" && __props.user && (__props.user !== ((
|
|
156
|
+
__props.type !== "short" && __props.user && (__props.user !== ((_t = __props.creator.target) == null ? void 0 : _t._id) || __props.actions && __props.actions.length > 0) ? (vue.openBlock(), vue.createBlock(Dropdown.default, {
|
|
150
157
|
key: 3,
|
|
151
158
|
label: { component: IconEllipsis.default, class: "t-transp i-regular" },
|
|
152
159
|
align: "right",
|
|
@@ -155,7 +162,7 @@ const _sfc_main = {
|
|
|
155
162
|
default: vue.withCtx(() => {
|
|
156
163
|
var _a2;
|
|
157
164
|
return [
|
|
158
|
-
vue.createElementVNode("section",
|
|
165
|
+
vue.createElementVNode("section", _hoisted_11, [
|
|
159
166
|
__props.user !== ((_a2 = __props.creator.target) == null ? void 0 : _a2._id) ? (vue.openBlock(), vue.createBlock(FormReport.default, {
|
|
160
167
|
key: 0,
|
|
161
168
|
user: __props.user,
|
|
@@ -185,7 +192,7 @@ const _sfc_main = {
|
|
|
185
192
|
key: 1,
|
|
186
193
|
onClick: action.method,
|
|
187
194
|
class: vue.normalizeClass(action.class || "w-100 bg-black br-solid br-1px br-white-transp-20 t-white button-small button")
|
|
188
|
-
}, vue.toDisplayString(action.label), 11,
|
|
195
|
+
}, vue.toDisplayString(action.label), 11, _hoisted_12)) : vue.createCommentVNode("", true)
|
|
189
196
|
], 64);
|
|
190
197
|
}), 256)) : vue.createCommentVNode("", true)
|
|
191
198
|
])
|