@hellotext/hellotext 2.5.6 → 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 (113) hide show
  1. package/README.md +5 -26
  2. package/dist/hellotext.js +1 -1
  3. package/dist/hellotext.js.LICENSE.txt +1 -1
  4. package/index.d.ts +15 -6
  5. package/lib/api/acks.cjs +17 -31
  6. package/lib/api/acks.js +17 -42
  7. package/lib/api/businesses.cjs +14 -28
  8. package/lib/api/businesses.js +13 -36
  9. package/lib/api/events.cjs +26 -40
  10. package/lib/api/events.js +28 -52
  11. package/lib/api/forms.cjs +24 -40
  12. package/lib/api/forms.js +24 -57
  13. package/lib/api/identifications.cjs +15 -29
  14. package/lib/api/identifications.js +15 -40
  15. package/lib/api/index.cjs +26 -46
  16. package/lib/api/index.js +28 -49
  17. package/lib/api/push/identities.cjs +43 -0
  18. package/lib/api/push/identities.js +35 -0
  19. package/lib/api/response.cjs +30 -52
  20. package/lib/api/response.js +31 -60
  21. package/lib/api/submissions.cjs +18 -34
  22. package/lib/api/submissions.js +18 -48
  23. package/lib/api/webchat/messages.cjs +44 -64
  24. package/lib/api/webchat/messages.js +44 -80
  25. package/lib/api/webchats.cjs +37 -56
  26. package/lib/api/webchats.js +37 -65
  27. package/lib/api/whatsapp_widgets.cjs +49 -72
  28. package/lib/api/whatsapp_widgets.js +48 -91
  29. package/lib/builders/input_builder.cjs +36 -48
  30. package/lib/builders/input_builder.js +36 -48
  31. package/lib/builders/logo_builder.cjs +10 -29
  32. package/lib/builders/logo_builder.js +20 -28
  33. package/lib/channels/application_channel.cjs +136 -178
  34. package/lib/channels/application_channel.js +137 -180
  35. package/lib/channels/webchat_channel.cjs +125 -170
  36. package/lib/channels/webchat_channel.js +125 -170
  37. package/lib/controllers/form_controller.cjs +82 -121
  38. package/lib/controllers/form_controller.js +82 -130
  39. package/lib/controllers/message_controller.cjs +211 -282
  40. package/lib/controllers/message_controller.js +209 -284
  41. package/lib/controllers/mixins/usePopover.cjs +3 -6
  42. package/lib/controllers/mixins/usePopover.js +17 -22
  43. package/lib/controllers/webchat/emoji_picker_controller.cjs +106 -150
  44. package/lib/controllers/webchat/emoji_picker_controller.js +105 -170
  45. package/lib/controllers/webchat/useBehaviour.js +5 -5
  46. package/lib/controllers/webchat/useOpeningSequence.js +6 -6
  47. package/lib/controllers/webchat/useTeaser.js +9 -9
  48. package/lib/controllers/webchat_controller.cjs +916 -1088
  49. package/lib/controllers/webchat_controller.js +926 -1152
  50. package/lib/core/configuration/forms.cjs +21 -35
  51. package/lib/core/configuration/forms.js +20 -35
  52. package/lib/core/configuration/locale.cjs +36 -71
  53. package/lib/core/configuration/locale.js +36 -70
  54. package/lib/core/configuration/push.cjs +16 -0
  55. package/lib/core/configuration/push.js +10 -0
  56. package/lib/core/configuration/webchat.cjs +142 -182
  57. package/lib/core/configuration/webchat.js +145 -189
  58. package/lib/core/configuration/whatsapp.cjs +76 -102
  59. package/lib/core/configuration/whatsapp.js +76 -105
  60. package/lib/core/configuration.cjs +62 -75
  61. package/lib/core/configuration.js +61 -75
  62. package/lib/core/event.cjs +36 -59
  63. package/lib/core/event.js +35 -61
  64. package/lib/core/sanitize_html.js +4 -4
  65. package/lib/errors/invalid_event.cjs +5 -26
  66. package/lib/errors/invalid_event.js +5 -26
  67. package/lib/errors/not_initialized_error.cjs +5 -26
  68. package/lib/errors/not_initialized_error.js +5 -26
  69. package/lib/hellotext.cjs +186 -211
  70. package/lib/hellotext.js +189 -236
  71. package/lib/index.js +1 -1
  72. package/lib/models/business.cjs +115 -152
  73. package/lib/models/business.js +118 -162
  74. package/lib/models/cookies.cjs +34 -51
  75. package/lib/models/cookies.js +34 -51
  76. package/lib/models/fingerprint.cjs +8 -23
  77. package/lib/models/fingerprint.js +25 -58
  78. package/lib/models/form.cjs +106 -142
  79. package/lib/models/form.js +105 -153
  80. package/lib/models/form_collection.cjs +63 -101
  81. package/lib/models/form_collection.js +61 -107
  82. package/lib/models/index.cjs +7 -0
  83. package/lib/models/index.js +1 -0
  84. package/lib/models/page.cjs +106 -129
  85. package/lib/models/page.js +106 -131
  86. package/lib/models/push.cjs +345 -0
  87. package/lib/models/push.js +339 -0
  88. package/lib/models/query.cjs +21 -41
  89. package/lib/models/query.js +21 -41
  90. package/lib/models/session.cjs +33 -65
  91. package/lib/models/session.js +30 -63
  92. package/lib/models/user.cjs +29 -51
  93. package/lib/models/user.js +29 -51
  94. package/lib/models/utm.cjs +15 -27
  95. package/lib/models/utm.js +17 -32
  96. package/lib/models/webchat.cjs +52 -76
  97. package/lib/models/webchat.js +52 -90
  98. package/lib/models/whatsapp_widget.cjs +41 -59
  99. package/lib/models/whatsapp_widget.js +41 -73
  100. package/lib/vanilla.cjs +4 -7
  101. package/lib/vanilla.js +2 -1
  102. package/package.json +2 -10
  103. package/src/api/index.js +5 -0
  104. package/src/api/push/identities.js +42 -0
  105. package/src/core/configuration/push.js +12 -0
  106. package/src/core/configuration.js +5 -0
  107. package/src/hellotext.js +15 -1
  108. package/src/index.bundle.js +0 -1
  109. package/src/models/business.js +1 -0
  110. package/src/models/index.js +1 -0
  111. package/src/models/push.js +397 -0
  112. package/src/vanilla.js +2 -1
  113. package/styles/index.css +0 -30
