/** * @module Zakeke */ import { FocusAttributesEventListener } from '@zakeke/zakeke-3d-core'; import { EventMessage, FontFamily, Group, Item, NftForm, NftSettings, OnBeforeSendDataToParent, PrintingMethodsRestrictions, Product, SceneAnimationsConfig, Settings, Template, TemplateMacroCategory, TextSanitationResult, UIConfig, VisibleEventMessage } from '..'; import { Camera, ImageMacroCategory, ProductQuantityRule, SellerSettings, TemplateUploadRestrictions, ZakekeImage, AIPresetCategory, AIPreset, AIProductStagingRule, AIProductStagingOptions, AIProductStagingResult, AIVirtualTryOnOptions, AIVirtualTryOnResult, AIVirtualModelRule } from '../models'; interface RestrictionColor { colorCode: string; isDefault: boolean; } interface CustomPreviewSize { customCartPreviewWidth: number; customCartPreviewHeight: number; } interface ThemeCompositions { name: string; docID: string; previewImageUrl: string; tags: string[]; } export type { AIPresetCategory, AIPreset, AIProductStagingRule, AIProductStagingOptions, AIProductStagingResult, AIVirtualTryOnOptions, AIVirtualTryOnResult }; /** * Contains all the data and methods to control a Zakeke configuration */ export interface Zakeke { /** * @internal */ internalProduct: MPlaza.Model | null; /** * @internal */ internalScene: Zakeke.Scene | null; /** * @internal */ internalCurrentTemplate: MPlaza.Design | null | undefined; userSettings: Settings | null; /** * The current price of the configuration plus the product price */ price: number; isOutOfStock: boolean; culture: string; currency: string; isSceneLoading: boolean; isAddToCartLoading: boolean; isInfoPointContentVisible: boolean; imagesMacroCategories: ImageMacroCategory[]; isViewerReady: boolean; fonts: FontFamily[]; defaultFontID: number | null; disableTextColors: boolean; defaultColor: string; textColors: RestrictionColor[]; groups: Group[]; templates: Template[]; loadedComposition: { templateName: string; attributesOptions: Map; selectedCategoryID: number | null; } | null; currentTemplate: Template | null; items: Item[]; productName: string; productCode: string; product: Product | null; isCompositionSaving: boolean; cameras: Camera[]; sellerSettings: SellerSettings | null; quantityRule: ProductQuantityRule | null; eventMessages: EventMessage[] | null; personalizedMessages: EventMessage[] | null; visibleEventMessages: VisibleEventMessage[]; isAssetsLoading: boolean; draftCompositions: ThemeCompositions[] | null; additionalCustomProperties: { name: string; value: number; label: string; formatString: string; }[] | null; currentAttributesSelection: object | null; currentCompositionInfo: { compositionId: string | null; compositionName: string | null; compositionTags: string[] | null; } | null; nftSettings: NftSettings | null; useLegacyScreenshot: boolean; isAIEnabled: boolean; uiConfig: UIConfig | null; animationsConfig: SceneAnimationsConfig | null; backgroundColor: string; removeBackground: boolean; deepARsceneGLBUrl: string | null; shouldLoadDesign: boolean | null; getDeepARDesktopIframeUrl: () => Promise; setMouseWheelZoomEnabled: (enabled: boolean) => void; setCameraPinchingZoom: (toggle: boolean) => void; selectOption: (optionId: number) => void; /** * @internal */ internalAppendViewer: (container: HTMLElement) => void; getPrintingMethodsRestrictions: () => PrintingMethodsRestrictions; designUpdate: () => void; createQuote: (formData: any) => Promise; setTemplate: (templateId: number) => Promise; isAreaVisible: (areaId: number) => boolean; quantity: number; saveTemplate: (templateName: string, selectedCategoryID: number | null, attributesOptions: Map, save2Ddesign?: boolean) => Promise; addToCart: (additionalProperties: Record, OnBeforeSendDataToParent?: (data: OnBeforeSendDataToParent) => Promise>, legacyScreenshot?: boolean, nftForm?: NftForm, saveDesignFromTemplateEditor?: boolean) => Promise; /** * Create a PDF of the current configuration * @returns The URL of the PDF */ getPDF: () => Promise; getOnlineScreenshot: (width: number, height: number, legacyScreenshot?: boolean, backgroundColor?: string, padding?: number) => Promise<{ originalUrl: string; rewrittenUrl: string; }>; setCamera: (id: string, onlyAngleOfView?: boolean, animate?: boolean) => void; setCameraByName: (name: string, onlyAngleOfView?: boolean, animate?: boolean) => void; setCameraZoomEnabled: (enabled: boolean) => void; resetCameraPivot: () => void; setCameraPivot: (meshId: string) => void; fullyLoadFont: (fontFamily: string | FontFamily) => Promise; sanitizeString: (family: FontFamily, text: string) => string; getSanitationText: (family: FontFamily, text: string) => TextSanitationResult; getImages: (categoryId: number) => Promise; getMacroCategories: () => Promise; previewOnly__setItemImageFromBase64: (guid: string, base64: string) => void; setItemImageFromFile: (guid: string, file: File) => Promise; addItemImage: (id: number, areaId: number) => Promise; setItemSize: (guid: string, width: number, height: number) => Promise; setItemConstraints: (guid: string, constraints: { canMove?: boolean; canRotate?: boolean; canResize?: boolean; canDelete?: boolean; }) => void; /** * Upload an image and get the uploaded image * @param file The file to upload * @param progress A callback to get the upload progress * @returns The uploaded image */ createImage: (file: File, progress?: (percentage: number) => void) => Promise; createImageFromUrl: (url: string) => Promise; setItemImage: (guid: string, imageId: number) => Promise; setItemFontFamily: (guid: string, fontFamily: string) => void; setItemColor: (guid: string, color: string) => void; setItemBold: (guid: string, bold: boolean, fontFamily: FontFamily) => void; setItemItalic: (guid: string, italic: boolean, fontFamily: FontFamily) => void; setItemTextOnPath: (guid: string, areaId: number, value: boolean) => void; setItemText: (guid: string, text: string) => string; addItemText: (settings: { text: string; fontFamily: string; }, areaId: number) => Promise; /** * Remove an item from the customization * @param guid The guid of the item to remove */ removeItem: (guid: string) => Promise; setQuantity: (quantity: number) => void; getShareCompositionUrl: () => Promise; saveComposition: (customPreviewSize?: CustomPreviewSize, saveDesignFromTemplateEditor?: boolean) => Promise; loadComposition: (id: string) => Promise; switchFullscreen: () => void; openSecondScreen: () => void; isFullscreenMode: boolean; zoomIn: () => void; zoomOut: () => void; updateView: (adjustCamera?: boolean) => void; stopAllAnimations: () => void; hasAnimations: () => boolean; playAnimations: () => void; setHighlightSettings: (settings: { color: string; size: number; }) => void; hasExplodedMode: () => boolean; isExplodedMode: boolean; setExplodedMode: (exploded: boolean) => void; getMeshIDbyName: (name: string) => string | undefined | null; hideMeshAndSaveState: (meshId: string) => void; restoreMeshVisibility: (meshId: string) => void; setMeshDesignVisibility: (meshId: string, visible: boolean) => void; clearListeners: () => void; addFocusAttributesListener: (listenerFunction: FocusAttributesEventListener) => void; focusAttribute: (attributeId: number) => void; highlightGroup: (groupId: number) => void; highlightAttribute: (attributeId: number) => void; getQrCodeArUrl: (device: 'iOS' | 'Android') => Promise; getMobileArUrl: () => Promise; openArMobile: (url: string) => void; isSceneArEnabled: () => boolean; isArDeviceCompliant: () => boolean; IS_ANDROID: boolean; IS_IOS: boolean; setBackgroundColor: (color: string, alpha: number) => void; getTryOnUrl: (tryOnUrl?: string) => Promise; isSceneTryOnEnabled: () => boolean; setCameraLocked: (isBlocked: boolean) => void; getTemplateUploadRestrictions: (areaId: number) => TemplateUploadRestrictions; saveDraftsComposition: (name: string, tags: string[], isCopy?: boolean) => Promise; loadSavedComposition: (docID: string) => Promise; deleteSavedComposition: (docId: string) => Promise; exportSceneToGlb: () => Promise; reset: () => Promise; undo: () => Promise; redo: () => Promise; getCopyrightMessageAccepted: () => boolean; setCopyrightMessageAccepted: (copyrightMandatoryCheckbox: boolean) => void; validationNFTEmail: (email: string) => boolean; validationNFTWalletAddress: (walletAddress: string) => boolean; templateMacroCategories: TemplateMacroCategory[] | null; applyTemplate: (templateGroupCompositionId: number) => Promise; configureByAI: (text: string) => Promise; isAIStudioShoppingPreviewEnabled: boolean; isAIStudioEnabled: boolean; isAiEditorEnabled: boolean; isAiProductStagingEnabled: boolean; isAiVtoEnabled: boolean; startAIStudio: () => Promise; getAIPresetCategories: (presetType: string) => Promise; getAIPresetPresets: (presetType: string) => Promise; getApplicableAIStagingRules: (options: { productID?: number; printTypeID?: number; }) => Promise; getApplicableAIVirtualModelRules: (options: { productID?: number; printTypeID?: number; }) => Promise; generateAIProductStaging: (options: AIProductStagingOptions) => Promise; generateAIVirtualTryon: (options: AIVirtualTryOnOptions) => Promise; hasVTryOnEnabled: boolean; canUseTryOn: boolean; canUsePD: boolean; getTryOnSettings: () => Zakeke.TryOnSettings | undefined; isTryOnMeshVisible: boolean; isMandatoryPD: boolean; isVisibleMeshShownForTryOn: boolean; setPDDistance: (distance: number) => void; pdDistance: () => number; exportTryOnMeshToGlb: () => Promise; moveItemUp: (itemGuid: string) => void; moveItemDown: (itemGuid: string) => void; getPrintingMethods: () => Array<{ printMethodId: number; name: string; }>; setPrintingMethod: (printingMethodId: number, areaId: number) => void; getFontWeights: (font: FontFamily) => { normal: boolean; bold: boolean; italic: boolean; italicBold: boolean; normalWeight: number; boldWeight: number; italicWeight: number; italicBoldWeight: number; }; checkFontSupports: (fontName: string, needsBold: boolean, needsItalic: boolean) => { canKeepStyles: boolean; supportsBold: boolean; supportsItalic: boolean; }; T_static: (str: string) => string; T_dynamic: (str: string) => string; areTranslationsLoaded: boolean; /** * Forces a resize of the 3D viewer canvas to match its container. * Call this after all UI components have finished rendering to fix * canvas buffer/display size mismatches caused by layout reflows. */ forceViewerResize: () => void; }