@primestyleai/tryon 2.0.4 → 2.0.6
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.d.ts +1 -1
- package/dist/react/index.js +25 -5
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -24,4 +24,4 @@ export interface PrimeStyleTryonProps {
|
|
|
24
24
|
code?: string;
|
|
25
25
|
}) => void;
|
|
26
26
|
}
|
|
27
|
-
export declare function PrimeStyleTryon(
|
|
27
|
+
export declare function PrimeStyleTryon(props: PrimeStyleTryonProps): import("react/jsx-runtime").JSX.Element | null;
|
package/dist/react/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { useState,
|
|
2
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect, useRef, useMemo, useCallback } from "react";
|
|
4
4
|
import { A as ApiClient, S as SseClient, i as isValidImageFile, c as compressImage, P as PrimeStyleError } from "../image-utils-C9bJ1zKO.js";
|
|
5
5
|
function cx(base, override) {
|
|
6
6
|
return override ? `${base} ${override}` : base;
|
|
7
7
|
}
|
|
8
8
|
const LS_PREFIX = "primestyle_";
|
|
9
9
|
function lsGet(key, fallback) {
|
|
10
|
+
if (typeof window === "undefined") return fallback;
|
|
10
11
|
try {
|
|
11
12
|
const raw = localStorage.getItem(LS_PREFIX + key);
|
|
12
13
|
return raw ? JSON.parse(raw) : fallback;
|
|
@@ -37,6 +38,7 @@ const SIZING_COUNTRIES = [
|
|
|
37
38
|
const STEP_LABELS = ["", "Welcome", "Photo", "Size", "Generate", "Results"];
|
|
38
39
|
const TOTAL_STEPS = 5;
|
|
39
40
|
function detectLocale() {
|
|
41
|
+
if (typeof window === "undefined") return "US";
|
|
40
42
|
const l = (navigator.language || "en-US").toLowerCase();
|
|
41
43
|
if (l.includes("en-gb") || l.includes("en-au")) return "UK";
|
|
42
44
|
if (l.includes("en")) return "US";
|
|
@@ -152,7 +154,15 @@ function getApiKey() {
|
|
|
152
154
|
function getApiUrl(override) {
|
|
153
155
|
return override || process.env.NEXT_PUBLIC_PRIMESTYLE_API_URL || "https://myaifitting.com";
|
|
154
156
|
}
|
|
155
|
-
function PrimeStyleTryon({
|
|
157
|
+
function PrimeStyleTryon(props) {
|
|
158
|
+
const [mounted, setMounted] = useState(false);
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
setMounted(true);
|
|
161
|
+
}, []);
|
|
162
|
+
if (!mounted) return null;
|
|
163
|
+
return /* @__PURE__ */ jsx(PrimeStyleTryonInner, { ...props });
|
|
164
|
+
}
|
|
165
|
+
function PrimeStyleTryonInner({
|
|
156
166
|
productImage,
|
|
157
167
|
productTitle = "Product",
|
|
158
168
|
buttonText = "Virtual Try-On",
|
|
@@ -204,6 +214,17 @@ function PrimeStyleTryon({
|
|
|
204
214
|
const pollingRef = useRef(null);
|
|
205
215
|
const completedRef = useRef(false);
|
|
206
216
|
const bodyRef = useRef(null);
|
|
217
|
+
useEffect(() => {
|
|
218
|
+
const id = "ps-tryon-styles";
|
|
219
|
+
if (document.getElementById(id)) return;
|
|
220
|
+
const el = document.createElement("style");
|
|
221
|
+
el.id = id;
|
|
222
|
+
el.textContent = STYLES;
|
|
223
|
+
document.head.appendChild(el);
|
|
224
|
+
return () => {
|
|
225
|
+
el.remove();
|
|
226
|
+
};
|
|
227
|
+
}, []);
|
|
207
228
|
useEffect(() => {
|
|
208
229
|
try {
|
|
209
230
|
const key = getApiKey();
|
|
@@ -1075,8 +1096,7 @@ function PrimeStyleTryon({
|
|
|
1075
1096
|
/* @__PURE__ */ jsx("a", { href: "https://myaifitting.com", target: "_blank", rel: "noopener noreferrer", children: "PrimeStyle AI" })
|
|
1076
1097
|
] })
|
|
1077
1098
|
] }) }),
|
|
1078
|
-
/* @__PURE__ */ jsx(ProfileDetailModal, {})
|
|
1079
|
-
/* @__PURE__ */ jsx("style", { children: STYLES })
|
|
1099
|
+
/* @__PURE__ */ jsx(ProfileDetailModal, {})
|
|
1080
1100
|
] });
|
|
1081
1101
|
}
|
|
1082
1102
|
const STYLES = `
|