@symbo.ls/sdk 3.1.2 → 3.2.6

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.
Files changed (187) hide show
  1. package/README.md +143 -2
  2. package/dist/cjs/config/environment.js +98 -30
  3. package/dist/cjs/index.js +144 -24
  4. package/dist/cjs/services/AdminService.js +351 -0
  5. package/dist/cjs/services/AuthService.js +738 -305
  6. package/dist/cjs/services/BaseService.js +158 -6
  7. package/dist/cjs/services/BranchService.js +484 -0
  8. package/dist/cjs/services/CollabService.js +743 -0
  9. package/dist/cjs/services/DnsService.js +340 -0
  10. package/dist/cjs/services/FeatureFlagService.js +175 -0
  11. package/dist/cjs/services/FileService.js +201 -0
  12. package/dist/cjs/services/IntegrationService.js +538 -0
  13. package/dist/cjs/services/MetricsService.js +62 -0
  14. package/dist/cjs/services/PaymentService.js +271 -0
  15. package/dist/cjs/services/PlanService.js +426 -0
  16. package/dist/cjs/services/ProjectService.js +1207 -0
  17. package/dist/cjs/services/PullRequestService.js +503 -0
  18. package/dist/cjs/services/ScreenshotService.js +304 -0
  19. package/dist/cjs/services/SubscriptionService.js +396 -0
  20. package/dist/cjs/services/TrackingService.js +661 -0
  21. package/dist/cjs/services/WaitlistService.js +148 -0
  22. package/dist/cjs/services/index.js +64 -16
  23. package/dist/cjs/state/RootStateManager.js +65 -0
  24. package/dist/cjs/state/rootEventBus.js +74 -0
  25. package/dist/cjs/utils/CollabClient.js +223 -0
  26. package/dist/cjs/utils/TokenManager.js +78 -30
  27. package/dist/cjs/utils/changePreprocessor.js +199 -0
  28. package/dist/cjs/utils/jsonDiff.js +145 -0
  29. package/dist/cjs/utils/ordering.js +309 -0
  30. package/dist/cjs/utils/services.js +301 -103
  31. package/dist/cjs/utils/validation.js +0 -3
  32. package/dist/esm/config/environment.js +98 -30
  33. package/dist/esm/index.js +49505 -8718
  34. package/dist/esm/services/AdminService.js +1132 -0
  35. package/dist/esm/services/AuthService.js +1493 -386
  36. package/dist/esm/services/BaseService.js +757 -6
  37. package/dist/esm/services/BranchService.js +1265 -0
  38. package/dist/esm/services/CollabService.js +26895 -0
  39. package/dist/esm/services/DnsService.js +1121 -0
  40. package/dist/esm/services/FeatureFlagService.js +956 -0
  41. package/dist/esm/services/FileService.js +982 -0
  42. package/dist/esm/services/IntegrationService.js +1319 -0
  43. package/dist/esm/services/MetricsService.js +843 -0
  44. package/dist/esm/services/PaymentService.js +1052 -0
  45. package/dist/esm/services/PlanService.js +1207 -0
  46. package/dist/esm/services/ProjectService.js +2526 -0
  47. package/dist/esm/services/PullRequestService.js +1284 -0
  48. package/dist/esm/services/ScreenshotService.js +1085 -0
  49. package/dist/esm/services/SubscriptionService.js +1177 -0
  50. package/dist/esm/services/TrackingService.js +18454 -0
  51. package/dist/esm/services/WaitlistService.js +929 -0
  52. package/dist/esm/services/index.js +49062 -8569
  53. package/dist/esm/state/RootStateManager.js +90 -0
  54. package/dist/esm/state/rootEventBus.js +56 -0
  55. package/dist/esm/utils/CollabClient.js +18889 -0
  56. package/dist/esm/utils/TokenManager.js +78 -30
  57. package/dist/esm/utils/changePreprocessor.js +542 -0
  58. package/dist/esm/utils/jsonDiff.js +7011 -0
  59. package/dist/esm/utils/ordering.js +291 -0
  60. package/dist/esm/utils/services.js +301 -103
  61. package/dist/esm/utils/validation.js +116 -50
  62. package/dist/node/config/environment.js +98 -30
  63. package/dist/node/index.js +175 -32
  64. package/dist/node/services/AdminService.js +332 -0
  65. package/dist/node/services/AuthService.js +742 -310
  66. package/dist/node/services/BaseService.js +148 -6
  67. package/dist/node/services/BranchService.js +465 -0
  68. package/dist/node/services/CollabService.js +724 -0
  69. package/dist/node/services/DnsService.js +321 -0
  70. package/dist/node/services/FeatureFlagService.js +156 -0
  71. package/dist/node/services/FileService.js +182 -0
  72. package/dist/node/services/IntegrationService.js +519 -0
  73. package/dist/node/services/MetricsService.js +43 -0
  74. package/dist/node/services/PaymentService.js +252 -0
  75. package/dist/node/services/PlanService.js +407 -0
  76. package/dist/node/services/ProjectService.js +1188 -0
  77. package/dist/node/services/PullRequestService.js +484 -0
  78. package/dist/node/services/ScreenshotService.js +285 -0
  79. package/dist/node/services/SubscriptionService.js +377 -0
  80. package/dist/node/services/TrackingService.js +632 -0
  81. package/dist/node/services/WaitlistService.js +129 -0
  82. package/dist/node/services/index.js +64 -16
  83. package/dist/node/state/RootStateManager.js +36 -0
  84. package/dist/node/state/rootEventBus.js +55 -0
  85. package/dist/node/utils/CollabClient.js +194 -0
  86. package/dist/node/utils/TokenManager.js +78 -30
  87. package/dist/node/utils/changePreprocessor.js +180 -0
  88. package/dist/node/utils/jsonDiff.js +116 -0
  89. package/dist/node/utils/ordering.js +290 -0
  90. package/dist/node/utils/services.js +301 -103
  91. package/dist/node/utils/validation.js +0 -3
  92. package/package.json +39 -21
  93. package/src/config/environment.js +99 -28
  94. package/src/index.js +181 -36
  95. package/src/services/AdminService.js +374 -0
  96. package/src/services/AuthService.js +874 -328
  97. package/src/services/BaseService.js +166 -6
  98. package/src/services/BranchService.js +536 -0
  99. package/src/services/CollabService.js +900 -0
  100. package/src/services/DnsService.js +366 -0
  101. package/src/services/FeatureFlagService.js +174 -0
  102. package/src/services/FileService.js +213 -0
  103. package/src/services/IntegrationService.js +548 -0
  104. package/src/services/MetricsService.js +40 -0
  105. package/src/services/PaymentService.js +287 -0
  106. package/src/services/PlanService.js +468 -0
  107. package/src/services/ProjectService.js +1366 -0
  108. package/src/services/PullRequestService.js +537 -0
  109. package/src/services/ScreenshotService.js +258 -0
  110. package/src/services/SubscriptionService.js +425 -0
  111. package/src/services/TrackingService.js +853 -0
  112. package/src/services/WaitlistService.js +130 -0
  113. package/src/services/index.js +80 -13
  114. package/src/services/tests/BranchService/createBranch.test.js +153 -0
  115. package/src/services/tests/BranchService/deleteBranch.test.js +173 -0
  116. package/src/services/tests/BranchService/getBranchChanges.test.js +146 -0
  117. package/src/services/tests/BranchService/listBranches.test.js +87 -0
  118. package/src/services/tests/BranchService/mergeBranch.test.js +210 -0
  119. package/src/services/tests/BranchService/publishVersion.test.js +183 -0
  120. package/src/services/tests/BranchService/renameBranch.test.js +240 -0
  121. package/src/services/tests/BranchService/resetBranch.test.js +152 -0
  122. package/src/services/tests/FeatureFlagService/adminFeatureFlags.test.js +67 -0
  123. package/src/services/tests/FeatureFlagService/getFeatureFlags.test.js +75 -0
  124. package/src/services/tests/FileService/createFileFormData.test.js +74 -0
  125. package/src/services/tests/FileService/getFileUrl.test.js +69 -0
  126. package/src/services/tests/FileService/updateProjectIcon.test.js +109 -0
  127. package/src/services/tests/FileService/uploadDocument.test.js +36 -0
  128. package/src/services/tests/FileService/uploadFile.test.js +78 -0
  129. package/src/services/tests/FileService/uploadFileWithValidation.test.js +114 -0
  130. package/src/services/tests/FileService/uploadImage.test.js +36 -0
  131. package/src/services/tests/FileService/uploadMultipleFiles.test.js +111 -0
  132. package/src/services/tests/FileService/validateFile.test.js +63 -0
  133. package/src/services/tests/PlanService/createPlan.test.js +104 -0
  134. package/src/services/tests/PlanService/createPlanWithValidation.test.js +523 -0
  135. package/src/services/tests/PlanService/deletePlan.test.js +92 -0
  136. package/src/services/tests/PlanService/getActivePlans.test.js +123 -0
  137. package/src/services/tests/PlanService/getAdminPlans.test.js +84 -0
  138. package/src/services/tests/PlanService/getPlan.test.js +50 -0
  139. package/src/services/tests/PlanService/getPlanByKey.test.js +109 -0
  140. package/src/services/tests/PlanService/getPlanWithValidation.test.js +85 -0
  141. package/src/services/tests/PlanService/getPlans.test.js +53 -0
  142. package/src/services/tests/PlanService/getPlansByPriceRange.test.js +109 -0
  143. package/src/services/tests/PlanService/getPlansWithValidation.test.js +48 -0
  144. package/src/services/tests/PlanService/initializePlans.test.js +75 -0
  145. package/src/services/tests/PlanService/updatePlan.test.js +111 -0
  146. package/src/services/tests/PlanService/updatePlanWithValidation.test.js +556 -0
  147. package/src/state/RootStateManager.js +76 -0
  148. package/src/state/rootEventBus.js +67 -0
  149. package/src/utils/CollabClient.js +248 -0
  150. package/src/utils/TokenManager.js +88 -33
  151. package/src/utils/changePreprocessor.js +239 -0
  152. package/src/utils/jsonDiff.js +144 -0
  153. package/src/utils/ordering.js +271 -0
  154. package/src/utils/services.js +326 -107
  155. package/src/utils/validation.js +0 -3
  156. package/dist/cjs/services/AIService.js +0 -155
  157. package/dist/cjs/services/BasedService.js +0 -1185
  158. package/dist/cjs/services/CoreService.js +0 -1751
  159. package/dist/cjs/services/SocketIOService.js +0 -307
  160. package/dist/cjs/services/SocketService.js +0 -161
  161. package/dist/cjs/services/SymstoryService.js +0 -571
  162. package/dist/cjs/utils/basedQuerys.js +0 -181
  163. package/dist/cjs/utils/symstoryClient.js +0 -259
  164. package/dist/esm/services/AIService.js +0 -185
  165. package/dist/esm/services/BasedService.js +0 -5278
  166. package/dist/esm/services/CoreService.js +0 -2264
  167. package/dist/esm/services/SocketIOService.js +0 -470
  168. package/dist/esm/services/SocketService.js +0 -191
  169. package/dist/esm/services/SymstoryService.js +0 -7041
  170. package/dist/esm/utils/basedQuerys.js +0 -163
  171. package/dist/esm/utils/symstoryClient.js +0 -370
  172. package/dist/node/services/AIService.js +0 -136
  173. package/dist/node/services/BasedService.js +0 -1156
  174. package/dist/node/services/CoreService.js +0 -1722
  175. package/dist/node/services/SocketIOService.js +0 -278
  176. package/dist/node/services/SocketService.js +0 -142
  177. package/dist/node/services/SymstoryService.js +0 -542
  178. package/dist/node/utils/basedQuerys.js +0 -162
  179. package/dist/node/utils/symstoryClient.js +0 -230
  180. package/src/services/AIService.js +0 -150
  181. package/src/services/BasedService.js +0 -1301
  182. package/src/services/CoreService.js +0 -1943
  183. package/src/services/SocketIOService.js +0 -334
  184. package/src/services/SocketService.js +0 -168
  185. package/src/services/SymstoryService.js +0 -649
  186. package/src/utils/basedQuerys.js +0 -164
  187. package/src/utils/symstoryClient.js +0 -252
