@hellotext/hellotext 2.5.7 → 2.5.8

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 (102) hide show
  1. package/README.md +0 -25
  2. package/dist/hellotext.js +1 -1
  3. package/index.d.ts +0 -6
  4. package/lib/api/acks.cjs +17 -31
  5. package/lib/api/acks.js +17 -42
  6. package/lib/api/businesses.cjs +14 -28
  7. package/lib/api/businesses.js +13 -36
  8. package/lib/api/events.cjs +26 -40
  9. package/lib/api/events.js +28 -52
  10. package/lib/api/forms.cjs +24 -40
  11. package/lib/api/forms.js +24 -57
  12. package/lib/api/identifications.cjs +15 -29
  13. package/lib/api/identifications.js +15 -40
  14. package/lib/api/index.cjs +25 -51
  15. package/lib/api/index.js +27 -54
  16. package/lib/api/push/identities.cjs +30 -46
  17. package/lib/api/push/identities.js +30 -63
  18. package/lib/api/response.cjs +30 -52
  19. package/lib/api/response.js +31 -60
  20. package/lib/api/submissions.cjs +18 -34
  21. package/lib/api/submissions.js +18 -48
  22. package/lib/api/webchat/messages.cjs +44 -64
  23. package/lib/api/webchat/messages.js +44 -80
  24. package/lib/api/webchats.cjs +37 -56
  25. package/lib/api/webchats.js +37 -65
  26. package/lib/api/whatsapp_widgets.cjs +49 -72
  27. package/lib/api/whatsapp_widgets.js +48 -91
  28. package/lib/builders/input_builder.cjs +36 -48
  29. package/lib/builders/input_builder.js +36 -48
  30. package/lib/builders/logo_builder.cjs +10 -29
  31. package/lib/builders/logo_builder.js +20 -28
  32. package/lib/channels/application_channel.cjs +136 -178
  33. package/lib/channels/application_channel.js +137 -180
  34. package/lib/channels/webchat_channel.cjs +125 -170
  35. package/lib/channels/webchat_channel.js +125 -170
  36. package/lib/controllers/form_controller.cjs +82 -121
  37. package/lib/controllers/form_controller.js +82 -130
  38. package/lib/controllers/message_controller.cjs +211 -282
  39. package/lib/controllers/message_controller.js +209 -284
  40. package/lib/controllers/mixins/usePopover.cjs +3 -6
  41. package/lib/controllers/mixins/usePopover.js +17 -22
  42. package/lib/controllers/webchat/emoji_picker_controller.cjs +106 -150
  43. package/lib/controllers/webchat/emoji_picker_controller.js +105 -170
  44. package/lib/controllers/webchat/useBehaviour.js +5 -5
  45. package/lib/controllers/webchat/useOpeningSequence.js +6 -6
  46. package/lib/controllers/webchat/useTeaser.js +9 -9
  47. package/lib/controllers/webchat_controller.cjs +916 -1088
  48. package/lib/controllers/webchat_controller.js +926 -1152
  49. package/lib/core/configuration/forms.cjs +21 -35
  50. package/lib/core/configuration/forms.js +20 -35
  51. package/lib/core/configuration/locale.cjs +36 -71
  52. package/lib/core/configuration/locale.js +36 -70
  53. package/lib/core/configuration/push.cjs +9 -21
  54. package/lib/core/configuration/push.js +8 -20
  55. package/lib/core/configuration/webchat.cjs +142 -182
  56. package/lib/core/configuration/webchat.js +145 -189
  57. package/lib/core/configuration/whatsapp.cjs +76 -102
  58. package/lib/core/configuration/whatsapp.js +76 -105
  59. package/lib/core/configuration.cjs +60 -78
  60. package/lib/core/configuration.js +59 -78
  61. package/lib/core/event.cjs +36 -59
  62. package/lib/core/event.js +35 -61
  63. package/lib/core/sanitize_html.js +4 -4
  64. package/lib/errors/invalid_event.cjs +5 -26
  65. package/lib/errors/invalid_event.js +5 -26
  66. package/lib/errors/not_initialized_error.cjs +5 -26
  67. package/lib/errors/not_initialized_error.js +5 -26
  68. package/lib/hellotext.cjs +185 -223
  69. package/lib/hellotext.js +188 -247
  70. package/lib/index.js +1 -1
  71. package/lib/models/business.cjs +114 -152
  72. package/lib/models/business.js +117 -162
  73. package/lib/models/cookies.cjs +34 -51
  74. package/lib/models/cookies.js +34 -51
  75. package/lib/models/fingerprint.cjs +8 -23
  76. package/lib/models/fingerprint.js +25 -58
  77. package/lib/models/form.cjs +106 -142
  78. package/lib/models/form.js +105 -153
  79. package/lib/models/form_collection.cjs +63 -101
  80. package/lib/models/form_collection.js +61 -107
  81. package/lib/models/page.cjs +106 -129
  82. package/lib/models/page.js +106 -131
  83. package/lib/models/push.cjs +278 -322
  84. package/lib/models/push.js +284 -357
  85. package/lib/models/query.cjs +21 -41
  86. package/lib/models/query.js +21 -41
  87. package/lib/models/session.cjs +33 -65
  88. package/lib/models/session.js +30 -63
  89. package/lib/models/user.cjs +29 -51
  90. package/lib/models/user.js +29 -51
  91. package/lib/models/utm.cjs +15 -27
  92. package/lib/models/utm.js +17 -32
  93. package/lib/models/webchat.cjs +52 -76
  94. package/lib/models/webchat.js +52 -90
  95. package/lib/models/whatsapp_widget.cjs +41 -59
  96. package/lib/models/whatsapp_widget.js +41 -73
  97. package/lib/vanilla.cjs +4 -7
  98. package/lib/vanilla.js +2 -1
  99. package/package.json +1 -9
  100. package/src/index.bundle.js +0 -1
  101. package/src/vanilla.js +2 -1
  102. package/styles/index.css +0 -30
