@seamly/web-ui 23.0.6-alpha.1 → 23.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamly/web-ui",
3
- "version": "23.0.6-alpha.1",
3
+ "version": "23.0.6",
4
4
  "main": "build/dist/lib/index.js",
5
5
  "types": "build/src/javascripts/index.d.ts",
6
6
  "exports": {
@@ -382,6 +382,8 @@ export class API {
382
382
  )
383
383
  const body = await response.json()
384
384
  this.#updateUrls(body)
385
+ // Do not use the socket link from the config endpoint, as this is incomplete and will always fail if used
386
+ delete this.URLS.socket
385
387
  this.configReady = true
386
388
  return body.config
387
389
  } catch (error: any) {
@@ -465,17 +467,19 @@ export class API {
465
467
  this.connected = false
466
468
  const conversationInitialState = await this.#createConversation()
467
469
 
468
- this.conversation.connect(
469
- `${this.#getUrlPrefix('ws')}${this.URLS.socket}`,
470
- this.#config.context.channelName,
471
- this.#getChannelTopic(),
472
- this.#getAccessToken(),
473
- )
470
+ if (this.URLS.socket) {
471
+ this.conversation.connect(
472
+ `${this.#getUrlPrefix('ws')}${this.URLS.socket}`,
473
+ this.#config.context.channelName,
474
+ this.#getChannelTopic(),
475
+ this.#getAccessToken(),
476
+ )
474
477
 
475
- this.conversation.onConnection(({ connected, ready }) => {
476
- this.connected = connected
477
- this.#ready = ready
478
- })
478
+ this.conversation.onConnection(({ connected, ready }) => {
479
+ this.connected = connected
480
+ this.#ready = ready
481
+ })
482
+ }
479
483
 
480
484
  return conversationInitialState
481
485
  }
@@ -12,7 +12,7 @@ class ExternalApi {
12
12
  constructor(appConfig) {
13
13
  this._waitingActions = []
14
14
  this._instances = {}
15
- this._timeoutId = undefined
15
+ this.timeouts = {}
16
16
  this.appConfig = appConfig
17
17
  this.context = {}
18
18
  }
@@ -124,10 +124,7 @@ class ExternalApi {
124
124
  this._instances[config.namespace] = instance
125
125
  // Clear the context after creating the instance, so we do not reuse it for the next
126
126
  this.context = {}
127
- window.clearTimeout(this._timeoutId)
128
- this._timeoutId = window.setTimeout(() => {
129
- instance.render()
130
- }, 60)
127
+ this.debouncedRender(instance, config.namespace)
131
128
  }
132
129
  }
133
130
 
@@ -161,6 +158,17 @@ class ExternalApi {
161
158
  return new Engine(config, this)
162
159
  }
163
160
 
161
+ /**
162
+ * @param {Engine} instance
163
+ * @param {string} namespace
164
+ */
165
+ debouncedRender(instance, namespace) {
166
+ window.clearTimeout(this.timeouts[namespace])
167
+ this.timeouts[namespace] = window.setTimeout(() => {
168
+ instance.render()
169
+ }, 100)
170
+ }
171
+
164
172
  destroy(instance) {
165
173
  if (!instance) {
166
174
  Object.entries(this._instances).forEach(([namespace, _instance]) => {