@clerk/chrome-extension 3.0.0-canary-core3.v20251205142050 → 3.0.0-canary-core3.v20251207215551

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.
@@ -2237,7 +2237,7 @@ var retry = async (callback, options = {}) => {
2237
2237
  }
2238
2238
  };
2239
2239
 
2240
- // ../shared/dist/runtime/loadScript-DDWWb733.mjs
2240
+ // ../shared/dist/runtime/loadScript-CHWOPTAN.mjs
2241
2241
  var NO_DOCUMENT_ERROR = "loadScript cannot be called when document does not exist";
2242
2242
  var NO_SRC_ERROR = "loadScript cannot be called without a src";
2243
2243
  async function loadScript(src = "", opts) {
@@ -2251,7 +2251,6 @@ async function loadScript(src = "", opts) {
2251
2251
  script.async = async || false;
2252
2252
  script.defer = defer || false;
2253
2253
  script.addEventListener("load", () => {
2254
- console.log("this loaded ", src);
2255
2254
  script.remove();
2256
2255
  resolve(script);
2257
2256
  });
@@ -2267,7 +2266,6 @@ async function loadScript(src = "", opts) {
2267
2266
  });
2268
2267
  };
2269
2268
  return retry(load, { shouldRetry: (_, iterations) => {
2270
- console.log("nikos 3", _, iterations);
2271
2269
  return iterations <= 5;
2272
2270
  } });
2273
2271
  }
@@ -2298,12 +2296,12 @@ function addClerkPrefix(str) {
2298
2296
  return `clerk.${str.replace(regex, "")}`;
2299
2297
  }
2300
2298
 
