@seamly/web-ui 22.3.3 → 22.3.5-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 (35) hide show
  1. package/build/dist/lib/components.js +1485 -15
  2. package/build/dist/lib/components.js.map +1 -1
  3. package/build/dist/lib/components.min.js +1 -1
  4. package/build/dist/lib/components.min.js.map +1 -1
  5. package/build/dist/lib/hooks.js +1519 -9
  6. package/build/dist/lib/hooks.js.map +1 -1
  7. package/build/dist/lib/hooks.min.js +1 -1
  8. package/build/dist/lib/hooks.min.js.map +1 -1
  9. package/build/dist/lib/index.debug.js +16 -5
  10. package/build/dist/lib/index.debug.js.map +1 -1
  11. package/build/dist/lib/index.debug.min.js +1 -1
  12. package/build/dist/lib/index.debug.min.js.LICENSE.txt +4 -0
  13. package/build/dist/lib/index.debug.min.js.map +1 -1
  14. package/build/dist/lib/index.js +259 -245
  15. package/build/dist/lib/index.js.map +1 -1
  16. package/build/dist/lib/index.min.js +1 -1
  17. package/build/dist/lib/index.min.js.map +1 -1
  18. package/build/dist/lib/standalone.js +537 -246
  19. package/build/dist/lib/standalone.js.map +1 -1
  20. package/build/dist/lib/standalone.min.js +1 -1
  21. package/build/dist/lib/standalone.min.js.map +1 -1
  22. package/build/dist/lib/style-guide.js +266 -252
  23. package/build/dist/lib/style-guide.js.map +1 -1
  24. package/build/dist/lib/style-guide.min.js +1 -1
  25. package/build/dist/lib/style-guide.min.js.map +1 -1
  26. package/build/dist/lib/utils.js +8498 -8428
  27. package/build/dist/lib/utils.js.map +1 -1
  28. package/build/dist/lib/utils.min.js +1 -1
  29. package/build/dist/lib/utils.min.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/javascripts/api/conversation-connector.ts +48 -32
  32. package/src/javascripts/ui/components/core/seamly-event-subscriber.ts +197 -218
  33. package/src/javascripts/ui/hooks/seamly-hooks.js +5 -5
  34. package/src/javascripts/ui/hooks/use-notifications.ts +1 -1
  35. package/src/javascripts/ui/hooks/use-seamly-conversation.ts +13 -0
@@ -659,6 +659,20 @@ var path = __webpack_require__(4058);
659
659
  module.exports = path.Promise;
660
660
 
661
661
 
662
+ /***/ }),
663
+
664
+ /***/ 6998:
665
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
666
+
667
+ __webpack_require__(6274);
668
+ __webpack_require__(5967);
669
+ __webpack_require__(9008);
670
+ __webpack_require__(7971);
671
+ var path = __webpack_require__(4058);
672
+
673
+ module.exports = path.Set;
674
+
675
+
662
676
  /***/ }),
663
677
 
664
678
  /***/ 1631:
@@ -1401,6 +1415,221 @@ module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
1401
1415
  };
1402
1416
 
1403
1417
 
