canvico-editor 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +31 -8
  3. package/dist/CanvicoEditor.d.ts +45 -24
  4. package/dist/CanvicoEditor.d.ts.map +1 -1
  5. package/dist/CanvicoEditor.js +262 -87
  6. package/dist/CanvicoEditor.js.map +1 -1
  7. package/dist/modules/BaseModule.d.ts +5 -4
  8. package/dist/modules/BaseModule.d.ts.map +1 -1
  9. package/dist/modules/BaseModule.js +7 -6
  10. package/dist/modules/BaseModule.js.map +1 -1
  11. package/dist/modules/CropModule.d.ts +32 -31
  12. package/dist/modules/CropModule.d.ts.map +1 -1
  13. package/dist/modules/CropModule.js +147 -106
  14. package/dist/modules/CropModule.js.map +1 -1
  15. package/dist/modules/ResizeModule.d.ts +12 -26
  16. package/dist/modules/ResizeModule.d.ts.map +1 -1
  17. package/dist/modules/ResizeModule.js +27 -35
  18. package/dist/modules/ResizeModule.js.map +1 -1
  19. package/dist/modules/TransformModule.d.ts +38 -0
  20. package/dist/modules/TransformModule.d.ts.map +1 -0
  21. package/dist/modules/TransformModule.js +55 -0
  22. package/dist/modules/TransformModule.js.map +1 -0
  23. package/dist/state/CanvasState.d.ts +34 -0
  24. package/dist/state/CanvasState.d.ts.map +1 -0
  25. package/dist/state/CanvasState.js +67 -0
  26. package/dist/state/CanvasState.js.map +1 -0
  27. package/dist/state/EditorReducer.d.ts +60 -0
  28. package/dist/state/EditorReducer.d.ts.map +1 -0
  29. package/dist/state/EditorReducer.js +127 -0
  30. package/dist/state/EditorReducer.js.map +1 -0
  31. package/dist/types.d.ts +33 -0
  32. package/dist/types.d.ts.map +1 -1
  33. package/dist/utils/dom-manager.d.ts +12 -1
  34. package/dist/utils/dom-manager.d.ts.map +1 -1
  35. package/dist/utils/dom-manager.js +22 -14
  36. package/dist/utils/dom-manager.js.map +1 -1
  37. package/dist/utils/error-handler.d.ts +18 -7
  38. package/dist/utils/error-handler.d.ts.map +1 -1
  39. package/dist/utils/error-handler.js +34 -7
  40. package/dist/utils/error-handler.js.map +1 -1
  41. package/dist/utils/validation.d.ts +0 -7
  42. package/dist/utils/validation.d.ts.map +1 -1
  43. package/dist/utils/validation.js +33 -29
  44. package/dist/utils/validation.js.map +1 -1
  45. package/package.json +6 -4
package/dist/types.d.ts CHANGED
@@ -26,6 +26,17 @@ export type CropModuleConfig = {
26
26
  /** Optional color for the semi-transparent overlay outside the crop area. */
27
27
  outsideOverlayColor?: string;
28
28
  };
29
+ /**
30
+ * Configuration options for the Transform module.
31
+ */
32
+ export type TransformModuleConfig = {
33
+ /** Optional CSS selector for rotate input (degrees). */
34
+ rotateInputSelector?: string;
35
+ /** Optional CSS selector for flip horizontal button. */
36
+ flipHorizontalButtonSelector?: string;
37
+ /** Optional CSS selector for flip vertical button. */
38
+ flipVerticalButtonSelector?: string;
39
+ };
29
40
  /**
30
41
  * A container for all module-specific configuration options.
31
42
  */
@@ -34,7 +45,17 @@ export type ModuleConfig = {
34
45
  resize?: ResizeModuleConfig;
35
46
  /** Configuration for the Crop module. */
36
47
  crop?: CropModuleConfig;
48
+ /** Configuration for the Transform module. */
49
+ transform?: TransformModuleConfig;
50
+ };
51
+ export type CanvicoEditorErrorSource = "editor" | "dom" | "resize" | "crop" | "transform" | "validation" | "state";
52
+ export type CanvicoEditorErrorReport = {
53
+ error: Error;
54
+ source: CanvicoEditorErrorSource;
55
+ operation?: string;
56
+ timestamp: Date;
37
57
  };
58
+ export type CanvicoEditorErrorCallback = (report: CanvicoEditorErrorReport) => void;
38
59
  /**
39
60
  * The main configuration object for the CanvicoEditor.
40
61
  */
@@ -51,8 +72,20 @@ export type CanvicoEditorConfig = {
51
72
  clearCanvasButtonSelector: string;
52
73
  /** Optional maximum allowed file size in megabytes (MB). */
53
74
  maxFileSizeMB?: number;
75
+ /**
76
+ * When true, invalid module selectors throw during initialization
77
+ * (fail-fast behavior).
78
+ * When false, invalid module selectors disable only the affected module
79
+ * and report the error through the editor error pipeline.
80
+ * Defaults to `false`.
81
+ */
82
+ strictModuleSelectors?: boolean;
54
83
  /** Optional container for all module configurations. */
55
84
  modules?: ModuleConfig;
85
+ /** Optional callback to report handled runtime errors to host application. */
86
+ onError?: CanvicoEditorErrorCallback;
87
+ /** Controls whether handled errors are printed to console. Defaults to `true`. */
88
+ logErrorsToConsole?: boolean;
56
89
  };
57
90
  /**
58
91
  * The interface that all editor modules must implement.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC7B,8CAA8C;IAC9C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,+CAA+C;IAC/C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,uBAAuB,CAAC,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC3B,4DAA4D;IAC5D,sBAAsB,EAAE,MAAM,CAAC;IAC/B,yDAAyD;IACzD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACvB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,yCAAyC;IACzC,IAAI,CAAC,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,0EAA0E;IAC1E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,2DAA2D;IAC3D,sBAAsB,EAAE,MAAM,CAAC;IAC/B,+EAA+E;IAC/E,wBAAwB,EAAE,MAAM,CAA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0BAA0B,CAAC;IACrC,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF;;GAEG;AAEH,MAAM,WAAW,OAAO;IACpB,sEAAsE;IACtE,IAAI,IAAI,IAAI,CAAC;IAEb,sEAAsE;IACtE,OAAO,IAAI,IAAI,CAAC;IAEhB,6GAA6G;IAC7G,QAAQ,IAAI,IAAI,CAAC;IAEjB,2EAA2E;IAC3E,UAAU,IAAI,IAAI,CAAC;IAEnB,sEAAsE;IACtE,OAAO,IAAI,MAAM,CAAC;IAElB,sHAAsH;IACtH,WAAW,CAAC,IAAI,IAAI,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC"}
@@ -25,6 +25,14 @@ export interface CropDOMElements {
25
25
  activateButton: HTMLButtonElement;
26
26
  applyButton: HTMLButtonElement;
27
27
  }
28
+ /**
29
+ * Defines the DOM elements for the Transform module.
30
+ */
31
+ export interface TransformDOMElements {
32
+ rotateInput?: HTMLInputElement;
33
+ flipHorizontalButton?: HTMLButtonElement;
34
+ flipVerticalButton?: HTMLButtonElement;
35
+ }
28
36
  /**
29
37
  * Manages all DOM interactions for the CanvicoEditor.
30
38
  * It queries and validates the existence of all required and optional
@@ -37,7 +45,10 @@ export declare class DOMManager {
37
45
  readonly resizeElements?: ResizeDOMElements;
38
46
  /** Contains DOM elements for the crop module. Undefined if the module is not configured. */
