@primestyleai/tryon 5.7.6 → 5.7.7

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,14 +307,6 @@ 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
- }
318
310
  function detectLocale() {
319
311
  if (typeof navigator === "undefined") return "US";
320
312
  const lang = navigator.language || "";
@@ -335,12 +327,22 @@ function detectLocale() {
335
327
  return map[lang.split("-")[0].toLowerCase()] || "US";
336
328
  }
337
329
  function getApiKey() {
338
- const key = readEnv("NEXT_PUBLIC_PRIMESTYLE_API_KEY") ?? "";
330
+ let key = "";
331
+ try {
332
+ key = process.env.NEXT_PUBLIC_PRIMESTYLE_API_KEY ?? "";
333
+ } catch {
334
+ }
339
335
  if (!key) throw new PrimeStyleError("Missing NEXT_PUBLIC_PRIMESTYLE_API_KEY", "MISSING_API_KEY");
340
336
  return key;
341
337
  }
342
338
  function getApiUrl(override) {
343
- return override || readEnv("NEXT_PUBLIC_PRIMESTYLE_API_URL") || "http://localhost:4000";
339
+ if (override) return override;
340
+ let envUrl = "";
341
+ try {
342
+ envUrl = process.env.NEXT_PUBLIC_PRIMESTYLE_API_URL ?? "";
343
+ } catch {
344
+ }
345
+ return envUrl || "http://localhost:4000";
344
346
  }
345
347
  async function recommendForProduct(input) {
346
348
  const log = (...args) => console.log("[ps-sdk:recommend]", ...args);
@@ -1,3 +1,17 @@
1
1
  export declare function detectLocale(): string;
2
+ /**
3
+ * Read `process.env.NEXT_PUBLIC_PRIMESTYLE_API_KEY`.
4
+ *
5
+ * IMPORTANT: this MUST be a literal `process.env.X` access, NOT a
6
+ * dynamic property read like `process.env[key]`. Bundlers (Next.js
7
+ * SWC, Vite `define`, Webpack DefinePlugin) only perform STATIC
8
+ * replacement of literal property accesses. A dynamic access escapes
9
+ * the replacement and falls through to a runtime `process` lookup,
10
+ * which throws `ReferenceError: process is not defined` in any
11
+ * pure-browser context (Shopify storefront, etc.).
12
+ *
13
+ * The try/catch is the runtime safety net for environments that
14
+ * neither replace at build time NOR provide a `process` shim.
15
+ */
2
16
  export declare function getApiKey(): string;
3
17
  export declare function getApiUrl(override?: string): string;
@@ -9762,15 +9762,6 @@ function addSizeToHistory(profileId, entry) {
9762
9762
  saveProfiles(profiles);
9763
9763
  return profiles[idx];
9764
9764
  }
9765
- var define_process_env_default = {};
9766
- function readEnv(key) {
9767
- try {
9768
- if (typeof process === "undefined" || !process || !define_process_env_default) return void 0;
9769
- return define_process_env_default[key];
9770
- } catch {
9771
- return void 0;
9772
- }
9773
- }
9774
9765
  function detectLocale() {
9775
9766
  if (typeof navigator === "undefined") return "US";
9776
9767
  const lang = navigator.language || "";
@@ -9791,12 +9782,22 @@ function detectLocale() {
9791
9782
  return map[lang.split("-")[0].toLowerCase()] || "US";
9792
9783
  }
9793
9784
  function getApiKey() {
9794
- const key = readEnv("NEXT_PUBLIC_PRIMESTYLE_API_KEY") ?? "";
9785
+ let key = "";
9786
+ try {
9787
+ key = "shopify-proxy";
9788
+ } catch {
9789
+ }
9795
9790
  if (!key) throw new PrimeStyleError("Missing NEXT_PUBLIC_PRIMESTYLE_API_KEY", "MISSING_API_KEY");
9796
9791
  return key;
9797
9792
  }
9798
9793
  function getApiUrl(override) {
9799
- return override || readEnv("NEXT_PUBLIC_PRIMESTYLE_API_URL") || "http://localhost:4000";
9794
+ if (override) return override;
9795
+ let envUrl = "";
9796
+ try {
9797
+ envUrl = "";
9798
+ } catch {
9799
+ }
9800
+ return envUrl || "http://localhost:4000";
9800
9801
  }
9801
9802
  async function recommendForProduct(input) {
9802
9803
  const log = (...args) => console.log("[ps-sdk:recommend]", ...args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "5.7.6",
3
+ "version": "5.7.7",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",