@@ -8,35 +8,21 @@ 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 IdentificationsAPI = /*#__PURE__*/function () {
17
- function IdentificationsAPI() {
18
- _classCallCheck(this, IdentificationsAPI);
11
+ class IdentificationsAPI {
12
+ static get endpoint() {
13
+ return _core.Configuration.endpoint('public/identifications');
19
14
  }
20
- _createClass(IdentificationsAPI, null, [{
21
- key: "endpoint",
22
- get: function () {
23
- return _core.Configuration.endpoint('public/identifications');
24
- }
25
- }, {
26
- key: "create",
27
- value: async function create(data = {}) {
28
- const response = await fetch(this.endpoint, {
29
- method: 'POST',
30
- headers: _hellotext.default.headers,
31
- body: JSON.stringify({
32
- session: _hellotext.default.session,
33
- ...data
34
- })
35
- });
36
- return new _response.Response(response.ok, response);
37
- }
38
- }]);
39
- return IdentificationsAPI;
40
- }();
15
+ static async create(data = {}) {
16
+ const response = await fetch(this.endpoint, {
17
+ method: 'POST',
18
+ headers: _hellotext.default.headers,
19
+ body: JSON.stringify({
20
+ session: _hellotext.default.session,
21
+ ...data
22
+ })
23
+ });
24
+ return new _response.Response(response.ok, response);
25
+ }
26
+ }
41
27
  var _default = IdentificationsAPI;
42
28
  exports.default = _default;
@@ -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
@@ -18,13 +18,9 @@ var _identifications = _interopRequireDefault(require("./identifications"));
18
18
  var _webchats = _interopRequireDefault(require("./webchats"));
19
19
  var _whatsapp_widgets = _interopRequireDefault(require("./whatsapp_widgets"));
20
20
  var _acks = _interopRequireDefault(require("./acks"));
21
+ var _identities = _interopRequireDefault(require("./push/identities"));
21
22
  var _response = require("./response");
22
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
24
- 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); } }
25
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
26
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
27
- 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); }
28
24
  // Browsers keep `fetch(..., { keepalive: true })` requests alive during page
29
25
  // unload/navigation, which is exactly the failure mode for analytics events
30
26
  // fired from checkout redirects, form submissions, tab closes, and pixel
@@ -45,46 +41,30 @@ function keepaliveFor(body) {
45
41
  }
46
42
  return new Blob([serializedBody]).size < KEEPALIVE_BODY_LIMIT;
47
43
  }
