@seamly/web-ui 24.0.0-beta.1 → 24.0.0-beta.3

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 (32) hide show
  1. package/build/dist/lib/components.js +8 -1
  2. package/build/dist/lib/components.js.map +1 -1
  3. package/build/dist/lib/components.min.js.map +1 -1
  4. package/build/dist/lib/hooks.js +8 -1
  5. package/build/dist/lib/hooks.js.map +1 -1
  6. package/build/dist/lib/hooks.min.js +1 -1
  7. package/build/dist/lib/hooks.min.js.map +1 -1
  8. package/build/dist/lib/index.debug.js +54 -41
  9. package/build/dist/lib/index.debug.js.map +1 -1
  10. package/build/dist/lib/index.debug.min.js +1 -1
  11. package/build/dist/lib/index.debug.min.js.map +1 -1
  12. package/build/dist/lib/index.js +54 -41
  13. package/build/dist/lib/index.js.map +1 -1
  14. package/build/dist/lib/index.min.js +1 -1
  15. package/build/dist/lib/index.min.js.map +1 -1
  16. package/build/dist/lib/standalone.js +54 -41
  17. package/build/dist/lib/standalone.js.map +1 -1
  18. package/build/dist/lib/standalone.min.js +1 -1
  19. package/build/dist/lib/standalone.min.js.map +1 -1
  20. package/build/dist/lib/style-guide.js +54 -41
  21. package/build/dist/lib/style-guide.js.map +1 -1
  22. package/build/dist/lib/style-guide.min.js +1 -1
  23. package/build/dist/lib/style-guide.min.js.map +1 -1
  24. package/build/dist/lib/utils.js +54 -41
  25. package/build/dist/lib/utils.js.map +1 -1
  26. package/build/dist/lib/utils.min.js +1 -1
  27. package/build/dist/lib/utils.min.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/javascripts/api/conversation-connector.ts +8 -1
  30. package/src/javascripts/api/index.ts +21 -19
  31. package/src/javascripts/lib/external-api/index.ts +13 -1
  32. package/src/javascripts/ui/components/core/seamly-event-subscriber.ts +22 -26
