@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
@@ -4,11 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.modes = exports.Webchat = 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
7
  /**
13
8
  * @typedef {'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'} Placement
14
9
  * @description Valid placements for the webchat.
@@ -86,203 +81,168 @@ const modes = {
86
81
  * @property {Strategy} strategy - the strategy used to position the webchat. Defaults to 'absolute'
87
82
  */
88
83
  exports.modes = modes;
89
- let Webchat = /*#__PURE__*/function () {
90
- function Webchat() {
91
- _classCallCheck(this, Webchat);
84
+ class Webchat {
85
+ static _id;
86
+ static _container = 'body';
87
+ static _placement = 'bottom-right';
88
+ static _style = {};
89
+ static _appearance = {};
90
+ static _whatsapp = {};
91
+ static _mode = modes.POPOVER;
92
+ static _behaviour = null;
93
+ static _hasBehaviourOverride = false;
94
+ static _strategy = null;
95
+ static set container(value) {
96
+ this._container = value;
92
97
  }
93
- _createClass(Webchat, null, [{
94
- key: "container",
95
- get: function () {
96
- return this._container;
97
- },
98
- set: function (value) {
99
- this._container = value;
100
- }
101
- }, {
102
- key: "placement",
103
- get: function () {
104
- return this._placement;
105
- },
106
- set: function (value) {
107
- if (!Object.values(placements).includes(value)) {
108
- throw new Error(`Invalid placement value: ${value}`);
109
- }
110
- this._placement = value;
111
- }
112
- }, {
113
- key: "id",
114
- get: function () {
115
- return this._id;
116
- },
117
- set: function (value) {
118
- this._id = value;
98
+ static get container() {
99
+ return this._container;
100
+ }
101
+ static set placement(value) {
102
+ if (!Object.values(placements).includes(value)) {
103
+ throw new Error(`Invalid placement value: ${value}`);
119
104
  }
120
- }, {
121
- key: "isSet",
122
- get: function () {
123
- return !!this._id;
105
+ this._placement = value;
106
+ }
107
+ static get placement() {
108
+ return this._placement;
109
+ }
110
+ static set id(value) {
111
+ this._id = value;
112
+ }
113
+ static get id() {
114
+ return this._id;
115
+ }
116
+ static get isSet() {
117
+ return !!this._id;
118
+ }
119
+ static get style() {
120
+ return this._style;
121
+ }
122
+ static set style(value) {
123
+ if (typeof value !== 'object') {
124
+ throw new Error('Style must be an object');
124
125
  }
125
- }, {
126
- key: "style",
127
- get: function () {
128
- return this._style;
129
- },
130
- set: function (value) {
131
- if (typeof value !== 'object') {
132
- throw new Error('Style must be an object');
126
+ Object.entries(value).forEach(([key, value]) => {
127
+ if (!['primaryColor', 'secondaryColor', 'typography'].includes(key)) {
128
+ throw new Error(`Invalid style property: ${key}`);
133
129
  }
134
- Object.entries(value).forEach(([key, value]) => {
135
- if (!['primaryColor', 'secondaryColor', 'typography'].includes(key)) {
136
- throw new Error(`Invalid style property: ${key}`);
137
- }
138
- if (key === 'typography') {
139
- return;
140
- }
141
- if (!this.isHexOrRgba(value)) {
142
- throw new Error(`Invalid color value: ${value} for ${key}. Colors must be hex or rgb/a.`);
143
- }
144
- });
145
- this._style = value;
146
- }
147
- }, {
148
- key: "appearance",
149
- get: function () {
150
- return this._appearance;
151
- },
152
- set: function (value) {
153
- if (!this.isPlainObject(value)) {
154
- throw new Error('Appearance must be an object');
130
+ if (key === 'typography') {
131
+ return;
155
132
  }
156
- Object.entries(value).forEach(([key, nestedValue]) => {
157
- if (!['header', 'launcher'].includes(key)) {
158
- throw new Error(`Invalid appearance property: ${key}`);
159
- }
160
- if (!this.isPlainObject(nestedValue)) {
161
- throw new Error(`Appearance ${key} must be an object`);
162
- }
163
- Object.entries(nestedValue).forEach(([nestedKey, propertyValue]) => {
164
- if (key === 'header' && nestedKey !== 'name') {
165
- throw new Error(`Invalid appearance header property: ${nestedKey}`);
166
- }
167
- if (key === 'launcher' && nestedKey !== 'iconUrl') {
168
- throw new Error(`Invalid appearance launcher property: ${nestedKey}`);
169
- }
170
- if (propertyValue == null) {
171
- return;
172
- }
173
- if (typeof propertyValue !== 'string') {
174
- throw new Error(`Invalid appearance ${key}.${nestedKey} value: ${propertyValue}`);
175
- }
176
- });
177
- });
178
- this._appearance = value;
133
+ if (!this.isHexOrRgba(value)) {
134
+ throw new Error(`Invalid color value: ${value} for ${key}. Colors must be hex or rgb/a.`);
135
+ }
136
+ });
137
+ this._style = value;
138
+ }
139
+ static get appearance() {
140
+ return this._appearance;
141
+ }
142
+ static set appearance(value) {
143
+ if (!this.isPlainObject(value)) {
144
+ throw new Error('Appearance must be an object');
179
145
  }
180
- }, {
181
- key: "whatsapp",
182
- get: function () {
183
- return this._whatsapp;
184
- },
185
- set: function (value) {
186
- if (!this.isPlainObject(value)) {
187
- throw new Error('WhatsApp must be an object');
146
+ Object.entries(value).forEach(([key, nestedValue]) => {
147
+ if (!['header', 'launcher'].includes(key)) {
148
+ throw new Error(`Invalid appearance property: ${key}`);
149
+ }
150
+ if (!this.isPlainObject(nestedValue)) {
151
+ throw new Error(`Appearance ${key} must be an object`);
188
152
  }
189
- Object.entries(value).forEach(([key, nestedValue]) => {
190
- if (!['number', 'restrictToChannel'].includes(key)) {
191
- throw new Error(`Invalid WhatsApp property: ${key}`);
153
+ Object.entries(nestedValue).forEach(([nestedKey, propertyValue]) => {
154
+ if (key === 'header' && nestedKey !== 'name') {
155
+ throw new Error(`Invalid appearance header property: ${nestedKey}`);
192
156
  }
193
- if (nestedValue == null) {
194
- return;
157
+ if (key === 'launcher' && nestedKey !== 'iconUrl') {
158
+ throw new Error(`Invalid appearance launcher property: ${nestedKey}`);
195
159
  }
196
- if (key === 'number' && typeof nestedValue !== 'string') {
197
- throw new Error(`Invalid WhatsApp number value: ${nestedValue}`);
160
+ if (propertyValue == null) {
161
+ return;
198
162
  }
199
- if (key === 'restrictToChannel' && typeof nestedValue !== 'boolean') {
200
- throw new Error(`Invalid WhatsApp restrictToChannel value: ${nestedValue}`);
163
+ if (typeof propertyValue !== 'string') {
164
+ throw new Error(`Invalid appearance ${key}.${nestedKey} value: ${propertyValue}`);
201
165
  }
202
166
  });
203
- this._whatsapp = value;
167
+ });
168
+ this._appearance = value;
169
+ }
170
+ static get whatsapp() {
171
+ return this._whatsapp;
172
+ }
173
+ static set whatsapp(value) {
174
+ if (!this.isPlainObject(value)) {
175
+ throw new Error('WhatsApp must be an object');
204
176
  }
205
- }, {
206
- key: "mode",
207
- get: function () {
208
- return this._mode;
209
- },
210
- set: function (value) {
211
- if (!Object.values(modes).includes(value)) {
212
- throw new Error(`Invalid mode value: ${value}`);
177
+ Object.entries(value).forEach(([key, nestedValue]) => {
178
+ if (!['number', 'restrictToChannel'].includes(key)) {
179
+ throw new Error(`Invalid WhatsApp property: ${key}`);
213
180
  }
214
- this._mode = value;
215
- }
216
- }, {
217
- key: "behaviour",
218
- get: function () {
219
- return this._behaviour;
220
- },
221
- set: function (value) {
222
- if (value == null) {
223
- this._behaviour = value;
181
+ if (nestedValue == null) {
224
182
  return;
225
183
  }
226
- if (typeof value !== 'object' || Array.isArray(value)) {
227
- throw new Error(`Invalid behaviour value: ${value}`);
184
+ if (key === 'number' && typeof nestedValue !== 'string') {
185
+ throw new Error(`Invalid WhatsApp number value: ${nestedValue}`);
228
186
  }
229
- this._behaviour = value;
230
- }
231
- }, {
232
- key: "hasBehaviourOverride",
233
- get: function () {
234
- return this._hasBehaviourOverride;
187
+ if (key === 'restrictToChannel' && typeof nestedValue !== 'boolean') {
188
+ throw new Error(`Invalid WhatsApp restrictToChannel value: ${nestedValue}`);
189
+ }
190
+ });
191
+ this._whatsapp = value;
192
+ }
193
+ static get mode() {
194
+ return this._mode;
195
+ }
196
+ static set mode(value) {
197
+ if (!Object.values(modes).includes(value)) {
198
+ throw new Error(`Invalid mode value: ${value}`);
235
199
  }
236
- }, {
237
- key: "behaviourOverride",
238
- set: function (value) {
239
- this._hasBehaviourOverride = !!value;
200
+ this._mode = value;
201
+ }
202
+ static get behaviour() {
203
+ return this._behaviour;
204
+ }
205
+ static set behaviour(value) {
206
+ if (value == null) {
207
+ this._behaviour = value;
208
+ return;
240
209
  }
241
- }, {
242
- key: "strategy",
243
- get: function () {
244
- if (this._strategy) {
245
- return this._strategy;
246
- }
247
- return this.container == 'body' ? strategies.FIXED : strategies.ABSOLUTE;
248
- },
249
- set: function (value) {
250
- if (value && !Object.values(strategies).includes(value)) {
251
- throw new Error(`Invalid strategy value: ${value}`);
252
- }
253
- this._strategy = value;
210
+ if (typeof value !== 'object' || Array.isArray(value)) {
211
+ throw new Error(`Invalid behaviour value: ${value}`);
254
212
  }
255
- }, {
256
- key: "assign",
257
- value: function assign(props) {
258
- if (props) {
259
- Object.entries(props).forEach(([key, value]) => {
260
- this[key] = value;
261
- });
262
- }
263
- return this;
213
+ this._behaviour = value;
214
+ }
215
+ static get hasBehaviourOverride() {
216
+ return this._hasBehaviourOverride;
217
+ }
218
+ static set behaviourOverride(value) {
219
+ this._hasBehaviourOverride = !!value;
220
+ }
221
+ static get strategy() {
222
+ if (this._strategy) {
223
+ return this._strategy;
264
224
  }
265
- }, {
266
- key: "isHexOrRgba",
267
- value: function isHexOrRgba(value) {
268
- return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(value) || /^rgba?\(\s*\d{1,3},\s*\d{1,3},\s*\d{1,3},?\s*(0|1|0?\.\d+)?\s*\)$/.test(value);
225
+ return this.container == 'body' ? strategies.FIXED : strategies.ABSOLUTE;
226
+ }
227
+ static set strategy(value) {
228
+ if (value && !Object.values(strategies).includes(value)) {
229
+ throw new Error(`Invalid strategy value: ${value}`);
269
230
  }
270
- }, {
271
- key: "isPlainObject",
272
- value: function isPlainObject(value) {
273
- return typeof value === 'object' && value !== null && !Array.isArray(value);
231
+ this._strategy = value;
232
+ }
233
+ static assign(props) {
234
+ if (props) {
235
+ Object.entries(props).forEach(([key, value]) => {
236
+ this[key] = value;
237
+ });
274
238
  }
275
- }]);
276
- return Webchat;
277
- }();
278
- exports.Webchat = Webchat;
279
- Webchat._id = void 0;
280
- Webchat._container = 'body';
281
- Webchat._placement = 'bottom-right';
282
- Webchat._style = {};
283
- Webchat._appearance = {};
284
- Webchat._whatsapp = {};
285
- Webchat._mode = modes.POPOVER;
286
- Webchat._behaviour = null;
287
- Webchat._hasBehaviourOverride = false;
288
- Webchat._strategy = null;
239
+ return this;
240
+ }
241
+ static isHexOrRgba(value) {
242
+ return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(value) || /^rgba?\(\s*\d{1,3},\s*\d{1,3},\s*\d{1,3},?\s*(0|1|0?\.\d+)?\s*\)$/.test(value);
243
+ }
244
+ static isPlainObject(value) {
245
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
246
+ }
247
+ }
248
+ exports.Webchat = Webchat;