v2.0.0
This release is a behavior-preserving migration of the v1 image editor onto a TypeScript and Fabric.js v7 foundation, published in multiple module formats from a single source tree. On-screen behavior is carried forward from v1.5.2 — sizing, scroll, overflow, rollback, mask metadata, history snapshots, export framing, crop session lifecycle, and dispose ordering all match v1. The only intentional default change is crop.preserveMasksAfterCrop (see Changed). The public API is canonical to v2: every v1 alias introduced as deprecated in v1.3.0 has been removed.
Added
- Publish ESM, CJS (
.cjs), UMD, and TypeScript declaration files (.d.ts) from a singlenpm run build. Thepackage.jsonexportsmap exposes the documented entry points (import,require,default,types), and the UMD bundle declaresfabricas an external global. - Add
fabric@^7as a peer dependency. Consumers pass the Fabric module to the editor explicitly through the constructor, with aglobalThis.fabricfallback for UMD usage. - Add
setLayoutMode('fit' | 'cover' | 'expand')as the public way to select the layout strategy for future image loads without exposing internal options. - Add
maxExportPixelsas a public export-size guard. Invalid values fall back to the default budget, and oversized multiplier exports reject before rendering.
Changed
- Migrate the runtime source tree to TypeScript and decompose the editor into one module per subsystem under
src/<subsystem>/(animation, history, image, mask, crop, export, ui, core, fabric, utils).ImageEditorremains the only public class and the package facade. - Upgrade the rendering engine to Fabric.js v7 and use Fabric v7 promise APIs (
FabricImage.fromURL,canvas.loadFromJSON) plus the local Promise wrapper around Fabric v7 animation handles throughout the async control flow for image load, scale, rotate, merge, crop, and export. - Change
crop.preserveMasksAfterCropto default tofalse. v1 defaulted totrue; callers that relied on the old default must now passcrop: { preserveMasksAfterCrop: true }explicitly. - Change the CommonJS root entry to return the v2 namespace object (
{ ImageEditor, default, isMaskObject }) instead of returning the constructor function directly.
Removed
- Remove every v1 alias from runtime, type declarations, demo, and documentation in favor of the canonical v2 names that were introduced alongside the deprecated aliases in v1.3.0:
reset()→resetImageTransform()addMask()→createMask()merge()→mergeMasks()getImageBase64()→exportImageBase64()(andexportImageFile()for directFileexports)canvasEl,containerEl,placeholderElpublic DOM fields → removed; DOM references are now private to the editor and are not part of the public surface.
- Remove deprecated v1 DOM binding keys from the v2
ElementIdMap, runtime defaults, demo, and declarations:imgPlaceholder→imagePlaceholderscaleRate→scalePercentageInputrotationLeftInput→rotateLeftDegreesInputrotationRightInput→rotateRightDegreesInputrotateLeftBtn→rotateLeftButtonrotateRightBtn→rotateRightButtonaddMaskBtn→createMaskButtonremoveMaskBtn→removeSelectedMaskButtonremoveAllMasksBtn→removeAllMasksButtonmergeBtn→mergeMasksButtondownloadBtn→downloadImageButtonzoomInBtn→zoomInButtonzoomOutBtn→zoomOutButtonresetBtn→resetImageTransformButtonundoBtn→undoButtonredoBtn→redoButtoncropBtn→enterCropModeButtonapplyCropBtn→applyCropButtoncancelCropBtn→cancelCropButton
- Remove root-level exports of internal helpers such as
AnimationQueue,Command,HistoryManager, subsystem controllers, services, managers, and utility modules. The package root exports onlyImageEditor(default and named),isMaskObject, and the documented public types.
Security
- Upgrade
@rollup/plugin-terserto^1.0.0so the development build chain resolvesserialize-javascript@7.0.5, clearing the high-severity npm audit finding from the release verification pass.
Fixed
- Replace the
setLayoutModetest's privateeditor.optionsassertions with black-box load/export behavior checks. - Loosen the public
FabricModuletype sonew ImageEditor(fabric, options)type-checks with the standardimport * as fabric from 'fabric'namespace form. - Allow integration tests to pass from a clean tree before
dist/has been built, while still failing when a partialdist/directory is present.