Class: ChamevoJS
Defined in: core/src/services/ChamevoJS.ts:128
Extends
EventEmitter<ChamevoEvents>
Constructors
Constructor
new ChamevoJS(options): ChamevoJS;
Defined in: core/src/services/ChamevoJS.ts:491
Parameters
| Parameter | Type |
|---|---|
options | ChamevoJSOptions |
Returns
ChamevoJS
Overrides
EventEmitter<ChamevoEvents>.constructor
Properties
| Property | Modifier | Type | Default value | Description | Inherited from | Defined in |
|---|---|---|---|---|---|---|
optionsService | readonly | OptionsService | undefined | Options service for configuration cascade. | - | core/src/services/ChamevoJS.ts:132 |
fontService | readonly | FontService | undefined | Font loading service. | - | core/src/services/ChamevoJS.ts:134 |
pricingService | readonly | PricingService | undefined | Pricing rule evaluator. | - | core/src/services/ChamevoJS.ts:136 |
uploadService | readonly | UploadService | undefined | File upload service (validation, server upload, quality). | - | core/src/services/ChamevoJS.ts:138 |
canvas | public | ChamevoCanvas | undefined | The shared canvas instance. | - | core/src/services/ChamevoJS.ts:141 |
views | public | ChamevoView[] | [] | All view instances for the current product. | - | core/src/services/ChamevoJS.ts:144 |
currentViewIndex | public | number | 0 | Index of the currently active view. | - | core/src/services/ChamevoJS.ts:146 |
currentView | public | ChamevoView | null | null | Currently active view instance. | - | core/src/services/ChamevoJS.ts:148 |
productCreated | public | boolean | false | Whether a product has been fully loaded. | - | core/src/services/ChamevoJS.ts:150 |
orderQuantity | public | number | 1 | Order quantity multiplier for pricing. | - | core/src/services/ChamevoJS.ts:152 |
currentPrice | public | number | 0 | Total price (with quantity multiplier). | - | core/src/services/ChamevoJS.ts:155 |
singleProductPrice | public | number | 0 | Per-unit price from view element prices (without quantity). | - | core/src/services/ChamevoJS.ts:157 |
pricingRulesPrice | public | number | 0 | Additional price from pricing rules. | - | core/src/services/ChamevoJS.ts:159 |
colorLinkGroups | public | Record<string, ColorLinkGroup> | {} | Color link groups for cross-view color synchronization. | - | core/src/services/ChamevoJS.ts:164 |
namesNumbers | public | NamesNumbersEntry[] | [] | Product-level Names & Numbers roster. | - | core/src/services/ChamevoJS.ts:167 |
_bulkVariationsData | public | object[] | null | null | Bulk variations data set by cv-module-bulk-variations. Used in getOrder(). | - | core/src/services/ChamevoJS.ts:170 |
_listeners | protected | Map<keyof ChamevoEvents, Set<Handler<any>>> | undefined | - | EventEmitter._listeners | core/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
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):
- Engraving mode on the active print profile —
industry.opts.filter+industry.opts.invert. imagick_filteron the active print profile (cascades through currentOptions from the current print area).- 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
| Parameter | Type |
|---|---|
sourceUrl | string |
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
| Parameter | Type | Description |
|---|---|---|
element | ICVElement | The image element (must be CVImage with getType() === 'image') |
filterId | string | false | Filter 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
| Parameter | Type |
|---|---|
element | ICVElement |
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
| Parameter | Type | Default value |
|---|---|---|
element | ICVElement | undefined |
scale | number | 2 |
Returns
Promise<void>
setProxyFileServer()
setProxyFileServer(url): void;
Defined in: core/src/services/ChamevoJS.ts:517
Parameters
| Parameter | Type |
|---|---|
url | string |
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
index | number |
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
| Parameter | Type |
|---|---|
index | number |
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
| Parameter | Type |
|---|---|
index | number |
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
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
index | number |
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
| Parameter | Type |
|---|---|
index | number |
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
| Parameter | Type |
|---|---|
fromIndex | number |
toIndex | number |
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
| Parameter | Type |
|---|---|
index | number |
width | number |
height | number |
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
| Parameter | Type |
|---|---|
viewIndex | number |
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
| Name | Type | Defined in |
|---|---|---|
rule | "any" | "all" | core/src/services/ChamevoJS.ts:1270 |
views | boolean[] | core/src/services/ChamevoJS.ts:1270 |
valid | boolean | core/src/services/ChamevoJS.ts:1270 |
getElements()
getElements(viewIndex?, type?): SerializedElement[];
Defined in: core/src/services/ChamevoJS.ts:1395
Get serialized elements across views.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
viewIndex? | number | undefined | Specific view index, or undefined for all views. |
type? | string | 'all' | Filter by type: 'all', 'text', or 'image'. |
Returns
getCustomElements()
getCustomElements(type, viewIndex?): StoredElementRef[];
Defined in: core/src/services/ChamevoJS.ts:1416
Get custom-added elements with their view index.
Parameters
| Parameter | Type | Default value |
|---|---|---|
type | string | 'all' |
viewIndex? | number | undefined |
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
| Parameter | Type | Default value |
|---|---|---|
type | string | 'all' |
viewIndex? | number | undefined |
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
| Parameter | Type | Default value |
|---|---|---|
considerQuantity | boolean | true |
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
setOrderQuantity()
setOrderQuantity(quantity): void;
Defined in: core/src/services/ChamevoJS.ts:1653
Set the order quantity and recalculate price.
Parameters
| Parameter | Type |
|---|---|
quantity | number |
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
| Parameter | Type |
|---|---|
data | object[] | 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
| Parameter | Type | Description |
|---|---|---|
fontFamily? | string | Optional 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
| Name | Type | Defined in |
|---|---|---|
product | CVProduct | null | core/src/services/ChamevoJS.ts:1715 |
usedFonts | FontInfo[] | core/src/services/ChamevoJS.ts:1716 |
usedColors | ColorInfo[] | core/src/services/ChamevoJS.ts:1717 |
bulkVariations | object[] | null | core/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
| Parameter | Type | Description |
|---|---|---|
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? | number | Cap output thumbnails to this max width or height (whichever is larger). |
options.cropToPrintArea? | boolean | Crop each view's export to its first print area. Strips print area UI chrome. |
options.preserveSelection? | boolean | Keep 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
| Parameter | Type | Description |
|---|---|---|
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
| Parameter | Type | Description |
|---|---|---|
viewIndex? | number | Specific 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
| Parameter | Type | Description |
|---|---|---|
source | string | Image URL or data URI. |
title | string | Display title for the element. |
params | Record<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
| Parameter | Type |
|---|---|
event | K |
handler | Handler<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
| Parameter | Type |
|---|---|
event | K |
handler | Handler<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
| Parameter | Type |
|---|---|
event | K |
handler | Handler<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
voidevents:emit('ready') - For payload events:
emit('elementAdd', { element, view })
Type Parameters
| Type Parameter |
|---|
K extends keyof ChamevoEvents |
Parameters
| Parameter | Type |
|---|---|
...args | ChamevoEvents[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
| Parameter | Type |
|---|---|
event? | keyof ChamevoEvents |
Returns
void
Inherited from
EventEmitter.removeAllListeners