39
47
  readonly cropElements?: CropDOMElements;
40
- private errorHandler;
48
+ /** Contains DOM elements for the transform module. Undefined if the module is not configured. */
49
+ readonly transformElements?: TransformDOMElements;
50
+ private readonly errorHandler;
51
+ private readonly strictModuleSelectors;
41
52
  /**
42
53
  * Creates an instance of DOMManager.
43
54
  * @param config - The main editor configuration object containing CSS selectors.
@@ -1 +1 @@
1
- {"version":3,"file":"dom-manager.d.ts","sourceRoot":"","sources":["../../src/utils/dom-manager.ts"],"names":[],"mappings":"AAAA,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IACvB,cAAc,EAAE,gBAAgB,CAAC;IACjC,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,UAAU,EAAE,iBAAiB,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,eAAe,CAAC,EAAE,gBAAgB,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,cAAc,EAAE,iBAAiB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,oBAAoB,CAAC,EAAE,iBAAiB,CAAC;IACzC,kBAAkB,CAAC,EAAE,iBAAiB,CAAC;CAC1C;AAED;;;;GAIG;AACH,qBAAa,UAAU;IACnB,uDAAuD;IACvD,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAE1C,8FAA8F;IAC9F,SAAgB,cAAc,CAAC,EAAE,iBAAiB,CAAC;IAEnD,4FAA4F;IAC5F,SAAgB,YAAY,CAAC,EAAE,eAAe,CAAC;IAE/C,iGAAiG;IACjG,SAAgB,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;IAEzD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAU;IAEhD;;;;;OAKG;gBACS,MAAM,EAAE,mBAAmB,EAAE,YAAY,EAAE,YAAY;IA6CnE;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAWxB;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;CAanC"}
@@ -1,38 +1,44 @@
1
- import { createInvalidInputTypeError as l, createDOMElementNotFoundError as n } from "./validation.js";
2
- class s {
1
+ import { createInvalidInputTypeError as o, createDOMElementNotFoundError as n } from "./validation.js";
2
+ class u {
3
3
  /** Contains the core, always-required DOM elements. */
4
4
  elements;
5
5
  /** Contains DOM elements for the resize module. Undefined if the module is not configured. */
6
6
  resizeElements;
7
7
  /** Contains DOM elements for the crop module. Undefined if the module is not configured. */
8
8
  cropElements;
9
+ /** Contains DOM elements for the transform module. Undefined if the module is not configured. */
10
+ transformElements;
9
11
  errorHandler;
12
+ strictModuleSelectors;
10
13
  /**
11
14
  * Creates an instance of DOMManager.
12
15
  * @param config - The main editor configuration object containing CSS selectors.
13
16
  * @param errorHandler - The error handler instance for reporting non-fatal errors.
14
17
  * @throws {Error} If a required DOM element cannot be found.
15
18
  */
16
- constructor(t, r) {
17
- this.errorHandler = r, this.elements = {
19
+ constructor(t, i) {
20
+ this.errorHandler = i, this.strictModuleSelectors = t.strictModuleSelectors ?? !1, this.elements = {
18
21
  container: this.queryAndValidate(t.containerSelector),
19
22
  imageFileInput: this.queryAndValidate(t.imageFileInputSelector, (e) => {
20
23
  if (e.type !== "file")
21
- throw l(t.imageFileInputSelector);
24
+ throw o(t.imageFileInputSelector);
22
25
  }),
23
26
  resetEditsButton: this.queryAndValidate(t.resetEditsButtonSelector),
24
27
  clearCanvasButton: this.queryAndValidate(t.clearCanvasButtonSelector),
25
28
  saveButton: this.queryAndValidate(t.saveButtonSelector)
26
29
  }, this.resizeElements = this.initializeModuleElements(t.modules?.resize, "Resize", (e) => {
27
- const i = {
30
+ const r = {
28
31
  widthInput: this.queryAndValidate(e.widthInputSelector),
29
32
  heightInput: this.queryAndValidate(e.heightInputSelector)
30
33
  };
31
- return e.lockAspectRatioSelector && (i.lockAspectRatio = this.queryAndValidate(e.lockAspectRatioSelector)), i;
34
+ return e.lockAspectRatioSelector && (r.lockAspectRatio = this.queryAndValidate(e.lockAspectRatioSelector)), r;
32
35
  }), this.cropElements = this.initializeModuleElements(t.modules?.crop, "Crop", (e) => ({
33
36
  activateButton: this.queryAndValidate(e.activateButtonSelector),
34
37
  applyButton: this.queryAndValidate(e.applyButtonSelector)
35
- }));
38
+ })), this.transformElements = this.initializeModuleElements(t.modules?.transform, "Transform", (e) => {
39
+ const r = {};
40
+ return e.rotateInputSelector && (r.rotateInput = this.queryAndValidate(e.rotateInputSelector)), e.flipHorizontalButtonSelector && (r.flipHorizontalButton = this.queryAndValidate(e.flipHorizontalButtonSelector)), e.flipVerticalButtonSelector && (r.flipVerticalButton = this.queryAndValidate(e.flipVerticalButtonSelector)), r;
41
+ });
36
42
  }
37
43
  /**
38
44
  * Queries the document for an element and throws a detailed error if not found.
@@ -42,11 +48,11 @@ class s {
42
48
  * @returns The found element, correctly typed.
43
49
  * @throws {Error} If the element with the given selector does not exist in the DOM.
44
50
  */
