Skip to main content

Class: ChamevoJS

Defined in: core/src/services/ChamevoJS.ts:128

Extends

Constructors

Constructor

new ChamevoJS(options): ChamevoJS;

Defined in: core/src/services/ChamevoJS.ts:491

Parameters

ParameterType
optionsChamevoJSOptions

Returns

ChamevoJS

Overrides

EventEmitter<ChamevoEvents>.constructor

Properties

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
optionsServicereadonlyOptionsServiceundefinedOptions service for configuration cascade.-core/src/services/ChamevoJS.ts:132
fontServicereadonlyFontServiceundefinedFont loading service.-core/src/services/ChamevoJS.ts:134
pricingServicereadonlyPricingServiceundefinedPricing rule evaluator.-core/src/services/ChamevoJS.ts:136
uploadServicereadonlyUploadServiceundefinedFile upload service (validation, server upload, quality).-core/src/services/ChamevoJS.ts:138
canvaspublicChamevoCanvasundefinedThe shared canvas instance.-core/src/services/ChamevoJS.ts:141
viewspublicChamevoView[][]All view instances for the current product.-core/src/services/ChamevoJS.ts:144
currentViewIndexpublicnumber0Index of the currently active view.-core/src/services/ChamevoJS.ts:146
currentViewpublicChamevoView | nullnullCurrently active view instance.-core/src/services/ChamevoJS.ts:148
productCreatedpublicbooleanfalseWhether a product has been fully loaded.-core/src/services/ChamevoJS.ts:150
orderQuantitypublicnumber1Order quantity multiplier for pricing.-core/src/services/ChamevoJS.ts:152
currentPricepublicnumber0Total price (with quantity multiplier).-core/src/services/ChamevoJS.ts:155
singleProductPricepublicnumber0Per-unit price from view element prices (without quantity).-core/src/services/ChamevoJS.ts:157
pricingRulesPricepublicnumber0Additional price from pricing rules.-core/src/services/ChamevoJS.ts:159
colorLinkGroupspublicRecord<string, ColorLinkGroup>{}Color link groups for cross-view color synchronization.-core/src/services/ChamevoJS.ts:164
namesNumberspublicNamesNumbersEntry[][]Product-level Names & Numbers roster.-core/src/services/ChamevoJS.ts:167
_bulkVariationsDatapublicobject[] | nullnullBulk variations data set by cv-module-bulk-variations. Used in getOrder().-core/src/services/ChamevoJS.ts:170
_listenersprotectedMap<keyof ChamevoEvents, Set<Handler<any>>>undefined-EventEmitter._listenerscore/src/services/EventEmitter.ts:36

Accessors

currentOptions

Get Signature

get currentOptions(): ChamevoOptions;

Defined in: core/src/services/ChamevoJS.ts:176

Get fully resolved current options. Cascade: DEFAULTS → mainOptions → viewOptions → printAreaProfile

Returns

ChamevoOptions


uploadsToServer

Get Signature

get uploadsToServer(): boolean;

Defined in: core/src/services/ChamevoJS.ts:246

Whether uploads should go to a server (fileServerURL is configured).

Returns

boolean


hasActiveImageFilter

Get Signature

get hasActiveImageFilter(): boolean;

Defined in: core/src/services/ChamevoJS.ts:321

Whether a server-side image filter is currently active. Used by Pixabay / AI modules to decide whether a remote image needs to be routed through fileServerURL before being added to the canvas.

Returns

boolean


isLoadingProduct

Get Signature

get isLoadingProduct(): boolean;

Defined in: core/src/services/ChamevoJS.ts:787

Whether a product is currently being loaded.

Returns

boolean


initialProduct

Get Signature

get initialProduct(): CVProduct | null;

Defined in: core/src/services/ChamevoJS.ts:1740

Get a deep copy of the original product data as loaded. Used by reset-product to reload the initial state.

Returns

CVProduct | null

Methods

getAvailableFonts()

getAvailableFonts(): object[];

