canvas-editor-engine 1.1.25 → 1.1.27

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;
@@ -1,4 +1,4 @@
1
- import { IProjectModule, TProjectModuleName } from "../types/project";
1
+ import { Project, IProjectModule, TProjectModuleName } from "../types/project";
2
2
  import { ProjectFileSerializer } from "../utils/project-file-serializer";
3
3
  export default class ProjectsService {
4
4
  private static _modules;
@@ -8,4 +8,5 @@ export default class ProjectsService {
8
8
  instance: IProjectModule;
9
9
  };
10
10
  private static _addModule;
11
+ pull(name: Project['name'], description: Project['description']): Project;
11
12
  }
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
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");
3
6
  const project_file_serializer_1 = require("../utils/project-file-serializer");
7
+ const through_history_service_1 = require("./through-history.service");
4
8
  class LocalStorageProjectModule {
5
9
  projectsKey = 'cee-projects';
6
10
  getProjectsFromLocalStorage() {
@@ -94,5 +98,15 @@ class ProjectsService {
94
98
  static _addModule(name, module) {
95
99
  ProjectsService._modules.push({ name, instance: module });
96
100
  }
101
+ pull(name, description) {
102
+ const project = new project_1.Project();
103
+ project.id = new guid4_1.Guid4().generate();
104
+ project.description = description || 'New Project';
105
+ project.name = name || 'New Project';
106
+ project.state.cache = through_history_service_1.default.cache;
107
+ project.state.history = store_1.default.store.historyState.historyLines;
108
+ project.state.current = store_1.default.store.imageState.getEntry();
109
+ return project;
110
+ }
97
111
  }
98
112
  exports.default = ProjectsService;
@@ -0,0 +1,7 @@
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
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const project_1 = require("../types/project");
4
+ class PullProjectService {
5
+ static _project = new project_1.Project();
6
+ static get project() {
7
+ return this._project;
8
+ }
9
+ static refreshProject() {
10
+ PullProjectService._project = new project_1.Project();
11
+ }
12
+ static updateProject(project) {
13
+ Object.keys(project).forEach((key) => {
14
+ PullProjectService._project[key] = project[key];
15
+ });
16
+ }
17
+ }
18
+ 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.25",
3
+ "version": "1.1.27",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",