@@ -1,45 +1,20 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
5
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
8
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
9
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
10
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
11
1
  import Hellotext from '../hellotext';
12
2
  import { Configuration } from '../core';
13
3
  import { Response } from './response';
14
- var IdentificationsAPI = /*#__PURE__*/function () {
15
- function IdentificationsAPI() {
16
- _classCallCheck(this, IdentificationsAPI);
4
+ class IdentificationsAPI {
5
+ static get endpoint() {
6
+ return Configuration.endpoint('public/identifications');
17
7
  }
18
- _createClass(IdentificationsAPI, null, [{
19
- key: "endpoint",
20
- get: function get() {
21
- return Configuration.endpoint('public/identifications');
22
- }
23
- }, {
24
- key: "create",
25
- value: function () {
26
- var _create = _asyncToGenerator(function* () {
27
- var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
28
- var response = yield fetch(this.endpoint, {
29
- method: 'POST',
30
- headers: Hellotext.headers,
31
- body: JSON.stringify(_objectSpread({
32
- session: Hellotext.session
33
- }, data))
34
- });
35
- return new Response(response.ok, response);
36
- });
37
- function create() {
38
- return _create.apply(this, arguments);
39
- }
40
- return create;
41
- }()
42
- }]);
43
- return IdentificationsAPI;
44
- }();
8
+ static async create(data = {}) {
9
+ const response = await fetch(this.endpoint, {
10
+ method: 'POST',
11
+ headers: Hellotext.headers,
12
+ body: JSON.stringify({
13
+ session: Hellotext.session,
14
+ ...data
15
+ })
16
+ });
17
+ return new Response(response.ok, response);
18
+ }
19
+ }
45
20
  export default IdentificationsAPI;
package/lib/api/index.cjs CHANGED
@@ -21,11 +21,6 @@ var _acks = _interopRequireDefault(require("./acks"));
21
21
  var _identities = _interopRequireDefault(require("./push/identities"));
22
22
  var _response = require("./response");
23
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
26
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
27
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
28
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
29
24
  // Browsers keep `fetch(..., { keepalive: true })` requests alive during page
30
25
  // unload/navigation, which is exactly the failure mode for analytics events
31
26
  // fired from checkout redirects, form submissions, tab closes, and pixel
@@ -46,51 +41,30 @@ function keepaliveFor(body) {
46
41
  }
47
42
  return new Blob([serializedBody]).size < KEEPALIVE_BODY_LIMIT;
48
43
  }
