@telia-ace/widget-conversation 1.0.12 → 1.0.13
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/{lib-esm → dist}/agent.d.ts +0 -0
- package/{lib-esm → dist}/conversation-controller.d.ts +0 -0
- package/{lib-esm → dist}/conversation-form-adapter.d.ts +0 -0
- package/{lib-esm → dist}/conversation-platform.d.ts +0 -0
- package/{lib-esm → dist}/conversation-provider.d.ts +0 -0
- package/dist/conversation.js +1357 -0
- package/dist/conversation.js.map +1 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +867 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/resolve-entity-value.d.ts +0 -0
- package/dist/return-button.js +174 -0
- package/dist/return-button.js.map +1 -0
- package/{lib-esm → dist}/types.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-component.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-content.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-input.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-loader.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-message.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-styles.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/agent.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/custom-message-list-item.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/custom.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/system.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/timestamp.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/user.d.ts +0 -0
- package/{lib-esm → dist}/ui/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/return-button/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/return-button/return-button-component.d.ts +0 -0
- package/{lib-esm → dist}/ui/return-button/return-button.d.ts +0 -0
- package/{lib-esm → dist}/user.d.ts +0 -0
- package/{lib-esm → dist}/utils/custom-message.d.ts +0 -0
- package/{lib-esm → dist}/utils/index.d.ts +0 -0
- package/{lib-esm → dist}/utils/open-chat-widget.d.ts +0 -0
- package/package.json +14 -15
- package/lib/agent.d.ts +0 -17
- package/lib/agent.js +0 -37
- package/lib/conversation-controller.d.ts +0 -88
- package/lib/conversation-controller.js +0 -318
- package/lib/conversation-form-adapter.d.ts +0 -7
- package/lib/conversation-form-adapter.js +0 -88
- package/lib/conversation-platform.d.ts +0 -49
- package/lib/conversation-platform.js +0 -295
- package/lib/conversation-provider.d.ts +0 -22
- package/lib/conversation-provider.js +0 -73
- package/lib/index.d.ts +0 -9
- package/lib/index.js +0 -17
- package/lib/resolve-entity-value.d.ts +0 -10
- package/lib/resolve-entity-value.js +0 -22
- package/lib/types.d.ts +0 -110
- package/lib/types.js +0 -19
- package/lib/ui/conversation/conversation-component.d.ts +0 -37
- package/lib/ui/conversation/conversation-component.js +0 -152
- package/lib/ui/conversation/conversation-content.d.ts +0 -11
- package/lib/ui/conversation/conversation-content.js +0 -240
- package/lib/ui/conversation/conversation-input.d.ts +0 -6
- package/lib/ui/conversation/conversation-input.js +0 -163
- package/lib/ui/conversation/conversation-loader.d.ts +0 -8
- package/lib/ui/conversation/conversation-loader.js +0 -18
- package/lib/ui/conversation/conversation-message.d.ts +0 -7
- package/lib/ui/conversation/conversation-message.js +0 -141
- package/lib/ui/conversation/conversation-styles.d.ts +0 -11
- package/lib/ui/conversation/conversation-styles.js +0 -65
- package/lib/ui/conversation/conversation.d.ts +0 -6
- package/lib/ui/conversation/conversation.js +0 -139
- package/lib/ui/conversation/index.d.ts +0 -2
- package/lib/ui/conversation/index.js +0 -7
- package/lib/ui/conversation/message-types/agent.d.ts +0 -11
- package/lib/ui/conversation/message-types/agent.js +0 -54
- package/lib/ui/conversation/message-types/custom-message-list-item.d.ts +0 -9
- package/lib/ui/conversation/message-types/custom-message-list-item.js +0 -27
- package/lib/ui/conversation/message-types/custom.d.ts +0 -9
- package/lib/ui/conversation/message-types/custom.js +0 -50
- package/lib/ui/conversation/message-types/index.d.ts +0 -5
- package/lib/ui/conversation/message-types/index.js +0 -16
- package/lib/ui/conversation/message-types/system.d.ts +0 -12
- package/lib/ui/conversation/message-types/system.js +0 -26
- package/lib/ui/conversation/message-types/timestamp.d.ts +0 -8
- package/lib/ui/conversation/message-types/timestamp.js +0 -36
- package/lib/ui/conversation/message-types/user.d.ts +0 -8
- package/lib/ui/conversation/message-types/user.js +0 -24
- package/lib/ui/index.d.ts +0 -2
- package/lib/ui/index.js +0 -10
- package/lib/ui/return-button/index.d.ts +0 -2
- package/lib/ui/return-button/index.js +0 -7
- package/lib/ui/return-button/return-button-component.d.ts +0 -19
- package/lib/ui/return-button/return-button-component.js +0 -70
- package/lib/ui/return-button/return-button.d.ts +0 -6
- package/lib/ui/return-button/return-button.js +0 -82
- package/lib/user.d.ts +0 -7
- package/lib/user.js +0 -16
- package/lib/utils/custom-message.d.ts +0 -3
- package/lib/utils/custom-message.js +0 -56
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -7
- package/lib/utils/open-chat-widget.d.ts +0 -4
- package/lib/utils/open-chat-widget.js +0 -148
- package/lib-esm/agent.js +0 -34
- package/lib-esm/conversation-controller.js +0 -314
- package/lib-esm/conversation-form-adapter.js +0 -85
- package/lib-esm/conversation-platform.js +0 -292
- package/lib-esm/conversation-provider.js +0 -70
- package/lib-esm/index.js +0 -6
- package/lib-esm/resolve-entity-value.js +0 -18
- package/lib-esm/types.js +0 -16
- package/lib-esm/ui/conversation/conversation-component.js +0 -127
- package/lib-esm/ui/conversation/conversation-content.js +0 -212
- package/lib-esm/ui/conversation/conversation-input.js +0 -138
- package/lib-esm/ui/conversation/conversation-loader.js +0 -13
- package/lib-esm/ui/conversation/conversation-message.js +0 -113
- package/lib-esm/ui/conversation/conversation-styles.js +0 -39
- package/lib-esm/ui/conversation/conversation.js +0 -111
- package/lib-esm/ui/conversation/index.js +0 -2
- package/lib-esm/ui/conversation/message-types/agent.js +0 -25
- package/lib-esm/ui/conversation/message-types/custom-message-list-item.js +0 -22
- package/lib-esm/ui/conversation/message-types/custom.js +0 -25
- package/lib-esm/ui/conversation/message-types/index.js +0 -5
- package/lib-esm/ui/conversation/message-types/system.js +0 -20
- package/lib-esm/ui/conversation/message-types/timestamp.js +0 -31
- package/lib-esm/ui/conversation/message-types/user.js +0 -19
- package/lib-esm/ui/index.js +0 -2
- package/lib-esm/ui/return-button/index.js +0 -2
- package/lib-esm/ui/return-button/return-button-component.js +0 -44
- package/lib-esm/ui/return-button/return-button.js +0 -54
- package/lib-esm/user.js +0 -13
- package/lib-esm/utils/custom-message.js +0 -52
- package/lib-esm/utils/index.js +0 -1
- package/lib-esm/utils/open-chat-widget.js +0 -142
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.ConversationPlatform = exports.ConversationEndedBehavior = void 0;
|
|
40
|
-
var widget_core_1 = require("@telia-ace/widget-core");
|
|
41
|
-
var widget_services_1 = require("@telia-ace/widget-services");
|
|
42
|
-
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
43
|
-
var conversation_controller_1 = require("./conversation-controller");
|
|
44
|
-
var utils_1 = require("./utils");
|
|
45
|
-
var STORAGE_KEY = 'conversations';
|
|
46
|
-
var ConversationEndedBehavior;
|
|
47
|
-
(function (ConversationEndedBehavior) {
|
|
48
|
-
ConversationEndedBehavior["Deactivate"] = "deactivate";
|
|
49
|
-
ConversationEndedBehavior["Navigate"] = "navigate";
|
|
50
|
-
ConversationEndedBehavior["None"] = "none";
|
|
51
|
-
})(ConversationEndedBehavior = exports.ConversationEndedBehavior || (exports.ConversationEndedBehavior = {}));
|
|
52
|
-
var ConversationPlatform = /** @class */ (function () {
|
|
53
|
-
function ConversationPlatform(container, components) {
|
|
54
|
-
this.container = container;
|
|
55
|
-
this.components = components;
|
|
56
|
-
this.controllers = [];
|
|
57
|
-
this.providers = [];
|
|
58
|
-
this.disposeProviders = {};
|
|
59
|
-
this.subscriptions = [];
|
|
60
|
-
this.storageWriter = null;
|
|
61
|
-
this.router = null;
|
|
62
|
-
this.buttonQuery = null;
|
|
63
|
-
this.sessionInfo = null;
|
|
64
|
-
var widget = container.get('$widget');
|
|
65
|
-
this.events = widget.events.createChild(this);
|
|
66
|
-
}
|
|
67
|
-
ConversationPlatform.prototype.initialize = function () {
|
|
68
|
-
var _this = this;
|
|
69
|
-
(0, widget_services_1.createStorageWriter)(this.container, STORAGE_KEY, widget_services_1.StorageCategory.Necessary, {
|
|
70
|
-
medium: widget_services_1.StorageMedium.Local,
|
|
71
|
-
}).then(function (writer) { return (_this.storageWriter = writer); });
|
|
72
|
-
(0, widget_services_1.readStorage)(this.container, STORAGE_KEY, widget_services_1.StorageMedium.Local).then(function (storedSession) {
|
|
73
|
-
_this.buttonQuery = _this.components
|
|
74
|
-
.components()
|
|
75
|
-
.ofType('conversation-return-button');
|
|
76
|
-
if (storedSession) {
|
|
77
|
-
_this.sessionInfo = storedSession;
|
|
78
|
-
if (storedSession.id && storedSession.route) {
|
|
79
|
-
_this.writeToComponents({ active: true, alert: { show: false } });
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
this.container.getAsync('router').then(function (router) { return (_this.router = router); });
|
|
84
|
-
this.events.subscribe('conversation:ended', function (event, data) {
|
|
85
|
-
var _a, _b, _c;
|
|
86
|
-
switch ((_a = _this.sessionInfo) === null || _a === void 0 ? void 0 : _a.conversationEndedBehavior) {
|
|
87
|
-
case ConversationEndedBehavior.Deactivate:
|
|
88
|
-
var widget = _this.container.get('$widget');
|
|
89
|
-
widget.deactivate();
|
|
90
|
-
break;
|
|
91
|
-
case ConversationEndedBehavior.Navigate:
|
|
92
|
-
var initialRoute = (_b = _this.router) === null || _b === void 0 ? void 0 : _b.getInitialRoute();
|
|
93
|
-
if (initialRoute) {
|
|
94
|
-
(_c = _this.router) === null || _c === void 0 ? void 0 : _c.navigate(initialRoute.name);
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
case ConversationEndedBehavior.None:
|
|
98
|
-
default:
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
_this.writeToComponents({ active: false });
|
|
102
|
-
_this.sessionInfo = null;
|
|
103
|
-
_this.storageWriter && _this.storageWriter();
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
ConversationPlatform.prototype.addSubscription = function (sub) {
|
|
107
|
-
this.subscriptions.push(sub);
|
|
108
|
-
};
|
|
109
|
-
ConversationPlatform.getInstance = function (container, key) {
|
|
110
|
-
if (key === void 0) { key = 'conversation'; }
|
|
111
|
-
return (0, widget_utilities_1.lock)(container)(function () {
|
|
112
|
-
return container.getAsync(key).then(function (value) {
|
|
113
|
-
var conversation = value;
|
|
114
|
-
if (!conversation) {
|
|
115
|
-
return widget_core_1.ComponentPlatform.getInstance(container).then(function (components) {
|
|
116
|
-
conversation = new ConversationPlatform(container, components);
|
|
117
|
-
conversation.initialize();
|
|
118
|
-
container.registerAsync(key, function () { return conversation; });
|
|
119
|
-
return conversation;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return conversation;
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
ConversationPlatform.prototype.navigateToConversationIfActive = function (id) {
|
|
127
|
-
var _this = this;
|
|
128
|
-
return (0, widget_services_1.readStorage)(this.container, STORAGE_KEY, widget_services_1.StorageMedium.Local).then(function (storedSession) {
|
|
129
|
-
var _a;
|
|
130
|
-
if (storedSession && storedSession.id === id) {
|
|
131
|
-
if (storedSession.route) {
|
|
132
|
-
var _b = storedSession.route, name_1 = _b.name, params = _b.params;
|
|
133
|
-
(_a = _this.router) === null || _a === void 0 ? void 0 : _a.navigate(name_1, params);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
ConversationPlatform.prototype.setConversationEndedBehavior = function (behavior) {
|
|
139
|
-
var _this = this;
|
|
140
|
-
return (0, widget_services_1.readStorage)(this.container, STORAGE_KEY, widget_services_1.StorageMedium.Local).then(function (stored) {
|
|
141
|
-
var storedSession = stored;
|
|
142
|
-
if (storedSession) {
|
|
143
|
-
storedSession.conversationEndedBehavior = behavior;
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
storedSession = { conversationEndedBehavior: behavior };
|
|
147
|
-
}
|
|
148
|
-
_this.sessionInfo = storedSession;
|
|
149
|
-
return ((_this.storageWriter && _this.storageWriter(_this.sessionInfo)) ||
|
|
150
|
-
Promise.resolve());
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
ConversationPlatform.prototype.createController = function (id) {
|
|
154
|
-
var index = this.controllers.findIndex(function (c) { return c.conversation.id === id; });
|
|
155
|
-
if (index > -1) {
|
|
156
|
-
return this.controllers[index].conversation;
|
|
157
|
-
}
|
|
158
|
-
return new conversation_controller_1.ConversationController(this.container, id);
|
|
159
|
-
};
|
|
160
|
-
ConversationPlatform.prototype.registerProvider = function (name, handler) {
|
|
161
|
-
var _this = this;
|
|
162
|
-
var provider = {
|
|
163
|
-
name: name,
|
|
164
|
-
handler: handler,
|
|
165
|
-
};
|
|
166
|
-
this.providers.push(provider);
|
|
167
|
-
// execute provider for all matching controllers
|
|
168
|
-
this.controllers
|
|
169
|
-
.filter(function (controller) { return controller.conversation.providers.indexOf(name) > -1; })
|
|
170
|
-
.forEach(function (controller) {
|
|
171
|
-
_this.invokeHandler(provider, controller);
|
|
172
|
-
});
|
|
173
|
-
};
|
|
174
|
-
ConversationPlatform.prototype.registerController = function (conversation, component) {
|
|
175
|
-
var _this = this;
|
|
176
|
-
var index = this.controllers.findIndex(function (c) { return c.conversation.id === conversation.id; });
|
|
177
|
-
var controller;
|
|
178
|
-
if (index < 0) {
|
|
179
|
-
controller = { conversation: conversation, component: component };
|
|
180
|
-
this.controllers.push(controller);
|
|
181
|
-
var invokeHandlers_1 = function (providers) {
|
|
182
|
-
if (providers) {
|
|
183
|
-
_this.providers
|
|
184
|
-
.filter(function (provider) { return providers.indexOf(provider.name) > -1; })
|
|
185
|
-
.forEach(function (provider) {
|
|
186
|
-
_this.invokeHandler(provider, controller);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
this.subscriptions.push(conversation.onDispose(function (event, data) {
|
|
191
|
-
var index = _this.controllers.findIndex(function (c) { return c.conversation === data; });
|
|
192
|
-
index > -1 && _this.controllers.splice(index, 1);
|
|
193
|
-
_this.components
|
|
194
|
-
.components()
|
|
195
|
-
.ofType('conversation-return-button')
|
|
196
|
-
.select()
|
|
197
|
-
.writeProperties({ active: false });
|
|
198
|
-
_this.events.dispatch('conversation:ended', {}, { bubbles: true });
|
|
199
|
-
}));
|
|
200
|
-
this.subscriptions.push(conversation.onProvidersChange(function (event, data) {
|
|
201
|
-
var added = data.added, removed = data.removed;
|
|
202
|
-
removed.forEach(function (removedProvider) {
|
|
203
|
-
_this.disposeProviders[removedProvider].forEach(function (dispose) {
|
|
204
|
-
dispose();
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
invokeHandlers_1(added);
|
|
208
|
-
}));
|
|
209
|
-
this.subscriptions.push(conversation.onStarted(function (event, isActive) {
|
|
210
|
-
var _a, _b;
|
|
211
|
-
var session = {
|
|
212
|
-
id: conversation.id,
|
|
213
|
-
route: (_a = _this.router) === null || _a === void 0 ? void 0 : _a.getRouteData(),
|
|
214
|
-
conversationEndedBehavior: (_b = _this.sessionInfo) === null || _b === void 0 ? void 0 : _b.conversationEndedBehavior,
|
|
215
|
-
};
|
|
216
|
-
_this.sessionInfo = session;
|
|
217
|
-
_this.storageWriter && _this.storageWriter(session);
|
|
218
|
-
_this.writeToComponents({ active: isActive });
|
|
219
|
-
}));
|
|
220
|
-
this.subscriptions.push(conversation.onUnreadMessage(function (event, data) {
|
|
221
|
-
_this.events.dispatch('conversation:unread-message', data);
|
|
222
|
-
_this.writeToComponents({ alert: { show: data } });
|
|
223
|
-
}));
|
|
224
|
-
invokeHandlers_1(conversation.providers);
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
controller = this.controllers[index];
|
|
228
|
-
return false;
|
|
229
|
-
};
|
|
230
|
-
ConversationPlatform.prototype.writeToComponents = function (properties, key) {
|
|
231
|
-
if (key === void 0) { key = 'conversationReturnButtonState'; }
|
|
232
|
-
if (this.buttonQuery) {
|
|
233
|
-
this.components.write({
|
|
234
|
-
key: 'conversationReturnButtonState',
|
|
235
|
-
attributes: { properties: properties },
|
|
236
|
-
target: this.buttonQuery,
|
|
237
|
-
provider: 'localStorage',
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
ConversationPlatform.prototype.invokeHandler = function (provider, controller) {
|
|
242
|
-
var dispose = provider.handler(controller.conversation.createProvider(provider.name), controller.component);
|
|
243
|
-
if (dispose) {
|
|
244
|
-
if (!this.disposeProviders[provider.name]) {
|
|
245
|
-
this.disposeProviders[provider.name] = [];
|
|
246
|
-
}
|
|
247
|
-
this.disposeProviders[provider.name].push(dispose);
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
ConversationPlatform.prototype.getComponentRoute = function () {
|
|
251
|
-
return (0, widget_services_1.readStorage)(this.container, STORAGE_KEY, widget_services_1.StorageMedium.Local).then(function (stored) { return stored === null || stored === void 0 ? void 0 : stored.route; });
|
|
252
|
-
};
|
|
253
|
-
ConversationPlatform.prototype.dispose = function () {
|
|
254
|
-
var _this = this;
|
|
255
|
-
Object.keys(this.disposeProviders).forEach(function (key) {
|
|
256
|
-
_this.disposeProviders[key].forEach(function (dispose) {
|
|
257
|
-
dispose();
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
this.subscriptions.forEach(function (unsubscribe) {
|
|
261
|
-
unsubscribe();
|
|
262
|
-
});
|
|
263
|
-
this.controllers = [];
|
|
264
|
-
this.providers = [];
|
|
265
|
-
};
|
|
266
|
-
ConversationPlatform.handleContactMethodClick = function (event, container, contactMethod, callback) {
|
|
267
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
268
|
-
var triggerEl;
|
|
269
|
-
return __generator(this, function (_a) {
|
|
270
|
-
if ((0, utils_1.shouldPreventDefault)(container)) {
|
|
271
|
-
event.preventDefault();
|
|
272
|
-
triggerEl = document.getElementById('humany-dynamic-anchor');
|
|
273
|
-
if (!triggerEl) {
|
|
274
|
-
triggerEl = document.createElement('a');
|
|
275
|
-
triggerEl.setAttribute('href', '#');
|
|
276
|
-
triggerEl.id = 'humany-dynamic-anchor';
|
|
277
|
-
document.body.appendChild(triggerEl);
|
|
278
|
-
}
|
|
279
|
-
(0, utils_1.openChatWidget)(container, contactMethod, triggerEl);
|
|
280
|
-
}
|
|
281
|
-
(0, utils_1.openChatWidget)(container, contactMethod);
|
|
282
|
-
return [2 /*return*/];
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
};
|
|
286
|
-
ConversationPlatform.handleContactMethodSubmit = function (container, contactMethod) {
|
|
287
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
288
|
-
return __generator(this, function (_a) {
|
|
289
|
-
return [2 /*return*/, (0, utils_1.navigateToConversation)(container, contactMethod)];
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
};
|
|
293
|
-
return ConversationPlatform;
|
|
294
|
-
}());
|
|
295
|
-
exports.ConversationPlatform = ConversationPlatform;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Container, EventListener, EventSubscriptionCancellation } from '@webprovisions/platform';
|
|
2
|
-
import { Agent, AgentSettings } from './agent';
|
|
3
|
-
import { CancelLoaderDelegate, ConversationController, ConversationEntry, ConversationMessageType } from './conversation-controller';
|
|
4
|
-
import { ConversationMessageContent, ConversationMessageSender, ConversationMessageSettings } from './types';
|
|
5
|
-
export declare class ConversationProvider {
|
|
6
|
-
name: string;
|
|
7
|
-
private container;
|
|
8
|
-
controller: ConversationController | null;
|
|
9
|
-
private subscriptions;
|
|
10
|
-
user: any;
|
|
11
|
-
private constructor();
|
|
12
|
-
static create(name: string, container: Container, controller: ConversationController): ConversationProvider;
|
|
13
|
-
createAgent(settings?: AgentSettings): Agent | undefined;
|
|
14
|
-
print(settings: string | ConversationMessageSettings): ConversationEntry | undefined;
|
|
15
|
-
setTypingState(sender: ConversationMessageSender, type?: ConversationMessageType): (() => void) | undefined;
|
|
16
|
-
loading(): CancelLoaderDelegate;
|
|
17
|
-
createEntry(key: string, content: ConversationMessageContent, type: ConversationMessageType, sender?: ConversationMessageSender, timestamp?: number | null): ConversationEntry | undefined;
|
|
18
|
-
dispose(): void;
|
|
19
|
-
onUnreadMessage(fn: EventListener): EventSubscriptionCancellation | void;
|
|
20
|
-
onMounted(fn: EventListener): EventSubscriptionCancellation | void;
|
|
21
|
-
}
|
|
22
|
-
export default ConversationProvider;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConversationProvider = void 0;
|
|
4
|
-
var agent_1 = require("./agent");
|
|
5
|
-
var ConversationProvider = /** @class */ (function () {
|
|
6
|
-
function ConversationProvider(name, container, controller) {
|
|
7
|
-
this.name = name;
|
|
8
|
-
this.container = container;
|
|
9
|
-
this.controller = controller;
|
|
10
|
-
this.subscriptions = [];
|
|
11
|
-
this.user = controller === null || controller === void 0 ? void 0 : controller.user;
|
|
12
|
-
}
|
|
13
|
-
ConversationProvider.create = function (name, container, controller) {
|
|
14
|
-
return new ConversationProvider(name, container, controller);
|
|
15
|
-
};
|
|
16
|
-
ConversationProvider.prototype.createAgent = function (settings) {
|
|
17
|
-
if (settings === void 0) { settings = {}; }
|
|
18
|
-
if (this.controller) {
|
|
19
|
-
return new agent_1.Agent(this, settings);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
ConversationProvider.prototype.print = function (settings) {
|
|
23
|
-
var _a;
|
|
24
|
-
return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.print(settings);
|
|
25
|
-
};
|
|
26
|
-
ConversationProvider.prototype.setTypingState = function (sender, type) {
|
|
27
|
-
var _a;
|
|
28
|
-
return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.setTypingState(sender, type);
|
|
29
|
-
};
|
|
30
|
-
ConversationProvider.prototype.loading = function () {
|
|
31
|
-
if (!this.controller) {
|
|
32
|
-
return function () { return function () { }; };
|
|
33
|
-
}
|
|
34
|
-
return this.controller.loader();
|
|
35
|
-
};
|
|
36
|
-
ConversationProvider.prototype.createEntry = function (key, content, type, sender, timestamp) {
|
|
37
|
-
var _a;
|
|
38
|
-
return (_a = this.controller) === null || _a === void 0 ? void 0 : _a.createEntry(key, content, type, sender, timestamp);
|
|
39
|
-
};
|
|
40
|
-
ConversationProvider.prototype.dispose = function () {
|
|
41
|
-
var _a;
|
|
42
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
43
|
-
console.log("conversation-provider: dispose (".concat(this.name, ")"));
|
|
44
|
-
}
|
|
45
|
-
(_a = this.controller) === null || _a === void 0 ? void 0 : _a.disposeProvider(this);
|
|
46
|
-
this.controller = null;
|
|
47
|
-
this.subscriptions.forEach(function (unsub) { return unsub(); });
|
|
48
|
-
};
|
|
49
|
-
ConversationProvider.prototype.onUnreadMessage = function (fn) {
|
|
50
|
-
var _a;
|
|
51
|
-
if (this.controller) {
|
|
52
|
-
var unsubscribe_1 = (_a = this.controller) === null || _a === void 0 ? void 0 : _a.onUnreadMessage(fn);
|
|
53
|
-
this.subscriptions.push(unsubscribe_1);
|
|
54
|
-
return function () {
|
|
55
|
-
unsubscribe_1();
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
ConversationProvider.prototype.onMounted = function (fn) {
|
|
60
|
-
var _a;
|
|
61
|
-
if (this.controller) {
|
|
62
|
-
var unsubscribe_2 = (_a = this.controller) === null || _a === void 0 ? void 0 : _a.events.subscribe('conversation:component-mount-changed', fn);
|
|
63
|
-
this.subscriptions.push(unsubscribe_2);
|
|
64
|
-
fn({}, this.controller.getComponentMountedState());
|
|
65
|
-
return function () {
|
|
66
|
-
unsubscribe_2();
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
return ConversationProvider;
|
|
71
|
-
}());
|
|
72
|
-
exports.ConversationProvider = ConversationProvider;
|
|
73
|
-
exports.default = ConversationProvider;
|
package/lib/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ConversationEndedBehavior, ConversationPlatform, UnregisterControllerDelegate } from './conversation-platform';
|
|
2
|
-
export { ConversationController, ConversationEntry, ConversationMessageType, } from './conversation-controller';
|
|
3
|
-
export type { ConversationMessage } from './conversation-controller';
|
|
4
|
-
export { ConversationMessageListItemType } from './types';
|
|
5
|
-
export type { ConversationMessageContent, ConversationMessageSender, ConverstationMessageItem, } from './types';
|
|
6
|
-
export { ConversationComponent, ConversationReturnButtonComponent } from './ui';
|
|
7
|
-
export { registerCustomMessageComponent } from './utils/custom-message';
|
|
8
|
-
export { ConversationPlatform, ConversationEndedBehavior };
|
|
9
|
-
export type { UnregisterControllerDelegate };
|
package/lib/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConversationEndedBehavior = exports.ConversationPlatform = exports.registerCustomMessageComponent = exports.ConversationReturnButtonComponent = exports.ConversationComponent = exports.ConversationMessageListItemType = exports.ConversationMessageType = exports.ConversationEntry = exports.ConversationController = void 0;
|
|
4
|
-
var conversation_platform_1 = require("./conversation-platform");
|
|
5
|
-
Object.defineProperty(exports, "ConversationEndedBehavior", { enumerable: true, get: function () { return conversation_platform_1.ConversationEndedBehavior; } });
|
|
6
|
-
Object.defineProperty(exports, "ConversationPlatform", { enumerable: true, get: function () { return conversation_platform_1.ConversationPlatform; } });
|
|
7
|
-
var conversation_controller_1 = require("./conversation-controller");
|
|
8
|
-
Object.defineProperty(exports, "ConversationController", { enumerable: true, get: function () { return conversation_controller_1.ConversationController; } });
|
|
9
|
-
Object.defineProperty(exports, "ConversationEntry", { enumerable: true, get: function () { return conversation_controller_1.ConversationEntry; } });
|
|
10
|
-
Object.defineProperty(exports, "ConversationMessageType", { enumerable: true, get: function () { return conversation_controller_1.ConversationMessageType; } });
|
|
11
|
-
var types_1 = require("./types");
|
|
12
|
-
Object.defineProperty(exports, "ConversationMessageListItemType", { enumerable: true, get: function () { return types_1.ConversationMessageListItemType; } });
|
|
13
|
-
var ui_1 = require("./ui");
|
|
14
|
-
Object.defineProperty(exports, "ConversationComponent", { enumerable: true, get: function () { return ui_1.ConversationComponent; } });
|
|
15
|
-
Object.defineProperty(exports, "ConversationReturnButtonComponent", { enumerable: true, get: function () { return ui_1.ConversationReturnButtonComponent; } });
|
|
16
|
-
var custom_message_1 = require("./utils/custom-message");
|
|
17
|
-
Object.defineProperty(exports, "registerCustomMessageComponent", { enumerable: true, get: function () { return custom_message_1.registerCustomMessageComponent; } });
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { EventSubscriptionCancellation, Widget } from '@webprovisions/platform';
|
|
2
|
-
export declare type EntityValueResolver = (value: any) => void;
|
|
3
|
-
export declare type ResolveEntityValueHandler = (resolve: EntityValueResolver, originalValue: any) => any | Promise<any>;
|
|
4
|
-
/**
|
|
5
|
-
* Registers a handler to resolve entity values initiated by the backend service.
|
|
6
|
-
* @param widget Widget to resolve the entity value for.
|
|
7
|
-
* @param name Name of entity to resolve.
|
|
8
|
-
* @param handler Handler for resolving value.
|
|
9
|
-
*/
|
|
10
|
-
export declare const resolveEntityValue: (widget: Widget, name: string, handler: ResolveEntityValueHandler) => EventSubscriptionCancellation;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveEntityValue = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Registers a handler to resolve entity values initiated by the backend service.
|
|
6
|
-
* @param widget Widget to resolve the entity value for.
|
|
7
|
-
* @param name Name of entity to resolve.
|
|
8
|
-
* @param handler Handler for resolving value.
|
|
9
|
-
*/
|
|
10
|
-
var resolveEntityValue = function (widget, name, handler) {
|
|
11
|
-
return widget.events.subscribe('data:resolve-entity-value', function (event, data) {
|
|
12
|
-
if (data.name === name) {
|
|
13
|
-
return new Promise(function (resolve) {
|
|
14
|
-
handler(function (value) {
|
|
15
|
-
data.value = value;
|
|
16
|
-
resolve();
|
|
17
|
-
}, data.value);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
exports.resolveEntityValue = resolveEntityValue;
|
package/lib/types.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Form, FormBuilder } from '@telia-ace/widget-forms';
|
|
2
|
-
import { Symbol } from '@telia-ace/widget-ui';
|
|
3
|
-
export declare type ConversationMessageSettings = {
|
|
4
|
-
key?: string;
|
|
5
|
-
timestamp?: number;
|
|
6
|
-
title?: string;
|
|
7
|
-
body?: string;
|
|
8
|
-
actions?: {
|
|
9
|
-
[actionKey: string]: any;
|
|
10
|
-
};
|
|
11
|
-
form?: (builder: FormBuilder) => void;
|
|
12
|
-
type?: string;
|
|
13
|
-
items?: ConversationMessageList[];
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
};
|
|
16
|
-
export declare type NormalizedMessageSettings = {
|
|
17
|
-
content: ConversationMessageContent;
|
|
18
|
-
key: string;
|
|
19
|
-
timestamp: number | null;
|
|
20
|
-
};
|
|
21
|
-
export declare type ConversationMessageList = {
|
|
22
|
-
header?: string;
|
|
23
|
-
itemKey: string;
|
|
24
|
-
type?: ConversationMessageListType;
|
|
25
|
-
items: ConversationMessageListItem[];
|
|
26
|
-
};
|
|
27
|
-
export declare type ConversationMessageListItem = {
|
|
28
|
-
icon?: string;
|
|
29
|
-
type?: ConversationMessageListItemType;
|
|
30
|
-
actions?: {
|
|
31
|
-
[actionKey: string]: any;
|
|
32
|
-
};
|
|
33
|
-
form?: Form;
|
|
34
|
-
body?: string;
|
|
35
|
-
key: string;
|
|
36
|
-
[key: string]: any;
|
|
37
|
-
};
|
|
38
|
-
export declare type ConversationMessageContent = {
|
|
39
|
-
title?: string;
|
|
40
|
-
body?: string;
|
|
41
|
-
actions?: {
|
|
42
|
-
[actionKey: string]: any;
|
|
43
|
-
};
|
|
44
|
-
items?: ConverstationMessageItem<any>[];
|
|
45
|
-
form?: Form;
|
|
46
|
-
[key: string]: any;
|
|
47
|
-
};
|
|
48
|
-
export declare type ConverstationMessageItem<T, R = ItemPayload> = R extends [T, any] ? R : never;
|
|
49
|
-
export declare type ConversationMessageUpdateSettings = ConversationMessageContent & {
|
|
50
|
-
timestamp?: number;
|
|
51
|
-
};
|
|
52
|
-
export declare type ConversationMessageSender = {
|
|
53
|
-
name?: string;
|
|
54
|
-
avatar?: string | Symbol;
|
|
55
|
-
};
|
|
56
|
-
export declare enum ConversationMessageListType {
|
|
57
|
-
Ordinary = "ordinary",
|
|
58
|
-
Seperator = "seperator"
|
|
59
|
-
}
|
|
60
|
-
export declare enum ConversationMessageListItemType {
|
|
61
|
-
Header = "header",
|
|
62
|
-
LinkList = "link-list",
|
|
63
|
-
Separator = "separator",
|
|
64
|
-
NoGoodAlternative = "no-good-alternative",
|
|
65
|
-
ButtonList = "button-list",
|
|
66
|
-
Text = "text",
|
|
67
|
-
HTML = "html",
|
|
68
|
-
FeedbackList = "feedback-list"
|
|
69
|
-
}
|
|
70
|
-
declare type LinkListItem = [
|
|
71
|
-
ConversationMessageListItemType.LinkList,
|
|
72
|
-
{
|
|
73
|
-
actions: {
|
|
74
|
-
[key: string]: string;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
];
|
|
78
|
-
declare type HeaderItem = [ConversationMessageListItemType.Header, string];
|
|
79
|
-
declare type TextItem = [ConversationMessageListItemType.Text, string];
|
|
80
|
-
declare type SeparatorItem = [ConversationMessageListItemType.Separator, undefined];
|
|
81
|
-
declare type NoGoodAlternativeItem = [
|
|
82
|
-
ConversationMessageListItemType.NoGoodAlternative,
|
|
83
|
-
{
|
|
84
|
-
body: string;
|
|
85
|
-
}
|
|
86
|
-
];
|
|
87
|
-
declare type ButtonListItem = [
|
|
88
|
-
ConversationMessageListItemType.ButtonList,
|
|
89
|
-
{
|
|
90
|
-
actions: {
|
|
91
|
-
[key: string]: string;
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
];
|
|
95
|
-
declare type FeedbackListItem = [
|
|
96
|
-
ConversationMessageListItemType.FeedbackList,
|
|
97
|
-
{
|
|
98
|
-
actions: {
|
|
99
|
-
[key: string]: string;
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
];
|
|
103
|
-
declare type HTMLItem = [
|
|
104
|
-
ConversationMessageListItemType.HTML,
|
|
105
|
-
{
|
|
106
|
-
body: string;
|
|
107
|
-
}
|
|
108
|
-
];
|
|
109
|
-
declare type ItemPayload = LinkListItem | HeaderItem | TextItem | SeparatorItem | NoGoodAlternativeItem | ButtonListItem | HTMLItem | FeedbackListItem;
|
|
110
|
-
export {};
|
package/lib/types.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConversationMessageListItemType = exports.ConversationMessageListType = void 0;
|
|
4
|
-
var ConversationMessageListType;
|
|
5
|
-
(function (ConversationMessageListType) {
|
|
6
|
-
ConversationMessageListType["Ordinary"] = "ordinary";
|
|
7
|
-
ConversationMessageListType["Seperator"] = "seperator";
|
|
8
|
-
})(ConversationMessageListType = exports.ConversationMessageListType || (exports.ConversationMessageListType = {}));
|
|
9
|
-
var ConversationMessageListItemType;
|
|
10
|
-
(function (ConversationMessageListItemType) {
|
|
11
|
-
ConversationMessageListItemType["Header"] = "header";
|
|
12
|
-
ConversationMessageListItemType["LinkList"] = "link-list";
|
|
13
|
-
ConversationMessageListItemType["Separator"] = "separator";
|
|
14
|
-
ConversationMessageListItemType["NoGoodAlternative"] = "no-good-alternative";
|
|
15
|
-
ConversationMessageListItemType["ButtonList"] = "button-list";
|
|
16
|
-
ConversationMessageListItemType["Text"] = "text";
|
|
17
|
-
ConversationMessageListItemType["HTML"] = "html";
|
|
18
|
-
ConversationMessageListItemType["FeedbackList"] = "feedback-list";
|
|
19
|
-
})(ConversationMessageListItemType = exports.ConversationMessageListItemType || (exports.ConversationMessageListItemType = {}));
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Container } from '@webprovisions/platform';
|
|
2
|
-
import { ConversationMessage, ConversationMessageType } from '../../conversation-controller';
|
|
3
|
-
import { ConversationMessageContent, ConversationMessageSender } from '../../types';
|
|
4
|
-
export declare type BundledConversationMessage = {
|
|
5
|
-
timestamp: number;
|
|
6
|
-
content: [BundledMessageContent];
|
|
7
|
-
sender: ConversationMessageSender;
|
|
8
|
-
type: ConversationMessageType;
|
|
9
|
-
};
|
|
10
|
-
declare type BundledMessageContent = {
|
|
11
|
-
key: string;
|
|
12
|
-
} & ConversationMessageContent;
|
|
13
|
-
export declare type ConversationContent = {
|
|
14
|
-
loading: boolean;
|
|
15
|
-
typingActors: ConversationMessageSender[];
|
|
16
|
-
messages: ConversationMessage[];
|
|
17
|
-
};
|
|
18
|
-
export declare type ConversationComponentProperties = {
|
|
19
|
-
providers: string[];
|
|
20
|
-
messages: BundledConversationMessage[];
|
|
21
|
-
loading: boolean;
|
|
22
|
-
inputPlaceholder: string;
|
|
23
|
-
inputDisabled: boolean;
|
|
24
|
-
inputHidden: boolean;
|
|
25
|
-
inputMultiline: boolean;
|
|
26
|
-
userLabel: string;
|
|
27
|
-
avatarSize: string;
|
|
28
|
-
typingActors: any[];
|
|
29
|
-
sendButtonLabel: string;
|
|
30
|
-
secondaryAction?: {
|
|
31
|
-
icon?: string;
|
|
32
|
-
action: string;
|
|
33
|
-
label: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
declare const ConversationComponent: (container: Container) => Promise<void>;
|
|
37
|
-
export default ConversationComponent;
|