@chrryai/chrry 1.4.76 → 1.4.77
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 +91 -155
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +424 -487
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
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) {
|
|
492
|
-
const defaultMode = "
|
|
492
|
+
const defaultMode = "atlas";
|
|
493
493
|
const rawHost = hostname2 || (typeof window !== "undefined" ? window?.location?.hostname : "") || "";
|
|
494
494
|
let host = rawHost?.trim().toLowerCase();
|
|
495
495
|
if (host?.includes("://")) {
|
|
@@ -1899,7 +1899,7 @@ var init_utils = __esm({
|
|
|
1899
1899
|
};
|
|
1900
1900
|
isFirefox = typeof navigator !== "undefined" && navigator?.userAgent?.includes("Firefox");
|
|
1901
1901
|
config = getSiteConfig(getClientHostname());
|
|
1902
|
-
VERSION = config.version || "1.4.
|
|
1902
|
+
VERSION = config.version || "1.4.77";
|
|
1903
1903
|
getSlugFromPathname = (path) => {
|
|
1904
1904
|
return getAppAndStoreSlugs(path, {
|
|
1905
1905
|
defaultAppSlug: config.slug,
|
|
@@ -2294,31 +2294,54 @@ var init_storage = __esm({
|
|
|
2294
2294
|
});
|
|
2295
2295
|
|
|
2296
2296
|
// platform/cookies.ts
|
|
2297
|
+
function stringifyOptions(options) {
|
|
2298
|
+
return Object.keys(options).reduce((acc, key) => {
|
|
2299
|
+
if (key === "days") {
|
|
2300
|
+
return acc;
|
|
2301
|
+
} else {
|
|
2302
|
+
const value = options[key];
|
|
2303
|
+
if (value === false) {
|
|
2304
|
+
return acc;
|
|
2305
|
+
} else if (value === true) {
|
|
2306
|
+
return `${acc}; ${key}`;
|
|
2307
|
+
} else if (value) {
|
|
2308
|
+
return `${acc}; ${key}=${value}`;
|
|
2309
|
+
}
|
|
2310
|
+
return acc;
|
|
2311
|
+
}
|
|
2312
|
+
}, "");
|
|
2313
|
+
}
|
|
2297
2314
|
function useCookie(key, initialValue = "") {
|
|
2315
|
+
if (isBrowser && !isNative() && !isBrowserExtension()) {
|
|
2316
|
+
const [item, setItem] = (0, import_react2.useState)(() => {
|
|
2317
|
+
return getCookieWeb(key, initialValue);
|
|
2318
|
+
});
|
|
2319
|
+
const updateItem2 = (0, import_react2.useCallback)(
|
|
2320
|
+
(value2, options) => {
|
|
2321
|
+
setItem(value2);
|
|
2322
|
+
setCookieWeb(key, value2, options);
|
|
2323
|
+
},
|
|
2324
|
+
[key]
|
|
2325
|
+
);
|
|
2326
|
+
const removeItem2 = (0, import_react2.useCallback)(() => {
|
|
2327
|
+
setItem(initialValue);
|
|
2328
|
+
removeCookieWeb(key);
|
|
2329
|
+
}, [key, initialValue]);
|
|
2330
|
+
return [item, updateItem2, removeItem2];
|
|
2331
|
+
}
|
|
2298
2332
|
const [value, setValue] = (0, import_react2.useState)(initialValue);
|
|
2299
|
-
(0, import_react2.
|
|
2300
|
-
|
|
2301
|
-
const cookieValue = await getCookie(key);
|
|
2302
|
-
if (cookieValue !== null) {
|
|
2303
|
-
setValue(cookieValue);
|
|
2304
|
-
} else if (initialValue) {
|
|
2305
|
-
await setCookieValue(key, initialValue);
|
|
2306
|
-
}
|
|
2307
|
-
};
|
|
2308
|
-
loadCookie();
|
|
2309
|
-
}, [key, initialValue]);
|
|
2310
|
-
const setCookie = (0, import_react2.useCallback)(
|
|
2311
|
-
async (newValue, options) => {
|
|
2333
|
+
const updateItem = (0, import_react2.useCallback)(
|
|
2334
|
+
(newValue, _options) => {
|
|
2312
2335
|
setValue(newValue);
|
|
2313
|
-
|
|
2336
|
+
storage2.setItem(key, newValue);
|
|
2314
2337
|
},
|
|
2315
2338
|
[key]
|
|
2316
2339
|
);
|
|
2317
|
-
const
|
|
2340
|
+
const removeItem = (0, import_react2.useCallback)(() => {
|
|
2318
2341
|
setValue(initialValue);
|
|
2319
|
-
|
|
2342
|
+
storage2.removeItem(key);
|
|
2320
2343
|
}, [key, initialValue]);
|
|
2321
|
-
return [value,
|
|
2344
|
+
return [value, updateItem, removeItem];
|
|
2322
2345
|
}
|
|
2323
2346
|
function getCookieSync(key) {
|
|
2324
2347
|
if (typeof document !== "undefined" && document.cookie) {
|
|
@@ -2332,129 +2355,7 @@ function getCookieSync(key) {
|
|
|
2332
2355
|
}
|
|
2333
2356
|
return null;
|
|
2334
2357
|
}
|
|
2335
|
-
|
|
2336
|
-
if (isNative()) {
|
|
2337
|
-
return storage2.getItem(key);
|
|
2338
|
-
}
|
|
2339
|
-
if (isBrowserExtension()) {
|
|
2340
|
-
try {
|
|
2341
|
-
const websiteUrls = getExtensionUrls();
|
|
2342
|
-
const final = [];
|
|
2343
|
-
if (typeof chrome !== "undefined" && chrome.cookies) {
|
|
2344
|
-
for (const url of websiteUrls) {
|
|
2345
|
-
const cookie = await new Promise(
|
|
2346
|
-
(resolve) => {
|
|
2347
|
-
chrome.cookies.get({ url, name: key }, (cookie2) => {
|
|
2348
|
-
if (chrome.runtime.lastError) {
|
|
2349
|
-
resolve(null);
|
|
2350
|
-
} else {
|
|
2351
|
-
resolve(cookie2);
|
|
2352
|
-
}
|
|
2353
|
-
});
|
|
2354
|
-
}
|
|
2355
|
-
);
|
|
2356
|
-
if (cookie?.value) {
|
|
2357
|
-
final.push(cookie?.value);
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
if (key === "token") {
|
|
2361
|
-
storage2.setItem("_cookiesReady", "true");
|
|
2362
|
-
}
|
|
2363
|
-
if (final.length) {
|
|
2364
|
-
if (key === "token") {
|
|
2365
|
-
return final.sort((a, b) => b.length - a.length)[0] || null;
|
|
2366
|
-
}
|
|
2367
|
-
return final[0] || null;
|
|
2368
|
-
}
|
|
2369
|
-
return await storage2.getItem(key);
|
|
2370
|
-
}
|
|
2371
|
-
if (typeof browser !== "undefined" && browser.cookies) {
|
|
2372
|
-
for (const url of websiteUrls) {
|
|
2373
|
-
const cookie = await browser.cookies.get({ url, name: key });
|
|
2374
|
-
if (cookie?.value) {
|
|
2375
|
-
return cookie.value;
|
|
2376
|
-
}
|
|
2377
|
-
}
|
|
2378
|
-
return await storage2.getItem(key);
|
|
2379
|
-
}
|
|
2380
|
-
} catch {
|
|
2381
|
-
}
|
|
2382
|
-
return await storage2.getItem(key);
|
|
2383
|
-
}
|
|
2384
|
-
if (typeof document !== "undefined" && document.cookie) {
|
|
2385
|
-
const cookies = document.cookie.split(";");
|
|
2386
|
-
for (const cookie of cookies) {
|
|
2387
|
-
const [cookieName, cookieValue] = cookie.split("=").map((c) => c.trim());
|
|
2388
|
-
if (cookieName === key && cookieValue) {
|
|
2389
|
-
return decodeURIComponent(cookieValue);
|
|
2390
|
-
}
|
|
2391
|
-
}
|
|
2392
|
-
}
|
|
2393
|
-
return null;
|
|
2394
|
-
}
|
|
2395
|
-
async function setCookieValue(key, value, options = {}) {
|
|
2396
|
-
if (isNative()) {
|
|
2397
|
-
storage2.setItem(key, value);
|
|
2398
|
-
return;
|
|
2399
|
-
}
|
|
2400
|
-
if (isBrowserExtension()) {
|
|
2401
|
-
console.log("Setting cookie in extension storage:", key, value);
|
|
2402
|
-
storage2.setItem(key, value);
|
|
2403
|
-
return;
|
|
2404
|
-
}
|
|
2405
|
-
if (typeof document !== "undefined") {
|
|
2406
|
-
let cookieString = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
2407
|
-
if (options.maxAge) {
|
|
2408
|
-
cookieString += `; max-age=${options.maxAge}`;
|
|
2409
|
-
}
|
|
2410
|
-
if (options.expires) {
|
|
2411
|
-
cookieString += `; expires=${options.expires.toUTCString()}`;
|
|
2412
|
-
}
|
|
2413
|
-
cookieString += `; path=${options.path || "/"}`;
|
|
2414
|
-
if (options.domain) {
|
|
2415
|
-
cookieString += `; domain=${options.domain}`;
|
|
2416
|
-
}
|
|
2417
|
-
if (options.secure) {
|
|
2418
|
-
cookieString += "; secure";
|
|
2419
|
-
}
|
|
2420
|
-
if (options.sameSite) {
|
|
2421
|
-
cookieString += `; samesite=${options.sameSite}`;
|
|
2422
|
-
}
|
|
2423
|
-
document.cookie = cookieString;
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
|
-
async function deleteCookie(key) {
|
|
2427
|
-
if (isNative()) {
|
|
2428
|
-
storage2.removeItem(key);
|
|
2429
|
-
return;
|
|
2430
|
-
}
|
|
2431
|
-
if (isBrowserExtension()) {
|
|
2432
|
-
try {
|
|
2433
|
-
if (typeof chrome !== "undefined" && chrome.cookies) {
|
|
2434
|
-
return new Promise((resolve) => {
|
|
2435
|
-
chrome.cookies.remove(
|
|
2436
|
-
{ url: window.location.href, name: key },
|
|
2437
|
-
() => resolve()
|
|
2438
|
-
);
|
|
2439
|
-
});
|
|
2440
|
-
}
|
|
2441
|
-
if (typeof browser !== "undefined" && browser.cookies) {
|
|
2442
|
-
await browser.cookies.remove({
|
|
2443
|
-
url: window.location.href,
|
|
2444
|
-
name: key
|
|
2445
|
-
});
|
|
2446
|
-
return;
|
|
2447
|
-
}
|
|
2448
|
-
} catch {
|
|
2449
|
-
}
|
|
2450
|
-
storage2.removeItem(key);
|
|
2451
|
-
return;
|
|
2452
|
-
}
|
|
2453
|
-
if (typeof document !== "undefined") {
|
|
2454
|
-
document.cookie = `${encodeURIComponent(key)}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
var import_react2;
|
|
2358
|
+
var import_react2, isBrowser, setCookieWeb, getCookieWeb, removeCookieWeb;
|
|
2458
2359
|
var init_cookies = __esm({
|
|
2459
2360
|
"platform/cookies.ts"() {
|
|
2460
2361
|
"use strict";
|
|
@@ -2462,6 +2363,29 @@ var init_cookies = __esm({
|
|
|
2462
2363
|
init_PlatformProvider();
|
|
2463
2364
|
init_storage();
|
|
2464
2365
|
init_utils();
|
|
2366
|
+
isBrowser = typeof window !== "undefined";
|
|
2367
|
+
setCookieWeb = (name, value, options = {}) => {
|
|
2368
|
+
if (!isBrowser) return;
|
|
2369
|
+
const optionsWithDefaults = {
|
|
2370
|
+
days: 7,
|
|
2371
|
+
path: "/",
|
|
2372
|
+
...options
|
|
2373
|
+
};
|
|
2374
|
+
const expires = new Date(
|
|
2375
|
+
Date.now() + (optionsWithDefaults.days || 7) * 864e5
|
|
2376
|
+
).toUTCString();
|
|
2377
|
+
document.cookie = name + "=" + encodeURIComponent(value) + "; expires=" + expires + stringifyOptions(optionsWithDefaults);
|
|
2378
|
+
};
|
|
2379
|
+
getCookieWeb = (name, initialValue = "") => {
|
|
2380
|
+
return isBrowser && document.cookie.split("; ").reduce((r, v) => {
|
|
2381
|
+
const parts = v.split("=");
|
|
2382
|
+
return parts[0] === name && parts[1] ? decodeURIComponent(parts[1]) : r;
|
|
2383
|
+
}, "") || initialValue;
|
|
2384
|
+
};
|
|
2385
|
+
removeCookieWeb = (name) => {
|
|
2386
|
+
if (!isBrowser) return;
|
|
2387
|
+
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
|
|
2388
|
+
};
|
|
2465
2389
|
}
|
|
2466
2390
|
});
|
|
2467
2391
|
|
|
@@ -5910,7 +5834,7 @@ var init_ThemeContext = __esm({
|
|
|
5910
5834
|
});
|
|
5911
5835
|
|
|
5912
5836
|
// lib/db.ts
|
|
5913
|
-
var import_idb, dbInstance, getDB, cacheData, getCachedData;
|
|
5837
|
+
var import_idb, dbInstance, getDB, cacheData, getCachedData, clearCache;
|
|
5914
5838
|
var init_db = __esm({
|
|
5915
5839
|
"lib/db.ts"() {
|
|
5916
5840
|
"use strict";
|
|
@@ -5963,6 +5887,15 @@ var init_db = __esm({
|
|
|
5963
5887
|
return null;
|
|
5964
5888
|
}
|
|
5965
5889
|
};
|
|
5890
|
+
clearCache = async () => {
|
|
5891
|
+
try {
|
|
5892
|
+
const db = await getDB();
|
|
5893
|
+
if (!db) return;
|
|
5894
|
+
await db.clear("cache");
|
|
5895
|
+
} catch (error) {
|
|
5896
|
+
console.error("Failed to clear cache:", error);
|
|
5897
|
+
}
|
|
5898
|
+
};
|
|
5966
5899
|
}
|
|
5967
5900
|
});
|
|
5968
5901
|
|
|
@@ -23052,9 +22985,10 @@ function AuthProvider({
|
|
|
23052
22985
|
);
|
|
23053
22986
|
const [token, setTokenInternal] = useCookieOrLocalStorage(
|
|
23054
22987
|
"token",
|
|
23055
|
-
|
|
23056
|
-
|
|
22988
|
+
session2?.user?.token || session2?.guest?.fingerprint || apiKey,
|
|
22989
|
+
isExtension2
|
|
23057
22990
|
);
|
|
22991
|
+
console.log(`\u{1F680} ~ DataProvider ~ token:`, token);
|
|
23058
22992
|
const [isCookieReady, setIsCookieReady] = (0, import_react19.useState)(false);
|
|
23059
22993
|
(0, import_react19.useEffect)(() => {
|
|
23060
22994
|
if (isExtension2) {
|
|
@@ -23081,6 +23015,7 @@ function AuthProvider({
|
|
|
23081
23015
|
}
|
|
23082
23016
|
}, [isExtension2]);
|
|
23083
23017
|
const setToken = (token2) => {
|
|
23018
|
+
console.log(`\u{1F680} ~ setToken ~ token:`, token2);
|
|
23084
23019
|
setTokenInternal(token2 || "");
|
|
23085
23020
|
};
|
|
23086
23021
|
(0, import_react19.useEffect)(() => {
|
|
@@ -23098,10 +23033,6 @@ function AuthProvider({
|
|
|
23098
23033
|
);
|
|
23099
23034
|
const TEST_MEMBER_FINGERPRINTS = session2?.TEST_MEMBER_FINGERPRINTS || [];
|
|
23100
23035
|
const TEST_GUEST_FINGERPRINTS = session2?.TEST_GUEST_FINGERPRINTS || [];
|
|
23101
|
-
console.log(
|
|
23102
|
-
`\u{1F680} ~ AuthProvider ~ TEST_GUEST_FINGERPRINTS:`,
|
|
23103
|
-
TEST_GUEST_FINGERPRINTS
|
|
23104
|
-
);
|
|
23105
23036
|
const TEST_MEMBER_EMAILS = session2?.TEST_MEMBER_EMAILS || [];
|
|
23106
23037
|
const [taskId, setTaskId] = (0, import_react19.useState)(
|
|
23107
23038
|
searchParams.get("taskId") || void 0
|
|
@@ -23120,7 +23051,7 @@ function AuthProvider({
|
|
|
23120
23051
|
const isLiveTest = isGuestTest || isMemberTest;
|
|
23121
23052
|
const [signInPart, setSignInPartInternal] = import_react19.default.useState(void 0);
|
|
23122
23053
|
const setSignInPart = (part) => {
|
|
23123
|
-
const newPart = part &&
|
|
23054
|
+
const newPart = part && isE2E ? "credentials" : !!user ? void 0 : part;
|
|
23124
23055
|
setSignInPartInternal(newPart);
|
|
23125
23056
|
if (newPart) {
|
|
23126
23057
|
addParams({ signIn: newPart });
|
|
@@ -23885,6 +23816,7 @@ function AuthProvider({
|
|
|
23885
23816
|
const bloom = allApps.find((app2) => app2.slug === "bloom");
|
|
23886
23817
|
const zarathustra = allApps.find((app2) => app2.slug === "zarathustra");
|
|
23887
23818
|
const signOut = async () => {
|
|
23819
|
+
await clearCache();
|
|
23888
23820
|
setShouldFetchSession(false);
|
|
23889
23821
|
setUser(void 0);
|
|
23890
23822
|
setGuest(void 0);
|
|
@@ -24130,7 +24062,7 @@ function DataProvider({ children, ...rest }) {
|
|
|
24130
24062
|
const [instructions, setInstructions] = (0, import_react21.useState)([]);
|
|
24131
24063
|
const [affiliateStats, setAffiliateStats] = (0, import_react21.useState)(null);
|
|
24132
24064
|
const [loadingAffiliateStats, setLoadingAffiliateStats] = (0, import_react21.useState)(false);
|
|
24133
|
-
const VERSION4 = "1.4.
|
|
24065
|
+
const VERSION4 = "1.4.77";
|
|
24134
24066
|
const [weather, setWeather] = useLocalStorage2("weather", user?.weather || guest?.weather || void 0);
|
|
24135
24067
|
const {
|
|
24136
24068
|
API_URL: API_URL2,
|
|
@@ -26584,10 +26516,9 @@ function ChatProvider({
|
|
|
26584
26516
|
const {
|
|
26585
26517
|
data: threadSWR,
|
|
26586
26518
|
mutate,
|
|
26587
|
-
error
|
|
26588
|
-
isLoading: isLoadingThread
|
|
26519
|
+
error
|
|
26589
26520
|
} = (0, import_swr3.default)(
|
|
26590
|
-
shouldFetchThread && token && threadId ? ["thread", threadId, liked, until] : null,
|
|
26521
|
+
shouldFetchThread && token && threadId ? ["thread", threadId, liked, until, token] : null,
|
|
26591
26522
|
async () => {
|
|
26592
26523
|
if (!threadId) return;
|
|
26593
26524
|
const threadData2 = await actions.getThread({
|
|
@@ -42294,10 +42225,14 @@ function SignIn({
|
|
|
42294
42225
|
guest,
|
|
42295
42226
|
isExtensionRedirect,
|
|
42296
42227
|
fingerprint,
|
|
42297
|
-
signInContext,
|
|
42228
|
+
signInContext: signInContextInternal,
|
|
42298
42229
|
signInPart: part,
|
|
42299
42230
|
setSignInPart: setPart
|
|
42300
42231
|
} = useAuth();
|
|
42232
|
+
const signInContext = async (provider, options) => {
|
|
42233
|
+
await clearCache();
|
|
42234
|
+
return signInContextInternal?.(provider, options);
|
|
42235
|
+
};
|
|
42301
42236
|
const { t: t6 } = useAppContext();
|
|
42302
42237
|
const {
|
|
42303
42238
|
FRONTEND_URL: FRONTEND_URL2,
|
|
@@ -42739,6 +42674,7 @@ var init_SignIn_web = __esm({
|
|
|
42739
42674
|
init_Modal();
|
|
42740
42675
|
init_providers();
|
|
42741
42676
|
init_platform();
|
|
42677
|
+
init_db();
|
|
42742
42678
|
}
|
|
42743
42679
|
});
|
|
42744
42680
|
|