@ourlu/assistant-sdk 0.2.3 → 0.2.4
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/dist/iife/engine.v1.2b5bb43b.js +735 -0
- package/dist/iife/engine.v1.80d2230f.js +770 -0
- package/dist/iife/engine.v1.9ca6b7ec.js +756 -0
- package/dist/iife/engine.v1.c0c00bd0.js +721 -0
- package/dist/iife/engine.v1.c54c9a1a.js +770 -0
- package/dist/iife/engine.v1.d1052e81.js +770 -0
- package/dist/iife/engine.v1.js +60 -11
- package/dist/iife/loader.v1.js +1 -1
- package/dist/iife/ui.v1.5d2d4504.js +942 -0
- package/dist/iife/ui.v1.6afac75f.js +944 -0
- package/dist/iife/ui.v1.7fb4db0b.js +935 -0
- package/dist/iife/ui.v1.923a4e6d.js +937 -0
- package/dist/iife/ui.v1.9bfe2815.js +942 -0
- package/dist/iife/ui.v1.c58e1d58.js +959 -0
- package/dist/iife/ui.v1.cdfe9a45.js +919 -0
- package/dist/iife/ui.v1.js +116 -76
- package/dist/iife/widget-manifest.json +2 -2
- package/package.json +1 -1
package/dist/iife/engine.v1.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
var trimTrailingSlash = runtime.utils.trimTrailingSlash;
|
|
10
10
|
var WidgetUIManager = runtime.WidgetUIManager, WidgetAudioManager = runtime.WidgetAudioManager;
|
|
11
11
|
var EventBus = runtime.EventBus, CONTAINER_ID = runtime.constants.CONTAINER_ID;
|
|
12
|
-
var MASCOT_SPECS = JSON.parse('[["mascotSecondaryColor","mascot_secondary_color","data-mascot-secondary-color","#
|
|
12
|
+
var MASCOT_SPECS = JSON.parse('[["mascotSecondaryColor","mascot_secondary_color","data-mascot-secondary-color","#68b1d6"],["mascotSecondaryDarkColor","mascot_secondary_dark_color","data-mascot-secondary-dark-color","#1472a8"],["mascotGoldColor","mascot_gold_color","data-mascot-gold-color","#ffd22e"],["mascotEyeColor","mascot_eye_color","data-mascot-eye-color","#040402"],["mascotBeakColor","mascot_beak_color","data-mascot-beak-color","#ab5f30"],["mascotClawColor","mascot_claw_color","data-mascot-claw-color","#ab5f30"],["mascotNeutralColor","mascot_neutral_color","data-mascot-neutral-color","#e6e6e6"],["mascotBrowColor","mascot_brow_color","data-mascot-brow-color","#3e3e3e"]]');
|
|
13
13
|
var CONFIG_STRING_ATTRS = JSON.parse('[["tenantId","data-tenant-id",""],["widgetKey","data-widget-key",""],["apiBaseUrl","data-api-base-url",""],["widgetOrigin","data-widget-origin",""],["bootstrapEndpoint","data-bootstrap-endpoint",""],["configEndpoint","data-config-endpoint",""],["sessionBootstrapToken","data-session-bootstrap-token",""],["sessionBootstrapTokenExpiresAt","data-session-bootstrap-token-expires-at",""],["chatSessionEndpoint","data-chat-session-endpoint","/v1/occe/chat/sessions"],["chatMessageTemplate","data-chat-message-template","/v1/occe/chat/sessions/{session_id}/messages"],["chatStreamTemplate","data-chat-stream-template","/v1/occe/chat/sessions/{session_id}/stream"],["chatAudioSessionTemplate","data-chat-audio-session-template","/v1/occe/chat/sessions/{session_id}/audio/session"],["chatAudioChunkTemplate","data-chat-audio-chunk-template","/v1/occe/chat/sessions/{session_id}/audio/chunk"],["chatAudioCloseTemplate","data-chat-audio-close-template","/v1/occe/chat/sessions/{session_id}/audio/close"],["chatAudioStreamTemplate","data-chat-audio-stream-template","/v1/occe/chat/sessions/{session_id}/audio/stream"],["panelWidth","data-panel-width","420"],["panelHeight","data-panel-height","640"],["panelMaxHeightVh","data-panel-max-height-vh","85"],["mascotUrl","data-mascot-url",""],["welcomeMessage","data-welcome-message","Bonjour ! Comment puis-je vous aider ?"],["disclaimerText","data-disclaimer-text","Assistant IA - Les reponses ne constituent pas une decision administrative officielle."],["transparencyText","data-transparency-text","Reponses generees par intelligence artificielle."]]');
|
|
14
14
|
var RUNTIME_ENDPOINT_SPECS = JSON.parse('[["chatSessionEndpoint","chat_session_endpoint","/v1/occe/chat/sessions"],["chatMessageTemplate","chat_message_template","/v1/occe/chat/sessions/{session_id}/messages"],["chatStreamTemplate","chat_stream_template","/v1/occe/chat/sessions/{session_id}/stream"],["chatAudioSessionTemplate","chat_audio_session_template","/v1/occe/chat/sessions/{session_id}/audio/session"],["chatAudioChunkTemplate","chat_audio_chunk_template","/v1/occe/chat/sessions/{session_id}/audio/chunk"],["chatAudioCloseTemplate","chat_audio_close_template","/v1/occe/chat/sessions/{session_id}/audio/close"],["chatAudioStreamTemplate","chat_audio_stream_template","/v1/occe/chat/sessions/{session_id}/audio/stream"]]');
|
|
15
15
|
function applyMascotLabelColors(config, labels) {
|
|
@@ -170,10 +170,10 @@ Object.assign(TurnstileChallengeManager.prototype, {
|
|
|
170
170
|
script.src = TURNSTILE_SCRIPT_URL;
|
|
171
171
|
script.async = true;
|
|
172
172
|
var timeoutId = setTimeout(function() {
|
|
173
|
-
reject(new Error("
|
|
173
|
+
reject(new Error("Le module de sécurité n'a pas pu se charger. Veuillez réessayer."));
|
|
174
174
|
}, TURNSTILE_LOAD_TIMEOUT_MS);
|
|
175
175
|
script.onload = function() { clearTimeout(timeoutId); self.scriptLoaded = true; resolve(); };
|
|
176
|
-
script.onerror = function() { clearTimeout(timeoutId); self.scriptLoadPromise = null; reject(new Error("
|
|
176
|
+
script.onerror = function() { clearTimeout(timeoutId); self.scriptLoadPromise = null; reject(new Error("Impossible de charger le module de sécurité.")); };
|
|
177
177
|
document.head.appendChild(script);
|
|
178
178
|
});
|
|
179
179
|
return this.scriptLoadPromise;
|
|
@@ -183,11 +183,46 @@ Object.assign(TurnstileChallengeManager.prototype, {
|
|
|
183
183
|
if (existing) return existing;
|
|
184
184
|
var container = document.createElement("div");
|
|
185
185
|
container.id = TURNSTILE_CONTAINER_ID;
|
|
186
|
-
container.style.cssText = "display:none;position:fixed;
|
|
186
|
+
container.style.cssText = "display:none;position:fixed;z-index:2147483647;background:transparent;padding:0;";
|
|
187
187
|
document.body.appendChild(container);
|
|
188
188
|
return container;
|
|
189
189
|
},
|
|
190
|
-
|
|
190
|
+
positionInsidePanel: function(container) {
|
|
191
|
+
var widgetHost = document.getElementById("__ourlu_widget_container");
|
|
192
|
+
if (!widgetHost || !widgetHost.shadowRoot) {
|
|
193
|
+
container.style.right = "24px";
|
|
194
|
+
container.style.bottom = "90px";
|
|
195
|
+
container.style.left = "";
|
|
196
|
+
container.style.top = "";
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
var panel = widgetHost.shadowRoot.querySelector("#cm-panel");
|
|
200
|
+
if (!panel) {
|
|
201
|
+
container.style.right = "24px";
|
|
202
|
+
container.style.bottom = "90px";
|
|
203
|
+
container.style.left = "";
|
|
204
|
+
container.style.top = "";
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
var rect = panel.getBoundingClientRect();
|
|
208
|
+
if (rect.width === 0 || rect.height === 0) {
|
|
209
|
+
container.style.right = "24px";
|
|
210
|
+
container.style.bottom = "90px";
|
|
211
|
+
container.style.left = "";
|
|
212
|
+
container.style.top = "";
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
var containerWidth = 300;
|
|
216
|
+
var containerHeight = 65;
|
|
217
|
+
container.style.left = Math.round(rect.left + (rect.width - containerWidth) / 2) + "px";
|
|
218
|
+
container.style.top = Math.round(rect.top + rect.height - containerHeight - 70) + "px";
|
|
219
|
+
container.style.right = "";
|
|
220
|
+
container.style.bottom = "";
|
|
221
|
+
},
|
|
222
|
+
showContainer: function(container) {
|
|
223
|
+
container.style.display = "block";
|
|
224
|
+
this.positionInsidePanel(container);
|
|
225
|
+
},
|
|
191
226
|
hideContainer: function(container) { container.style.display = "none"; },
|
|
192
227
|
isCachedTokenValid: function() {
|
|
193
228
|
return Boolean(this.cachedToken) && (Date.now() - this.cachedTokenTimestamp) < TURNSTILE_TOKEN_TTL_MS;
|
|
@@ -197,7 +232,7 @@ Object.assign(TurnstileChallengeManager.prototype, {
|
|
|
197
232
|
if (this.isCachedTokenValid()) return this.cachedToken;
|
|
198
233
|
await this.loadScript();
|
|
199
234
|
if (typeof window.turnstile === "undefined") {
|
|
200
|
-
throw new Error("
|
|
235
|
+
throw new Error("Le module de sécurité n'est pas disponible.");
|
|
201
236
|
}
|
|
202
237
|
var self = this;
|
|
203
238
|
var token = await new Promise(function(resolve, reject) {
|
|
@@ -205,7 +240,7 @@ Object.assign(TurnstileChallengeManager.prototype, {
|
|
|
205
240
|
var timeoutId = setTimeout(function() {
|
|
206
241
|
self.hideContainer(container);
|
|
207
242
|
self.cleanup();
|
|
208
|
-
reject(new Error("
|
|
243
|
+
reject(new Error("Vérification de sécurité expirée. Veuillez réessayer."));
|
|
209
244
|
}, TURNSTILE_CHALLENGE_TIMEOUT_MS);
|
|
210
245
|
if (self.widgetId !== null) { window.turnstile.remove(self.widgetId); self.widgetId = null; }
|
|
211
246
|
self.widgetId = window.turnstile.render(container, {
|
|
@@ -224,13 +259,13 @@ Object.assign(TurnstileChallengeManager.prototype, {
|
|
|
224
259
|
clearTimeout(timeoutId);
|
|
225
260
|
self.hideContainer(container);
|
|
226
261
|
self.cleanup();
|
|
227
|
-
reject(new Error("
|
|
262
|
+
reject(new Error("Erreur lors de la vérification de sécurité. Veuillez réessayer."));
|
|
228
263
|
},
|
|
229
264
|
"timeout-callback": function() {
|
|
230
265
|
clearTimeout(timeoutId);
|
|
231
266
|
self.hideContainer(container);
|
|
232
267
|
self.cleanup();
|
|
233
|
-
reject(new Error("
|
|
268
|
+
reject(new Error("La vérification de sécurité a expiré. Veuillez réessayer."));
|
|
234
269
|
}
|
|
235
270
|
});
|
|
236
271
|
});
|
|
@@ -671,7 +706,10 @@ function mountFromScript(scriptTag) {
|
|
|
671
706
|
onDone: function() {}
|
|
672
707
|
});
|
|
673
708
|
} catch (error) {
|
|
674
|
-
|
|
709
|
+
var sendErrorMessage = (error && error.message) || "Impossible d'envoyer le message.";
|
|
710
|
+
ui.showRetryableError(sendErrorMessage, function() {
|
|
711
|
+
handleSend(event);
|
|
712
|
+
});
|
|
675
713
|
} finally {
|
|
676
714
|
state.sending = false;
|
|
677
715
|
ui.showTyping(false);
|
|
@@ -684,7 +722,18 @@ function mountFromScript(scriptTag) {
|
|
|
684
722
|
events.emit(state.open ? "open" : "close", {});
|
|
685
723
|
if (state.open) {
|
|
686
724
|
api.ensureSession().catch(function(error) {
|
|
687
|
-
|
|
725
|
+
var errorMessage = (error && error.message) || "Impossible d'initialiser le chat.";
|
|
726
|
+
ui.showRetryableError(errorMessage, function() {
|
|
727
|
+
state.sessionId = "";
|
|
728
|
+
state.token = "";
|
|
729
|
+
state.bootstrapPromise = null;
|
|
730
|
+
state.sessionPromise = null;
|
|
731
|
+
if (turnstile) turnstile.invalidateCache();
|
|
732
|
+
api.prefetchedBootstrapAcked = false;
|
|
733
|
+
api.ensureSession().catch(function(retryError) {
|
|
734
|
+
ui.showRetryableError((retryError && retryError.message) || "Impossible d'initialiser le chat.", arguments.callee);
|
|
735
|
+
});
|
|
736
|
+
});
|
|
688
737
|
});
|
|
689
738
|
}
|
|
690
739
|
}
|
package/dist/iife/loader.v1.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function() {
|
|
2
2
|
"use strict";
|
|
3
|
-
var __WIDGET_MANIFEST__ = {"ui.v1.js":"ui.v1.
|
|
3
|
+
var __WIDGET_MANIFEST__ = {"ui.v1.js":"ui.v1.c58e1d58.js","audio.v1.js":"audio.v1.95146620.js","engine.v1.js":"engine.v1.d1052e81.js"};
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var RUNTIME_NS = "__OurluWidgetRuntimeV1";
|