canvas-editor-engine 1.1.26 → 1.1.28

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.
@@ -1,9 +1,9 @@
1
1
  import type { IDrawImageArgs, IDrawImageProcessor, IFilterOptions, IImageLoggingDataVague, IImageOptions } from "../types/image";
2
- import { IProject } from "../types/project";
2
+ import { Project } from "../types/project";
3
3
  export default class DrawService {
4
4
  static imageProcessor: IDrawImageProcessor;
5
5
  static drawImage(ctx: CanvasRenderingContext2D, src: string, options: IDrawImageArgs): void;
6
- static drawProject(ctx: CanvasRenderingContext2D, project: IProject): void;
6
+ static drawProject(ctx: CanvasRenderingContext2D, project: Project): void;
7
7
  static drawSmoothImage(useStore: boolean, options: IDrawImageArgs, filterOptions: IFilterOptions): void;
8
8
  private static updateImageStateAfterVague;
9
9
  private static getFilterArgs;
@@ -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,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const store_1 = require("../store/store");
4
+ const project_1 = require("../types/project");
5
+ const guid4_1 = require("../utils/guid4");
6
+ const through_history_service_1 = require("./through-history.service");
7
+ class PullProjectService {
8
+ static _project = new project_1.Project();
9
+ static get project() {
10
+ return this._project;
11
+ }
12
+ static refreshProject() {
13
+ PullProjectService._project = new project_1.Project();
14
+ }
15
+ static updateProject(project) {
16
+ Object.keys(project).forEach((key) => {
17
+ PullProjectService._project[key] = project[key];
18
+ });
19
+ }
20
+ static pull(name, description) {
21
+ const project = new project_1.Project();
22
+ project.id = new guid4_1.Guid4().generate();
23
+ project.description = description || 'New Project';
24
+ project.name = name || 'New Project';
25
+ project.state.cache = through_history_service_1.default.cache;
26
+ project.state.history = store_1.default.store.historyState.historyLines;
27
+ project.state.current = store_1.default.store.imageState.getEntry();
28
+ this._project = project;
29
+ }
30
+ }
31
+ exports.default = PullProjectService;
@@ -64,7 +64,6 @@ class Reducer {
64
64
  isUpdate = true;
65
65
  }
66
66
  if (isUpdate && !!this.state._emergeCompleteIt) {
67
- console.log(JSON.stringify(this.state._historyLines));
68
67
  this.state._emergeCompleteIt(this.state._historyLines);
69
68
  }
70
69
  }
@@ -21,5 +21,10 @@ export declare class ImageState implements StateService {
21
21
  constructor();
22
22
  reduce(payload: IImageStateReduce, title?: string): void;
23
23
  reset(): void;
24
+ getEntry(): {
25
+ position: IPosition;
26
+ size: ISize;
27
+ imageData: ImageData;
28
+ };
24
29
  addToHistory(title: string): void;
25
30
  }
@@ -47,6 +47,13 @@ class ImageState {
47
47
  reset() {
48
48
  this.reduce(this.default, "reset to default");
49
49
  }
50
+ getEntry() {
51
+ return {
52
+ position: this._position,
53
+ size: this._size,
54
+ imageData: this._tempImageData,
55
+ };
56
+ }
50
57
  addToHistory(title) {
51
58
  const stateValue = {
52
59
  position: this._position,
@@ -1,6 +1,6 @@
1
1
  import { IHistoryLine } from "./history";
2
2
  import { IImageLoggingData } from "./image";
3
- export interface IProject {
3
+ export declare class Project {
4
4
  id: string;
5
5
  name: string;
6
6
  description: string;
@@ -12,13 +12,24 @@ export interface IProject {
12
12
  createdAt: string;
13
13
  updatedAt: string;
14
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
+ }
15
26
  export interface IProjectModule {
16
- getProjects(): IProject[];
17
- getProject(projectId: string): IProject;
18
- saveProjects(projects: IProject[]): void;
19
- saveProject(project: IProject): void;
27
+ getProjects(): Project[];
28
+ getProject(projectId: string): Project;
29
+ saveProjects(projects: Project[]): void;
30
+ saveProject(project: Project): void;
20
31
  removeProject(projectId: string): void;
21
- updateProject(project: IProject): void;
32
+ updateProject(project: Project): void;
22
33
  }
23
34
  export type TProjectModule = {
24
35
  name: string;
@@ -1,2 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Project = void 0;
4
+ class Project {
5
+ id = null;
6
+ name = null;
7
+ description = null;
8
+ state = null;
9
+ createdAt = new Date(Date.now()).toString();
10
+ updatedAt = new Date(Date.now()).toString();
11
+ }
12
+ exports.Project = Project;
13
+ ;
14
+ ;
@@ -1,13 +1,13 @@
1
- import { IProject } from "../types/project";
1
+ import { Project } from "../types/project";
2
2
  export declare class ProjectFileSerializer {
3
3
  private file;
4
4
  private projects;
5
5
  constructor(file: any);
6
6
  private load;
7
- saveProjects(projects: IProject[]): void;
8
- getProjects(): IProject[];
9
- getProject(projectId: string): IProject;
10
- saveProject(project: IProject): void;
7
+ saveProjects(projects: Project[]): void;
8
+ getProjects(): Project[];
9
+ getProject(projectId: string): Project;
10
+ saveProject(project: Project): void;
11
11
  removeProject(projectId: string): void;
12
- updateProject(project: IProject): void;
12
+ updateProject(project: Project): void;
13
13
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProjectFileSerializer = void 0;
4
4
  class ProjectFileSerializer {
5
5
  file;
6
- projects;
6
+ projects = [];
7
7
  constructor(file) {
8
8
  this.file = file;
9
9
  this.projects = this.load();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "1.1.26",
3
+ "version": "1.1.28",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",