canvas-editor-engine 1.0.73 → 1.0.75
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.
- package/dist/services/crop.service.js +8 -6
- package/dist/store/history.state.d.ts +13 -0
- package/dist/store/history.state.js +33 -0
- package/dist/store/image.state.d.ts +15 -4
- package/dist/store/image.state.js +37 -6
- package/dist/store/store.d.ts +3 -1
- package/dist/store/store.js +6 -2
- package/dist/types/history.d.ts +4 -0
- package/dist/types/history.js +2 -0
- package/package.json +1 -1
|
@@ -19,12 +19,14 @@ class CropService {
|
|
|
19
19
|
y: (config_1.default.CANVAS_SIZE.height / 2) - (options.height / 2),
|
|
20
20
|
};
|
|
21
21
|
filter.update(imageData, putOptions);
|
|
22
|
-
store_1.default.store.imageState.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
store_1.default.store.imageState.reduce({
|
|
23
|
+
tempImageData: imageData,
|
|
24
|
+
position: putOptions,
|
|
25
|
+
size: {
|
|
26
|
+
width: options.width,
|
|
27
|
+
height: options.height,
|
|
28
|
+
}
|
|
29
|
+
}, "Use crop");
|
|
28
30
|
}
|
|
29
31
|
static viewCropButton() {
|
|
30
32
|
const cropButtons = excretions_component_1.default.excretionWrap.querySelectorAll('.crop-button');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StateService } from "../services/store.service";
|
|
2
|
+
import { IHistoryLine } from "../types/history";
|
|
3
|
+
export interface IHistoryState {
|
|
4
|
+
historyLines: IHistoryLine[];
|
|
5
|
+
}
|
|
6
|
+
export declare class HistoryState implements StateService {
|
|
7
|
+
private default;
|
|
8
|
+
private _historyLines;
|
|
9
|
+
get historyLines(): IHistoryState['historyLines'];
|
|
10
|
+
constructor();
|
|
11
|
+
reduce(payload: IHistoryLine | IHistoryState): void;
|
|
12
|
+
reset(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HistoryState = void 0;
|
|
4
|
+
;
|
|
5
|
+
class HistoryState {
|
|
6
|
+
default = {
|
|
7
|
+
historyLines: [],
|
|
8
|
+
};
|
|
9
|
+
_historyLines = this.default.historyLines;
|
|
10
|
+
get historyLines() { return this._historyLines; }
|
|
11
|
+
;
|
|
12
|
+
constructor() {
|
|
13
|
+
this.reset();
|
|
14
|
+
}
|
|
15
|
+
reduce(payload) {
|
|
16
|
+
let isUpdate = false;
|
|
17
|
+
if (!!payload?.historyLines) {
|
|
18
|
+
this._historyLines = payload.historyLines;
|
|
19
|
+
isUpdate = true;
|
|
20
|
+
}
|
|
21
|
+
if (!!payload.view) {
|
|
22
|
+
this._historyLines.push(payload);
|
|
23
|
+
isUpdate = true;
|
|
24
|
+
}
|
|
25
|
+
if (isUpdate) {
|
|
26
|
+
console.log(this._historyLines);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
reset() {
|
|
30
|
+
this.reduce(this.default);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.HistoryState = HistoryState;
|
|
@@ -5,10 +5,21 @@ export interface IImageState {
|
|
|
5
5
|
size: ISize;
|
|
6
6
|
tempImageData: ImageData | null;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
8
|
+
export interface IImageStateReduce {
|
|
9
|
+
position?: IImageState['position'];
|
|
10
|
+
size?: IImageState['size'];
|
|
11
|
+
tempImageData?: IImageState['tempImageData'];
|
|
12
|
+
}
|
|
13
|
+
export declare class ImageState implements StateService {
|
|
9
14
|
private default;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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;
|
|
13
23
|
reset(): void;
|
|
24
|
+
addToHistory(title: string): void;
|
|
14
25
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ImageState = void 0;
|
|
4
|
+
const store_1 = require("./store");
|
|
5
|
+
;
|
|
4
6
|
;
|
|
5
7
|
class ImageState {
|
|
6
8
|
default = {
|
|
@@ -14,13 +16,42 @@ class ImageState {
|
|
|
14
16
|
},
|
|
15
17
|
tempImageData: null,
|
|
16
18
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
_position = this.default.position;
|
|
20
|
+
_size = this.default.size;
|
|
21
|
+
_tempImageData = this.default.tempImageData;
|
|
22
|
+
get position() { return this._position; }
|
|
23
|
+
;
|
|
24
|
+
get size() { return this._size; }
|
|
25
|
+
;
|
|
26
|
+
get tempImageData() { return this._tempImageData; }
|
|
27
|
+
;
|
|
28
|
+
constructor() {
|
|
29
|
+
this.reset();
|
|
30
|
+
}
|
|
31
|
+
reduce(payload, title) {
|
|
32
|
+
let isUpdate = false;
|
|
33
|
+
if (!!payload?.position) {
|
|
34
|
+
this._position = payload.position;
|
|
35
|
+
}
|
|
36
|
+
if (!!payload?.size) {
|
|
37
|
+
this._size = payload.size;
|
|
38
|
+
}
|
|
39
|
+
if (!!payload?.tempImageData) {
|
|
40
|
+
this._tempImageData = payload.tempImageData;
|
|
41
|
+
isUpdate = true;
|
|
42
|
+
}
|
|
43
|
+
if (isUpdate) {
|
|
44
|
+
this.addToHistory(`${title || "reduce image"}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
20
47
|
reset() {
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
48
|
+
this.reduce(this.default, "reset to default");
|
|
49
|
+
}
|
|
50
|
+
addToHistory(title) {
|
|
51
|
+
store_1.default.store.historyState.reduce({
|
|
52
|
+
view: title,
|
|
53
|
+
stateName: 'image',
|
|
54
|
+
});
|
|
24
55
|
}
|
|
25
56
|
}
|
|
26
57
|
exports.ImageState = ImageState;
|
package/dist/store/store.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { StoreService } from "../services/store.service";
|
|
2
|
+
import { HistoryState } from "./history.state";
|
|
2
3
|
import { ImageState } from "./image.state";
|
|
3
4
|
export declare class Store implements StoreService {
|
|
4
5
|
imageState: ImageState;
|
|
5
|
-
|
|
6
|
+
historyState: HistoryState;
|
|
7
|
+
constructor(imageState: ImageState, historyState: HistoryState);
|
|
6
8
|
reset(): void;
|
|
7
9
|
}
|
|
8
10
|
export default class AppStore {
|
package/dist/store/store.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Store = void 0;
|
|
4
|
+
const history_state_1 = require("./history.state");
|
|
4
5
|
const image_state_1 = require("./image.state");
|
|
5
6
|
class Store {
|
|
6
7
|
imageState;
|
|
7
|
-
|
|
8
|
+
historyState;
|
|
9
|
+
constructor(imageState, historyState) {
|
|
8
10
|
this.imageState = imageState;
|
|
11
|
+
this.historyState = historyState;
|
|
9
12
|
}
|
|
10
13
|
;
|
|
11
14
|
reset() {
|
|
12
15
|
this.imageState.reset();
|
|
16
|
+
this.historyState.reset();
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
19
|
exports.Store = Store;
|
|
16
20
|
class AppStore {
|
|
17
21
|
static store;
|
|
18
22
|
static {
|
|
19
|
-
AppStore.store = new Store(new image_state_1.ImageState());
|
|
23
|
+
AppStore.store = new Store(new image_state_1.ImageState(), new history_state_1.HistoryState());
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
exports.default = AppStore;
|