48
- let API = /*#__PURE__*/function () {
49
- function API() {
50
- _classCallCheck(this, API);
44
+ class API {
45
+ static get businesses() {
46
+ return _businesses.default;
51
47
  }
52
- _createClass(API, null, [{
53
- key: "businesses",
54
- get: function () {
55
- return _businesses.default;
56
- }
57
- }, {
58
- key: "events",
59
- get: function () {
60
- return _events.default;
61
- }
62
- }, {
63
- key: "forms",
64
- get: function () {
65
- return _forms.default;
66
- }
67
- }, {
68
- key: "webchats",
69
- get: function () {
70
- return _webchats.default;
71
- }
72
- }, {
73
- key: "whatsappWidgets",
74
- get: function () {
75
- return _whatsapp_widgets.default;
76
- }
77
- }, {
78
- key: "identifications",
79
- get: function () {
80
- return _identifications.default;
81
- }
82
- }, {
83
- key: "acks",
84
- get: function () {
85
- return _acks.default;
86
- }
87
- }]);
88
- return API;
89
- }();
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
+ }
90
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';
@@ -10,6 +5,7 @@ import IdentificationsAPI from './identifications';
10
5
  import WebchatsAPI from './webchats';
11
6
  import WhatsAppWidgetsAPI from './whatsapp_widgets';
12
7
  import AcksAPI from './acks';
8
+ import PushIdentitiesAPI from './push/identities';
13
9
 
14
10
  // Browsers keep `fetch(..., { keepalive: true })` requests alive during page
15
11
  // unload/navigation, which is exactly the failure mode for analytics events
@@ -18,9 +14,9 @@ import AcksAPI from './acks';
18
14
  // browsers can reject or drop oversized requests instead of making delivery
19
15
  // more reliable. Keep the limit below that ceiling so the SDK only opts in when
20
16
  // the payload is small enough for the keepalive transport contract.
21
- var KEEPALIVE_BODY_LIMIT = 60000;
17
+ const KEEPALIVE_BODY_LIMIT = 60000;
22
18
  function keepaliveFor(body) {
23
- var serializedBody = JSON.stringify(body);
19
+ const serializedBody = JSON.stringify(body);
24
20
 
25
21
  // Use byte size when the runtime exposes Blob because non-ASCII JSON can be
26
22
  // larger on the wire than its JavaScript string length. The string-length
@@ -31,48 +27,31 @@ function keepaliveFor(body) {
31
27
  }
32
28
  return new Blob([serializedBody]).size < KEEPALIVE_BODY_LIMIT;
33
29
  }
34
- var API = /*#__PURE__*/function () {
35
- function API() {
36
- _classCallCheck(this, API);
30
+ export default class API {
31
+ static get businesses() {
32
+ return BusinessesAPI;
37
33
  }
38
- _createClass(API, null, [{
39
- key: "businesses",
40
- get: function get() {
41
- return BusinessesAPI;
42
- }
43
- }, {
44
- key: "events",
45
- get: function get() {
46
- return EventsAPI;
47
- }
48
- }, {
49
- key: "forms",
50
- get: function get() {
51
- return FormsAPI;
52
- }
53
- }, {
54
- key: "webchats",
55
- get: function get() {
56
- return WebchatsAPI;
57
- }
58
- }, {
59
- key: "whatsappWidgets",
60
- get: function get() {
61
- return WhatsAppWidgetsAPI;
62
- }
63
- }, {
64
- key: "identifications",
65
- get: function get() {
66
- return IdentificationsAPI;
67
- }
68
- }, {
69
- key: "acks",
70
- get: function get() {
71
- return AcksAPI;
72
- }
73
- }]);
74
- return API;
75
- }();
76
- 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
+ }
77
56
  export { Response } from './response';
78
57
  export { keepaliveFor };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _hellotext = _interopRequireDefault(require("../../hellotext"));
8
+ var _core = require("../../core");
9
+ var _response = require("../response");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ class PushIdentitiesAPI {
12
+ static get endpoint() {
13
+ return _core.Configuration.endpoint('public/push/identities');
14
+ }
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
+ }
42
+ var _default = PushIdentitiesAPI;
43
+ exports.default = _default;
@@ -0,0 +1,35 @@
1
+ import Hellotext from '../../hellotext';
2
+ import { Configuration } from '../../core';
3
+ import { Response } from '../response';
4
+ class PushIdentitiesAPI {
5
+ static get endpoint() {
6
+ return Configuration.endpoint('public/push/identities');
7
+ }
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
+ }
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 };