@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.
- package/README.md +5 -26
- package/dist/hellotext.js +1 -1
- package/dist/hellotext.js.LICENSE.txt +1 -1
- package/index.d.ts +15 -6
- package/lib/api/acks.cjs +17 -31
- package/lib/api/acks.js +17 -42
- package/lib/api/businesses.cjs +14 -28
- package/lib/api/businesses.js +13 -36
- package/lib/api/events.cjs +26 -40
- package/lib/api/events.js +28 -52
- package/lib/api/forms.cjs +24 -40
- package/lib/api/forms.js +24 -57
- package/lib/api/identifications.cjs +15 -29
- package/lib/api/identifications.js +15 -40
- package/lib/api/index.cjs +26 -46
- package/lib/api/index.js +28 -49
- package/lib/api/push/identities.cjs +43 -0
- package/lib/api/push/identities.js +35 -0
- package/lib/api/response.cjs +30 -52
- package/lib/api/response.js +31 -60
- package/lib/api/submissions.cjs +18 -34
- package/lib/api/submissions.js +18 -48
- package/lib/api/webchat/messages.cjs +44 -64
- package/lib/api/webchat/messages.js +44 -80
- package/lib/api/webchats.cjs +37 -56
- package/lib/api/webchats.js +37 -65
- package/lib/api/whatsapp_widgets.cjs +49 -72
- package/lib/api/whatsapp_widgets.js +48 -91
- package/lib/builders/input_builder.cjs +36 -48
- package/lib/builders/input_builder.js +36 -48
- package/lib/builders/logo_builder.cjs +10 -29
- package/lib/builders/logo_builder.js +20 -28
- package/lib/channels/application_channel.cjs +136 -178
- package/lib/channels/application_channel.js +137 -180
- package/lib/channels/webchat_channel.cjs +125 -170
- package/lib/channels/webchat_channel.js +125 -170
- package/lib/controllers/form_controller.cjs +82 -121
- package/lib/controllers/form_controller.js +82 -130
- package/lib/controllers/message_controller.cjs +211 -282
- package/lib/controllers/message_controller.js +209 -284
- package/lib/controllers/mixins/usePopover.cjs +3 -6
- package/lib/controllers/mixins/usePopover.js +17 -22
- package/lib/controllers/webchat/emoji_picker_controller.cjs +106 -150
- package/lib/controllers/webchat/emoji_picker_controller.js +105 -170
- package/lib/controllers/webchat/useBehaviour.js +5 -5
- package/lib/controllers/webchat/useOpeningSequence.js +6 -6
- package/lib/controllers/webchat/useTeaser.js +9 -9
- package/lib/controllers/webchat_controller.cjs +916 -1088
- package/lib/controllers/webchat_controller.js +926 -1152
- package/lib/core/configuration/forms.cjs +21 -35
- package/lib/core/configuration/forms.js +20 -35
- package/lib/core/configuration/locale.cjs +36 -71
- package/lib/core/configuration/locale.js +36 -70
- package/lib/core/configuration/push.cjs +16 -0
- package/lib/core/configuration/push.js +10 -0
- package/lib/core/configuration/webchat.cjs +142 -182
- package/lib/core/configuration/webchat.js +145 -189
- package/lib/core/configuration/whatsapp.cjs +76 -102
- package/lib/core/configuration/whatsapp.js +76 -105
- package/lib/core/configuration.cjs +62 -75
- package/lib/core/configuration.js +61 -75
- package/lib/core/event.cjs +36 -59
- package/lib/core/event.js +35 -61
- package/lib/core/sanitize_html.js +4 -4
- package/lib/errors/invalid_event.cjs +5 -26
- package/lib/errors/invalid_event.js +5 -26
- package/lib/errors/not_initialized_error.cjs +5 -26
- package/lib/errors/not_initialized_error.js +5 -26
- package/lib/hellotext.cjs +186 -211
- package/lib/hellotext.js +189 -236
- package/lib/index.js +1 -1
- package/lib/models/business.cjs +115 -152
- package/lib/models/business.js +118 -162
- package/lib/models/cookies.cjs +34 -51
- package/lib/models/cookies.js +34 -51
- package/lib/models/fingerprint.cjs +8 -23
- package/lib/models/fingerprint.js +25 -58
- package/lib/models/form.cjs +106 -142
- package/lib/models/form.js +105 -153
- package/lib/models/form_collection.cjs +63 -101
- package/lib/models/form_collection.js +61 -107
- package/lib/models/index.cjs +7 -0
- package/lib/models/index.js +1 -0
- package/lib/models/page.cjs +106 -129
- package/lib/models/page.js +106 -131
- package/lib/models/push.cjs +345 -0
- package/lib/models/push.js +339 -0
- package/lib/models/query.cjs +21 -41
- package/lib/models/query.js +21 -41
- package/lib/models/session.cjs +33 -65
- package/lib/models/session.js +30 -63
- package/lib/models/user.cjs +29 -51
- package/lib/models/user.js +29 -51
- package/lib/models/utm.cjs +15 -27
- package/lib/models/utm.js +17 -32
- package/lib/models/webchat.cjs +52 -76
- package/lib/models/webchat.js +52 -90
- package/lib/models/whatsapp_widget.cjs +41 -59
- package/lib/models/whatsapp_widget.js +41 -73
- package/lib/vanilla.cjs +4 -7
- package/lib/vanilla.js +2 -1
- package/package.json +2 -10
- package/src/api/index.js +5 -0
- package/src/api/push/identities.js +42 -0
- package/src/core/configuration/push.js +12 -0
- package/src/core/configuration.js +5 -0
- package/src/hellotext.js +15 -1
- package/src/index.bundle.js +0 -1
- package/src/models/business.js +1 -0
- package/src/models/index.js +1 -0
- package/src/models/push.js +397 -0
- package/src/vanilla.js +2 -1
- 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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
127
|
-
|
|
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
|
-
|
|
135
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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(
|
|
190
|
-
if (
|
|
191
|
-
throw new Error(`Invalid
|
|
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 (
|
|
194
|
-
|
|
157
|
+
if (key === 'launcher' && nestedKey !== 'iconUrl') {
|
|
158
|
+
throw new Error(`Invalid appearance launcher property: ${nestedKey}`);
|
|
195
159
|
}
|
|
196
|
-
if (
|
|
197
|
-
|
|
160
|
+
if (propertyValue == null) {
|
|
161
|
+
return;
|
|
198
162
|
}
|
|
199
|
-
if (
|
|
200
|
-
throw new Error(`Invalid
|
|
163
|
+
if (typeof propertyValue !== 'string') {
|
|
164
|
+
throw new Error(`Invalid appearance ${key}.${nestedKey} value: ${propertyValue}`);
|
|
201
165
|
}
|
|
202
166
|
});
|
|
203
|
-
|
|
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
|
-
|
|
207
|
-
|
|
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
|
-
|
|
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
|
|
227
|
-
throw new Error(`Invalid
|
|
184
|
+
if (key === 'number' && typeof nestedValue !== 'string') {
|
|
185
|
+
throw new Error(`Invalid WhatsApp number value: ${nestedValue}`);
|
|
228
186
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
Webchat
|
|
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;
|