@wewear/virtual-try-on 1.1.0 → 1.3.0

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 ADDED
@@ -0,0 +1,2 @@
1
+ import type { VirtualTryOnResult } from "./index.js";
2
+ export declare function callVirtualTryOnApi(baseUrl: string, ww_access_token: string, ww_user_id: string, ww_product_id: string, ww_image: Blob): Promise<VirtualTryOnResult | null>;
@@ -0,0 +1,3 @@
1
+ export declare function startCamera(video: HTMLVideoElement, loadingIndicator: HTMLElement, captureButton: HTMLButtonElement): Promise<void>;
2
+ export declare function stopCamera(video: HTMLVideoElement): void;
3
+ export declare function captureImageFromVideo(video: HTMLVideoElement, canvas: HTMLCanvasElement): Promise<Blob>;
@@ -0,0 +1,2 @@
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;
@@ -0,0 +1,4 @@
1
+ export interface CameraModalCallbacks {
2
+ onCapture: (video: HTMLVideoElement, canvas: HTMLCanvasElement) => Promise<void>;
3
+ }
4
+ export declare function showCameraModal(callbacks: CameraModalCallbacks): void;
@@ -0,0 +1 @@
1
+ export declare function showImageModal(imageUrl: string): void;
@@ -0,0 +1,4 @@
1
+ export { createButton, createButtonContainer } from "./button.js";
2
+ export { type CameraModalCallbacks, showCameraModal } from "./camera-modal.js";
3
+ export { createLoadingOverlay, removeModalLoading, removeProductLoading, showModalLoading, showProductLoading, } from "./loading-overlay.js";
4
+ export { type ReviewModalCallbacks, showReviewModal } from "./review-modal.js";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Creates a loading overlay that can be shown in different containers
3
+ */
4
+ export declare function createLoadingOverlay(text?: string): HTMLElement;
5
+ /**
6
+ * Shows a loading overlay in a modal container
7
+ */
8
+ export declare function showModalLoading(text?: string): void;
9
+ /**
10
+ * Removes loading overlay from modal
11
+ */
12
+ export declare function removeModalLoading(): void;
13
+ /**
14
+ * Shows a loading overlay in the product gallery container
15
+ */
16
+ export declare function showProductLoading(container: HTMLElement, text?: string): void;
17
+ /**
18
+ * Removes loading overlay from product container
19
+ */
20
+ export declare function removeProductLoading(container: HTMLElement): void;
@@ -0,0 +1,5 @@
1
+ export interface ReviewModalCallbacks {
2
+ onRetake: () => void;
3
+ onAccept: (imageBlob: Blob) => Promise<void>;
4
+ }
5
+ export declare function showReviewModal(imageBlob: Blob, callbacks: ReviewModalCallbacks): void;
@@ -0,0 +1,37 @@
1
+ /** Default configuration constants */
2
+ export declare const DEFAULT_CONFIG: {
3
+ readonly BASE_URL: "https://virtual-try-on-widget.vercel.app";
4
+ readonly PRODUCT_PAGE_SELECTOR: "/product/";
5
+ readonly GALLERY_SELECTOR: ".woocommerce-product-gallery__image";
6
+ readonly SKU_SELECTOR: ".sku";
7
+ readonly BUTTON_POSITION: "bottom-right";
8
+ };
9
+ /** CSS class names for consistent styling */
10
+ export declare const CSS_CLASSES: {
11
+ readonly BUTTON_CONTAINER: "wewear-vto-button-container";
12
+ readonly BUTTON: "wewear-vto-button";
13
+ readonly MODAL: "wewear-vto-modal";
14
+ };
15
+ /** Z-index values for proper layering */
16
+ export declare const Z_INDEX: {
17
+ readonly BUTTON: 10;
18
+ readonly MODAL: 99999;
19
+ };
20
+ /** Camera constraints for optimal capture */
21
+ export declare const CAMERA_CONSTRAINTS: {
22
+ readonly video: {
23
+ readonly width: {
24
+ readonly ideal: 1280;
25
+ };
26
+ readonly height: {
27
+ readonly ideal: 720;
28
+ };
29
+ readonly facingMode: "user";
30
+ };
31
+ readonly audio: false;
32
+ };
33
+ /** Image capture settings */
34
+ export declare const IMAGE_SETTINGS: {
35
+ readonly FORMAT: "image/jpeg";
36
+ readonly QUALITY: 0.8;
37
+ };
package/dist/index.d.ts CHANGED
@@ -1,37 +1,18 @@
1
- /**
2
- * WeWear Virtual Try-On Widget
3
- *
4
- * A professional virtual try-on widget for e-commerce integration.
5
- * Provides seamless virtual try-on experiences for product pages.
6
- *
7
- * @version 1.0.0
8
- * @author WeWear
9
- */
10
1
  export interface VirtualTryOnConfig {
11
- /** Base URL for the virtual try-on API service */
12
2
  baseUrl?: string;
13
- /** URL pattern to identify product pages (default: '/product/') */
14
3
  productPageSelector?: string;
15
- /** CSS selector for the product gallery container */
16
4
  gallerySelector?: string;
17
- /** CSS selector for the product SKU element */
18
5
  skuSelector?: string;
19
- /** Position of the virtual try-on button */
20
6
  buttonPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
21
7
  }
22
8
  export interface VirtualTryOnResult {
23
- /** URL of the generated virtual try-on image */
24
- imageUrl?: string;
25
- /** Error message if the operation failed */
26
- error?: string;
9
+ imageUrl: string;
27
10
  }
28
11
  export interface VirtualTryOnAPIRequest {
29
- /** Authentication token (optional) */
30
- ww_access_token?: string;
31
- /** User identifier (required) */
12
+ ww_access_token: string;
32
13
  ww_user_id: string;
33
- /** Product identifier (required) */
34
14
  ww_product_id: string;
15
+ ww_image: Blob;
35
16
  }
36
- export { destroyVirtualTryOn, initVirtualTryOn } from "./installer.js";
17
+ export { destroyVirtualTryOn, getWidgetInstance, initVirtualTryOn, } from "./installer.js";
37
18
  export { VirtualTryOnWidget } from "./widget.js";