2301
- // ../shared/dist/runtime/versionSelector-BxWn31ih.mjs
2302
- var versionSelector = (clerkJSVersion, packageVersion = "6.0.0-canary-core3.v20251205142050") => {
2299
+ // ../shared/dist/runtime/versionSelector-C__XHXrq.mjs
2300
+ var versionSelector = (clerkJSVersion, packageVersion = "6.0.0-canary-core3.v20251207215551") => {
2303
2301
  if (clerkJSVersion) return clerkJSVersion;
2304
2302
  const prereleaseTag = getPrereleaseTag(packageVersion);
2305
2303
  if (prereleaseTag) {
2306
- if (prereleaseTag === "snapshot") return "6.0.0-canary-core3.v20251205142050";
2304
+ if (prereleaseTag === "snapshot") return "6.0.0-canary-core3.v20251207215551";
2307
2305
  return prereleaseTag;
2308
2306
  }
2309
2307
  return getMajorVersion(packageVersion);
@@ -2322,6 +2320,21 @@ function isClerkGlobalProperlyLoaded(prop) {
2322
2320
  return !!window[prop];
2323
2321
  }
2324
2322
  var isClerkUiProperlyLoaded = () => isClerkGlobalProperlyLoaded("__internal_ClerkUiCtor");
2323
+ function hasScriptRequestError(scriptUrl) {
2324
+ if (typeof window === "undefined" || !window.performance) return false;
2325
+ const entries = performance.getEntriesByName(scriptUrl, "resource");
2326
+ if (entries.length === 0) return false;
2327
+ const scriptEntry = entries[entries.length - 1];
2328
+ if (scriptEntry.transferSize === 0 && scriptEntry.decodedBodySize === 0) {
2329
+ if (scriptEntry.responseEnd === 0) return true;
2330
+ if (scriptEntry.responseEnd > 0 && scriptEntry.responseStart > 0) return true;
2331
+ if ("responseStatus" in scriptEntry) {
2332
+ if (scriptEntry.responseStatus >= 400) return true;
2333
+ if (scriptEntry.responseStatus === 0) return true;
2334
+ }
2335
+ }
2336
+ return false;
2337
+ }
2325
2338
  var loadClerkUiScript = async (opts) => {
2326
2339
  var _a5;
2327
2340
  const timeout = (_a5 = opts == null ? void 0 : opts.scriptLoadTimeout) != null ? _a5 : 15e3;
@@ -2330,13 +2343,21 @@ var loadClerkUiScript = async (opts) => {
2330
2343
  cause: error
2331
2344
  });
2332
2345
  if (isClerkUiProperlyLoaded()) return null;
2333
- if (document.querySelector("script[data-clerk-ui-script]")) return waitForPredicateWithTimeout(timeout, isClerkUiProperlyLoaded, rejectWith());
2334
2346
  if (!(opts == null ? void 0 : opts.publishableKey)) {
2335
2347
  errorThrower2.throwMissingPublishableKeyError();
2336
2348
  return null;
2337
2349
  }
2350
+ const scriptUrl = clerkUiScriptUrl(opts);
2351
+ const existingScript = document.querySelector("script[data-clerk-ui-script]");
2352
+ if (existingScript) if (hasScriptRequestError(scriptUrl)) existingScript.remove();
2353
+ else try {
2354
+ await waitForPredicateWithTimeout(timeout, isClerkUiProperlyLoaded, rejectWith(), existingScript);
2355
+ return null;
2356
+ } catch {
2357
+ existingScript.remove();
2358
+ }
2338
2359
  const loadPromise = waitForPredicateWithTimeout(timeout, isClerkUiProperlyLoaded, rejectWith());
2339
- loadScript(clerkUiScriptUrl(opts), {
2360
+ loadScript(scriptUrl, {
2340
2361
  async: true,
2341
2362
  crossOrigin: "anonymous",
2342
2363
  nonce: opts.nonce,
@@ -2376,13 +2397,17 @@ var buildScriptHost = (opts) => {
2376
2397
  else if (domain && !isDevOrStagingUrl(((_a5 = parsePublishableKey(publishableKey)) == null ? void 0 : _a5.frontendApi) || "")) return addClerkPrefix(domain);
2377
2398
  else return ((_b = parsePublishableKey(publishableKey)) == null ? void 0 : _b.frontendApi) || "";
2378
2399
  };
2379
- function waitForPredicateWithTimeout(timeoutMs, predicate, rejectWith) {
2400
+ function waitForPredicateWithTimeout(timeoutMs, predicate, rejectWith, existingScript) {
2380
2401
  return new Promise((resolve, reject) => {
2381
2402
  let resolved = false;
2382
2403
  const cleanup = (timeoutId$1, pollInterval$1) => {
2383
2404
  clearTimeout(timeoutId$1);
2384
2405
  clearInterval(pollInterval$1);
2385
2406
  };
2407
+ existingScript == null ? void 0 : existingScript.addEventListener("error", () => {
2408
+ cleanup(timeoutId, pollInterval);
2409
+ reject(rejectWith);
2410
+ });
2386
2411
  const checkAndResolve = () => {
2387
2412
  if (resolved) return;
2388
2413
  if (predicate()) {
@@ -2995,7 +3020,7 @@ if (typeof globalThis.__BUILD_DISABLE_RHC__ === "undefined") {
2995
3020
  }
2996
3021
  var SDK_METADATA = {
2997
3022
  name: "@clerk/react",
2998
- version: "6.0.0-canary-core3.v20251205142050",
3023
+ version: "6.0.0-canary-core3.v20251207215551",
2999
3024
  environment: process.env.NODE_ENV
3000
3025
  };
3001
3026
  var _status;
@@ -4574,7 +4599,7 @@ var BrowserStorageCache = createBrowserStorageCache();
4574
4599
  var clerk;
4575
4600
  noRhc.Clerk.sdkMetadata = {
4576
4601
  name: "@clerk/chrome-extension",
4577
- version: "3.0.0-canary-core3.v20251205142050"
4602
+ version: "3.0.0-canary-core3.v20251207215551"
4578
4603
  };
4579
4604
  function createClerkClient({
4580
4605
  __experimental_syncHostListener = false,