Defined in: core/src/services/ChamevoJS.ts:208

Fonts offered in the pickers (toolbar, properties panel, layers) for the element being edited.

The global font registry (mainOptions.fonts) is filtered by the assigned fonts of the most specific scope that defines them, with precedence: selected element's print-area profile → current view → main/master. The font analogue of how the Graphics module filters categories by designCategories. Empty/absent at every scope = show every loaded font.

Each scope's value is read DIRECTLY (raw modulesConfig.text.fonts or the legacy top-level assignedFonts) rather than through getCurrentOptions, because a view serialised with an empty modulesConfig: [] (PHP empties become arrays) would clobber the merged value — and a profile that inherits its fonts from master carries no assignedFonts of its own, so the master value (held on main options) must remain reachable as the fallback.

Matching is case-insensitive. Font loading and variant resolution still use the full registry, so an element already set to a font outside the scope's assignment keeps rendering — this only narrows what the pickers offer.

Independent of getUsedFonts, which intentionally reads the full mainOptions.fonts registry (never this filtered list) so export/print metadata covers every font an element actually uses.

Returns

object[]


buildFileServerURL()

buildFileServerURL(): string | null;

Defined in: core/src/services/ChamevoJS.ts:271

Build the file server URL for the current request.

Resolves the effective Imagick filter to apply server-side, with precedence (highest first):

  1. Engraving mode on the active print profile — industry.opts.filter + industry.opts.invert.
  2. imagick_filter on the active print profile (cascades through currentOptions from the current print area).
  3. Post-level fallback at modulesConfig.uploads.imagickFilter.

Always recomputed per call so the current print area's print profile decides the filter — this is why upload/Pixabay/AI modules must call this every time they hit the server, not cache the URL at load time.

Returns null if fileServerURL is not set.

Returns

string | null


filterRemoteImage()

filterRemoteImage(sourceUrl): Promise<string>;

Defined in: core/src/services/ChamevoJS.ts:333

Route a remote image URL through fileServerURL for server-side filter application. Returns the filtered image URL, or the original URL if no filter is configured / the request fails / the server is not configured. Used by Pixabay and AI image source modules so their images receive the same Imagick filter that uploads receive.

Parameters

ParameterType
sourceUrlstring

Returns

Promise<string>


applyImageFilter()

applyImageFilter(element, filterId): Promise<void>;

Defined in: core/src/services/ChamevoJS.ts:359

Apply a server-side image filter to an image element. Sends the original image URL + filter ID to fileServerURL, receives back a processed image URL, and swaps the element's source.

Pass false to revert the element to its original (unfiltered) image.

Parameters

ParameterTypeDescription
elementICVElementThe image element (must be CVImage with getType() === 'image')
filterIdstring | falseFilter ID string, or false to remove the current filter

Returns

Promise<void>


removeBackground()

removeBackground(element): Promise<void>;

Defined in: core/src/services/ChamevoJS.ts:407

Remove background from a raster image using the AI service.

Parameters

ParameterType
elementICVElement

Returns

Promise<void>


upscaleImage()

upscaleImage(element, scale): Promise<void>;

Defined in: core/src/services/ChamevoJS.ts:441

Upscale an image using AI super-resolution.

Parameters

ParameterTypeDefault value
elementICVElementundefined
scalenumber2

Returns

Promise<void>


setProxyFileServer()

setProxyFileServer(url): void;

Defined in: core/src/services/ChamevoJS.ts:517

Parameters

ParameterType
urlstring

Returns

void


_initLabels()

_initLabels(opts?): void;

Defined in: core/src/services/ChamevoJS.ts:529

Initialize labels from options. Handles both new labels and legacy langJSON (object form).

Parameters

ParameterType
opts?Partial<ChamevoOptions>

Returns

void


loadProduct()

loadProduct(productOrViews, replaceInitialElements?): Promise<void>;

Defined in: core/src/services/ChamevoJS.ts:570

