@chrryai/chrry 1.5.41 → 1.5.43

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/index.js CHANGED
@@ -773,7 +773,7 @@ var init_siteConfig = __esm({
773
773
  favicon: "focus",
774
774
  mode: "focus",
775
775
  slug: "focus",
776
- version: "26.10.46",
776
+ version: "26.10.47",
777
777
  storeSlug: "blossom",
778
778
  name: "Focus",
779
779
  domain: "focus.chrry.ai",
@@ -2093,7 +2093,7 @@ var init_utils = __esm({
2093
2093
  };
2094
2094
  isFirefox = typeof navigator !== "undefined" && navigator?.userAgent?.includes("Firefox");
2095
2095
  config = getSiteConfig(getClientHostname());
2096
- VERSION = config.version || "1.5.41";
2096
+ VERSION = config.version || "1.5.43";
2097
2097
  getSlugFromPathname = (path) => {
2098
2098
  return getAppAndStoreSlugs(path, {
2099
2099
  defaultAppSlug: config.slug,
@@ -23341,7 +23341,6 @@ function AuthProvider({
23341
23341
  const API_PORT2 = process.env.API_PORT || "3001";
23342
23342
  const isTestingDevice2 = false;
23343
23343
  const chrryUrl = CHRRY_URL;
23344
- console.log(`\u{1F680} ~ AuthProvider ~ chrryUrl:`, chrryUrl);
23345
23344
  const [deviceId, setDeviceId] = useCookieOrLocalStorage(
23346
23345
  "deviceId",
23347
23346
  session2?.deviceId
@@ -23595,17 +23594,15 @@ function AuthProvider({
23595
23594
  sessionData?.app?.store?.apps || []
23596
23595
  );
23597
23596
  const getAppSlug = (targetApp, defaultSlug = "/") => {
23598
- const localeMatch = locales.find(
23599
- (loc) => pathname === `/${loc}` || pathname.startsWith(`/${loc}/`)
23600
- );
23597
+ const localeMatch = locales.find((loc) => {
23598
+ return pathname === `/${loc}` || pathname.startsWith(`/${loc}/`);
23599
+ });
23601
23600
  const localePrefix = localeMatch ? `/${localeMatch}` : "";
23602
23601
  let computedSlug = defaultSlug;
23603
23602
  if (targetApp) {
23604
23603
  if (targetApp.id === baseApp?.id) {
23605
23604
  computedSlug = defaultSlug;
23606
- } else if (baseApp?.id === chrry?.id && targetApp.id === chrry?.id) {
23607
- computedSlug = defaultSlug;
23608
- } else if (targetApp.id === chrry?.id || baseApp?.store?.apps.some((app2) => app2.id === targetApp.id)) {
23605
+ } else if (targetApp.id === app?.id && baseApp?.store?.apps.some((app2) => app2.id === targetApp.id)) {
23609
23606
  computedSlug = `/${targetApp.slug}`;
23610
23607
  } else {
23611
23608
  computedSlug = `/${targetApp.store?.slug}/${targetApp.slug}`;
@@ -23625,14 +23622,11 @@ function AuthProvider({
23625
23622
  }
23626
23623
  return computedSlug || defaultSlug;
23627
23624
  };
23628
- const baseApp = storeApps.concat(session2?.app?.store?.apps || []).find((item) => {
23625
+ const baseApp = storeApps.find((item) => {
23629
23626
  if (!item) return false;
23630
23627
  if (siteConfig.slug === item.slug && item.store?.slug === siteConfig.storeSlug) {
23631
23628
  return true;
23632
23629
  }
23633
- if (item.id !== item.store?.appId) return false;
23634
- if (!item?.store?.domain) return false;
23635
- return getAlterNativeDomains(item.store).includes(chrryUrl) || item.store.domain === chrryUrl;
23636
23630
  });
23637
23631
  const [threadId, setThreadId] = (0, import_react19.useState)(getThreadId(pathname));
23638
23632
  const [app, setAppInternal] = (0, import_react19.useState)(session2?.app || baseApp);
@@ -23727,28 +23721,17 @@ function AuthProvider({
23727
23721
  const [hasNotifications, setHasNotifications] = (0, import_react19.useState)(
23728
23722
  false
23729
23723
  );
23730
- const getSlugFromPathname2 = (path) => {
23724
+ const lasProcessedSession = (0, import_react19.useRef)(void 0);
23725
+ const findAppByPathname = (path, apps2) => {
23731
23726
  if (path === "/") return void 0;
23732
23727
  const { appSlug, storeSlug } = getAppAndStoreSlugs(path, {
23733
23728
  defaultAppSlug: baseApp?.slug || siteConfig.slug,
23734
- defaultStoreSlug: baseApp?.store?.slug || siteConfig.storeSlug,
23735
- excludedRoutes: excludedSlugRoutes,
23736
- locales
23729
+ defaultStoreSlug: baseApp?.store?.slug || siteConfig.storeSlug
23737
23730
  });
23738
- console.log(`\u{1F680} ~ getSlugFromPathname ~ appSlug:`, appSlug, storeSlug);
23739
- if (!appSlug) {
23740
- return void 0;
23741
- }
23742
23731
  const matchedApp = storeApps?.find(
23743
- (item) => item.slug === appSlug && (!baseApp ? true : !baseApp?.store?.apps?.some((a) => a.id === item.id) ? item.store?.slug === storeSlug : true)
23732
+ (item) => item.slug === appSlug && (hasStoreApps(baseApp) ? baseApp?.store?.apps?.find((app2) => app2.slug === appSlug) || item.store?.slug === storeSlug : true)
23744
23733
  );
23745
- return matchedApp?.slug;
23746
- };
23747
- const lasProcessedSession = (0, import_react19.useRef)(void 0);
23748
- const findAppByPathname = (path, apps2) => {
23749
- const slugFromPath = getSlugFromPathname2(path);
23750
- if (!slugFromPath) return void 0;
23751
- return apps2.find((app2) => app2.slug === slugFromPath);
23734
+ return matchedApp;
23752
23735
  };
23753
23736
  const [lastAppId, setLastAppId] = useLocalStorage2(
23754
23737
  "lastAppId",
@@ -23757,11 +23740,13 @@ function AuthProvider({
23757
23740
  const [newApp, setNewApp] = (0, import_react19.useState)(void 0);
23758
23741
  const mergeApps = (0, import_react19.useCallback)((newApps) => {
23759
23742
  setAllApps((prevApps) => {
23760
- console.log(`\u{1F680} ~ AuthProvider ~ prevApps:`, prevApps);
23761
23743
  const existingAppsMap = new Map(prevApps.map((app2) => [app2.id, app2]));
23762
- newApps.forEach((app2) => {
23763
- if (!existingAppsMap.has(app2.id) || !existingAppsMap.get(app2.id)?.store?.apps.length || !existingAppsMap.get(app2.id)?.store?.app) {
23764
- existingAppsMap.set(app2.id, app2);
23744
+ newApps.forEach((newApp2) => {
23745
+ const existingApp = existingAppsMap.get(newApp2.id);
23746
+ if (hasStoreApps(newApp2) && !hasStoreApps(existingApp)) {
23747
+ existingAppsMap.set(newApp2.id, newApp2);
23748
+ } else {
23749
+ existingAppsMap.set(newApp2.id, newApp2);
23765
23750
  }
23766
23751
  });
23767
23752
  return Array.from(existingAppsMap.values());
@@ -23798,23 +23783,24 @@ function AuthProvider({
23798
23783
  try {
23799
23784
  if (!token || !appId) return;
23800
23785
  const app2 = await getApp({ token, appId, chrryUrl });
23801
- if (loadingAppId) {
23802
- setLoadingAppId(void 0);
23803
- }
23804
- const apps2 = app2.store?.apps;
23805
- apps2 && mergeApps(apps2);
23806
- return apps2;
23786
+ return app2.store?.apps;
23807
23787
  } catch (error2) {
23808
23788
  import_react_hot_toast.default.error("Something went wrong");
23809
23789
  }
23810
23790
  });
23791
+ (0, import_react19.useEffect)(() => {
23792
+ if (storeAppsSwr) {
23793
+ mergeApps(storeAppsSwr);
23794
+ setLoadingAppId(void 0);
23795
+ }
23796
+ }, [storeAppsSwr]);
23811
23797
  const hasStoreApps = (item) => {
23812
23798
  if (!item || !storeApps.length) return false;
23813
23799
  const app2 = storeApps?.find((app3) => {
23814
23800
  return app3.id === item?.id;
23815
23801
  });
23816
23802
  return Boolean(
23817
- app2?.store?.apps.length && storeApps?.find(
23803
+ app2?.store?.app && app2?.store?.apps.length && storeApps?.find(
23818
23804
  (app3) => app3.store?.appId && app3.id === item?.store?.appId
23819
23805
  )
23820
23806
  );
@@ -23834,10 +23820,18 @@ function AuthProvider({
23834
23820
  setShowFocus(canShowFocus);
23835
23821
  }, [canShowFocus]);
23836
23822
  const [store, setStore] = (0, import_react19.useState)(app?.store);
23837
- const base = storeApps.find(
23838
- (a) => a.store?.appId === a.id && a.store.id === app?.store?.id
23823
+ const storeAppInternal = app?.store?.apps.find(
23824
+ (item) => app?.store?.appId && item.id === app?.store?.appId
23839
23825
  );
23840
- const apps = app?.store?.id ? storeApps.filter((a) => base?.store?.apps.some((b) => b.id === a.id)) : storeApps;
23826
+ const [storeApp, setStoreApp] = (0, import_react19.useState)(
23827
+ storeAppInternal
23828
+ );
23829
+ (0, import_react19.useEffect)(() => {
23830
+ setStoreApp(storeAppInternal);
23831
+ }, [storeAppInternal]);
23832
+ const apps = storeApps.filter((item) => {
23833
+ return app?.store?.app?.store?.apps?.some((app2) => app2.id === item.id);
23834
+ });
23841
23835
  const userBaseApp = storeApps?.find(
23842
23836
  (app2) => user?.userName && app2.store?.slug === user?.userName
23843
23837
  );
@@ -23846,15 +23840,6 @@ function AuthProvider({
23846
23840
  (app2) => guest?.id && app2.store?.slug === guest?.id
23847
23841
  );
23848
23842
  const guestBaseStore = guestBaseApp?.store;
23849
- const storeAppInternal = app?.store?.apps.find(
23850
- (item) => item.id === app?.store?.appId
23851
- );
23852
- const [storeApp, setStoreApp] = (0, import_react19.useState)(
23853
- storeAppInternal
23854
- );
23855
- (0, import_react19.useEffect)(() => {
23856
- storeAppInternal && setStoreApp(storeAppInternal);
23857
- }, [storeAppInternal]);
23858
23843
  const [slugState, setSlugState] = (0, import_react19.useState)(
23859
23844
  app && getAppSlug(app) || void 0
23860
23845
  );
@@ -23985,7 +23970,7 @@ function AuthProvider({
23985
23970
  );
23986
23971
  const setApp = (0, import_react19.useCallback)(
23987
23972
  (item) => {
23988
- ;
23973
+ if (!item) return;
23989
23974
  (item?.id !== baseApp?.id || !isExtension2) && setLastAppId(item?.id);
23990
23975
  setAppInternal((prevApp) => {
23991
23976
  const newApp2 = item ? {
@@ -24027,7 +24012,7 @@ function AuthProvider({
24027
24012
  }
24028
24013
  if (!matchedApp) {
24029
24014
  matchedApp = findAppByPathname(pathname, storeApps) || baseApp;
24030
- console.log("\u{1F6E3}\uFE0F Using pathname app:", matchedApp?.slug);
24015
+ console.log("\u{1F6E3}\uFE0F Using pathname app:", matchedApp?.slug, pathname);
24031
24016
  }
24032
24017
  console.log("\u{1F50D} App detection:", {
24033
24018
  pathname,
@@ -24429,7 +24414,7 @@ function DataProvider({ children, ...rest }) {
24429
24414
  const [instructions, setInstructions] = (0, import_react21.useState)([]);
24430
24415
  const [affiliateStats, setAffiliateStats] = (0, import_react21.useState)(null);
24431
24416
  const [loadingAffiliateStats, setLoadingAffiliateStats] = (0, import_react21.useState)(false);
24432
- const VERSION4 = "1.5.41";
24417
+ const VERSION4 = "1.5.43";
24433
24418
  const [weather, setWeather] = useLocalStorage2("weather", user?.weather || guest?.weather || void 0);
24434
24419
  const {
24435
24420
  API_URL: API_URL2,
@@ -24596,26 +24581,6 @@ function DataProvider({ children, ...rest }) {
24596
24581
  ];
24597
24582
  return fahrenheitCountries.includes(country) ? "F" : "C";
24598
24583
  }
24599
- const swrConfig = {
24600
- onError: (error2) => {
24601
- if (error2?.status === 429) {
24602
- const errorKey = `rate_limit_${Date.now()}`;
24603
- const lastShown = localStorage.getItem("last_rate_limit_toast");
24604
- const now2 = Date.now();
24605
- if (!lastShown || now2 - parseInt(lastShown) > 3e4) {
24606
- toast_default.error(
24607
- "Rate limit exceeded. Please wait a moment before trying again."
24608
- );
24609
- localStorage.setItem("last_rate_limit_toast", now2.toString());
24610
- }
24611
- }
24612
- },
24613
- onErrorRetry: (error2, revalidate, { retryCount }) => {
24614
- if (error2?.status === 429) return;
24615
- if (retryCount >= 3) return;
24616
- setTimeout(() => revalidate({ retryCount }), 5e3);
24617
- }
24618
- };
24619
24584
  (0, import_react21.useEffect)(() => {
24620
24585
  if (error) captureException(error);
24621
24586
  }, [error]);
@@ -26912,6 +26877,7 @@ function ChatProvider({
26912
26877
  value && setDebateAgent(null);
26913
26878
  };
26914
26879
  const setSelectedAgent = (agent) => {
26880
+ if (selectedAgent?.name === agent?.name) return;
26915
26881
  if (agent === null) {
26916
26882
  setAgentName("");
26917
26883
  setSelectedAgentInternal(null);
@@ -36115,7 +36081,7 @@ function App({
36115
36081
  ...styles4.appsGrid.style
36116
36082
  }
36117
36083
  },
36118
- /* @__PURE__ */ import_react55.default.createElement(Div, { style: { ...styles4.apps.style } }, appsState.filter((item) => item.id !== popcorn2?.id).slice(0, 5)?.map((item, index) => {
36084
+ /* @__PURE__ */ import_react55.default.createElement(Div, { style: { ...styles4.apps.style } }, appsState.slice(0, 5)?.map((item, index) => {
36119
36085
  const showAtlasHere = index === 1 && app?.id === chrry?.id;
36120
36086
  const showFocusHere = focus2 && !showAtlasHere && index === 1;
36121
36087
  const showPacmanHere = app?.store?.id !== popcorn2?.store?.id && index === 2;
@@ -36194,9 +36160,7 @@ function App({
36194
36160
  size: 24
36195
36161
  }
36196
36162
  ) : /* @__PURE__ */ import_react55.default.createElement(Loading, { size: 24 })
36197
- ), showPacmanHere ? popcorn2 && store && store?.appId !== popcorn2?.id && store?.apps?.some(
36198
- (app2) => app2.id === popcorn2.id
36199
- ) ? /* @__PURE__ */ import_react55.default.createElement(
36163
+ ), showPacmanHere ? popcorn2 && store && store?.appId !== popcorn2?.id && store?.apps?.some((app2) => app2.id === popcorn2.id) ? /* @__PURE__ */ import_react55.default.createElement(
36200
36164
  Anchor,
36201
36165
  {
36202
36166
  preventDefault: true,
@@ -36239,9 +36203,7 @@ function App({
36239
36203
  height: 26
36240
36204
  }
36241
36205
  )
36242
- ) : null, slug && index === appsState.findIndex(
36243
- (a) => getAppSlug(a) === slug
36244
- ) ? /* @__PURE__ */ import_react55.default.createElement(import_react55.default.Fragment, null, /* @__PURE__ */ import_react55.default.createElement(StoreApp, { key: "vex" })) : item.id !== app?.id && /* @__PURE__ */ import_react55.default.createElement(
36206
+ ) : null, slug && getAppSlug(item) === slug ? /* @__PURE__ */ import_react55.default.createElement(import_react55.default.Fragment, null, /* @__PURE__ */ import_react55.default.createElement(StoreApp, { key: "vex" })) : item.id !== app?.id && /* @__PURE__ */ import_react55.default.createElement(
36245
36207
  Anchor,
36246
36208
  {
36247
36209
  preventDefault: true,
@@ -41219,6 +41181,7 @@ function Menu({
41219
41181
  goToThreads
41220
41182
  } = useNavigationContext();
41221
41183
  const { app } = useApp();
41184
+ app && console.log("ssskacsnckjfnckjjdfc kjf c", getAppSlug(app, ""));
41222
41185
  const { viewPortHeight, isStandalone: isStandalone2 } = usePlatform();
41223
41186
  const [loadingThreadId, setLoadingThreadId] = (0, import_react62.useState)(null);
41224
41187
  (0, import_react62.useEffect)(() => {
@@ -41451,7 +41414,7 @@ function Menu({
41451
41414
  /* @__PURE__ */ import_react62.default.createElement(
41452
41415
  Anchor,
41453
41416
  {
41454
- href: isStandalone2 ? void 0 : `${app ? getAppSlug(app, "") : ""}/threads`,
41417
+ href: `${app ? getAppSlug(app, "") : ""}/threads`,
41455
41418
  onClick: (e) => {
41456
41419
  track({
41457
41420
  name: "threads-click-menu"
@@ -41727,33 +41690,40 @@ function Menu({
41727
41690
  )
41728
41691
  ))
41729
41692
  ), !threads?.totalCount && /* @__PURE__ */ import_react62.default.createElement(import_react62.default.Fragment, null, /* @__PURE__ */ import_react62.default.createElement(Div, { style: styles4.noThreadsContainer.style }, t5("Nothing here yet"))), threads?.threads.length ? (() => {
41730
- const url = `/threads${collaborationStatus ? `?collaborationStatus=${collaborationStatus}` : ""}`;
41731
- return /* @__PURE__ */ import_react62.default.createElement(Div, { style: styles4.loadMoreButtonContainer.style }, /* @__PURE__ */ import_react62.default.createElement(
41732
- Anchor,
41693
+ const url = `${app ? getAppSlug(app, "") : ""}/threads${collaborationStatus ? `?collaborationStatus=${collaborationStatus}` : ""}`;
41694
+ return /* @__PURE__ */ import_react62.default.createElement(
41695
+ Div,
41733
41696
  {
41734
- href: url,
41735
- "data-testid": "load-more-threads-menu",
41736
- onClick: (e) => {
41737
- addHapticFeedback();
41738
- track({
41739
- name: "load-more-threads-menu"
41740
- });
41741
- if (e.metaKey || e.ctrlKey) {
41742
- return;
41743
- }
41744
- e.preventDefault();
41745
- isSmallDevice ? toggleMenu() : null;
41746
- collaborationStatus ? goToThreads({
41747
- collaborationStatus
41748
- }) : goToThreads();
41749
- },
41750
- className: "button transparent small",
41751
- style: styles4.loadMoreButton.style
41697
+ suppressHydrationWarning: true,
41698
+ style: styles4.loadMoreButtonContainer.style
41752
41699
  },
41753
- /* @__PURE__ */ import_react62.default.createElement(icons_exports.LoaderCircle, { size: 14 }),
41754
- " ",
41755
- t5("Load more")
41756
- ));
41700
+ /* @__PURE__ */ import_react62.default.createElement(
41701
+ Anchor,
41702
+ {
41703
+ href: url,
41704
+ "data-testid": "load-more-threads-menu",
41705
+ onClick: (e) => {
41706
+ addHapticFeedback();
41707
+ track({
41708
+ name: "load-more-threads-menu"
41709
+ });
41710
+ if (e.metaKey || e.ctrlKey) {
41711
+ return;
41712
+ }
41713
+ e.preventDefault();
41714
+ isSmallDevice ? toggleMenu() : null;
41715
+ collaborationStatus ? goToThreads({
41716
+ collaborationStatus
41717
+ }) : goToThreads();
41718
+ },
41719
+ className: "button transparent small",
41720
+ style: styles4.loadMoreButton.style
41721
+ },
41722
+ /* @__PURE__ */ import_react62.default.createElement(icons_exports.LoaderCircle, { size: 14 }),
41723
+ " ",
41724
+ t5("Load more")
41725
+ )
41726
+ );
41757
41727
  })() : null, !threads?.threads?.length || threads?.threads?.length < 2 ? /* @__PURE__ */ import_react62.default.createElement(EmptyStateTips, { style: { marginTop: 15 } }) : null)
41758
41728
  )
41759
41729
  )
@@ -81952,7 +81922,7 @@ function AppProviders({
81952
81922
  setTimeout(() => revalidate({ retryCount }), 5e3);
81953
81923
  }
81954
81924
  };
81955
- return /* @__PURE__ */ import_react118.default.createElement(import_swr10.SWRConfig, { key: cacheReady ? "persistent" : "memory", value: swrConfig }, /* @__PURE__ */ import_react118.default.createElement(
81925
+ return /* @__PURE__ */ import_react118.default.createElement(import_swr10.SWRConfig, { value: swrConfig }, /* @__PURE__ */ import_react118.default.createElement(
81956
81926
  PlatformProvider,
81957
81927
  {
81958
81928
  viewPortWidth,