@burdenoff/website-sdk 2026.829.4 → 2026.829.6

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.
@@ -252,6 +252,12 @@ var EXPLORE_MESSAGE_FIELDS = (
252
252
  }
253
253
  followUps
254
254
  answered
255
+ attachments {
256
+ name
257
+ mimeType
258
+ size
259
+ textExtracted
260
+ }
255
261
  errorCode
256
262
  createdAt
257
263
  completedAt
@@ -337,6 +343,16 @@ var CREATE_EXPLORE_SHARE_LINK_MUTATION = (
337
343
  }
338
344
  `
339
345
  );
346
+ var EXPLORE_SHARED_CONVERSATION_QUERY = (
347
+ /* GraphQL */
348
+ `
349
+ query ExploreSharedConversation($shareToken: String!) {
350
+ exploreSharedConversation(shareToken: $shareToken) {
351
+ ${EXPLORE_MESSAGE_FIELDS}
352
+ }
353
+ }
354
+ `
355
+ );
340
356
 
341
357
  // src/data/products.ts
342
358
  var ECOSYSTEM_PRODUCTS = [
@@ -787,6 +803,14 @@ function readPersisted(key) {
787
803
  return null;
788
804
  }
789
805
  }
806
+ function readShareToken() {
807
+ if (typeof window === "undefined") return null;
808
+ try {
809
+ return new URL(window.location.href).searchParams.get("c");
810
+ } catch {
811
+ return null;
812
+ }
813
+ }
790
814
  function visibleText(message) {
791
815
  return message.content || message.partialContent || "";
792
816
  }
@@ -825,10 +849,18 @@ function useExploreChat(options = {}) {
825
849
  const pollGenerationRef = useRef(0);
826
850
  const pollTimerRef = useRef(null);
827
851
  const conversationTokenRef = useRef(null);
852
+ const shareTokenRef = useRef(void 0);
853
+ if (shareTokenRef.current === void 0) {
854
+ shareTokenRef.current = readShareToken();
855
+ }
856
+ const isSharedView = shareTokenRef.current !== null;
828
857
  const catalogRef = useRef(fallbackCatalog);
829
858
  const turnCountRef = useRef(0);
830
859
  const focusProductRef = useRef(null);
831
860
  const lastSentTextRef = useRef(null);
861
+ const lastSentAttachmentsRef = useRef(
862
+ []
863
+ );
832
864
  const inFlightRef = useRef(false);
833
865
  catalogRef.current = catalog;
834
866
  const clearPollTimer = useCallback(() => {
@@ -853,6 +885,43 @@ function useExploreChat(options = {}) {
853
885
  };
854
886
  }, []);
855
887
  useEffect(() => {
888
+ const shareToken = shareTokenRef.current;
889
+ if (!shareToken) return;
890
+ let cancelled = false;
891
+ setHydrated(true);
892
+ void client.query(
893
+ EXPLORE_SHARED_CONVERSATION_QUERY,
894
+ { shareToken },
895
+ { cache: false }
896
+ ).then((res) => {
897
+ if (cancelled || !mountedRef.current) return;
898
+ const shared = res?.data?.exploreSharedConversation;
899
+ if (shared && shared.length > 0) {
900
+ setMessages(shared);
901
+ return;
902
+ }
903
+ setError({
904
+ kind: "unknown",
905
+ code: "SHARE_NOT_FOUND",
906
+ message: "That shared conversation could not be found. The link may have expired.",
907
+ // Nothing to retry: a bad token will stay bad.
908
+ retryable: false
909
+ });
910
+ }).catch(() => {
911
+ if (cancelled || !mountedRef.current) return;
912
+ setError({
913
+ kind: "unknown",
914
+ code: "SHARE_NOT_FOUND",
915
+ message: "That shared conversation could not be loaded.",
916
+ retryable: true
917
+ });
918
+ });
919
+ return () => {
920
+ cancelled = true;
921
+ };
922
+ }, [client]);
923
+ useEffect(() => {
924
+ if (shareTokenRef.current !== null) return;
856
925
  if (!persist) {
857
926
  setHydrated(true);
858
927
  return;
@@ -1020,7 +1089,7 @@ function useExploreChat(options = {}) {
1020
1089
  [client, pollIntervalMs, pollTimeoutMs]
1021
1090
  );
1022
1091
  const submit = useCallback(
1023
- async (text, optimisticId, captchaAttempt) => {
1092
+ async (text, optimisticId, captchaAttempt, attachments) => {
1024
1093
  const activeCatalog = catalogRef.current;
1025
1094
  let recaptchaToken;
1026
1095
  if (activeCatalog.captchaRequired && activeCatalog.recaptchaSiteKey) {
@@ -1038,7 +1107,8 @@ function useExploreChat(options = {}) {
1038
1107
  ...focusProductRef.current || productSlug ? { productSlug: focusProductRef.current ?? productSlug } : {},
1039
1108
  ...recaptchaToken ? { recaptchaToken } : {},
1040
1109
  ...locale ? { locale } : {},
1041
- ...pageUrl ? { pageUrl } : {}
1110
+ ...pageUrl ? { pageUrl } : {},
1111
+ ...attachments.length > 0 ? { attachments: [...attachments] } : {}
1042
1112
  };
1043
1113
  const res = await client.mutate(
1044
1114
  SEND_EXPLORE_MESSAGE_MUTATION,
@@ -1052,7 +1122,7 @@ function useExploreChat(options = {}) {
1052
1122
  const code = typeof first?.extensions?.code === "string" ? first.extensions.code : void 0;
1053
1123
  const classified = classifyExploreError(code, first?.message);
1054
1124
  if (classified.kind === "captcha" && captchaAttempt === 0) {
1055
- await submit(text, optimisticId, 1);
1125
+ await submit(text, optimisticId, 1, attachments);
1056
1126
  return;
1057
1127
  }
1058
1128
  inFlightRef.current = false;
@@ -1089,7 +1159,7 @@ function useExploreChat(options = {}) {
1089
1159
  [client, locale, pageUrl, productSlug, startPolling]
1090
1160
  );
1091
1161
  const send = useCallback(
1092
- async (message) => {
1162
+ async (message, attachments = []) => {
1093
1163
  const text = message.trim();
1094
1164
  if (!text) return;
1095
1165
  if (inFlightRef.current) return;
@@ -1119,6 +1189,7 @@ function useExploreChat(options = {}) {
1119
1189
  }
1120
1190
  inFlightRef.current = true;
1121
1191
  lastSentTextRef.current = text;
1192
+ lastSentAttachmentsRef.current = attachments;
1122
1193
  setError(null);
1123
1194
  setPhase("sending");
1124
1195
  cancelPolling();
@@ -1141,7 +1212,7 @@ function useExploreChat(options = {}) {
1141
1212
  setTurnCount(turnCountRef.current);
1142
1213
  onSend?.(text);
1143
1214
  try {
1144
- await submit(text, optimistic.id, 0);
1215
+ await submit(text, optimistic.id, 0, attachments);
1145
1216
  } catch (err) {
1146
1217
  if (!mountedRef.current) return;
1147
1218
  console.error("[WebSDK] Explore send failed", err);
@@ -1190,7 +1261,7 @@ function useExploreChat(options = {}) {
1190
1261
  });
1191
1262
  turnCountRef.current = Math.max(0, turnCountRef.current - 1);
1192
1263
  setTurnCount(turnCountRef.current);
1193
- void send(text);
1264
+ void send(text, lastSentAttachmentsRef.current);
1194
1265
  }, [cancelPolling, send]);
1195
1266
  const reset = useCallback(() => {
1196
1267
  setArchive(
@@ -1204,6 +1275,7 @@ function useExploreChat(options = {}) {
1204
1275
  inFlightRef.current = false;
1205
1276
  conversationTokenRef.current = null;
1206
1277
  lastSentTextRef.current = null;
1278
+ lastSentAttachmentsRef.current = [];
1207
1279
  turnCountRef.current = 0;
1208
1280
  setTurnCount(0);
1209
1281
  setMessages([]);
@@ -1312,7 +1384,8 @@ function useExploreChat(options = {}) {
1312
1384
  deleteConversation,
1313
1385
  clearHistory,
1314
1386
  recordClick,
1315
- createShareLink
1387
+ createShareLink,
1388
+ isSharedView
1316
1389
  };
1317
1390
  }
1318
1391
  var optimisticCounter = 0;