Load a product into the designer. Accepts either a CVProduct object or a flat array of views (legacy format). Clears any existing product, creates views sequentially (cascade pattern), and emits productCreate when all views are loaded.

Parameters

ParameterType
productOrViews| CVView | CVView[] | CVProduct
replaceInitialElements?boolean

Returns

Promise<void>


abortProductLoading()

abortProductLoading(): void;

Defined in: core/src/services/ChamevoJS.ts:779

Abort the current product loading operation.

Returns

void


reset()

reset(): void;

Defined in: core/src/services/ChamevoJS.ts:795

Clear all views and reset state. Does NOT clear the canvas — views handle their own deactivation.

Returns

void


selectView()

selectView(index): Promise<void>;

Defined in: core/src/services/ChamevoJS.ts:843

Select and activate a view by index. Deactivates the current view and activates the new one on the shared canvas.

Parameters

ParameterType
indexnumber

Returns

Promise<void>


lockView()

lockView(index): void;

Defined in: core/src/services/ChamevoJS.ts:936

Lock a view (mark as optional/inactive). Locked views are excluded from pricing and export.

Parameters

ParameterType
indexnumber

Returns

void


unlockView()

unlockView(index): void;

Defined in: core/src/services/ChamevoJS.ts:962

Unlock a view (make it active/editable). Unlocked views contribute to pricing and export.

Parameters

ParameterType
indexnumber

Returns

void


addView()

addView(options?): Promise<number>;

Defined in: core/src/services/ChamevoJS.ts:988

Add a dynamic view with a print area at the specified dimensions. Dynamic views only work in combination with print areas. Returns the new view index, or -1 if enableDynamicViews is disabled.

Parameters

ParameterType
options?{ title?: string; width?: number; height?: number; insertAfter?: number; }
options.title?string
options.width?number
options.height?number
options.insertAfter?number

Returns

Promise<number>


removeView()

removeView(index): Promise<boolean>;

Defined in: core/src/services/ChamevoJS.ts:1058

Remove a dynamic view. Cannot remove the last view or non-dynamic views.

Parameters

ParameterType
indexnumber

Returns

Promise<boolean>


duplicateView()

duplicateView(index): Promise<number>;

Defined in: core/src/services/ChamevoJS.ts:1103

Duplicate a view. The duplicate is always marked as dynamic.

Parameters

ParameterType
indexnumber

Returns

Promise<number>


reorderViews()

reorderViews(fromIndex, toIndex): Promise<void>;

Defined in: core/src/services/ChamevoJS.ts:1155

Reorder views by moving a view from one index to another. Syncs all parallel arrays and remaps colorLinkGroup view indices.

Parameters

ParameterType
fromIndexnumber
toIndexnumber

Returns

Promise<void>


resizeView()

resizeView(
index,
width,
height): void;

Defined in: core/src/services/ChamevoJS.ts:1215

Resize a dynamic view and its print area.

Parameters

ParameterType
indexnumber
widthnumber
heightnumber

Returns

void


isViewCustomized()

isViewCustomized(viewIndex): boolean;

Defined in: core/src/services/ChamevoJS.ts:1248

Whether a specific view has been customized (net change depth > 0). Respects undo: if all changes are undone the view is no longer customized.

Parameters

ParameterType
viewIndexnumber

Returns

boolean


isProductCustomized()

isProductCustomized(): boolean;

Defined in: core/src/services/ChamevoJS.ts:1257

Whether the product meets the customizationRequiredRule.

  • 'any' (default): at least one view has been customized
  • 'all': every view has been customized

Returns

boolean


getCustomizationState()

getCustomizationState(): object;

Defined in: core/src/services/ChamevoJS.ts:1270

Get full customization state for UI display.

Returns

object

NameTypeDefined in
rule"any" | "all"core/src/services/ChamevoJS.ts:1270
viewsboolean[]core/src/services/ChamevoJS.ts:1270
validbooleancore/src/services/ChamevoJS.ts:1270

getElements()

getElements(viewIndex?, type?): SerializedElement[];

Defined in: core/src/services/ChamevoJS.ts:1395

