@ourlu/assistant-sdk 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/iife/audio.v1.028c93fe.js +160 -0
  2. package/dist/iife/audio.v1.051ececf.js +183 -0
  3. package/dist/iife/audio.v1.200db1a6.js +208 -0
  4. package/dist/iife/audio.v1.20858b08.js +191 -0
  5. package/dist/iife/audio.v1.2690e445.js +179 -0
  6. package/dist/iife/audio.v1.2742ff12.js +188 -0
  7. package/dist/iife/audio.v1.70af81b3.js +191 -0
  8. package/dist/iife/audio.v1.95146620.js +1 -1
  9. package/dist/iife/audio.v1.b330baaf.js +166 -0
  10. package/dist/iife/audio.v1.bb9c2d88.js +181 -0
  11. package/dist/iife/audio.v1.ea7571b2.js +182 -0
  12. package/dist/iife/audio.v1.fc0aa8af.js +191 -0
  13. package/dist/iife/audio.v1.js +107 -95
  14. package/dist/iife/engine.v1.2b5bb43b.js +3 -3
  15. package/dist/iife/engine.v1.3b09dc20.js +3 -3
  16. package/dist/iife/engine.v1.56074e5a.js +769 -0
  17. package/dist/iife/engine.v1.61c10e6c.js +770 -0
  18. package/dist/iife/engine.v1.773fc15d.js +2 -2
  19. package/dist/iife/engine.v1.80d2230f.js +3 -3
  20. package/dist/iife/engine.v1.940ba9ea.js +764 -0
  21. package/dist/iife/engine.v1.99a33ee2.js +767 -0
  22. package/dist/iife/engine.v1.9ca6b7ec.js +3 -3
  23. package/dist/iife/engine.v1.a1f7dea2.js +764 -0
  24. package/dist/iife/engine.v1.c0c00bd0.js +3 -3
  25. package/dist/iife/engine.v1.c127656e.js +820 -0
  26. package/dist/iife/engine.v1.c54c9a1a.js +3 -3
  27. package/dist/iife/engine.v1.d1052e81.js +3 -3
  28. package/dist/iife/engine.v1.f6d23a0f.js +770 -0
  29. package/dist/iife/engine.v1.js +75 -25
  30. package/dist/iife/loader.v1.js +5 -1
  31. package/dist/iife/signalement.v1.d321dfde.js +518 -0
  32. package/dist/iife/signalement.v1.js +518 -0
  33. package/dist/iife/ui.v1.00abf020.js +895 -0
  34. package/dist/iife/ui.v1.6becaa84.js +895 -0
  35. package/dist/iife/ui.v1.6c9e4995.js +895 -0
  36. package/dist/iife/ui.v1.88bf5494.js +898 -0
  37. package/dist/iife/ui.v1.a8cfe724.js +900 -0
  38. package/dist/iife/ui.v1.e007c7c4.js +926 -0
  39. package/dist/iife/ui.v1.e24ba2bd.js +903 -0
  40. package/dist/iife/ui.v1.f1d8e998.js +903 -0
  41. package/dist/iife/ui.v1.fc52b520.js +895 -0
  42. package/dist/iife/ui.v1.js +44 -77
  43. package/dist/iife/widget-manifest.json +4 -3
  44. package/package.json +2 -1