@@ -3552,7 +3552,14 @@ class ConversationConnector {
3552
3552
  try {
3553
3553
  switch (json.type) {
3554
3554
  case 'attach_channel_response':
3555
- if (!json.payload.success) return;
3555
+ if (!json.payload.success) {
3556
+ this.#emitConnectionState({
3557
+ connected: true,
3558
+ ready: false,
3559
+ currentState: 'attach_channel_erred'
3560
+ });
3561
+ return;
3562
+ }
3556
3563
  this.#emitConnectionState({
3557
3564
  connected: true,
3558
3565
  ready: true,
@@ -4274,21 +4281,23 @@ class API {
4274
4281
  async connect() {
4275
4282
  this.connected = false;
4276
4283
  const conversationInitialState = !this.hasConversation() ? await this.createConversation() : undefined;
4277
- this.conversation.connect(`${this.#getUrlPrefix('ws')}${this.URLS.socket?.href}`, this.#config.context.channelName || '', this.getChannelTopic(), this.getAccessToken());
4278
- this.conversation.onConnection(({
4279
- connected,
4280
- ready
4281
- }) => {
4282
- this.connected = connected;
4283
- this.#ready = ready;
4284
- });
4285
-
4286
- // Send environment
4287
- const environment = this.#config.sendEnvironment === true ? this.getEnvironment() : this.#config.sendEnvironment;
4288
- if (this.#config.sendEnvironment) {
4289
- this.send('context', {
4290
- environment
4284
+ if (this.URLS.socket) {
4285
+ this.conversation.connect(`${this.#getUrlPrefix('ws')}${this.URLS.socket.href}`, this.#config.context.channelName || '', this.getChannelTopic(), this.getAccessToken());
4286
+ this.conversation.onConnection(({
4287
+ connected,
4288
+ ready
4289
+ }) => {
4290
+ this.connected = connected;
4291
+ this.#ready = ready;
4291
4292
  });
4293
+
4294
+ // Send environment
4295
+ const environment = this.#config.sendEnvironment === true ? this.getEnvironment() : this.#config.sendEnvironment;
4296
+ if (this.#config.sendEnvironment) {
4297
+ this.send('context', {
4298
+ environment
4299
+ });
4300
+ }
4292
4301
  }
4293
4302
  return conversationInitialState;
4294
4303
  }
@@ -4327,7 +4336,7 @@ class API {
4327
4336
  return {
4328
4337
  clientName: "@seamly/web-ui",
4329
4338
  clientVariant: this.#layoutMode,
4330
- clientVersion: "24.0.0-beta.1",
4339
+ clientVersion: "24.0.0-beta.3",
4331
4340
  currentUrl: window.location.toString(),
4332
4341
  screenResolution: `${window.screen.width}x${window.screen.height}`,
4333
4342
  timezone: getTimeZone(),
@@ -17133,34 +17142,12 @@ const SeamlyEventSubscriber = () => {
17133
17142
  const {
17134
17143
  emitEvent
17135
17144
  } = use_seamly_commands();
17136
- (0,hooks_module/* useEffect */.vJ)(() => {
17137
- if (conversation.socket) {
17138
- const {
17139
- onError,
17140
- onOpen
17141
- } = conversation;
17142
- onError(err => {
17143
- const seamlyOfflineError = new SeamlyOfflineError(err);
17144
- dispatch(setInterrupt({
17145
- name: seamlyOfflineError.name,
17146
- message: seamlyOfflineError.message,
17147
- langKey: seamlyOfflineError.langKey,
17148
- originalEvent: seamlyOfflineError.originalEvent,
17149
- originalError: seamlyOfflineError.originalError
17150
- }));
17151
- dispatch(clearEvents());
17152
- });
17153
- onOpen(() => {
17154
- dispatch(clearInterrupt());
17155
- });
17156
- }
17157
- }, [conversation, dispatch]);
17158
17145
  (0,hooks_module/* useEffect */.vJ)(() => {
17159
17146
  if (conversation.socket) {
17160
17147
  conversation.onConnection(({
17161
17148
  currentState
17162
17149
  }) => {
17163
- if (currentState === 'socket_join_error') {
17150
+ if (currentState === 'attach_channel_erred') {
17164
17151
  const seamlyGeneralError = new SeamlyGeneralError();
17165
17152
  dispatch(setInterrupt({
17166
17153
  name: seamlyGeneralError.name,
@@ -17174,8 +17161,22 @@ const SeamlyEventSubscriber = () => {
17174
17161
  }
17175
17162
  return false;
17176
17163
  });
17164
+ conversation.onError(err => {
17165
+ const seamlyOfflineError = new SeamlyOfflineError(err);
17166
+ dispatch(setInterrupt({
17167
+ name: seamlyOfflineError.name,
17168
+ message: seamlyOfflineError.message,
17169
+ langKey: seamlyOfflineError.langKey,
17170
+ originalEvent: seamlyOfflineError.originalEvent,
17171
+ originalError: seamlyOfflineError.originalError
17172
+ }));
17173
+ dispatch(clearEvents());
17174
+ });
17175
+ conversation.onOpen(() => {
17176
+ dispatch(clearInterrupt());
17177
+ });
17177
17178
  }
17178
- }, [conversation, dispatch]);
17179
+ }, [conversation, conversation.socket, dispatch]);
17179
17180
  (0,hooks_module/* useEffect */.vJ)(() => {
17180
17181
  conversation.onConnection(({
17181
17182
  connected
@@ -21829,6 +21830,7 @@ class ExternalApi {
21829
21830
  constructor(appConfig) {
21830
21831
  this._waitingActions = [];
21831
21832
  this._instances = {};
21833
+ this.timeouts = {};
21832
21834
  this.appConfig = appConfig;
21833
21835
  this.context = {};
21834
21836
  }
@@ -21938,7 +21940,7 @@ class ExternalApi {
21938
21940
  this._instances[config.namespace] = instance;
21939
21941
  // Clear the context after creating the instance, so we do not reuse it for the next
21940
21942
  this.context = {};
21941
- instance.render();
21943
+ this.debouncedRender(instance, config.namespace);
21942
21944
  }
21943
21945
  }
21944
21946
  handleDestroy(actionObj) {
@@ -21965,6 +21967,17 @@ class ExternalApi {
21965
21967
  createInstance(config) {
21966
21968
  return new Engine(config, this);
21967
21969
  }
21970
+
21971
+ /**
21972
+ * @param {Engine} instance
21973
+ * @param {string} namespace
21974
+ */
21975
+ debouncedRender(instance, namespace) {
21976
+ window.clearTimeout(this.timeouts[namespace]);
21977
+ this.timeouts[namespace] = window.setTimeout(() => {
21978
+ instance.render();
21979
+ }, 100);
21980
+ }
21968
21981
  destroy(instance) {
21969
21982
  if (!instance) {
21970
21983
  Object.entries(this._instances).forEach(([namespace, _instance]) => {