Get serialized elements across views.

Parameters

ParameterTypeDefault valueDescription
viewIndex?numberundefinedSpecific view index, or undefined for all views.
type?string'all'Filter by type: 'all', 'text', or 'image'.

Returns

SerializedElement[]


getCustomElements()

getCustomElements(type, viewIndex?): StoredElementRef[];

Defined in: core/src/services/ChamevoJS.ts:1416

Get custom-added elements with their view index.

Parameters

ParameterTypeDefault value
typestring'all'
viewIndex?numberundefined

Returns

StoredElementRef[]


getFixedElements()

getFixedElements(type, viewIndex?): StoredElementRef[];

Defined in: core/src/services/ChamevoJS.ts:1446

Get fixed elements (persist across product loads) with their view index.

Parameters

ParameterTypeDefault value
typestring'all'
viewIndex?numberundefined

Returns

StoredElementRef[]


calculatePrice()

calculatePrice(considerQuantity): number;

Defined in: core/src/services/ChamevoJS.ts:1497

Calculate total price from all views + pricing rules × quantity. Ported from legacy FancyProductDesigner.calculatePrice.

Parameters

ParameterTypeDefault value
considerQuantitybooleantrue

Returns

number


getPricingBreakdown()

getPricingBreakdown(): PricingLineItem[];

Defined in: core/src/services/ChamevoJS.ts:1646

Get the current pricing rules breakdown from the last price calculation.

Returns

PricingLineItem[]


setOrderQuantity()

setOrderQuantity(quantity): void;

Defined in: core/src/services/ChamevoJS.ts:1653

Set the order quantity and recalculate price.

Parameters

ParameterType
quantitynumber

Returns

void


setBulkVariations()

setBulkVariations(data): void;

Defined in: core/src/services/ChamevoJS.ts:1663

Store bulk variations data from cv-module-bulk-variations. Called automatically when rows change. Included in getOrder().

Parameters

ParameterType
dataobject[] | null

Returns

void


getProduct()

getProduct(): CVProduct | null;

Defined in: core/src/services/ChamevoJS.ts:1673

Get the current product as a serializable CVProduct object. Includes product-level metadata (id, title, thumbnail) and all views.

Returns

CVProduct | null


clearFontCache()

clearFontCache(fontFamily?): void;

Defined in: core/src/services/ChamevoJS.ts:1691

Clear FabricJS global font cache and recalculate text dimensions. Call this if text bounding boxes appear incorrect (e.g. after loading custom fonts).

Parameters

ParameterTypeDescription
fontFamily?stringOptional font family to clear. Clears all fonts if omitted.

Returns

void


getOrder()

getOrder(): object;

Defined in: core/src/services/ChamevoJS.ts:1714

Get order data including product, used fonts, used colors, and bulk variations.

Returns

object

NameTypeDefined in
productCVProduct | nullcore/src/services/ChamevoJS.ts:1715
usedFontsFontInfo[]core/src/services/ChamevoJS.ts:1716
usedColorsColorInfo[]core/src/services/ChamevoJS.ts:1717
bulkVariationsobject[] | nullcore/src/services/ChamevoJS.ts:1718

getViewsDataURL()

getViewsDataURL(options): Promise<string[]>;

Defined in: core/src/services/ChamevoJS.ts:1755

Export each view as a data URL. Temporarily switches views to render each one, then returns to the original.

Parameters

ParameterTypeDescription
options{ format?: "png" | "jpeg"; backgroundColor?: string; multiplier?: number; maxDimension?: number; cropToPrintArea?: boolean; preserveSelection?: boolean; viewIndices?: number[]; }Export options (format, backgroundColor, multiplier, maxDimension). maxDimension caps the output to the specified max width/height per view, computing the multiplier dynamically from each view's stage size.
options.format?"png" | "jpeg"-
options.backgroundColor?string-
options.multiplier?number-
options.maxDimension?numberCap output thumbnails to this max width or height (whichever is larger).
options.cropToPrintArea?booleanCrop each view's export to its first print area. Strips print area UI chrome.
options.preserveSelection?booleanKeep the active selection on the canvas (skip discardActiveObject).
options.viewIndices?number[]Only export views at these indices. Out-of-range indices are silently skipped. When omitted or empty, all views are exported.

