@chrryai/chrry 1.7.38 → 1.7.40

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.d.mts CHANGED
@@ -1629,13 +1629,14 @@ declare const getApps: ({ API_URL, token, chrryUrl, appId, }: {
1629
1629
  error: string;
1630
1630
  status: number;
1631
1631
  }>;
1632
- declare const getApp: ({ API_URL, token, appId, chrryUrl, skipCache, pathname, }: {
1632
+ declare const getApp: ({ API_URL, token, appId, chrryUrl, skipCache, pathname, storeSlug, }: {
1633
1633
  API_URL?: string;
1634
1634
  token: string;
1635
1635
  appId?: string;
1636
1636
  chrryUrl?: string;
1637
1637
  pathname?: string;
1638
1638
  skipCache?: boolean;
1639
+ storeSlug?: string;
1639
1640
  }) => Promise<appWithStore>;
1640
1641
  declare const getTranslations: ({ API_URL, token, locale, }?: {
1641
1642
  API_URL?: string;
package/dist/index.d.ts CHANGED
@@ -1629,13 +1629,14 @@ declare const getApps: ({ API_URL, token, chrryUrl, appId, }: {
1629
1629
  error: string;
1630
1630
  status: number;
1631
1631
  }>;
1632
- declare const getApp: ({ API_URL, token, appId, chrryUrl, skipCache, pathname, }: {
1632
+ declare const getApp: ({ API_URL, token, appId, chrryUrl, skipCache, pathname, storeSlug, }: {
1633
1633
  API_URL?: string;
1634
1634
  token: string;
1635
1635
  appId?: string;
1636
1636
  chrryUrl?: string;
1637
1637
  pathname?: string;
1638
1638
  skipCache?: boolean;
1639
+ storeSlug?: string;
1639
1640
  }) => Promise<appWithStore>;
1640
1641
  declare const getTranslations: ({ API_URL, token, locale, }?: {
1641
1642
  API_URL?: string;
package/dist/index.js CHANGED
@@ -2434,7 +2434,8 @@ var init_lib = __esm({
2434
2434
  appId,
2435
2435
  chrryUrl,
2436
2436
  skipCache,
2437
- pathname
2437
+ pathname,
2438
+ storeSlug
2438
2439
  }) => {
2439
2440
  const params = new URLSearchParams();
2440
2441
  if (chrryUrl) params.append("chrryUrl", chrryUrl);
@@ -3264,7 +3265,7 @@ var init_utils = __esm({
3264
3265
  };
3265
3266
  isFirefox = typeof navigator !== "undefined" && navigator?.userAgent?.includes("Firefox");
3266
3267
  config = getSiteConfig(getClientHostname2());
3267
- VERSION = config.version || "1.7.38";
3268
+ VERSION = config.version || "1.7.40";
3268
3269
  getSlugFromPathname = (path) => {
3269
3270
  return getAppAndStoreSlugs(path, {
3270
3271
  defaultAppSlug: config.slug,
@@ -23806,6 +23807,33 @@ function AuthProvider({
23806
23807
  setIsCookieReady(true);
23807
23808
  }
23808
23809
  }, [isExtension2]);
23810
+ const merge = (prevApps, newApps) => {
23811
+ const existingAppsMap = new Map(prevApps.map((app2) => [app2.id, app2]));
23812
+ newApps.forEach((newApp2) => {
23813
+ const existingApp = existingAppsMap.get(newApp2.id);
23814
+ if (newApp2.name === "MyAgent") {
23815
+ }
23816
+ if (existingApp && hasStoreApps(newApp2)) {
23817
+ existingAppsMap.set(newApp2.id, newApp2);
23818
+ } else {
23819
+ existingAppsMap.set(newApp2.id, newApp2);
23820
+ }
23821
+ });
23822
+ return Array.from(existingAppsMap.values());
23823
+ };
23824
+ const [userBaseApp, setUserBaseApp] = (0, import_react20.useState)(
23825
+ session2?.userBaseApp
23826
+ );
23827
+ const userBaseStore = userBaseApp?.store;
23828
+ const [guestBaseApp, setGuestBaseApp] = (0, import_react20.useState)(
23829
+ session2?.guestBaseApp
23830
+ );
23831
+ const accountApp = userBaseApp || guestBaseApp;
23832
+ const setBaseAccountApp = (app2) => {
23833
+ user && setUserBaseApp(app2);
23834
+ guest && setGuestBaseApp(app2);
23835
+ };
23836
+ const guestBaseStore = guestBaseApp?.store;
23809
23837
  function processSession(sessionData2) {
23810
23838
  if (sessionData2) {
23811
23839
  setSession(sessionData2);
@@ -23876,15 +23904,40 @@ function AuthProvider({
23876
23904
  removeParams("signIn");
23877
23905
  }
23878
23906
  };
23907
+ const [newApp, setNewApp] = (0, import_react20.useState)(void 0);
23908
+ const [updatedApp, setUpdatedApp] = (0, import_react20.useState)(
23909
+ void 0
23910
+ );
23911
+ const [loadingAppId, setLoadingAppId] = (0, import_react20.useState)(
23912
+ void 0
23913
+ );
23914
+ const allApps = merge(
23915
+ session2?.app?.store?.apps || [],
23916
+ userBaseApp ? [userBaseApp] : guestBaseApp ? [guestBaseApp] : []
23917
+ );
23918
+ const [storeApps, setAllApps] = (0, import_react20.useState)(allApps);
23919
+ const getAppSlug2 = (targetApp, defaultSlug = "/") => getAppSlug_default({ targetApp, defaultSlug, pathname, baseApp });
23920
+ const baseAppInternal = storeApps.find((item) => {
23921
+ if (!item) return false;
23922
+ if (siteConfig.slug === item.slug && item.store?.slug === siteConfig.storeSlug) {
23923
+ return true;
23924
+ }
23925
+ });
23926
+ const [baseApp, setBaseApp] = (0, import_react20.useState)(
23927
+ baseAppInternal
23928
+ );
23929
+ const [app, setAppInternal] = (0, import_react20.useState)(props.app || session2?.app || baseApp);
23930
+ const appId = newApp?.id || updatedApp?.id || loadingAppId || app?.id;
23931
+ const [isSavingApp, setIsSavingApp] = (0, import_react20.useState)(false);
23932
+ const [isManagingApp, setIsManagingApp] = (0, import_react20.useState)(false);
23879
23933
  const {
23880
23934
  data: sessionSwr,
23881
23935
  mutate: refetchSession,
23882
23936
  isLoading: isSessionLoading,
23883
23937
  error: sessionError
23884
23938
  } = (0, import_swr.default)(
23885
- (isExtension2 ? isStorageReady && isCookieReady : true) && fingerprint && token && deviceId && shouldFetchSession && !isRemovingApp ? "session" : null,
23939
+ (isExtension2 ? isStorageReady && isCookieReady : true) && fingerprint && token && deviceId && shouldFetchSession && !isRemovingApp && !isSavingApp && !isManagingApp ? "session" : null,
23886
23940
  async () => {
23887
- console.log(`\u{1F680} ~ fingerprint:`, fingerprint);
23888
23941
  try {
23889
23942
  const result = await getSession({
23890
23943
  deviceId,
@@ -24008,54 +24061,11 @@ function AuthProvider({
24008
24061
  isPWA
24009
24062
  });
24010
24063
  };
24011
- const merge = (prevApps, newApps) => {
24012
- const existingAppsMap = new Map(prevApps.map((app2) => [app2.id, app2]));
24013
- newApps.forEach((newApp2) => {
24014
- const existingApp = existingAppsMap.get(newApp2.id);
24015
- if (newApp2.name === "MyAgent") {
24016
- }
24017
- if (existingApp && hasStoreApps(newApp2)) {
24018
- existingAppsMap.set(newApp2.id, newApp2);
24019
- } else {
24020
- existingAppsMap.set(newApp2.id, newApp2);
24021
- }
24022
- });
24023
- return Array.from(existingAppsMap.values());
24024
- };
24025
- const [userBaseApp, setUserBaseApp] = (0, import_react20.useState)(
24026
- session2?.userBaseApp
24027
- );
24028
- const userBaseStore = userBaseApp?.store;
24029
- const [guestBaseApp, setGuestBaseApp] = (0, import_react20.useState)(
24030
- session2?.guestBaseApp
24031
- );
24032
- const accountApp = userBaseApp || guestBaseApp;
24033
- const setBaseAccountApp = (app2) => {
24034
- user && setUserBaseApp(app2);
24035
- guest && setGuestBaseApp(app2);
24036
- };
24037
- const guestBaseStore = guestBaseApp?.store;
24038
- const allApps = merge(
24039
- sessionData?.app?.store?.apps || [],
24040
- userBaseApp ? [userBaseApp] : guestBaseApp ? [guestBaseApp] : []
24041
- );
24042
- const [storeApps, setAllApps] = (0, import_react20.useState)(allApps);
24043
- const getAppSlug2 = (targetApp, defaultSlug = "/") => getAppSlug_default({ targetApp, defaultSlug, pathname, baseApp });
24044
- const baseAppInternal = storeApps.find((item) => {
24045
- if (!item) return false;
24046
- if (siteConfig.slug === item.slug && item.store?.slug === siteConfig.storeSlug) {
24047
- return true;
24048
- }
24049
- });
24050
- const [baseApp, setBaseApp] = (0, import_react20.useState)(
24051
- baseAppInternal
24052
- );
24053
24064
  (0, import_react20.useEffect)(() => {
24054
24065
  hasStoreApps(baseAppInternal) && setBaseApp(baseAppInternal);
24055
24066
  }, [baseAppInternal]);
24056
24067
  const threadId = getThreadId(pathname);
24057
24068
  const threadIdRef = (0, import_react20.useRef)(threadId);
24058
- const [app, setAppInternal] = (0, import_react20.useState)(props.app || session2?.app || baseApp);
24059
24069
  (0, import_react20.useEffect)(() => {
24060
24070
  const signInParam = searchParams.get("signIn");
24061
24071
  const currentPart = signInParam;
@@ -24177,10 +24187,6 @@ function AuthProvider({
24177
24187
  "lastAppId",
24178
24188
  void 0
24179
24189
  );
24180
- const [newApp, setNewApp] = (0, import_react20.useState)(void 0);
24181
- const [updatedApp, setUpdatedApp] = (0, import_react20.useState)(
24182
- void 0
24183
- );
24184
24190
  const mergeApps = (0, import_react20.useCallback)(
24185
24191
  (newApps) => {
24186
24192
  setAllApps(merge(storeApps, newApps));
@@ -24193,9 +24199,6 @@ function AuthProvider({
24193
24199
  shouldFetchSession && await refetchSession();
24194
24200
  };
24195
24201
  const [isSplash, setIsSplash] = (0, import_react20.useState)(true);
24196
- const [loadingAppId, setLoadingAppId] = (0, import_react20.useState)(
24197
- void 0
24198
- );
24199
24202
  const [loadingApp, setLoadingAppInternal] = (0, import_react20.useState)(void 0);
24200
24203
  const setLoadingApp = (appWithStore) => {
24201
24204
  setLoadingAppId(appWithStore?.id);
@@ -24207,8 +24210,6 @@ function AuthProvider({
24207
24210
  const sushi = storeApps?.find((app2) => app2.slug === "sushi");
24208
24211
  const focus2 = storeApps?.find((app2) => app2.slug === "focus");
24209
24212
  const accountAppId = userBaseApp?.id || guestBaseApp?.id;
24210
- const appId = newApp?.id || updatedApp?.id || loadingAppId || app?.id;
24211
- const [isManagingApp, setIsManagingApp] = (0, import_react20.useState)(false);
24212
24213
  const {
24213
24214
  data: storeAppsSwr,
24214
24215
  mutate: refetchApps,
@@ -24216,29 +24217,24 @@ function AuthProvider({
24216
24217
  } = (0, import_swr.default)(token && !isRemovingApp && ["app", appId], async () => {
24217
24218
  try {
24218
24219
  if (!token) return;
24219
- const app2 = await getApp({
24220
+ const result = await getApp({
24220
24221
  token,
24221
24222
  appId,
24222
24223
  chrryUrl,
24223
24224
  pathname,
24224
- skipCache: !!accountAppId || appId === accountAppId || !!newApp?.id || isManagingApp
24225
+ skipCache: appId !== app?.id || appId === accountAppId
24225
24226
  });
24226
- return app2;
24227
+ return result;
24227
24228
  } catch (error2) {
24228
24229
  captureException(error2);
24229
24230
  }
24230
24231
  });
24231
- (0, import_react20.useEffect)(() => {
24232
- if (newApp?.id || updatedApp?.id) {
24233
- refetchApps();
24234
- }
24235
- }, [newApp?.id, updatedApp?.id]);
24236
24232
  (0, import_react20.useEffect)(() => {
24237
24233
  if (storeAppsSwr) {
24238
24234
  storeAppsSwr.store?.apps?.find((app2) => app2.id === loadingAppId) && setLoadingApp(void 0);
24239
24235
  mergeApps(storeAppsSwr.store?.apps || []);
24240
24236
  }
24241
- }, [storeAppsSwr, guest, user, newApp, updatedApp, loadingAppId]);
24237
+ }, [storeAppsSwr]);
24242
24238
  const canShowFocus = !!(focus2 && app && app?.id === focus2.id && !threadId);
24243
24239
  const [showFocus, setShowFocus] = (0, import_react20.useState)(canShowFocus);
24244
24240
  (0, import_react20.useEffect)(() => {
@@ -24548,7 +24544,6 @@ function AuthProvider({
24548
24544
  console.warn("PerformanceObserver not supported:", error2);
24549
24545
  }
24550
24546
  }, [track]);
24551
- const [isSavingApp, setIsSavingApp] = (0, import_react20.useState)(false);
24552
24547
  const [shouldFetchTasks, setShouldFetchTasks] = (0, import_react20.useState)(false);
24553
24548
  const [isLoadingTasks, setIsLoadingTasks] = (0, import_react20.useState)(false);
24554
24549
  const { data: tasksData, mutate: refetchTasks } = (0, import_swr.default)(
@@ -24864,7 +24859,7 @@ function DataProvider({ children, ...rest }) {
24864
24859
  const [instructions, setInstructions] = (0, import_react21.useState)([]);
24865
24860
  const [affiliateStats, setAffiliateStats] = (0, import_react21.useState)(null);
24866
24861
  const [loadingAffiliateStats, setLoadingAffiliateStats] = (0, import_react21.useState)(false);
24867
- const VERSION4 = "1.7.38";
24862
+ const VERSION4 = "1.7.40";
24868
24863
  const [weather, setWeather] = useLocalStorage2("weather", user?.weather || guest?.weather || void 0);
24869
24864
  const {
24870
24865
  API_URL: API_URL2,
@@ -26029,7 +26024,7 @@ function AppProvider({ children }) {
26029
26024
  Object.entries(payload).forEach(([key, value]) => {
26030
26025
  newSearchParams.set(key, String(value));
26031
26026
  });
26032
- const slug2 = userBaseApp?.store?.slug || guestBaseApp?.store?.slug || baseApp?.store?.slug;
26027
+ const slug2 = baseApp?.store?.slug;
26033
26028
  const newUrl = `/${slug2 === chrry?.slug ? "" : slug2 ?? chrry?.slug}/${app?.slug}?${newSearchParams.toString()}`;
26034
26029
  push(newUrl);
26035
26030
  } else {
@@ -27075,10 +27070,10 @@ function ChatProvider({
27075
27070
  }, [appStatus?.part]);
27076
27071
  const [shouldFetchThread, setShouldFetchThread] = (0, import_react29.useState)(!auth.threadData);
27077
27072
  (0, import_react29.useEffect)(() => {
27078
- if (threadId && auth?.threadData?.thread.id !== threadId && !shouldFetchThread) {
27073
+ if (threadId && !shouldFetchThread) {
27079
27074
  setShouldFetchThread(true);
27080
27075
  }
27081
- }, [threadId, auth?.threadData?.thread.id, shouldFetchThread]);
27076
+ }, [threadId, shouldFetchThread]);
27082
27077
  const [until, setUntil] = (0, import_react29.useState)(1);
27083
27078
  const [liked, setLiked] = (0, import_react29.useState)(void 0);
27084
27079
  const [isLoading, setIsLoading] = (0, import_react29.useState)(!!threadId);