@primestyleai/tryon 5.7.1 → 5.7.3

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.
@@ -307,6 +307,14 @@ function getCachedSize(profile, productId) {
307
307
  if (profile.lastEditedAt && profile.lastEditedAt > entry.savedAt) return null;
308
308
  return entry;
309
309
  }
310
+ function readEnv(key) {
311
+ try {
312
+ if (typeof process === "undefined" || !process || !process.env) return void 0;
313
+ return process.env[key];
314
+ } catch {
315
+ return void 0;
316
+ }
317
+ }
310
318
  function detectLocale() {
311
319
  if (typeof navigator === "undefined") return "US";
312
320
  const lang = navigator.language || "";
@@ -327,12 +335,12 @@ function detectLocale() {
327
335
  return map[lang.split("-")[0].toLowerCase()] || "US";
328
336
  }
329
337
  function getApiKey() {
330
- const key = process.env.NEXT_PUBLIC_PRIMESTYLE_API_KEY ?? "";
338
+ const key = readEnv("NEXT_PUBLIC_PRIMESTYLE_API_KEY") ?? "";
331
339
  if (!key) throw new PrimeStyleError("Missing NEXT_PUBLIC_PRIMESTYLE_API_KEY", "MISSING_API_KEY");
332
340
  return key;
333
341
  }
334
342
  function getApiUrl(override) {
335
- return override || process.env.NEXT_PUBLIC_PRIMESTYLE_API_URL || "http://localhost:4000";
343
+ return override || readEnv("NEXT_PUBLIC_PRIMESTYLE_API_URL") || "http://localhost:4000";
336
344
  }
337
345
  async function recommendForProduct(input) {
338
346
  const log = (...args) => console.log("[ps-sdk:recommend]", ...args);