49
- let API = /*#__PURE__*/function () {
50
- function API() {
51
- _classCallCheck(this, API);
44
+ class API {
45
+ static get businesses() {
46
+ return _businesses.default;
52
47
  }
53
- _createClass(API, null, [{
54
- key: "businesses",
55
- get: function () {
56
- return _businesses.default;
57
- }
58
- }, {
59
- key: "events",
60
- get: function () {
61
- return _events.default;
62
- }
63
- }, {
64
- key: "forms",
65
- get: function () {
66
- return _forms.default;
67
- }
68
- }, {
69
- key: "webchats",
70
- get: function () {
71
- return _webchats.default;
72
- }
73
- }, {
74
- key: "whatsappWidgets",
75
- get: function () {
76
- return _whatsapp_widgets.default;
77
- }
78
- }, {
79
- key: "identifications",
80
- get: function () {
81
- return _identifications.default;
82
- }
83
- }, {
84
- key: "acks",
85
- get: function () {
86
- return _acks.default;
87
- }
88
- }, {
89
- key: "pushIdentities",
90
- get: function () {
91
- return _identities.default;
92
- }
93
- }]);
94
- return API;
95
- }();
48
+ static get events() {
49
+ return _events.default;
50
+ }
51
+ static get forms() {
52
+ return _forms.default;
53
+ }
54
+ static get webchats() {
55
+ return _webchats.default;
56
+ }
57
+ static get whatsappWidgets() {
58
+ return _whatsapp_widgets.default;
59
+ }
60
+ static get identifications() {
61
+ return _identifications.default;
62
+ }
63
+ static get acks() {
64
+ return _acks.default;
65
+ }
66
+ static get pushIdentities() {
67
+ return _identities.default;
68
+ }
69
+ }
96
70
  exports.default = API;
package/lib/api/index.js CHANGED
@@ -1,8 +1,3 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
1
  import BusinessesAPI from './businesses';
7
2
  import EventsAPI from './events';
8
3
  import FormsAPI from './forms';
@@ -19,9 +14,9 @@ import PushIdentitiesAPI from './push/identities';
19
14
  // browsers can reject or drop oversized requests instead of making delivery
20
15
  // more reliable. Keep the limit below that ceiling so the SDK only opts in when
21
16
  // the payload is small enough for the keepalive transport contract.
22
- var KEEPALIVE_BODY_LIMIT = 60000;
17
+ const KEEPALIVE_BODY_LIMIT = 60000;
23
18
  function keepaliveFor(body) {
24
- var serializedBody = JSON.stringify(body);
19
+ const serializedBody = JSON.stringify(body);
25
20
 
26
21
  // Use byte size when the runtime exposes Blob because non-ASCII JSON can be
27
22
  // larger on the wire than its JavaScript string length. The string-length
@@ -32,53 +27,31 @@ function keepaliveFor(body) {
32
27
  }
33
28
  return new Blob([serializedBody]).size < KEEPALIVE_BODY_LIMIT;
34
29
  }
35
- var API = /*#__PURE__*/function () {
36
- function API() {
37
- _classCallCheck(this, API);
30
+ export default class API {
31
+ static get businesses() {
32
+ return BusinessesAPI;
38
33
  }
39
- _createClass(API, null, [{
40
- key: "businesses",
41
- get: function get() {
42
- return BusinessesAPI;
43
- }
44
- }, {
45
- key: "events",
46
- get: function get() {
47
- return EventsAPI;
48
- }
49
- }, {
50
- key: "forms",
51
- get: function get() {
52
- return FormsAPI;
53
- }
54
- }, {
55
- key: "webchats",
56
- get: function get() {
57
- return WebchatsAPI;
58
- }
59
- }, {
60
- key: "whatsappWidgets",
61
- get: function get() {
62
- return WhatsAppWidgetsAPI;
63
- }
64
- }, {
65
- key: "identifications",
66
- get: function get() {
67
- return IdentificationsAPI;
68
- }
69
- }, {
70
- key: "acks",
71
- get: function get() {
72
- return AcksAPI;
73
- }
74
- }, {
75
- key: "pushIdentities",
76
- get: function get() {
77
- return PushIdentitiesAPI;
78
- }
79
- }]);
80
- return API;
81
- }();
82
- export { API as default };
34
+ static get events() {
35
+ return EventsAPI;
36
+ }
37
+ static get forms() {
38
+ return FormsAPI;
39
+ }
40
+ static get webchats() {
41
+ return WebchatsAPI;
42
+ }
43
+ static get whatsappWidgets() {
44
+ return WhatsAppWidgetsAPI;
45
+ }
46
+ static get identifications() {
47
+ return IdentificationsAPI;
48
+ }
49
+ static get acks() {
50
+ return AcksAPI;
51
+ }
52
+ static get pushIdentities() {
53
+ return PushIdentitiesAPI;
54
+ }
55
+ }
83
56
  export { Response } from './response';
84
57
  export { keepaliveFor };
@@ -8,52 +8,36 @@ var _hellotext = _interopRequireDefault(require("../../hellotext"));
8
8
  var _core = require("../../core");
9
9
  var _response = require("../response");
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
13
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
- let PushIdentitiesAPI = /*#__PURE__*/function () {
17
- function PushIdentitiesAPI() {
18
- _classCallCheck(this, PushIdentitiesAPI);
11
+ class PushIdentitiesAPI {
12
+ static get endpoint() {
13
+ return _core.Configuration.endpoint('public/push/identities');
19
14
  }
20
- _createClass(PushIdentitiesAPI, null, [{
21
- key: "endpoint",
22
- get: function () {
23
- return _core.Configuration.endpoint('public/push/identities');
24
- }
25
- }, {
26
- key: "create",
27
- value: async function create(data = {}) {
28
- const response = await fetch(this.endpoint, {
29
- method: 'POST',
30
- keepalive: true,
31
- headers: _hellotext.default.headers,
32
- body: JSON.stringify({
33
- ...data,
34
- session: _hellotext.default.session,
35
- origin: window.location.origin
36
- })
37
- });
38
- return new _response.Response(response.ok, response);
39
- }
40
- }, {
41
- key: "destroy",
42
- value: async function destroy(data = {}) {
43
- const response = await fetch(this.endpoint, {
44
- method: 'DELETE',
45
- keepalive: true,
46
- headers: _hellotext.default.headers,
47
- body: JSON.stringify({
48
- ...data,
49
- session: _hellotext.default.session,
50
- origin: window.location.origin
51
- })
52
- });
53
- return new _response.Response(response.ok, response);
54
- }
55
- }]);
56
- return PushIdentitiesAPI;
57
- }();
15
+ static async create(data = {}) {
16
+ const response = await fetch(this.endpoint, {
17
+ method: 'POST',
18
+ keepalive: true,
19
+ headers: _hellotext.default.headers,
20
+ body: JSON.stringify({
21
+ ...data,
22
+ session: _hellotext.default.session,
23
+ origin: window.location.origin
24
+ })
25
+ });
26
+ return new _response.Response(response.ok, response);
27
+ }
28
+ static async destroy(data = {}) {
29
+ const response = await fetch(this.endpoint, {
30
+ method: 'DELETE',
31
+ keepalive: true,
32
+ headers: _hellotext.default.headers,
33
+ body: JSON.stringify({
34
+ ...data,
35
+ session: _hellotext.default.session,
36
+ origin: window.location.origin
37
+ })
38
+ });
39
+ return new _response.Response(response.ok, response);
40
+ }
41
+ }
58
42
  var _default = PushIdentitiesAPI;
59
43
  exports.default = _default;
@@ -1,68 +1,35 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
5
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
8
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
9
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
10
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
11
1
  import Hellotext from '../../hellotext';
12
2
  import { Configuration } from '../../core';
13
3
  import { Response } from '../response';
14
- var PushIdentitiesAPI = /*#__PURE__*/function () {
15
- function PushIdentitiesAPI() {
16
- _classCallCheck(this, PushIdentitiesAPI);
4
+ class PushIdentitiesAPI {
5
+ static get endpoint() {
6
+ return Configuration.endpoint('public/push/identities');
17
7
  }
18
- _createClass(PushIdentitiesAPI, null, [{
19
- key: "endpoint",
20
- get: function get() {
21
- return Configuration.endpoint('public/push/identities');
22
- }
23
- }, {
24
- key: "create",
25
- value: function () {
26
- var _create = _asyncToGenerator(function* () {
27
- var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
28
- var response = yield fetch(this.endpoint, {
29
- method: 'POST',
30
- keepalive: true,
31
- headers: Hellotext.headers,
32
- body: JSON.stringify(_objectSpread(_objectSpread({}, data), {}, {
33
- session: Hellotext.session,
34
- origin: window.location.origin
35
- }))
36
- });
37
- return new Response(response.ok, response);
38
- });
39
- function create() {
40
- return _create.apply(this, arguments);
41
- }
42
- return create;
43
- }()
44
- }, {
45
- key: "destroy",
46
- value: function () {
47
- var _destroy = _asyncToGenerator(function* () {
48
- var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
49
- var response = yield fetch(this.endpoint, {
50
- method: 'DELETE',
51
- keepalive: true,
52
- headers: Hellotext.headers,
53
- body: JSON.stringify(_objectSpread(_objectSpread({}, data), {}, {
54
- session: Hellotext.session,
55
- origin: window.location.origin
56
- }))
57
- });
58
- return new Response(response.ok, response);
59
- });
60
- function destroy() {
61
- return _destroy.apply(this, arguments);
62
- }
63
- return destroy;
64
- }()
65
- }]);
66
- return PushIdentitiesAPI;
67
- }();
8
+ static async create(data = {}) {
9
+ const response = await fetch(this.endpoint, {
10
+ method: 'POST',
11
+ keepalive: true,
12
+ headers: Hellotext.headers,
13
+ body: JSON.stringify({
14
+ ...data,
15
+ session: Hellotext.session,
16
+ origin: window.location.origin
17
+ })
18
+ });
19
+ return new Response(response.ok, response);
20
+ }
21
+ static async destroy(data = {}) {
22
+ const response = await fetch(this.endpoint, {
23
+ method: 'DELETE',
24
+ keepalive: true,
25
+ headers: Hellotext.headers,
26
+ body: JSON.stringify({
27
+ ...data,
28
+ session: Hellotext.session,
29
+ origin: window.location.origin
30
+ })
31
+ });
32
+ return new Response(response.ok, response);
33
+ }
34
+ }
68
35
  export default PushIdentitiesAPI;
@@ -4,15 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Response = void 0;
7
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
- function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
13
- var id = 0;
14
- function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
15
- var _success = /*#__PURE__*/_classPrivateFieldLooseKey("success");
16
7
  /**
17
8
  * Response class
18
9
  * @class
@@ -20,57 +11,44 @@ var _success = /*#__PURE__*/_classPrivateFieldLooseKey("success");
20
11
  * @property {Boolean} succeeded
21
12
  * @property {Object} data
22
13
  */
23
- let Response = /*#__PURE__*/function () {
24
- function Response(success, response) {
25
- _classCallCheck(this, Response);
26
- Object.defineProperty(this, _success, {
27
- writable: true,
28
- value: void 0
29
- });
14
+
15
+ class Response {
16
+ #success;
17
+ constructor(success, response) {
30
18
  this.response = response;
31
- _classPrivateFieldLooseBase(this, _success)[_success] = success;
19
+ this.#success = success;
32
20
  }
33
21
 
34
22
  /**
35
23
  * Get the response data
36
24
  * @returns {*}
37
25
  */
38
- _createClass(Response, [{
39
- key: "data",
40
- get: function () {
41
- return this.response;
42
- }
26
+ get data() {
27
+ return this.response;
28
+ }
43
29
 
44
- /**
45
- * Parse the response as JSON
46
- * @returns {Promise<*>}
47
- */
48
- }, {
49
- key: "json",
50
- value: async function json() {
51
- return await this.response.json();
52
- }
30
+ /**
31
+ * Parse the response as JSON
32
+ * @returns {Promise<*>}
33
+ */
34
+ async json() {
35
+ return await this.response.json();
36
+ }
53
37
 
54
- /**
55
- * Has the request failed?
56
- * @returns {boolean}
57
- */
58
- }, {
59
- key: "failed",
60
- get: function () {
61
- return _classPrivateFieldLooseBase(this, _success)[_success] === false;
62
- }
38
+ /**
39
+ * Has the request failed?
40
+ * @returns {boolean}
41
+ */
42
+ get failed() {
43
+ return this.#success === false;
44
+ }
63
45
 
64
- /**
65
- * Has the request succeeded?
66
- * @returns {boolean}
67
- */
68
- }, {
69
- key: "succeeded",
70
- get: function () {
71
- return _classPrivateFieldLooseBase(this, _success)[_success] === true;
72
- }
73
- }]);
74
- return Response;
75
- }();
46
+ /**
47
+ * Has the request succeeded?
48
+ * @returns {boolean}
49
+ */
50
+ get succeeded() {
51
+ return this.#success === true;
52
+ }
53
+ }
76
54
  exports.Response = Response;
@@ -1,14 +1,3 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
5
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
7
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
- function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
9
- var id = 0;
10
- function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
11
- var _success = /*#__PURE__*/_classPrivateFieldLooseKey("success");
12
1
  /**
13
2
  * Response class
14
3
  * @class
@@ -16,62 +5,44 @@ var _success = /*#__PURE__*/_classPrivateFieldLooseKey("success");
16
5
  * @property {Boolean} succeeded
17
6
  * @property {Object} data
18
7
  */
19
- var Response = /*#__PURE__*/function () {
20
- function Response(success, response) {
21
- _classCallCheck(this, Response);
22
- Object.defineProperty(this, _success, {
23
- writable: true,
24
- value: void 0
25
- });
8
+
9
+ class Response {
10
+ #success;
11
+ constructor(success, response) {
26
12
  this.response = response;
27
- _classPrivateFieldLooseBase(this, _success)[_success] = success;
13
+ this.#success = success;
28
14
  }
29
15
 
30
16
  /**
31
17
  * Get the response data
32
18
  * @returns {*}
33
19
  */
34
- _createClass(Response, [{
35
- key: "data",
36
- get: function get() {
37
- return this.response;
38
- }
20
+ get data() {
21
+ return this.response;
22
+ }
23
+
24
+ /**
25
+ * Parse the response as JSON
26
+ * @returns {Promise<*>}
27
+ */
28
+ async json() {
29
+ return await this.response.json();
30
+ }
39
31
 
40
- /**
41
- * Parse the response as JSON
42
- * @returns {Promise<*>}
43
- */
44
- }, {
45
- key: "json",
46
- value: function () {
47
- var _json = _asyncToGenerator(function* () {
48
- return yield this.response.json();
49
- });
50
- function json() {
51
- return _json.apply(this, arguments);
52
- }
53
- return json;
54
- }()
55
- /**
56
- * Has the request failed?
57
- * @returns {boolean}
58
- */
59
- }, {
60
- key: "failed",
61
- get: function get() {
62
- return _classPrivateFieldLooseBase(this, _success)[_success] === false;
63
- }
32
+ /**
33
+ * Has the request failed?
34
+ * @returns {boolean}
35
+ */
36
+ get failed() {
37
+ return this.#success === false;
38
+ }
64
39
 
65
- /**
66
- * Has the request succeeded?
67
- * @returns {boolean}
68
- */
69
- }, {
70
- key: "succeeded",
71
- get: function get() {
72
- return _classPrivateFieldLooseBase(this, _success)[_success] === true;
73
- }
74
- }]);
75
- return Response;
76
- }();
40
+ /**
41
+ * Has the request succeeded?
42
+ * @returns {boolean}
43
+ */
44
+ get succeeded() {
45
+ return this.#success === true;
46
+ }
47
+ }
77
48
  export { Response };