JS runtime API reference

Every designer and admin page exposes a global window.Veyop object. Addon JS bundles run after it's ready and register against it — no build-time coupling to core's source.

if (window.Veyop && window.Veyop.apiVersion >= 2) {
  // v2+ adds the stable façades documented below
}

Hooks & events

MemberUse
Veyop.hooks.on(event, fn) / .off(event, fn) / .emit(event, payload)Plain pub/sub for designer lifecycle events (table below).
Veyop.hooks.addFilter(name, namespace, callback, priority = 10) / .applyFilters(name, value, ...args)JS-side equivalent of a WordPress filter — transform a value through every registered callback.
Veyop.hooks.addAction(name, namespace, callback, priority = 10) / .doAction(name, ...args)JS-side equivalent of a WordPress action.
Veyop.hooks.registerSlot(name, namespace, render, priority = 10)Add content to a named slot in the designer/admin UI. render(context) returns what to show, or null to show nothing.
Veyop.hooks?.addFilter?.('veyop.item.patch', 'my-addon', (patch, item) => {
  return patch;
});
namespace is required. A call without it is ignored and reports no error. Use your addon slug. Registering the same name and namespace again replaces the earlier entry, lower priorities run first, and each call returns a function that removes the registration.

Core façades

MemberUse
Veyop.http.request(path, options) (also Veyop.api.request)Authenticated request helper for calling core or addon endpoints on every platform.
Veyop.ui.notify(type, message)Show a toast. type is success, error, warning, or anything else for an info toast.
Veyop.ui.confirm(message)Returns a promise for the answer. It currently opens the browser's native confirm() dialog.
Veyop.ui.registerToolbarAction(action)Add a primary action to the top toolbar.
Veyop.ui.registerMobileNavItem(item)Add a button to the mobile bottom navigation. context is default, selected, or always.
Veyop.designer.commands.addItem(item, options) / .updateItem(id, patch) / .removeItem(id) / .selectItem(id) / .getItems() / .addText(value, overrides, options)Mutate the design through the same command path the core UI uses, so undo/redo and autosave stay correct. Pass { placement: 'print-area-center' } to center a new item in the print area. commands is bound after the designer creates its store, so it is undefined while your bundle first loads.
Veyop.designer.commands.setProductColor(index) / .setAttribute(slug, value) / .setQuantity(qty) / .getTeamMembers() / .setTeamMembers(members) / .openLeftPanel(id) / .closeLeftPanel()Drive the product options, team list, and left panel from addon code.
Veyop.admin.registerPageTab({ pageId, id, label, component })Inject a new tab into an existing admin addon settings page.
Veyop.admin.registerLeaveGuard(isDirty)Join the admin's Stay/Leave prompt. isDirty() returns true while your addon page has unsaved changes. Returns a function that removes the guard, so call it when the page unmounts.
Veyop.tools.registerTextTool(tool)Add a button to the text-item popover toolbar.
Veyop.itemRenderers.register({ id, matches, render, priority })Register how a design item type renders on canvas — required for any custom item type. render(item, container) mounts into container and returns a cleanup function. The lowest priority is checked first (default 100).
Veyop.imagePipeline.registerItemSvgExporter({ id, matches, exportSvg, prepare, priority })Register how a design item type renders to SVG at export time — share the render logic with the canvas renderer so preview and export always match. id is required. Use the optional prepare(item, ctx) to load fonts or other assets before exportSvg runs.
Veyop.imagePipeline.registerImageRasterizer(entry)Provide a custom raster for matching items, used by both the canvas renderer and the export.
Veyop.designer.registerLayout({ id, theme, component })Register an entirely new Vue layout theme for the designer shell.
Veyop.uploads.uploadImage(file)Store an image your addon created (background removed, erased, cropped) through the shopper upload. It works for guests on every platform and resolves to { url, large, thumb, file, name }. Update large as well as src, because large is what gets printed.
Veyop.uploads.registerProcessor({ id, accept, matches, process })Transform a file the shopper picks before it is uploaded, for example turning a PDF into an image of its first page.

Adding a brand-new design item type

DesignItem is an open map — there's no closed type union enforced at runtime. Three registrations are enough to add a fully working new item type:

// 1. Create it from a toolbar action
Veyop.designer.commands.addItem({ type: 'my-addon:widget', /* ...initial data */ });

// 2. Render it on canvas
Veyop.itemRenderers.register({
  id: 'my-addon-widget',
  matches: (item) => item.type === 'my-addon:widget',
  render: (item, container) => {
    container.innerHTML = buildWidgetSvg(item); // shared, pure render function
    return () => { container.innerHTML = ''; }; // cleanup
  },
});

// 3. Export it identically at print time
Veyop.imagePipeline.registerItemSvgExporter({
  id: 'my-addon-widget',
  matches: (item) => item.type === 'my-addon:widget',
  exportSvg: (item) => buildWidgetSvg(item), // same function as above
});

Save, load, undo, and multi-select all work automatically — core treats any registered item type the same way.

Slot names

SlotLocation
veyo_toolbar_after_actionsEnd of the main designer toolbar.
veyo_sidebar_before_panels / veyo_sidebar_after_panelsAround the designer's panel stack (Layers, Text, Upload, etc.).
veyo_designer_root_start / veyo_designer_root_endVery start / end of the designer root element.
veyo_designer_before_toolbar / veyo_designer_after_toolbarAround the toolbar as a whole.
veyo_designer_before_canvas / veyo_designer_after_canvasAround the design canvas.

Lifecycle events

Subscribe with Veyop.hooks.on('event.name', fn).

EventFires
veyop:designer:beforeMountJust before the designer app mounts.
veyop:designer:readyAfter the designer has fully mounted and loaded its config.
select.item.designA design item is selected on canvas.
add.item.design / remove.item.designA design item is added or removed.
update.designAny part of the design is mutated.
before.save.design / after.save.designAround a save (draft or final).
before.load.design / after.load.designAround loading a saved design.
change.view.designCustomer switches product view (front/back/left/right).
add.to.cart.designCustomer adds the personalized product to cart.