@flowengage/react-chatbot 1.8.2 → 1.8.3

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.
@@ -2443,49 +2443,47 @@ async function $n(e, { skipPushState: t = !1, isBack: n = !1 } = {}) {
2443
2443
  }
2444
2444
  return f(e);
2445
2445
  };
2446
- function m(e) {
2447
- let t = e.toLowerCase();
2448
- return !!(/\/jquery[.\-\/]/.test(t) || /\/jquery\.min\.js/.test(t) || /\/jquery-once/.test(t) || /\/jquery\.once/.test(t) || /\/jquery\.ui[\./]/.test(t) || /\/jqueryui/.test(t) || /\/core\/misc\//.test(t) || /\/core\/modules\//.test(t) || /\/misc\/drupal\.js/.test(t) || /\/lodash[.\-\/]/.test(t) || /\/underscore[.\-\/]/.test(t) || /\/backbone[.\-\/]/.test(t) || /\/modernizr[.\-\/]/.test(t) || /\/popper[.\-\/]/.test(t) || /\/bootstrap\.min\.js/.test(t) || /\/bootstrap\.bundle/.test(t));
2449
- }
2450
- let h = new Set(Array.from(document.querySelectorAll("script[src]")).map((e) => {
2446
+ let m = new Set(Array.from(document.querySelectorAll("script[src]")).map((e) => {
2451
2447
  try {
2452
2448
  return new URL(e.getAttribute("src") || "", window.location.href).href;
2453
2449
  } catch {
2454
2450
  return "";
2455
2451
  }
2456
2452
  }));
2457
- function g(t, n) {
2453
+ function h(t, n) {
2458
2454
  let r = t.getAttribute("src") || "";
2459
- if (r.includes("flowengage")) return;
2460
- let i = document.createElement("script");
2461
- if (r) {
2462
- let n;
2463
- try {
2464
- n = new URL(r, e).href;
2465
- } catch {
2466
- return;
2467
- }
2468
- if (h.has(n)) {
2469
- if (m(n)) return;
2470
- j("trySpaNavigate: re-running theme/custom script:", n);
2471
- }
2472
- h.add(n), i.src = n, i.async = t.async, i.defer = t.defer;
2473
- } else if (t.textContent.trim()) {
2474
- let e = t.textContent;
2475
- if (/window\.location\s*[.=]|location\s*\.\s*(href|assign|replace|reload)\s*[=(]/i.test(e)) {
2476
- j("trySpaNavigate: skipping inline script with navigation:", e.slice(0, 120));
2477
- return;
2455
+ if (!r.includes("flowengage")) {
2456
+ if (r) {
2457
+ let i;
2458
+ try {
2459
+ i = new URL(r, e).href;
2460
+ } catch {
2461
+ return;
2462
+ }
2463
+ if (m.has(i)) return;
2464
+ m.add(i);
2465
+ let a = document.createElement("script");
2466
+ a.src = i, a.async = t.async, a.defer = t.defer;
2467
+ let o = t.getAttribute("type");
2468
+ o && o !== "text/javascript" && o !== "" && (a.type = o), n.parentNode.insertBefore(a, n), j("trySpaNavigate: loading NEW external script:", i);
2469
+ } else if (t.textContent.trim()) {
2470
+ let e = t.textContent, r = t.getAttribute("type") || "";
2471
+ if (r && r !== "text/javascript" && r !== "" || /window\.location\s*[.=]|location\s*\.\s*(href|assign|replace|reload)\s*[=(]/i.test(e) || /drupalSettings\s*[,=]/.test(e)) return;
2472
+ let i = document.createElement("script");
2473
+ i.textContent = `(function(){try{${e}}catch(e){if(!(e instanceof SyntaxError))throw e;}})();`, n.parentNode.insertBefore(i, n);
2478
2474
  }
2479
- if (/^\s*\(?\s*(?:window\.)?drupalSettings\s*[,=]/.test(e)) return;
2480
- i.textContent = e;
2481
- } else return;
2482
- let a = t.getAttribute("type");
2483
- a && a !== "text/javascript" && a !== "" && (i.type = a), n.parentNode.insertBefore(i, n);
2484
- }
2485
- for (let e of Array.from(s.head.querySelectorAll("script"))) g(e, c);
2486
- for (let e of Array.from(s.body.querySelectorAll("script"))) g(e, c);
2475
+ }
2476
+ }
2477
+ for (let e of Array.from(s.body.querySelectorAll(":scope > script"))) h(e, c);
2487
2478
  try {
2488
- typeof window.Drupal?.attachBehaviors == "function" && window.Drupal.attachBehaviors(document.body, window.drupalSettings);
2479
+ if (typeof window.Drupal?.attachBehaviors == "function") {
2480
+ let e = window.Drupal.behaviors || {};
2481
+ for (let [t, n] of Object.entries(e)) if (typeof n.attach == "function") try {
2482
+ n.attach(document.body, window.drupalSettings);
2483
+ } catch (e) {
2484
+ j("trySpaNavigate: behavior", t, "attach error:", e.message);
2485
+ }
2486
+ }
2489
2487
  } catch {}
2490
2488
  try {
2491
2489
  typeof window.jQuery == "function" && (window.jQuery(document).trigger("ready"), window.dispatchEvent(new Event("resize")));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowengage/react-chatbot",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "Embeddable AI chat widget for React — powered by FlowEngage. Drop it in with a single siteId.",
5
5
  "keywords": [
6
6
  "chatbot",