@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
@@ -3503,7 +3503,14 @@ class ConversationConnector {
3503
3503
  try {
3504
3504
  switch (json.type) {
3505
3505
  case 'attach_channel_response':
3506
- if (!json.payload.success) return;
3506
+ if (!json.payload.success) {
3507
+ this.#emitConnectionState({
3508
+ connected: true,
3509
+ ready: false,
3510
+ currentState: 'attach_channel_erred'
3511
+ });
3512
+ return;
3513
+ }
3507
3514
  this.#emitConnectionState({
3508
3515
  connected: true,
3509
3516
  ready: true,
@@ -4225,21 +4232,23 @@ class API {
4225
4232
  async connect() {
4226
4233
  this.connected = false;
4227
4234
  const conversationInitialState = !this.hasConversation() ? await this.createConversation() : undefined;
4228
- this.conversation.connect(`${this.#getUrlPrefix('ws')}${this.URLS.socket?.href}`, this.#config.context.channelName || '', this.getChannelTopic(), this.getAccessToken());
4229
- this.conversation.onConnection(({
4230
- connected,
4231
- ready
4232
- }) => {
4233
- this.connected = connected;
4234
- this.#ready = ready;
4235
- });
4236
-
4237
- // Send environment
4238
- const environment = this.#config.sendEnvironment === true ? this.getEnvironment() : this.#config.sendEnvironment;
4239
- if (this.#config.sendEnvironment) {
4240
- this.send('context', {
4241
- environment
4235
+ if (this.URLS.socket) {
4236
+ this.conversation.connect(`${this.#getUrlPrefix('ws')}${this.URLS.socket.href}`, this.#config.context.channelName || '', this.getChannelTopic(), this.getAccessToken());
4237
+ this.conversation.onConnection(({
4238
+ connected,
4239
+ ready
4240
+ }) => {
4241
+ this.connected = connected;
4242
+ this.#ready = ready;
4242
4243
  });
4244
+
4245
+ // Send environment
4246
+ const environment = this.#config.sendEnvironment === true ? this.getEnvironment() : this.#config.sendEnvironment;
4247
+ if (this.#config.sendEnvironment) {
4248
+ this.send('context', {
4249
+ environment
4250
+ });
4251
+ }
4243
4252
  }
4244
4253
  return conversationInitialState;
4245
4254
  }
@@ -4278,7 +4287,7 @@ class API {
4278
4287
  return {
4279
4288
  clientName: "@seamly/web-ui",
4280
4289
  clientVariant: this.#layoutMode,
4281
- clientVersion: "24.0.0-beta.1",
4290
+ clientVersion: "24.0.0-beta.3",
4282
4291
  currentUrl: window.location.toString(),
4283
4292
  screenResolution: `${window.screen.width}x${window.screen.height}`,
4284
4293
  timezone: getTimeZone(),
@@ -17084,34 +17093,12 @@ const SeamlyEventSubscriber = () => {
17084
17093
  const {
17085
17094
  emitEvent
17086
17095
  } = use_seamly_commands();
17087
- (0,hooks_.useEffect)(() => {
17088
- if (conversation.socket) {
17089
- const {
17090
- onError,
17091
- onOpen
17092
- } = conversation;
17093
- onError(err => {
17094
- const seamlyOfflineError = new SeamlyOfflineError(err);
17095
- dispatch(setInterrupt({
17096
- name: seamlyOfflineError.name,
17097
- message: seamlyOfflineError.message,
17098
- langKey: seamlyOfflineError.langKey,
17099
- originalEvent: seamlyOfflineError.originalEvent,
17100
- originalError: seamlyOfflineError.originalError
17101
- }));
17102
- dispatch(clearEvents());
17103
- });
17104
- onOpen(() => {
17105
- dispatch(clearInterrupt());
17106
- });
17107
- }
17108
- }, [conversation, dispatch]);
17109
17096
  (0,hooks_.useEffect)(() => {
17110
17097
  if (conversation.socket) {
17111
17098
  conversation.onConnection(({
17112
17099
  currentState
17113
17100
  }) => {
17114
- if (currentState === 'socket_join_error') {
17101
+ if (currentState === 'attach_channel_erred') {
17115
17102
  const seamlyGeneralError = new SeamlyGeneralError();
17116
17103
  dispatch(setInterrupt({
17117
17104
  name: seamlyGeneralError.name,
@@ -17125,8 +17112,22 @@ const SeamlyEventSubscriber = () => {
17125
17112
  }
17126
17113
  return false;
17127
17114
  });
17115
+ conversation.onError(err => {
17116
+ const seamlyOfflineError = new SeamlyOfflineError(err);
17117
+ dispatch(setInterrupt({
17118
+ name: seamlyOfflineError.name,
17119
+ message: seamlyOfflineError.message,
17120
+ langKey: seamlyOfflineError.langKey,
17121
+ originalEvent: seamlyOfflineError.originalEvent,
17122
+ originalError: seamlyOfflineError.originalError
17123
+ }));
17124
+ dispatch(clearEvents());
17125
+ });
17126
+ conversation.onOpen(() => {
17127
+ dispatch(clearInterrupt());
17128
+ });
17128
17129
  }
17129
- }, [conversation, dispatch]);
17130
+ }, [conversation, conversation.socket, dispatch]);
17130
17131
  (0,hooks_.useEffect)(() => {
17131
17132
  conversation.onConnection(({
17132
17133
  connected
@@ -21780,6 +21781,7 @@ class ExternalApi {
21780
21781
  constructor(appConfig) {
21781
21782
  this._waitingActions = [];
21782
21783
  this._instances = {};
21784
+ this.timeouts = {};
21783
21785
  this.appConfig = appConfig;
21784
21786
  this.context = {};
21785
21787
  }
@@ -21889,7 +21891,7 @@ class ExternalApi {
21889
21891
  this._instances[config.namespace] = instance;
21890
21892
  // Clear the context after creating the instance, so we do not reuse it for the next
21891
21893
  this.context = {};
21892
- instance.render();
21894
+ this.debouncedRender(instance, config.namespace);
21893
21895
  }
21894
21896
  }
21895
21897
  handleDestroy(actionObj) {
@@ -21916,6 +21918,17 @@ class ExternalApi {
21916
21918
  createInstance(config) {
21917
21919
  return new Engine(config, this);
21918
21920
  }
21921
+
21922
+ /**
21923
+ * @param {Engine} instance
21924
+ * @param {string} namespace
21925
+ */
21926
+ debouncedRender(instance, namespace) {
21927
+ window.clearTimeout(this.timeouts[namespace]);
21928
+ this.timeouts[namespace] = window.setTimeout(() => {
21929
+ instance.render();
21930
+ }, 100);
21931
+ }
21919
21932
  destroy(instance) {
21920
21933
  if (!instance) {
21921
21934
  Object.entries(this._instances).forEach(([namespace, _instance]) => {