@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
@@ -662,7 +662,14 @@ class ConversationConnector {
662
662
  try {
663
663
  switch (json.type) {
664
664
  case 'attach_channel_response':
665
- if (!json.payload.success) return;
665
+ if (!json.payload.success) {
666
+ this.#emitConnectionState({
667
+ connected: true,
668
+ ready: false,
669
+ currentState: 'attach_channel_erred'
670
+ });
671
+ return;
672
+ }
666
673
  this.#emitConnectionState({
667
674
  connected: true,
668
675
  ready: true,
@@ -14913,21 +14920,23 @@ class API {
14913
14920
  async connect() {
14914
14921
  this.connected = false;
14915
14922
  const conversationInitialState = !this.hasConversation() ? await this.createConversation() : undefined;
14916
- this.conversation.connect(`${this.#getUrlPrefix('ws')}${this.URLS.socket?.href}`, this.#config.context.channelName || '', this.getChannelTopic(), this.getAccessToken());
14917
- this.conversation.onConnection(({
14918
- connected,
14919
- ready
14920
- }) => {
14921
- this.connected = connected;
14922
- this.#ready = ready;
14923
- });
14924
-
14925
- // Send environment
14926
- const environment = this.#config.sendEnvironment === true ? this.getEnvironment() : this.#config.sendEnvironment;
14927
- if (this.#config.sendEnvironment) {
14928
- this.send('context', {
14929
- environment
14923
+ if (this.URLS.socket) {
14924
+ this.conversation.connect(`${this.#getUrlPrefix('ws')}${this.URLS.socket.href}`, this.#config.context.channelName || '', this.getChannelTopic(), this.getAccessToken());
14925
+ this.conversation.onConnection(({
14926
+ connected,
14927
+ ready
14928
+ }) => {
14929
+ this.connected = connected;
14930
+ this.#ready = ready;
14930
14931
  });
14932
+
14933
+ // Send environment
14934
+ const environment = this.#config.sendEnvironment === true ? this.getEnvironment() : this.#config.sendEnvironment;
14935
+ if (this.#config.sendEnvironment) {
14936
+ this.send('context', {
14937
+ environment
14938
+ });
14939
+ }
14931
14940
  }
14932
14941
  return conversationInitialState;
14933
14942
  }
@@ -14966,7 +14975,7 @@ class API {
14966
14975
  return {
14967
14976
  clientName: "@seamly/web-ui",
14968
14977
  clientVariant: this.#layoutMode,
14969
- clientVersion: "24.0.0-beta.1",
14978
+ clientVersion: "24.0.0-beta.3",
14970
14979
  currentUrl: window.location.toString(),
14971
14980
  screenResolution: `${window.screen.width}x${window.screen.height}`,
14972
14981
  timezone: getTimeZone(),
@@ -18110,34 +18119,12 @@ const SeamlyEventSubscriber = () => {
18110
18119
  const {
18111
18120
  emitEvent
18112
18121
  } = (0,seamly_hooks/* useSeamlyCommands */.Li)();
18113
- (0,hooks_.useEffect)(() => {
18114
- if (conversation.socket) {
18115
- const {
18116
- onError,
18117
- onOpen
18118
- } = conversation;
18119
- onError(err => {
18120
- const seamlyOfflineError = new seamly_offline_error/* default */.A(err);
18121
- dispatch((0,interrupt_slice/* setInterrupt */.y7)({
18122
- name: seamlyOfflineError.name,
18123
- message: seamlyOfflineError.message,
18124
- langKey: seamlyOfflineError.langKey,
18125
- originalEvent: seamlyOfflineError.originalEvent,
18126
- originalError: seamlyOfflineError.originalError
18127
- }));
18128
- dispatch((0,store_slice/* clearEvents */.lh)());
18129
- });
18130
- onOpen(() => {
18131
- dispatch((0,interrupt_slice/* clearInterrupt */.DB)());
18132
- });
18133
- }
18134
- }, [conversation, dispatch]);
18135
18122
  (0,hooks_.useEffect)(() => {
18136
18123
  if (conversation.socket) {
18137
18124
  conversation.onConnection(({
18138
18125
  currentState
18139
18126
  }) => {
18140
- if (currentState === 'socket_join_error') {
18127
+ if (currentState === 'attach_channel_erred') {
18141
18128
  const seamlyGeneralError = new seamly_general_error/* default */.A();
18142
18129
  dispatch((0,interrupt_slice/* setInterrupt */.y7)({
18143
18130
  name: seamlyGeneralError.name,
@@ -18151,8 +18138,22 @@ const SeamlyEventSubscriber = () => {
18151
18138
  }
18152
18139
  return false;
18153
18140
  });
18141
+ conversation.onError(err => {
18142
+ const seamlyOfflineError = new seamly_offline_error/* default */.A(err);
18143
+ dispatch((0,interrupt_slice/* setInterrupt */.y7)({
18144
+ name: seamlyOfflineError.name,
18145
+ message: seamlyOfflineError.message,
18146
+ langKey: seamlyOfflineError.langKey,
18147
+ originalEvent: seamlyOfflineError.originalEvent,
18148
+ originalError: seamlyOfflineError.originalError
18149
+ }));
18150
+ dispatch((0,store_slice/* clearEvents */.lh)());
18151
+ });
18152
+ conversation.onOpen(() => {
18153
+ dispatch((0,interrupt_slice/* clearInterrupt */.DB)());
18154
+ });
18154
18155
  }
18155
- }, [conversation, dispatch]);
18156
+ }, [conversation, conversation.socket, dispatch]);
18156
18157
  (0,hooks_.useEffect)(() => {
18157
18158
  conversation.onConnection(({
18158
18159
  connected
@@ -22833,6 +22834,7 @@ class ExternalApi {
22833
22834
  constructor(appConfig) {
22834
22835
  this._waitingActions = [];
22835
22836
  this._instances = {};
22837
+ this.timeouts = {};
22836
22838
  this.appConfig = appConfig;
22837
22839
  this.context = {};
22838
22840
  }
@@ -22942,7 +22944,7 @@ class ExternalApi {
22942
22944
  this._instances[config.namespace] = instance;
22943
22945
  // Clear the context after creating the instance, so we do not reuse it for the next
22944
22946
  this.context = {};
22945
- instance.render();
22947
+ this.debouncedRender(instance, config.namespace);
22946
22948
  }
22947
22949
  }
22948
22950
  handleDestroy(actionObj) {
@@ -22969,6 +22971,17 @@ class ExternalApi {
22969
22971
  createInstance(config) {
22970
22972
  return new Engine(config, this);
22971
22973
  }
22974
+
22975
+ /**
22976
+ * @param {Engine} instance
22977
+ * @param {string} namespace
22978
+ */
22979
+ debouncedRender(instance, namespace) {
22980
+ window.clearTimeout(this.timeouts[namespace]);
22981
+ this.timeouts[namespace] = window.setTimeout(() => {
22982
+ instance.render();
22983
+ }, 100);
22984
+ }
22972
22985
  destroy(instance) {
22973
22986
  if (!instance) {
22974
22987
  Object.entries(this._instances).forEach(([namespace, _instance]) => {