@seamly/web-ui 20.8.1 → 21.0.1-beta.1

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 (225) hide show
  1. package/build/dist/lib/components.js +14855 -20
  2. package/build/dist/lib/components.min.js +2 -1
  3. package/build/dist/lib/components.min.js.LICENSE.txt +48 -0
  4. package/build/dist/lib/config.js +9 -3
  5. package/build/dist/lib/config.min.js +1 -1
  6. package/build/dist/lib/contexts.js +14 -5
  7. package/build/dist/lib/contexts.min.js +1 -1
  8. package/build/dist/lib/deprecated-view.js +1 -1
  9. package/build/dist/lib/hooks.js +8446 -20
  10. package/build/dist/lib/hooks.min.js +2 -1
  11. package/build/dist/lib/hooks.min.js.LICENSE.txt +38 -0
  12. package/build/dist/lib/index.debug.js +585 -584
  13. package/build/dist/lib/index.debug.min.js +1 -1
  14. package/build/dist/lib/index.debug.min.js.LICENSE.txt +110 -110
  15. package/build/dist/lib/index.js +20279 -26454
  16. package/build/dist/lib/index.min.js +1 -1
  17. package/build/dist/lib/index.min.js.LICENSE.txt +6 -1
  18. package/build/dist/lib/standalone.js +27823 -34681
  19. package/build/dist/lib/standalone.min.js +1 -1
  20. package/build/dist/lib/standalone.min.js.LICENSE.txt +1 -1
  21. package/build/dist/lib/storage.js +6 -15
  22. package/build/dist/lib/style-guide.js +23181 -7921
  23. package/build/dist/lib/style-guide.min.js +1 -1
  24. package/build/dist/lib/style-guide.min.js.LICENSE.txt +10 -0
  25. package/build/dist/lib/styles-default-implementation.js +1 -1
  26. package/build/dist/lib/styles.js +1 -1
  27. package/build/dist/lib/utils.js +22149 -17
  28. package/build/dist/lib/utils.min.js +2 -1
  29. package/build/dist/lib/utils.min.js.LICENSE.txt +48 -0
  30. package/package.json +54 -52
  31. package/src/icons/icon_check-16.svg +14 -0
  32. package/src/icons/icon_check-32.svg +14 -0
  33. package/src/javascripts/api/conversation-connector.ts +149 -0
  34. package/src/javascripts/api/errors/seamly-base-error.js +19 -0
  35. package/src/javascripts/api/errors/seamly-unavailable-error.js +5 -7
  36. package/src/javascripts/api/{index.js → index.ts} +163 -116
  37. package/src/javascripts/config.types.ts +5 -4
  38. package/src/javascripts/domains/app/actions.ts +47 -46
  39. package/src/javascripts/domains/app/hooks.js +1 -1
  40. package/src/javascripts/domains/config/actions.ts +2 -8
  41. package/src/javascripts/domains/config/hooks.ts +1 -1
  42. package/src/javascripts/domains/config/selectors.ts +6 -6
  43. package/src/javascripts/domains/config/slice.ts +3 -3
  44. package/src/javascripts/domains/errors/index.ts +66 -0
  45. package/src/javascripts/domains/forms/context.ts +1 -1
  46. package/src/javascripts/domains/forms/forms.types.ts +3 -3
  47. package/src/javascripts/domains/forms/hooks.ts +10 -10
  48. package/src/javascripts/domains/forms/provider.tsx +9 -9
  49. package/src/javascripts/domains/i18n/actions.ts +11 -5
  50. package/src/javascripts/domains/i18n/hooks.ts +11 -8
  51. package/src/javascripts/domains/i18n/selectors.ts +10 -4
  52. package/src/javascripts/domains/i18n/slice.ts +0 -1
  53. package/src/javascripts/domains/interrupt/hooks.ts +1 -1
  54. package/src/javascripts/domains/interrupt/middleware.ts +1 -1
  55. package/src/javascripts/domains/store/index.ts +1 -1
  56. package/src/javascripts/domains/store/selectors.ts +16 -0
  57. package/src/javascripts/domains/store/slice.ts +47 -41
  58. package/src/javascripts/domains/store/store.types.ts +38 -10
  59. package/src/javascripts/domains/translations/components/{options-button.js → options-button.tsx} +30 -20
  60. package/src/javascripts/domains/translations/components/options-dialog/index.tsx +33 -0
  61. package/src/javascripts/domains/translations/components/options-dialog/translation-option.tsx +42 -0
  62. package/src/javascripts/domains/translations/components/options-dialog/translation-options.tsx +81 -0
  63. package/src/javascripts/domains/translations/components/translation-status.tsx +15 -0
  64. package/src/javascripts/domains/translations/hooks.ts +77 -11
  65. package/src/javascripts/domains/translations/slice.ts +20 -9
  66. package/src/javascripts/domains/translations/translations.types.ts +4 -2
  67. package/src/javascripts/domains/visibility/actions.ts +6 -10
  68. package/src/javascripts/domains/visibility/hooks.ts +33 -14
  69. package/src/javascripts/domains/visibility/selectors.ts +3 -2
  70. package/src/javascripts/domains/visibility/slice.ts +2 -6
  71. package/src/javascripts/index.ts +18 -22
  72. package/src/javascripts/lib/engine/{index.js → index.tsx} +25 -7
  73. package/src/javascripts/lib/url-helpers.ts +112 -0
  74. package/src/javascripts/package/components.js +15 -1
  75. package/src/javascripts/package/config.js +1 -1
  76. package/src/javascripts/package/contexts.js +5 -3
  77. package/src/javascripts/package/hooks.js +19 -1
  78. package/src/javascripts/package/utils.js +13 -3
  79. package/src/javascripts/schema.ts +28 -0
  80. package/src/javascripts/style-guide/components/app.js +16 -12
  81. package/src/javascripts/style-guide/components/links.js +6 -6
  82. package/src/javascripts/style-guide/components/static-core.js +14 -9
  83. package/src/javascripts/style-guide/components/view.js +2 -2
  84. package/src/javascripts/style-guide/states.js +132 -36
  85. package/src/javascripts/style-guide/style-guide-engine.js +2 -1
  86. package/src/javascripts/style-guide/style-guide-external-api.js +1 -1
  87. package/src/javascripts/ui/components/app-options/index.js +25 -6
  88. package/src/javascripts/ui/components/chat-app.js +1 -1
  89. package/src/javascripts/ui/components/chat-status/chat-status-action.tsx +30 -0
  90. package/src/javascripts/ui/components/chat-status/index.tsx +61 -0
  91. package/src/javascripts/ui/components/conversation/component-filter.js +9 -9
  92. package/src/javascripts/ui/components/conversation/{conversation.js → conversation.tsx} +32 -41
  93. package/src/javascripts/ui/components/conversation/event/card-component.js +2 -2
  94. package/src/javascripts/ui/components/conversation/event/card-message.js +1 -1
  95. package/src/javascripts/ui/components/conversation/event/carousel-component/components/controls.js +2 -2
  96. package/src/javascripts/ui/components/conversation/event/carousel-component/index.js +4 -4
  97. package/src/javascripts/ui/components/conversation/event/carousel-message/components/slide.js +2 -2
  98. package/src/javascripts/ui/components/conversation/event/carousel-message/index.js +1 -1
  99. package/src/javascripts/ui/components/conversation/event/chat-scroll/chat-scroll-context.ts +12 -0
  100. package/src/javascripts/ui/components/conversation/event/chat-scroll/chat-scroll-provider.tsx +46 -0
  101. package/src/javascripts/ui/components/conversation/event/chat-scroll/unread-messages-button.tsx +30 -0
  102. package/src/javascripts/ui/components/conversation/event/choice-prompt.js +12 -8
  103. package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +6 -6
  104. package/src/javascripts/ui/components/conversation/event/cta.js +2 -2
  105. package/src/javascripts/ui/components/conversation/event/divider/index.js +0 -1
  106. package/src/javascripts/ui/components/conversation/event/divider/variants/default.js +1 -1
  107. package/src/javascripts/ui/components/conversation/event/divider/variants/new-translation.js +17 -22
  108. package/src/javascripts/ui/components/conversation/event/divider/variants/time-indicator.js +2 -2
  109. package/src/javascripts/ui/components/conversation/event/event-participant.js +1 -1
  110. package/src/javascripts/ui/components/conversation/event/event.tsx +66 -0
  111. package/src/javascripts/ui/components/conversation/event/hooks/use-event-link-click-handler.js +1 -1
  112. package/src/javascripts/ui/components/conversation/event/hooks/use-formatted-date.js +1 -1
  113. package/src/javascripts/ui/components/conversation/event/image-lightbox.js +1 -1
  114. package/src/javascripts/ui/components/conversation/event/image.js +2 -2
  115. package/src/javascripts/ui/components/conversation/event/splash.js +1 -1
  116. package/src/javascripts/ui/components/conversation/event/translation.js +1 -1
  117. package/src/javascripts/ui/components/conversation/event/upload.js +2 -2
  118. package/src/javascripts/ui/components/conversation/event/video.js +2 -2
  119. package/src/javascripts/ui/components/conversation/event-divider.js +1 -1
  120. package/src/javascripts/ui/components/conversation/message-container.js +1 -1
  121. package/src/javascripts/ui/components/conversation/use-chat-scroll.ts +108 -0
  122. package/src/javascripts/ui/components/core/{seamly-activity-monitor.js → seamly-activity-monitor.tsx} +12 -5
  123. package/src/javascripts/ui/components/core/seamly-api-context.ts +7 -0
  124. package/src/javascripts/ui/components/core/seamly-chat.tsx +8 -0
  125. package/src/javascripts/ui/components/core/{seamly-core.js → seamly-core.tsx} +27 -14
  126. package/src/javascripts/ui/components/core/seamly-event-subscriber.ts +340 -0
  127. package/src/javascripts/ui/components/core/seamly-file-upload.js +2 -2
  128. package/src/javascripts/ui/components/core/seamly-idle-detach-counter.js +1 -1
  129. package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +24 -11
  130. package/src/javascripts/ui/components/core/seamly-live-region.js +4 -4
  131. package/src/javascripts/ui/components/core/seamly-new-notifications.js +3 -3
  132. package/src/javascripts/ui/components/core/seamly-read-state.js +2 -33
  133. package/src/javascripts/ui/components/entry/deprecated-toggle-button.js +4 -4
  134. package/src/javascripts/ui/components/entry/entry-container.js +8 -8
  135. package/src/javascripts/ui/components/entry/text-entry/hooks.js +3 -3
  136. package/src/javascripts/ui/components/entry/text-entry/index.js +3 -3
  137. package/src/javascripts/ui/components/entry/text-entry/text-entry-form.js +4 -4
  138. package/src/javascripts/ui/components/entry/upload/file-upload-form.js +3 -3
  139. package/src/javascripts/ui/components/entry/upload/index.js +5 -5
  140. package/src/javascripts/ui/components/entry/upload-toggle.js +6 -6
  141. package/src/javascripts/ui/components/faq/faq.js +14 -14
  142. package/src/javascripts/ui/components/form-controls/error.js +2 -2
  143. package/src/javascripts/ui/components/form-controls/file-input.js +3 -3
  144. package/src/javascripts/ui/components/layout/agent-info.js +3 -3
  145. package/src/javascripts/ui/components/layout/chat-frame.js +20 -12
  146. package/src/javascripts/ui/components/layout/chat.js +5 -5
  147. package/src/javascripts/ui/components/layout/deprecated-app-frame.js +6 -6
  148. package/src/javascripts/ui/components/layout/deprecated-chat-frame.js +34 -0
  149. package/src/javascripts/ui/components/layout/header.js +2 -2
  150. package/src/javascripts/ui/components/layout/icon.js +11 -9
  151. package/src/javascripts/ui/components/layout/interrupt.js +7 -5
  152. package/src/javascripts/ui/components/layout/pre-chat-messages.js +1 -1
  153. package/src/javascripts/ui/components/layout/privacy-disclaimer.js +2 -2
  154. package/src/javascripts/ui/components/options/options-button.js +5 -5
  155. package/src/javascripts/ui/components/options/{options-frame.js → options-frame.tsx} +52 -18
  156. package/src/javascripts/ui/components/options/transcript/index.js +9 -10
  157. package/src/javascripts/ui/components/options/transcript/transcript-form.js +2 -2
  158. package/src/javascripts/ui/components/suggestions/index.js +8 -8
  159. package/src/javascripts/ui/components/suggestions/suggestions-item.js +1 -1
  160. package/src/javascripts/{domains/translations/components/chat-status.js → ui/components/translation-chat-status/index.tsx} +13 -14
  161. package/src/javascripts/ui/components/translation-proposal/index.tsx +36 -0
  162. package/src/javascripts/ui/components/view/app-view.js +2 -7
  163. package/src/javascripts/ui/components/view/deprecated-view.js +8 -10
  164. package/src/javascripts/ui/components/view/index.js +6 -6
  165. package/src/javascripts/ui/components/view/inline-view.js +4 -8
  166. package/src/javascripts/ui/components/view/window-view/collapse-button.js +2 -2
  167. package/src/javascripts/ui/components/view/window-view/index.js +11 -17
  168. package/src/javascripts/ui/components/view/window-view/window-open-button.js +6 -6
  169. package/src/javascripts/ui/components/warnings/idle-detach-warning.js +3 -3
  170. package/src/javascripts/ui/components/warnings/prompt.js +1 -1
  171. package/src/javascripts/ui/components/warnings/resume-conversation-prompt.js +4 -4
  172. package/src/javascripts/ui/components/widgets/in-out-transition.js +20 -18
  173. package/src/javascripts/ui/components/widgets/lightbox.js +3 -3
  174. package/src/javascripts/ui/components/widgets/modal.js +2 -2
  175. package/src/javascripts/ui/components/widgets/upload-progress.js +2 -2
  176. package/src/javascripts/ui/hooks/file-upload-hooks.js +1 -1
  177. package/src/javascripts/ui/hooks/focus-helper-hooks.js +1 -1
  178. package/src/javascripts/ui/hooks/seamly-entry-hooks.js +6 -6
  179. package/src/javascripts/ui/hooks/seamly-hooks.js +11 -10
  180. package/src/javascripts/ui/hooks/seamly-option-hooks.js +6 -6
  181. package/src/javascripts/ui/hooks/{seamly-state-hooks.js → seamly-state-hooks.ts} +9 -6
  182. package/src/javascripts/ui/hooks/use-click-outside.ts +29 -0
  183. package/src/javascripts/ui/hooks/use-event-component-mapping.js +11 -10
  184. package/src/javascripts/ui/hooks/use-interval.js +1 -1
  185. package/src/javascripts/ui/hooks/use-seamly-actions.ts +29 -29
  186. package/src/javascripts/ui/hooks/use-seamly-chat.js +14 -24
  187. package/src/javascripts/ui/hooks/use-seamly-commands.js +20 -15
  188. package/src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js +8 -8
  189. package/src/javascripts/ui/hooks/use-seamly-resume-conversation-prompt.js +2 -2
  190. package/src/javascripts/ui/hooks/use-single-file-upload.js +1 -1
  191. package/src/javascripts/ui/hooks/utility-hooks.js +1 -1
  192. package/src/javascripts/ui/utils/general-utils.js +0 -23
  193. package/src/javascripts/ui/utils/seamly-utils.ts +10 -1
  194. package/src/javascripts/ui/utils/seamly-utils.types.ts +9 -0
  195. package/src/stylesheets/1-settings/_config.scss +1 -1
  196. package/src/stylesheets/3-chat/_chat.scss +24 -9
  197. package/src/stylesheets/5-components/_chat-status.scss +72 -16
  198. package/src/stylesheets/5-components/_conversation.scss +35 -1
  199. package/src/stylesheets/5-components/_disclaimer.scss +0 -5
  200. package/src/stylesheets/5-components/_options.scss +16 -6
  201. package/src/stylesheets/5-components/_translation-options.scss +51 -0
  202. package/src/stylesheets/6-default-implementation/_scrollbar.scss +1 -1
  203. package/src/stylesheets/7-deprecated/3-app/_app.scss +19 -4
  204. package/src/stylesheets/7-deprecated/5-components/_chat-status.scss +5 -0
  205. package/src/stylesheets/7-deprecated/5-components/_options.scss +1 -4
  206. package/src/stylesheets/7-deprecated/5-components/_translation-options.scss +49 -0
  207. package/src/stylesheets/deprecated-view.scss +1 -0
  208. package/src/stylesheets/styles.scss +1 -0
  209. package/webpack/config.common.js +4 -4
  210. package/webpack/config.package.js +10 -16
  211. package/webpack/config.site.js +4 -1
  212. package/webpack/config.test.js +2 -1
  213. package/build/dist/lib/deprecated-view.css +0 -1
  214. package/build/dist/lib/styles-default-implementation.css +0 -1
  215. package/build/dist/lib/styles.css +0 -1
  216. package/src/.DS_Store +0 -0
  217. package/src/javascripts/api/event-producer.js +0 -20
  218. package/src/javascripts/api/producer.js +0 -136
  219. package/src/javascripts/domains/errors/index.js +0 -37
  220. package/src/javascripts/domains/translations/components/options-dialog/form.js +0 -70
  221. package/src/javascripts/domains/translations/components/options-dialog/index.js +0 -87
  222. package/src/javascripts/ui/components/chat-status/index.js +0 -38
  223. package/src/javascripts/ui/components/conversation/event/event.js +0 -36
  224. package/src/javascripts/ui/components/core/seamly-api-context.js +0 -5
  225. package/src/javascripts/ui/components/core/seamly-event-subscriber.js +0 -279
