@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
package/lib/models/webchat.cjs
CHANGED
|
@@ -8,85 +8,61 @@ var _core = require("../core");
|
|
|
8
8
|
var _api = _interopRequireDefault(require("../api"));
|
|
9
9
|
var _business = require("./business");
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
class Webchat {
|
|
12
|
+
static async load(id) {
|
|
13
|
+
const webchat = new Webchat({
|
|
14
|
+
id,
|
|
15
|
+
html: await _api.default.webchats.get(id)
|
|
16
|
+
});
|
|
17
|
+
webchat.rendered = webchat.render();
|
|
18
|
+
return webchat;
|
|
19
|
+
}
|
|
20
|
+
constructor(data) {
|
|
19
21
|
this.data = data;
|
|
20
22
|
this.mounted = false;
|
|
21
23
|
this.rendered = Promise.resolve(false);
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
console.warn('Hellotext webchat was not mounted because its stylesheet failed to load.');
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
this.containerToAppendTo.appendChild(this.data.html);
|
|
32
|
-
this.markCoexistingWidgets();
|
|
33
|
-
this.mounted = true;
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
}, {
|
|
37
|
-
key: "applyBehaviourOverride",
|
|
38
|
-
value: function applyBehaviourOverride() {
|
|
39
|
-
if (!_core.Configuration.webchat.hasBehaviourOverride || !_core.Configuration.webchat.behaviour) return;
|
|
40
|
-
this.data.html.setAttribute('data-hellotext--webchat-behaviour-value', JSON.stringify(this.serializedBehaviour));
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
key: "serializedBehaviour",
|
|
44
|
-
get: function () {
|
|
45
|
-
const behaviour = _core.Configuration.webchat.behaviour;
|
|
46
|
-
return {
|
|
47
|
-
trigger: this.serializeTrigger(behaviour.trigger),
|
|
48
|
-
delay_seconds: behaviour.delaySeconds,
|
|
49
|
-
first_visit_only: behaviour.firstVisitOnly,
|
|
50
|
-
once_per_session: behaviour.oncePerSession
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: "serializeTrigger",
|
|
55
|
-
value: function serializeTrigger(trigger) {
|
|
56
|
-
if (trigger === 'onLoad') return 'on_load';
|
|
57
|
-
if (trigger === 'onClick') return 'on_click';
|
|
58
|
-
return trigger;
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
key: "containerToAppendTo",
|
|
62
|
-
get: function () {
|
|
63
|
-
return document.querySelector(_core.Configuration.webchat.container);
|
|
64
|
-
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "stylesheetLoaded",
|
|
67
|
-
get: function () {
|
|
68
|
-
return _business.Business.waitForStylesheet(_business.Business.latestStylesheet);
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "markCoexistingWidgets",
|
|
72
|
-
value: function markCoexistingWidgets() {
|
|
73
|
-
const webchat = this.data.html;
|
|
74
|
-
const whatsapp = document.querySelector('.hellotext--whatsapp-widget');
|
|
75
|
-
if (!webchat || !whatsapp) return;
|
|
76
|
-
webchat.classList.add('hellotext--with-whatsapp-widget');
|
|
77
|
-
whatsapp.classList.add('hellotext--with-webchat');
|
|
78
|
-
}
|
|
79
|
-
}], [{
|
|
80
|
-
key: "load",
|
|
81
|
-
value: async function load(id) {
|
|
82
|
-
const webchat = new Webchat({
|
|
83
|
-
id,
|
|
84
|
-
html: await _api.default.webchats.get(id)
|
|
85
|
-
});
|
|
86
|
-
webchat.rendered = webchat.render();
|
|
87
|
-
return webchat;
|
|
25
|
+
async render() {
|
|
26
|
+
this.applyBehaviourOverride();
|
|
27
|
+
if (!(await this.stylesheetLoaded)) {
|
|
28
|
+
console.warn('Hellotext webchat was not mounted because its stylesheet failed to load.');
|
|
29
|
+
return false;
|
|
88
30
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
31
|
+
this.containerToAppendTo.appendChild(this.data.html);
|
|
32
|
+
this.markCoexistingWidgets();
|
|
33
|
+
this.mounted = true;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
applyBehaviourOverride() {
|
|
37
|
+
if (!_core.Configuration.webchat.hasBehaviourOverride || !_core.Configuration.webchat.behaviour) return;
|
|
38
|
+
this.data.html.setAttribute('data-hellotext--webchat-behaviour-value', JSON.stringify(this.serializedBehaviour));
|
|
39
|
+
}
|
|
40
|
+
get serializedBehaviour() {
|
|
41
|
+
const behaviour = _core.Configuration.webchat.behaviour;
|
|
42
|
+
return {
|
|
43
|
+
trigger: this.serializeTrigger(behaviour.trigger),
|
|
44
|
+
delay_seconds: behaviour.delaySeconds,
|
|
45
|
+
first_visit_only: behaviour.firstVisitOnly,
|
|
46
|
+
once_per_session: behaviour.oncePerSession
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
serializeTrigger(trigger) {
|
|
50
|
+
if (trigger === 'onLoad') return 'on_load';
|
|
51
|
+
if (trigger === 'onClick') return 'on_click';
|
|
52
|
+
return trigger;
|
|
53
|
+
}
|
|
54
|
+
get containerToAppendTo() {
|
|
55
|
+
return document.querySelector(_core.Configuration.webchat.container);
|
|
56
|
+
}
|
|
57
|
+
get stylesheetLoaded() {
|
|
58
|
+
return _business.Business.waitForStylesheet(_business.Business.latestStylesheet);
|
|
59
|
+
}
|
|
60
|
+
markCoexistingWidgets() {
|
|
61
|
+
const webchat = this.data.html;
|
|
62
|
+
const whatsapp = document.querySelector('.hellotext--whatsapp-widget');
|
|
63
|
+
if (!webchat || !whatsapp) return;
|
|
64
|
+
webchat.classList.add('hellotext--with-whatsapp-widget');
|
|
65
|
+
whatsapp.classList.add('hellotext--with-webchat');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
92
68
|
exports.Webchat = Webchat;
|
package/lib/models/webchat.js
CHANGED
|
@@ -1,99 +1,61 @@
|
|
|
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
1
|
import { Configuration } from '../core';
|
|
9
2
|
import API from '../api';
|
|
10
3
|
import { Business } from './business';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
class Webchat {
|
|
5
|
+
static async load(id) {
|
|
6
|
+
const webchat = new Webchat({
|
|
7
|
+
id,
|
|
8
|
+
html: await API.webchats.get(id)
|
|
9
|
+
});
|
|
10
|
+
webchat.rendered = webchat.render();
|
|
11
|
+
return webchat;
|
|
12
|
+
}
|
|
13
|
+
constructor(data) {
|
|
14
14
|
this.data = data;
|
|
15
15
|
this.mounted = false;
|
|
16
16
|
this.rendered = Promise.resolve(false);
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!(yield this.stylesheetLoaded)) {
|
|
24
|
-
console.warn('Hellotext webchat was not mounted because its stylesheet failed to load.');
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
this.containerToAppendTo.appendChild(this.data.html);
|
|
28
|
-
this.markCoexistingWidgets();
|
|
29
|
-
this.mounted = true;
|
|
30
|
-
return true;
|
|
31
|
-
});
|
|
32
|
-
function render() {
|
|
33
|
-
return _render.apply(this, arguments);
|
|
34
|
-
}
|
|
35
|
-
return render;
|
|
36
|
-
}()
|
|
37
|
-
}, {
|
|
38
|
-
key: "applyBehaviourOverride",
|
|
39
|
-
value: function applyBehaviourOverride() {
|
|
40
|
-
if (!Configuration.webchat.hasBehaviourOverride || !Configuration.webchat.behaviour) return;
|
|
41
|
-
this.data.html.setAttribute('data-hellotext--webchat-behaviour-value', JSON.stringify(this.serializedBehaviour));
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
key: "serializedBehaviour",
|
|
45
|
-
get: function get() {
|
|
46
|
-
var behaviour = Configuration.webchat.behaviour;
|
|
47
|
-
return {
|
|
48
|
-
trigger: this.serializeTrigger(behaviour.trigger),
|
|
49
|
-
delay_seconds: behaviour.delaySeconds,
|
|
50
|
-
first_visit_only: behaviour.firstVisitOnly,
|
|
51
|
-
once_per_session: behaviour.oncePerSession
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "serializeTrigger",
|
|
56
|
-
value: function serializeTrigger(trigger) {
|
|
57
|
-
if (trigger === 'onLoad') return 'on_load';
|
|
58
|
-
if (trigger === 'onClick') return 'on_click';
|
|
59
|
-
return trigger;
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: "containerToAppendTo",
|
|
63
|
-
get: function get() {
|
|
64
|
-
return document.querySelector(Configuration.webchat.container);
|
|
18
|
+
async render() {
|
|
19
|
+
this.applyBehaviourOverride();
|
|
20
|
+
if (!(await this.stylesheetLoaded)) {
|
|
21
|
+
console.warn('Hellotext webchat was not mounted because its stylesheet failed to load.');
|
|
22
|
+
return false;
|
|
65
23
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
value
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
24
|
+
this.containerToAppendTo.appendChild(this.data.html);
|
|
25
|
+
this.markCoexistingWidgets();
|
|
26
|
+
this.mounted = true;
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
applyBehaviourOverride() {
|
|
30
|
+
if (!Configuration.webchat.hasBehaviourOverride || !Configuration.webchat.behaviour) return;
|
|
31
|
+
this.data.html.setAttribute('data-hellotext--webchat-behaviour-value', JSON.stringify(this.serializedBehaviour));
|
|
32
|
+
}
|
|
33
|
+
get serializedBehaviour() {
|
|
34
|
+
const behaviour = Configuration.webchat.behaviour;
|
|
35
|
+
return {
|
|
36
|
+
trigger: this.serializeTrigger(behaviour.trigger),
|
|
37
|
+
delay_seconds: behaviour.delaySeconds,
|
|
38
|
+
first_visit_only: behaviour.firstVisitOnly,
|
|
39
|
+
once_per_session: behaviour.oncePerSession
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
serializeTrigger(trigger) {
|
|
43
|
+
if (trigger === 'onLoad') return 'on_load';
|
|
44
|
+
if (trigger === 'onClick') return 'on_click';
|
|
45
|
+
return trigger;
|
|
46
|
+
}
|
|
47
|
+
get containerToAppendTo() {
|
|
48
|
+
return document.querySelector(Configuration.webchat.container);
|
|
49
|
+
}
|
|
50
|
+
get stylesheetLoaded() {
|
|
51
|
+
return Business.waitForStylesheet(Business.latestStylesheet);
|
|
52
|
+
}
|
|
53
|
+
markCoexistingWidgets() {
|
|
54
|
+
const webchat = this.data.html;
|
|
55
|
+
const whatsapp = document.querySelector('.hellotext--whatsapp-widget');
|
|
56
|
+
if (!webchat || !whatsapp) return;
|
|
57
|
+
webchat.classList.add('hellotext--with-whatsapp-widget');
|
|
58
|
+
whatsapp.classList.add('hellotext--with-webchat');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
99
61
|
export { Webchat };
|
|
@@ -8,70 +8,52 @@ var _core = require("../core");
|
|
|
8
8
|
var _api = _interopRequireDefault(require("../api"));
|
|
9
9
|
var _business = require("./business");
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
class WhatsAppWidget {
|
|
12
|
+
static async load(id) {
|
|
13
|
+
const widget = new WhatsAppWidget({
|
|
14
|
+
id,
|
|
15
|
+
html: await _api.default.whatsappWidgets.get(id)
|
|
16
|
+
});
|
|
17
|
+
widget.rendered = widget.render();
|
|
18
|
+
return widget;
|
|
19
|
+
}
|
|
20
|
+
constructor(data) {
|
|
19
21
|
this.data = data;
|
|
20
22
|
this.mounted = false;
|
|
21
23
|
this.rendered = Promise.resolve(false);
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
console.warn(`Hellotext WhatsApp widget was not mounted because the container ${_core.Configuration.whatsapp.container} was not found.`);
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
if (!(await this.stylesheetLoaded)) {
|
|
33
|
-
console.warn('Hellotext WhatsApp widget was not mounted because its stylesheet failed to load.');
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
container.appendChild(this.data.html);
|
|
37
|
-
this.markCoexistingWidgets();
|
|
38
|
-
this.mounted = true;
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
}, {
|
|
42
|
-
key: "containerToAppendTo",
|
|
43
|
-
get: function () {
|
|
44
|
-
try {
|
|
45
|
-
return document.querySelector(_core.Configuration.whatsapp.container);
|
|
46
|
-
} catch (_) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
25
|
+
async render() {
|
|
26
|
+
if (!this.data.html) return false;
|
|
27
|
+
const container = this.containerToAppendTo;
|
|
28
|
+
if (!container) {
|
|
29
|
+
console.warn(`Hellotext WhatsApp widget was not mounted because the container ${_core.Configuration.whatsapp.container} was not found.`);
|
|
30
|
+
return false;
|
|
49
31
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return _business.Business.waitForStylesheet(_business.Business.latestStylesheet);
|
|
32
|
+
if (!(await this.stylesheetLoaded)) {
|
|
33
|
+
console.warn('Hellotext WhatsApp widget was not mounted because its stylesheet failed to load.');
|
|
34
|
+
return false;
|
|
54
35
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
whatsapp.
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
key: "load",
|
|
66
|
-
value: async function load(id) {
|
|
67
|
-
const widget = new WhatsAppWidget({
|
|
68
|
-
id,
|
|
69
|
-
html: await _api.default.whatsappWidgets.get(id)
|
|
70
|
-
});
|
|
71
|
-
widget.rendered = widget.render();
|
|
72
|
-
return widget;
|
|
36
|
+
container.appendChild(this.data.html);
|
|
37
|
+
this.markCoexistingWidgets();
|
|
38
|
+
this.mounted = true;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
get containerToAppendTo() {
|
|
42
|
+
try {
|
|
43
|
+
return document.querySelector(_core.Configuration.whatsapp.container);
|
|
44
|
+
} catch (_) {
|
|
45
|
+
return null;
|
|
73
46
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
47
|
+
}
|
|
48
|
+
get stylesheetLoaded() {
|
|
49
|
+
return _business.Business.waitForStylesheet(_business.Business.latestStylesheet);
|
|
50
|
+
}
|
|
51
|
+
markCoexistingWidgets() {
|
|
52
|
+
const webchat = document.querySelector('.hellotext--webchat:not(.hellotext--whatsapp-widget)');
|
|
53
|
+
const whatsapp = this.data.html;
|
|
54
|
+
if (!webchat || !whatsapp) return;
|
|
55
|
+
webchat.classList.add('hellotext--with-whatsapp-widget');
|
|
56
|
+
whatsapp.classList.add('hellotext--with-webchat');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
77
59
|
exports.WhatsAppWidget = WhatsAppWidget;
|
|
@@ -1,84 +1,52 @@
|
|
|
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
1
|
import { Configuration } from '../core';
|
|
9
2
|
import API from '../api';
|
|
10
3
|
import { Business } from './business';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
class WhatsAppWidget {
|
|
5
|
+
static async load(id) {
|
|
6
|
+
const widget = new WhatsAppWidget({
|
|
7
|
+
id,
|
|
8
|
+
html: await API.whatsappWidgets.get(id)
|
|
9
|
+
});
|
|
10
|
+
widget.rendered = widget.render();
|
|
11
|
+
return widget;
|
|
12
|
+
}
|
|
13
|
+
constructor(data) {
|
|
14
14
|
this.data = data;
|
|
15
15
|
this.mounted = false;
|
|
16
16
|
this.rendered = Promise.resolve(false);
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (!container) {
|
|
25
|
-
console.warn("Hellotext WhatsApp widget was not mounted because the container ".concat(Configuration.whatsapp.container, " was not found."));
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
if (!(yield this.stylesheetLoaded)) {
|
|
29
|
-
console.warn('Hellotext WhatsApp widget was not mounted because its stylesheet failed to load.');
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
container.appendChild(this.data.html);
|
|
33
|
-
this.markCoexistingWidgets();
|
|
34
|
-
this.mounted = true;
|
|
35
|
-
return true;
|
|
36
|
-
});
|
|
37
|
-
function render() {
|
|
38
|
-
return _render.apply(this, arguments);
|
|
39
|
-
}
|
|
40
|
-
return render;
|
|
41
|
-
}()
|
|
42
|
-
}, {
|
|
43
|
-
key: "containerToAppendTo",
|
|
44
|
-
get: function get() {
|
|
45
|
-
try {
|
|
46
|
-
return document.querySelector(Configuration.whatsapp.container);
|
|
47
|
-
} catch (_) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
18
|
+
async render() {
|
|
19
|
+
if (!this.data.html) return false;
|
|
20
|
+
const container = this.containerToAppendTo;
|
|
21
|
+
if (!container) {
|
|
22
|
+
console.warn(`Hellotext WhatsApp widget was not mounted because the container ${Configuration.whatsapp.container} was not found.`);
|
|
23
|
+
return false;
|
|
50
24
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return Business.waitForStylesheet(Business.latestStylesheet);
|
|
25
|
+
if (!(await this.stylesheetLoaded)) {
|
|
26
|
+
console.warn('Hellotext WhatsApp widget was not mounted because its stylesheet failed to load.');
|
|
27
|
+
return false;
|
|
55
28
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
whatsapp.
|
|
29
|
+
container.appendChild(this.data.html);
|
|
30
|
+
this.markCoexistingWidgets();
|
|
31
|
+
this.mounted = true;
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
get containerToAppendTo() {
|
|
35
|
+
try {
|
|
36
|
+
return document.querySelector(Configuration.whatsapp.container);
|
|
37
|
+
} catch (_) {
|
|
38
|
+
return null;
|
|
64
39
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return _load.apply(this, arguments);
|
|
78
|
-
}
|
|
79
|
-
return load;
|
|
80
|
-
}()
|
|
81
|
-
}]);
|
|
82
|
-
return WhatsAppWidget;
|
|
83
|
-
}();
|
|
40
|
+
}
|
|
41
|
+
get stylesheetLoaded() {
|
|
42
|
+
return Business.waitForStylesheet(Business.latestStylesheet);
|
|
43
|
+
}
|
|
44
|
+
markCoexistingWidgets() {
|
|
45
|
+
const webchat = document.querySelector('.hellotext--webchat:not(.hellotext--whatsapp-widget)');
|
|
46
|
+
const whatsapp = this.data.html;
|
|
47
|
+
if (!webchat || !whatsapp) return;
|
|
48
|
+
webchat.classList.add('hellotext--with-whatsapp-widget');
|
|
49
|
+
whatsapp.classList.add('hellotext--with-webchat');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
84
52
|
export { WhatsAppWidget };
|
package/lib/vanilla.cjs
CHANGED
|
@@ -3,11 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _hellotext.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
6
|
+
exports.default = void 0;
|
|
12
7
|
var _hellotext = _interopRequireDefault(require("./hellotext"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var _default = _hellotext.default;
|
|
10
|
+
exports.default = _default;
|
package/lib/vanilla.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import Hellotext from './hellotext';
|
|
2
|
+
export default Hellotext;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hellotext/hellotext",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
4
4
|
"description": "Hellotext JavaScript Client",
|
|
5
5
|
"source": "src/index.js",
|
|
6
6
|
"main": "lib/index.cjs",
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"lib",
|
|
16
16
|
"dist",
|
|
17
17
|
"src",
|
|
18
|
-
"styles",
|
|
19
18
|
"index.d.ts"
|
|
20
19
|
],
|
|
21
20
|
"exports": {
|
|
@@ -30,12 +29,9 @@
|
|
|
30
29
|
"import": "./lib/vanilla.js",
|
|
31
30
|
"require": "./lib/vanilla.cjs"
|
|
32
31
|
},
|
|
33
|
-
"./styles/*": "./styles/*",
|
|
34
|
-
"./styles/index.css": "./styles/index.css",
|
|
35
32
|
"./package.json": "./package.json"
|
|
36
33
|
},
|
|
37
34
|
"sideEffects": [
|
|
38
|
-
"*.css",
|
|
39
35
|
"./lib/index.js",
|
|
40
36
|
"./lib/index.cjs"
|
|
41
37
|
],
|
|
@@ -45,16 +41,12 @@
|
|
|
45
41
|
"devDependencies": {
|
|
46
42
|
"@babel/cli": "^7.20.7",
|
|
47
43
|
"@babel/core": "^7.20.12",
|
|
48
|
-
"@babel/plugin-proposal-export-default-from": "^7.20.0",
|
|
49
|
-
"@babel/plugin-proposal-private-methods": "^7.18.6",
|
|
50
44
|
"@babel/preset-env": "^7.20.2",
|
|
51
45
|
"@testing-library/jest-dom": "^5.16.5",
|
|
52
46
|
"babel-loader": "^9.1.2",
|
|
53
|
-
"css-loader": "^6.5.0",
|
|
54
47
|
"jest": "^29.3.1",
|
|
55
48
|
"jest-environment-jsdom": "^29.3.1",
|
|
56
49
|
"prettier": "2.8.2",
|
|
57
|
-
"style-loader": "^3.3.1",
|
|
58
50
|
"webpack": "^5.107.2",
|
|
59
51
|
"webpack-cli": "^5.0.1",
|
|
60
52
|
"whatwg-fetch": "^3.6.20"
|
|
@@ -94,7 +86,7 @@
|
|
|
94
86
|
"@emoji-mart/data": "^1.2.1",
|
|
95
87
|
"@floating-ui/dom": "^1.7.3",
|
|
96
88
|
"@hotwired/stimulus": "^3.0.0",
|
|
97
|
-
"dompurify": "^3.4.
|
|
89
|
+
"dompurify": "^3.4.14",
|
|
98
90
|
"emoji-mart": "^5.6.0"
|
|
99
91
|
},
|
|
100
92
|
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610",
|
package/src/api/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import IdentificationsAPI from './identifications'
|
|
|
5
5
|
import WebchatsAPI from './webchats'
|
|
6
6
|
import WhatsAppWidgetsAPI from './whatsapp_widgets'
|
|
7
7
|
import AcksAPI from './acks'
|
|
8
|
+
import PushIdentitiesAPI from './push/identities'
|
|
8
9
|
|
|
9
10
|
// Browsers keep `fetch(..., { keepalive: true })` requests alive during page
|
|
10
11
|
// unload/navigation, which is exactly the failure mode for analytics events
|
|
@@ -57,6 +58,10 @@ export default class API {
|
|
|
57
58
|
static get acks() {
|
|
58
59
|
return AcksAPI
|
|
59
60
|
}
|
|
61
|
+
|
|
62
|
+
static get pushIdentities() {
|
|
63
|
+
return PushIdentitiesAPI
|
|
64
|
+
}
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
export { Response } from './response'
|