Returns

Promise<string[]>

Array of data URL strings, one per view.


getProductDataURL()

getProductDataURL(options): Promise<string>;

Defined in: core/src/services/ChamevoJS.ts:1963

Export all views composited into a single data URL (stacked vertically).

Parameters

ParameterTypeDescription
options{ format?: "png" | "jpeg"; backgroundColor?: string; multiplier?: number; }Export options (format, backgroundColor, multiplier).
options.format?"png" | "jpeg"-
options.backgroundColor?string-
options.multiplier?number-

Returns

Promise<string>

A single data URL with all views stacked.


print()

print(): Promise<boolean>;

Defined in: core/src/services/ChamevoJS.ts:2011

Open a popup window with all view images and trigger the browser print dialog.

Returns

Promise<boolean>

true if popup opened successfully, false if blocked.


getUsedFonts()

getUsedFonts(): FontInfo[];

Defined in: core/src/services/ChamevoJS.ts:2056

Get all fonts used in the current product.

Returns

FontInfo[]


getUsedColors()

getUsedColors(viewIndex?): string[];

Defined in: core/src/services/ChamevoJS.ts:2107

Get all unique colors used in the product.

Parameters

ParameterTypeDescription
viewIndex?numberSpecific view, or undefined for all views.

Returns

string[]


handleImageUpload()

handleImageUpload(
source,
title,
params): Promise<ICVElement | null>;

Defined in: core/src/services/ChamevoJS.ts:2147

Add an uploaded image to the canvas with before/after hook events.

Emits beforeImageUpload (async, cancellable via cancel()) before adding the element, and afterImageUpload after it's been added.

Parameters

ParameterTypeDescription
sourcestringImage URL or data URI.
titlestringDisplay title for the element.
paramsRecord<string, unknown>Additional element parameters.

Returns

Promise<ICVElement | null>

The created element, or null if cancelled by a listener.


on()

on<K>(event, handler): void;

Defined in: core/src/services/EventEmitter.ts:41

Subscribe to an event.

Type Parameters

Type Parameter
K extends keyof ChamevoEvents

Parameters

ParameterType
eventK
handlerHandler<ChamevoEvents[K]>

Returns

void

Inherited from

EventEmitter.on

off()

off<K>(event, handler): void;

Defined in: core/src/services/EventEmitter.ts:53

Unsubscribe from an event.

Type Parameters

Type Parameter
K extends keyof ChamevoEvents

Parameters

ParameterType
eventK
handlerHandler<ChamevoEvents[K]>

Returns

void

Inherited from

EventEmitter.off

once()

once<K>(event, handler): void;

Defined in: core/src/services/EventEmitter.ts:60

Subscribe to an event, but only fire the handler once.

Type Parameters

Type Parameter
K extends keyof ChamevoEvents

Parameters

ParameterType
eventK
handlerHandler<ChamevoEvents[K]>

Returns

void

Inherited from

EventEmitter.once

emit()

emit<K>(...args): void;

Defined in: core/src/services/EventEmitter.ts:74

Emit an event.

  • For void events: emit('ready')
  • For payload events: emit('elementAdd', { element, view })

Type Parameters

Type Parameter
K extends keyof ChamevoEvents

Parameters

ParameterType
...argsChamevoEvents[K] extends void ? [K] : [K, ChamevoEvents[K]]

Returns

void

Inherited from

EventEmitter.emit

removeAllListeners()

removeAllListeners(event?): void;

Defined in: core/src/services/EventEmitter.ts:87

Remove all listeners for a specific event, or all events if no event is specified.

Parameters

ParameterType
event?keyof ChamevoEvents

Returns

void

Inherited from

EventEmitter.removeAllListeners