@@ -1,334 +0,0 @@
1
- import { connect, send, disconnect } from '@symbo.ls/socket/client.js'
2
- import { BaseService } from './BaseService.js'
3
-
4
- import * as utils from '@domql/utils'
5
- import { router } from '@symbo.ls/router'
6
- import environment from '../config/environment.js'
7
-
8
- const { deepStringify, deepDestringify, isString } = utils.default || utils
9
-
10
- export class SocketService extends BaseService {
11
- constructor (config) {
12
- super(config)
13
- this._socket = null
14
- this._reconnectAttempts = 0
15
- this._maxReconnectAttempts = config?.maxReconnectAttempts || 5
16
- this._reconnectDelay = config?.reconnectDelay || 1000
17
- this._handlers = new Map()
18
- this._sessionId = Math.random()
19
-
20
- this._ignoreSync = [
21
- 'userId',
22
- 'username',
23
- 'usersName',
24
- 'email',
25
- 'projects',
26
- 'feedbacks',
27
- 'userRoles',
28
- 'loading',
29
- 'appKey',
30
- 'projectName',
31
- 'followingUser',
32
- 'activeProject',
33
- 'user',
34
- 'sessionId',
35
- 'clients'
36
- ]
37
- }
38
-
39
- init () {
40
- try {
41
- const { _context, _options } = this
42
- const socketUrl = environment.socketUrl || _options.socketUrl
43
-
44
- if (!socketUrl) {
45
- throw new Error('Socket URL is required')
46
- }
47
-
48
- this._info = {
49
- config: {
50
- url: socketUrl,
51
- hasToken: Boolean(_context.authToken),
52
- status: 'initializing'
53
- }
54
- }
55
-
56
- this._setReady()
57
- } catch (error) {
58
- this._setError(error)
59
- throw error
60
- }
61
- }
62
-
63
- connect () {
64
- try {
65
- // Check if already connected or connecting
66
- if (
67
- this._socket &&
68
- ['connected', 'connecting'].includes(this._info?.config?.status)
69
- ) {
70
- console.warn(
71
- 'Socket connection already exists:',
72
- this._info?.config?.status
73
- )
74
- return true
75
- }
76
-
77
- const { _context } = this
78
-
79
- if (!_context.appKey) {
80
- throw new Error('App key is required')
81
- }
82
-
83
- // Update status to connecting before attempting connection
84
- this._updateStatus('connecting')
85
-
86
- const config = {
87
- source: 'platform',
88
- userId: _context.user?.id,
89
- socketUrl: this._info.config.url,
90
- location: window.location.host,
91
- // onConnect: () => {
92
- // console.log('waz')
93
- // },
94
- onChange: this._handleMessage.bind(this),
95
- sessionId: this._sessionId,
96
- usersName: _context.user?.name,
97
- route: window.location.pathname,
98
- onDisconnect: this._handleDisconnect.bind(this)
99
- }
100
-
101
- // If a previous socket exists but wasn't properly cleaned up, destroy it
102
- if (this._socket) {
103
- this.destroy()
104
- }
105
-
106
- this._socket = connect(_context.appKey, config)
107
- this._updateStatus('connected')
108
-
109
- if (environment.isDevelopment) {
110
- console.log('Socket connection established:', {
111
- appKey: _context.appKey,
112
- userId: _context.user?.id,
113
- sessionId: this._sessionId,
114
- url: this._info.config.url
115
- })
116
- }
117
-
118
- return true
119
- } catch (error) {
120
- this._updateStatus('failed')
121
- console.error('Socket connection failed:', error)
122
- throw new Error(`Socket connection failed: ${error.message}`)
123
- }
124
- }
125
-
126
- send (type, data, opts = {}) {
127
- this._requireReady()
128
-
129
- if (!this._socket) {
130
- throw new Error('Socket is not connected')
131
- }
132
-
133
- const payload = {
134
- sessionId: this._sessionId,
135
- userId: this._context.user?.id,
136
- usersName: this._context.user?.name,
137
- ...data
138
- }
139
-
140
- send.call(
141
- this._socket,
142
- type,
143
- opts.useDeepStringify ? deepStringify(payload) : payload
144
- )
145
- }
146
-
147
- _handleMessage (event, data) {
148
- try {
149
- const d = isString(data) ? deepDestringify(JSON.parse(data)) : data
150
- if (this._sessionId === d.sessionId) {
151
- return
152
- }
153
-
154
- const handlers = this._handlers.get(event)
155
- if (handlers) {
156
- handlers.forEach(handler => handler(d))
157
- }
158
-
159
- // Handle specific events
160
- switch (event) {
161
- case 'change':
162
- this._handleChangeEvent(d)
163
- break
164
- case 'clients':
165
- this._handleClientsEvent(d)
166
- break
167
- case 'route':
168
- this._handleRouteEvent(d)
169
- break
170
- default:
171
- break
172
- }
173
- } catch (error) {
174
- this._setError(new Error(`Failed to handle message: ${error.message}`))
175
- }
176
- }
177
-
178
- _handleChangeEvent (data) {
179
- const { type, changes, version } = data
180
- if (version) this._context.state.version = version
181
- if (changes) {
182
- window.requestAnimationFrame(async () => {
183
- await this._context.state.setPathCollection(changes, {
184
- preventReplace: type === 'canvas',
185
- preventUpdate: true,
186
- fromSocket: true,
187
- userId: data.userId,
188
- changes
189
- })
190
- })
191
- }
192
-
193
- // monaco updates
194
- // if (data.canvas) {
195
- // const { clients } = data.canvas
196
- // const [firstClientKey] = Object.keys(clients)
197
- // const monaco =
198
- // clients && clients[firstClientKey] && clients[firstClientKey].monaco
199
- // if (monaco) {
200
- // const Canvas =
201
- // this._context.element && this._context.element.getCanvas()
202
- // if (Canvas) {
203
- // Canvas.Chosen.EditorPanels.update({}, { forceMonacoUpdate: true })
204
- // }
205
- // }
206
- // return
207
- // }
208
- }
209
-
210
- _handleClientsEvent (data) {
211
- const { root } = this._context.state
212
-
213
- root.replace(
214
- { clients: data },
215
- {
216
- fromSocket: true,
217
- preventUpdate: true
218
- }
219
- )
220
- }
221
-
222
- _handleRouteEvent (data) {
223
- const { element } = this._context
224
- const { state } = this._context
225
-
226
- if (data.userId && data.type === 'routeChanged') {
227
- const isModalOpen = this.getWindow('modal')
228
- const isFollowing = state.followingUser === data.userId
229
- const isRouteSyncEnabled =
230
- element.getUserSettings('presentMode') && data.userId === state.userId
231
-
232
- if ((isFollowing || isRouteSyncEnabled) && !isModalOpen) {
233
- router(
234
- data.route,
235
- element.__ref.root,
236
- {},
237
- {
238
- fromSocket: true,
239
- updateStateOptions: {
240
- fromSocket: true,
241
- preventStateUpdateListener: 1 // !isModalRoute(data.route, element)
242
- }
243
- }
244
- )
245
- }
246
- } else if (data.reload) {
247
- window.location.reload()
248
- } else if (data.route && data.type === 'routeForced') {
249
- router(
250
- data.route,
251
- element.__ref.root,
252
- {},
253
- {
254
- fromSocket: true,
255
- updateStateOptions: {
256
- fromSocket: true
257
- }
258
- }
259
- )
260
- } else if (data.componentKey) {
261
- if (!element.getData('components')[data.componentKey]) {
262
- return
263
- }
264
- element.activateSelected(data.componentKey)
265
- }
266
- }
267
-
268
- _handleDisconnect () {
269
- this._updateStatus('disconnected')
270
- this._handleReconnect()
271
- }
272
-
273
- _handleReconnect () {
274
- if (this._reconnectAttempts < this._maxReconnectAttempts) {
275
- this._reconnectAttempts++
276
- this._updateStatus('reconnecting')
277
-
278
- setTimeout(() => {
279
- try {
280
- const connected = this.connect()
281
- if (connected) {
282
- this._reconnectAttempts = 0
283
- } else {
284
- this._handleReconnect()
285
- }
286
- } catch (error) {
287
- console.error('Reconnection failed:', error)
288
- this._handleReconnect()
289
- }
290
- }, this._reconnectDelay * this._reconnectAttempts)
291
- } else {
292
- this._updateStatus('failed')
293
- this._setError(new Error('Max reconnection attempts reached'))
294
- }
295
- }
296
-
297
- _updateStatus (status) {
298
- this._info = {
299
- ...this._info,
300
- config: {
301
- ...this._info.config,
302
- status
303
- }
304
- }
305
- }
306
-
307
- destroy () {
308
- if (this._socket) {
309
- disconnect.call(this._socket)
310
- this._socket = null
311
- }
312
- this._handlers.clear()
313
- this._setReady(false)
314
- }
315
-
316
- reconnect () {
317
- this.destroy()
318
- this.connect()
319
- }
320
-
321
- _checkRequiredContext () {
322
- return Boolean(
323
- this._context?.appKey && this._context?.authToken && this._socket
324
- )
325
- }
326
-
327
- isReady () {
328
- if (this._checkRequiredContext()) {
329
- this._setReady(true)
330
- }
331
-
332
- return this._ready
333
- }
334
- }
@@ -1,168 +0,0 @@
1
- import { BaseService } from './BaseService'
2
-
3
- export class SocketService extends BaseService {
4
- constructor (config) {
5
- super(config)
6
- this._socket = null
7
- this._reconnectAttempts = 0
8
- this._maxReconnectAttempts = config?.maxReconnectAttempts || 5
9
- this._reconnectDelay = config?.reconnectDelay || 1000
10
- this._handlers = new Map()
11
- }
12
-
13
- async init ({ context, options }) {
14
- try {
15
- this._context = context
16
- this._options = options
17
- const { authToken } = context
18
- const { socketUrl } = context.socket || {}
19
-
20
- if (!socketUrl) {
21
- throw new Error('Socket URL is required')
22
- }
23
-
24
- this._info = {
25
- config: {
26
- url: socketUrl,
27
- hasToken: Boolean(authToken),
28
- status: 'initializing'
29
- }
30
- }
31
-
32
- await this.connect()
33
- this._setReady()
34
- } catch (error) {
35
- this._setError(error)
36
- throw error
37
- }
38
- }
39
-
40
- connect () {
41
- try {
42
- const { socketUrl, authToken } = this._context.socket || {}
43
-
44
- this._socket = new window.WebSocket(socketUrl)
45
-
46
- this._socket.onopen = () => {
47
- this._reconnectAttempts = 0
48
- this._updateStatus('connected')
49
-
50
- // Authenticate if token available
51
- if (authToken) {
52
- this.send('auth', { token: authToken })
53
- }
54
- }
55
-
56
- this._socket.onclose = () => {
57
- this._updateStatus('disconnected')
58
- this._handleReconnect()
59
- }
60
-
61
- this._socket.onerror = error => {
62
- this._updateStatus('error')
63
- this._setError(error)
64
- }
65
-
66
- this._socket.onmessage = event => {
67
- this._handleMessage(event.data)
68
- }
69
- } catch (error) {
70
- throw new Error(`Socket connection failed: ${error.message}`)
71
- }
72
- }
73
-
74
- // Send message to socket server
75
- send (type, data) {
76
- this._requireReady()
77
-
78
- if (!this._socket || this._socket.readyState !== window.WebSocket.OPEN) {
79
- throw new Error('Socket is not connected')
80
- }
81
-
82
- this._socket.send(JSON.stringify({ type, data }))
83
- }
84
-
85
- // Subscribe to socket events
86
- subscribe (type, handler) {
87
- if (!this._handlers.has(type)) {
88
- this._handlers.set(type, new Set())
89
- }
90
-
91
- this._handlers.get(type).add(handler)
92
-
93
- return () => {
94
- const handlers = this._handlers.get(type)
95
- if (handlers) {
96
- handlers.delete(handler)
97
- if (handlers.size === 0) {
98
- this._handlers.delete(type)
99
- }
100
- }
101
- }
102
- }
103
-
104
- subscribeChannel (type, handler) {
105
- return this.subscribe(type, handler)
106
- }
107
-
108
- // Private methods
109
- _handleMessage (rawData) {
110
- try {
111
- const { type, data } = JSON.parse(rawData)
112
- const handlers = this._handlers.get(type)
113
-
114
- if (handlers) {
115
- handlers.forEach(handler => handler(data))
116
- }
117
- } catch (error) {
118
- this._setError(new Error(`Failed to handle message: ${error.message}`))
119
- }
120
- }
121
-
122
- _handleReconnect () {
123
- if (this._reconnectAttempts < this._maxReconnectAttempts) {
124
- this._reconnectAttempts++
125
- this._updateStatus('reconnecting')
126
-
127
- setTimeout(() => {
128
- this.connect()
129
- }, this._reconnectDelay * this._reconnectAttempts)
130
- } else {
131
- this._updateStatus('failed')
132
- this._setError(new Error('Max reconnection attempts reached'))
133
- }
134
- }
135
-
136
- _updateStatus (status) {
137
- this._info = {
138
- ...this._info,
139
- config: {
140
- ...this._info.config,
141
- status
142
- }
143
- }
144
- }
145
-
146
- // Cleanup
147
- destroy () {
148
- if (this._socket) {
149
- this._socket.close()
150
- this._socket = null
151
- }
152
- this._handlers.clear()
153
- this._setReady(false)
154
- }
155
-
156
- _checkRequiredContext () {
157
- const { socket } = this._context
158
- return Boolean(socket?.socketUrl && this._socket)
159
- }
160
-
161
- isReady () {
162
- if (this._checkRequiredContext()) {
163
- this._setReady(true)
164
- }
165
-
166
- return this._ready
167
- }
168
- }