1418
+ /***/ }),
1419
+
1420
+ /***/ 5616:
1421
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1422
+
1423
+ "use strict";
1424
+
1425
+ var create = __webpack_require__(9290);
1426
+ var defineBuiltInAccessor = __webpack_require__(9202);
1427
+ var defineBuiltIns = __webpack_require__(4380);
1428
+ var bind = __webpack_require__(6843);
1429
+ var anInstance = __webpack_require__(5743);
1430
+ var isNullOrUndefined = __webpack_require__(2119);
1431
+ var iterate = __webpack_require__(3091);
1432
+ var defineIterator = __webpack_require__(5105);
1433
+ var createIterResultObject = __webpack_require__(3538);
1434
+ var setSpecies = __webpack_require__(4431);
1435
+ var DESCRIPTORS = __webpack_require__(5746);
1436
+ var fastKey = (__webpack_require__(1647).fastKey);
1437
+ var InternalStateModule = __webpack_require__(5402);
1438
+
1439
+ var setInternalState = InternalStateModule.set;
1440
+ var internalStateGetterFor = InternalStateModule.getterFor;
1441
+
1442
+ module.exports = {
1443
+ getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
1444
+ var Constructor = wrapper(function (that, iterable) {
1445
+ anInstance(that, Prototype);
1446
+ setInternalState(that, {
1447
+ type: CONSTRUCTOR_NAME,
1448
+ index: create(null),
1449
+ first: undefined,
1450
+ last: undefined,
1451
+ size: 0
1452
+ });
1453
+ if (!DESCRIPTORS) that.size = 0;
1454
+ if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
1455
+ });
1456
+
1457
+ var Prototype = Constructor.prototype;
1458
+
1459
+ var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
1460
+
1461
+ var define = function (that, key, value) {
1462
+ var state = getInternalState(that);
1463
+ var entry = getEntry(that, key);
1464
+ var previous, index;
1465
+ // change existing entry
1466
+ if (entry) {
1467
+ entry.value = value;
1468
+ // create new entry
1469
+ } else {
1470
+ state.last = entry = {
1471
+ index: index = fastKey(key, true),
1472
+ key: key,
1473
+ value: value,
1474
+ previous: previous = state.last,
1475
+ next: undefined,
1476
+ removed: false
1477
+ };
1478
+ if (!state.first) state.first = entry;
1479
+ if (previous) previous.next = entry;
1480
+ if (DESCRIPTORS) state.size++;
1481
+ else that.size++;
1482
+ // add to index
1483
+ if (index !== 'F') state.index[index] = entry;
1484
+ } return that;
1485
+ };
1486
+
1487
+ var getEntry = function (that, key) {
1488
+ var state = getInternalState(that);
1489
+ // fast case
1490
+ var index = fastKey(key);
1491
+ var entry;
1492
+ if (index !== 'F') return state.index[index];
1493
+ // frozen object case
1494
+ for (entry = state.first; entry; entry = entry.next) {
1495
+ if (entry.key == key) return entry;
1496
+ }
1497
+ };
1498
+
1499
+ defineBuiltIns(Prototype, {
1500
+ // `{ Map, Set }.prototype.clear()` methods
1501
+ // https://tc39.es/ecma262/#sec-map.prototype.clear
1502
+ // https://tc39.es/ecma262/#sec-set.prototype.clear
1503
+ clear: function clear() {
1504
+ var that = this;
1505
+ var state = getInternalState(that);
1506
+ var data = state.index;
1507
+ var entry = state.first;
1508
+ while (entry) {
1509
+ entry.removed = true;
1510
+ if (entry.previous) entry.previous = entry.previous.next = undefined;
1511
+ delete data[entry.index];
1512
+ entry = entry.next;
1513
+ }
1514
+ state.first = state.last = undefined;
1515
+ if (DESCRIPTORS) state.size = 0;
1516
+ else that.size = 0;
1517
+ },
1518
+ // `{ Map, Set }.prototype.delete(key)` methods
1519
+ // https://tc39.es/ecma262/#sec-map.prototype.delete
1520
+ // https://tc39.es/ecma262/#sec-set.prototype.delete
1521
+ 'delete': function (key) {
1522
+ var that = this;
1523
+ var state = getInternalState(that);
1524
+ var entry = getEntry(that, key);
1525
+ if (entry) {
1526
+ var next = entry.next;
1527
+ var prev = entry.previous;
1528
+ delete state.index[entry.index];
1529
+ entry.removed = true;
1530
+ if (prev) prev.next = next;
1531
+ if (next) next.previous = prev;
1532
+ if (state.first == entry) state.first = next;
1533
+ if (state.last == entry) state.last = prev;
1534
+ if (DESCRIPTORS) state.size--;
1535
+ else that.size--;
1536
+ } return !!entry;
1537
+ },
1538
+ // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods
1539
+ // https://tc39.es/ecma262/#sec-map.prototype.foreach
1540
+ // https://tc39.es/ecma262/#sec-set.prototype.foreach
1541
+ forEach: function forEach(callbackfn /* , that = undefined */) {
1542
+ var state = getInternalState(this);
1543
+ var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
1544
+ var entry;
1545
+ while (entry = entry ? entry.next : state.first) {
1546
+ boundFunction(entry.value, entry.key, this);
1547
+ // revert to the last existing entry
1548
+ while (entry && entry.removed) entry = entry.previous;
1549
+ }
1550
+ },
1551
+ // `{ Map, Set}.prototype.has(key)` methods
1552
+ // https://tc39.es/ecma262/#sec-map.prototype.has
1553
+ // https://tc39.es/ecma262/#sec-set.prototype.has
1554
+ has: function has(key) {
1555
+ return !!getEntry(this, key);
1556
+ }
1557
+ });
1558
+
1559
+ defineBuiltIns(Prototype, IS_MAP ? {
1560
+ // `Map.prototype.get(key)` method
1561
+ // https://tc39.es/ecma262/#sec-map.prototype.get
1562
+ get: function get(key) {
1563
+ var entry = getEntry(this, key);
1564
+ return entry && entry.value;
1565
+ },
1566
+ // `Map.prototype.set(key, value)` method
1567
+ // https://tc39.es/ecma262/#sec-map.prototype.set
1568
+ set: function set(key, value) {
1569
+ return define(this, key === 0 ? 0 : key, value);
1570
+ }
1571
+ } : {
1572
+ // `Set.prototype.add(value)` method
1573
+ // https://tc39.es/ecma262/#sec-set.prototype.add
1574
+ add: function add(value) {
1575
+ return define(this, value = value === 0 ? 0 : value, value);
1576
+ }
1577
+ });
1578
+ if (DESCRIPTORS) defineBuiltInAccessor(Prototype, 'size', {
1579
+ configurable: true,
1580
+ get: function () {
1581
+ return getInternalState(this).size;
1582
+ }
1583
+ });
1584
+ return Constructor;
1585
+ },
1586
+ setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) {
1587
+ var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator';
1588
+ var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME);
1589
+ var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME);
1590
+ // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods
1591
+ // https://tc39.es/ecma262/#sec-map.prototype.entries
1592
+ // https://tc39.es/ecma262/#sec-map.prototype.keys
1593
+ // https://tc39.es/ecma262/#sec-map.prototype.values
1594
+ // https://tc39.es/ecma262/#sec-map.prototype-@@iterator
1595
+ // https://tc39.es/ecma262/#sec-set.prototype.entries
1596
+ // https://tc39.es/ecma262/#sec-set.prototype.keys
1597
+ // https://tc39.es/ecma262/#sec-set.prototype.values
1598
+ // https://tc39.es/ecma262/#sec-set.prototype-@@iterator
1599
+ defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) {
1600
+ setInternalState(this, {
1601
+ type: ITERATOR_NAME,
1602
+ target: iterated,
1603
+ state: getInternalCollectionState(iterated),
1604
+ kind: kind,
1605
+ last: undefined
1606
+ });
1607
+ }, function () {
1608
+ var state = getInternalIteratorState(this);
1609
+ var kind = state.kind;
1610
+ var entry = state.last;
1611
+ // revert to the last existing entry
1612
+ while (entry && entry.removed) entry = entry.previous;
1613
+ // get next entry
1614
+ if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
1615
+ // or finish the iteration
1616
+ state.target = undefined;
1617
+ return createIterResultObject(undefined, true);
1618
+ }
1619
+ // return step by kind
1620
+ if (kind == 'keys') return createIterResultObject(entry.key, false);
1621
+ if (kind == 'values') return createIterResultObject(entry.value, false);
1622
+ return createIterResultObject([entry.key, entry.value], false);
1623
+ }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
1624
+
1625
+ // `{ Map, Set }.prototype[@@species]` accessors
1626
+ // https://tc39.es/ecma262/#sec-get-map-@@species
1627
+ // https://tc39.es/ecma262/#sec-get-set-@@species
1628
+ setSpecies(CONSTRUCTOR_NAME);
1629
+ }
1630
+ };
1631
+
1632
+
1404
1633
  /***/ }),