@@ -0,0 +1,48 @@
1
+ /*!
2
+ * focus-trap 7.1.0
3
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
4
+ */
5
+
6
+ /*!
7
+ * tabbable 6.0.1
8
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
9
+ */
10
+
11
+ /**
12
+ * @license React
13
+ * react-is.production.min.js
14
+ *
15
+ * Copyright (c) Facebook, Inc. and its affiliates.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+ /**
22
+ * @license React
23
+ * use-sync-external-store-shim.production.min.js
24
+ *
25
+ * Copyright (c) Facebook, Inc. and its affiliates.
26
+ *
27
+ * This source code is licensed under the MIT license found in the
28
+ * LICENSE file in the root directory of this source tree.
29
+ */
30
+
31
+ /**
32
+ * @license React
33
+ * use-sync-external-store-shim/with-selector.production.min.js
34
+ *
35
+ * Copyright (c) Facebook, Inc. and its affiliates.
36
+ *
37
+ * This source code is licensed under the MIT license found in the
38
+ * LICENSE file in the root directory of this source tree.
39
+ */
40
+
41
+ /** @license React v16.13.1
42
+ * react-is.production.min.js
43
+ *
44
+ * Copyright (c) Facebook, Inc. and its affiliates.
45
+ *
46
+ * This source code is licensed under the MIT license found in the
47
+ * LICENSE file in the root directory of this source tree.
48
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamly/web-ui",
3
- "version": "20.8.1",
3
+ "version": "21.0.1-beta.1",
4
4
  "main": "build/dist/lib/index.js",
5
5
  "types": "build/src/javascripts/index.d.ts",
6
6
  "module": "",
@@ -22,76 +22,78 @@
22
22
  "webpack/*"
23
23
  ],
24
24
  "dependencies": {
25
- "@reduxjs/toolkit": "^1.8.5",
25
+ "@reduxjs/toolkit": "^1.8.6",
26
26
  "@ultraq/icu-message-formatter": "^0.12.0",
27
27
  "deep-keys": "^0.5.0",
28
- "focus-trap": "^6.7.1",
28
+ "focus-trap": "^7.0.0",
29
29
  "include-media": "^1.4.10",
30
30
  "js-cookie": "^3.0.1",
31
- "minivents": "^2.2.0",
32
- "phoenix": "1.6.11",
33
- "react-redux": "^8.0.2",
34
- "superagent": "^7.1.2",
35
- "xstream": "^11.14.0"
31
+ "minivents": "^2.2.1",
32
+ "phoenix": "1.6.15",
33
+ "react-redux": "^8.0.4",
34
+ "superagent": "^8.0.3"
36
35
  },
37
36
  "devDependencies": {
38
- "@babel/core": "^7.18.2",
39
- "@babel/plugin-proposal-object-rest-spread": "^7.15.6",
37
+ "@babel/core": "^7.19.6",
38
+ "@babel/plugin-proposal-object-rest-spread": "^7.19.4",
40
39
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
41
- "@babel/plugin-transform-classes": "^7.15.4",
42
- "@babel/plugin-transform-react-jsx": "^7.14.9",
43
- "@babel/plugin-transform-runtime": "^7.15.8",
44
- "@babel/preset-env": "^7.15.8",
40
+ "@babel/plugin-transform-classes": "^7.19.0",
41
+ "@babel/plugin-transform-react-jsx": "^7.19.0",
42
+ "@babel/plugin-transform-runtime": "^7.19.6",
43
+ "@babel/preset-env": "^7.19.4",
45
44
  "@babel/preset-react": "^7.18.6",
46
45
  "@babel/preset-typescript": "^7.18.6",
47
- "@babel/runtime-corejs3": "^7.18.3",
48
- "@seamly/doc-site": "^1.0",
49
- "@seamly/eslint-config": "^2.2.0",
50
- "@seamly/prettier-config": "^2.1.0",
46
+ "@babel/runtime-corejs3": "^7.18.9",
47
+ "@seamly/doc-site": "^2.0.0",
48
+ "@seamly/eslint-config": "^2.3.0",
49
+ "@seamly/prettier-config": "^2.2.0",
51
50
  "@seamly/stylelint-config": "^2.0.0",
52
51
  "@testing-library/jest-dom": "^5.16.5",
53
- "@testing-library/preact": "^2.0.1",
54
- "@types/jest": "^27.1.7",
55
- "@typescript-eslint/eslint-plugin": "^5.35.1",
56
- "@typescript-eslint/parser": "^5.35.1",
57
- "babel-loader": "^8.2.2",
58
- "copy-webpack-plugin": "^10.2.4",
59
- "cypress": "^10.0.3",
52
+ "@testing-library/preact": "^3.2.2",
53
+ "@trivago/prettier-plugin-sort-imports": "^3.4.0",
54
+ "@types/jest": "^27.5.2",
55
+ "@types/phoenix": "^1.5.4",
56
+ "@typescript-eslint/eslint-plugin": "^5.42.0",
57
+ "@typescript-eslint/parser": "^5.42.0",
58
+ "babel-loader": "^9.0.1",
59
+ "babel-plugin-react-remove-properties": "^0.3.0",
60
+ "copy-webpack-plugin": "^11.0.0",
60
61
  "cypress-file-upload": "^5.0.8",
61
62
  "cypress-wait-until": "^1.7.2",
62
- "debug": "^4.3.2",
63
- "eslint": "^8.17.0",
63
+ "cypress": "^10.11.0",
64
+ "debug": "^4.3.4",
64
65
  "eslint-import-resolver-alias": "^1.1.2",
65
- "eslint-import-resolver-typescript": "^3.5.0",
66
+ "eslint-import-resolver-typescript": "^3.5.2",
66
67
  "eslint-plugin-cypress": "^2.12.1",
67
68
  "eslint-plugin-import": "^2.26.0",
68
- "eslint-plugin-jest": "^26.5.3",
69
+ "eslint-plugin-jest": "^27.1.3",
70
+ "eslint": "^8.27.0",
69
71
  "file-loader": "^6.2.0",
70
72
  "glob": "^8.0.3",
71
- "husky": "^7.0.2",
73
+ "husky": "^8.0.1",
72
74
  "ignore-loader": "^0.1.2",
75
+ "jest-environment-jsdom": "^27.5.1",
73
76
  "jest": "^27.5.1",
74
- "mini-css-extract-plugin": "^2.4.2",
77
+ "mini-css-extract-plugin": "^2.6.1",
75
78
  "postcss": "8",
76
- "preact": "^10.10.6",
77
- "prettier": "^2.4.1",
79
+ "preact": "^10.11.2",
80
+ "prettier": "^2.7.1",
78
81
  "raw-loader": "^4.0.2",
79
82
  "rimraf": "^3.0.2",
80
- "sneakpeek-cli": "^0.2.1",
81
83
  "start-server-and-test": "^1.14.0",
82
- "style-loader": "^3.3.0",
83
- "stylelint": "14.9.0",
84
- "ts-loader": "^9.3.1",
85
- "typescript": "^4.7.4",
84
+ "style-loader": "^3.3.1",
85
+ "stylelint": "^14.14.0",
86
+ "ts-loader": "^9.4.1",
87
+ "typescript": "^4.8.4",
86
88
  "url-loader": "^4.1.1",
87
- "webpack": "^5.58.2",
88
- "webpack-bundle-analyzer": "^4.5.0",
89
- "webpack-cli": "^4.9.1",
90
- "webpack-dev-server": "^4.3.1",
91
- "webpack-merge": "^5.8.0"
89
+ "webpack-bundle-analyzer": "^4.7.0",
90
+ "webpack-cli": "^4.10.0",
91
+ "webpack-dev-server": "^4.11.1",
92
+ "webpack-merge": "^5.8.0",
93
+ "webpack": "^5.74.0"
92
94
  },
93
95
  "peerDependencies": {
94
- "preact": "10.10.6"
96
+ "preact": "^10.11.2"
95
97
  },
96
98
  "scripts": {
97
99
  "build:clean": "rimraf build; mkdir -p build",
@@ -101,17 +103,18 @@
101
103
  "server": "webpack serve --node-env=development",
102
104
  "server:test": "webpack serve --node-env=development --env build=test",
103
105
  "lint:scss": "stylelint \"src/stylesheets/**/*.scss\" --formatter=verbose",
