@wewear/virtual-try-on 1.3.1 → 1.3.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.
- package/dist/api.d.ts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +70 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +70 -25
- package/dist/index.js.map +1 -1
- package/dist/widget.d.ts +2 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { VirtualTryOnResult } from "./index.js";
|
|
2
|
-
export declare function callVirtualTryOnApi(baseUrl: string, ww_access_token: string, ww_user_id: string,
|
|
2
|
+
export declare function callVirtualTryOnApi(baseUrl: string, ww_access_token: string, ww_user_id: string, ww_product_image: string, ww_image: Blob): Promise<VirtualTryOnResult | null>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function createButtonContainer(buttonPosition: string, hasVirtualTryOn: boolean | undefined, onCameraClick: () => void, onRefreshClick?: () => void, onToggleClick?: () => void, isShowingVirtualTryOn?: boolean): HTMLElement;
|
|
2
|
-
export declare function createButton(buttonPosition: string, onClick: () => void): HTMLElement;
|
|
2
|
+
export declare function createButton(buttonPosition: string, onClick: () => void, disabled?: boolean): HTMLElement;
|
package/dist/constants.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare const DEFAULT_CONFIG: {
|
|
|
3
3
|
readonly BASE_URL: "https://virtual-try-on-widget.vercel.app";
|
|
4
4
|
readonly PRODUCT_PAGE_SELECTOR: "/product/";
|
|
5
5
|
readonly GALLERY_SELECTOR: ".woocommerce-product-gallery__image";
|
|
6
|
-
readonly
|
|
6
|
+
readonly PRODUCT_IMAGE_SELECTOR: ".woocommerce-product-gallery__image img";
|
|
7
7
|
readonly BUTTON_POSITION: "bottom-right";
|
|
8
8
|
};
|
|
9
9
|
/** CSS class names for consistent styling */
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export interface VirtualTryOnConfig {
|
|
|
2
2
|
baseUrl?: string;
|
|
3
3
|
productPageSelector?: string;
|
|
4
4
|
gallerySelector?: string;
|
|
5
|
-
|
|
5
|
+
productImageSelector?: string;
|
|
6
6
|
buttonPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
7
7
|
}
|
|
8
8
|
export interface VirtualTryOnResult {
|
|
@@ -11,7 +11,7 @@ export interface VirtualTryOnResult {
|
|
|
11
11
|
export interface VirtualTryOnAPIRequest {
|
|
12
12
|
ww_access_token: string;
|
|
13
13
|
ww_user_id: string;
|
|
14
|
-
|
|
14
|
+
ww_product_image: string;
|
|
15
15
|
ww_image: Blob;
|
|
16
16
|
}
|
|
17
17
|
export { destroyVirtualTryOn, getWidgetInstance, initVirtualTryOn, } from "./installer.js";
|
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
async function callVirtualTryOnApi(baseUrl, ww_access_token, ww_user_id,
|
|
1
|
+
async function callVirtualTryOnApi(baseUrl, ww_access_token, ww_user_id, ww_product_image, ww_image) {
|
|
2
2
|
try {
|
|
3
3
|
const formData = new FormData();
|
|
4
4
|
formData.append("ww_user_id", ww_user_id);
|
|
5
|
-
formData.append("
|
|
5
|
+
formData.append("ww_product_image", ww_product_image);
|
|
6
6
|
formData.append("ww_image", ww_image, "captured-image.jpg");
|
|
7
7
|
formData.append("ww_access_token", ww_access_token);
|
|
8
8
|
const response = await fetch(`${baseUrl}/api/virtual-try-on`, {
|
|
@@ -28,7 +28,7 @@ const DEFAULT_CONFIG = {
|
|
|
28
28
|
BASE_URL: "https://virtual-try-on-widget.vercel.app",
|
|
29
29
|
PRODUCT_PAGE_SELECTOR: "/product/",
|
|
30
30
|
GALLERY_SELECTOR: ".woocommerce-product-gallery__image",
|
|
31
|
-
|
|
31
|
+
PRODUCT_IMAGE_SELECTOR: ".woocommerce-product-gallery__image img",
|
|
32
32
|
BUTTON_POSITION: "bottom-right",
|
|
33
33
|
};
|
|
34
34
|
/** CSS class names for consistent styling */
|
|
@@ -247,8 +247,18 @@ function createButtonContainer(buttonPosition, hasVirtualTryOn = false, onCamera
|
|
|
247
247
|
}
|
|
248
248
|
return container;
|
|
249
249
|
}
|
|
250
|
-
function createButton(buttonPosition, onClick) {
|
|
251
|
-
|
|
250
|
+
function createButton(buttonPosition, onClick, disabled = false) {
|
|
251
|
+
const container = createButtonContainer(buttonPosition, false, onClick);
|
|
252
|
+
const cameraButton = container.querySelector('.ww-camera-btn');
|
|
253
|
+
if (cameraButton) {
|
|
254
|
+
cameraButton.disabled = disabled;
|
|
255
|
+
if (disabled) {
|
|
256
|
+
cameraButton.style.opacity = '0.5';
|
|
257
|
+
cameraButton.style.cursor = 'not-allowed';
|
|
258
|
+
cameraButton.title = 'Find your ideal size first';
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return container;
|
|
252
262
|
}
|
|
253
263
|
|
|
254
264
|
function showCameraModal(callbacks) {
|
|
@@ -610,11 +620,13 @@ class VirtualTryOnWidget {
|
|
|
610
620
|
this.virtualTryOnImageUrl = null;
|
|
611
621
|
this.isShowingVirtualTryOn = false;
|
|
612
622
|
this.lastApiParams = null;
|
|
623
|
+
this.cookieCheckInterval = null;
|
|
624
|
+
this.cameraButton = null;
|
|
613
625
|
this.config = {
|
|
614
626
|
baseUrl: config.baseUrl || DEFAULT_CONFIG.BASE_URL,
|
|
615
627
|
productPageSelector: config.productPageSelector || DEFAULT_CONFIG.PRODUCT_PAGE_SELECTOR,
|
|
616
628
|
gallerySelector: config.gallerySelector || DEFAULT_CONFIG.GALLERY_SELECTOR,
|
|
617
|
-
|
|
629
|
+
productImageSelector: config.productImageSelector || DEFAULT_CONFIG.PRODUCT_IMAGE_SELECTOR,
|
|
618
630
|
buttonPosition: config.buttonPosition || DEFAULT_CONFIG.BUTTON_POSITION,
|
|
619
631
|
};
|
|
620
632
|
}
|
|
@@ -638,12 +650,40 @@ class VirtualTryOnWidget {
|
|
|
638
650
|
if (getComputedStyle(container).position === "static") {
|
|
639
651
|
container.style.position = "relative";
|
|
640
652
|
}
|
|
653
|
+
// Check required cookies
|
|
654
|
+
const ww_access_token = getCookie("ww_access_token");
|
|
655
|
+
const ww_user_id = getCookie("ww_user_id");
|
|
656
|
+
const cookiesPresent = !!ww_access_token && !!ww_user_id;
|
|
641
657
|
// Create and add the virtual try-on button
|
|
642
658
|
const button = createButton(this.config.buttonPosition, async () => {
|
|
643
|
-
|
|
644
|
-
|
|
659
|
+
if (this.cameraButton && !this.cameraButton.disabled) {
|
|
660
|
+
await this.handleTryOnClick();
|
|
661
|
+
}
|
|
662
|
+
}, !cookiesPresent);
|
|
663
|
+
// Store reference to camera button for dynamic enable/disable
|
|
664
|
+
this.cameraButton = button.querySelector('.ww-camera-btn');
|
|
645
665
|
container.appendChild(button);
|
|
646
666
|
console.log("[WeWear VTO] Widget initialized successfully");
|
|
667
|
+
// Periodically check cookies and update button state
|
|
668
|
+
this.cookieCheckInterval = window.setInterval(() => {
|
|
669
|
+
const accessToken = getCookie("ww_access_token");
|
|
670
|
+
const userId = getCookie("ww_user_id");
|
|
671
|
+
const present = !!accessToken && !!userId;
|
|
672
|
+
if (this.cameraButton) {
|
|
673
|
+
if (present && this.cameraButton.disabled) {
|
|
674
|
+
this.cameraButton.disabled = false;
|
|
675
|
+
this.cameraButton.style.opacity = '1';
|
|
676
|
+
this.cameraButton.style.cursor = 'pointer';
|
|
677
|
+
this.cameraButton.title = '';
|
|
678
|
+
}
|
|
679
|
+
else if (!present && !this.cameraButton.disabled) {
|
|
680
|
+
this.cameraButton.disabled = true;
|
|
681
|
+
this.cameraButton.style.opacity = '0.5';
|
|
682
|
+
this.cameraButton.style.cursor = 'not-allowed';
|
|
683
|
+
this.cameraButton.title = 'Required cookies missing';
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}, 2000); // check every 2 seconds
|
|
647
687
|
}
|
|
648
688
|
catch (error) {
|
|
649
689
|
console.error("[WeWear VTO] Initialization failed:", error);
|
|
@@ -654,17 +694,16 @@ class VirtualTryOnWidget {
|
|
|
654
694
|
* @private
|
|
655
695
|
*/
|
|
656
696
|
async handleTryOnClick() {
|
|
657
|
-
var _a;
|
|
658
697
|
console.log("[WeWear VTO] Button clicked, starting try-on process...");
|
|
659
698
|
try {
|
|
660
699
|
// Get required data
|
|
661
700
|
const ww_access_token = getCookie("ww_access_token");
|
|
662
701
|
const ww_user_id = getCookie("ww_user_id");
|
|
663
|
-
const
|
|
664
|
-
const
|
|
702
|
+
const productImageElement = document.querySelector(this.config.productImageSelector);
|
|
703
|
+
const ww_product_image = (productImageElement === null || productImageElement === void 0 ? void 0 : productImageElement.src) || (productImageElement === null || productImageElement === void 0 ? void 0 : productImageElement.getAttribute('data-src')) || '';
|
|
665
704
|
console.log("[WeWear VTO] Retrieved data:", {
|
|
666
705
|
ww_user_id,
|
|
667
|
-
|
|
706
|
+
ww_product_image,
|
|
668
707
|
ww_access_token,
|
|
669
708
|
});
|
|
670
709
|
// Validate required data
|
|
@@ -672,8 +711,8 @@ class VirtualTryOnWidget {
|
|
|
672
711
|
console.warn("[WeWear VTO] Missing required cookie: ww_user_id");
|
|
673
712
|
return;
|
|
674
713
|
}
|
|
675
|
-
if (!
|
|
676
|
-
console.warn("[WeWear VTO] Product
|
|
714
|
+
if (!ww_product_image) {
|
|
715
|
+
console.warn("[WeWear VTO] Product image not found:", this.config.productImageSelector);
|
|
677
716
|
return;
|
|
678
717
|
}
|
|
679
718
|
if (!ww_access_token) {
|
|
@@ -681,7 +720,7 @@ class VirtualTryOnWidget {
|
|
|
681
720
|
return;
|
|
682
721
|
}
|
|
683
722
|
// Show camera capture modal
|
|
684
|
-
this.showCameraModalWithCallbacks(ww_access_token, ww_user_id,
|
|
723
|
+
this.showCameraModalWithCallbacks(ww_access_token, ww_user_id, ww_product_image);
|
|
685
724
|
}
|
|
686
725
|
catch (error) {
|
|
687
726
|
console.error("[WeWear VTO] Try-on request failed:", error);
|
|
@@ -691,7 +730,7 @@ class VirtualTryOnWidget {
|
|
|
691
730
|
* Shows camera modal with appropriate callbacks
|
|
692
731
|
* @private
|
|
693
732
|
*/
|
|
694
|
-
showCameraModalWithCallbacks(ww_access_token, ww_user_id,
|
|
733
|
+
showCameraModalWithCallbacks(ww_access_token, ww_user_id, ww_product_image) {
|
|
695
734
|
const callbacks = {
|
|
696
735
|
onCapture: async (video, canvas) => {
|
|
697
736
|
try {
|
|
@@ -700,7 +739,7 @@ class VirtualTryOnWidget {
|
|
|
700
739
|
// Stop camera and show review modal
|
|
701
740
|
stopCamera(video);
|
|
702
741
|
// Show review modal instead of immediately processing
|
|
703
|
-
this.showReviewModalWithCallbacks(imageBlob, ww_access_token, ww_user_id,
|
|
742
|
+
this.showReviewModalWithCallbacks(imageBlob, ww_access_token, ww_user_id, ww_product_image);
|
|
704
743
|
}
|
|
705
744
|
catch (error) {
|
|
706
745
|
console.error("[WeWear VTO] Image capture error:", error);
|
|
@@ -713,14 +752,14 @@ class VirtualTryOnWidget {
|
|
|
713
752
|
* Shows review modal with appropriate callbacks
|
|
714
753
|
* @private
|
|
715
754
|
*/
|
|
716
|
-
showReviewModalWithCallbacks(imageBlob, ww_access_token, ww_user_id,
|
|
755
|
+
showReviewModalWithCallbacks(imageBlob, ww_access_token, ww_user_id, ww_product_image) {
|
|
717
756
|
const callbacks = {
|
|
718
757
|
onRetake: () => {
|
|
719
758
|
// Reopen camera modal
|
|
720
|
-
this.showCameraModalWithCallbacks(ww_access_token, ww_user_id,
|
|
759
|
+
this.showCameraModalWithCallbacks(ww_access_token, ww_user_id, ww_product_image);
|
|
721
760
|
},
|
|
722
761
|
onAccept: async (acceptedImageBlob) => {
|
|
723
|
-
await this.processAcceptedImage(acceptedImageBlob, ww_access_token, ww_user_id,
|
|
762
|
+
await this.processAcceptedImage(acceptedImageBlob, ww_access_token, ww_user_id, ww_product_image);
|
|
724
763
|
},
|
|
725
764
|
};
|
|
726
765
|
showReviewModal(imageBlob, callbacks);
|
|
@@ -729,7 +768,7 @@ class VirtualTryOnWidget {
|
|
|
729
768
|
* Processes the accepted image by calling the API
|
|
730
769
|
* @private
|
|
731
770
|
*/
|
|
732
|
-
async processAcceptedImage(imageBlob, ww_access_token, ww_user_id,
|
|
771
|
+
async processAcceptedImage(imageBlob, ww_access_token, ww_user_id, ww_product_image) {
|
|
733
772
|
try {
|
|
734
773
|
console.log("[WeWear VTO] Processing accepted image...");
|
|
735
774
|
// Show loading in the review modal first
|
|
@@ -739,10 +778,10 @@ class VirtualTryOnWidget {
|
|
|
739
778
|
imageBlob,
|
|
740
779
|
ww_access_token,
|
|
741
780
|
ww_user_id,
|
|
742
|
-
|
|
781
|
+
ww_product_image,
|
|
743
782
|
};
|
|
744
783
|
// Call the API with the accepted image
|
|
745
|
-
const result = await callVirtualTryOnApi(this.config.baseUrl, ww_access_token, ww_user_id,
|
|
784
|
+
const result = await callVirtualTryOnApi(this.config.baseUrl, ww_access_token, ww_user_id, ww_product_image, imageBlob);
|
|
746
785
|
// Remove modal loading and close modal
|
|
747
786
|
removeModalLoading();
|
|
748
787
|
removeElements(`.${CSS_CLASSES.MODAL}`);
|
|
@@ -776,7 +815,7 @@ class VirtualTryOnWidget {
|
|
|
776
815
|
showProductLoading(container, "Generating new virtual try-on...");
|
|
777
816
|
}
|
|
778
817
|
// Call the API with the stored parameters
|
|
779
|
-
const result = await callVirtualTryOnApi(this.config.baseUrl, this.lastApiParams.ww_access_token, this.lastApiParams.ww_user_id, this.lastApiParams.
|
|
818
|
+
const result = await callVirtualTryOnApi(this.config.baseUrl, this.lastApiParams.ww_access_token, this.lastApiParams.ww_user_id, this.lastApiParams.ww_product_image, this.lastApiParams.imageBlob);
|
|
780
819
|
if (result === null || result === void 0 ? void 0 : result.imageUrl) {
|
|
781
820
|
this.virtualTryOnImageUrl = result.imageUrl;
|
|
782
821
|
// Find the gallery container and update the image
|
|
@@ -909,7 +948,7 @@ class VirtualTryOnWidget {
|
|
|
909
948
|
image.style.cssText = `
|
|
910
949
|
width: ${widthStyle};
|
|
911
950
|
height: ${heightStyle};
|
|
912
|
-
object-fit:
|
|
951
|
+
object-fit: cover;
|
|
913
952
|
border-radius: 8px;
|
|
914
953
|
`;
|
|
915
954
|
container.appendChild(image);
|
|
@@ -946,6 +985,12 @@ class VirtualTryOnWidget {
|
|
|
946
985
|
removeElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);
|
|
947
986
|
// Remove all modals
|
|
948
987
|
removeElements(`.${CSS_CLASSES.MODAL}`);
|
|
988
|
+
// Clear interval
|
|
989
|
+
if (this.cookieCheckInterval !== null) {
|
|
990
|
+
clearInterval(this.cookieCheckInterval);
|
|
991
|
+
this.cookieCheckInterval = null;
|
|
992
|
+
}
|
|
993
|
+
this.cameraButton = null;
|
|
949
994
|
// Reset state
|
|
950
995
|
this.virtualTryOnImageUrl = null;
|
|
951
996
|
this.isShowingVirtualTryOn = false;
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/api.ts","../src/constants.ts","../src/camera.ts","../src/utils.ts","../src/components/button.ts","../src/components/camera-modal.ts","../src/components/loading-overlay.ts","../src/components/review-modal.ts","../src/widget.ts","../src/installer.ts"],"sourcesContent":["import type { VirtualTryOnResult } from \"./index.js\";\n\nexport async function callVirtualTryOnApi(\n baseUrl: string,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ww_image: Blob,\n): Promise<VirtualTryOnResult | null> {\n try {\n const formData = new FormData();\n formData.append(\"ww_user_id\", ww_user_id);\n formData.append(\"ww_product_id\", ww_product_id);\n formData.append(\"ww_image\", ww_image, \"captured-image.jpg\");\n formData.append(\"ww_access_token\", ww_access_token);\n\n const response = await fetch(`${baseUrl}/api/virtual-try-on`, {\n method: \"POST\",\n body: formData,\n });\n\n if (!response.ok) {\n console.error(\n \"[WeWear VTO] API request failed:\",\n response.status,\n response.statusText,\n );\n return null;\n }\n\n const result = await response.json();\n console.log(\"[WeWear VTO] API response:\", result);\n return result;\n } catch (error) {\n console.error(\"[WeWear VTO] API call failed:\", error);\n return null;\n }\n}\n","/** Default configuration constants */\nexport const DEFAULT_CONFIG = {\n BASE_URL: \"https://virtual-try-on-widget.vercel.app\",\n PRODUCT_PAGE_SELECTOR: \"/product/\",\n GALLERY_SELECTOR: \".woocommerce-product-gallery__image\",\n SKU_SELECTOR: \".sku\",\n BUTTON_POSITION: \"bottom-right\" as const,\n} as const;\n\n/** CSS class names for consistent styling */\nexport const CSS_CLASSES = {\n BUTTON_CONTAINER: \"wewear-vto-button-container\",\n BUTTON: \"wewear-vto-button\",\n MODAL: \"wewear-vto-modal\",\n} as const;\n\n/** Z-index values for proper layering */\nexport const Z_INDEX = {\n BUTTON: 10,\n MODAL: 99999,\n} as const;\n\n/** Camera constraints for optimal capture */\nexport const CAMERA_CONSTRAINTS = {\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: \"user\", // Front-facing camera\n },\n audio: false,\n} as const;\n\n/** Image capture settings */\nexport const IMAGE_SETTINGS = {\n FORMAT: \"image/jpeg\",\n QUALITY: 0.8,\n} as const;\n","import { CAMERA_CONSTRAINTS, IMAGE_SETTINGS } from \"./constants.js\";\n\nexport async function startCamera(\n video: HTMLVideoElement,\n loadingIndicator: HTMLElement,\n captureButton: HTMLButtonElement,\n): Promise<void> {\n console.log(\"[WeWear VTO] Starting camera...\");\n\n try {\n console.log(\"[WeWear VTO] Requesting camera access...\");\n const stream =\n await navigator.mediaDevices.getUserMedia(CAMERA_CONSTRAINTS);\n video.srcObject = stream;\n\n video.onloadedmetadata = () => {\n console.log(\"[WeWear VTO] Camera stream loaded successfully\");\n loadingIndicator.style.display = \"none\";\n captureButton.style.display = \"flex\";\n };\n } catch (error) {\n console.error(\"[WeWear VTO] Camera access error:\", error);\n loadingIndicator.innerHTML =\n \"Camera access denied. Please allow camera permissions.\";\n }\n}\n\nexport function stopCamera(video: HTMLVideoElement): void {\n const stream = video.srcObject as MediaStream;\n if (stream) {\n const tracks = stream.getTracks();\n tracks.forEach((track) => {\n track.stop();\n });\n video.srcObject = null;\n }\n}\n\nexport async function captureImageFromVideo(\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n): Promise<Blob> {\n // Set canvas dimensions to match video\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // Draw video frame to canvas\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) {\n throw new Error(\"Could not get canvas context\");\n }\n\n ctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n\n // Convert canvas to blob\n return new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n (blob) => {\n if (blob) {\n resolve(blob);\n } else {\n reject(new Error(\"Failed to create blob from canvas\"));\n }\n },\n IMAGE_SETTINGS.FORMAT,\n IMAGE_SETTINGS.QUALITY,\n );\n });\n}\n","export function getCookie(name: string): string | null {\n if (typeof document === \"undefined\") return null;\n\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n\n if (parts.length === 2) {\n const part = parts.pop();\n return part ? part.split(\";\").shift()?.trim() || null : null;\n }\n\n return null;\n}\n\nexport function getPositionStyles(position: string): string {\n switch (position) {\n case \"bottom-left\":\n return \"left: 20px; bottom: 20px;\";\n case \"top-right\":\n return \"right: 20px; top: 20px;\";\n case \"top-left\":\n return \"left: 20px; top: 20px;\";\n default:\n return \"right: 20px; bottom: 20px;\";\n }\n}\n\nexport function removeElements(selector: string): void {\n const elements = document.querySelectorAll(selector);\n elements.forEach((element) => {\n element.remove();\n });\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { getPositionStyles } from \"../utils.js\";\n\nexport function createButtonContainer(\n buttonPosition: string,\n hasVirtualTryOn: boolean = false,\n onCameraClick: () => void,\n onRefreshClick?: () => void,\n onToggleClick?: () => void,\n isShowingVirtualTryOn: boolean = false,\n): HTMLElement {\n const container = document.createElement(\"div\");\n container.className = `${CSS_CLASSES.BUTTON_CONTAINER} ww-button-group`;\n\n const positionStyles = getPositionStyles(buttonPosition);\n container.style.cssText = `\n position: absolute;\n ${positionStyles}\n display: flex;\n border-radius: 9999px;\n background: white;\n padding: 4px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n z-index: ${Z_INDEX.BUTTON};\n `;\n\n // Camera button\n const cameraButton = document.createElement(\"button\");\n cameraButton.type = \"button\";\n cameraButton.className = `${CSS_CLASSES.BUTTON} ww-camera-btn`;\n cameraButton.setAttribute(\"aria-label\", \"Virtual Try-On\");\n cameraButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: transparent;\n color: currentColor;\n `;\n\n cameraButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-camera\">\n <path d=\"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z\"></path>\n <circle cx=\"12\" cy=\"13\" r=\"3\"></circle>\n </svg>\n `;\n\n cameraButton.onclick = onCameraClick;\n container.appendChild(cameraButton);\n\n // Add refresh and toggle buttons if we have a virtual try-on\n if (hasVirtualTryOn) {\n // Refresh button - calls API again\n if (onRefreshClick) {\n const refreshButton = document.createElement(\"button\");\n refreshButton.type = \"button\";\n refreshButton.className = \"ww-refresh-btn\";\n refreshButton.setAttribute(\"aria-label\", \"Refresh virtual try-on\");\n refreshButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: transparent;\n color: currentColor;\n `;\n\n refreshButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-refresh-ccw\">\n <path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path>\n <path d=\"M3 3v5h5\"></path>\n <path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path>\n <path d=\"M16 16h5v5\"></path>\n </svg>\n `;\n\n refreshButton.onclick = onRefreshClick;\n container.appendChild(refreshButton);\n }\n\n // Toggle button (scan-face) - switches between original and virtual try-on\n if (onToggleClick) {\n const toggleButton = document.createElement(\"button\");\n toggleButton.type = \"button\";\n toggleButton.className = \"ww-toggle-btn\";\n toggleButton.setAttribute(\n \"aria-label\",\n isShowingVirtualTryOn ? \"Show Original Image\" : \"Show Virtual Try-On\",\n );\n toggleButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: ${isShowingVirtualTryOn ? \"rgba(0, 0, 0)\" : \"none\"};\n color: ${isShowingVirtualTryOn ? \"white\" : \"currentColor\"};\n `;\n\n toggleButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-scan-face\">\n <path d=\"M3 7V5a2 2 0 0 1 2-2h2\"></path>\n <path d=\"M17 3h2a2 2 0 0 1 2 2v2\"></path>\n <path d=\"M21 17v2a2 2 0 0 1-2 2h-2\"></path>\n <path d=\"M7 21H5a2 2 0 0 1-2-2v-2\"></path>\n <path d=\"M8 14s1.5 2 4 2 4-2 4-2\"></path>\n <path d=\"M9 9h.01\"></path>\n <path d=\"M15 9h.01\"></path>\n </svg>\n `;\n\n toggleButton.onclick = onToggleClick;\n container.appendChild(toggleButton);\n }\n }\n\n return container;\n}\n\nexport function createButton(\n buttonPosition: string,\n onClick: () => void,\n): HTMLElement {\n return createButtonContainer(buttonPosition, false, onClick);\n}\n","import { startCamera, stopCamera } from \"../camera.js\";\nimport { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { removeElements } from \"../utils.js\";\n\nexport interface CameraModalCallbacks {\n onCapture: (\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n ) => Promise<void>;\n}\n\nexport function showCameraModal(callbacks: CameraModalCallbacks): void {\n console.log(\"[WeWear VTO] Opening camera modal...\");\n\n // Remove any existing modals first\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create camera container\n const cameraContainer = document.createElement(\"div\");\n cameraContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 70vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create video element\n const video = document.createElement(\"video\");\n video.autoplay = true;\n video.playsInline = true;\n video.muted = true;\n video.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create canvas for capturing\n const canvas = document.createElement(\"canvas\");\n canvas.style.display = \"none\";\n\n // Create capture button\n const captureButton = document.createElement(\"button\");\n captureButton.innerHTML = \"\";\n captureButton.style.cssText = `\n position: absolute;\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n width: 60px;\n height: 60px;\n border: 3px solid white;\n background-color: rgba(0, 0, 0, 0.7);\n border-radius: 50%;\n cursor: pointer;\n display: none;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create loading indicator\n const loadingIndicator = document.createElement(\"div\");\n loadingIndicator.innerHTML = \"Initializing camera...\";\n loadingIndicator.style.cssText = `\n color: white;\n font-size: 16px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n stopCamera(video);\n modal.remove();\n };\n\n captureButton.onclick = async () => {\n await callbacks.onCapture(video, canvas);\n };\n\n // Assemble the camera modal\n cameraContainer.appendChild(video);\n cameraContainer.appendChild(canvas);\n cameraContainer.appendChild(captureButton);\n cameraContainer.appendChild(closeButton);\n cameraContainer.appendChild(loadingIndicator);\n modal.appendChild(cameraContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Camera modal added to DOM\");\n\n // Start camera\n startCamera(video, loadingIndicator, captureButton);\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\n\n/**\n * Creates a loading overlay that can be shown in different containers\n */\nexport function createLoadingOverlay(\n text: string = \"Processing...\",\n): HTMLElement {\n const overlay = document.createElement(\"div\");\n overlay.className = \"ww-loading-overlay\";\n overlay.style.cssText = `\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.8);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL + 1};\n border-radius: inherit;\n `;\n\n // Add CSS animation to the document if not already added\n if (!document.getElementById(\"ww-loading-animation\")) {\n const style = document.createElement(\"style\");\n style.id = \"ww-loading-animation\";\n style.textContent = `\n @keyframes ww-pulse {\n 0%, 100% { opacity: 0.7; transform: scale(1); }\n 50% { opacity: 1; transform: scale(1.05); }\n }\n .ww-loading-overlay .ww-logo {\n animation: ww-pulse 2s ease-in-out infinite;\n }\n `;\n document.head.appendChild(style);\n }\n\n overlay.innerHTML = `\n <div style=\"display: flex; flex-direction: column; align-items: center; gap: 24px; color: white;\">\n <svg class=\"ww-logo\" width=\"80\" height=\"50\" viewBox=\"0 0 214 135\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <g clip-path=\"url(#clip0_3624_12755)\">\n <path d=\"M102.906 74.8679C102.906 77.9717 101.574 80.7453 98.9104 83.1887C96.6871 85.1918 93.9025 86.6997 90.5566 87.7123C87.695 88.5708 84.6462 89 81.4104 89C73.8821 89 68.0047 87.0189 63.7783 83.0566C59.5519 87.0189 53.6855 89 46.1792 89C42.9434 89 39.9057 88.5708 37.066 87.7123C33.7201 86.6997 30.9245 85.1918 28.6792 83.1887C26.0157 80.7453 24.684 77.9717 24.684 74.8679V41.6509H32.3774V74.8679C32.3774 76.2547 33.489 77.5645 35.7123 78.7972C37.3632 79.7217 39.0692 80.3711 40.8302 80.7453C42.5252 81.1195 44.3082 81.3066 46.1792 81.3066C48.0063 81.3066 49.7673 81.1195 51.4623 80.7453C53.2453 80.3711 54.9623 79.7217 56.6132 78.7972C58.8585 77.5645 59.9811 76.2547 59.9811 74.8679V41.6509H67.6085V74.8679C67.6085 76.2547 68.7311 77.5645 70.9764 78.7972C72.6274 79.7217 74.3443 80.3711 76.1274 80.7453C77.8223 81.1195 79.5833 81.3066 81.4104 81.3066C83.2814 81.3066 85.0755 81.1195 86.7925 80.7453C88.5314 80.3711 90.2264 79.7217 91.8774 78.7972C94.1006 77.5645 95.2123 76.2547 95.2123 74.8679V41.6509H102.906V74.8679ZM189.283 74.8679C189.283 77.9717 187.951 80.7453 185.288 83.1887C183.064 85.1918 180.28 86.6997 176.934 87.7123C174.072 88.5708 171.024 89 167.788 89C160.259 89 154.382 87.0189 150.156 83.0566C145.929 87.0189 140.063 89 132.557 89C129.321 89 126.283 88.5708 123.443 87.7123C120.097 86.6997 117.302 85.1918 115.057 83.1887C112.393 80.7453 111.061 77.9717 111.061 74.8679V41.6509H118.755V74.8679C118.755 76.2547 119.866 77.5645 122.09 78.7972C123.741 79.7217 125.447 80.3711 127.208 80.7453C128.903 81.1195 130.686 81.3066 132.557 81.3066C134.384 81.3066 136.145 81.1195 137.84 80.7453C139.623 80.3711 141.34 79.7217 142.991 78.7972C145.236 77.5645 146.358 76.2547 146.358 74.8679V41.6509H153.986V74.8679C153.986 76.2547 155.108 77.5645 157.354 78.7972C159.005 79.7217 160.722 80.3711 162.505 80.7453C164.2 81.1195 165.961 81.3066 167.788 81.3066C169.659 81.3066 171.453 81.1195 173.17 80.7453C174.909 80.3711 176.604 79.7217 178.255 78.7972C180.478 77.5645 181.59 76.2547 181.59 74.8679V41.6509H189.283V74.8679Z\" fill=\"white\"/>\n </g>\n <defs>\n <clipPath id=\"clip0_3624_12755\">\n <rect width=\"214\" height=\"135\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n <div style=\"font-size: 16px; font-weight: 500; text-align: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\">${text}</div>\n </div>\n `;\n\n return overlay;\n}\n\n/**\n * Shows a loading overlay in a modal container\n */\nexport function showModalLoading(text: string = \"Processing...\"): void {\n const modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\n if (!modal) return;\n\n // Remove any existing loading overlays\n removeModalLoading();\n\n const loadingOverlay = createLoadingOverlay(text);\n modal.appendChild(loadingOverlay);\n}\n\n/**\n * Removes loading overlay from modal\n */\nexport function removeModalLoading(): void {\n const modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\n if (!modal) return;\n\n const existingOverlay = modal.querySelector(\".ww-loading-overlay\");\n if (existingOverlay) {\n existingOverlay.remove();\n }\n}\n\n/**\n * Shows a loading overlay in the product gallery container\n */\nexport function showProductLoading(\n container: HTMLElement,\n text: string = \"Generating virtual try-on...\",\n): void {\n // Remove any existing loading overlays\n removeProductLoading(container);\n\n // Make container relative if it's not already positioned\n const computedStyle = window.getComputedStyle(container);\n if (computedStyle.position === \"static\") {\n container.style.position = \"relative\";\n }\n\n const loadingOverlay = createLoadingOverlay(text);\n container.appendChild(loadingOverlay);\n}\n\n/**\n * Removes loading overlay from product container\n */\nexport function removeProductLoading(container: HTMLElement): void {\n const existingOverlay = container.querySelector(\".ww-loading-overlay\");\n if (existingOverlay) {\n existingOverlay.remove();\n }\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { removeElements } from \"../utils.js\";\n\nexport interface ReviewModalCallbacks {\n onRetake: () => void;\n onAccept: (imageBlob: Blob) => Promise<void>;\n}\n\nexport function showReviewModal(\n imageBlob: Blob,\n callbacks: ReviewModalCallbacks,\n): void {\n console.log(\"[WeWear VTO] Opening review modal...\");\n\n // Remove any existing modals first\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Create image URL for preview\n const imageUrl = URL.createObjectURL(imageBlob);\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n gap: 20px;\n `;\n\n // Create review container\n const reviewContainer = document.createElement(\"div\");\n reviewContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 63vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create image element\n const image = document.createElement(\"img\");\n image.src = imageUrl;\n image.alt = \"Review your photo\";\n image.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create button container\n const buttonContainer = document.createElement(\"div\");\n buttonContainer.style.cssText = `\n display: flex;\n gap: 15px;\n width: 100%;\n max-width: 500px;\n `;\n\n // Create retake button\n const retakeButton = document.createElement(\"button\");\n retakeButton.textContent = \"Retake\";\n retakeButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: rgba(255, 255, 255, 0.9);\n color: black;\n border-radius: 8px;\n border: none;\n font-size: 16px;\n font-weight: normal;\n cursor: pointer;\n `;\n\n // Create use photo button\n const usePhotoButton = document.createElement(\"button\");\n usePhotoButton.textContent = \"Use Photo\";\n usePhotoButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n border-radius: 8px;\n border: none;\n font-size: 16px;\n font-weight: normal;\n cursor: pointer;\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n };\n\n retakeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n callbacks.onRetake();\n };\n\n usePhotoButton.onclick = async () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n await callbacks.onAccept(imageBlob);\n };\n\n // Assemble the review modal\n buttonContainer.appendChild(retakeButton);\n buttonContainer.appendChild(usePhotoButton);\n reviewContainer.appendChild(image);\n reviewContainer.appendChild(closeButton);\n modal.appendChild(reviewContainer);\n modal.appendChild(buttonContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Review modal added to DOM\");\n}\n","import { callVirtualTryOnApi } from \"./api.js\";\nimport { captureImageFromVideo, stopCamera } from \"./camera.js\";\nimport {\n type CameraModalCallbacks,\n createButton,\n createButtonContainer,\n type ReviewModalCallbacks,\n removeModalLoading,\n removeProductLoading,\n showCameraModal,\n showModalLoading,\n showProductLoading,\n showReviewModal,\n} from \"./components/index.js\";\nimport { CSS_CLASSES, DEFAULT_CONFIG } from \"./constants.js\";\nimport type { VirtualTryOnConfig } from \"./index.js\";\nimport { getCookie, removeElements } from \"./utils.js\";\n\nexport class VirtualTryOnWidget {\n private readonly config: Required<VirtualTryOnConfig>;\n private virtualTryOnImageUrl: string | null = null;\n private isShowingVirtualTryOn: boolean = false;\n private lastApiParams: {\n imageBlob: Blob;\n ww_access_token: string;\n ww_user_id: string;\n ww_product_id: string;\n } | null = null;\n\n constructor(config: VirtualTryOnConfig = {}) {\n this.config = {\n baseUrl: config.baseUrl || DEFAULT_CONFIG.BASE_URL,\n productPageSelector:\n config.productPageSelector || DEFAULT_CONFIG.PRODUCT_PAGE_SELECTOR,\n gallerySelector:\n config.gallerySelector || DEFAULT_CONFIG.GALLERY_SELECTOR,\n skuSelector: config.skuSelector || DEFAULT_CONFIG.SKU_SELECTOR,\n buttonPosition: config.buttonPosition || DEFAULT_CONFIG.BUTTON_POSITION,\n };\n }\n\n /**\n * Initializes the virtual try-on widget on the current page\n * @returns Promise that resolves when initialization is complete\n */\n public async init(): Promise<void> {\n try {\n // Check if we're on a product page\n if (!window.location.pathname.includes(this.config.productPageSelector)) {\n return;\n }\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Ensure container has relative positioning for button placement\n if (getComputedStyle(container).position === \"static\") {\n container.style.position = \"relative\";\n }\n\n // Create and add the virtual try-on button\n const button = createButton(this.config.buttonPosition, async () => {\n await this.handleTryOnClick();\n });\n\n container.appendChild(button);\n console.log(\"[WeWear VTO] Widget initialized successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization failed:\", error);\n }\n }\n\n /**\n * Handles virtual try-on button click\n * @private\n */\n private async handleTryOnClick(): Promise<void> {\n console.log(\"[WeWear VTO] Button clicked, starting try-on process...\");\n\n try {\n // Get required data\n const ww_access_token = getCookie(\"ww_access_token\");\n const ww_user_id = getCookie(\"ww_user_id\");\n const skuElement = document.querySelector(this.config.skuSelector);\n const ww_product_id = skuElement?.textContent?.trim();\n\n console.log(\"[WeWear VTO] Retrieved data:\", {\n ww_user_id,\n ww_product_id,\n ww_access_token,\n });\n\n // Validate required data\n if (!ww_user_id) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_user_id\");\n return;\n }\n\n if (!ww_product_id) {\n console.warn(\n \"[WeWear VTO] Product SKU not found:\",\n this.config.skuSelector,\n );\n return;\n }\n\n if (!ww_access_token) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_access_token\");\n return;\n }\n\n // Show camera capture modal\n this.showCameraModalWithCallbacks(\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Try-on request failed:\", error);\n }\n }\n\n /**\n * Shows camera modal with appropriate callbacks\n * @private\n */\n private showCameraModalWithCallbacks(\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ): void {\n const callbacks: CameraModalCallbacks = {\n onCapture: async (video: HTMLVideoElement, canvas: HTMLCanvasElement) => {\n try {\n // Capture image from video\n const imageBlob = await captureImageFromVideo(video, canvas);\n\n // Stop camera and show review modal\n stopCamera(video);\n\n // Show review modal instead of immediately processing\n this.showReviewModalWithCallbacks(\n imageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Image capture error:\", error);\n }\n },\n };\n\n showCameraModal(callbacks);\n }\n\n /**\n * Shows review modal with appropriate callbacks\n * @private\n */\n private showReviewModalWithCallbacks(\n imageBlob: Blob,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ): void {\n const callbacks: ReviewModalCallbacks = {\n onRetake: () => {\n // Reopen camera modal\n this.showCameraModalWithCallbacks(\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n },\n onAccept: async (acceptedImageBlob: Blob) => {\n await this.processAcceptedImage(\n acceptedImageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n },\n };\n\n showReviewModal(imageBlob, callbacks);\n }\n\n /**\n * Processes the accepted image by calling the API\n * @private\n */\n private async processAcceptedImage(\n imageBlob: Blob,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ): Promise<void> {\n try {\n console.log(\"[WeWear VTO] Processing accepted image...\");\n\n // Show loading in the review modal first\n showModalLoading(\"Processing image...\");\n\n // Store the API parameters for potential refresh\n this.lastApiParams = {\n imageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n };\n\n // Call the API with the accepted image\n const result = await callVirtualTryOnApi(\n this.config.baseUrl,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n imageBlob,\n );\n\n // Remove modal loading and close modal\n removeModalLoading();\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n if (result?.imageUrl) {\n this.replaceProductImage(result.imageUrl);\n } else {\n console.error(\"[WeWear VTO] Invalid API response:\", result);\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error processing accepted image:\", error);\n // Remove loading on error\n removeModalLoading();\n }\n }\n\n /**\n * Recalls the virtual try-on API with the same parameters\n * @private\n */\n private async refreshVirtualTryOn(): Promise<void> {\n if (!this.lastApiParams) {\n console.warn(\n \"[WeWear VTO] No previous API parameters available for refresh\",\n );\n return;\n }\n\n try {\n console.log(\n \"[WeWear VTO] Refreshing virtual try-on with previous parameters...\",\n );\n\n // Show loading in the product area\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n showProductLoading(container, \"Generating new virtual try-on...\");\n }\n\n // Call the API with the stored parameters\n const result = await callVirtualTryOnApi(\n this.config.baseUrl,\n this.lastApiParams.ww_access_token,\n this.lastApiParams.ww_user_id,\n this.lastApiParams.ww_product_id,\n this.lastApiParams.imageBlob,\n );\n\n if (result?.imageUrl) {\n this.virtualTryOnImageUrl = result.imageUrl;\n\n // Find the gallery container and update the image\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n this.showVirtualTryOnImage(container);\n this.updateButtonContainer(container);\n }\n } else {\n console.error(\"[WeWear VTO] Invalid API response on refresh:\", result);\n // Remove loading on error\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n }\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error refreshing virtual try-on:\", error);\n // Remove loading on error\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n }\n }\n }\n\n /**\n * Replaces the product image in the gallery with the virtual try-on result\n * @private\n */\n private replaceProductImage(imageUrl: string): void {\n try {\n // Store the virtual try-on image URL\n this.virtualTryOnImageUrl = imageUrl;\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found for image replacement:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Store the original content if not already stored\n if (!container.hasAttribute(\"data-ww-original-content\")) {\n container.setAttribute(\"data-ww-original-content\", container.innerHTML);\n }\n\n // Capture original image dimensions before replacement to prevent layout shift\n const originalImg = container.querySelector('img');\n if (originalImg && !container.hasAttribute(\"data-ww-original-dimensions\")) {\n const computedStyle = window.getComputedStyle(originalImg);\n const rect = originalImg.getBoundingClientRect();\n container.setAttribute(\"data-ww-original-width\", computedStyle.width);\n container.setAttribute(\"data-ww-original-height\", computedStyle.height);\n container.setAttribute(\"data-ww-original-rect-width\", rect.width.toString());\n container.setAttribute(\"data-ww-original-rect-height\", rect.height.toString());\n container.setAttribute(\"data-ww-original-dimensions\", \"true\");\n }\n\n // Show the virtual try-on image initially\n this.showVirtualTryOnImage(container);\n\n // Replace the button container with the new multi-button version\n this.updateButtonContainer(container);\n\n console.log(\n \"[WeWear VTO] Product image replaced with virtual try-on result\",\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Error replacing product image:\", error);\n }\n }\n\n /**\n * Updates the button container to show all available buttons\n * @private\n */\n private updateButtonContainer(container: HTMLElement): void {\n // Remove existing button containers\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n existingButtons.forEach((btn) => {\n btn.remove();\n });\n\n // Create new button container with all buttons\n const buttonContainer = createButtonContainer(\n this.config.buttonPosition,\n this.virtualTryOnImageUrl !== null,\n async () => {\n await this.handleTryOnClick();\n },\n async () => {\n await this.refreshVirtualTryOn();\n },\n () => {\n if (this.isShowingVirtualTryOn) {\n this.showOriginalImage(container);\n } else {\n this.showVirtualTryOnImage(container);\n }\n this.updateButtonContainer(container);\n },\n this.isShowingVirtualTryOn,\n );\n\n container.appendChild(buttonContainer);\n }\n\n /**\n * Shows the virtual try-on image in the container\n * @private\n */\n private showVirtualTryOnImage(container: HTMLElement): void {\n if (!this.virtualTryOnImageUrl) {\n console.warn(\"[WeWear VTO] No virtual try-on image URL available\");\n return;\n }\n\n // Clear existing content except buttons\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n container.innerHTML = \"\";\n\n // Get stored original dimensions to prevent layout shift\n const originalWidth = container.getAttribute(\"data-ww-original-width\") || '';\n const originalHeight = container.getAttribute(\"data-ww-original-height\") || '';\n const originalRectWidth = container.getAttribute(\"data-ww-original-rect-width\") || '';\n const originalRectHeight = container.getAttribute(\"data-ww-original-rect-height\") || '';\n\n const image = document.createElement(\"img\");\n image.src = this.virtualTryOnImageUrl;\n image.alt = \"Virtual Try-On Result\";\n\n // Use original dimensions to prevent layout shift\n let widthStyle = '100%';\n let heightStyle = '100%';\n\n // Prefer computed style dimensions, fallback to bounding rect, then container fill\n if (originalWidth && originalWidth !== 'auto' && originalWidth !== '0px') {\n widthStyle = originalWidth;\n } else if (originalRectWidth && originalRectWidth !== '0') {\n widthStyle = `${originalRectWidth}px`;\n }\n\n if (originalHeight && originalHeight !== 'auto' && originalHeight !== '0px') {\n heightStyle = originalHeight;\n } else if (originalRectHeight && originalRectHeight !== '0') {\n heightStyle = `${originalRectHeight}px`;\n }\n\n image.style.cssText = `\n width: ${widthStyle};\n height: ${heightStyle};\n object-fit: contain;\n border-radius: 8px;\n `;\n\n container.appendChild(image);\n\n // Re-add buttons\n existingButtons.forEach((btn) => {\n container.appendChild(btn);\n });\n\n this.isShowingVirtualTryOn = true;\n }\n\n /**\n * Shows the original product image in the container\n * @private\n */\n private showOriginalImage(container: HTMLElement): void {\n const originalContent = container.getAttribute(\"data-ww-original-content\");\n if (originalContent) {\n // Store existing buttons\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n\n // Restore original content\n container.innerHTML = originalContent;\n\n // Re-add buttons\n existingButtons.forEach((btn) => {\n container.appendChild(btn);\n });\n }\n\n this.isShowingVirtualTryOn = false;\n }\n\n /**\n * Destroys the widget and cleans up resources\n */\n public destroy(): void {\n try {\n // Remove all buttons\n removeElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);\n\n // Remove all modals\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Reset state\n this.virtualTryOnImageUrl = null;\n this.isShowingVirtualTryOn = false;\n this.lastApiParams = null;\n\n console.log(\"[WeWear VTO] Widget destroyed successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Error during widget destruction:\", error);\n }\n }\n}\n","import type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n try {\n // Clean up any existing instance\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n }\n\n // Create and initialize new instance\n widgetInstance = new VirtualTryOnWidget(config);\n\n // Initialize immediately if DOM is ready, otherwise wait for it\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n widgetInstance?.init().catch((error) => {\n console.error(\n \"[WeWear VTO] Failed to initialize after DOM ready:\",\n error,\n );\n });\n });\n } else {\n widgetInstance.init().catch((error) => {\n console.error(\"[WeWear VTO] Failed to initialize:\", error);\n });\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization error:\", error);\n }\n}\n\nexport function destroyVirtualTryOn(): void {\n try {\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n console.log(\"[WeWear VTO] Widget instance destroyed\");\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error destroying widget:\", error);\n }\n}\n\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n return widgetInstance;\n}\n\nif (typeof window !== \"undefined\") {\n initVirtualTryOn();\n}\n"],"names":[],"mappings":"AAEO,eAAe,mBAAmB,CACrC,OAAe,EACf,eAAuB,EACvB,UAAkB,EAClB,aAAqB,EACrB,QAAc,EAAA;AAEd,IAAA,IAAI;AACA,QAAA,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE;AAC/B,QAAA,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC;AACzC,QAAA,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,aAAa,CAAC;QAC/C,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,oBAAoB,CAAC;AAC3D,QAAA,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,eAAe,CAAC;QAEnD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,CAAA,EAAG,OAAO,qBAAqB,EAAE;AAC1D,YAAA,MAAM,EA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OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;IAC9D;AACJ;SAEgB,mBAAmB,GAAA;AAC/B,IAAA,IAAI;QACA,IAAI,cAAc,EAAE;YAChB,cAAc,CAAC,OAAO,EAAE;YACxB,cAAc,GAAG,IAAI;AACrB,YAAA,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC;QACzD;IACJ;IAAE,OAAO,KAAK,EAAE;AACZ,QAAA,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC;IACjE;AACJ;SAEgB,iBAAiB,GAAA;AAC7B,IAAA,OAAO,cAAc;AACzB;AAEA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAC/B,IAAA,gBAAgB,EAAE;AACtB;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/api.ts","../src/constants.ts","../src/camera.ts","../src/utils.ts","../src/components/button.ts","../src/components/camera-modal.ts","../src/components/loading-overlay.ts","../src/components/review-modal.ts","../src/widget.ts","../src/installer.ts"],"sourcesContent":["import type { VirtualTryOnResult } from \"./index.js\";\n\nexport async function callVirtualTryOnApi(\n baseUrl: string,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_image: string,\n ww_image: Blob,\n): Promise<VirtualTryOnResult | null> {\n try {\n const formData = new FormData();\n formData.append(\"ww_user_id\", ww_user_id);\n formData.append(\"ww_product_image\", ww_product_image);\n formData.append(\"ww_image\", ww_image, \"captured-image.jpg\");\n formData.append(\"ww_access_token\", ww_access_token);\n\n const response = await fetch(`${baseUrl}/api/virtual-try-on`, {\n method: \"POST\",\n body: formData,\n });\n\n if (!response.ok) {\n console.error(\n \"[WeWear VTO] API request failed:\",\n response.status,\n response.statusText,\n );\n return null;\n }\n\n const result = await response.json();\n console.log(\"[WeWear VTO] API response:\", result);\n return result;\n } catch (error) {\n console.error(\"[WeWear VTO] API call failed:\", error);\n return null;\n }\n}\n","/** Default configuration constants */\nexport const DEFAULT_CONFIG = {\n BASE_URL: \"https://virtual-try-on-widget.vercel.app\",\n PRODUCT_PAGE_SELECTOR: \"/product/\",\n GALLERY_SELECTOR: \".woocommerce-product-gallery__image\",\n PRODUCT_IMAGE_SELECTOR: \".woocommerce-product-gallery__image img\",\n BUTTON_POSITION: \"bottom-right\" as const,\n} as const;\n\n/** CSS class names for consistent styling */\nexport const CSS_CLASSES = {\n BUTTON_CONTAINER: \"wewear-vto-button-container\",\n BUTTON: \"wewear-vto-button\",\n MODAL: \"wewear-vto-modal\",\n} as const;\n\n/** Z-index values for proper layering */\nexport const Z_INDEX = {\n BUTTON: 10,\n MODAL: 99999,\n} as const;\n\n/** Camera constraints for optimal capture */\nexport const CAMERA_CONSTRAINTS = {\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: \"user\", // Front-facing camera\n },\n audio: false,\n} as const;\n\n/** Image capture settings */\nexport const IMAGE_SETTINGS = {\n FORMAT: \"image/jpeg\",\n QUALITY: 0.8,\n} as const;\n","import { CAMERA_CONSTRAINTS, IMAGE_SETTINGS } from \"./constants.js\";\n\nexport async function startCamera(\n video: HTMLVideoElement,\n loadingIndicator: HTMLElement,\n captureButton: HTMLButtonElement,\n): Promise<void> {\n console.log(\"[WeWear VTO] Starting camera...\");\n\n try {\n console.log(\"[WeWear VTO] Requesting camera access...\");\n const stream =\n await navigator.mediaDevices.getUserMedia(CAMERA_CONSTRAINTS);\n video.srcObject = stream;\n\n video.onloadedmetadata = () => {\n console.log(\"[WeWear VTO] Camera stream loaded successfully\");\n loadingIndicator.style.display = \"none\";\n captureButton.style.display = \"flex\";\n };\n } catch (error) {\n console.error(\"[WeWear VTO] Camera access error:\", error);\n loadingIndicator.innerHTML =\n \"Camera access denied. Please allow camera permissions.\";\n }\n}\n\nexport function stopCamera(video: HTMLVideoElement): void {\n const stream = video.srcObject as MediaStream;\n if (stream) {\n const tracks = stream.getTracks();\n tracks.forEach((track) => {\n track.stop();\n });\n video.srcObject = null;\n }\n}\n\nexport async function captureImageFromVideo(\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n): Promise<Blob> {\n // Set canvas dimensions to match video\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // Draw video frame to canvas\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) {\n throw new Error(\"Could not get canvas context\");\n }\n\n ctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n\n // Convert canvas to blob\n return new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n (blob) => {\n if (blob) {\n resolve(blob);\n } else {\n reject(new Error(\"Failed to create blob from canvas\"));\n }\n },\n IMAGE_SETTINGS.FORMAT,\n IMAGE_SETTINGS.QUALITY,\n );\n });\n}\n","export function getCookie(name: string): string | null {\n if (typeof document === \"undefined\") return null;\n\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n\n if (parts.length === 2) {\n const part = parts.pop();\n return part ? part.split(\";\").shift()?.trim() || null : null;\n }\n\n return null;\n}\n\nexport function getPositionStyles(position: string): string {\n switch (position) {\n case \"bottom-left\":\n return \"left: 20px; bottom: 20px;\";\n case \"top-right\":\n return \"right: 20px; top: 20px;\";\n case \"top-left\":\n return \"left: 20px; top: 20px;\";\n default:\n return \"right: 20px; bottom: 20px;\";\n }\n}\n\nexport function removeElements(selector: string): void {\n const elements = document.querySelectorAll(selector);\n elements.forEach((element) => {\n element.remove();\n });\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { getPositionStyles } from \"../utils.js\";\n\nexport function createButtonContainer(\n buttonPosition: string,\n hasVirtualTryOn: boolean = false,\n onCameraClick: () => void,\n onRefreshClick?: () => void,\n onToggleClick?: () => void,\n isShowingVirtualTryOn: boolean = false,\n): HTMLElement {\n const container = document.createElement(\"div\");\n container.className = `${CSS_CLASSES.BUTTON_CONTAINER} ww-button-group`;\n\n const positionStyles = getPositionStyles(buttonPosition);\n container.style.cssText = `\n position: absolute;\n ${positionStyles}\n display: flex;\n border-radius: 9999px;\n background: white;\n padding: 4px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n z-index: ${Z_INDEX.BUTTON};\n `;\n\n // Camera button\n const cameraButton = document.createElement(\"button\");\n cameraButton.type = \"button\";\n cameraButton.className = `${CSS_CLASSES.BUTTON} ww-camera-btn`;\n cameraButton.setAttribute(\"aria-label\", \"Virtual Try-On\");\n cameraButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: transparent;\n color: currentColor;\n `;\n\n cameraButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-camera\">\n <path d=\"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z\"></path>\n <circle cx=\"12\" cy=\"13\" r=\"3\"></circle>\n </svg>\n `;\n\n cameraButton.onclick = onCameraClick;\n container.appendChild(cameraButton);\n\n // Add refresh and toggle buttons if we have a virtual try-on\n if (hasVirtualTryOn) {\n // Refresh button - calls API again\n if (onRefreshClick) {\n const refreshButton = document.createElement(\"button\");\n refreshButton.type = \"button\";\n refreshButton.className = \"ww-refresh-btn\";\n refreshButton.setAttribute(\"aria-label\", \"Refresh virtual try-on\");\n refreshButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: transparent;\n color: currentColor;\n `;\n\n refreshButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-refresh-ccw\">\n <path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path>\n <path d=\"M3 3v5h5\"></path>\n <path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path>\n <path d=\"M16 16h5v5\"></path>\n </svg>\n `;\n\n refreshButton.onclick = onRefreshClick;\n container.appendChild(refreshButton);\n }\n\n // Toggle button (scan-face) - switches between original and virtual try-on\n if (onToggleClick) {\n const toggleButton = document.createElement(\"button\");\n toggleButton.type = \"button\";\n toggleButton.className = \"ww-toggle-btn\";\n toggleButton.setAttribute(\n \"aria-label\",\n isShowingVirtualTryOn ? \"Show Original Image\" : \"Show Virtual Try-On\",\n );\n toggleButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: ${isShowingVirtualTryOn ? \"rgba(0, 0, 0)\" : \"none\"};\n color: ${isShowingVirtualTryOn ? \"white\" : \"currentColor\"};\n `;\n\n toggleButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-scan-face\">\n <path d=\"M3 7V5a2 2 0 0 1 2-2h2\"></path>\n <path d=\"M17 3h2a2 2 0 0 1 2 2v2\"></path>\n <path d=\"M21 17v2a2 2 0 0 1-2 2h-2\"></path>\n <path d=\"M7 21H5a2 2 0 0 1-2-2v-2\"></path>\n <path d=\"M8 14s1.5 2 4 2 4-2 4-2\"></path>\n <path d=\"M9 9h.01\"></path>\n <path d=\"M15 9h.01\"></path>\n </svg>\n `;\n\n toggleButton.onclick = onToggleClick;\n container.appendChild(toggleButton);\n }\n }\n\n return container;\n}\n\nexport function createButton(\n buttonPosition: string,\n onClick: () => void,\n disabled: boolean = false,\n): HTMLElement {\n const container = createButtonContainer(buttonPosition, false, onClick);\n const cameraButton = container.querySelector('.ww-camera-btn') as HTMLButtonElement;\n if (cameraButton) {\n cameraButton.disabled = disabled;\n if (disabled) {\n cameraButton.style.opacity = '0.5';\n cameraButton.style.cursor = 'not-allowed';\n cameraButton.title = 'Find your ideal size first';\n }\n }\n return container;\n}\n","import { startCamera, stopCamera } from \"../camera.js\";\nimport { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { removeElements } from \"../utils.js\";\n\nexport interface CameraModalCallbacks {\n onCapture: (\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n ) => Promise<void>;\n}\n\nexport function showCameraModal(callbacks: CameraModalCallbacks): void {\n console.log(\"[WeWear VTO] Opening camera modal...\");\n\n // Remove any existing modals first\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create camera container\n const cameraContainer = document.createElement(\"div\");\n cameraContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 70vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create video element\n const video = document.createElement(\"video\");\n video.autoplay = true;\n video.playsInline = true;\n video.muted = true;\n video.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create canvas for capturing\n const canvas = document.createElement(\"canvas\");\n canvas.style.display = \"none\";\n\n // Create capture button\n const captureButton = document.createElement(\"button\");\n captureButton.innerHTML = \"\";\n captureButton.style.cssText = `\n position: absolute;\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n width: 60px;\n height: 60px;\n border: 3px solid white;\n background-color: rgba(0, 0, 0, 0.7);\n border-radius: 50%;\n cursor: pointer;\n display: none;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create loading indicator\n const loadingIndicator = document.createElement(\"div\");\n loadingIndicator.innerHTML = \"Initializing camera...\";\n loadingIndicator.style.cssText = `\n color: white;\n font-size: 16px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n stopCamera(video);\n modal.remove();\n };\n\n captureButton.onclick = async () => {\n await callbacks.onCapture(video, canvas);\n };\n\n // Assemble the camera modal\n cameraContainer.appendChild(video);\n cameraContainer.appendChild(canvas);\n cameraContainer.appendChild(captureButton);\n cameraContainer.appendChild(closeButton);\n cameraContainer.appendChild(loadingIndicator);\n modal.appendChild(cameraContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Camera modal added to DOM\");\n\n // Start camera\n startCamera(video, loadingIndicator, captureButton);\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\n\n/**\n * Creates a loading overlay that can be shown in different containers\n */\nexport function createLoadingOverlay(\n text: string = \"Processing...\",\n): HTMLElement {\n const overlay = document.createElement(\"div\");\n overlay.className = \"ww-loading-overlay\";\n overlay.style.cssText = `\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.8);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL + 1};\n border-radius: inherit;\n `;\n\n // Add CSS animation to the document if not already added\n if (!document.getElementById(\"ww-loading-animation\")) {\n const style = document.createElement(\"style\");\n style.id = \"ww-loading-animation\";\n style.textContent = `\n @keyframes ww-pulse {\n 0%, 100% { opacity: 0.7; transform: scale(1); }\n 50% { opacity: 1; transform: scale(1.05); }\n }\n .ww-loading-overlay .ww-logo {\n animation: ww-pulse 2s ease-in-out infinite;\n }\n `;\n document.head.appendChild(style);\n }\n\n overlay.innerHTML = `\n <div style=\"display: flex; flex-direction: column; align-items: center; gap: 24px; color: white;\">\n <svg class=\"ww-logo\" width=\"80\" height=\"50\" viewBox=\"0 0 214 135\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <g clip-path=\"url(#clip0_3624_12755)\">\n <path d=\"M102.906 74.8679C102.906 77.9717 101.574 80.7453 98.9104 83.1887C96.6871 85.1918 93.9025 86.6997 90.5566 87.7123C87.695 88.5708 84.6462 89 81.4104 89C73.8821 89 68.0047 87.0189 63.7783 83.0566C59.5519 87.0189 53.6855 89 46.1792 89C42.9434 89 39.9057 88.5708 37.066 87.7123C33.7201 86.6997 30.9245 85.1918 28.6792 83.1887C26.0157 80.7453 24.684 77.9717 24.684 74.8679V41.6509H32.3774V74.8679C32.3774 76.2547 33.489 77.5645 35.7123 78.7972C37.3632 79.7217 39.0692 80.3711 40.8302 80.7453C42.5252 81.1195 44.3082 81.3066 46.1792 81.3066C48.0063 81.3066 49.7673 81.1195 51.4623 80.7453C53.2453 80.3711 54.9623 79.7217 56.6132 78.7972C58.8585 77.5645 59.9811 76.2547 59.9811 74.8679V41.6509H67.6085V74.8679C67.6085 76.2547 68.7311 77.5645 70.9764 78.7972C72.6274 79.7217 74.3443 80.3711 76.1274 80.7453C77.8223 81.1195 79.5833 81.3066 81.4104 81.3066C83.2814 81.3066 85.0755 81.1195 86.7925 80.7453C88.5314 80.3711 90.2264 79.7217 91.8774 78.7972C94.1006 77.5645 95.2123 76.2547 95.2123 74.8679V41.6509H102.906V74.8679ZM189.283 74.8679C189.283 77.9717 187.951 80.7453 185.288 83.1887C183.064 85.1918 180.28 86.6997 176.934 87.7123C174.072 88.5708 171.024 89 167.788 89C160.259 89 154.382 87.0189 150.156 83.0566C145.929 87.0189 140.063 89 132.557 89C129.321 89 126.283 88.5708 123.443 87.7123C120.097 86.6997 117.302 85.1918 115.057 83.1887C112.393 80.7453 111.061 77.9717 111.061 74.8679V41.6509H118.755V74.8679C118.755 76.2547 119.866 77.5645 122.09 78.7972C123.741 79.7217 125.447 80.3711 127.208 80.7453C128.903 81.1195 130.686 81.3066 132.557 81.3066C134.384 81.3066 136.145 81.1195 137.84 80.7453C139.623 80.3711 141.34 79.7217 142.991 78.7972C145.236 77.5645 146.358 76.2547 146.358 74.8679V41.6509H153.986V74.8679C153.986 76.2547 155.108 77.5645 157.354 78.7972C159.005 79.7217 160.722 80.3711 162.505 80.7453C164.2 81.1195 165.961 81.3066 167.788 81.3066C169.659 81.3066 171.453 81.1195 173.17 80.7453C174.909 80.3711 176.604 79.7217 178.255 78.7972C180.478 77.5645 181.59 76.2547 181.59 74.8679V41.6509H189.283V74.8679Z\" fill=\"white\"/>\n </g>\n <defs>\n <clipPath id=\"clip0_3624_12755\">\n <rect width=\"214\" height=\"135\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n <div style=\"font-size: 16px; font-weight: 500; text-align: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\">${text}</div>\n </div>\n `;\n\n return overlay;\n}\n\n/**\n * Shows a loading overlay in a modal container\n */\nexport function showModalLoading(text: string = \"Processing...\"): void {\n const modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\n if (!modal) return;\n\n // Remove any existing loading overlays\n removeModalLoading();\n\n const loadingOverlay = createLoadingOverlay(text);\n modal.appendChild(loadingOverlay);\n}\n\n/**\n * Removes loading overlay from modal\n */\nexport function removeModalLoading(): void {\n const modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\n if (!modal) return;\n\n const existingOverlay = modal.querySelector(\".ww-loading-overlay\");\n if (existingOverlay) {\n existingOverlay.remove();\n }\n}\n\n/**\n * Shows a loading overlay in the product gallery container\n */\nexport function showProductLoading(\n container: HTMLElement,\n text: string = \"Generating virtual try-on...\",\n): void {\n // Remove any existing loading overlays\n removeProductLoading(container);\n\n // Make container relative if it's not already positioned\n const computedStyle = window.getComputedStyle(container);\n if (computedStyle.position === \"static\") {\n container.style.position = \"relative\";\n }\n\n const loadingOverlay = createLoadingOverlay(text);\n container.appendChild(loadingOverlay);\n}\n\n/**\n * Removes loading overlay from product container\n */\nexport function removeProductLoading(container: HTMLElement): void {\n const existingOverlay = container.querySelector(\".ww-loading-overlay\");\n if (existingOverlay) {\n existingOverlay.remove();\n }\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { removeElements } from \"../utils.js\";\n\nexport interface ReviewModalCallbacks {\n onRetake: () => void;\n onAccept: (imageBlob: Blob) => Promise<void>;\n}\n\nexport function showReviewModal(\n imageBlob: Blob,\n callbacks: ReviewModalCallbacks,\n): void {\n console.log(\"[WeWear VTO] Opening review modal...\");\n\n // Remove any existing modals first\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Create image URL for preview\n const imageUrl = URL.createObjectURL(imageBlob);\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n gap: 20px;\n `;\n\n // Create review container\n const reviewContainer = document.createElement(\"div\");\n reviewContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 63vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create image element\n const image = document.createElement(\"img\");\n image.src = imageUrl;\n image.alt = \"Review your photo\";\n image.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create button container\n const buttonContainer = document.createElement(\"div\");\n buttonContainer.style.cssText = `\n display: flex;\n gap: 15px;\n width: 100%;\n max-width: 500px;\n `;\n\n // Create retake button\n const retakeButton = document.createElement(\"button\");\n retakeButton.textContent = \"Retake\";\n retakeButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: rgba(255, 255, 255, 0.9);\n color: black;\n border-radius: 8px;\n border: none;\n font-size: 16px;\n font-weight: normal;\n cursor: pointer;\n `;\n\n // Create use photo button\n const usePhotoButton = document.createElement(\"button\");\n usePhotoButton.textContent = \"Use Photo\";\n usePhotoButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n border-radius: 8px;\n border: none;\n font-size: 16px;\n font-weight: normal;\n cursor: pointer;\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n };\n\n retakeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n callbacks.onRetake();\n };\n\n usePhotoButton.onclick = async () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n await callbacks.onAccept(imageBlob);\n };\n\n // Assemble the review modal\n buttonContainer.appendChild(retakeButton);\n buttonContainer.appendChild(usePhotoButton);\n reviewContainer.appendChild(image);\n reviewContainer.appendChild(closeButton);\n modal.appendChild(reviewContainer);\n modal.appendChild(buttonContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Review modal added to DOM\");\n}\n","import { callVirtualTryOnApi } from \"./api.js\";\nimport { captureImageFromVideo, stopCamera } from \"./camera.js\";\nimport {\n type CameraModalCallbacks,\n createButton,\n createButtonContainer,\n type ReviewModalCallbacks,\n removeModalLoading,\n removeProductLoading,\n showCameraModal,\n showModalLoading,\n showProductLoading,\n showReviewModal,\n} from \"./components/index.js\";\nimport { CSS_CLASSES, DEFAULT_CONFIG } from \"./constants.js\";\nimport type { VirtualTryOnConfig } from \"./index.js\";\nimport { getCookie, removeElements } from \"./utils.js\";\n\nexport class VirtualTryOnWidget {\n private readonly config: Required<VirtualTryOnConfig>;\n private virtualTryOnImageUrl: string | null = null;\n private isShowingVirtualTryOn: boolean = false;\n private lastApiParams: {\n imageBlob: Blob;\n ww_access_token: string;\n ww_user_id: string;\n ww_product_image: string;\n } | null = null;\n private cookieCheckInterval: number | null = null;\n private cameraButton: HTMLButtonElement | null = null;\n\n constructor(config: VirtualTryOnConfig = {}) {\n this.config = {\n baseUrl: config.baseUrl || DEFAULT_CONFIG.BASE_URL,\n productPageSelector:\n config.productPageSelector || DEFAULT_CONFIG.PRODUCT_PAGE_SELECTOR,\n gallerySelector:\n config.gallerySelector || DEFAULT_CONFIG.GALLERY_SELECTOR,\n productImageSelector: config.productImageSelector || DEFAULT_CONFIG.PRODUCT_IMAGE_SELECTOR,\n buttonPosition: config.buttonPosition || DEFAULT_CONFIG.BUTTON_POSITION,\n };\n }\n\n /**\n * Initializes the virtual try-on widget on the current page\n * @returns Promise that resolves when initialization is complete\n */\n public async init(): Promise<void> {\n try {\n // Check if we're on a product page\n if (!window.location.pathname.includes(this.config.productPageSelector)) {\n return;\n }\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Ensure container has relative positioning for button placement\n if (getComputedStyle(container).position === \"static\") {\n container.style.position = \"relative\";\n }\n\n // Check required cookies\n const ww_access_token = getCookie(\"ww_access_token\");\n const ww_user_id = getCookie(\"ww_user_id\");\n const cookiesPresent = !!ww_access_token && !!ww_user_id;\n\n // Create and add the virtual try-on button\n const button = createButton(this.config.buttonPosition, async () => {\n if (this.cameraButton && !this.cameraButton.disabled) {\n await this.handleTryOnClick();\n }\n }, !cookiesPresent);\n\n // Store reference to camera button for dynamic enable/disable\n this.cameraButton = button.querySelector('.ww-camera-btn');\n container.appendChild(button);\n console.log(\"[WeWear VTO] Widget initialized successfully\");\n\n // Periodically check cookies and update button state\n this.cookieCheckInterval = window.setInterval(() => {\n const accessToken = getCookie(\"ww_access_token\");\n const userId = getCookie(\"ww_user_id\");\n const present = !!accessToken && !!userId;\n if (this.cameraButton) {\n if (present && this.cameraButton.disabled) {\n this.cameraButton.disabled = false;\n this.cameraButton.style.opacity = '1';\n this.cameraButton.style.cursor = 'pointer';\n this.cameraButton.title = '';\n } else if (!present && !this.cameraButton.disabled) {\n this.cameraButton.disabled = true;\n this.cameraButton.style.opacity = '0.5';\n this.cameraButton.style.cursor = 'not-allowed';\n this.cameraButton.title = 'Required cookies missing';\n }\n }\n }, 2000); // check every 2 seconds\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization failed:\", error);\n }\n }\n\n /**\n * Handles virtual try-on button click\n * @private\n */\n private async handleTryOnClick(): Promise<void> {\n console.log(\"[WeWear VTO] Button clicked, starting try-on process...\");\n\n try {\n // Get required data\n const ww_access_token = getCookie(\"ww_access_token\");\n const ww_user_id = getCookie(\"ww_user_id\");\n const productImageElement = document.querySelector(this.config.productImageSelector) as HTMLImageElement;\n const ww_product_image = productImageElement?.src || productImageElement?.getAttribute('data-src') || '';\n\n console.log(\"[WeWear VTO] Retrieved data:\", {\n ww_user_id,\n ww_product_image,\n ww_access_token,\n });\n\n // Validate required data\n if (!ww_user_id) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_user_id\");\n return;\n }\n\n if (!ww_product_image) {\n console.warn(\n \"[WeWear VTO] Product image not found:\",\n this.config.productImageSelector,\n );\n return;\n }\n\n if (!ww_access_token) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_access_token\");\n return;\n }\n\n // Show camera capture modal\n this.showCameraModalWithCallbacks(\n ww_access_token,\n ww_user_id,\n ww_product_image,\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Try-on request failed:\", error);\n }\n }\n\n /**\n * Shows camera modal with appropriate callbacks\n * @private\n */\n private showCameraModalWithCallbacks(\n ww_access_token: string,\n ww_user_id: string,\n ww_product_image: string,\n ): void {\n const callbacks: CameraModalCallbacks = {\n onCapture: async (video: HTMLVideoElement, canvas: HTMLCanvasElement) => {\n try {\n // Capture image from video\n const imageBlob = await captureImageFromVideo(video, canvas);\n\n // Stop camera and show review modal\n stopCamera(video);\n\n // Show review modal instead of immediately processing\n this.showReviewModalWithCallbacks(\n imageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_image,\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Image capture error:\", error);\n }\n },\n };\n\n showCameraModal(callbacks);\n }\n\n /**\n * Shows review modal with appropriate callbacks\n * @private\n */\n private showReviewModalWithCallbacks(\n imageBlob: Blob,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_image: string,\n ): void {\n const callbacks: ReviewModalCallbacks = {\n onRetake: () => {\n // Reopen camera modal\n this.showCameraModalWithCallbacks(\n ww_access_token,\n ww_user_id,\n ww_product_image,\n );\n },\n onAccept: async (acceptedImageBlob: Blob) => {\n await this.processAcceptedImage(\n acceptedImageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_image,\n );\n },\n };\n\n showReviewModal(imageBlob, callbacks);\n }\n\n /**\n * Processes the accepted image by calling the API\n * @private\n */\n private async processAcceptedImage(\n imageBlob: Blob,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_image: string,\n ): Promise<void> {\n try {\n console.log(\"[WeWear VTO] Processing accepted image...\");\n\n // Show loading in the review modal first\n showModalLoading(\"Processing image...\");\n\n // Store the API parameters for potential refresh\n this.lastApiParams = {\n imageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_image,\n };\n\n // Call the API with the accepted image\n const result = await callVirtualTryOnApi(\n this.config.baseUrl,\n ww_access_token,\n ww_user_id,\n ww_product_image,\n imageBlob,\n );\n\n // Remove modal loading and close modal\n removeModalLoading();\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n if (result?.imageUrl) {\n this.replaceProductImage(result.imageUrl);\n } else {\n console.error(\"[WeWear VTO] Invalid API response:\", result);\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error processing accepted image:\", error);\n // Remove loading on error\n removeModalLoading();\n }\n }\n\n /**\n * Recalls the virtual try-on API with the same parameters\n * @private\n */\n private async refreshVirtualTryOn(): Promise<void> {\n if (!this.lastApiParams) {\n console.warn(\n \"[WeWear VTO] No previous API parameters available for refresh\",\n );\n return;\n }\n\n try {\n console.log(\n \"[WeWear VTO] Refreshing virtual try-on with previous parameters...\",\n );\n\n // Show loading in the product area\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n showProductLoading(container, \"Generating new virtual try-on...\");\n }\n\n // Call the API with the stored parameters\n const result = await callVirtualTryOnApi(\n this.config.baseUrl,\n this.lastApiParams.ww_access_token,\n this.lastApiParams.ww_user_id,\n this.lastApiParams.ww_product_image,\n this.lastApiParams.imageBlob,\n );\n\n if (result?.imageUrl) {\n this.virtualTryOnImageUrl = result.imageUrl;\n\n // Find the gallery container and update the image\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n this.showVirtualTryOnImage(container);\n this.updateButtonContainer(container);\n }\n } else {\n console.error(\"[WeWear VTO] Invalid API response on refresh:\", result);\n // Remove loading on error\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n }\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error refreshing virtual try-on:\", error);\n // Remove loading on error\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n }\n }\n }\n\n /**\n * Replaces the product image in the gallery with the virtual try-on result\n * @private\n */\n private replaceProductImage(imageUrl: string): void {\n try {\n // Store the virtual try-on image URL\n this.virtualTryOnImageUrl = imageUrl;\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found for image replacement:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Store the original content if not already stored\n if (!container.hasAttribute(\"data-ww-original-content\")) {\n container.setAttribute(\"data-ww-original-content\", container.innerHTML);\n }\n\n // Capture original image dimensions before replacement to prevent layout shift\n const originalImg = container.querySelector('img');\n if (originalImg && !container.hasAttribute(\"data-ww-original-dimensions\")) {\n const computedStyle = window.getComputedStyle(originalImg);\n const rect = originalImg.getBoundingClientRect();\n container.setAttribute(\"data-ww-original-width\", computedStyle.width);\n container.setAttribute(\"data-ww-original-height\", computedStyle.height);\n container.setAttribute(\"data-ww-original-rect-width\", rect.width.toString());\n container.setAttribute(\"data-ww-original-rect-height\", rect.height.toString());\n container.setAttribute(\"data-ww-original-dimensions\", \"true\");\n }\n\n // Show the virtual try-on image initially\n this.showVirtualTryOnImage(container);\n\n // Replace the button container with the new multi-button version\n this.updateButtonContainer(container);\n\n console.log(\n \"[WeWear VTO] Product image replaced with virtual try-on result\",\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Error replacing product image:\", error);\n }\n }\n\n /**\n * Updates the button container to show all available buttons\n * @private\n */\n private updateButtonContainer(container: HTMLElement): void {\n // Remove existing button containers\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n existingButtons.forEach((btn) => {\n btn.remove();\n });\n\n // Create new button container with all buttons\n const buttonContainer = createButtonContainer(\n this.config.buttonPosition,\n this.virtualTryOnImageUrl !== null,\n async () => {\n await this.handleTryOnClick();\n },\n async () => {\n await this.refreshVirtualTryOn();\n },\n () => {\n if (this.isShowingVirtualTryOn) {\n this.showOriginalImage(container);\n } else {\n this.showVirtualTryOnImage(container);\n }\n this.updateButtonContainer(container);\n },\n this.isShowingVirtualTryOn,\n );\n\n container.appendChild(buttonContainer);\n }\n\n /**\n * Shows the virtual try-on image in the container\n * @private\n */\n private showVirtualTryOnImage(container: HTMLElement): void {\n if (!this.virtualTryOnImageUrl) {\n console.warn(\"[WeWear VTO] No virtual try-on image URL available\");\n return;\n }\n\n // Clear existing content except buttons\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n container.innerHTML = \"\";\n\n // Get stored original dimensions to prevent layout shift\n const originalWidth = container.getAttribute(\"data-ww-original-width\") || '';\n const originalHeight = container.getAttribute(\"data-ww-original-height\") || '';\n const originalRectWidth = container.getAttribute(\"data-ww-original-rect-width\") || '';\n const originalRectHeight = container.getAttribute(\"data-ww-original-rect-height\") || '';\n\n const image = document.createElement(\"img\");\n image.src = this.virtualTryOnImageUrl;\n image.alt = \"Virtual Try-On Result\";\n\n // Use original dimensions to prevent layout shift\n let widthStyle = '100%';\n let heightStyle = '100%';\n\n // Prefer computed style dimensions, fallback to bounding rect, then container fill\n if (originalWidth && originalWidth !== 'auto' && originalWidth !== '0px') {\n widthStyle = originalWidth;\n } else if (originalRectWidth && originalRectWidth !== '0') {\n widthStyle = `${originalRectWidth}px`;\n }\n\n if (originalHeight && originalHeight !== 'auto' && originalHeight !== '0px') {\n heightStyle = originalHeight;\n } else if (originalRectHeight && originalRectHeight !== '0') {\n heightStyle = `${originalRectHeight}px`;\n }\n\n image.style.cssText = `\n width: ${widthStyle};\n height: ${heightStyle};\n object-fit: cover;\n border-radius: 8px;\n `;\n\n container.appendChild(image);\n\n // Re-add buttons\n existingButtons.forEach((btn) => {\n container.appendChild(btn);\n });\n\n this.isShowingVirtualTryOn = true;\n }\n\n /**\n * Shows the original product image in the container\n * @private\n */\n private showOriginalImage(container: HTMLElement): void {\n const originalContent = container.getAttribute(\"data-ww-original-content\");\n if (originalContent) {\n // Store existing buttons\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n\n // Restore original content\n container.innerHTML = originalContent;\n\n // Re-add buttons\n existingButtons.forEach((btn) => {\n container.appendChild(btn);\n });\n }\n\n this.isShowingVirtualTryOn = false;\n }\n\n /**\n * Destroys the widget and cleans up resources\n */\n public destroy(): void {\n try {\n // Remove all buttons\n removeElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);\n\n // Remove all modals\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Clear interval\n if (this.cookieCheckInterval !== null) {\n clearInterval(this.cookieCheckInterval);\n this.cookieCheckInterval = null;\n }\n this.cameraButton = null;\n\n // Reset state\n this.virtualTryOnImageUrl = null;\n this.isShowingVirtualTryOn = false;\n this.lastApiParams = null;\n\n console.log(\"[WeWear VTO] Widget destroyed successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Error during widget destruction:\", error);\n }\n }\n}\n","import type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n try {\n // Clean up any existing instance\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n }\n\n // Create and initialize new instance\n widgetInstance = new VirtualTryOnWidget(config);\n\n // Initialize immediately if DOM is ready, otherwise wait for it\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n widgetInstance?.init().catch((error) => {\n console.error(\n \"[WeWear VTO] Failed to initialize after DOM ready:\",\n error,\n );\n });\n });\n } else {\n widgetInstance.init().catch((error) => {\n console.error(\"[WeWear VTO] Failed to initialize:\", error);\n });\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization error:\", error);\n }\n}\n\nexport function destroyVirtualTryOn(): void {\n try {\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n console.log(\"[WeWear VTO] Widget instance destroyed\");\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error destroying widget:\", error);\n }\n}\n\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n return widgetInstance;\n}\n\nif (typeof window !== \"undefined\") {\n initVirtualTryOn();\n}\n"],"names":[],"mappings":"AAEO,eAAe,mBAAmB,CACrC,OAAe,EACf,eAAuB,EACvB,UAAkB,EAClB,gBAAwB,EACxB,QAAc,EAAA;AAEd,IAAA,IAAI;AACA,QAAA,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE;AAC/B,QAAA,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC;AACzC,QAAA,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;QACrD,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,oBAAoB,CAAC;AAC3D,QAAA,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,eAAe,CAAC;QAEnD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,CAAA,EAAG,OAAO,qBAAqB,EAAE;AAC1D,YAAA,MAAM,EAAE,MAAM;AACd,YAAA,IAAI,EAAE,QAAQ;AACjB,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;AACd,YAAA,OAAO,CAAC,KAAK,CACT,kCAAkC,EAClC,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,UAAU,CACtB;AACD,YAAA,OAAO,IAAI;QACf;AAEA,QAAA,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE;AACpC,QAAA,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,MAAM,CAAC;AACjD,QAAA,O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AA,cAAc,KAAA,IAAA,IAAd,cAAc,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAd,cAAc,CAAE,IAAI,EAAA,CAAG,KAAK,CAAC,CAAC,KAAK,KAAI;AACnC,oBAAA,OAAO,CAAC,KAAK,CACT,oDAAoD,EACpD,KAAK,CACR;AACL,gBAAA,CAAC,CAAC;AACN,YAAA,CAAC,CAAC;QACN;aAAO;YACH,cAAc,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;AAClC,gBAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;AAC9D,YAAA,CAAC,CAAC;QACN;IACJ;IAAE,OAAO,KAAK,EAAE;AACZ,QAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;IAC9D;AACJ;SAEgB,mBAAmB,GAAA;AAC/B,IAAA,IAAI;QACA,IAAI,cAAc,EAAE;YAChB,cAAc,CAAC,OAAO,EAAE;YACxB,cAAc,GAAG,IAAI;AACrB,YAAA,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC;QACzD;IACJ;IAAE,OAAO,KAAK,EAAE;AACZ,QAAA,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC;IACjE;AACJ;SAEgB,iBAAiB,GAAA;AAC7B,IAAA,OAAO,cAAc;AACzB;AAEA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAC/B,IAAA,gBAAgB,EAAE;AACtB;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.WeWearVirtualTryOn = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
async function callVirtualTryOnApi(baseUrl, ww_access_token, ww_user_id,
|
|
7
|
+
async function callVirtualTryOnApi(baseUrl, ww_access_token, ww_user_id, ww_product_image, ww_image) {
|
|
8
8
|
try {
|
|
9
9
|
const formData = new FormData();
|
|
10
10
|
formData.append("ww_user_id", ww_user_id);
|
|
11
|
-
formData.append("
|
|
11
|
+
formData.append("ww_product_image", ww_product_image);
|
|
12
12
|
formData.append("ww_image", ww_image, "captured-image.jpg");
|
|
13
13
|
formData.append("ww_access_token", ww_access_token);
|
|
14
14
|
const response = await fetch(`${baseUrl}/api/virtual-try-on`, {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
BASE_URL: "https://virtual-try-on-widget.vercel.app",
|
|
35
35
|
PRODUCT_PAGE_SELECTOR: "/product/",
|
|
36
36
|
GALLERY_SELECTOR: ".woocommerce-product-gallery__image",
|
|
37
|
-
|
|
37
|
+
PRODUCT_IMAGE_SELECTOR: ".woocommerce-product-gallery__image img",
|
|
38
38
|
BUTTON_POSITION: "bottom-right",
|
|
39
39
|
};
|
|
40
40
|
/** CSS class names for consistent styling */
|
|
@@ -253,8 +253,18 @@
|
|
|
253
253
|
}
|
|
254
254
|
return container;
|
|
255
255
|
}
|
|
256
|
-
function createButton(buttonPosition, onClick) {
|
|
257
|
-
|
|
256
|
+
function createButton(buttonPosition, onClick, disabled = false) {
|
|
257
|
+
const container = createButtonContainer(buttonPosition, false, onClick);
|
|
258
|
+
const cameraButton = container.querySelector('.ww-camera-btn');
|
|
259
|
+
if (cameraButton) {
|
|
260
|
+
cameraButton.disabled = disabled;
|
|
261
|
+
if (disabled) {
|
|
262
|
+
cameraButton.style.opacity = '0.5';
|
|
263
|
+
cameraButton.style.cursor = 'not-allowed';
|
|
264
|
+
cameraButton.title = 'Find your ideal size first';
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return container;
|
|
258
268
|
}
|
|
259
269
|
|
|
260
270
|
function showCameraModal(callbacks) {
|
|
@@ -616,11 +626,13 @@
|
|
|
616
626
|
this.virtualTryOnImageUrl = null;
|
|
617
627
|
this.isShowingVirtualTryOn = false;
|
|
618
628
|
this.lastApiParams = null;
|
|
629
|
+
this.cookieCheckInterval = null;
|
|
630
|
+
this.cameraButton = null;
|
|
619
631
|
this.config = {
|
|
620
632
|
baseUrl: config.baseUrl || DEFAULT_CONFIG.BASE_URL,
|
|
621
633
|
productPageSelector: config.productPageSelector || DEFAULT_CONFIG.PRODUCT_PAGE_SELECTOR,
|
|
622
634
|
gallerySelector: config.gallerySelector || DEFAULT_CONFIG.GALLERY_SELECTOR,
|
|
623
|
-
|
|
635
|
+
productImageSelector: config.productImageSelector || DEFAULT_CONFIG.PRODUCT_IMAGE_SELECTOR,
|
|
624
636
|
buttonPosition: config.buttonPosition || DEFAULT_CONFIG.BUTTON_POSITION,
|
|
625
637
|
};
|
|
626
638
|
}
|
|
@@ -644,12 +656,40 @@
|
|
|
644
656
|
if (getComputedStyle(container).position === "static") {
|
|
645
657
|
container.style.position = "relative";
|
|
646
658
|
}
|
|
659
|
+
// Check required cookies
|
|
660
|
+
const ww_access_token = getCookie("ww_access_token");
|
|
661
|
+
const ww_user_id = getCookie("ww_user_id");
|
|
662
|
+
const cookiesPresent = !!ww_access_token && !!ww_user_id;
|
|
647
663
|
// Create and add the virtual try-on button
|
|
648
664
|
const button = createButton(this.config.buttonPosition, async () => {
|
|
649
|
-
|
|
650
|
-
|
|
665
|
+
if (this.cameraButton && !this.cameraButton.disabled) {
|
|
666
|
+
await this.handleTryOnClick();
|
|
667
|
+
}
|
|
668
|
+
}, !cookiesPresent);
|
|
669
|
+
// Store reference to camera button for dynamic enable/disable
|
|
670
|
+
this.cameraButton = button.querySelector('.ww-camera-btn');
|
|
651
671
|
container.appendChild(button);
|
|
652
672
|
console.log("[WeWear VTO] Widget initialized successfully");
|
|
673
|
+
// Periodically check cookies and update button state
|
|
674
|
+
this.cookieCheckInterval = window.setInterval(() => {
|
|
675
|
+
const accessToken = getCookie("ww_access_token");
|
|
676
|
+
const userId = getCookie("ww_user_id");
|
|
677
|
+
const present = !!accessToken && !!userId;
|
|
678
|
+
if (this.cameraButton) {
|
|
679
|
+
if (present && this.cameraButton.disabled) {
|
|
680
|
+
this.cameraButton.disabled = false;
|
|
681
|
+
this.cameraButton.style.opacity = '1';
|
|
682
|
+
this.cameraButton.style.cursor = 'pointer';
|
|
683
|
+
this.cameraButton.title = '';
|
|
684
|
+
}
|
|
685
|
+
else if (!present && !this.cameraButton.disabled) {
|
|
686
|
+
this.cameraButton.disabled = true;
|
|
687
|
+
this.cameraButton.style.opacity = '0.5';
|
|
688
|
+
this.cameraButton.style.cursor = 'not-allowed';
|
|
689
|
+
this.cameraButton.title = 'Required cookies missing';
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}, 2000); // check every 2 seconds
|
|
653
693
|
}
|
|
654
694
|
catch (error) {
|
|
655
695
|
console.error("[WeWear VTO] Initialization failed:", error);
|
|
@@ -660,17 +700,16 @@
|
|
|
660
700
|
* @private
|
|
661
701
|
*/
|
|
662
702
|
async handleTryOnClick() {
|
|
663
|
-
var _a;
|
|
664
703
|
console.log("[WeWear VTO] Button clicked, starting try-on process...");
|
|
665
704
|
try {
|
|
666
705
|
// Get required data
|
|
667
706
|
const ww_access_token = getCookie("ww_access_token");
|
|
668
707
|
const ww_user_id = getCookie("ww_user_id");
|
|
669
|
-
const
|
|
670
|
-
const
|
|
708
|
+
const productImageElement = document.querySelector(this.config.productImageSelector);
|
|
709
|
+
const ww_product_image = (productImageElement === null || productImageElement === void 0 ? void 0 : productImageElement.src) || (productImageElement === null || productImageElement === void 0 ? void 0 : productImageElement.getAttribute('data-src')) || '';
|
|
671
710
|
console.log("[WeWear VTO] Retrieved data:", {
|
|
672
711
|
ww_user_id,
|
|
673
|
-
|
|
712
|
+
ww_product_image,
|
|
674
713
|
ww_access_token,
|
|
675
714
|
});
|
|
676
715
|
// Validate required data
|
|
@@ -678,8 +717,8 @@
|
|
|
678
717
|
console.warn("[WeWear VTO] Missing required cookie: ww_user_id");
|
|
679
718
|
return;
|
|
680
719
|
}
|
|
681
|
-
if (!
|
|
682
|
-
console.warn("[WeWear VTO] Product
|
|
720
|
+
if (!ww_product_image) {
|
|
721
|
+
console.warn("[WeWear VTO] Product image not found:", this.config.productImageSelector);
|
|
683
722
|
return;
|
|
684
723
|
}
|
|
685
724
|
if (!ww_access_token) {
|
|
@@ -687,7 +726,7 @@
|
|
|
687
726
|
return;
|
|
688
727
|
}
|
|
689
728
|
// Show camera capture modal
|
|
690
|
-
this.showCameraModalWithCallbacks(ww_access_token, ww_user_id,
|
|
729
|
+
this.showCameraModalWithCallbacks(ww_access_token, ww_user_id, ww_product_image);
|
|
691
730
|
}
|
|
692
731
|
catch (error) {
|
|
693
732
|
console.error("[WeWear VTO] Try-on request failed:", error);
|
|
@@ -697,7 +736,7 @@
|
|
|
697
736
|
* Shows camera modal with appropriate callbacks
|
|
698
737
|
* @private
|
|
699
738
|
*/
|
|
700
|
-
showCameraModalWithCallbacks(ww_access_token, ww_user_id,
|
|
739
|
+
showCameraModalWithCallbacks(ww_access_token, ww_user_id, ww_product_image) {
|
|
701
740
|
const callbacks = {
|
|
702
741
|
onCapture: async (video, canvas) => {
|
|
703
742
|
try {
|
|
@@ -706,7 +745,7 @@
|
|
|
706
745
|
// Stop camera and show review modal
|
|
707
746
|
stopCamera(video);
|
|
708
747
|
// Show review modal instead of immediately processing
|
|
709
|
-
this.showReviewModalWithCallbacks(imageBlob, ww_access_token, ww_user_id,
|
|
748
|
+
this.showReviewModalWithCallbacks(imageBlob, ww_access_token, ww_user_id, ww_product_image);
|
|
710
749
|
}
|
|
711
750
|
catch (error) {
|
|
712
751
|
console.error("[WeWear VTO] Image capture error:", error);
|
|
@@ -719,14 +758,14 @@
|
|
|
719
758
|
* Shows review modal with appropriate callbacks
|
|
720
759
|
* @private
|
|
721
760
|
*/
|
|
722
|
-
showReviewModalWithCallbacks(imageBlob, ww_access_token, ww_user_id,
|
|
761
|
+
showReviewModalWithCallbacks(imageBlob, ww_access_token, ww_user_id, ww_product_image) {
|
|
723
762
|
const callbacks = {
|
|
724
763
|
onRetake: () => {
|
|
725
764
|
// Reopen camera modal
|
|
726
|
-
this.showCameraModalWithCallbacks(ww_access_token, ww_user_id,
|
|
765
|
+
this.showCameraModalWithCallbacks(ww_access_token, ww_user_id, ww_product_image);
|
|
727
766
|
},
|
|
728
767
|
onAccept: async (acceptedImageBlob) => {
|
|
729
|
-
await this.processAcceptedImage(acceptedImageBlob, ww_access_token, ww_user_id,
|
|
768
|
+
await this.processAcceptedImage(acceptedImageBlob, ww_access_token, ww_user_id, ww_product_image);
|
|
730
769
|
},
|
|
731
770
|
};
|
|
732
771
|
showReviewModal(imageBlob, callbacks);
|
|
@@ -735,7 +774,7 @@
|
|
|
735
774
|
* Processes the accepted image by calling the API
|
|
736
775
|
* @private
|
|
737
776
|
*/
|
|
738
|
-
async processAcceptedImage(imageBlob, ww_access_token, ww_user_id,
|
|
777
|
+
async processAcceptedImage(imageBlob, ww_access_token, ww_user_id, ww_product_image) {
|
|
739
778
|
try {
|
|
740
779
|
console.log("[WeWear VTO] Processing accepted image...");
|
|
741
780
|
// Show loading in the review modal first
|
|
@@ -745,10 +784,10 @@
|
|
|
745
784
|
imageBlob,
|
|
746
785
|
ww_access_token,
|
|
747
786
|
ww_user_id,
|
|
748
|
-
|
|
787
|
+
ww_product_image,
|
|
749
788
|
};
|
|
750
789
|
// Call the API with the accepted image
|
|
751
|
-
const result = await callVirtualTryOnApi(this.config.baseUrl, ww_access_token, ww_user_id,
|
|
790
|
+
const result = await callVirtualTryOnApi(this.config.baseUrl, ww_access_token, ww_user_id, ww_product_image, imageBlob);
|
|
752
791
|
// Remove modal loading and close modal
|
|
753
792
|
removeModalLoading();
|
|
754
793
|
removeElements(`.${CSS_CLASSES.MODAL}`);
|
|
@@ -782,7 +821,7 @@
|
|
|
782
821
|
showProductLoading(container, "Generating new virtual try-on...");
|
|
783
822
|
}
|
|
784
823
|
// Call the API with the stored parameters
|
|
785
|
-
const result = await callVirtualTryOnApi(this.config.baseUrl, this.lastApiParams.ww_access_token, this.lastApiParams.ww_user_id, this.lastApiParams.
|
|
824
|
+
const result = await callVirtualTryOnApi(this.config.baseUrl, this.lastApiParams.ww_access_token, this.lastApiParams.ww_user_id, this.lastApiParams.ww_product_image, this.lastApiParams.imageBlob);
|
|
786
825
|
if (result === null || result === void 0 ? void 0 : result.imageUrl) {
|
|
787
826
|
this.virtualTryOnImageUrl = result.imageUrl;
|
|
788
827
|
// Find the gallery container and update the image
|
|
@@ -915,7 +954,7 @@
|
|
|
915
954
|
image.style.cssText = `
|
|
916
955
|
width: ${widthStyle};
|
|
917
956
|
height: ${heightStyle};
|
|
918
|
-
object-fit:
|
|
957
|
+
object-fit: cover;
|
|
919
958
|
border-radius: 8px;
|
|
920
959
|
`;
|
|
921
960
|
container.appendChild(image);
|
|
@@ -952,6 +991,12 @@
|
|
|
952
991
|
removeElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);
|
|
953
992
|
// Remove all modals
|
|
954
993
|
removeElements(`.${CSS_CLASSES.MODAL}`);
|
|
994
|
+
// Clear interval
|
|
995
|
+
if (this.cookieCheckInterval !== null) {
|
|
996
|
+
clearInterval(this.cookieCheckInterval);
|
|
997
|
+
this.cookieCheckInterval = null;
|
|
998
|
+
}
|
|
999
|
+
this.cameraButton = null;
|
|
955
1000
|
// Reset state
|
|
956
1001
|
this.virtualTryOnImageUrl = null;
|
|
957
1002
|
this.isShowingVirtualTryOn = false;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/api.ts","../src/constants.ts","../src/camera.ts","../src/utils.ts","../src/components/button.ts","../src/components/camera-modal.ts","../src/components/loading-overlay.ts","../src/components/review-modal.ts","../src/widget.ts","../src/installer.ts"],"sourcesContent":["import type { VirtualTryOnResult } from \"./index.js\";\n\nexport async function callVirtualTryOnApi(\n baseUrl: string,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ww_image: Blob,\n): Promise<VirtualTryOnResult | null> {\n try {\n const formData = new FormData();\n formData.append(\"ww_user_id\", ww_user_id);\n formData.append(\"ww_product_id\", ww_product_id);\n formData.append(\"ww_image\", ww_image, \"captured-image.jpg\");\n formData.append(\"ww_access_token\", ww_access_token);\n\n const response = await fetch(`${baseUrl}/api/virtual-try-on`, {\n method: \"POST\",\n body: formData,\n });\n\n if (!response.ok) {\n console.error(\n \"[WeWear VTO] API request failed:\",\n response.status,\n response.statusText,\n );\n return null;\n }\n\n const result = await response.json();\n console.log(\"[WeWear VTO] API response:\", result);\n return result;\n } catch (error) {\n console.error(\"[WeWear VTO] API call failed:\", error);\n return null;\n }\n}\n","/** Default configuration constants */\nexport const DEFAULT_CONFIG = {\n BASE_URL: \"https://virtual-try-on-widget.vercel.app\",\n PRODUCT_PAGE_SELECTOR: \"/product/\",\n GALLERY_SELECTOR: \".woocommerce-product-gallery__image\",\n SKU_SELECTOR: \".sku\",\n BUTTON_POSITION: \"bottom-right\" as const,\n} as const;\n\n/** CSS class names for consistent styling */\nexport const CSS_CLASSES = {\n BUTTON_CONTAINER: \"wewear-vto-button-container\",\n BUTTON: \"wewear-vto-button\",\n MODAL: \"wewear-vto-modal\",\n} as const;\n\n/** Z-index values for proper layering */\nexport const Z_INDEX = {\n BUTTON: 10,\n MODAL: 99999,\n} as const;\n\n/** Camera constraints for optimal capture */\nexport const CAMERA_CONSTRAINTS = {\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: \"user\", // Front-facing camera\n },\n audio: false,\n} as const;\n\n/** Image capture settings */\nexport const IMAGE_SETTINGS = {\n FORMAT: \"image/jpeg\",\n QUALITY: 0.8,\n} as const;\n","import { CAMERA_CONSTRAINTS, IMAGE_SETTINGS } from \"./constants.js\";\n\nexport async function startCamera(\n video: HTMLVideoElement,\n loadingIndicator: HTMLElement,\n captureButton: HTMLButtonElement,\n): Promise<void> {\n console.log(\"[WeWear VTO] Starting camera...\");\n\n try {\n console.log(\"[WeWear VTO] Requesting camera access...\");\n const stream =\n await navigator.mediaDevices.getUserMedia(CAMERA_CONSTRAINTS);\n video.srcObject = stream;\n\n video.onloadedmetadata = () => {\n console.log(\"[WeWear VTO] Camera stream loaded successfully\");\n loadingIndicator.style.display = \"none\";\n captureButton.style.display = \"flex\";\n };\n } catch (error) {\n console.error(\"[WeWear VTO] Camera access error:\", error);\n loadingIndicator.innerHTML =\n \"Camera access denied. Please allow camera permissions.\";\n }\n}\n\nexport function stopCamera(video: HTMLVideoElement): void {\n const stream = video.srcObject as MediaStream;\n if (stream) {\n const tracks = stream.getTracks();\n tracks.forEach((track) => {\n track.stop();\n });\n video.srcObject = null;\n }\n}\n\nexport async function captureImageFromVideo(\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n): Promise<Blob> {\n // Set canvas dimensions to match video\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // Draw video frame to canvas\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) {\n throw new Error(\"Could not get canvas context\");\n }\n\n ctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n\n // Convert canvas to blob\n return new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n (blob) => {\n if (blob) {\n resolve(blob);\n } else {\n reject(new Error(\"Failed to create blob from canvas\"));\n }\n },\n IMAGE_SETTINGS.FORMAT,\n IMAGE_SETTINGS.QUALITY,\n );\n });\n}\n","export function getCookie(name: string): string | null {\n if (typeof document === \"undefined\") return null;\n\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n\n if (parts.length === 2) {\n const part = parts.pop();\n return part ? part.split(\";\").shift()?.trim() || null : null;\n }\n\n return null;\n}\n\nexport function getPositionStyles(position: string): string {\n switch (position) {\n case \"bottom-left\":\n return \"left: 20px; bottom: 20px;\";\n case \"top-right\":\n return \"right: 20px; top: 20px;\";\n case \"top-left\":\n return \"left: 20px; top: 20px;\";\n default:\n return \"right: 20px; bottom: 20px;\";\n }\n}\n\nexport function removeElements(selector: string): void {\n const elements = document.querySelectorAll(selector);\n elements.forEach((element) => {\n element.remove();\n });\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { getPositionStyles } from \"../utils.js\";\n\nexport function createButtonContainer(\n buttonPosition: string,\n hasVirtualTryOn: boolean = false,\n onCameraClick: () => void,\n onRefreshClick?: () => void,\n onToggleClick?: () => void,\n isShowingVirtualTryOn: boolean = false,\n): HTMLElement {\n const container = document.createElement(\"div\");\n container.className = `${CSS_CLASSES.BUTTON_CONTAINER} ww-button-group`;\n\n const positionStyles = getPositionStyles(buttonPosition);\n container.style.cssText = `\n position: absolute;\n ${positionStyles}\n display: flex;\n border-radius: 9999px;\n background: white;\n padding: 4px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n z-index: ${Z_INDEX.BUTTON};\n `;\n\n // Camera button\n const cameraButton = document.createElement(\"button\");\n cameraButton.type = \"button\";\n cameraButton.className = `${CSS_CLASSES.BUTTON} ww-camera-btn`;\n cameraButton.setAttribute(\"aria-label\", \"Virtual Try-On\");\n cameraButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: transparent;\n color: currentColor;\n `;\n\n cameraButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-camera\">\n <path d=\"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z\"></path>\n <circle cx=\"12\" cy=\"13\" r=\"3\"></circle>\n </svg>\n `;\n\n cameraButton.onclick = onCameraClick;\n container.appendChild(cameraButton);\n\n // Add refresh and toggle buttons if we have a virtual try-on\n if (hasVirtualTryOn) {\n // Refresh button - calls API again\n if (onRefreshClick) {\n const refreshButton = document.createElement(\"button\");\n refreshButton.type = \"button\";\n refreshButton.className = \"ww-refresh-btn\";\n refreshButton.setAttribute(\"aria-label\", \"Refresh virtual try-on\");\n refreshButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: transparent;\n color: currentColor;\n `;\n\n refreshButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-refresh-ccw\">\n <path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path>\n <path d=\"M3 3v5h5\"></path>\n <path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path>\n <path d=\"M16 16h5v5\"></path>\n </svg>\n `;\n\n refreshButton.onclick = onRefreshClick;\n container.appendChild(refreshButton);\n }\n\n // Toggle button (scan-face) - switches between original and virtual try-on\n if (onToggleClick) {\n const toggleButton = document.createElement(\"button\");\n toggleButton.type = \"button\";\n toggleButton.className = \"ww-toggle-btn\";\n toggleButton.setAttribute(\n \"aria-label\",\n isShowingVirtualTryOn ? \"Show Original Image\" : \"Show Virtual Try-On\",\n );\n toggleButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: ${isShowingVirtualTryOn ? \"rgba(0, 0, 0)\" : \"none\"};\n color: ${isShowingVirtualTryOn ? \"white\" : \"currentColor\"};\n `;\n\n toggleButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-scan-face\">\n <path d=\"M3 7V5a2 2 0 0 1 2-2h2\"></path>\n <path d=\"M17 3h2a2 2 0 0 1 2 2v2\"></path>\n <path d=\"M21 17v2a2 2 0 0 1-2 2h-2\"></path>\n <path d=\"M7 21H5a2 2 0 0 1-2-2v-2\"></path>\n <path d=\"M8 14s1.5 2 4 2 4-2 4-2\"></path>\n <path d=\"M9 9h.01\"></path>\n <path d=\"M15 9h.01\"></path>\n </svg>\n `;\n\n toggleButton.onclick = onToggleClick;\n container.appendChild(toggleButton);\n }\n }\n\n return container;\n}\n\nexport function createButton(\n buttonPosition: string,\n onClick: () => void,\n): HTMLElement {\n return createButtonContainer(buttonPosition, false, onClick);\n}\n","import { startCamera, stopCamera } from \"../camera.js\";\nimport { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { removeElements } from \"../utils.js\";\n\nexport interface CameraModalCallbacks {\n onCapture: (\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n ) => Promise<void>;\n}\n\nexport function showCameraModal(callbacks: CameraModalCallbacks): void {\n console.log(\"[WeWear VTO] Opening camera modal...\");\n\n // Remove any existing modals first\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create camera container\n const cameraContainer = document.createElement(\"div\");\n cameraContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 70vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create video element\n const video = document.createElement(\"video\");\n video.autoplay = true;\n video.playsInline = true;\n video.muted = true;\n video.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create canvas for capturing\n const canvas = document.createElement(\"canvas\");\n canvas.style.display = \"none\";\n\n // Create capture button\n const captureButton = document.createElement(\"button\");\n captureButton.innerHTML = \"\";\n captureButton.style.cssText = `\n position: absolute;\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n width: 60px;\n height: 60px;\n border: 3px solid white;\n background-color: rgba(0, 0, 0, 0.7);\n border-radius: 50%;\n cursor: pointer;\n display: none;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create loading indicator\n const loadingIndicator = document.createElement(\"div\");\n loadingIndicator.innerHTML = \"Initializing camera...\";\n loadingIndicator.style.cssText = `\n color: white;\n font-size: 16px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n stopCamera(video);\n modal.remove();\n };\n\n captureButton.onclick = async () => {\n await callbacks.onCapture(video, canvas);\n };\n\n // Assemble the camera modal\n cameraContainer.appendChild(video);\n cameraContainer.appendChild(canvas);\n cameraContainer.appendChild(captureButton);\n cameraContainer.appendChild(closeButton);\n cameraContainer.appendChild(loadingIndicator);\n modal.appendChild(cameraContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Camera modal added to DOM\");\n\n // Start camera\n startCamera(video, loadingIndicator, captureButton);\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\n\n/**\n * Creates a loading overlay that can be shown in different containers\n */\nexport function createLoadingOverlay(\n text: string = \"Processing...\",\n): HTMLElement {\n const overlay = document.createElement(\"div\");\n overlay.className = \"ww-loading-overlay\";\n overlay.style.cssText = `\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.8);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL + 1};\n border-radius: inherit;\n `;\n\n // Add CSS animation to the document if not already added\n if (!document.getElementById(\"ww-loading-animation\")) {\n const style = document.createElement(\"style\");\n style.id = \"ww-loading-animation\";\n style.textContent = `\n @keyframes ww-pulse {\n 0%, 100% { opacity: 0.7; transform: scale(1); }\n 50% { opacity: 1; transform: scale(1.05); }\n }\n .ww-loading-overlay .ww-logo {\n animation: ww-pulse 2s ease-in-out infinite;\n }\n `;\n document.head.appendChild(style);\n }\n\n overlay.innerHTML = `\n <div style=\"display: flex; flex-direction: column; align-items: center; gap: 24px; color: white;\">\n <svg class=\"ww-logo\" width=\"80\" height=\"50\" viewBox=\"0 0 214 135\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <g clip-path=\"url(#clip0_3624_12755)\">\n <path d=\"M102.906 74.8679C102.906 77.9717 101.574 80.7453 98.9104 83.1887C96.6871 85.1918 93.9025 86.6997 90.5566 87.7123C87.695 88.5708 84.6462 89 81.4104 89C73.8821 89 68.0047 87.0189 63.7783 83.0566C59.5519 87.0189 53.6855 89 46.1792 89C42.9434 89 39.9057 88.5708 37.066 87.7123C33.7201 86.6997 30.9245 85.1918 28.6792 83.1887C26.0157 80.7453 24.684 77.9717 24.684 74.8679V41.6509H32.3774V74.8679C32.3774 76.2547 33.489 77.5645 35.7123 78.7972C37.3632 79.7217 39.0692 80.3711 40.8302 80.7453C42.5252 81.1195 44.3082 81.3066 46.1792 81.3066C48.0063 81.3066 49.7673 81.1195 51.4623 80.7453C53.2453 80.3711 54.9623 79.7217 56.6132 78.7972C58.8585 77.5645 59.9811 76.2547 59.9811 74.8679V41.6509H67.6085V74.8679C67.6085 76.2547 68.7311 77.5645 70.9764 78.7972C72.6274 79.7217 74.3443 80.3711 76.1274 80.7453C77.8223 81.1195 79.5833 81.3066 81.4104 81.3066C83.2814 81.3066 85.0755 81.1195 86.7925 80.7453C88.5314 80.3711 90.2264 79.7217 91.8774 78.7972C94.1006 77.5645 95.2123 76.2547 95.2123 74.8679V41.6509H102.906V74.8679ZM189.283 74.8679C189.283 77.9717 187.951 80.7453 185.288 83.1887C183.064 85.1918 180.28 86.6997 176.934 87.7123C174.072 88.5708 171.024 89 167.788 89C160.259 89 154.382 87.0189 150.156 83.0566C145.929 87.0189 140.063 89 132.557 89C129.321 89 126.283 88.5708 123.443 87.7123C120.097 86.6997 117.302 85.1918 115.057 83.1887C112.393 80.7453 111.061 77.9717 111.061 74.8679V41.6509H118.755V74.8679C118.755 76.2547 119.866 77.5645 122.09 78.7972C123.741 79.7217 125.447 80.3711 127.208 80.7453C128.903 81.1195 130.686 81.3066 132.557 81.3066C134.384 81.3066 136.145 81.1195 137.84 80.7453C139.623 80.3711 141.34 79.7217 142.991 78.7972C145.236 77.5645 146.358 76.2547 146.358 74.8679V41.6509H153.986V74.8679C153.986 76.2547 155.108 77.5645 157.354 78.7972C159.005 79.7217 160.722 80.3711 162.505 80.7453C164.2 81.1195 165.961 81.3066 167.788 81.3066C169.659 81.3066 171.453 81.1195 173.17 80.7453C174.909 80.3711 176.604 79.7217 178.255 78.7972C180.478 77.5645 181.59 76.2547 181.59 74.8679V41.6509H189.283V74.8679Z\" fill=\"white\"/>\n </g>\n <defs>\n <clipPath id=\"clip0_3624_12755\">\n <rect width=\"214\" height=\"135\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n <div style=\"font-size: 16px; font-weight: 500; text-align: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\">${text}</div>\n </div>\n `;\n\n return overlay;\n}\n\n/**\n * Shows a loading overlay in a modal container\n */\nexport function showModalLoading(text: string = \"Processing...\"): void {\n const modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\n if (!modal) return;\n\n // Remove any existing loading overlays\n removeModalLoading();\n\n const loadingOverlay = createLoadingOverlay(text);\n modal.appendChild(loadingOverlay);\n}\n\n/**\n * Removes loading overlay from modal\n */\nexport function removeModalLoading(): void {\n const modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\n if (!modal) return;\n\n const existingOverlay = modal.querySelector(\".ww-loading-overlay\");\n if (existingOverlay) {\n existingOverlay.remove();\n }\n}\n\n/**\n * Shows a loading overlay in the product gallery container\n */\nexport function showProductLoading(\n container: HTMLElement,\n text: string = \"Generating virtual try-on...\",\n): void {\n // Remove any existing loading overlays\n removeProductLoading(container);\n\n // Make container relative if it's not already positioned\n const computedStyle = window.getComputedStyle(container);\n if (computedStyle.position === \"static\") {\n container.style.position = \"relative\";\n }\n\n const loadingOverlay = createLoadingOverlay(text);\n container.appendChild(loadingOverlay);\n}\n\n/**\n * Removes loading overlay from product container\n */\nexport function removeProductLoading(container: HTMLElement): void {\n const existingOverlay = container.querySelector(\".ww-loading-overlay\");\n if (existingOverlay) {\n existingOverlay.remove();\n }\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { removeElements } from \"../utils.js\";\n\nexport interface ReviewModalCallbacks {\n onRetake: () => void;\n onAccept: (imageBlob: Blob) => Promise<void>;\n}\n\nexport function showReviewModal(\n imageBlob: Blob,\n callbacks: ReviewModalCallbacks,\n): void {\n console.log(\"[WeWear VTO] Opening review modal...\");\n\n // Remove any existing modals first\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Create image URL for preview\n const imageUrl = URL.createObjectURL(imageBlob);\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n gap: 20px;\n `;\n\n // Create review container\n const reviewContainer = document.createElement(\"div\");\n reviewContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 63vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create image element\n const image = document.createElement(\"img\");\n image.src = imageUrl;\n image.alt = \"Review your photo\";\n image.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create button container\n const buttonContainer = document.createElement(\"div\");\n buttonContainer.style.cssText = `\n display: flex;\n gap: 15px;\n width: 100%;\n max-width: 500px;\n `;\n\n // Create retake button\n const retakeButton = document.createElement(\"button\");\n retakeButton.textContent = \"Retake\";\n retakeButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: rgba(255, 255, 255, 0.9);\n color: black;\n border-radius: 8px;\n border: none;\n font-size: 16px;\n font-weight: normal;\n cursor: pointer;\n `;\n\n // Create use photo button\n const usePhotoButton = document.createElement(\"button\");\n usePhotoButton.textContent = \"Use Photo\";\n usePhotoButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n border-radius: 8px;\n border: none;\n font-size: 16px;\n font-weight: normal;\n cursor: pointer;\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n };\n\n retakeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n callbacks.onRetake();\n };\n\n usePhotoButton.onclick = async () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n await callbacks.onAccept(imageBlob);\n };\n\n // Assemble the review modal\n buttonContainer.appendChild(retakeButton);\n buttonContainer.appendChild(usePhotoButton);\n reviewContainer.appendChild(image);\n reviewContainer.appendChild(closeButton);\n modal.appendChild(reviewContainer);\n modal.appendChild(buttonContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Review modal added to DOM\");\n}\n","import { callVirtualTryOnApi } from \"./api.js\";\nimport { captureImageFromVideo, stopCamera } from \"./camera.js\";\nimport {\n type CameraModalCallbacks,\n createButton,\n createButtonContainer,\n type ReviewModalCallbacks,\n removeModalLoading,\n removeProductLoading,\n showCameraModal,\n showModalLoading,\n showProductLoading,\n showReviewModal,\n} from \"./components/index.js\";\nimport { CSS_CLASSES, DEFAULT_CONFIG } from \"./constants.js\";\nimport type { VirtualTryOnConfig } from \"./index.js\";\nimport { getCookie, removeElements } from \"./utils.js\";\n\nexport class VirtualTryOnWidget {\n private readonly config: Required<VirtualTryOnConfig>;\n private virtualTryOnImageUrl: string | null = null;\n private isShowingVirtualTryOn: boolean = false;\n private lastApiParams: {\n imageBlob: Blob;\n ww_access_token: string;\n ww_user_id: string;\n ww_product_id: string;\n } | null = null;\n\n constructor(config: VirtualTryOnConfig = {}) {\n this.config = {\n baseUrl: config.baseUrl || DEFAULT_CONFIG.BASE_URL,\n productPageSelector:\n config.productPageSelector || DEFAULT_CONFIG.PRODUCT_PAGE_SELECTOR,\n gallerySelector:\n config.gallerySelector || DEFAULT_CONFIG.GALLERY_SELECTOR,\n skuSelector: config.skuSelector || DEFAULT_CONFIG.SKU_SELECTOR,\n buttonPosition: config.buttonPosition || DEFAULT_CONFIG.BUTTON_POSITION,\n };\n }\n\n /**\n * Initializes the virtual try-on widget on the current page\n * @returns Promise that resolves when initialization is complete\n */\n public async init(): Promise<void> {\n try {\n // Check if we're on a product page\n if (!window.location.pathname.includes(this.config.productPageSelector)) {\n return;\n }\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Ensure container has relative positioning for button placement\n if (getComputedStyle(container).position === \"static\") {\n container.style.position = \"relative\";\n }\n\n // Create and add the virtual try-on button\n const button = createButton(this.config.buttonPosition, async () => {\n await this.handleTryOnClick();\n });\n\n container.appendChild(button);\n console.log(\"[WeWear VTO] Widget initialized successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization failed:\", error);\n }\n }\n\n /**\n * Handles virtual try-on button click\n * @private\n */\n private async handleTryOnClick(): Promise<void> {\n console.log(\"[WeWear VTO] Button clicked, starting try-on process...\");\n\n try {\n // Get required data\n const ww_access_token = getCookie(\"ww_access_token\");\n const ww_user_id = getCookie(\"ww_user_id\");\n const skuElement = document.querySelector(this.config.skuSelector);\n const ww_product_id = skuElement?.textContent?.trim();\n\n console.log(\"[WeWear VTO] Retrieved data:\", {\n ww_user_id,\n ww_product_id,\n ww_access_token,\n });\n\n // Validate required data\n if (!ww_user_id) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_user_id\");\n return;\n }\n\n if (!ww_product_id) {\n console.warn(\n \"[WeWear VTO] Product SKU not found:\",\n this.config.skuSelector,\n );\n return;\n }\n\n if (!ww_access_token) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_access_token\");\n return;\n }\n\n // Show camera capture modal\n this.showCameraModalWithCallbacks(\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Try-on request failed:\", error);\n }\n }\n\n /**\n * Shows camera modal with appropriate callbacks\n * @private\n */\n private showCameraModalWithCallbacks(\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ): void {\n const callbacks: CameraModalCallbacks = {\n onCapture: async (video: HTMLVideoElement, canvas: HTMLCanvasElement) => {\n try {\n // Capture image from video\n const imageBlob = await captureImageFromVideo(video, canvas);\n\n // Stop camera and show review modal\n stopCamera(video);\n\n // Show review modal instead of immediately processing\n this.showReviewModalWithCallbacks(\n imageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Image capture error:\", error);\n }\n },\n };\n\n showCameraModal(callbacks);\n }\n\n /**\n * Shows review modal with appropriate callbacks\n * @private\n */\n private showReviewModalWithCallbacks(\n imageBlob: Blob,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ): void {\n const callbacks: ReviewModalCallbacks = {\n onRetake: () => {\n // Reopen camera modal\n this.showCameraModalWithCallbacks(\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n },\n onAccept: async (acceptedImageBlob: Blob) => {\n await this.processAcceptedImage(\n acceptedImageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n );\n },\n };\n\n showReviewModal(imageBlob, callbacks);\n }\n\n /**\n * Processes the accepted image by calling the API\n * @private\n */\n private async processAcceptedImage(\n imageBlob: Blob,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_id: string,\n ): Promise<void> {\n try {\n console.log(\"[WeWear VTO] Processing accepted image...\");\n\n // Show loading in the review modal first\n showModalLoading(\"Processing image...\");\n\n // Store the API parameters for potential refresh\n this.lastApiParams = {\n imageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n };\n\n // Call the API with the accepted image\n const result = await callVirtualTryOnApi(\n this.config.baseUrl,\n ww_access_token,\n ww_user_id,\n ww_product_id,\n imageBlob,\n );\n\n // Remove modal loading and close modal\n removeModalLoading();\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n if (result?.imageUrl) {\n this.replaceProductImage(result.imageUrl);\n } else {\n console.error(\"[WeWear VTO] Invalid API response:\", result);\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error processing accepted image:\", error);\n // Remove loading on error\n removeModalLoading();\n }\n }\n\n /**\n * Recalls the virtual try-on API with the same parameters\n * @private\n */\n private async refreshVirtualTryOn(): Promise<void> {\n if (!this.lastApiParams) {\n console.warn(\n \"[WeWear VTO] No previous API parameters available for refresh\",\n );\n return;\n }\n\n try {\n console.log(\n \"[WeWear VTO] Refreshing virtual try-on with previous parameters...\",\n );\n\n // Show loading in the product area\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n showProductLoading(container, \"Generating new virtual try-on...\");\n }\n\n // Call the API with the stored parameters\n const result = await callVirtualTryOnApi(\n this.config.baseUrl,\n this.lastApiParams.ww_access_token,\n this.lastApiParams.ww_user_id,\n this.lastApiParams.ww_product_id,\n this.lastApiParams.imageBlob,\n );\n\n if (result?.imageUrl) {\n this.virtualTryOnImageUrl = result.imageUrl;\n\n // Find the gallery container and update the image\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n this.showVirtualTryOnImage(container);\n this.updateButtonContainer(container);\n }\n } else {\n console.error(\"[WeWear VTO] Invalid API response on refresh:\", result);\n // Remove loading on error\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n }\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error refreshing virtual try-on:\", error);\n // Remove loading on error\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n }\n }\n }\n\n /**\n * Replaces the product image in the gallery with the virtual try-on result\n * @private\n */\n private replaceProductImage(imageUrl: string): void {\n try {\n // Store the virtual try-on image URL\n this.virtualTryOnImageUrl = imageUrl;\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found for image replacement:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Store the original content if not already stored\n if (!container.hasAttribute(\"data-ww-original-content\")) {\n container.setAttribute(\"data-ww-original-content\", container.innerHTML);\n }\n\n // Capture original image dimensions before replacement to prevent layout shift\n const originalImg = container.querySelector('img');\n if (originalImg && !container.hasAttribute(\"data-ww-original-dimensions\")) {\n const computedStyle = window.getComputedStyle(originalImg);\n const rect = originalImg.getBoundingClientRect();\n container.setAttribute(\"data-ww-original-width\", computedStyle.width);\n container.setAttribute(\"data-ww-original-height\", computedStyle.height);\n container.setAttribute(\"data-ww-original-rect-width\", rect.width.toString());\n container.setAttribute(\"data-ww-original-rect-height\", rect.height.toString());\n container.setAttribute(\"data-ww-original-dimensions\", \"true\");\n }\n\n // Show the virtual try-on image initially\n this.showVirtualTryOnImage(container);\n\n // Replace the button container with the new multi-button version\n this.updateButtonContainer(container);\n\n console.log(\n \"[WeWear VTO] Product image replaced with virtual try-on result\",\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Error replacing product image:\", error);\n }\n }\n\n /**\n * Updates the button container to show all available buttons\n * @private\n */\n private updateButtonContainer(container: HTMLElement): void {\n // Remove existing button containers\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n existingButtons.forEach((btn) => {\n btn.remove();\n });\n\n // Create new button container with all buttons\n const buttonContainer = createButtonContainer(\n this.config.buttonPosition,\n this.virtualTryOnImageUrl !== null,\n async () => {\n await this.handleTryOnClick();\n },\n async () => {\n await this.refreshVirtualTryOn();\n },\n () => {\n if (this.isShowingVirtualTryOn) {\n this.showOriginalImage(container);\n } else {\n this.showVirtualTryOnImage(container);\n }\n this.updateButtonContainer(container);\n },\n this.isShowingVirtualTryOn,\n );\n\n container.appendChild(buttonContainer);\n }\n\n /**\n * Shows the virtual try-on image in the container\n * @private\n */\n private showVirtualTryOnImage(container: HTMLElement): void {\n if (!this.virtualTryOnImageUrl) {\n console.warn(\"[WeWear VTO] No virtual try-on image URL available\");\n return;\n }\n\n // Clear existing content except buttons\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n container.innerHTML = \"\";\n\n // Get stored original dimensions to prevent layout shift\n const originalWidth = container.getAttribute(\"data-ww-original-width\") || '';\n const originalHeight = container.getAttribute(\"data-ww-original-height\") || '';\n const originalRectWidth = container.getAttribute(\"data-ww-original-rect-width\") || '';\n const originalRectHeight = container.getAttribute(\"data-ww-original-rect-height\") || '';\n\n const image = document.createElement(\"img\");\n image.src = this.virtualTryOnImageUrl;\n image.alt = \"Virtual Try-On Result\";\n\n // Use original dimensions to prevent layout shift\n let widthStyle = '100%';\n let heightStyle = '100%';\n\n // Prefer computed style dimensions, fallback to bounding rect, then container fill\n if (originalWidth && originalWidth !== 'auto' && originalWidth !== '0px') {\n widthStyle = originalWidth;\n } else if (originalRectWidth && originalRectWidth !== '0') {\n widthStyle = `${originalRectWidth}px`;\n }\n\n if (originalHeight && originalHeight !== 'auto' && originalHeight !== '0px') {\n heightStyle = originalHeight;\n } else if (originalRectHeight && originalRectHeight !== '0') {\n heightStyle = `${originalRectHeight}px`;\n }\n\n image.style.cssText = `\n width: ${widthStyle};\n height: ${heightStyle};\n object-fit: contain;\n border-radius: 8px;\n `;\n\n container.appendChild(image);\n\n // Re-add buttons\n existingButtons.forEach((btn) => {\n container.appendChild(btn);\n });\n\n this.isShowingVirtualTryOn = true;\n }\n\n /**\n * Shows the original product image in the container\n * @private\n */\n private showOriginalImage(container: HTMLElement): void {\n const originalContent = container.getAttribute(\"data-ww-original-content\");\n if (originalContent) {\n // Store existing buttons\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n\n // Restore original content\n container.innerHTML = originalContent;\n\n // Re-add buttons\n existingButtons.forEach((btn) => {\n container.appendChild(btn);\n });\n }\n\n this.isShowingVirtualTryOn = false;\n }\n\n /**\n * Destroys the widget and cleans up resources\n */\n public destroy(): void {\n try {\n // Remove all buttons\n removeElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);\n\n // Remove all modals\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Reset state\n this.virtualTryOnImageUrl = null;\n this.isShowingVirtualTryOn = false;\n this.lastApiParams = null;\n\n console.log(\"[WeWear VTO] Widget destroyed successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Error during widget destruction:\", error);\n }\n }\n}\n","import type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n try {\n // Clean up any existing instance\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n }\n\n // Create and initialize new instance\n widgetInstance = new VirtualTryOnWidget(config);\n\n // Initialize immediately if DOM is ready, otherwise wait for it\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n widgetInstance?.init().catch((error) => {\n console.error(\n \"[WeWear VTO] Failed to initialize after DOM ready:\",\n error,\n );\n });\n });\n } else {\n widgetInstance.init().catch((error) => {\n console.error(\"[WeWear VTO] Failed to initialize:\", error);\n });\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization error:\", error);\n }\n}\n\nexport function destroyVirtualTryOn(): void {\n try {\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n console.log(\"[WeWear VTO] Widget instance destroyed\");\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error destroying widget:\", error);\n }\n}\n\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n return widgetInstance;\n}\n\nif (typeof window !== \"undefined\") {\n initVirtualTryOn();\n}\n"],"names":[],"mappings":";;;;;;IAEO,eAAe,mBAAmB,CACrC,OAAe,EACf,eAAuB,EACvB,UAAkB,EAClB,aAAqB,EACrB,QAAc,EAAA;IAEd,IAAA,IAAI;IACA,QAAA,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE;IAC/B,QAAA,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC;IACzC,QAAA,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,aAAa,CAAC;YAC/C,QAAQ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oDAAoD,EACpD,KAAK,CACR;IACL,gBAAA,CAAC,CAAC;IACN,YAAA,CAAC,CAAC;YACN;iBAAO;gBACH,cAAc,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;IAClC,gBAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;IAC9D,YAAA,CAAC,CAAC;YACN;QACJ;QAAE,OAAO,KAAK,EAAE;IACZ,QAAA,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC;QAC9D;IACJ;aAEgB,mBAAmB,GAAA;IAC/B,IAAA,IAAI;YACA,IAAI,cAAc,EAAE;gBAChB,cAAc,CAAC,OAAO,EAAE;gBACxB,cAAc,GAAG,IAAI;IACrB,YAAA,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC;YACzD;QACJ;QAAE,OAAO,KAAK,EAAE;IACZ,QAAA,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC;QACjE;IACJ;aAEgB,iBAAiB,GAAA;IAC7B,IAAA,OAAO,cAAc;IACzB;IAEA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAC/B,IAAA,gBAAgB,EAAE;IACtB;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/api.ts","../src/constants.ts","../src/camera.ts","../src/utils.ts","../src/components/button.ts","../src/components/camera-modal.ts","../src/components/loading-overlay.ts","../src/components/review-modal.ts","../src/widget.ts","../src/installer.ts"],"sourcesContent":["import type { VirtualTryOnResult } from \"./index.js\";\n\nexport async function callVirtualTryOnApi(\n baseUrl: string,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_image: string,\n ww_image: Blob,\n): Promise<VirtualTryOnResult | null> {\n try {\n const formData = new FormData();\n formData.append(\"ww_user_id\", ww_user_id);\n formData.append(\"ww_product_image\", ww_product_image);\n formData.append(\"ww_image\", ww_image, \"captured-image.jpg\");\n formData.append(\"ww_access_token\", ww_access_token);\n\n const response = await fetch(`${baseUrl}/api/virtual-try-on`, {\n method: \"POST\",\n body: formData,\n });\n\n if (!response.ok) {\n console.error(\n \"[WeWear VTO] API request failed:\",\n response.status,\n response.statusText,\n );\n return null;\n }\n\n const result = await response.json();\n console.log(\"[WeWear VTO] API response:\", result);\n return result;\n } catch (error) {\n console.error(\"[WeWear VTO] API call failed:\", error);\n return null;\n }\n}\n","/** Default configuration constants */\nexport const DEFAULT_CONFIG = {\n BASE_URL: \"https://virtual-try-on-widget.vercel.app\",\n PRODUCT_PAGE_SELECTOR: \"/product/\",\n GALLERY_SELECTOR: \".woocommerce-product-gallery__image\",\n PRODUCT_IMAGE_SELECTOR: \".woocommerce-product-gallery__image img\",\n BUTTON_POSITION: \"bottom-right\" as const,\n} as const;\n\n/** CSS class names for consistent styling */\nexport const CSS_CLASSES = {\n BUTTON_CONTAINER: \"wewear-vto-button-container\",\n BUTTON: \"wewear-vto-button\",\n MODAL: \"wewear-vto-modal\",\n} as const;\n\n/** Z-index values for proper layering */\nexport const Z_INDEX = {\n BUTTON: 10,\n MODAL: 99999,\n} as const;\n\n/** Camera constraints for optimal capture */\nexport const CAMERA_CONSTRAINTS = {\n video: {\n width: { ideal: 1280 },\n height: { ideal: 720 },\n facingMode: \"user\", // Front-facing camera\n },\n audio: false,\n} as const;\n\n/** Image capture settings */\nexport const IMAGE_SETTINGS = {\n FORMAT: \"image/jpeg\",\n QUALITY: 0.8,\n} as const;\n","import { CAMERA_CONSTRAINTS, IMAGE_SETTINGS } from \"./constants.js\";\n\nexport async function startCamera(\n video: HTMLVideoElement,\n loadingIndicator: HTMLElement,\n captureButton: HTMLButtonElement,\n): Promise<void> {\n console.log(\"[WeWear VTO] Starting camera...\");\n\n try {\n console.log(\"[WeWear VTO] Requesting camera access...\");\n const stream =\n await navigator.mediaDevices.getUserMedia(CAMERA_CONSTRAINTS);\n video.srcObject = stream;\n\n video.onloadedmetadata = () => {\n console.log(\"[WeWear VTO] Camera stream loaded successfully\");\n loadingIndicator.style.display = \"none\";\n captureButton.style.display = \"flex\";\n };\n } catch (error) {\n console.error(\"[WeWear VTO] Camera access error:\", error);\n loadingIndicator.innerHTML =\n \"Camera access denied. Please allow camera permissions.\";\n }\n}\n\nexport function stopCamera(video: HTMLVideoElement): void {\n const stream = video.srcObject as MediaStream;\n if (stream) {\n const tracks = stream.getTracks();\n tracks.forEach((track) => {\n track.stop();\n });\n video.srcObject = null;\n }\n}\n\nexport async function captureImageFromVideo(\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n): Promise<Blob> {\n // Set canvas dimensions to match video\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // Draw video frame to canvas\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) {\n throw new Error(\"Could not get canvas context\");\n }\n\n ctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n\n // Convert canvas to blob\n return new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n (blob) => {\n if (blob) {\n resolve(blob);\n } else {\n reject(new Error(\"Failed to create blob from canvas\"));\n }\n },\n IMAGE_SETTINGS.FORMAT,\n IMAGE_SETTINGS.QUALITY,\n );\n });\n}\n","export function getCookie(name: string): string | null {\n if (typeof document === \"undefined\") return null;\n\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n\n if (parts.length === 2) {\n const part = parts.pop();\n return part ? part.split(\";\").shift()?.trim() || null : null;\n }\n\n return null;\n}\n\nexport function getPositionStyles(position: string): string {\n switch (position) {\n case \"bottom-left\":\n return \"left: 20px; bottom: 20px;\";\n case \"top-right\":\n return \"right: 20px; top: 20px;\";\n case \"top-left\":\n return \"left: 20px; top: 20px;\";\n default:\n return \"right: 20px; bottom: 20px;\";\n }\n}\n\nexport function removeElements(selector: string): void {\n const elements = document.querySelectorAll(selector);\n elements.forEach((element) => {\n element.remove();\n });\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { getPositionStyles } from \"../utils.js\";\n\nexport function createButtonContainer(\n buttonPosition: string,\n hasVirtualTryOn: boolean = false,\n onCameraClick: () => void,\n onRefreshClick?: () => void,\n onToggleClick?: () => void,\n isShowingVirtualTryOn: boolean = false,\n): HTMLElement {\n const container = document.createElement(\"div\");\n container.className = `${CSS_CLASSES.BUTTON_CONTAINER} ww-button-group`;\n\n const positionStyles = getPositionStyles(buttonPosition);\n container.style.cssText = `\n position: absolute;\n ${positionStyles}\n display: flex;\n border-radius: 9999px;\n background: white;\n padding: 4px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n z-index: ${Z_INDEX.BUTTON};\n `;\n\n // Camera button\n const cameraButton = document.createElement(\"button\");\n cameraButton.type = \"button\";\n cameraButton.className = `${CSS_CLASSES.BUTTON} ww-camera-btn`;\n cameraButton.setAttribute(\"aria-label\", \"Virtual Try-On\");\n cameraButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: transparent;\n color: currentColor;\n `;\n\n cameraButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-camera\">\n <path d=\"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z\"></path>\n <circle cx=\"12\" cy=\"13\" r=\"3\"></circle>\n </svg>\n `;\n\n cameraButton.onclick = onCameraClick;\n container.appendChild(cameraButton);\n\n // Add refresh and toggle buttons if we have a virtual try-on\n if (hasVirtualTryOn) {\n // Refresh button - calls API again\n if (onRefreshClick) {\n const refreshButton = document.createElement(\"button\");\n refreshButton.type = \"button\";\n refreshButton.className = \"ww-refresh-btn\";\n refreshButton.setAttribute(\"aria-label\", \"Refresh virtual try-on\");\n refreshButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: transparent;\n color: currentColor;\n `;\n\n refreshButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-refresh-ccw\">\n <path d=\"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"></path>\n <path d=\"M3 3v5h5\"></path>\n <path d=\"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16\"></path>\n <path d=\"M16 16h5v5\"></path>\n </svg>\n `;\n\n refreshButton.onclick = onRefreshClick;\n container.appendChild(refreshButton);\n }\n\n // Toggle button (scan-face) - switches between original and virtual try-on\n if (onToggleClick) {\n const toggleButton = document.createElement(\"button\");\n toggleButton.type = \"button\";\n toggleButton.className = \"ww-toggle-btn\";\n toggleButton.setAttribute(\n \"aria-label\",\n isShowingVirtualTryOn ? \"Show Original Image\" : \"Show Virtual Try-On\",\n );\n toggleButton.style.cssText = `\n display: flex;\n width: 36px;\n height: 36px;\n cursor: pointer;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n padding: 8px;\n border: none;\n background: ${isShowingVirtualTryOn ? \"rgba(0, 0, 0)\" : \"none\"};\n color: ${isShowingVirtualTryOn ? \"white\" : \"currentColor\"};\n `;\n\n toggleButton.innerHTML = `\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-scan-face\">\n <path d=\"M3 7V5a2 2 0 0 1 2-2h2\"></path>\n <path d=\"M17 3h2a2 2 0 0 1 2 2v2\"></path>\n <path d=\"M21 17v2a2 2 0 0 1-2 2h-2\"></path>\n <path d=\"M7 21H5a2 2 0 0 1-2-2v-2\"></path>\n <path d=\"M8 14s1.5 2 4 2 4-2 4-2\"></path>\n <path d=\"M9 9h.01\"></path>\n <path d=\"M15 9h.01\"></path>\n </svg>\n `;\n\n toggleButton.onclick = onToggleClick;\n container.appendChild(toggleButton);\n }\n }\n\n return container;\n}\n\nexport function createButton(\n buttonPosition: string,\n onClick: () => void,\n disabled: boolean = false,\n): HTMLElement {\n const container = createButtonContainer(buttonPosition, false, onClick);\n const cameraButton = container.querySelector('.ww-camera-btn') as HTMLButtonElement;\n if (cameraButton) {\n cameraButton.disabled = disabled;\n if (disabled) {\n cameraButton.style.opacity = '0.5';\n cameraButton.style.cursor = 'not-allowed';\n cameraButton.title = 'Find your ideal size first';\n }\n }\n return container;\n}\n","import { startCamera, stopCamera } from \"../camera.js\";\nimport { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { removeElements } from \"../utils.js\";\n\nexport interface CameraModalCallbacks {\n onCapture: (\n video: HTMLVideoElement,\n canvas: HTMLCanvasElement,\n ) => Promise<void>;\n}\n\nexport function showCameraModal(callbacks: CameraModalCallbacks): void {\n console.log(\"[WeWear VTO] Opening camera modal...\");\n\n // Remove any existing modals first\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n `;\n\n // Create camera container\n const cameraContainer = document.createElement(\"div\");\n cameraContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 70vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create video element\n const video = document.createElement(\"video\");\n video.autoplay = true;\n video.playsInline = true;\n video.muted = true;\n video.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create canvas for capturing\n const canvas = document.createElement(\"canvas\");\n canvas.style.display = \"none\";\n\n // Create capture button\n const captureButton = document.createElement(\"button\");\n captureButton.innerHTML = \"\";\n captureButton.style.cssText = `\n position: absolute;\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n width: 60px;\n height: 60px;\n border: 3px solid white;\n background-color: rgba(0, 0, 0, 0.7);\n border-radius: 50%;\n cursor: pointer;\n display: none;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create loading indicator\n const loadingIndicator = document.createElement(\"div\");\n loadingIndicator.innerHTML = \"Initializing camera...\";\n loadingIndicator.style.cssText = `\n color: white;\n font-size: 16px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n stopCamera(video);\n modal.remove();\n };\n\n captureButton.onclick = async () => {\n await callbacks.onCapture(video, canvas);\n };\n\n // Assemble the camera modal\n cameraContainer.appendChild(video);\n cameraContainer.appendChild(canvas);\n cameraContainer.appendChild(captureButton);\n cameraContainer.appendChild(closeButton);\n cameraContainer.appendChild(loadingIndicator);\n modal.appendChild(cameraContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Camera modal added to DOM\");\n\n // Start camera\n startCamera(video, loadingIndicator, captureButton);\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\n\n/**\n * Creates a loading overlay that can be shown in different containers\n */\nexport function createLoadingOverlay(\n text: string = \"Processing...\",\n): HTMLElement {\n const overlay = document.createElement(\"div\");\n overlay.className = \"ww-loading-overlay\";\n overlay.style.cssText = `\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.8);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL + 1};\n border-radius: inherit;\n `;\n\n // Add CSS animation to the document if not already added\n if (!document.getElementById(\"ww-loading-animation\")) {\n const style = document.createElement(\"style\");\n style.id = \"ww-loading-animation\";\n style.textContent = `\n @keyframes ww-pulse {\n 0%, 100% { opacity: 0.7; transform: scale(1); }\n 50% { opacity: 1; transform: scale(1.05); }\n }\n .ww-loading-overlay .ww-logo {\n animation: ww-pulse 2s ease-in-out infinite;\n }\n `;\n document.head.appendChild(style);\n }\n\n overlay.innerHTML = `\n <div style=\"display: flex; flex-direction: column; align-items: center; gap: 24px; color: white;\">\n <svg class=\"ww-logo\" width=\"80\" height=\"50\" viewBox=\"0 0 214 135\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <g clip-path=\"url(#clip0_3624_12755)\">\n <path d=\"M102.906 74.8679C102.906 77.9717 101.574 80.7453 98.9104 83.1887C96.6871 85.1918 93.9025 86.6997 90.5566 87.7123C87.695 88.5708 84.6462 89 81.4104 89C73.8821 89 68.0047 87.0189 63.7783 83.0566C59.5519 87.0189 53.6855 89 46.1792 89C42.9434 89 39.9057 88.5708 37.066 87.7123C33.7201 86.6997 30.9245 85.1918 28.6792 83.1887C26.0157 80.7453 24.684 77.9717 24.684 74.8679V41.6509H32.3774V74.8679C32.3774 76.2547 33.489 77.5645 35.7123 78.7972C37.3632 79.7217 39.0692 80.3711 40.8302 80.7453C42.5252 81.1195 44.3082 81.3066 46.1792 81.3066C48.0063 81.3066 49.7673 81.1195 51.4623 80.7453C53.2453 80.3711 54.9623 79.7217 56.6132 78.7972C58.8585 77.5645 59.9811 76.2547 59.9811 74.8679V41.6509H67.6085V74.8679C67.6085 76.2547 68.7311 77.5645 70.9764 78.7972C72.6274 79.7217 74.3443 80.3711 76.1274 80.7453C77.8223 81.1195 79.5833 81.3066 81.4104 81.3066C83.2814 81.3066 85.0755 81.1195 86.7925 80.7453C88.5314 80.3711 90.2264 79.7217 91.8774 78.7972C94.1006 77.5645 95.2123 76.2547 95.2123 74.8679V41.6509H102.906V74.8679ZM189.283 74.8679C189.283 77.9717 187.951 80.7453 185.288 83.1887C183.064 85.1918 180.28 86.6997 176.934 87.7123C174.072 88.5708 171.024 89 167.788 89C160.259 89 154.382 87.0189 150.156 83.0566C145.929 87.0189 140.063 89 132.557 89C129.321 89 126.283 88.5708 123.443 87.7123C120.097 86.6997 117.302 85.1918 115.057 83.1887C112.393 80.7453 111.061 77.9717 111.061 74.8679V41.6509H118.755V74.8679C118.755 76.2547 119.866 77.5645 122.09 78.7972C123.741 79.7217 125.447 80.3711 127.208 80.7453C128.903 81.1195 130.686 81.3066 132.557 81.3066C134.384 81.3066 136.145 81.1195 137.84 80.7453C139.623 80.3711 141.34 79.7217 142.991 78.7972C145.236 77.5645 146.358 76.2547 146.358 74.8679V41.6509H153.986V74.8679C153.986 76.2547 155.108 77.5645 157.354 78.7972C159.005 79.7217 160.722 80.3711 162.505 80.7453C164.2 81.1195 165.961 81.3066 167.788 81.3066C169.659 81.3066 171.453 81.1195 173.17 80.7453C174.909 80.3711 176.604 79.7217 178.255 78.7972C180.478 77.5645 181.59 76.2547 181.59 74.8679V41.6509H189.283V74.8679Z\" fill=\"white\"/>\n </g>\n <defs>\n <clipPath id=\"clip0_3624_12755\">\n <rect width=\"214\" height=\"135\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n <div style=\"font-size: 16px; font-weight: 500; text-align: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\">${text}</div>\n </div>\n `;\n\n return overlay;\n}\n\n/**\n * Shows a loading overlay in a modal container\n */\nexport function showModalLoading(text: string = \"Processing...\"): void {\n const modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\n if (!modal) return;\n\n // Remove any existing loading overlays\n removeModalLoading();\n\n const loadingOverlay = createLoadingOverlay(text);\n modal.appendChild(loadingOverlay);\n}\n\n/**\n * Removes loading overlay from modal\n */\nexport function removeModalLoading(): void {\n const modal = document.querySelector(`.${CSS_CLASSES.MODAL}`);\n if (!modal) return;\n\n const existingOverlay = modal.querySelector(\".ww-loading-overlay\");\n if (existingOverlay) {\n existingOverlay.remove();\n }\n}\n\n/**\n * Shows a loading overlay in the product gallery container\n */\nexport function showProductLoading(\n container: HTMLElement,\n text: string = \"Generating virtual try-on...\",\n): void {\n // Remove any existing loading overlays\n removeProductLoading(container);\n\n // Make container relative if it's not already positioned\n const computedStyle = window.getComputedStyle(container);\n if (computedStyle.position === \"static\") {\n container.style.position = \"relative\";\n }\n\n const loadingOverlay = createLoadingOverlay(text);\n container.appendChild(loadingOverlay);\n}\n\n/**\n * Removes loading overlay from product container\n */\nexport function removeProductLoading(container: HTMLElement): void {\n const existingOverlay = container.querySelector(\".ww-loading-overlay\");\n if (existingOverlay) {\n existingOverlay.remove();\n }\n}\n","import { CSS_CLASSES, Z_INDEX } from \"../constants.js\";\nimport { removeElements } from \"../utils.js\";\n\nexport interface ReviewModalCallbacks {\n onRetake: () => void;\n onAccept: (imageBlob: Blob) => Promise<void>;\n}\n\nexport function showReviewModal(\n imageBlob: Blob,\n callbacks: ReviewModalCallbacks,\n): void {\n console.log(\"[WeWear VTO] Opening review modal...\");\n\n // Remove any existing modals first\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Create image URL for preview\n const imageUrl = URL.createObjectURL(imageBlob);\n\n // Create modal container\n const modal = document.createElement(\"div\");\n modal.className = CSS_CLASSES.MODAL;\n modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.95);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n z-index: ${Z_INDEX.MODAL};\n padding: 20px;\n box-sizing: border-box;\n gap: 20px;\n `;\n\n // Create review container\n const reviewContainer = document.createElement(\"div\");\n reviewContainer.style.cssText = `\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 63vh;\n background-color: #000;\n border-radius: 12px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n `;\n\n // Create image element\n const image = document.createElement(\"img\");\n image.src = imageUrl;\n image.alt = \"Review your photo\";\n image.style.cssText = `\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 12px;\n `;\n\n // Create close button\n const closeButton = document.createElement(\"button\");\n closeButton.innerHTML = \"×\";\n closeButton.style.cssText = `\n position: absolute;\n top: 15px;\n right: 15px;\n width: 40px;\n height: 40px;\n border: none;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n font-size: 24px;\n font-weight: bold;\n cursor: pointer;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n\n // Create button container\n const buttonContainer = document.createElement(\"div\");\n buttonContainer.style.cssText = `\n display: flex;\n gap: 15px;\n width: 100%;\n max-width: 500px;\n `;\n\n // Create retake button\n const retakeButton = document.createElement(\"button\");\n retakeButton.textContent = \"Retake\";\n retakeButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: rgba(255, 255, 255, 0.9);\n color: black;\n border-radius: 8px;\n border: none;\n font-size: 16px;\n font-weight: normal;\n cursor: pointer;\n `;\n\n // Create use photo button\n const usePhotoButton = document.createElement(\"button\");\n usePhotoButton.textContent = \"Use Photo\";\n usePhotoButton.style.cssText = `\n flex: 1;\n padding: 12px 24px;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n border-radius: 8px;\n border: none;\n font-size: 16px;\n font-weight: normal;\n cursor: pointer;\n `;\n\n // Add event listeners\n closeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n };\n\n retakeButton.onclick = () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n callbacks.onRetake();\n };\n\n usePhotoButton.onclick = async () => {\n URL.revokeObjectURL(imageUrl); // Clean up\n modal.remove();\n await callbacks.onAccept(imageBlob);\n };\n\n // Assemble the review modal\n buttonContainer.appendChild(retakeButton);\n buttonContainer.appendChild(usePhotoButton);\n reviewContainer.appendChild(image);\n reviewContainer.appendChild(closeButton);\n modal.appendChild(reviewContainer);\n modal.appendChild(buttonContainer);\n\n document.body.appendChild(modal);\n console.log(\"[WeWear VTO] Review modal added to DOM\");\n}\n","import { callVirtualTryOnApi } from \"./api.js\";\nimport { captureImageFromVideo, stopCamera } from \"./camera.js\";\nimport {\n type CameraModalCallbacks,\n createButton,\n createButtonContainer,\n type ReviewModalCallbacks,\n removeModalLoading,\n removeProductLoading,\n showCameraModal,\n showModalLoading,\n showProductLoading,\n showReviewModal,\n} from \"./components/index.js\";\nimport { CSS_CLASSES, DEFAULT_CONFIG } from \"./constants.js\";\nimport type { VirtualTryOnConfig } from \"./index.js\";\nimport { getCookie, removeElements } from \"./utils.js\";\n\nexport class VirtualTryOnWidget {\n private readonly config: Required<VirtualTryOnConfig>;\n private virtualTryOnImageUrl: string | null = null;\n private isShowingVirtualTryOn: boolean = false;\n private lastApiParams: {\n imageBlob: Blob;\n ww_access_token: string;\n ww_user_id: string;\n ww_product_image: string;\n } | null = null;\n private cookieCheckInterval: number | null = null;\n private cameraButton: HTMLButtonElement | null = null;\n\n constructor(config: VirtualTryOnConfig = {}) {\n this.config = {\n baseUrl: config.baseUrl || DEFAULT_CONFIG.BASE_URL,\n productPageSelector:\n config.productPageSelector || DEFAULT_CONFIG.PRODUCT_PAGE_SELECTOR,\n gallerySelector:\n config.gallerySelector || DEFAULT_CONFIG.GALLERY_SELECTOR,\n productImageSelector: config.productImageSelector || DEFAULT_CONFIG.PRODUCT_IMAGE_SELECTOR,\n buttonPosition: config.buttonPosition || DEFAULT_CONFIG.BUTTON_POSITION,\n };\n }\n\n /**\n * Initializes the virtual try-on widget on the current page\n * @returns Promise that resolves when initialization is complete\n */\n public async init(): Promise<void> {\n try {\n // Check if we're on a product page\n if (!window.location.pathname.includes(this.config.productPageSelector)) {\n return;\n }\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Ensure container has relative positioning for button placement\n if (getComputedStyle(container).position === \"static\") {\n container.style.position = \"relative\";\n }\n\n // Check required cookies\n const ww_access_token = getCookie(\"ww_access_token\");\n const ww_user_id = getCookie(\"ww_user_id\");\n const cookiesPresent = !!ww_access_token && !!ww_user_id;\n\n // Create and add the virtual try-on button\n const button = createButton(this.config.buttonPosition, async () => {\n if (this.cameraButton && !this.cameraButton.disabled) {\n await this.handleTryOnClick();\n }\n }, !cookiesPresent);\n\n // Store reference to camera button for dynamic enable/disable\n this.cameraButton = button.querySelector('.ww-camera-btn');\n container.appendChild(button);\n console.log(\"[WeWear VTO] Widget initialized successfully\");\n\n // Periodically check cookies and update button state\n this.cookieCheckInterval = window.setInterval(() => {\n const accessToken = getCookie(\"ww_access_token\");\n const userId = getCookie(\"ww_user_id\");\n const present = !!accessToken && !!userId;\n if (this.cameraButton) {\n if (present && this.cameraButton.disabled) {\n this.cameraButton.disabled = false;\n this.cameraButton.style.opacity = '1';\n this.cameraButton.style.cursor = 'pointer';\n this.cameraButton.title = '';\n } else if (!present && !this.cameraButton.disabled) {\n this.cameraButton.disabled = true;\n this.cameraButton.style.opacity = '0.5';\n this.cameraButton.style.cursor = 'not-allowed';\n this.cameraButton.title = 'Required cookies missing';\n }\n }\n }, 2000); // check every 2 seconds\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization failed:\", error);\n }\n }\n\n /**\n * Handles virtual try-on button click\n * @private\n */\n private async handleTryOnClick(): Promise<void> {\n console.log(\"[WeWear VTO] Button clicked, starting try-on process...\");\n\n try {\n // Get required data\n const ww_access_token = getCookie(\"ww_access_token\");\n const ww_user_id = getCookie(\"ww_user_id\");\n const productImageElement = document.querySelector(this.config.productImageSelector) as HTMLImageElement;\n const ww_product_image = productImageElement?.src || productImageElement?.getAttribute('data-src') || '';\n\n console.log(\"[WeWear VTO] Retrieved data:\", {\n ww_user_id,\n ww_product_image,\n ww_access_token,\n });\n\n // Validate required data\n if (!ww_user_id) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_user_id\");\n return;\n }\n\n if (!ww_product_image) {\n console.warn(\n \"[WeWear VTO] Product image not found:\",\n this.config.productImageSelector,\n );\n return;\n }\n\n if (!ww_access_token) {\n console.warn(\"[WeWear VTO] Missing required cookie: ww_access_token\");\n return;\n }\n\n // Show camera capture modal\n this.showCameraModalWithCallbacks(\n ww_access_token,\n ww_user_id,\n ww_product_image,\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Try-on request failed:\", error);\n }\n }\n\n /**\n * Shows camera modal with appropriate callbacks\n * @private\n */\n private showCameraModalWithCallbacks(\n ww_access_token: string,\n ww_user_id: string,\n ww_product_image: string,\n ): void {\n const callbacks: CameraModalCallbacks = {\n onCapture: async (video: HTMLVideoElement, canvas: HTMLCanvasElement) => {\n try {\n // Capture image from video\n const imageBlob = await captureImageFromVideo(video, canvas);\n\n // Stop camera and show review modal\n stopCamera(video);\n\n // Show review modal instead of immediately processing\n this.showReviewModalWithCallbacks(\n imageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_image,\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Image capture error:\", error);\n }\n },\n };\n\n showCameraModal(callbacks);\n }\n\n /**\n * Shows review modal with appropriate callbacks\n * @private\n */\n private showReviewModalWithCallbacks(\n imageBlob: Blob,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_image: string,\n ): void {\n const callbacks: ReviewModalCallbacks = {\n onRetake: () => {\n // Reopen camera modal\n this.showCameraModalWithCallbacks(\n ww_access_token,\n ww_user_id,\n ww_product_image,\n );\n },\n onAccept: async (acceptedImageBlob: Blob) => {\n await this.processAcceptedImage(\n acceptedImageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_image,\n );\n },\n };\n\n showReviewModal(imageBlob, callbacks);\n }\n\n /**\n * Processes the accepted image by calling the API\n * @private\n */\n private async processAcceptedImage(\n imageBlob: Blob,\n ww_access_token: string,\n ww_user_id: string,\n ww_product_image: string,\n ): Promise<void> {\n try {\n console.log(\"[WeWear VTO] Processing accepted image...\");\n\n // Show loading in the review modal first\n showModalLoading(\"Processing image...\");\n\n // Store the API parameters for potential refresh\n this.lastApiParams = {\n imageBlob,\n ww_access_token,\n ww_user_id,\n ww_product_image,\n };\n\n // Call the API with the accepted image\n const result = await callVirtualTryOnApi(\n this.config.baseUrl,\n ww_access_token,\n ww_user_id,\n ww_product_image,\n imageBlob,\n );\n\n // Remove modal loading and close modal\n removeModalLoading();\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n if (result?.imageUrl) {\n this.replaceProductImage(result.imageUrl);\n } else {\n console.error(\"[WeWear VTO] Invalid API response:\", result);\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error processing accepted image:\", error);\n // Remove loading on error\n removeModalLoading();\n }\n }\n\n /**\n * Recalls the virtual try-on API with the same parameters\n * @private\n */\n private async refreshVirtualTryOn(): Promise<void> {\n if (!this.lastApiParams) {\n console.warn(\n \"[WeWear VTO] No previous API parameters available for refresh\",\n );\n return;\n }\n\n try {\n console.log(\n \"[WeWear VTO] Refreshing virtual try-on with previous parameters...\",\n );\n\n // Show loading in the product area\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n showProductLoading(container, \"Generating new virtual try-on...\");\n }\n\n // Call the API with the stored parameters\n const result = await callVirtualTryOnApi(\n this.config.baseUrl,\n this.lastApiParams.ww_access_token,\n this.lastApiParams.ww_user_id,\n this.lastApiParams.ww_product_image,\n this.lastApiParams.imageBlob,\n );\n\n if (result?.imageUrl) {\n this.virtualTryOnImageUrl = result.imageUrl;\n\n // Find the gallery container and update the image\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n this.showVirtualTryOnImage(container);\n this.updateButtonContainer(container);\n }\n } else {\n console.error(\"[WeWear VTO] Invalid API response on refresh:\", result);\n // Remove loading on error\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n }\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error refreshing virtual try-on:\", error);\n // Remove loading on error\n const container = document.querySelector(this.config.gallerySelector);\n if (container instanceof HTMLElement) {\n removeProductLoading(container);\n }\n }\n }\n\n /**\n * Replaces the product image in the gallery with the virtual try-on result\n * @private\n */\n private replaceProductImage(imageUrl: string): void {\n try {\n // Store the virtual try-on image URL\n this.virtualTryOnImageUrl = imageUrl;\n\n // Find the gallery container\n const container = document.querySelector(this.config.gallerySelector);\n if (!container || !(container instanceof HTMLElement)) {\n console.warn(\n \"[WeWear VTO] Gallery container not found for image replacement:\",\n this.config.gallerySelector,\n );\n return;\n }\n\n // Store the original content if not already stored\n if (!container.hasAttribute(\"data-ww-original-content\")) {\n container.setAttribute(\"data-ww-original-content\", container.innerHTML);\n }\n\n // Capture original image dimensions before replacement to prevent layout shift\n const originalImg = container.querySelector('img');\n if (originalImg && !container.hasAttribute(\"data-ww-original-dimensions\")) {\n const computedStyle = window.getComputedStyle(originalImg);\n const rect = originalImg.getBoundingClientRect();\n container.setAttribute(\"data-ww-original-width\", computedStyle.width);\n container.setAttribute(\"data-ww-original-height\", computedStyle.height);\n container.setAttribute(\"data-ww-original-rect-width\", rect.width.toString());\n container.setAttribute(\"data-ww-original-rect-height\", rect.height.toString());\n container.setAttribute(\"data-ww-original-dimensions\", \"true\");\n }\n\n // Show the virtual try-on image initially\n this.showVirtualTryOnImage(container);\n\n // Replace the button container with the new multi-button version\n this.updateButtonContainer(container);\n\n console.log(\n \"[WeWear VTO] Product image replaced with virtual try-on result\",\n );\n } catch (error) {\n console.error(\"[WeWear VTO] Error replacing product image:\", error);\n }\n }\n\n /**\n * Updates the button container to show all available buttons\n * @private\n */\n private updateButtonContainer(container: HTMLElement): void {\n // Remove existing button containers\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n existingButtons.forEach((btn) => {\n btn.remove();\n });\n\n // Create new button container with all buttons\n const buttonContainer = createButtonContainer(\n this.config.buttonPosition,\n this.virtualTryOnImageUrl !== null,\n async () => {\n await this.handleTryOnClick();\n },\n async () => {\n await this.refreshVirtualTryOn();\n },\n () => {\n if (this.isShowingVirtualTryOn) {\n this.showOriginalImage(container);\n } else {\n this.showVirtualTryOnImage(container);\n }\n this.updateButtonContainer(container);\n },\n this.isShowingVirtualTryOn,\n );\n\n container.appendChild(buttonContainer);\n }\n\n /**\n * Shows the virtual try-on image in the container\n * @private\n */\n private showVirtualTryOnImage(container: HTMLElement): void {\n if (!this.virtualTryOnImageUrl) {\n console.warn(\"[WeWear VTO] No virtual try-on image URL available\");\n return;\n }\n\n // Clear existing content except buttons\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n container.innerHTML = \"\";\n\n // Get stored original dimensions to prevent layout shift\n const originalWidth = container.getAttribute(\"data-ww-original-width\") || '';\n const originalHeight = container.getAttribute(\"data-ww-original-height\") || '';\n const originalRectWidth = container.getAttribute(\"data-ww-original-rect-width\") || '';\n const originalRectHeight = container.getAttribute(\"data-ww-original-rect-height\") || '';\n\n const image = document.createElement(\"img\");\n image.src = this.virtualTryOnImageUrl;\n image.alt = \"Virtual Try-On Result\";\n\n // Use original dimensions to prevent layout shift\n let widthStyle = '100%';\n let heightStyle = '100%';\n\n // Prefer computed style dimensions, fallback to bounding rect, then container fill\n if (originalWidth && originalWidth !== 'auto' && originalWidth !== '0px') {\n widthStyle = originalWidth;\n } else if (originalRectWidth && originalRectWidth !== '0') {\n widthStyle = `${originalRectWidth}px`;\n }\n\n if (originalHeight && originalHeight !== 'auto' && originalHeight !== '0px') {\n heightStyle = originalHeight;\n } else if (originalRectHeight && originalRectHeight !== '0') {\n heightStyle = `${originalRectHeight}px`;\n }\n\n image.style.cssText = `\n width: ${widthStyle};\n height: ${heightStyle};\n object-fit: cover;\n border-radius: 8px;\n `;\n\n container.appendChild(image);\n\n // Re-add buttons\n existingButtons.forEach((btn) => {\n container.appendChild(btn);\n });\n\n this.isShowingVirtualTryOn = true;\n }\n\n /**\n * Shows the original product image in the container\n * @private\n */\n private showOriginalImage(container: HTMLElement): void {\n const originalContent = container.getAttribute(\"data-ww-original-content\");\n if (originalContent) {\n // Store existing buttons\n const existingButtons = container.querySelectorAll(\n `.${CSS_CLASSES.BUTTON_CONTAINER}`,\n );\n\n // Restore original content\n container.innerHTML = originalContent;\n\n // Re-add buttons\n existingButtons.forEach((btn) => {\n container.appendChild(btn);\n });\n }\n\n this.isShowingVirtualTryOn = false;\n }\n\n /**\n * Destroys the widget and cleans up resources\n */\n public destroy(): void {\n try {\n // Remove all buttons\n removeElements(`.${CSS_CLASSES.BUTTON_CONTAINER}`);\n\n // Remove all modals\n removeElements(`.${CSS_CLASSES.MODAL}`);\n\n // Clear interval\n if (this.cookieCheckInterval !== null) {\n clearInterval(this.cookieCheckInterval);\n this.cookieCheckInterval = null;\n }\n this.cameraButton = null;\n\n // Reset state\n this.virtualTryOnImageUrl = null;\n this.isShowingVirtualTryOn = false;\n this.lastApiParams = null;\n\n console.log(\"[WeWear VTO] Widget destroyed successfully\");\n } catch (error) {\n console.error(\"[WeWear VTO] Error during widget destruction:\", error);\n }\n }\n}\n","import type { VirtualTryOnConfig } from \"./index.js\";\nimport { VirtualTryOnWidget } from \"./widget.js\";\n\nlet widgetInstance: VirtualTryOnWidget | null = null;\n\nexport function initVirtualTryOn(config?: VirtualTryOnConfig): void {\n try {\n // Clean up any existing instance\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n }\n\n // Create and initialize new instance\n widgetInstance = new VirtualTryOnWidget(config);\n\n // Initialize immediately if DOM is ready, otherwise wait for it\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n widgetInstance?.init().catch((error) => {\n console.error(\n \"[WeWear VTO] Failed to initialize after DOM ready:\",\n error,\n );\n });\n });\n } else {\n widgetInstance.init().catch((error) => {\n console.error(\"[WeWear VTO] Failed to initialize:\", error);\n });\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Initialization error:\", error);\n }\n}\n\nexport function destroyVirtualTryOn(): void {\n try {\n if (widgetInstance) {\n widgetInstance.destroy();\n widgetInstance = null;\n console.log(\"[WeWear VTO] Widget instance destroyed\");\n }\n } catch (error) {\n console.error(\"[WeWear VTO] Error destroying widget:\", error);\n }\n}\n\nexport function getWidgetInstance(): VirtualTryOnWidget | null {\n return widgetInstance;\n}\n\nif (typeof window !== \"undefined\") {\n initVirtualTryOn();\n}\n"],"names":[],"mappings":";;;;;;IAEO,eAAe,mBAAmB,CACrC,OAAe,EACf,eAAuB,EACvB,UAAkB,EAClB,gBAAwB,EACxB,QAAc,EAAA;IAEd,IAAA,IAAI;IACA,QAAA,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE;IAC/B,QAAA,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC;IACzC,QAAA,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;YACrD,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,oBAAoB,CAAC;IAC3D,QAAA,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,eAAe,CAAC;YAEnD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,CAAA,EAAG,OAAO,qBAAqB,EAAE;IAC1D,YAAA,MAAM,EAAE,MAAM;IACd,YAAA,IAAI,EAAE,QAAQ;IACjB,SAAA,CAAC;IAEF,QAAA,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AI,OAAO,MAAM,KAAK,WAAW,EAAE;IAC/B,IAAA,gBAAgB,EAAE;IACtB;;;;;;;;;;;"}
|
package/dist/widget.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export declare class VirtualTryOnWidget {
|
|
|
4
4
|
private virtualTryOnImageUrl;
|
|
5
5
|
private isShowingVirtualTryOn;
|
|
6
6
|
private lastApiParams;
|
|
7
|
+
private cookieCheckInterval;
|
|
8
|
+
private cameraButton;
|
|
7
9
|
constructor(config?: VirtualTryOnConfig);
|
|
8
10
|
/**
|
|
9
11
|
* Initializes the virtual try-on widget on the current page
|