1405
1634
 
1406
1635
  /***/ 8850:
@@ -7148,6 +7377,32 @@ $({ target: 'Promise', stat: true, forced: IS_PURE || FORCED_PROMISE_CONSTRUCTOR
7148
7377
  });
7149
7378
 
7150
7379
 
7380
+ /***/ }),
7381
+
7382
+ /***/ 2266:
7383
+ /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
7384
+
7385
+ "use strict";
7386
+
7387
+ var collection = __webpack_require__(4683);
7388
+ var collectionStrong = __webpack_require__(5616);
7389
+
7390
+ // `Set` constructor
7391
+ // https://tc39.es/ecma262/#sec-set-objects
7392
+ collection('Set', function (init) {
7393
+ return function Set() { return init(this, arguments.length ? arguments[0] : undefined); };
7394
+ }, collectionStrong);
7395
+
7396
+
7397
+ /***/ }),
7398
+
7399
+ /***/ 9008:
7400
+ /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
7401
+
7402
+ // TODO: Remove this module from `core-js@4` since it's replaced to module below
7403
+ __webpack_require__(2266);
7404
+
7405
+
7151
7406
  /***/ }),
7152
7407
 
7153
7408
  /***/ 1035:
@@ -9705,6 +9960,17 @@ var path = __webpack_require__(4058);
9705
9960
  module.exports = path.setTimeout;
9706
9961
 
9707
9962
 
9963
+ /***/ }),
9964
+
9965
+ /***/ 5519:
9966
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
9967
+
9968
+ var parent = __webpack_require__(6998);
9969
+ __webpack_require__(7634);
9970
+
9971
+ module.exports = parent;
9972
+
9973
+
9708
9974
  /***/ }),
9709
9975
 
9710
9976
  /***/ 7641:
@@ -10359,6 +10625,13 @@ module.exports = __webpack_require__(7989);
10359
10625
 
10360
10626
  /***/ }),
10361
10627
 
10628
+ /***/ 7487:
10629
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
10630
+
10631
+ module.exports = __webpack_require__(5519);
10632
+
10633
+ /***/ }),
10634
+
10362
10635
  /***/ 3460:
10363
10636
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
10364
10637
 
@@ -10966,6 +11239,9 @@ function store(key) {
10966
11239
  }
10967
11240
  };
10968
11241
  }
11242
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/set.js
11243
+ var set = __webpack_require__(7487);
11244
+ var set_default = /*#__PURE__*/__webpack_require__.n(set);
10969
11245
  ;// CONCATENATED MODULE: ./node_modules/phoenix/priv/static/phoenix.mjs
10970
11246
  // js/phoenix/utils.js