104
- "lint:js": "eslint --fix --max-warnings 0 src webpack",
106
+ "lint:js": "yarn run check:eslint && yarn run check:code",
105
107
  "lint": "yarn run lint:js && yarn run lint:scss && yarn check:prettier",
106
- "format:code": "prettier --write \"src/**/*.{js,scss}\"",
107
- "format:tests": "prettier --write \"tests/**/*.{js,scss}\"",
108
- "format:public": "prettier --write \"public/**/*.{js,scss,html}\"",
109
- "format:webpack": "prettier --write \"webpack/**/*.{js,scss}\"",
108
+ "format:code": "yarn run check:eslint --fix && prettier --write \"src/**/*.{js,ts,tsx,scss}\"",
109
+ "format:tests": "prettier --write \"tests/**/*.{js,ts,tsx,scss}\"",
110
+ "format:public": "prettier --write \"public/**/*.{js,ts,tsx,scss,html}\"",
111
+ "format:webpack": "prettier --write \"webpack/**/*.{js,ts,tsx,scss}\"",
110
112
  "format": "yarn run format:code && yarn run format:tests && yarn run format:public && yarn run format:webpack",
111
- "check:code": "prettier --check \"src/**/*.{js,scss}\"",
113
+ "check:code": "prettier --check \"src/**/*.{js,ts,tsx,scss}\"",
112
114
  "check:tests": "prettier --check \"tests/**/*.{js,scss}\"",
