@eshal-bot/chat-widget 0.2.1 → 0.2.2

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.
@@ -1 +1 @@
1
- export{S as default}from"./chat-widget-index-D45VhRbc.esm.js";import"react";import"react-dom/client";import"react-dom";import"react/jsx-runtime";
1
+ export{S as default}from"./chat-widget-index-Da4GAL7R.esm.js";import"react";import"react-dom/client";import"react/jsx-runtime";import"react-dom";
@@ -14560,59 +14560,45 @@
14560
14560
  return typeof u === 'string' && /^https?:\/\//i.test(u) ? u : undefined;
14561
14561
  }
14562
14562
 
14563
- var jsxRuntime = {exports: {}};
14564
-
14565
- var reactJsxRuntime_production_min = {};
14566
-
14567
14563
  /**
14568
- * @license React
14569
- * react-jsx-runtime.production.min.js
14564
+ * WidgetCitationContext - the message's `sources` array + download handler,
14565
+ * supplied by `<MessageBubble>` and consumed by every `<CitationPill>` that
14566
+ * `rehypeCitations` renders inside the ReactMarkdown output.
14570
14567
  *
14571
- * Copyright (c) Facebook, Inc. and its affiliates.
14568
+ * EV-2904 - WHY THIS LIVES IN ITS OWN MODULE, BEHIND A GLOBAL SINGLETON
14569
+ * ---------------------------------------------------------------------
14570
+ * The vanilla/IIFE build (`chat-widget.min.js` - the `<script src=...>`
14571
+ * snippet customers actually install) ships the markdown pipeline as a
14572
+ * SEPARATE IIFE bundle, `chat-widget-markdown-chunk.min.js`, injected at
14573
+ * runtime by vanilla/lazyChunkLoader.js. Per rollup.config.js, `react` is
14574
+ * the ONLY module the two bundles share (via the `__eshalChatWidgetReact`
14575
+ * global) - every other module, including this one, is bundled a SECOND
14576
+ * time into the chunk.
14572
14577
  *
14573
- * This source code is licensed under the MIT license found in the
14574
- * LICENSE file in the root directory of this source tree.
14578
+ * The provider (`MessageBubble.jsx`) lives in the main bundle; the consumer
14579
+ * (`CitationPill.jsx`) is pulled in by `MarkdownRenderer.jsx` and therefore
14580
+ * lives in the chunk. With a plain `createContext(null)` in each bundle,
14581
+ * those are two DIFFERENT context objects: the pill's `useContext` finds no
14582
+ * matching Provider above it, falls back to the default `null`, and
14583
+ * `CitationPill` returns `null` (its "rendered outside a chat" guard). The
14584
+ * result is that citations silently vanish on the installed widget - no
14585
+ * error, no raw `[N]` leak - while the Testing Lab and the ESM/UMD builds
14586
+ * (single module graph) render them fine.
14587
+ *
14588
+ * Stashing the context object on a `window` key makes it a true
14589
+ * cross-bundle singleton: whichever bundle evaluates first creates it, the
14590
+ * other reuses it, so provider and consumer always agree. Safe for the
14591
+ * single-graph builds too - the second import just re-reads the same
14592
+ * object, which is exactly what a plain module-level `createContext` did.
14593
+ *
14594
+ * `createContext` must come from the one shared React instance for hooks to
14595
+ * work at all; rollup.config.js already guarantees that via the
14596
+ * `__eshalChatWidgetReact` global, so the object created here is valid in
14597
+ * both bundles.
14575
14598
  */
14576
- var f = reactExports,
14577
- k = Symbol.for("react.element"),
14578
- l = Symbol.for("react.fragment"),
14579
- m = Object.prototype.hasOwnProperty,
14580
- n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
14581
- p = {
14582
- key: true,
14583
- ref: true,
14584
- __self: true,
14585
- __source: true
14586
- };
14587
- function q(c, a, g) {
14588
- var b,
14589
- d = {},
14590
- e = null,
14591
- h = null;
14592
- void 0 !== g && (e = "" + g);
14593
- void 0 !== a.key && (e = "" + a.key);
14594
- void 0 !== a.ref && (h = a.ref);
14595
- for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
14596
- if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
14597
- return {
14598
- $$typeof: k,
14599
- type: c,
14600
- key: e,
14601
- ref: h,
14602
- props: d,
14603
- _owner: n.current
14604
- };
14605
- }
14606
- reactJsxRuntime_production_min.Fragment = l;
14607
- reactJsxRuntime_production_min.jsx = q;
14608
- reactJsxRuntime_production_min.jsxs = q;
14609
-
14610
- {
14611
- jsxRuntime.exports = reactJsxRuntime_production_min;
14612
- }
14613
- var jsxRuntimeExports = jsxRuntime.exports;
14614
-
14615
- const WidgetCitationContext = /*#__PURE__*/reactExports.createContext(null);
14599
+ const GLOBAL_KEY = "__eshalChatWidgetCitationContext";
14600
+ const globalScope = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : undefined;
14601
+ const WidgetCitationContext = globalScope ? globalScope[GLOBAL_KEY] || (globalScope[GLOBAL_KEY] = /*#__PURE__*/reactExports.createContext(null)) : /*#__PURE__*/reactExports.createContext(null);
14616
14602
 
14617
14603
  var _document$currentScri;
14618
14604
  // Runtime loader for the lazy markdown/chart chunk in the vanilla/IIFE
@@ -14687,6 +14673,58 @@
14687
14673
  return loadMarkdownRendererChunk();
14688
14674
  }
14689
14675
 
14676
+ var jsxRuntime = {exports: {}};
14677
+
14678
+ var reactJsxRuntime_production_min = {};
14679
+
14680
+ /**
14681
+ * @license React
14682
+ * react-jsx-runtime.production.min.js
14683
+ *
14684
+ * Copyright (c) Facebook, Inc. and its affiliates.
14685
+ *
14686
+ * This source code is licensed under the MIT license found in the
14687
+ * LICENSE file in the root directory of this source tree.
14688
+ */
14689
+ var f = reactExports,
14690
+ k = Symbol.for("react.element"),
14691
+ l = Symbol.for("react.fragment"),
14692
+ m = Object.prototype.hasOwnProperty,
14693
+ n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
14694
+ p = {
14695
+ key: true,
14696
+ ref: true,
14697
+ __self: true,
14698
+ __source: true
14699
+ };
14700
+ function q(c, a, g) {
14701
+ var b,
14702
+ d = {},
14703
+ e = null,
14704
+ h = null;
14705
+ void 0 !== g && (e = "" + g);
14706
+ void 0 !== a.key && (e = "" + a.key);
14707
+ void 0 !== a.ref && (h = a.ref);
14708
+ for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
14709
+ if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
14710
+ return {
14711
+ $$typeof: k,
14712
+ type: c,
14713
+ key: e,
14714
+ ref: h,
14715
+ props: d,
14716
+ _owner: n.current
14717
+ };
14718
+ }
14719
+ reactJsxRuntime_production_min.Fragment = l;
14720
+ reactJsxRuntime_production_min.jsx = q;
14721
+ reactJsxRuntime_production_min.jsxs = q;
14722
+
14723
+ {
14724
+ jsxRuntime.exports = reactJsxRuntime_production_min;
14725
+ }
14726
+ var jsxRuntimeExports = jsxRuntime.exports;
14727
+
14690
14728
  const MarkdownRenderer = /*#__PURE__*/reactExports.lazy(loadMarkdownRenderer);
14691
14729
 
14692
14730
  // The IIFE build's chunk loader does a real network fetch for a sibling