45
- queryAndValidate(t, r) {
51
+ queryAndValidate(t, i) {
46
52
  const e = document.querySelector(t);
47
53
  if (!e)
48
54
  throw n(t);
49
- return r && r(e), e;
55
+ return i && i(e), e;
50
56
  }
51
57
  /**
52
58
  * Initializes DOM elements for a module using a provided extractor function.
@@ -55,17 +61,19 @@ class s {
55
61
  * @param extractor - A function that extracts and validates DOM elements from the config.
56
62
  * @returns An object with DOM elements or `undefined`.
57
63
  */
58
- initializeModuleElements(t, r, e) {
64
+ initializeModuleElements(t, i, e) {
59
65
  if (t)
60
66
  try {
61
67
  return e(t);
62
- } catch (i) {
63
- console.warn(`DOM elements for ${r} module not found. The module will be disabled.`), this.errorHandler.handle(i);
68
+ } catch (r) {
69
+ const l = this.errorHandler.handle(r, { source: "dom", operation: `initialize-module-elements:${i}` });
70
+ if (this.strictModuleSelectors)
71
+ throw l;
64
72
  return;
65
73
  }
66
74
  }
67
75
  }
68
76
  export {
69
- s as DOMManager
77
+ u as DOMManager
70
78
  };
71
79
  //# sourceMappingURL=dom-manager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dom-manager.js","sources":["../../src/utils/dom-manager.ts"],"sourcesContent":["import type { CanvicoEditorConfig } from \"../types.js\";\r\nimport { ErrorHandler } from \"./error-handler.js\";\r\nimport { createDOMElementNotFoundError, createInvalidInputTypeError } from \"./validation.js\";\r\n\r\n/**\r\n * Defines the core DOM elements required by the editor.\r\n */\r\nexport interface CoreDOMElements {\r\n container: HTMLElement;\r\n imageFileInput: HTMLInputElement;\r\n resetEditsButton: HTMLButtonElement;\r\n clearCanvasButton: HTMLButtonElement;\r\n saveButton: HTMLButtonElement;\r\n}\r\n\r\n/**\r\n * Defines the DOM elements for the Resize module.\r\n */\r\nexport interface ResizeDOMElements {\r\n widthInput: HTMLInputElement;\r\n heightInput: HTMLInputElement;\r\n lockAspectRatio?: HTMLInputElement;\r\n}\r\n\r\n/**\r\n * Defines the DOM elements for the Crop module.\r\n */\r\nexport interface CropDOMElements {\r\n activateButton: HTMLButtonElement;\r\n applyButton: HTMLButtonElement;\r\n}\r\n\r\n/**\r\n * Manages all DOM interactions for the CanvicoEditor.\r\n * It queries and validates the existence of all required and optional\r\n * elements upon instantiation, providing a single, reliable source of DOM nodes.\r\n */\r\nexport class DOMManager {\r\n /** Contains the core, always-required DOM elements. */\r\n public readonly elements: CoreDOMElements;\r\n\r\n /** Contains DOM elements for the resize module. Undefined if the module is not configured. */\r\n public readonly resizeElements?: ResizeDOMElements;\r\n\r\n /** Contains DOM elements for the crop module. Undefined if the module is not configured. */\r\n public readonly cropElements?: CropDOMElements;\r\n\r\n private errorHandler: ErrorHandler;\r\n\r\n /**\r\n * Creates an instance of DOMManager.\r\n * @param config - The main editor configuration object containing CSS selectors.\r\n * @param errorHandler - The error handler instance for reporting non-fatal errors.\r\n * @throws {Error} If a required DOM element cannot be found.\r\n */\r\n constructor(config: CanvicoEditorConfig, errorHandler: ErrorHandler) {\r\n this.errorHandler = errorHandler;\r\n this.elements = {\r\n container: this.queryAndValidate<HTMLElement>(config.containerSelector),\r\n imageFileInput: this.queryAndValidate<HTMLInputElement>(config.imageFileInputSelector, (el) => {\r\n if (el.type !== \"file\") {\r\n throw createInvalidInputTypeError(config.imageFileInputSelector);\r\n }\r\n }),\r\n resetEditsButton: this.queryAndValidate<HTMLButtonElement>(config.resetEditsButtonSelector),\r\n clearCanvasButton: this.queryAndValidate<HTMLButtonElement>(config.clearCanvasButtonSelector),\r\n saveButton: this.queryAndValidate<HTMLButtonElement>(config.saveButtonSelector),\r\n };\r\n\r\n this.resizeElements = this.initializeModuleElements(config.modules?.resize, \"Resize\", (cfg) => {\r\n const elements: ResizeDOMElements = {\r\n widthInput: this.queryAndValidate<HTMLInputElement>(cfg.widthInputSelector),\r\n heightInput: this.queryAndValidate<HTMLInputElement>(cfg.heightInputSelector),\r\n };\r\n if (cfg.lockAspectRatioSelector) {\r\n elements.lockAspectRatio = this.queryAndValidate<HTMLInputElement>(cfg.lockAspectRatioSelector);\r\n }\r\n return elements;\r\n });\r\n this.cropElements = this.initializeModuleElements(config.modules?.crop, \"Crop\", (cfg) => ({\r\n activateButton: this.queryAndValidate<HTMLButtonElement>(cfg.activateButtonSelector),\r\n applyButton: this.queryAndValidate<HTMLButtonElement>(cfg.applyButtonSelector),\r\n }));\r\n }\r\n\r\n /**\r\n * Queries the document for an element and throws a detailed error if not found.\r\n * @template T - The expected HTML element type.\r\n * @param selector - The CSS selector for the element.\r\n * @param validator - Optional validation function to check specific element properties.\r\n * @returns The found element, correctly typed.\r\n * @throws {Error} If the element with the given selector does not exist in the DOM.\r\n */\r\n private queryAndValidate<T extends HTMLElement>(selector: string, validator?: (element: T) => void): T {\r\n const element = document.querySelector<T>(selector);\r\n if (!element) {\r\n throw createDOMElementNotFoundError(selector);\r\n }\r\n if (validator) {\r\n validator(element);\r\n }\r\n return element;\r\n }\r\n\r\n /**\r\n * Initializes DOM elements for a module using a provided extractor function.\r\n * @param config - The module configuration object.\r\n * @param moduleName - The name of the module for error logging.\r\n * @param extractor - A function that extracts and validates DOM elements from the config.\r\n * @returns An object with DOM elements or `undefined`.\r\n */\r\n private initializeModuleElements<TConfig, TResult>(config: TConfig | undefined, moduleName: string, extractor: (config: TConfig) => TResult): TResult | undefined {\r\n if (!config) return undefined;\r\n\r\n try {\r\n return extractor(config);\r\n } catch (error) {\r\n console.warn(`DOM elements for ${moduleName} module not found. The module will be disabled.`);\r\n this.errorHandler.handle(error as Error);\r\n return undefined;\r\n }\r\n }\r\n}\r\n"],"names":["DOMManager","config","errorHandler","el","createInvalidInputTypeError","cfg","elements","selector","validator","element","createDOMElementNotFoundError","moduleName","extractor","error"],"mappings":";AAqCO,MAAMA,EAAW;AAAA;AAAA,EAEJ;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA,EAER;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQR,YAAYC,GAA6BC,GAA4B;AACjE,SAAK,eAAeA,GACpB,KAAK,WAAW;AAAA,MACZ,WAAW,KAAK,iBAA8BD,EAAO,iBAAiB;AAAA,MACtE,gBAAgB,KAAK,iBAAmCA,EAAO,wBAAwB,CAACE,MAAO;AAC3F,YAAIA,EAAG,SAAS;AACZ,gBAAMC,EAA4BH,EAAO,sBAAsB;AAAA,MAEvE,CAAC;AAAA,MACD,kBAAkB,KAAK,iBAAoCA,EAAO,wBAAwB;AAAA,MAC1F,mBAAmB,KAAK,iBAAoCA,EAAO,yBAAyB;AAAA,MAC5F,YAAY,KAAK,iBAAoCA,EAAO,kBAAkB;AAAA,IAAA,GAGlF,KAAK,iBAAiB,KAAK,yBAAyBA,EAAO,SAAS,QAAQ,UAAU,CAACI,MAAQ;AAC3F,YAAMC,IAA8B;AAAA,QAChC,YAAY,KAAK,iBAAmCD,EAAI,kBAAkB;AAAA,QAC1E,aAAa,KAAK,iBAAmCA,EAAI,mBAAmB;AAAA,MAAA;AAEhF,aAAIA,EAAI,4BACJC,EAAS,kBAAkB,KAAK,iBAAmCD,EAAI,uBAAuB,IAE3FC;AAAA,IACX,CAAC,GACD,KAAK,eAAe,KAAK,yBAAyBL,EAAO,SAAS,MAAM,QAAQ,CAACI,OAAS;AAAA,MACtF,gBAAgB,KAAK,iBAAoCA,EAAI,sBAAsB;AAAA,MACnF,aAAa,KAAK,iBAAoCA,EAAI,mBAAmB;AAAA,IAAA,EAC/E;AAAA,EACN;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUQ,iBAAwCE,GAAkBC,GAAqC;AACnG,UAAMC,IAAU,SAAS,cAAiBF,CAAQ;AAClD,QAAI,CAACE;AACD,YAAMC,EAA8BH,CAAQ;AAEhD,WAAIC,KACAA,EAAUC,CAAO,GAEdA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,yBAA2CR,GAA6BU,GAAoBC,GAA8D;AAC9J,QAAKX;AAEL,UAAI;AACA,eAAOW,EAAUX,CAAM;AAAA,MAC3B,SAASY,GAAO;AACZ,gBAAQ,KAAK,oBAAoBF,CAAU,iDAAiD,GAC5F,KAAK,aAAa,OAAOE,CAAc;AACvC;AAAA,MACJ;AAAA,EACJ;AACJ;"}
1
+ {"version":3,"file":"dom-manager.js","sources":["../../src/utils/dom-manager.ts"],"sourcesContent":["import type { CanvicoEditorConfig } from \"../types.js\";\r\nimport { ErrorHandler } from \"./error-handler.js\";\r\nimport { createDOMElementNotFoundError, createInvalidInputTypeError } from \"./validation.js\";\r\n\r\n/**\r\n * Defines the core DOM elements required by the editor.\r\n */\r\nexport interface CoreDOMElements {\r\n container: HTMLElement;\r\n imageFileInput: HTMLInputElement;\r\n resetEditsButton: HTMLButtonElement;\r\n clearCanvasButton: HTMLButtonElement;\r\n saveButton: HTMLButtonElement;\r\n}\r\n\r\n/**\r\n * Defines the DOM elements for the Resize module.\r\n */\r\nexport interface ResizeDOMElements {\r\n widthInput: HTMLInputElement;\r\n heightInput: HTMLInputElement;\r\n lockAspectRatio?: HTMLInputElement;\r\n}\r\n\r\n/**\r\n * Defines the DOM elements for the Crop module.\r\n */\r\nexport interface CropDOMElements {\r\n activateButton: HTMLButtonElement;\r\n applyButton: HTMLButtonElement;\r\n}\r\n\r\n/**\r\n * Defines the DOM elements for the Transform module.\r\n */\r\nexport interface TransformDOMElements {\r\n rotateInput?: HTMLInputElement;\r\n flipHorizontalButton?: HTMLButtonElement;\r\n flipVerticalButton?: HTMLButtonElement;\r\n}\r\n\r\n/**\r\n * Manages all DOM interactions for the CanvicoEditor.\r\n * It queries and validates the existence of all required and optional\r\n * elements upon instantiation, providing a single, reliable source of DOM nodes.\r\n */\r\nexport class DOMManager {\r\n /** Contains the core, always-required DOM elements. */\r\n public readonly elements: CoreDOMElements;\r\n\r\n /** Contains DOM elements for the resize module. Undefined if the module is not configured. */\r\n public readonly resizeElements?: ResizeDOMElements;\r\n\r\n /** Contains DOM elements for the crop module. Undefined if the module is not configured. */\r\n public readonly cropElements?: CropDOMElements;\r\n\r\n /** Contains DOM elements for the transform module. Undefined if the module is not configured. */\r\n public readonly transformElements?: TransformDOMElements;\r\n\r\n private readonly errorHandler: ErrorHandler;\r\n private readonly strictModuleSelectors: boolean;\r\n\r\n /**\r\n * Creates an instance of DOMManager.\r\n * @param config - The main editor configuration object containing CSS selectors.\r\n * @param errorHandler - The error handler instance for reporting non-fatal errors.\r\n * @throws {Error} If a required DOM element cannot be found.\r\n */\r\n constructor(config: CanvicoEditorConfig, errorHandler: ErrorHandler) {\r\n this.errorHandler = errorHandler;\r\n this.strictModuleSelectors = config.strictModuleSelectors ?? false;\r\n this.elements = {\r\n container: this.queryAndValidate<HTMLElement>(config.containerSelector),\r\n imageFileInput: this.queryAndValidate<HTMLInputElement>(config.imageFileInputSelector, (el) => {\r\n if (el.type !== \"file\") {\r\n throw createInvalidInputTypeError(config.imageFileInputSelector);\r\n }\r\n }),\r\n resetEditsButton: this.queryAndValidate<HTMLButtonElement>(config.resetEditsButtonSelector),\r\n clearCanvasButton: this.queryAndValidate<HTMLButtonElement>(config.clearCanvasButtonSelector),\r\n saveButton: this.queryAndValidate<HTMLButtonElement>(config.saveButtonSelector),\r\n };\r\n\r\n this.resizeElements = this.initializeModuleElements(config.modules?.resize, \"Resize\", (cfg) => {\r\n const elements: ResizeDOMElements = {\r\n widthInput: this.queryAndValidate<HTMLInputElement>(cfg.widthInputSelector),\r\n heightInput: this.queryAndValidate<HTMLInputElement>(cfg.heightInputSelector),\r\n };\r\n if (cfg.lockAspectRatioSelector) {\r\n elements.lockAspectRatio = this.queryAndValidate<HTMLInputElement>(cfg.lockAspectRatioSelector);\r\n }\r\n return elements;\r\n });\r\n this.cropElements = this.initializeModuleElements(config.modules?.crop, \"Crop\", (cfg) => ({\r\n activateButton: this.queryAndValidate<HTMLButtonElement>(cfg.activateButtonSelector),\r\n applyButton: this.queryAndValidate<HTMLButtonElement>(cfg.applyButtonSelector),\r\n }));\r\n\r\n this.transformElements = this.initializeModuleElements(config.modules?.transform, \"Transform\", (cfg) => {\r\n const elements: TransformDOMElements = {};\r\n if (cfg.rotateInputSelector) {\r\n elements.rotateInput = this.queryAndValidate<HTMLInputElement>(cfg.rotateInputSelector);\r\n }\r\n if (cfg.flipHorizontalButtonSelector) {\r\n elements.flipHorizontalButton = this.queryAndValidate<HTMLButtonElement>(cfg.flipHorizontalButtonSelector);\r\n }\r\n if (cfg.flipVerticalButtonSelector) {\r\n elements.flipVerticalButton = this.queryAndValidate<HTMLButtonElement>(cfg.flipVerticalButtonSelector);\r\n }\r\n return elements;\r\n });\r\n }\r\n\r\n /**\r\n * Queries the document for an element and throws a detailed error if not found.\r\n * @template T - The expected HTML element type.\r\n * @param selector - The CSS selector for the element.\r\n * @param validator - Optional validation function to check specific element properties.\r\n * @returns The found element, correctly typed.\r\n * @throws {Error} If the element with the given selector does not exist in the DOM.\r\n */\r\n private queryAndValidate<T extends HTMLElement>(selector: string, validator?: (element: T) => void): T {\r\n const element = document.querySelector<T>(selector);\r\n if (!element) {\r\n throw createDOMElementNotFoundError(selector);\r\n }\r\n if (validator) {\r\n validator(element);\r\n }\r\n return element;\r\n }\r\n\r\n /**\r\n * Initializes DOM elements for a module using a provided extractor function.\r\n * @param config - The module configuration object.\r\n * @param moduleName - The name of the module for error logging.\r\n * @param extractor - A function that extracts and validates DOM elements from the config.\r\n * @returns An object with DOM elements or `undefined`.\r\n */\r\n private initializeModuleElements<TConfig, TResult>(config: TConfig | undefined, moduleName: string, extractor: (config: TConfig) => TResult): TResult | undefined {\r\n if (!config) return undefined;\r\n\r\n try {\r\n return extractor(config);\r\n } catch (error) {\r\n const handledError = this.errorHandler.handle(error, { source: \"dom\", operation: `initialize-module-elements:${moduleName}` });\r\n if (this.strictModuleSelectors) {\r\n throw handledError;\r\n }\r\n return undefined;\r\n }\r\n }\r\n}\r\n"],"names":["DOMManager","config","errorHandler","el","createInvalidInputTypeError","cfg","elements","selector","validator","element","createDOMElementNotFoundError","moduleName","extractor","error","handledError"],"mappings":";AA8CO,MAAMA,EAAW;AAAA;AAAA,EAEJ;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA,EAEC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjB,YAAYC,GAA6BC,GAA4B;AACjE,SAAK,eAAeA,GACpB,KAAK,wBAAwBD,EAAO,yBAAyB,IAC7D,KAAK,WAAW;AAAA,MACZ,WAAW,KAAK,iBAA8BA,EAAO,iBAAiB;AAAA,MACtE,gBAAgB,KAAK,iBAAmCA,EAAO,wBAAwB,CAACE,MAAO;AAC3F,YAAIA,EAAG,SAAS;AACZ,gBAAMC,EAA4BH,EAAO,sBAAsB;AAAA,MAEvE,CAAC;AAAA,MACD,kBAAkB,KAAK,iBAAoCA,EAAO,wBAAwB;AAAA,MAC1F,mBAAmB,KAAK,iBAAoCA,EAAO,yBAAyB;AAAA,MAC5F,YAAY,KAAK,iBAAoCA,EAAO,kBAAkB;AAAA,IAAA,GAGlF,KAAK,iBAAiB,KAAK,yBAAyBA,EAAO,SAAS,QAAQ,UAAU,CAACI,MAAQ;AAC3F,YAAMC,IAA8B;AAAA,QAChC,YAAY,KAAK,iBAAmCD,EAAI,kBAAkB;AAAA,QAC1E,aAAa,KAAK,iBAAmCA,EAAI,mBAAmB;AAAA,MAAA;AAEhF,aAAIA,EAAI,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
+ export type ErrorHandlerContext = {
3
+ source: CanvicoEditorErrorSource;
4
+ operation?: string;
5
+ };
6
+ export type ErrorHandlerOptions = {
7
+ onError?: CanvicoEditorErrorCallback;
8
+ logToConsole?: boolean;
9
+ };
1
10
  /**
2
- * A centralized class for handling errors that occur within the application.
3
- * By default, it logs errors to the console, but it can be extended
4
- * in the future to support other reporting mechanisms (e.g., sending to a logging service).
11
+ * Centralized error handling for the editor runtime.
12
+ * It can report errors to host application and optionally to the browser console.
5
13
  */
6
14
  export declare class ErrorHandler {
15
+ private readonly onError?;
16
+ private readonly logToConsole;
17
+ constructor(options?: ErrorHandlerOptions);
7
18
  /**
8
- * Handles an error by logging it to the console.
9
- * This is the central place for logging errors for developers.
10
- * @param error - The error object to handle, which should include a message and preferably a stack trace.
19
+ * Handles an error and reports it using configured channels.
20
+ * Returns a normalized `Error` instance for callers that need it.
11
21
  */
12
- handle(error: Error): void;
22
+ handle(errorLike: unknown, context?: ErrorHandlerContext): Error;
23
+ private _normalizeError;
13
24
  }
14
25
  //# sourceMappingURL=error-handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,YAAY;IACrB;;;;OAIG;IACI,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAIpC"}
1
+ {"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAA4B,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAElH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,MAAM,EAAE,wBAAwB,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,OAAO,CAAC,EAAE,0BAA0B,CAAC;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAIF;;;GAGG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAA6B;IACtD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;gBAE3B,OAAO,CAAC,EAAE,mBAAmB;IAKzC;;;OAGG;IACI,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,KAAK;IA4BvE,OAAO,CAAC,eAAe;CAQ1B"}
@@ -1,14 +1,41 @@
1
- class o {
1
+ const c = { source: "editor" };
2
+ class a {
3
+ onError;
4
+ logToConsole;
5
+ constructor(o) {
6
+ this.onError = o?.onError, this.logToConsole = o?.logToConsole ?? !0;
7
+ }
2
8
  /**
3
- * Handles an error by logging it to the console.
4
- * This is the central place for logging errors for developers.
5
- * @param error - The error object to handle, which should include a message and preferably a stack trace.
9
+ * Handles an error and reports it using configured channels.
10
+ * Returns a normalized `Error` instance for callers that need it.
6
11
  */
7
- handle(r) {
8
- console.error(r);
12
+ handle(o, n) {
13
+ const r = n ?? c, e = this._normalizeError(o), s = {
14
+ error: e,
15
+ source: r.source,
16
+ operation: r.operation,
17
+ timestamp: /* @__PURE__ */ new Date()
18
+ };
19
+ if (this.logToConsole) {
20
+ const t = r.operation ? `:${r.operation}` : "";
21
+ console.error(`[CanvicoEditor][${r.source}${t}]`, e);
22
+ }
23
+ if (this.onError)
24
+ try {
25
+ this.onError(s);
26
+ } catch (t) {
27
+ this.logToConsole && console.error("[CanvicoEditor][error-handler:onError-callback]", t);
28
+ }
29
+ return e;
30
+ }
31
+ _normalizeError(o) {
32
+ if (o instanceof Error)
33
+ return o;
34
+ const n = typeof o == "string" ? o : "Unknown error";
35
+ return new Error(n);
9
36
  }
10
37
  }
11
38
  export {
12
- o as ErrorHandler
39
+ a as ErrorHandler
13
40
  };
14
41
  //# sourceMappingURL=error-handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-handler.js","sources":["../../src/utils/error-handler.ts"],"sourcesContent":["/**\r\n * A centralized class for handling errors that occur within the application.\r\n * By default, it logs errors to the console, but it can be extended\r\n * in the future to support other reporting mechanisms (e.g., sending to a logging service).\r\n */\r\nexport class ErrorHandler {\r\n /**\r\n * Handles an error by logging it to the console.\r\n * This is the central place for logging errors for developers.\r\n * @param error - The error object to handle, which should include a message and preferably a stack trace.\r\n */\r\n public handle(error: Error): void {\r\n // We log the entire error object to provide the most detail in the console.\r\n console.error(error);\r\n }\r\n}\r\n"],"names":["ErrorHandler","error"],"mappings":"AAKO,MAAMA,EAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMf,OAAOC,GAAoB;AAE9B,YAAQ,MAAMA,CAAK;AAAA,EACvB;AACJ;"}
1
+ {"version":3,"file":"error-handler.js","sources":["../../src/utils/error-handler.ts"],"sourcesContent":["import type { CanvicoEditorErrorCallback, CanvicoEditorErrorReport, CanvicoEditorErrorSource } from \"../types.js\";\r\n\r\nexport type ErrorHandlerContext = {\r\n source: CanvicoEditorErrorSource;\r\n operation?: string;\r\n};\r\n\r\nexport type ErrorHandlerOptions = {\r\n onError?: CanvicoEditorErrorCallback;\r\n logToConsole?: boolean;\r\n};\r\n\r\nconst DEFAULT_ERROR_CONTEXT: ErrorHandlerContext = { source: \"editor\" };\r\n\r\n/**\r\n * Centralized error handling for the editor runtime.\r\n * It can report errors to host application and optionally to the browser console.\r\n */\r\nexport class ErrorHandler {\r\n private readonly onError?: CanvicoEditorErrorCallback;\r\n private readonly logToConsole: boolean;\r\n\r\n constructor(options?: ErrorHandlerOptions) {\r\n this.onError = options?.onError;\r\n this.logToConsole = options?.logToConsole ?? true;\r\n }\r\n\r\n /**\r\n * Handles an error and reports it using configured channels.\r\n * Returns a normalized `Error` instance for callers that need it.\r\n */\r\n public handle(errorLike: unknown, context?: ErrorHandlerContext): Error {\r\n const resolvedContext = context ?? DEFAULT_ERROR_CONTEXT;\r\n const error = this._normalizeError(errorLike);\r\n const report: CanvicoEditorErrorReport = {\r\n error,\r\n source: resolvedContext.source,\r\n operation: resolvedContext.operation,\r\n timestamp: new Date(),\r\n };\r\n\r\n if (this.logToConsole) {\r\n const operationLabel = resolvedContext.operation ? `:${resolvedContext.operation}` : \"\";\r\n console.error(`[CanvicoEditor][${resolvedContext.source}${operationLabel}]`, error);\r\n }\r\n\r\n if (this.onError) {\r\n try {\r\n this.onError(report);\r\n } catch (callbackError) {\r\n if (this.logToConsole) {\r\n console.error(\"[CanvicoEditor][error-handler:onError-callback]\", callbackError);\r\n }\r\n }\r\n }\r\n\r\n return error;\r\n }\r\n\r\n private _normalizeError(errorLike: unknown): Error {\r\n if (errorLike instanceof Error) {\r\n return errorLike;\r\n }\r\n\r\n const message = typeof errorLike === \"string\" ? errorLike : \"Unknown error\";\r\n return new Error(message);\r\n }\r\n}\r\n"],"names":["DEFAULT_ERROR_CONTEXT","ErrorHandler","options","errorLike","context","resolvedContext","error","report","operationLabel","callbackError","message"],"mappings":"AAYA,MAAMA,IAA6C,EAAE,QAAQ,SAAA;AAMtD,MAAMC,EAAa;AAAA,EACL;AAAA,EACA;AAAA,EAEjB,YAAYC,GAA+B;AACvC,SAAK,UAAUA,GAAS,SACxB,KAAK,eAAeA,GAAS,gBAAgB;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,OAAOC,GAAoBC,GAAsC;AACpE,UAAMC,IAAkBD,KAAWJ,GAC7BM,IAAQ,KAAK,gBAAgBH,CAAS,GACtCI,IAAmC;AAAA,MACrC,OAAAD;AAAA,MACA,QAAQD,EAAgB;AAAA,MACxB,WAAWA,EAAgB;AAAA,MAC3B,+BAAe,KAAA;AAAA,IAAK;AAGxB,QAAI,KAAK,cAAc;AACnB,YAAMG,IAAiBH,EAAgB,YAAY,IAAIA,EAAgB,SAAS,KAAK;AACrF,cAAQ,MAAM,mBAAmBA,EAAgB,MAAM,GAAGG,CAAc,KAAKF,CAAK;AAAA,IACtF;AAEA,QAAI,KAAK;AACL,UAAI;AACA,aAAK,QAAQC,CAAM;AAAA,MACvB,SAASE,GAAe;AACpB,QAAI,KAAK,gBACL,QAAQ,MAAM,mDAAmDA,CAAa;AAAA,MAEtF;AAGJ,WAAOH;AAAA,EACX;AAAA,EAEQ,gBAAgBH,GAA2B;AAC/C,QAAIA,aAAqB;AACrB,aAAOA;AAGX,UAAMO,IAAU,OAAOP,KAAc,WAAWA,IAAY;AAC5D,WAAO,IAAI,MAAMO,CAAO;AAAA,EAC5B;AACJ;"}
@@ -32,13 +32,6 @@ export declare function createCanvasContextError(): Error;
32
32
  * @returns {Error} A new Error object with a descriptive message.
33
33
  */
34
34
  export declare function createImageSaveError(): Error;
35
- /**
36
- * Creates a standardized error for when a module is configured with an incomplete set of selectors.
37
- * @param {string} moduleName - The name of the module (e.g., 'Resize', 'Crop').
38
- * @param {string[]} selectors - The list of required selector names for the module.
39
- * @returns {Error} A new Error object with a descriptive message.
40
- */
41
- export declare function createMissingModuleSelectorsError(moduleName: string, selectors: string[]): Error;
42
35
  /**
43
36
  * Creates a standardized error for when a required browser feature is not supported.
44
37
  * @param {string} featureName - The name of the required feature (e.g., 'FileReader').
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAErE;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,MAAiC,GAAG,KAAK,CAEtF;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,KAAK,CAEhD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,KAAK,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,KAAK,CAEhG;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK,CAEzE;AAID;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAWpE"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAErE;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,MAAiC,GAAG,KAAK,CAEtF;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,KAAK,CAEhD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,KAAK,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK,CAEzE;AAID;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAWpE"}
@@ -1,40 +1,44 @@
1
- const r = "CanvicoEditor:";
2
- function a(e) {
3
- return new Error(`${r} Required DOM element not found for selector: "${e}".`);
1
+ const i = "CanvicoEditor:";
2
+ function e(r, o) {
3
+ const t = new Error(`${i} ${o}`);
4
+ return t.name = r, t;
4
5
  }
5
- function u(e) {
6
- return new Error(`${r} Element for selector "${e}" is not an <input type="file">.`);
6
+ function u(r) {
7
+ return e("CanvicoDOMElementNotFoundError", `Required DOM element not found for selector: "${r}".`);
7
8
  }
8
- function n(e) {
9
- return new Error(`${r} Invalid file: ${e}`);
9
+ function c(r) {
10
+ return e("CanvicoInvalidInputTypeError", `Element for selector "${r}" is not an <input type="file">.`);
10
11
  }
11
- function c(e = "File could not be read") {
12
- return new Error(`${r} Image load error: ${e}`);
12
+ function a(r) {
13
+ return e("CanvicoInvalidFileError", `Invalid file: ${r}`);
13
14
  }
14
- function s() {
15
- return new Error(`${r} 2D context is not supported by the browser.`);
15
+ function d(r = "File could not be read") {
16
+ return e("CanvicoImageLoadError", `Image load error: ${r}`);
17
+ }
18
+ function p() {
19
+ return e("CanvicoCanvasContextError", "2D context is not supported by the browser.");
16
20
  }
17
- function d() {
18
- return new Error(`${r} Cannot save because no image is loaded.`);
21
+ function s() {
22
+ return e("CanvicoImageSaveError", "Cannot save because no image is loaded.");
19
23
  }
20
- function p(e) {
21
- return new Error(`${r} Required browser feature not supported: ${e}.`);
24
+ function l(r) {
25
+ return e("CanvicoFeatureNotSupportedError", `Required browser feature not supported: ${r}.`);
22
26
  }
23
- function l(e, t) {
24
- const i = t * 1024 * 1024, o = ["image/jpeg", "image/png", "image/gif", "image/webp"];
25
- if (!o.includes(e.type))
26
- throw n(`Unsupported file type. Supported types are: ${o.join(", ")}.`);
27
- if (e.size > i)
28
- throw n(`File is too large. Maximum size is ${t}MB.`);
27
+ function E(r, o) {
28
+ const t = o * 1024 * 1024, n = ["image/jpeg", "image/png", "image/webp"];
29
+ if (!n.includes(r.type))
30
+ throw a(`Unsupported file type. Supported types are: ${n.join(", ")}.`);
31
+ if (r.size > t)
32
+ throw a(`File is too large. Maximum size is ${o}MB.`);
29
33
  }
30
34
  export {
31
- s as createCanvasContextError,
32
- a as createDOMElementNotFoundError,
33
- p as createFeatureNotSupportedError,
34
- c as createImageLoadError,
35
- d as createImageSaveError,
36
- n as createInvalidFileError,
37
- u as createInvalidInputTypeError,
38
- l as validateFile
35
+ p as createCanvasContextError,
36
+ u as createDOMElementNotFoundError,
37
+ l as createFeatureNotSupportedError,
38
+ d as createImageLoadError,
39
+ s as createImageSaveError,
40
+ a as createInvalidFileError,
41
+ c as createInvalidInputTypeError,
42
+ E as validateFile
39
43
  };
40
44
  //# sourceMappingURL=validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sources":["../../src/utils/validation.ts"],"sourcesContent":["const PREFIX = \"CanvicoEditor:\";\r\n\r\n// --- ERROR FACTORY FUNCTIONS ---\r\n\r\n/**\r\n * Creates a standardized error for when a required DOM element is not found.\r\n * * @param selector - The CSS selector that failed to find an element.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createDOMElementNotFoundError(selector: string): Error {\r\n return new Error(`${PREFIX} Required DOM element not found for selector: \"${selector}\".`);\r\n}\r\n\r\n/**\r\n * Creates a standardized error for when the main input element is not of `type=\"file\"`.\r\n * @param {string} selector - The CSS selector used to find the input element.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createInvalidInputTypeError(selector: string): Error {\r\n return new Error(`${PREFIX} Element for selector \"${selector}\" is not an <input type=\"file\">.`);\r\n}\r\n\r\n/**\r\n * Creates a standardized error for file validation issues (e.g., wrong type, size).\r\n * @param {string} message - The specific reason why the file is invalid.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createInvalidFileError(message: string): Error {\r\n return new Error(`${PREFIX} Invalid file: ${message}`);\r\n}\r\n\r\n/**\r\n * Creates a standardized error for when an image fails to load from a file.\r\n * @param {string} [details=\"File could not be read\"] - Specific details about the loading error.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createImageLoadError(details: string = \"File could not be read\"): Error {\r\n return new Error(`${PREFIX} Image load error: ${details}`);\r\n}\r\n\r\n/**\r\n * Creates a standardized error for when the canvas 2D rendering context cannot be obtained.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createCanvasContextError(): Error {\r\n return new Error(`${PREFIX} 2D context is not supported by the browser.`);\r\n}\r\n\r\n/**\r\n * Creates a standardized error for when a save operation is attempted with no image loaded.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createImageSaveError(): Error {\r\n return new Error(`${PREFIX} Cannot save because no image is loaded.`);\r\n}\r\n\r\n/**\r\n * Creates a standardized error for when a module is configured with an incomplete set of selectors.\r\n * @param {string} moduleName - The name of the module (e.g., 'Resize', 'Crop').\r\n * @param {string[]} selectors - The list of required selector names for the module.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createMissingModuleSelectorsError(moduleName: string, selectors: string[]): Error {\r\n return new Error(`${PREFIX} To use the ${moduleName} module, you must provide all of these selectors: ${selectors.join(\", \")}.`);\r\n}\r\n\r\n/**\r\n * Creates a standardized error for when a required browser feature is not supported.\r\n * @param {string} featureName - The name of the required feature (e.g., 'FileReader').\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createFeatureNotSupportedError(featureName: string): Error {\r\n return new Error(`${PREFIX} Required browser feature not supported: ${featureName}.`);\r\n}\r\n\r\n// --- VALIDATION FUNCTIONS ---\r\n\r\n/**\r\n * Validates if the selected file is a supported image and within the size limit.\r\n * @param {File} file - The file to validate.\r\n * @param {number} maxFileSizeMB - The maximum allowed file size in megabytes.\r\n * @throws {Error} If the file type is unsupported or the file size exceeds the limit.\r\n */\r\nexport function validateFile(file: File, maxFileSizeMB: number): void {\r\n const maxFileSizeInBytes = maxFileSizeMB * 1024 * 1024;\r\n const validTypes = [\"image/jpeg\", \"image/png\", \"image/gif\", \"image/webp\"];\r\n\r\n if (!validTypes.includes(file.type)) {\r\n throw createInvalidFileError(`Unsupported file type. Supported types are: ${validTypes.join(\", \")}.`);\r\n }\r\n\r\n if (file.size > maxFileSizeInBytes) {\r\n throw createInvalidFileError(`File is too large. Maximum size is ${maxFileSizeMB}MB.`);\r\n }\r\n}\r\n"],"names":["PREFIX","createDOMElementNotFoundError","selector","createInvalidInputTypeError","createInvalidFileError","message","createImageLoadError","details","createCanvasContextError","createImageSaveError","createFeatureNotSupportedError","featureName","validateFile","file","maxFileSizeMB","maxFileSizeInBytes","validTypes"],"mappings":"AAAA,MAAMA,IAAS;AASR,SAASC,EAA8BC,GAAyB;AACnE,SAAO,IAAI,MAAM,GAAGF,CAAM,kDAAkDE,CAAQ,IAAI;AAC5F;AAOO,SAASC,EAA4BD,GAAyB;AACjE,SAAO,IAAI,MAAM,GAAGF,CAAM,0BAA0BE,CAAQ,kCAAkC;AAClG;AAOO,SAASE,EAAuBC,GAAwB;AAC3D,SAAO,IAAI,MAAM,GAAGL,CAAM,kBAAkBK,CAAO,EAAE;AACzD;AAOO,SAASC,EAAqBC,IAAkB,0BAAiC;AACpF,SAAO,IAAI,MAAM,GAAGP,CAAM,sBAAsBO,CAAO,EAAE;AAC7D;AAMO,SAASC,IAAkC;AAC9C,SAAO,IAAI,MAAM,GAAGR,CAAM,8CAA8C;AAC5E;AAMO,SAASS,IAA8B;AAC1C,SAAO,IAAI,MAAM,GAAGT,CAAM,0CAA0C;AACxE;AAiBO,SAASU,EAA+BC,GAA4B;AACvE,SAAO,IAAI,MAAM,GAAGX,CAAM,4CAA4CW,CAAW,GAAG;AACxF;AAUO,SAASC,EAAaC,GAAYC,GAA6B;AAClE,QAAMC,IAAqBD,IAAgB,OAAO,MAC5CE,IAAa,CAAC,cAAc,aAAa,aAAa,YAAY;AAExE,MAAI,CAACA,EAAW,SAASH,EAAK,IAAI;AAC9B,UAAMT,EAAuB,+CAA+CY,EAAW,KAAK,IAAI,CAAC,GAAG;AAGxG,MAAIH,EAAK,OAAOE;AACZ,UAAMX,EAAuB,sCAAsCU,CAAa,KAAK;AAE7F;"}
1
+ {"version":3,"file":"validation.js","sources":["../../src/utils/validation.ts"],"sourcesContent":["const PREFIX = \"CanvicoEditor:\";\r\n\r\nfunction createEditorError(name: string, message: string): Error {\r\n const error = new Error(`${PREFIX} ${message}`);\r\n error.name = name;\r\n return error;\r\n}\r\n\r\n// --- ERROR FACTORY FUNCTIONS ---\r\n\r\n/**\r\n * Creates a standardized error for when a required DOM element is not found.\r\n * * @param selector - The CSS selector that failed to find an element.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createDOMElementNotFoundError(selector: string): Error {\r\n return createEditorError(\"CanvicoDOMElementNotFoundError\", `Required DOM element not found for selector: \"${selector}\".`);\r\n}\r\n\r\n/**\r\n * Creates a standardized error for when the main input element is not of `type=\"file\"`.\r\n * @param {string} selector - The CSS selector used to find the input element.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createInvalidInputTypeError(selector: string): Error {\r\n return createEditorError(\"CanvicoInvalidInputTypeError\", `Element for selector \"${selector}\" is not an <input type=\"file\">.`);\r\n}\r\n\r\n/**\r\n * Creates a standardized error for file validation issues (e.g., wrong type, size).\r\n * @param {string} message - The specific reason why the file is invalid.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createInvalidFileError(message: string): Error {\r\n return createEditorError(\"CanvicoInvalidFileError\", `Invalid file: ${message}`);\r\n}\r\n\r\n/**\r\n * Creates a standardized error for when an image fails to load from a file.\r\n * @param {string} [details=\"File could not be read\"] - Specific details about the loading error.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createImageLoadError(details: string = \"File could not be read\"): Error {\r\n return createEditorError(\"CanvicoImageLoadError\", `Image load error: ${details}`);\r\n}\r\n\r\n/**\r\n * Creates a standardized error for when the canvas 2D rendering context cannot be obtained.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createCanvasContextError(): Error {\r\n return createEditorError(\"CanvicoCanvasContextError\", \"2D context is not supported by the browser.\");\r\n}\r\n\r\n/**\r\n * Creates a standardized error for when a save operation is attempted with no image loaded.\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createImageSaveError(): Error {\r\n return createEditorError(\"CanvicoImageSaveError\", \"Cannot save because no image is loaded.\");\r\n}\r\n\r\n/**\r\n * Creates a standardized error for when a required browser feature is not supported.\r\n * @param {string} featureName - The name of the required feature (e.g., 'FileReader').\r\n * @returns {Error} A new Error object with a descriptive message.\r\n */\r\nexport function createFeatureNotSupportedError(featureName: string): Error {\r\n return createEditorError(\"CanvicoFeatureNotSupportedError\", `Required browser feature not supported: ${featureName}.`);\r\n}\r\n\r\n// --- VALIDATION FUNCTIONS ---\r\n\r\n/**\r\n * Validates if the selected file is a supported image and within the size limit.\r\n * @param {File} file - The file to validate.\r\n * @param {number} maxFileSizeMB - The maximum allowed file size in megabytes.\r\n * @throws {Error} If the file type is unsupported or the file size exceeds the limit.\r\n */\r\nexport function validateFile(file: File, maxFileSizeMB: number): void {\r\n const maxFileSizeInBytes = maxFileSizeMB * 1024 * 1024;\r\n const validTypes = [\"image/jpeg\", \"image/png\", \"image/webp\"];\r\n\r\n if (!validTypes.includes(file.type)) {\r\n throw createInvalidFileError(`Unsupported file type. Supported types are: ${validTypes.join(\", \")}.`);\r\n }\r\n\r\n if (file.size > maxFileSizeInBytes) {\r\n throw createInvalidFileError(`File is too large. Maximum size is ${maxFileSizeMB}MB.`);\r\n }\r\n}\r\n"],"names":["PREFIX","createEditorError","name","message","error","createDOMElementNotFoundError","selector","createInvalidInputTypeError","createInvalidFileError","createImageLoadError","details","createCanvasContextError","createImageSaveError","createFeatureNotSupportedError","featureName","validateFile","file","maxFileSizeMB","maxFileSizeInBytes","validTypes"],"mappings":"AAAA,MAAMA,IAAS;AAEf,SAASC,EAAkBC,GAAcC,GAAwB;AAC7D,QAAMC,IAAQ,IAAI,MAAM,GAAGJ,CAAM,IAAIG,CAAO,EAAE;AAC9C,SAAAC,EAAM,OAAOF,GACNE;AACX;AASO,SAASC,EAA8BC,GAAyB;AACnE,SAAOL,EAAkB,kCAAkC,iDAAiDK,CAAQ,IAAI;AAC5H;AAOO,SAASC,EAA4BD,GAAyB;AACjE,SAAOL,EAAkB,gCAAgC,yBAAyBK,CAAQ,kCAAkC;AAChI;AAOO,SAASE,EAAuBL,GAAwB;AAC3D,SAAOF,EAAkB,2BAA2B,iBAAiBE,CAAO,EAAE;AAClF;AAOO,SAASM,EAAqBC,IAAkB,0BAAiC;AACpF,SAAOT,EAAkB,yBAAyB,qBAAqBS,CAAO,EAAE;AACpF;AAMO,SAASC,IAAkC;AAC9C,SAAOV,EAAkB,6BAA6B,6CAA6C;AACvG;AAMO,SAASW,IAA8B;AAC1C,SAAOX,EAAkB,yBAAyB,yCAAyC;AAC/F;AAOO,SAASY,EAA+BC,GAA4B;AACvE,SAAOb,EAAkB,mCAAmC,2CAA2Ca,CAAW,GAAG;AACzH;AAUO,SAASC,EAAaC,GAAYC,GAA6B;AAClE,QAAMC,IAAqBD,IAAgB,OAAO,MAC5CE,IAAa,CAAC,cAAc,aAAa,YAAY;AAE3D,MAAI,CAACA,EAAW,SAASH,EAAK,IAAI;AAC9B,UAAMR,EAAuB,+CAA+CW,EAAW,KAAK,IAAI,CAAC,GAAG;AAGxG,MAAIH,EAAK,OAAOE;AACZ,UAAMV,EAAuB,sCAAsCS,CAAa,KAAK;AAE7F;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "canvico-editor",
3
3
  "description": "A simple and extensible image editor built with TypeScript and the Canvas API. Designed with modularity and developer experience in mind, it separates DOM logic from business logic, provides strong typing, and includes robust error handling. Easily integrable into web projects.",
4
4
  "private": false,
5
- "version": "1.0.2",
5
+ "version": "2.0.0",
6
6
  "type": "module",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
@@ -47,14 +47,16 @@
47
47
  "docs:serve": "cd docs && npm run serve",
48
48
  "docs:api": "cd docs && npm run build",
49
49
  "release:patch": "npm run build && npm version patch && git push --follow-tags",
50
+ "release:minor": "npm run build && npm version minor && git push --follow-tags",
51
+ "release:major": "npm run build && npm version major && git push --follow-tags",
50
52
  "prepublishOnly": "vite build",
51
53
  "publish:package": "npm publish",
52
54
  "build:watch": "vite build --watch"
53
55
  },
54
56
  "devDependencies": {
55
- "@types/node": "^25.0.3",
57
+ "@types/node": "^25.3.2",
56
58
  "typescript": "~5.9.3",
57
- "vite": "^7.2.4",
58
- "vite-plugin-dts": "^4.5.0"
59
+ "vite": "^7.3.1",
60
+ "vite-plugin-dts": "^4.5.4"
59
61
  }
60
62
  }