canvas-editor-engine 2.0.12 → 2.0.13

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 (42) hide show
  1. package/dist/components/canvas.component.d.ts +21 -0
  2. package/dist/components/excretions.component.d.ts +32 -0
  3. package/dist/components/loading.component.d.ts +14 -0
  4. package/dist/components/pipette.component.d.ts +23 -0
  5. package/dist/components/slot.component.d.ts +10 -0
  6. package/dist/config.d.ts +23 -0
  7. package/dist/filters/collection/vague.d.ts +13 -0
  8. package/dist/filters/index.d.ts +2 -0
  9. package/dist/index.d.ts +18 -574
  10. package/dist/index.mjs +2148 -0
  11. package/dist/services/component.service.d.ts +5 -0
  12. package/dist/services/crop.service.d.ts +7 -0
  13. package/dist/services/download.service.d.ts +4 -0
  14. package/dist/services/draw.service.d.ts +17 -0
  15. package/dist/services/event.service.d.ts +16 -0
  16. package/dist/services/logger.service.d.ts +20 -0
  17. package/dist/services/projects.service.d.ts +11 -0
  18. package/dist/services/pull-project.service.d.ts +8 -0
  19. package/dist/services/store.service.d.ts +6 -0
  20. package/dist/services/through-history.service.d.ts +12 -0
  21. package/dist/services/tool-layers.service.d.ts +4 -0
  22. package/dist/services/tool.service.d.ts +10 -0
  23. package/dist/store/history.state.d.ts +15 -0
  24. package/dist/store/image.state.d.ts +30 -0
  25. package/dist/store/store.d.ts +13 -0
  26. package/dist/types/canvas.d.ts +10 -0
  27. package/dist/types/cursor.d.ts +9 -0
  28. package/dist/types/excretion.d.ts +27 -0
  29. package/dist/types/general.d.ts +24 -0
  30. package/dist/types/history.d.ts +7 -0
  31. package/dist/types/image.d.ts +48 -0
  32. package/dist/types/log.d.ts +13 -0
  33. package/dist/types/pipette.d.ts +1 -0
  34. package/dist/types/project.d.ts +38 -0
  35. package/dist/utils/convert.d.ts +12 -0
  36. package/dist/utils/filter.d.ts +21 -0
  37. package/dist/utils/guid4.d.ts +13 -0
  38. package/dist/utils/project-file-serializer.d.ts +13 -0
  39. package/dist/web-component.d.ts +30 -0
  40. package/package.json +11 -5
  41. package/dist/index.mjs.js +0 -2
  42. package/dist/index.mjs.js.LICENSE.txt +0 -8