10971
11247
  var closure = (value) => {
@@ -12150,6 +12426,7 @@ const splitUrlParams = url => {
12150
12426
 
12151
12427
 
12152
12428
 
12429
+
12153
12430
  var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
12154
12431
  function adopt(value) {
12155
12432
  return value instanceof P ? value : new P(function (resolve) {
@@ -12194,6 +12471,14 @@ var _ConversationConnector_instances, _ConversationConnector_connectionListeners
12194
12471
 
12195
12472
 
12196
12473
  const log = debug_default()('seamly');
12474
+ // Subscribers set which are used to subscribe to changes in the conversation.
12475
+ // Needs to be outside of the ConversationConnector class so its not recreated for each instance.
12476
+ const subscribers = new (set_default())();
12477
+ // Syncs the lifecycle of the conversation with Preact. Each subscriber will fetch the latest value from the conversation if needed.
12478
+ const emitChange = () => {
12479
+ // Call the callback function for each subscriber
12480
+ for_each_default()(subscribers).call(subscribers, callback => callback());
12481
+ };
12197
12482
  class ConversationConnector {
12198
12483
  constructor() {
12199
12484
  _ConversationConnector_instances.add(this);
@@ -12209,35 +12494,37 @@ class ConversationConnector {
12209
12494
  url: splittedUrl,
12210
12495
  params
12211
12496
  } = split_url_params(this.url);
12212
- if (!this.socket) {
12213
- this.socket = new Socket(splittedUrl, {
12214
- params: assign_default()(assign_default()({}, params), {
12215
- v: apiVersion
12216
- }),
12217
- reconnectAfterMs: tries => {
12218
- // Calculate the backoff time based on the number of tries.
12219
- const backoff = Math.pow(2, tries) * 250;
12220
- // Limit the backoff time to 10 seconds.
12221
- return Math.min(backoff, 10000);
12222
- }
12223
- });
12224
- }
12225
- // Checks if the socket is not already connected before attempting a connection.
12226
- // This prevents multiple connection attempts during server reconnects, network switches or SPA route changes.
12227
- if (!this.socket.isConnected()) {
12228
- this.socket.connect();
12229
- }
12230
- this.channel = this.socket.channel(this.channelTopic, {
12231
- authorization: `Bearer ${this.accessToken}`,
12232
- channelName: this.channelName
12497
+ this.socket = new Socket(splittedUrl, {
12498
+ params: assign_default()(assign_default()({}, params), {
12499
+ v: apiVersion
12500
+ }),
12501
+ reconnectAfterMs: tries => {
12502
+ // Calculate the backoff time based on the number of tries.
12503
+ const backoff = Math.pow(2, tries) * 250;
12504
+ // Limit the backoff time to 10 seconds.
12505
+ return Math.min(backoff, 10000);
12506
+ }
12233
12507
  });
12234
- this.start();
12235
12508
  this.socket.onError(err => {
12236
12509
  log('[SOCKET][ERROR]', err);
12237
12510
  });
12238
12511
  this.socket.onOpen(() => {
12239
12512
  log('[SOCKET]OPEN');
12240
12513
  });
12514
+ this.socket.onClose(() => {
12515
+ log('[SOCKET]CLOSE');
12516
+ __classPrivateFieldGet(this, _ConversationConnector_instances, "m", _ConversationConnector_emitConnectionState).call(this, {
12517
+ connected: false,
12518
+ ready: false,
12519
+ currentState: 'socket_closed'
12520
+ });
12521
+ });
12522
+ this.socket.connect();
12523
+ this.channel = this.socket.channel(this.channelTopic, {
12524
+ authorization: `Bearer ${this.accessToken}`,
12525
+ channelName: this.channelName
12526
+ });
12527
+ this.start();
12241
12528
  this.channel.on('system', msg => {
12242
12529
  switch (msg.type) {
12243
12530
  case 'attach_channel_succeeded':
@@ -12249,14 +12536,6 @@ class ConversationConnector {
12249
12536
  break;
12250
12537
  }
12251
12538
  });
12252
- this.socket.onClose(() => {
12253
- log('[SOCKET]CLOSE');
12254
- __classPrivateFieldGet(this, _ConversationConnector_instances, "m", _ConversationConnector_emitConnectionState).call(this, {
12255
- connected: false,
12256
- ready: false,
12257
- currentState: 'socket_closed'
12258
- });
12259
- });
12260
12539
  this.channel.onClose(() => {
12261
12540
  log('[CHANNEL]CLOSE');
12262
12541
  __classPrivateFieldGet(this, _ConversationConnector_instances, "m", _ConversationConnector_emitConnectionState).call(this, {
@@ -12311,6 +12590,13 @@ class ConversationConnector {
12311
12590
  let timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10000;
12312
12591
  this.channel.push(command, payload, timeout);
12313
12592
  }
12593
+ // Adds a callback function to the subscribers set and returns a method to unsubscribe from the store.
12594
+ // This method is used to sync the state with the lifecycle of Preact.
12595
+ static subscribe(callback) {
12596
+ subscribers.add(callback);
12597
+ // Returns a function that removes the callback from the subscribers set.
12598
+ return () => subscribers.delete(callback);
12599
+ }
12314
12600
  }
12315
12601
  _ConversationConnector_connectionListeners = new (weak_map_default())(), _ConversationConnector_instances = new (weak_set_default())(), _ConversationConnector_listenTo = function _ConversationConnector_listenTo() {
12316
12602
  for (var _len = arguments.length, types = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -12328,6 +12614,7 @@ _ConversationConnector_connectionListeners = new (weak_map_default())(), _Conver
12328
12614
  // If we only want to execute the callback once, remove it from the listener
12329
12615
  return !complete;
12330
12616
  }), "f");
12617
+ emitChange();
12331
12618
  };
12332
12619
  /* harmony default export */ var conversation_connector = (ConversationConnector);
12333
12620
  ;// CONCATENATED MODULE: ./src/javascripts/api/index.ts
@@ -12871,7 +13158,7 @@ _API_ready = new (weak_map_default())(), _API_externalId = new (weak_map_default
12871
13158
  return {
12872
13159
  clientName: "@seamly/web-ui",
12873
13160
  clientVariant: api_classPrivateFieldGet(this, _API_layoutMode, "f"),
12874
- clientVersion: "22.3.3",
13161
+ clientVersion: "22.3.5-beta.1",
12875
13162
  currentUrl: window.location.toString(),
12876
13163
  screenResolution: `${window.screen.width}x${window.screen.height}`,
12877
13164
  timezone: getTimeZone(),
@@ -20423,6 +20710,16 @@ const useSeamlyMessageContainerClassNames = event => {
20423
20710
  }
20424
20711
  return classNames;
20425
20712
  };
20713
+ ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/use-seamly-conversation.ts
20714
+
20715
+
20716
+
20717
+ const useSeamlyConversation = () => {
20718
+ const api = useSeamlyApiContext();
20719
+ const getSnapshot = () => api.conversation;
20720
+ return (0,compat_module.useSyncExternalStore)(conversation_connector.subscribe, getSnapshot);
20721
+ };
20722
+ /* harmony default export */ var use_seamly_conversation = (useSeamlyConversation);
20426
20723
  ;// CONCATENATED MODULE: ./src/javascripts/ui/hooks/focus-helper-hooks.js
20427
20724
 
20428
20725
 
@@ -20880,12 +21177,12 @@ const useStableCallback = callback => {
20880
21177
  // and imported directly from this file
20881
21178
  // Please do not remove
20882
21179
  const useSeamlyEventStream = (nextFn, filterFn) => {
20883
- const api = useSeamlyApiContext();
21180
+ const conversation = use_seamly_conversation();
20884
21181
  (0,hooks_module/* useEffect */.d4)(() => {
20885
- if (api.connectionInfo && api.conversation?.channel) {
21182
+ if (conversation.channel) {
20886
21183
  const {
20887
21184
  channel
20888
- } = api.conversation;
21185
+ } = conversation;
20889
21186
  channel.onMessage = (type, payload) => {
20890
21187
  if (!filterFn || filterFn({
20891
21188
  type,
@@ -20899,7 +21196,7 @@ const useSeamlyEventStream = (nextFn, filterFn) => {
20899
21196
  return payload;
20900
21197
  };
20901
21198
  }
20902
- }, [nextFn, filterFn, api.connectionInfo, api.conversation]);
21199
+ }, [nextFn, filterFn, conversation]);
20903
21200
  };
20904
21201
  ;// CONCATENATED MODULE: ./src/javascripts/domains/translations/selectors.ts
20905
21202
 
@@ -24587,9 +24884,10 @@ var seamly_event_subscriber_rest = undefined && undefined.__rest || function (s,
24587
24884
 
24588
24885
 
24589
24886
 
24887
+
24590
24888
  const EMITTABLE_MESSAGE_TYPES = ['text', 'choice_prompt', 'image', 'video'];
24591
24889
  const SeamlyEventSubscriber = () => {
24592
- const api = useSeamlyApiContext();
24890
+ const conversation = use_seamly_conversation();
24593
24891
  const syncChannelRef = (0,hooks_module/* useRef */.sO)();
24594
24892
  const messageChannelRef = (0,hooks_module/* useRef */.sO)();
24595
24893
  const dispatch = useAppDispatch();
@@ -24603,10 +24901,10 @@ const SeamlyEventSubscriber = () => {
24603
24901
  emitEvent
24604
24902
  } = use_seamly_commands();
24605
24903
  (0,hooks_module/* useEffect */.d4)(() => {
24606
- if (api.connectionInfo && api.conversation.socket) {
24904
+ if (conversation.socket) {
24607
24905
  const {
24608
24906
  socket
24609
- } = api.conversation;
24907
+ } = conversation;
24610
24908
  socket.onError(err => {
24611
24909
  const seamlyOfflineError = new SeamlyOfflineError(err);
24612
24910
  dispatch(setInterrupt({
@@ -24622,10 +24920,10 @@ const SeamlyEventSubscriber = () => {
24622
24920
  dispatch(clearInterrupt());
24623
24921
  });
24624
24922
  }
24625
- }, [api, api.connectionInfo, api.conversation.socket, dispatch]);
24923
+ }, [conversation, dispatch]);
24626
24924
  (0,hooks_module/* useEffect */.d4)(() => {
24627
- if (api.connectionInfo && api.conversation.socket) {
24628
- api.conversation.onConnection(_ref => {
24925
+ if (conversation.socket) {
24926
+ conversation.onConnection(_ref => {
24629
24927
  let {
24630
24928
  currentState
24631
24929
  } = _ref;
@@ -24644,220 +24942,213 @@ const SeamlyEventSubscriber = () => {
24644
24942
  return false;
24645
24943
  });
24646
24944
  }
24647
- }, [api, api.connectionInfo, api.conversation.channel, dispatch]);
24945
+ }, [conversation, dispatch]);
24648
24946
  (0,hooks_module/* useEffect */.d4)(() => {
24649
- if (api.connectionInfo) {
24650
- const updateParticipant = event => {
24651
- if (event.type !== 'participant') {
24652
- return;
24653
- }
24654
- const {
24947
+ const updateParticipant = event => {
24948
+ if (event.type !== 'participant') {
24949
+ return;
24950
+ }
24951
+ const {
24952
+ payload
24953
+ } = event;
24954
+ if (!payload || !payload.participant) {
24955
+ return;
24956
+ }
24957
+ const {
24958
+ fromClient,
24959
+ participant
24960
+ } = payload;
24961
+ if (!fromClient && typeof participant !== 'string' && (participant === null || participant === void 0 ? void 0 : participant.name)) {
24962
+ dispatch(setHeaderSubTitle(participant.name));
24963
+ }
24964
+ dispatch(setParticipant({
24965
+ participant,
24966
+ fromClient
24967
+ }));
24968
+ if (typeof participant !== 'string' && participant.introduction) {
24969
+ dispatch(addEvent(event));
24970
+ }
24971
+ };
24972
+ conversation.onConnection(_ref2 => {
24973
+ let {
24974
+ connected
24975
+ } = _ref2;
24976
+ if (!connected) return false;
24977
+ const {
24978
+ channel
24979
+ } = conversation;
24980
+ channel.onMessage = (type, payload) => {
24981
+ const event = {
24982
+ type,
24655
24983
  payload
24656
- } = event;
24657
- if (!payload || !payload.participant) {
24658
- return;
24659
- }
24660
- const {
24661
- fromClient,
24662
- participant
24663
- } = payload;
24664
- if (!fromClient && typeof participant !== 'string' && (participant === null || participant === void 0 ? void 0 : participant.name)) {
24665
- dispatch(setHeaderSubTitle(participant.name));
24666
- }
24667
- dispatch(setParticipant({
24668
- participant,
24669
- fromClient
24670
- }));
24671
- if (typeof participant !== 'string' && participant.introduction) {
24672
- dispatch(addEvent(event));
24673
- }
24674
- };
24675
- api.conversation.onConnection(_ref2 => {
24676
- let {
24677
- connected
24678
- } = _ref2;
24679
- if (!connected) return false;
24680
- const {
24681
- channel
24682
- } = api.conversation;
24683
- channel.onMessage = (type, payload) => {
24684
- const event = {
24685
- type,
24686
- payload
24687
- };
24688
- switch (type) {
24689
- case 'ui':
24690
- if (payload.state && payload.state.hasOwnProperty('loading')) {
24691
- dispatch(setIsLoading(payload.state.loading));
24692
- }
24693
- switch (payload.type) {
24694
- case 'idle_detach_countdown':
24695
- initCountdown(payload.body.duration);
24696
- break;
24697
- case 'idle_detach_countdown_elapsed':
24698
- endCountdown(undefined, true);
24699
- break;
24700
- case 'resume_conversation_prompt':
24701
- dispatch(initResumeConversationPrompt());
24702
- break;
24703
- case 'translation_proposal':
24704
- dispatch(setTranslationProposalPrompt(payload.body));
24705
- break;
24706
- case 'user_first_response':
24707
- dispatch(setHasResponded(true));
24708
- // @ts-ignore
24709
- eventBus.emit('system.userFirstResponse', payload.body);
24710
- break;
24711
- }
24712
- break;
24713
- case 'message':
24714
- updateParticipant(payload);
24715
- switch (payload.type) {
24716
- case 'text':
24717
- case 'choice_prompt':
24718
- case 'splash':
24719
- case 'image':
24720
- case 'upload':
24721
- case 'video':
24722
- case 'cta':
24723
- case 'custom':
24724
- case 'carousel':
24725
- case 'card':
24726
- if (payload.service && payload.service.serviceSessionId) {
24727
- dispatch(setActiveService(payload.service.serviceSessionId));
24728
- }
24729
- dispatch(addEvent(event));
24730
- break;
24731
- }
24732
- break;
24733
- case 'participant':
24734
- updateParticipant(event);
24735
- break;
24736
- case 'service_data':
24737
- if (payload.persist) {
24738
- dispatch(setServiceDataItem(payload));
24739
- }
24740
- break;
24741
- case 'ack':
24742
- dispatch(ackEvent(event));
24743
- break;
24744
- case 'system':
24745
- if (payload.type === 'service_changed') {
24746
- const {
24747
- serviceSettings
24748
- } = payload,
24749
- eventPayload = seamly_event_subscriber_rest(payload, ["serviceSettings"]);
24750
- const {
24751
- entry,
24752
- proactiveMessages
24753
- } = serviceSettings;
24754
- const {
24755
- upload
24756
- } = entry.options;
24757
- dispatch(setFeatureEnabledState({
24758
- key: featureKeys.uploads,
24759
- enabled: !!(upload && upload.enabled)
24760
- }));
24761
- dispatch(setProactiveMessages(proactiveMessages.enabled || false));
24762
- dispatch(setServiceEntryMetadata(entry));
24763
- if (payload.serviceSessionId) {
24764
- dispatch(setActiveService(payload.serviceSessionId));
24984
+ };
24985
+ switch (type) {
24986
+ case 'ui':
24987
+ if (payload.state && payload.state.hasOwnProperty('loading')) {
24988
+ dispatch(setIsLoading(payload.state.loading));
24989
+ }
24990
+ switch (payload.type) {
24991
+ case 'idle_detach_countdown':
24992
+ initCountdown(payload.body.duration);
24993
+ break;
24994
+ case 'idle_detach_countdown_elapsed':
24995
+ endCountdown(undefined, true);
24996
+ break;
24997
+ case 'resume_conversation_prompt':
24998
+ dispatch(initResumeConversationPrompt());
24999
+ break;
25000
+ case 'translation_proposal':
25001
+ dispatch(setTranslationProposalPrompt(payload.body));
25002
+ break;
25003
+ case 'user_first_response':
25004
+ dispatch(setHasResponded(true));
25005
+ // @ts-ignore
25006
+ eventBus.emit('system.userFirstResponse', payload.body);
25007
+ break;
25008
+ }
25009
+ break;
25010
+ case 'message':
25011
+ updateParticipant(payload);
25012
+ switch (payload.type) {
25013
+ case 'text':
25014
+ case 'choice_prompt':
25015
+ case 'splash':
25016
+ case 'image':
25017
+ case 'upload':
25018
+ case 'video':
25019
+ case 'cta':
25020
+ case 'custom':
25021
+ case 'carousel':
25022
+ case 'card':
25023
+ if (payload.service && payload.service.serviceSessionId) {
25024
+ dispatch(setActiveService(payload.service.serviceSessionId));
24765
25025
  }
24766
- emitEvent('system.serviceChanged', eventPayload);
24767
- }
24768
- break;
24769
- case 'info':
24770
- if (payload.type === 'divider' || payload.type === 'text' || payload.type === 'translation') {
24771
25026
  dispatch(addEvent(event));
25027
+ break;
25028
+ }
25029
+ break;
25030
+ case 'participant':
25031
+ updateParticipant(event);
25032
+ break;
25033
+ case 'service_data':
25034
+ if (payload.persist) {
25035
+ dispatch(setServiceDataItem(payload));
25036
+ }
25037
+ break;
25038
+ case 'ack':
25039
+ dispatch(ackEvent(event));
25040
+ break;
25041
+ case 'system':
25042
+ if (payload.type === 'service_changed') {
25043
+ const {
25044
+ serviceSettings
25045
+ } = payload,
25046
+ eventPayload = seamly_event_subscriber_rest(payload, ["serviceSettings"]);
25047
+ const {
25048
+ entry,
25049
+ proactiveMessages
25050
+ } = serviceSettings;
25051
+ const {
25052
+ upload
25053
+ } = entry.options;
25054
+ dispatch(setFeatureEnabledState({
25055
+ key: featureKeys.uploads,
25056
+ enabled: !!(upload && upload.enabled)
25057
+ }));
25058
+ dispatch(setProactiveMessages(proactiveMessages.enabled || false));
25059
+ dispatch(setServiceEntryMetadata(entry));
25060
+ if (payload.serviceSessionId) {
25061
+ dispatch(setActiveService(payload.serviceSessionId));
24772
25062
  }
24773
- break;
24774
- case 'error':
24775
- switch (payload.type) {
24776
- case 'find_conversation_erred':
24777
- const seamlySessionExpiredError = new SeamlySessionExpiredError(event);
24778
- dispatch(setInterrupt({
24779
- name: seamlySessionExpiredError.name,
24780
- action: seamlySessionExpiredError.action,
24781
- message: seamlySessionExpiredError.message,
24782
- originalEvent: seamlySessionExpiredError.originalEvent,
24783
- originalError: seamlySessionExpiredError.originalError
24784
- }));
24785
- break;
24786
- case 'conversation_erred':
24787
- case 'attach_channel_erred':
24788
- const seamlyGeneralError = new SeamlyGeneralError(event);
24789
- dispatch(setInterrupt({
24790
- name: seamlyGeneralError.name,
24791
- message: seamlyGeneralError.message,
24792
- langKey: seamlyGeneralError.langKey,
24793
- originalEvent: seamlyGeneralError.originalEvent,
24794
- originalError: seamlyGeneralError.originalError,
24795
- action: seamlyGeneralError.action
24796
- }));
24797
- break;
24798
- }
24799
- }
24800
- return payload;
24801
- };
24802
- return false;
24803
- });
24804
- }
24805
- }, [api, api.connectionInfo, api.conversation.channel, dispatch, emitEvent, endCountdown, eventBus, initCountdown]);
24806
- (0,hooks_module/* useEffect */.d4)(() => {
24807
- if (api.connectionInfo) {
24808
- api.conversation.onConnection(_ref3 => {
24809
- let {
24810
- connected
24811
- } = _ref3;
24812
- if (!connected) return false;
24813
- const {
24814
- channel
24815
- } = api.conversation;
24816
- if (messageChannelRef.current) {
24817
- channel === null || channel === void 0 ? void 0 : channel.off('message', messageChannelRef.current);
25063
+ emitEvent('system.serviceChanged', eventPayload);
25064
+ }
25065
+ break;
25066
+ case 'info':
25067
+ if (payload.type === 'divider' || payload.type === 'text' || payload.type === 'translation') {
25068
+ dispatch(addEvent(event));
25069
+ }
25070
+ break;
25071
+ case 'error':
25072
+ switch (payload.type) {
25073
+ case 'find_conversation_erred':
25074
+ const seamlySessionExpiredError = new SeamlySessionExpiredError(event);
25075
+ dispatch(setInterrupt({
25076
+ name: seamlySessionExpiredError.name,
25077
+ action: seamlySessionExpiredError.action,
25078
+ message: seamlySessionExpiredError.message,
25079
+ originalEvent: seamlySessionExpiredError.originalEvent,
25080
+ originalError: seamlySessionExpiredError.originalError
25081
+ }));
25082
+ break;
25083
+ case 'conversation_erred':
25084
+ case 'attach_channel_erred':
25085
+ const seamlyGeneralError = new SeamlyGeneralError(event);
25086
+ dispatch(setInterrupt({
25087
+ name: seamlyGeneralError.name,
25088
+ message: seamlyGeneralError.message,
25089
+ langKey: seamlyGeneralError.langKey,
25090
+ originalEvent: seamlyGeneralError.originalEvent,
25091
+ originalError: seamlyGeneralError.originalError,
25092
+ action: seamlyGeneralError.action
25093
+ }));
25094
+ break;
25095
+ }
24818
25096
  }
24819
- messageChannelRef.current = channel.on('message', payload => {
24820
- if (!includes_default()(EMITTABLE_MESSAGE_TYPES).call(EMITTABLE_MESSAGE_TYPES, payload.type)) {
24821
- return payload;
24822
- }
24823
- // This check dedupes the sending of messages via
24824
- // the bus if a duplicate connection exists in an
24825
- // error situation.
24826
- if (payload.id !== prevEmittedEventId.current) {
24827
- // @ts-ignore
24828
- eventBus.emit('message', payload);
24829
- }
24830
- prevEmittedEventId.current = payload.id;
25097
+ return payload;
25098
+ };
25099
+ return false;
25100
+ });
25101
+ }, [conversation, dispatch, emitEvent, endCountdown, eventBus, initCountdown]);
25102
+ (0,hooks_module/* useEffect */.d4)(() => {
25103
+ conversation.onConnection(_ref3 => {
25104
+ let {
25105
+ connected
25106
+ } = _ref3;
25107
+ if (!connected) return false;
25108
+ const {
25109
+ channel
25110
+ } = conversation;
25111
+ if (messageChannelRef.current) {
25112
+ channel.off('message', messageChannelRef.current);
25113
+ }
25114
+ messageChannelRef.current = channel.on('message', payload => {
25115
+ if (!includes_default()(EMITTABLE_MESSAGE_TYPES).call(EMITTABLE_MESSAGE_TYPES, payload.type)) {
24831
25116
  return payload;
24832
- });
24833
- return true;
25117
+ }
25118
+ // This check dedupes the sending of messages via
25119
+ // the bus if a duplicate connection exists in an
25120
+ // error situation.
25121
+ if (payload.id !== prevEmittedEventId.current) {
25122
+ // @ts-ignore
25123
+ eventBus.emit('message', payload);
25124
+ }
25125
+ prevEmittedEventId.current = payload.id;
25126
+ return payload;
24834
25127
  });
24835
- }
24836
- }, [api, api.connectionInfo, api.conversation.channel, eventBus]);
25128
+ return true;
25129
+ });
25130
+ }, [conversation, eventBus]);
24837
25131
  (0,hooks_module/* useEffect */.d4)(() => {
24838
- if (api.connectionInfo) {
24839
- api.conversation.onConnection(_ref4 => {
24840
- let {
24841
- connected
24842
- } = _ref4;
24843
- var _a;
24844
- if (!connected) return false;
24845
- if (syncChannelRef.current) {
24846
- (_a = api.conversation.channel) === null || _a === void 0 ? void 0 : _a.off('sync', syncChannelRef.current);
25132
+ conversation.onConnection(_ref4 => {
25133
+ let {
25134
+ connected
25135
+ } = _ref4;
25136
+ if (!connected) return false;
25137
+ if (syncChannelRef.current) {
25138
+ conversation.channel.off('sync', syncChannelRef.current);
25139
+ }
25140
+ syncChannelRef.current = conversation.channel.on('sync', payload => seamly_event_subscriber_awaiter(void 0, void 0, void 0, function* () {
25141
+ try {
25142
+ const history = yield dispatch(getConversation(payload)).unwrap();
25143
+ if (!history) return;
25144
+ dispatch(setHistory(history));
25145
+ } catch (_e) {
25146
+ // nothing to do, the error is handled in the thunk
24847
25147
  }
24848
- syncChannelRef.current = api.conversation.channel.on('sync', payload => seamly_event_subscriber_awaiter(void 0, void 0, void 0, function* () {
24849
- try {
24850
- const history = yield dispatch(getConversation(payload)).unwrap();
24851
- if (!history) return;
24852
- dispatch(setHistory(history));
24853
- } catch (_e) {
24854
- // nothing to do, the error is handled in the thunk
24855
- }
24856
- }));
24857
- return true;
24858
- });
24859
- }
24860
- }, [api, api.connectionInfo, api.conversation.channel, dispatch]);
25148
+ }));
25149
+ return true;
25150
+ });
25151
+ }, [conversation, dispatch]);
24861
25152
  return null;
24862
25153
  };
24863
25154
  /* harmony default export */ var seamly_event_subscriber = (SeamlyEventSubscriber);
@@ -28640,7 +28931,7 @@ const useNotification = () => {
28640
28931
  const [visibilityState, setVisibilityState] = (0,hooks_module/* useState */.eJ)(document.visibilityState);
28641
28932
  const showNotifications = useSelector_useSelector(selectShowNotifications);
28642
28933
  const requestPermission = (0,hooks_module/* useCallback */.I4)(() => use_notifications_awaiter(void 0, void 0, void 0, function* () {
28643
- if (Notification && permission !== 'granted') {
28934
+ if (hasNotificationSupport && permission !== 'granted') {
28644
28935
  const notificationPermission = yield Notification.requestPermission();
28645
28936
  setPermission(notificationPermission);
28646
28937
  }