113
115
  "check:public": "prettier --check \"public/**/*.{js,scss,html}\"",
114
116
  "check:webpack": "prettier --check \"webpack/**/*.{js,scss,html}\"",
117
+ "check:eslint": "eslint --ext .js,.ts,.tsx src/ webpack/",
115
118
  "check:prettier": "yarn run check:code && yarn run check:tests && yarn run check:public && yarn run check:webpack",
116
119
  "test": "jest",
117
120
  "types:generate": "npx openapi-typescript schema.yaml --output src/javascripts/schema.ts",
@@ -121,6 +124,5 @@
121
124
  "test:e2e": "start-server-and-test server:test http-get://localhost:8080/tests/index.js cypress:open",
122
125
  "test:e2e:ci": "start-server-and-test server:test http-get://localhost:8080/tests/index.js cypress:run",
123
126
  "prepare": "husky install"
124
- },
125
- "prettier": "@seamly/prettier-config"
127
+ }
126
128
  }
@@ -0,0 +1,14 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="16px"
4
+ height="16px"
5
+ x="0px"
6
+ y="0px"
7
+ viewBox="0 0 16 16"
8
+ >
9
+ <path
10
+ fill="currentColor"
11
+ d="M11.6,4.3l-5,5L4.9,7.5C4.4,7,3.7,7,3.2,7.5l0,0C2.8,8,2.8,8.7,3.2,9.2l1.7,1.7l0,0l0.8,0.8
12
+ c0.5,0.5,1.2,0.5,1.7,0l0.8-0.8l5-5c0.5-0.5,0.5-1.2,0-1.7l0,0C12.8,3.8,12.1,3.8,11.6,4.3z"
13
+ />
14
+ </svg>
@@ -0,0 +1,14 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="32px"
4
+ height="32px"
5
+ x="0px"
6
+ y="0px"
7
+ viewBox="0 0 32 32"
8
+ >
9
+ <path
10
+ fill="currentColor"
11
+ d="M22.9,9.3l-9.3,9.3l-3.2-3.2c-0.9-0.9-2.3-0.9-3.2,0l0,0c-0.9,0.9-0.9,2.3,0,3.2l3.2,3.2l0,0l1.6,1.6
12
+ c0.9,0.9,2.3,0.9,3.2,0l1.6-1.6l9.3-9.3c0.9-0.9,0.9-2.3,0-3.2l0,0C25.2,8.4,23.7,8.4,22.9,9.3z"
13
+ />
14
+ </svg>
@@ -0,0 +1,149 @@
1
+ import { Channel, Socket } from 'phoenix'
2
+ import { apiVersion } from 'config'
3
+ import debug from 'lib/debug'
4
+ import splitUrlParams from 'lib/split-url-params'
5
+
6
+ const log = debug('seamly')
7
+
8
+ type ConnectionState =
9
+ | 'socket_closed' // Socket is closed.
10
+ | 'channel_closed' // Channel is closed.
11
+ | 'channel_erred' // Errors received from joined channel.
12
+ | 'join_channel_succeeded' // Joined channel succesfully.
13
+ | 'join_channel_erred' // Error on joining channel. This is usefull when you want to restart a chat sessions.
14
+ | 'attach_channel_succeeded' // Attached channel to system.
15
+ export default class ConversationConnector {
16
+ #connectionListeners = []
17
+
18
+ accessToken: string
19
+
20
+ channelName: string
21
+
22
+ channelTopic: string
23
+
24
+ url: string
25
+
26
+ socket: Socket
27
+
28
+ channel: Channel
29
+
30
+ async connect(
31
+ url: string,
32
+ channelName: string,
33
+ channelTopic: string,
34
+ accessToken: string,
35
+ ) {
36
+ this.url = url
37
+
38
+ this.accessToken = accessToken
39
+ this.channelName = channelName
40
+ this.channelTopic = channelTopic
41
+ const { url: splittedUrl, params } = splitUrlParams(this.url)
42
+
43
+ this.socket = new Socket(splittedUrl, {
44
+ params: { ...params, v: apiVersion },
45
+ })
46
+
47
+ this.socket.connect()
48
+
49
+ this.channel = this.socket.channel(this.channelTopic, {
50
+ authorization: `Bearer ${this.accessToken}`,
51
+ channelName: this.channelName,
52
+ })
53
+
54
+ this.start()
55
+
56
+ this.socket.onError((err) => {
57
+ log('[SOCKET][ERROR]', err)
58
+ })
59
+
60
+ this.socket.onOpen(() => {
61
+ log('[SOCKET]OPEN')
62
+ })
63
+
64
+ this.channel.on('system', (msg) => {
65
+ switch (msg.type) {
66
+ case 'attach_channel_succeeded':
67
+ this.#emitConnectionState('attach_channel_succeeded')
68
+ break
69
+ }
70
+ })
71
+
72
+ this.socket.onClose(() => {
73
+ log('[SOCKET]CLOSE')
74
+ this.#emitConnectionState('socket_closed')
75
+ })
76
+
77
+ this.channel.onClose(() => {
78
+ log('[CHANNEL]CLOSE')
79
+ this.#emitConnectionState('channel_closed')
80
+ })
81
+
82
+ this.channel.onError((msg) => {
83
+ log('[CHANNEL][ERROR]', msg)
84
+ this.#emitConnectionState('channel_erred')
85
+ })
86
+
87
+ this.#listenTo(
88
+ 'ack',
89
+ 'ui',
90
+ 'error',
91
+ 'participant',
92
+ 'message',
93
+ 'service_data',
94
+ 'system',
95
+ 'info',
96
+ 'sync',
97
+ )
98
+ }
99
+
100
+ start() {
101
+ this.channel
102
+ .join()
103
+ .receive('ok', () => {
104
+ log('[CHANNEL][JOIN] OK')
105
+ this.#emitConnectionState('join_channel_succeeded')
106
+ })
107
+ .receive('error', (err) => {
108
+ log('[CHANNEL][JOIN] ERROR', err)
109
+ this.#emitConnectionState('join_channel_erred')
110
+ // @ts-ignore
111
+ this.channel.socket.disconnect()
112
+ })
113
+ .receive('timeout', () => {
114
+ log('[CHANEL][JOIN] Networking issue. Still waiting...')
115
+ })
116
+ }
117
+
118
+ disconnect() {
119
+ this.#connectionListeners = []
120
+ this.channel?.leave()
121
+ this.socket?.remove(this.channel)
122
+ this.socket?.disconnect()
123
+ }
124
+
125
+ #listenTo(...types: string[]) {
126
+ types.forEach((type) => {
127
+ this.channel.on(type, (msg) => {
128
+ log('[RECEIVE]', type, msg)
129
+ })
130
+ })
131
+ }
132
+
133
+ // eslint-disable-next-line no-unused-vars
134
+ onConnection(cb: (_payload: ConnectionState) => void) {
135
+ this.#connectionListeners.push(cb)
136
+ }
137
+
138
+ #emitConnectionState(payload: ConnectionState) {
139
+ this.#connectionListeners.forEach((cb) => cb(payload))
140
+ }
141
+
142
+ pushToChannel(
143
+ command: string,
144
+ payload: { type: string; error: unknown },
145
+ timeout = 10000,
146
+ ) {
147
+ this.channel.push(command, payload, timeout)
148
+ }
149
+ }
@@ -1,4 +1,17 @@
1
+ function parseOriginalErrMsg(str) {
2
+ try {
3
+ const json = JSON.parse(str)
4
+ return json.error
5
+ } catch (e) {
6
+ return str
7
+ }
8
+ }
9
+
1
10
  export default class SeamlyBaseError extends Error {
11
+ action = ''
12
+
13
+ langKey = ''
14
+
2
15
  constructor(originalError, ...params) {
3
16
  super(...params)
4
17
 
@@ -6,11 +19,17 @@ export default class SeamlyBaseError extends Error {
6
19
  Error.captureStackTrace(this, Object.getPrototypeOf(this))
7
20
  }
8
21
  this.originalError = originalError
22
+
9
23
  if (originalError?.payload) {
10
24
  this.originalEvent = originalError
11
25
  this.originalError = originalError.payload.error
12
26
  this.message = `Event of type ${originalError.payload.type} encountered`
13
27
  }
28
+ if (!this.message && originalError?.message) {
29
+ const parsedOriginalMessage = parseOriginalErrMsg(originalError.message)
30
+ this.message = parsedOriginalMessage
31
+ }
32
+
14
33
  if (originalError?.error) {
15
34
  this.originalError = originalError.error
16
35
  }
@@ -1,15 +1,13 @@
1
+ import SeamlyBaseError from './seamly-base-error'
2
+
1
3
  /**
2
4
  * This error is used to alert the user that there's a problem with the connection
3
5
  * when initialising the application because of a connection issue on either the server
4
6
  * or the client side.
5
7
  */
6
- export default class SeamlyUnavailableError extends Error {
7
- constructor(params) {
8
- super(params)
9
-
10
- if (Error.captureStackTrace) {
11
- Error.captureStackTrace(this, SeamlyUnavailableError)
12
- }
8
+ export default class SeamlyUnavailableError extends SeamlyBaseError {
9
+ constructor(originalError, ...params) {
10
+ super(originalError, ...params)
13
11
 
14
12
  this.name = 'SeamlyUnavailableError'
15
13
  this.langKey = 'errors.seamlyUnavailable'