@primestyleai/tryon 5.7.0 → 5.7.2
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/react/index.js +10 -2
- package/dist/storefront/index.d.ts +16 -0
- package/dist/storefront/primestyle-tryon.js +9910 -34306
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -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 =
|
|
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 ||
|
|
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);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storefront auto-mount entry.
|
|
3
|
+
*
|
|
4
|
+
* Built by `vite.storefront.config.ts` into
|
|
5
|
+
* `dist/storefront/primestyle-tryon.js` — a single self-contained bundle
|
|
6
|
+
* with React + React-DOM inlined, designed to be dropped into a Shopify
|
|
7
|
+
* theme app extension's `assets/` folder and loaded via a normal
|
|
8
|
+
* `<script src="{{ 'primestyle-tryon.js' | asset_url }}" defer>` tag.
|
|
9
|
+
*
|
|
10
|
+
* On load, it scans the page for every `.primestyle-tryon-root` element
|
|
11
|
+
* (injected by the Liquid block), reads its `data-*` attributes, and
|
|
12
|
+
* mounts a `<PrimeStyleTryon>` React component inside each one. No
|
|
13
|
+
* host-side JS is required — the Liquid block just needs to render the
|
|
14
|
+
* root div with the right data attributes.
|
|
15
|
+
*/
|
|
16
|
+
import "../locales";
|