@chrryai/chrry 1.5.35 → 1.5.37

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
@@ -1500,23 +1500,22 @@ declare const getSession: ({ deviceId, fingerprint, gift, isStandalone, appId, t
1500
1500
  translate?: boolean;
1501
1501
  locale?: string;
1502
1502
  source?: string;
1503
- }) => Promise<session | {
1504
- error?: string;
1505
- status?: number;
1506
- } | undefined>;
1503
+ }) => Promise<session | undefined>;
1507
1504
  type ApiActions = ReturnType<typeof getActions>;
1508
- declare const getApps: ({ API_URL, token, appId, }: {
1505
+ declare const getApps: ({ API_URL, token, chrryUrl, appId, }: {
1509
1506
  API_URL?: string;
1510
1507
  token: string;
1511
1508
  appId?: string;
1509
+ chrryUrl?: string;
1512
1510
  }) => Promise<appWithStore[] | {
1513
1511
  error: string;
1514
1512
  status: number;
1515
1513
  }>;
1516
- declare const getApp: ({ API_URL, token, appId, }: {
1514
+ declare const getApp: ({ API_URL, token, appId, chrryUrl, }: {
1517
1515
  API_URL?: string;
1518
1516
  token: string;
1519
1517
  appId: string;
1518
+ chrryUrl?: string;
1520
1519
  }) => Promise<appWithStore>;
1521
1520
  declare const getTranslations: ({ API_URL, token, locale, }?: {
1522
1521
  API_URL?: string;
@@ -1649,10 +1648,7 @@ declare const getActions: ({ API_URL, token, }: {
1649
1648
  API_URL?: string;
1650
1649
  VERSION?: string;
1651
1650
  app?: "extension" | "pwa" | "web";
1652
- }) => Promise<session | {
1653
- error?: string;
1654
- status?: number;
1655
- } | undefined>;
1651
+ }) => Promise<session | undefined>;
1656
1652
  };
1657
1653
 
1658
1654
  declare const aiAgentCapabilitiesSchema: z.ZodObject<{
package/dist/index.d.ts CHANGED
@@ -1500,23 +1500,22 @@ declare const getSession: ({ deviceId, fingerprint, gift, isStandalone, appId, t
1500
1500
  translate?: boolean;
1501
1501
  locale?: string;
1502
1502
  source?: string;
1503
- }) => Promise<session | {
1504
- error?: string;
1505
- status?: number;
1506
- } | undefined>;
1503
+ }) => Promise<session | undefined>;
1507
1504
  type ApiActions = ReturnType<typeof getActions>;
1508
- declare const getApps: ({ API_URL, token, appId, }: {
1505
+ declare const getApps: ({ API_URL, token, chrryUrl, appId, }: {
1509
1506
  API_URL?: string;
1510
1507
  token: string;
1511
1508
  appId?: string;
1509
+ chrryUrl?: string;
1512
1510
  }) => Promise<appWithStore[] | {
1513
1511
  error: string;
1514
1512
  status: number;
1515
1513
  }>;
1516
- declare const getApp: ({ API_URL, token, appId, }: {
1514
+ declare const getApp: ({ API_URL, token, appId, chrryUrl, }: {
1517
1515
  API_URL?: string;
1518
1516
  token: string;
1519
1517
  appId: string;
1518
+ chrryUrl?: string;
1520
1519
  }) => Promise<appWithStore>;
1521
1520
  declare const getTranslations: ({ API_URL, token, locale, }?: {
1522
1521
  API_URL?: string;
@@ -1649,10 +1648,7 @@ declare const getActions: ({ API_URL, token, }: {
1649
1648
  API_URL?: string;
1650
1649
  VERSION?: string;
1651
1650
  app?: "extension" | "pwa" | "web";
1652
- }) => Promise<session | {
1653
- error?: string;
1654
- status?: number;
1655
- } | undefined>;
1651
+ }) => Promise<session | undefined>;
1656
1652
  };
1657
1653
 
1658
1654
  declare const aiAgentCapabilitiesSchema: z.ZodObject<{
package/dist/index.js CHANGED
@@ -489,7 +489,7 @@ var init_locales = __esm({
489
489
 
490
490
  // utils/siteConfig.ts
491
491
  function detectSiteModeDomain(hostname2, mode) {
492
- const defaultMode = process.env.MODE || import_meta?.env?.VITE_SITE_MODE || mode || "vex";
492
+ const defaultMode = process.env.MODE || import_meta?.env?.VITE_SITE_MODE || mode || "zarathustra";
493
493
  const rawHost = hostname2 || (typeof window !== "undefined" ? window?.location?.hostname : "") || "";
494
494
  let host = rawHost?.trim().toLowerCase();
495
495
  if (host?.includes("://")) {
@@ -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.35";
2096
+ VERSION = config.version || "1.5.37";
2097
2097
  getSlugFromPathname = (path) => {
2098
2098
  return getAppAndStoreSlugs(path, {
2099
2099
  defaultAppSlug: config.slug,
@@ -5862,13 +5862,16 @@ var init_lib = __esm({
5862
5862
  getApps = async ({
5863
5863
  API_URL: API_URL2 = API_URL,
5864
5864
  token,
5865
+ chrryUrl,
5865
5866
  appId
5866
5867
  }) => {
5867
5868
  const params = new URLSearchParams();
5868
5869
  appId && params.append("appId", appId);
5870
+ chrryUrl && params.append("chrryUrl", chrryUrl);
5869
5871
  const response = await fetch(`${API_URL2}/apps?${params}`, {
5870
5872
  headers: {
5871
- Authorization: `Bearer ${token}`
5873
+ Authorization: `Bearer ${token}`,
5874
+ ...chrryUrl ? { "x-chrry-url": chrryUrl } : {}
5872
5875
  }
5873
5876
  });
5874
5877
  if (!response.ok) {
@@ -5883,12 +5886,16 @@ var init_lib = __esm({
5883
5886
  getApp = async ({
5884
5887
  API_URL: API_URL2 = API_URL,
5885
5888
  token,
5886
- appId
5889
+ appId,
5890
+ chrryUrl
5887
5891
  }) => {
5892
+ const params = new URLSearchParams();
5893
+ chrryUrl && params.append("chrryUrl", chrryUrl);
5888
5894
  const response = await fetch(`${API_URL2}/apps/${appId}`, {
5889
5895
  headers: {
5890
5896
  Authorization: `Bearer ${token}`,
5891
- "x-app-id": appId
5897
+ "x-app-id": appId,
5898
+ ...chrryUrl ? { "x-chrry-url": chrryUrl } : {}
5892
5899
  }
5893
5900
  });
5894
5901
  const data = await response.json();
@@ -23334,6 +23341,7 @@ function AuthProvider({
23334
23341
  const API_PORT2 = process.env.API_PORT || "3001";
23335
23342
  const isTestingDevice2 = false;
23336
23343
  const chrryUrl = CHRRY_URL;
23344
+ console.log(`\u{1F680} ~ AuthProvider ~ chrryUrl:`, chrryUrl);
23337
23345
  const [deviceId, setDeviceId] = useCookieOrLocalStorage(
23338
23346
  "deviceId",
23339
23347
  session2?.deviceId
@@ -23480,11 +23488,11 @@ function AuthProvider({
23480
23488
  throw new Error("No response from server");
23481
23489
  }
23482
23490
  if ("error" in result || "status" in result) {
23483
- if (result.status === 429) {
23491
+ if ("status" in result && result.status === 429) {
23484
23492
  setShouldFetchSession(false);
23485
23493
  throw new Error("Rate limit exceeded");
23486
23494
  }
23487
- if (result.error) {
23495
+ if ("error" in result && result.error) {
23488
23496
  import_react_hot_toast.default.error(result.error);
23489
23497
  setShouldFetchSession(false);
23490
23498
  }
@@ -23507,7 +23515,7 @@ function AuthProvider({
23507
23515
  }
23508
23516
  return sessionResult;
23509
23517
  } catch (error2) {
23510
- import_react_hot_toast.default.error("Something went wrong");
23518
+ console.error("Error fetching session:", error2);
23511
23519
  }
23512
23520
  },
23513
23521
  {
@@ -23617,7 +23625,7 @@ function AuthProvider({
23617
23625
  }
23618
23626
  return computedSlug || defaultSlug;
23619
23627
  };
23620
- const baseApp = storeApps?.find((item) => {
23628
+ const baseApp = storeApps.concat(session2?.app?.store?.apps || []).find((item) => {
23621
23629
  if (!item) return false;
23622
23630
  if (siteConfig.slug === item.slug && item.store?.slug === siteConfig.storeSlug) {
23623
23631
  return true;
@@ -23748,6 +23756,7 @@ function AuthProvider({
23748
23756
  const [newApp, setNewApp] = (0, import_react19.useState)(void 0);
23749
23757
  const mergeApps = (0, import_react19.useCallback)((newApps) => {
23750
23758
  setAllApps((prevApps) => {
23759
+ console.log(`\u{1F680} ~ AuthProvider ~ prevApps:`, prevApps);
23751
23760
  const existingAppsMap = new Map(prevApps.map((app2) => [app2.id, app2]));
23752
23761
  newApps.forEach((app2) => {
23753
23762
  if (!existingAppsMap.has(app2.id) || !existingAppsMap.get(app2.id)?.store?.apps.length || !existingAppsMap.get(app2.id)?.store?.app) {
@@ -23784,13 +23793,15 @@ function AuthProvider({
23784
23793
  data: storeAppsSwr,
23785
23794
  mutate: refetchApps,
23786
23795
  isLoading: isLoadingApps
23787
- } = (0, import_swr2.default)(token && appId ? ["apps", appId] : null, async () => {
23796
+ } = (0, import_swr2.default)(token && appId ? ["app", appId] : null, async () => {
23788
23797
  try {
23789
23798
  if (!token || !appId) return;
23790
- const apps2 = await getApps({ token, appId });
23799
+ const app2 = await getApp({ token, appId, chrryUrl });
23791
23800
  if (loadingAppId) {
23792
23801
  setLoadingAppId(void 0);
23793
23802
  }
23803
+ const apps2 = app2.store?.apps;
23804
+ apps2 && mergeApps(apps2);
23794
23805
  return apps2;
23795
23806
  } catch (error2) {
23796
23807
  import_react_hot_toast.default.error("Something went wrong");
@@ -23816,11 +23827,6 @@ function AuthProvider({
23816
23827
  refetchApps();
23817
23828
  }
23818
23829
  }, [loadingApp, isLoadingApps, storeApps]);
23819
- (0, import_react19.useEffect)(() => {
23820
- if (storeAppsSwr && Array.isArray(storeAppsSwr)) {
23821
- mergeApps(storeAppsSwr);
23822
- }
23823
- }, [storeAppsSwr, mergeApps]);
23824
23830
  const canShowFocus = !!focus2 && app?.id === focus2.id && !threadId;
23825
23831
  const [showFocus, setShowFocus] = (0, import_react19.useState)(canShowFocus);
23826
23832
  (0, import_react19.useEffect)(() => {
@@ -24416,7 +24422,7 @@ function DataProvider({ children, ...rest }) {
24416
24422
  const [instructions, setInstructions] = (0, import_react21.useState)([]);
24417
24423
  const [affiliateStats, setAffiliateStats] = (0, import_react21.useState)(null);
24418
24424
  const [loadingAffiliateStats, setLoadingAffiliateStats] = (0, import_react21.useState)(false);
24419
- const VERSION4 = "1.5.35";
24425
+ const VERSION4 = "1.5.37";
24420
24426
  const [weather, setWeather] = useLocalStorage2("weather", user?.weather || guest?.weather || void 0);
24421
24427
  const {
24422
24428
  API_URL: API_URL2,
@@ -26885,7 +26891,7 @@ function ChatProvider({
26885
26891
  return threadData2;
26886
26892
  },
26887
26893
  {
26888
- revalidateOnMount: true
26894
+ // revalidateOnMount: true,
26889
26895
  }
26890
26896
  );
26891
26897
  const [agentName, setAgentName] = (0, import_react31.useState)(session2?.aiAgent?.name || "");
@@ -28320,7 +28326,9 @@ var init_AppContext = __esm({
28320
28326
  reportedMissingKeys = /* @__PURE__ */ new Set();
28321
28327
  checkedKeys = /* @__PURE__ */ new Set();
28322
28328
  AppContext = (0, import_react35.createContext)({
28323
- t: (key, values, autoAdd) => key
28329
+ t: (key, values, autoAdd) => key,
28330
+ captureException: () => {
28331
+ }
28324
28332
  });
28325
28333
  AppContextProvider = ({
28326
28334
  children
@@ -28342,11 +28350,13 @@ var init_AppContext = __esm({
28342
28350
  const name = app && atlas2 && app.store?.appId === atlas2.id ? "Atlas" : config2.name;
28343
28351
  return result.replace(/Vex/g, name).replace(/vex/g, name.toLowerCase());
28344
28352
  };
28353
+ const { captureException } = useError();
28345
28354
  return /* @__PURE__ */ import_react35.default.createElement(
28346
28355
  AppContext.Provider,
28347
28356
  {
28348
28357
  value: {
28349
- t: t5
28358
+ t: t5,
28359
+ captureException
28350
28360
  }
28351
28361
  },
28352
28362
  children
@@ -35466,7 +35476,7 @@ function App({
35466
35476
  const grape = apps.find((app2) => app2.slug === "grape");
35467
35477
  const zarathustra2 = apps.find((app2) => app2.slug === "zarathustra");
35468
35478
  const isBlossom = app?.store?.id === chrry?.store?.id;
35469
- const getApps2 = () => {
35479
+ const getApps3 = () => {
35470
35480
  return apps.filter(
35471
35481
  (item) => item.id !== store?.appId && item.id !== chrry?.id && item.id !== grape?.id && (isBlossom ? item.id !== atlas2?.id && item.id !== zarathustra2?.id && item.id !== popcorn2?.id : true)
35472
35482
  ).filter((item) => item.id !== focus2?.id).sort((a, b) => {
@@ -35486,9 +35496,9 @@ function App({
35486
35496
  return item;
35487
35497
  });
35488
35498
  };
35489
- const [appsState, setApps] = import_react55.default.useState(getApps2());
35499
+ const [appsState, setApps] = import_react55.default.useState(getApps3());
35490
35500
  (0, import_react55.useEffect)(() => {
35491
- setApps(getApps2());
35501
+ setApps(getApps3());
35492
35502
  }, [apps, store?.id, store?.appId, currentStoreId, baseApp, app]);
35493
35503
  const [file, setFile] = import_react55.default.useState();
35494
35504
  const [image, setImageInternal] = import_react55.default.useState(
@@ -41646,7 +41656,7 @@ function Menu({
41646
41656
  const threadApp = storeApps.find(
41647
41657
  (app2) => app2.id === thread2.appId
41648
41658
  );
41649
- if (thread2.appId && threadApp && !hasStoreApps(threadApp)) {
41659
+ if (thread2.appId && (!threadApp || !hasStoreApps(threadApp))) {
41650
41660
  setLoadingThreadId(thread2.id);
41651
41661
  setLoadingAppId(thread2.appId);
41652
41662
  return;