@@ -169,13 +169,13 @@ function installMascotTheme(ui) {
169
169
  return fetch(normalizedMascotUrl, { method: "GET", credentials: "omit" })
170
170
  .then(function(response) {
171
171
  if (!response.ok) {
172
- throw new Error("mascot fetch failed");
172
+ throw new Error("Impossible de charger la mascotte.");
173
173
  }
174
174
  return response.text();
175
175
  })
176
176
  .then(function(rawSvgMarkup) {
177
177
  if (!rawSvgMarkup || rawSvgMarkup.indexOf("<svg") === -1) {
178
- throw new Error("mascot SVG invalide ou reponse non-SVG pour " + normalizedMascotUrl);
178
+ throw new Error("Mascotte SVG invalide ou réponse non-SVG pour " + normalizedMascotUrl);
179
179
  }
180
180
  var themedSvgMarkup = ui.replaceSvgColorTokens(rawSvgMarkup, replacementMap);
181
181
  var themedDataUrl = ui.encodeSvgToDataUrl(themedSvgMarkup);
@@ -387,7 +387,6 @@ function installWidgetCssBuilder(ui) {
387
387
  WidgetCssBuilder.prototype.build = function() {
388
388
  var cfg = this.config;
389
389
  var side = cfg.position === "bottom-left" ? "left" : "right";
390
- var resizeCorner = cfg.position === "bottom-left" ? "right" : "left";
391
390
  var gradient = "linear-gradient(135deg," + cfg.primaryColor + " 0%,#0047b3 100%)";
392
391
  var panelBg = ui.hexToRgba(cfg.panelBackgroundColor, cfg.panelBackgroundAlpha);
393
392
  var layout = this.resolveLayout();
@@ -406,7 +405,6 @@ function installWidgetCssBuilder(ui) {
406
405
  this.buildMessageBubbles(cfg.primaryColor),
407
406
  this.buildTypingAndError(),
408
407
  this.buildComposer(cfg.primaryColor, br),
409
- this.buildResizeHandle(resizeCorner),
410
408
  this.buildMobileOverrides()
411
409
  ].join("\n");
412
410
  };
@@ -455,7 +453,7 @@ function installWidgetCssBuilder(ui) {
455
453
  return [
456
454
  "#cm-disclaimer,#cm-transparency{font-size:13px;display:flex;align-items:center;gap:8px;padding:8px 14px;flex-shrink:0}",
457
455
  "#cm-disclaimer{background:#e8f4fd;color:#1a5276;border-bottom:1px solid #b3d9f2}",
458
- "#cm-transparency{color:#555;border-top:1px solid #eee;background:#fff}",
456
+ "#cm-transparency{color:#555;border-top:1px solid #eee;background:#fff;display:none}",
459
457
  ".cm-close-note{background:none;border:none;cursor:pointer;border-radius:6px;padding:4px 8px;min-width:32px;min-height:32px;width:32px;opacity:.6;transition:opacity .15s,background .15s;flex-shrink:0;display:flex;align-items:center;justify-content:center;margin-left:auto}",
460
458
  ".cm-close-note:hover{opacity:1;background:rgba(0,0,0,.08)}",
461
459
  ".cm-close-note svg{width:16px;height:16px}"
@@ -504,7 +502,7 @@ function installWidgetCssBuilder(ui) {
504
502
 
505
503
  WidgetCssBuilder.prototype.buildComposer = function(primaryColor, borderRadius) {
506
504
  return [
507
- "#cm-form{display:flex;align-items:flex-end;gap:8px;padding:12px 16px;border-top:1px solid #eee;background:#fff;border-radius:0 0 " + borderRadius + " " + borderRadius + "}",
505
+ "#cm-form{display:flex;align-items:flex-end;gap:8px;padding:12px 16px;border-top:1px solid #eee;background:#fff;border-radius:0 0 " + borderRadius + " " + borderRadius + ";flex-shrink:0}",
508
506
  "#cm-input{flex:1;border:1.5px solid #d1d5db;border-radius:14px;padding:12px 16px;min-height:48px;max-height:200px;resize:none;outline:none;line-height:1.5;font-size:15px;transition:border-color .2s,box-shadow .2s;overflow-y:auto}",
509
507
  "#cm-input:focus{border-color:" + primaryColor + ";box-shadow:0 0 0 3px rgba(0,102,255,.15)}",
510
508
  "#cm-input::placeholder{color:#9ca3af}",
@@ -520,35 +518,23 @@ function installWidgetCssBuilder(ui) {
520
518
  ].join("\n");
521
519
  };
522
520
 
523
- WidgetCssBuilder.prototype.buildResizeHandle = function(corner) {
524
- var posX = corner === "left" ? "left:0" : "right:0";
525
- var cursorType = corner === "left" ? "ne-resize" : "nw-resize";
526
- return [
527
- "#cm-resize-handle{position:absolute;top:0;" + posX + ";width:28px;height:28px;cursor:" + cursorType + ";z-index:10;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .2s}",
528
- "#cm-panel:hover #cm-resize-handle{opacity:.5}",
529
- "#cm-resize-handle:hover{opacity:1 !important}",
530
- "#cm-resize-handle svg{width:14px;height:14px;pointer-events:none}"
531
- ].join("\n");
532
- };
533
-
534
521
  WidgetCssBuilder.prototype.buildMobileOverrides = function() {
535
522
  return [
536
523
  "@media (max-width:600px){",
537
524
  "#cm-bubble{width:56px;height:56px;bottom:16px;right:16px !important;left:auto !important}",
538
525
  "#cm-bubble img{width:72px;height:72px;top:-12px}",
539
- "#cm-panel{left:0 !important;right:0 !important;bottom:0 !important;top:0 !important;width:100% !important;max-width:none !important;height:100dvh !important;height:100vh !important;max-height:none !important;border-radius:0 !important}",
540
- "#cm-header{border-radius:0 !important;padding:14px 16px 14px 72px;min-height:52px}",
526
+ "#cm-panel{left:8px !important;right:8px !important;bottom:8px !important;top:8px !important;width:auto !important;max-width:none !important;height:auto !important;max-height:none !important}",
527
+ "#cm-header{padding:10px 12px 10px 76px}",
541
528
  "#cm-header-mascot{width:68px;height:68px;left:-4px;top:-6px}",
542
529
  "#cm-title{font-size:16px}",
543
530
  ".cm-header-btn-maximize{display:none !important}",
544
531
  "#cm-messages{flex:1;padding:12px 16px;gap:12px;overflow-y:auto}",
545
532
  ".cm-msg{max-width:92%;padding:12px 14px;font-size:15px;border-radius:16px}",
546
- "#cm-form{padding:10px 12px;padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));border-radius:0 !important;gap:8px}",
533
+ "#cm-form{padding:10px 12px;padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));gap:8px}",
547
534
  "#cm-input{min-height:44px;font-size:16px;border-radius:14px;padding:10px 14px}",
548
535
  "#cm-send,#cm-mic{width:44px;height:44px}",
549
536
  "#cm-typing{padding:6px 16px;font-size:13px}",
550
537
  "#cm-disclaimer,#cm-transparency{font-size:12px;padding:8px 12px}",
551
- "#cm-resize-handle{display:none !important}",
552
538
  "#cm-welcome{font-size:15px;padding:24px 16px}",
553
539
  "}"
554
540
  ].join("\n");
@@ -575,7 +561,6 @@ function installWidgetUIManager(ui) {
575
561
  this.streamingAssistantElement = null;
576
562
  this.streamingAssistantBuffer = "";
577
563
  this.themeOverrideStyle = null;
578
- this._resizeDragState = null;
579
564
  }
580
565
 
581
566
  WidgetUIManager.prototype.mount = function() {
@@ -584,10 +569,6 @@ function installWidgetUIManager(ui) {
584
569
  var css = cssBuilder.build();
585
570
  var esc = ui.escapeHtml;
586
571
  var escAttr = ui.escapeHtmlAttribute;
587
- var resizeCorner = this.config.position === "bottom-left" ? "right" : "left";
588
- var resizeSvg = resizeCorner === "left"
589
- ? '<svg viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><line x1="2" y1="12" x2="12" y2="2"/><line x1="2" y1="7" x2="7" y2="2"/></svg>'
590
- : '<svg viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><line x1="12" y1="12" x2="2" y2="2"/><line x1="12" y1="7" x2="7" y2="2"/></svg>';
591
572
 
592
573
  var host = document.createElement("div");
593
574
  host.id = ui.CONTAINER_ID;
@@ -600,8 +581,7 @@ function installWidgetUIManager(ui) {
600
581
  '<img id="cm-bubble-mascot" src="' + escAttr(this.config.mascotUrl) + '" alt="Mascotte assistant" />',
601
582
  "</button>",
602
583
  '<div id="cm-panel" role="dialog" aria-modal="true" aria-label="Chat ' + escAttr(this.config.assistantName) + '">',
603
- '<div id="cm-resize-handle" aria-hidden="true">' + resizeSvg + '</div>',
604
- '<div id="cm-header"><img id="cm-header-mascot" src="' + escAttr(this.config.mascotUrl) + '" alt="" /><h3 id="cm-title">' + esc(this.config.assistantName) + '</h3><div id="cm-header-actions"><button class="cm-header-btn cm-header-btn-maximize" id="cm-maximize" type="button" aria-label="Agrandir"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6"/><path d="M9 21H3v-6"/><path d="M21 3l-7 7"/><path d="M3 21l7-7"/></svg></button><button class="cm-header-btn" id="cm-trash" type="button" aria-label="R\u00e9initialiser"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg></button><button class="cm-header-btn" id="cm-close" type="button" aria-label="Fermer l\'assistant"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg></button></div></div>',
584
+ '<div id="cm-header"><img id="cm-header-mascot" src="' + escAttr(this.config.mascotUrl) + '" alt="" /><h3 id="cm-title">' + esc(this.config.assistantName) + '</h3><div id="cm-header-actions"><button class="cm-header-btn cm-header-btn-maximize" id="cm-maximize" type="button" aria-label="Agrandir"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6"/><path d="M9 21H3v-6"/><path d="M21 3l-7 7"/><path d="M3 21l7-7"/></svg></button><button class="cm-header-btn" id="cm-close" type="button" aria-label="Fermer l\'assistant"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg></button></div></div>',
605
585
  this.config.disclaimer ? '<div id="cm-disclaimer"><span>' + esc(this.config.disclaimerText) + '</span><button class="cm-close-note" id="cm-disclaimer-close" type="button" aria-label="Fermer l\'avertissement"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg></button></div>' : "",
606
586
  '<div id="cm-messages" aria-live="polite" aria-relevant="additions"><p id="cm-welcome">' + esc(this.config.welcomeMessage) + "</p></div>",
607
587
  '<div id="cm-typing">L\'assistant r\u00e9fl\u00e9chit\u2026</div>',
@@ -629,7 +609,6 @@ function installWidgetUIManager(ui) {
629
609
  root.appendChild(this.themeOverrideStyle);
630
610
  this.bindMascotImageErrorHandlers();
631
611
  this.bindAutoGrowInput();
632
- this.bindResizeHandle();
633
612
  this.applyThemeOverrides();
634
613
  this.applyMascotTheme();
635
614
  return true;
@@ -649,47 +628,6 @@ function installWidgetUIManager(ui) {
649
628
  inputEl.style.overflowY = "hidden";
650
629
  };
651
630
 
652
- WidgetUIManager.prototype.bindResizeHandle = function() {
653
- var handle = this.root ? this.root.querySelector("#cm-resize-handle") : null;
654
- var panel = this.panel;
655
- if (!handle || !panel) return;
656
- var self = this;
657
- var isLeftCorner = this.config.position !== "bottom-left";
658
-
659
- handle.addEventListener("mousedown", function(startEvt) {
660
- startEvt.preventDefault();
661
- startEvt.stopPropagation();
662
- var rect = panel.getBoundingClientRect();
663
- self._resizeDragState = {
664
- startX: startEvt.clientX,
665
- startY: startEvt.clientY,
666
- startW: rect.width,
667
- startH: rect.height
668
- };
669
- document.addEventListener("mousemove", onMouseMove);
670
- document.addEventListener("mouseup", onMouseUp);
671
- });
672
-
673
- function onMouseMove(evt) {
674
- var st = self._resizeDragState;
675
- if (!st) return;
676
- var dx = evt.clientX - st.startX;
677
- var dy = evt.clientY - st.startY;
678
- var newW = isLeftCorner ? st.startW - dx : st.startW + dx;
679
- var newH = st.startH - dy;
680
- newW = Math.max(360, Math.min(960, newW));
681
- newH = Math.max(480, Math.min(window.innerHeight - 40, newH));
682
- panel.style.width = newW + "px";
683
- panel.style.height = newH + "px";
684
- }
685
-
686
- function onMouseUp() {
687
- self._resizeDragState = null;
688
- document.removeEventListener("mousemove", onMouseMove);
689
- document.removeEventListener("mouseup", onMouseUp);
690
- }
691
- };
692
-
693
631
  WidgetUIManager.prototype.bindMascotImageErrorHandlers = function() {
694
632
  var self = this;
695
633
  [this.bubbleMascot, this.headerMascot].forEach(function(mascotNode) {
@@ -729,8 +667,6 @@ function installWidgetUIManager(ui) {
729
667
  var maximizeBtn = this.root.querySelector("#cm-maximize");
730
668
  var panelRef = this.panel;
731
669
  if (maximizeBtn && panelRef) maximizeBtn.addEventListener("click", function() { panelRef.classList.toggle("maximized"); });
732
- var trashBtn = this.root.querySelector("#cm-trash");
733
- if (trashBtn && callbacks.onReset) trashBtn.addEventListener("click", callbacks.onReset);
734
670
  };
735
671
 
736
672
  WidgetUIManager.prototype.setMascotSource = function(sourceUrl) {
@@ -833,18 +769,24 @@ function installWidgetUIManager(ui) {
833
769
  WidgetUIManager.prototype.setOpen = function(opened) {
834
770
  this.panel.classList.toggle("open", opened);
835
771
  this.bubble.style.display = opened ? "none" : "flex";
836
- if (opened) this.input.focus();
772
+ if (opened && !("ontouchstart" in window)) this.input.focus();
837
773
  };
838
774
 
839
775
  WidgetUIManager.prototype.pullInput = function() {
840
776
  var value = this.input.value.trim();
841
777
  this.input.value = "";
842
- this.input.style.height = "auto";
778
+ this.input.dispatchEvent(new Event("input", { bubbles: true }));
843
779
  return value;
844
780
  };
845
781
 
846
- WidgetUIManager.prototype.setInput = function(value) { this.input.value = String(value || ""); };
782
+ WidgetUIManager.prototype.setInput = function(value) {
783
+ this.input.value = String(value || "");
784
+ this.input.dispatchEvent(new Event("input", { bubbles: true }));
785
+ };
847
786
  WidgetUIManager.prototype.inputValue = function() { return this.input.value; };
787
+ WidgetUIManager.prototype.setInputPlaceholder = function(text) {
788
+ this.input.placeholder = text || "Posez votre question\u2026";
789
+ };
848
790
  WidgetUIManager.prototype.showTyping = function(visible) { this.typing.classList.toggle("visible", Boolean(visible)); };
849
791
 
850
792
  WidgetUIManager.prototype.setComposerDisabled = function(disabled) {
@@ -924,11 +866,36 @@ function installWidgetUIManager(ui) {
924
866
 
925
867
  WidgetUIManager.prototype.setMicListening = function(isListening) {
926
868
  this.micButton.classList.toggle("listening", isListening);
927
- this.micButton.textContent = isListening ? "\u23f9" : "\ud83c\udfa4";
928
- this.micButton.setAttribute("aria-label", isListening ? "Arrêter la dictée vocale" : "Dicter un message");
869
+ this.micButton.innerHTML = isListening
870
+ ? '<svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>'
871
+ : '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>';
872
+ this.micButton.setAttribute("aria-label", isListening ? "Arr\u00eater la dict\u00e9e vocale" : "Dicter un message");
929
873
  this.input.placeholder = isListening ? "Transcription en cours\u2026" : "Posez votre question\u2026";
930
874
  };
931
875
 
876
+ WidgetUIManager.prototype.getHeader = function() {
877
+ return this.root ? this.root.querySelector("#cm-header") : null;
878
+ };
879
+
880
+ WidgetUIManager.prototype.getPanel = function() {
881
+ return this.panel;
882
+ };
883
+
884
+ WidgetUIManager.prototype.getRoot = function() {
885
+ return this.root;
886
+ };
887
+
888
+ WidgetUIManager.prototype.injectSignalementButton = function(messageNode, onOpen) {
889
+ if (!messageNode) return null;
890
+ var btn = document.createElement("button");
891
+ btn.className = "cm-sig-open-btn";
892
+ btn.type = "button";
893
+ btn.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4"/><path d="M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/></svg>Mon signalement';
894
+ btn.addEventListener("click", function() { if (typeof onOpen === "function") onOpen(); });
895
+ messageNode.appendChild(btn);
896
+ return btn;
897
+ };
898
+
932
899
  ui.WidgetUIManager = WidgetUIManager;
933
900
  }
934
901
 
@@ -1,5 +1,6 @@
1
1
  {
2
- "ui.v1.js": "ui.v1.c58e1d58.js",
3
- "audio.v1.js": "audio.v1.95146620.js",
4
- "engine.v1.js": "engine.v1.d1052e81.js"
2
+ "ui.v1.js": "ui.v1.e007c7c4.js",
3
+ "audio.v1.js": "audio.v1.20858b08.js",
4
+ "signalement.v1.js": "signalement.v1.d321dfde.js",
5
+ "engine.v1.js": "engine.v1.c127656e.js"
5
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ourlu/assistant-sdk",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "SDK JavaScript pour l'assistant conversationnel Ourlu — widget intégrable pour les mairies.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -10,6 +10,7 @@
10
10
  "./loader.v1.js": "./dist/iife/loader.v1.js",
11
11
  "./ui.v1.js": "./dist/iife/ui.v1.js",
12
12
  "./audio.v1.js": "./dist/iife/audio.v1.js",
13
+ "./signalement.v1.js": "./dist/iife/signalement.v1.js",
13
14
  "./engine.v1.js": "./dist/iife/engine.v1.js"
14
15
  },
15
16
  "files": [