@@ -0,0 +1,5 @@
1
+ import { IWrapOptions } from "../types/general";
2
+ export default class ComponentService {
3
+ protected static getTemplate(template: string, wrapOptions?: IWrapOptions): HTMLElement | null;
4
+ protected static getStyle(css: string): HTMLStyleElement | null;
5
+ }
@@ -0,0 +1,7 @@
1
+ import { IImageOptions } from "../types/image";
2
+ export default class CropService {
3
+ static setup(): void;
4
+ static crop(ctx: CanvasRenderingContext2D): void;
5
+ static viewCropButton(): void;
6
+ static get options(): IImageOptions;
7
+ }
@@ -0,0 +1,4 @@
1
+ export default class DownloadService {
2
+ static getDataUrl(): string;
3
+ static download(filename?: string): void;
4
+ }
@@ -0,0 +1,17 @@
1
+ import type { IDrawImageArgs, IDrawImageProcessor, IFilterOptions, IImageLoggingDataVague, IImageOptions } from "../types/image";
2
+ import { Project } from "../types/project";
3
+ export default class DrawService {
4
+ static imageProcessor: IDrawImageProcessor;
5
+ static drawImage(ctx: CanvasRenderingContext2D, src: string, options: IDrawImageArgs): void;
6
+ static drawProject(ctx: CanvasRenderingContext2D, project: Project): void;
7
+ static drawSmoothImage(useStore: boolean, options: IDrawImageArgs, filterOptions: IFilterOptions): void;
8
+ private static updateImageStateAfterVague;
9
+ private static getFilterArgs;
10
+ }
11
+ export declare class SCImage implements IDrawImageProcessor {
12
+ private img;
13
+ private ctx;
14
+ constructor(src: string, ctx: CanvasRenderingContext2D);
15
+ draw(options?: IDrawImageArgs): Promise<unknown>;
16
+ vague(options: IImageOptions, filterOptions: IFilterOptions): Promise<IImageLoggingDataVague>;
17
+ }
@@ -0,0 +1,16 @@
1
+ import { IGUID4 } from "../types/general";
2
+ export declare abstract class ControlEvent {
3
+ name: string;
4
+ action: (args?: any) => any;
5
+ }
6
+ export declare class EventAtom implements ControlEvent {
7
+ id: IGUID4;
8
+ name: string;
9
+ action: (args?: any) => any;
10
+ }
11
+ export default class EventService {
12
+ static eventList: EventAtom[];
13
+ static subcribe(controlEvent: ControlEvent): void;
14
+ static dispatch(name: ControlEvent['name'], eventArgs?: any): void;
15
+ static applyEvents(baseElement: HTMLDivElement): void;
16
+ }
@@ -0,0 +1,20 @@
1
+ import { ILog, ILogItem } from "../types/log";
2
+ import ComponentService from "./component.service";
3
+ export default class LoggerService {
4
+ static log: ILog<ComponentService, any, any>;
5
+ static get components(): {
6
+ add<TLogPrototype>(logItem: ILogItem<TLogPrototype>): void;
7
+ get<TLogPrototype>(field: keyof ILog<ComponentService, any, any>, name: string): void;
8
+ };
9
+ static get services(): {
10
+ add<TLogPrototype>(logItem: ILogItem<TLogPrototype>): void;
11
+ get<TLogPrototype>(field: keyof ILog<ComponentService, any, any>, name: string): void;
12
+ };
13
+ static get planed(): {
14
+ add<TLogPrototype>(logItem: ILogItem<TLogPrototype>): void;
15
+ get<TLogPrototype>(field: keyof ILog<ComponentService, any, any>, name: string): void;
16
+ };
17
+ private static getMethods;
18
+ private static _add;
19
+ private static _get;
20
+ }
@@ -0,0 +1,11 @@
1
+ import { IProjectModule, TProjectModuleName } from "../types/project";
2
+ import { ProjectFileSerializer } from "../utils/project-file-serializer";
3
+ export default class ProjectsService {
4
+ private static _modules;
5
+ private static _serializer;
6
+ static on(moduleName: TProjectModuleName): {
7
+ getSerializerInstance: (file: any) => ProjectFileSerializer;
8
+ instance: IProjectModule;
9
+ };
10
+ private static _addModule;
11
+ }
@@ -0,0 +1,8 @@
1
+ import { IUpdateProject, Project } from "../types/project";
2
+ export default class PullProjectService {
3
+ private static _project;
4
+ static get project(): Project;
5
+ static refreshProject(): void;
6
+ static updateProject(project: IUpdateProject): void;
7
+ static pull(name: Project['name'], description: Project['description']): void;
8
+ }
@@ -0,0 +1,6 @@
1
+ export declare abstract class StateService {
2
+ abstract reset(): void;
3
+ }
4
+ export declare abstract class StoreService {
5
+ abstract reset(): void;
6
+ }
@@ -0,0 +1,12 @@
1
+ import { IHistoryLine } from "../types/history";
2
+ import { Project } from "../types/project";
3
+ export default class ThroughHistoryService {
4
+ static cache: IHistoryLine[];
5
+ static current(): IHistoryLine;
6
+ static prev(): IHistoryLine;
7
+ static undo(ctx: CanvasRenderingContext2D): void;
8
+ static redo(ctx: CanvasRenderingContext2D): void;
9
+ static clearCache(): void;
10
+ static recovery(project: Project): void;
11
+ private static updateCanvas;
12
+ }
@@ -0,0 +1,4 @@
1
+ export default class ToolLayerService {
2
+ static multiplier: number;
3
+ static getLayerIndex(layerName: string): number;
4
+ }
@@ -0,0 +1,10 @@
1
+ import { ITool } from "../types/general";
2
+ export default class ToolService {
3
+ static before: ITool | null;
4
+ static active: ITool | null;
5
+ static registry: ITool[];
6
+ static add(tool: ITool): boolean;
7
+ static setActive(id: ITool['id']): void;
8
+ static offActive(id?: ITool['id']): void;
9
+ private static off;
10
+ }
@@ -0,0 +1,15 @@
1
+ import { StateService } from "../services/store.service";
2
+ import { IHistoryLine, TReducerNames } from "../types/history";
3
+ export interface IHistoryState {
4
+ historyLines: IHistoryLine[];
5
+ }
6
+ export declare class HistoryState implements StateService {
7
+ private default;
8
+ private _emergeCompleteIt;
9
+ private _historyLines;
10
+ get historyLines(): IHistoryState['historyLines'];
11
+ constructor();
12
+ reduce(name: TReducerNames, payload?: IHistoryLine | IHistoryState): void;
13
+ emerge(completeIt: (history: IHistoryState['historyLines']) => void): void;
14
+ reset(): void;
15
+ }
@@ -0,0 +1,30 @@
1
+ import { StateService } from "../services/store.service";
2
+ import { IPosition, ISize } from "../types/general";
3
+ export interface IImageState {
4
+ position: IPosition;
5
+ size: ISize;
6
+ tempImageData: ImageData | null;
7
+ }
8
+ export interface IImageStateReduce {
9
+ position?: IImageState['position'];
10
+ size?: IImageState['size'];
11
+ tempImageData?: IImageState['tempImageData'];
12
+ }
13
+ export declare class ImageState implements StateService {
14
+ private default;
15
+ private _position;
16
+ private _size;
17
+ private _tempImageData;
18
+ get position(): IImageState['position'];
19
+ get size(): IImageState['size'];
20
+ get tempImageData(): IImageState['tempImageData'];
21
+ constructor();
22
+ reduce(payload: IImageStateReduce, title?: string): void;
23
+ reset(): void;
24
+ getEntry(): {
25
+ position: IPosition;
26
+ size: ISize;
27
+ imageData: ImageData;
28
+ };
29
+ addToHistory(title: string): void;
30
+ }
@@ -0,0 +1,13 @@
1
+ import { StoreService } from "../services/store.service";
2
+ import { HistoryState } from "./history.state";
3
+ import { ImageState } from "./image.state";
4
+ export declare class Store implements StoreService {
5
+ imageState: ImageState;
6
+ historyState: HistoryState;
7
+ constructor(imageState: ImageState, historyState: HistoryState);
8
+ reset(): void;
9
+ }
10
+ export default class AppStore {
11
+ static store: Store;
12
+ static subscribe(to: 'history', completeIt: (...args: any) => void): void;
13
+ }
@@ -0,0 +1,10 @@
1
+ import { ICursorPosition } from "./cursor";
2
+ export interface ICanvasSize {
3
+ width: number;
4
+ height: number;
5
+ }
6
+ export type TSubscriptionTypes = 'click' | 'mousemove' | 'mousedown' | 'mouseup';
7
+ export type TSubscribeAction = (event: MouseEvent, cursorPosition?: ICursorPosition) => void;
8
+ export type TSubscriptions = {
9
+ [key in TSubscriptionTypes]: TSubscribeAction[];
10
+ };
@@ -0,0 +1,9 @@
1
+ export interface ICursorPosition {
2
+ x: number;
3
+ y: number;
4
+ }
5
+ export interface ICursorStyle {
6
+ before: TCursorStyleName | null;
7
+ current: TCursorStyleName | null;
8
+ }
9
+ export type TCursorStyleName = 'default' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'copy' | 'alias' | 'move' | 'not-allowed' | 'grab' | 'grabbing' | 'zoom-in' | 'zoom-out';
@@ -0,0 +1,27 @@
1
+ export interface IExcretionsCoords {
2
+ start?: {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ end?: {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ }
11
+ export interface IExcretionTempStart {
12
+ start: {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ }
17
+ export interface IExcretionTempEnd {
18
+ end: {
19
+ x: number;
20
+ y: number;
21
+ };
22
+ }
23
+ export type TExcretionTempCoords = (IExcretionTempStart | IExcretionTempEnd)[];
24
+ export type TExcretionToolState = 'taken' | 'abandoned';
25
+ export type TExcretionState = 'create' | 'add' | 'remove' | 'abandoned';
26
+ export type TExcretionActivity = 'active' | 'end' | 'abandoned';
27
+ export type TExcretionStyle = 'default' | 'crop';
@@ -0,0 +1,24 @@
1
+ export type THEXColor = `#${string}`;
2
+ export type TComponent = HTMLElement | HTMLDivElement | HTMLCanvasElement;
3
+ export interface IWrapOptions {
4
+ tag?: string;
5
+ className?: string;
6
+ id?: string;
7
+ }
8
+ export interface ITool {
9
+ id: number;
10
+ name: string;
11
+ onAction?: (...args: any) => void;
12
+ offAction?: (...args: any) => void;
13
+ support?: (...args: any) => void;
14
+ }
15
+ export type IGUID4 = `${number}-${number}-${number}-${number}`;
16
+ export interface IPosition {
17
+ x: number;
18
+ y: number;
19
+ }
20
+ export interface ISize {
21
+ width: number;
22
+ height: number;
23
+ }
24
+ export type TStringMatrix = string[][];
@@ -0,0 +1,7 @@
1
+ import { IImageState } from "../store/image.state";
2
+ export interface IHistoryLine {
3
+ stateName: string;
4
+ stateValue: IImageState;
5
+ view: string;
6
+ }
7
+ export type TReducerNames = 'SET_HISTORY' | 'UPDATE_HISTORY' | 'UNDO' | 'REDO';
@@ -0,0 +1,48 @@
1
+ import { IPosition, ISize, TStringMatrix } from "./general";
2
+ export interface IOptionImageSize {
3
+ width?: number;
4
+ height?: number;
5
+ }
6
+ export interface IImageOptions extends IPosition, IOptionImageSize {
7
+ }
8
+ export interface IDrawImageArgs {
9
+ position: IArgumentImagePosition;
10
+ size?: TArgumentImageSize;
11
+ }
12
+ export interface IArgumentImagePosition extends IPosition {
13
+ }
14
+ export interface IPixelPosition extends IPosition {
15
+ }
16
+ export type TArgumentImageSize = IOptionImageSize | 'initial';
17
+ export interface IImageSize extends ISize {
18
+ }
19
+ export type TRGBABuff = TByteRGBColor[];
20
+ export type TByteRGBColor = [number, number, number, number];
21
+ export type TBuff<T> = T[][];
22
+ export type TQualityBuff = TStringMatrix;
23
+ export type TRangeCommit = IPixelPosition[][];
24
+ export type TFilterMethod = 'pixel';
25
+ export interface IFilterOptions {
26
+ quality: number;
27
+ }
28
+ export declare const enum E_RGBA {
29
+ r = 0,
30
+ g = 1,
31
+ b = 2,
32
+ a = 3
33
+ }
34
+ export interface IExtendedImageDataModel {
35
+ imageData: ImageData;
36
+ size: ISize;
37
+ }
38
+ export interface IImageLoggingData {
39
+ imageData: ImageData;
40
+ size: ISize;
41
+ position: IPosition;
42
+ }
43
+ export interface IImageLoggingDataVague extends IImageLoggingData, IFilterOptions {
44
+ }
45
+ export interface IDrawImageProcessor {
46
+ draw(options?: IDrawImageArgs): Promise<any>;
47
+ vague(options: IImageOptions, filterOptions: IFilterOptions): Promise<IImageLoggingDataVague>;
48
+ }
@@ -0,0 +1,13 @@
1
+ export interface ILog<A, R, P> {
2
+ components: ILogItem<A>[];
3
+ services: ILogItem<R>[];
4
+ planed: ILogItem<P>[];
5
+ }
6
+ export interface ILogItem<TLogPrototype> {
7
+ info: ILogItemInfo;
8
+ prototype: TLogPrototype;
9
+ }
10
+ export interface ILogItemInfo {
11
+ name: string;
12
+ description: string;
13
+ }
@@ -0,0 +1 @@
1
+ export type TPipetteState = 'taken' | 'abandoned' | 'selected-color';
@@ -0,0 +1,38 @@
1
+ import { IHistoryLine } from "./history";
2
+ import { IImageLoggingData } from "./image";
3
+ export declare class Project {
4
+ id: string;
5
+ name: string;
6
+ description: string;
7
+ state: {
8
+ current: IImageLoggingData;
9
+ history: IHistoryLine[];
10
+ cache: IHistoryLine[];
11
+ };
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ }
15
+ export interface IUpdateProject {
16
+ id?: string;
17
+ name?: string;
18
+ description?: string;
19
+ state?: {
20
+ current: IImageLoggingData;
21
+ history: IHistoryLine[];
22
+ cache: IHistoryLine[];
23
+ };
24
+ updatedAt?: string;
25
+ }
26
+ export interface IProjectModule {
27
+ getProjects(): Project[];
28
+ getProject(projectId: string): Project;
29
+ saveProjects(projects: Project[]): void;
30
+ saveProject(project: Project): void;
31
+ removeProject(projectId: string): void;
32
+ updateProject(project: Project): void;
33
+ }
34
+ export type TProjectModule = {
35
+ name: string;
36
+ instance: IProjectModule;
37
+ };
38
+ export type TProjectModuleName = 'LocalStorage' | 'File';
@@ -0,0 +1,12 @@
1
+ import type { TByteRGBColor } from "../types/image";
2
+ import type { THEXColor } from "../types/general";
3
+ export declare class Convert {
4
+ static byteRGBToHEX(color: TByteRGBColor): THEXColor;
5
+ static rgbToHex(r: number, g: number, b: number): THEXColor;
6
+ static hexToRgb(hex: string): {
7
+ r: number;
8
+ g: number;
9
+ b: number;
10
+ };
11
+ private static componentToHEX;
12
+ }
@@ -0,0 +1,21 @@
1
+ import { IExtendedImageDataModel, type IImageOptions, type IImageSize, type TBuff, type TRGBABuff } from "../types/image";
2
+ import type { ISize, THEXColor } from '../types/general';
3
+ export declare class Filter {
4
+ ctx: CanvasRenderingContext2D;
5
+ imageSize: IImageSize;
6
+ constructor(ctx: CanvasRenderingContext2D);
7
+ setImageSize(size: IImageSize): void;
8
+ copy(options: IImageOptions): ImageData;
9
+ copyExtendedModel(options: IImageOptions): IExtendedImageDataModel;
10
+ update(imgData: ImageData, options: IImageOptions): void;
11
+ clearEmptyPixels(imageData: ImageData): IExtendedImageDataModel;
12
+ getSizeOfSparseMatrix(RGBAMatrix: TBuff<number[]>, tempSize: ISize): ISize;
13
+ getBuffCollection(imageData: ImageData): {
14
+ rowRGBABuff: TRGBABuff;
15
+ hexBuff: `#${string}`[];
16
+ buff: TBuff<string>;
17
+ };
18
+ getBuff(hexBuff: THEXColor[]): TBuff<string>;
19
+ getRGBAMatrix(rowRGBABuff: TRGBABuff, size?: ISize): TBuff<number[]>;
20
+ getRowRGBABuff(imageData: ImageData): TRGBABuff;
21
+ }
@@ -0,0 +1,13 @@
1
+ import { IGUID4 } from "../types/general";
2
+ export declare class Guid4 {
3
+ stack: IGUID4[];
4
+ guid4: IGUID4;
5
+ constructor();
6
+ generate(): `${number}-${number}-${number}-${number}`;
7
+ get finite(): IGUID4;
8
+ private generateWithFactor;
9
+ private getFactor;
10
+ private get attempt();
11
+ private get Guid4();
12
+ private formating;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { Project } from "../types/project";
2
+ export declare class ProjectFileSerializer {
3
+ private file;
4
+ private projects;
5
+ constructor(file: any);
6
+ private load;
7
+ saveProjects(projects: Project[]): void;
8
+ getProjects(): Project[];
9
+ getProject(projectId: string): Project;
10
+ saveProject(project: Project): void;
11
+ removeProject(projectId: string): void;
12
+ updateProject(project: Project): void;
13
+ }
@@ -0,0 +1,30 @@
1
+ import { TComponent } from "./types/general";
2
+ export declare class WebComponentWrapper {
3
+ baseElement: HTMLDivElement;
4
+ editorWrapElement: HTMLDivElement;
5
+ stylesWrapElement: HTMLDivElement;
6
+ toolsWrapElement: HTMLDivElement;
7
+ constructor();
8
+ get base(): {
9
+ add: (component: TComponent, style?: HTMLStyleElement) => HTMLDivElement;
10
+ };
11
+ get editorWrap(): {
12
+ add: (component: TComponent, style?: HTMLStyleElement) => HTMLDivElement;
13
+ };
14
+ get stylesWrap(): {
15
+ add: (component: TComponent, style?: HTMLStyleElement) => HTMLDivElement;
16
+ };
17
+ get toolsWrap(): {
18
+ add: (component: TComponent, style?: HTMLStyleElement) => HTMLDivElement;
19
+ };
20
+ private _methods;
21
+ private _add;
22
+ private _baseStyle;
23
+ }
24
+ declare global {
25
+ interface HTMLElement {
26
+ }
27
+ }
28
+ export default class WebComponent extends HTMLElement {
29
+ constructor();
30
+ }
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "2.0.12",
3
+ "version": "2.0.13",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
- "main": "dist/index.mjs.js",
5
+ "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
8
8
  "/dist"
9
9
  ],
10
+ "type": "module",
10
11
  "scripts": {
11
12
  "test": "node test/test.js",
12
13
  "build-ts": "tsc",
13
14
  "build": "npx webpack",
15
+ "build:rollup": "rollup -c",
14
16
  "realise": "npm version patch && npm publish"
15
17
  },
16
18
  "keywords": [
@@ -25,11 +27,15 @@
25
27
  "@types/node": "^22.7.4",
26
28
  "ts-loader": "^9.5.1",
27
29
  "typescript": "^5.7.2",
30
+ "typescript-declaration-webpack-plugin": "^0.3.0",
28
31
  "webpack": "^5.97.1",
29
- "webpack-cli": "^5.1.4",
30
- "typescript-declaration-webpack-plugin": "^0.3.0"
32
+ "webpack-cli": "^5.1.4"
31
33
  },
32
34
  "dependencies": {
33
- "lodash": "^4.17.21"
35
+ "@rollup/plugin-terser": "^0.4.4",
36
+ "@rollup/plugin-typescript": "^12.1.1",
37
+ "lodash": "^4.17.21",
38
+ "rollup": "^4.28.1",
39
+ "tslib": "^2.8.1"
34
40
  }
35
41
  }