@wcardinal/wcardinal-ui 0.168.0 → 0.169.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.
@@ -5,8 +5,12 @@ export declare const DCommandFlag: {
5
5
  */
6
6
  readonly UNSTORABLE: 1;
7
7
  /**
8
- * Commands with a `CLEAR` flag clears the command queue.
8
+ * Commands with a `CLEAR` flag clear the command queue.
9
9
  */
10
10
  readonly CLEAR: 2;
11
+ /**
12
+ * Commands with a `CLEAN` flag are not considered as modifications to documents
13
+ */
14
+ readonly CLEAN: 4;
11
15
  };
12
16
  export declare type DCommandFlag = number;
@@ -1,5 +1,7 @@
1
1
  import { utils } from "pixi.js";
2
2
  import { DCommand } from "./d-command";
3
+ import { DCommandRedo } from "./d-command-redo";
4
+ import { DCommandUndo } from "./d-command-undo";
3
5
  import { DControllerCommand } from "./d-controller-command";
4
6
  export declare class DControllerDefaultCommand extends utils.EventEmitter implements DControllerCommand {
5
7
  protected _position: number;
@@ -10,9 +12,14 @@ export declare class DControllerDefaultCommand extends utils.EventEmitter implem
10
12
  last(): DCommand | null;
11
13
  push(command: DCommand): void;
12
14
  next(): void;
15
+ protected executeUndo(command: DCommandUndo): void;
16
+ protected executeRedo(command: DCommandRedo): void;
17
+ protected execute(command: DCommand): void;
13
18
  protected cleanup(): void;
14
19
  protected remove(size: number): boolean;
15
20
  protected onSuccess(command: DCommand): void;
21
+ protected onSuccessUndo(undoed: DCommand): void;
22
+ protected onSuccessRedo(redoed: DCommand): void;
16
23
  protected onFail(command: DCommand): void;
17
24
  size(): number;
18
25
  clear(): void;
@@ -9,8 +9,12 @@ export var DCommandFlag = {
9
9
  */
10
10
  UNSTORABLE: 1,
11
11
  /**
12
- * Commands with a `CLEAR` flag clears the command queue.
12
+ * Commands with a `CLEAR` flag clear the command queue.
13
13
  */
14
- CLEAR: 2
14
+ CLEAR: 2,
15
+ /**
16
+ * Commands with a `CLEAN` flag are not considered as modifications to documents
17
+ */
18
+ CLEAN: 4
15
19
  };
16
20
  //# sourceMappingURL=d-command-flag.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"d-command-flag.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command-flag.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,IAAM,YAAY,GAAG;IAC3B,IAAI,EAAE,CAAC;IAEP;;OAEG;IACH,UAAU,EAAE,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,CAAC;CACC,CAAC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport const DCommandFlag = {\n\tNONE: 0,\n\n\t/**\n\t * Commands with a `UNSTORABLE` flag will not be queued to the `done` queue.\n\t */\n\tUNSTORABLE: 1,\n\n\t/**\n\t * Commands with a `CLEAR` flag clears the command queue.\n\t */\n\tCLEAR: 2\n} as const;\n\nexport type DCommandFlag = number;\n"]}
1
+ {"version":3,"file":"d-command-flag.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-command-flag.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,IAAM,YAAY,GAAG;IAC3B,IAAI,EAAE,CAAC;IAEP;;OAEG;IACH,UAAU,EAAE,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,CAAC;IAER;;OAEG;IACH,KAAK,EAAE,CAAC;CACC,CAAC","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport const DCommandFlag = {\n\tNONE: 0,\n\n\t/**\n\t * Commands with a `UNSTORABLE` flag will not be queued to the `done` queue.\n\t */\n\tUNSTORABLE: 1,\n\n\t/**\n\t * Commands with a `CLEAR` flag clear the command queue.\n\t */\n\tCLEAR: 2,\n\n\t/**\n\t * Commands with a `CLEAN` flag are not considered as modifications to documents\n\t */\n\tCLEAN: 4\n} as const;\n\nexport type DCommandFlag = number;\n"]}
@@ -14,6 +14,9 @@ var isCommandStorable = function (command) {
14
14
  var isCommandClear = function (command) {
15
15
  return !!(command.getFlag() & DCommandFlag.CLEAR);
16
16
  };
17
+ var isCommandClean = function (command) {
18
+ return !!(command.getFlag() & DCommandFlag.CLEAN);
19
+ };
17
20
  var DControllerDefaultCommand = /** @class */ (function (_super) {
18
21
  __extends(DControllerDefaultCommand, _super);
19
22
  function DControllerDefaultCommand() {
@@ -40,90 +43,109 @@ var DControllerDefaultCommand = /** @class */ (function (_super) {
40
43
  }
41
44
  };
42
45
  DControllerDefaultCommand.prototype.push = function (command) {
43
- var waiting = this._waiting;
44
- waiting.push(command);
46
+ this._waiting.push(command);
45
47
  this.next();
46
48
  };
47
49
  DControllerDefaultCommand.prototype.next = function () {
50
+ if (this._executing != null) {
51
+ // Still executing a command.
52
+ // So do nothing.
53
+ return;
54
+ }
55
+ var waiting = this._waiting;
56
+ if (waiting.length <= 0) {
57
+ // There is no waiting commands.
58
+ // So do nothing.
59
+ return;
60
+ }
61
+ var command = waiting.shift();
62
+ if (command == null) {
63
+ // There is no waiting commands.
64
+ // So do nothing.
65
+ return;
66
+ }
67
+ if (command instanceof DCommandUndo) {
68
+ this.executeUndo(command);
69
+ }
70
+ else if (command instanceof DCommandRedo) {
71
+ this.executeRedo(command);
72
+ }
73
+ else {
74
+ this.execute(command);
75
+ }
76
+ };
77
+ DControllerDefaultCommand.prototype.executeUndo = function (command) {
48
78
  var _this = this;
49
- if (this._executing == null) {
50
- var waiting = this._waiting;
51
- if (0 < waiting.length) {
52
- var command_1 = waiting.shift();
53
- if (command_1 != null) {
54
- if (command_1 instanceof DCommandUndo) {
55
- var done = this._done;
56
- if (this._position < done.length) {
57
- var current = done[done.length - 1 - this._position];
58
- this._position += 1;
59
- this.emit("change", this);
60
- var result = current.undo();
61
- if (result === true) {
62
- this.onSuccess(command_1);
63
- }
64
- else if (result === false) {
65
- this.onFail(command_1);
66
- }
67
- else {
68
- this._executing = result.then(function () {
69
- _this.onSuccess(command_1);
70
- }, function () {
71
- _this.onFail(command_1);
72
- });
73
- }
74
- }
75
- }
76
- else if (command_1 instanceof DCommandRedo) {
77
- var done = this._done;
78
- if (0 < this._position) {
79
- var current = done[done.length - this._position];
80
- this._position -= 1;
81
- this.emit("change", this);
82
- var result = current.redo();
83
- if (result === true) {
84
- this.onSuccess(command_1);
85
- }
86
- else if (result === false) {
87
- this.onFail(command_1);
88
- }
89
- else {
90
- this._executing = result.then(function () {
91
- _this.onSuccess(command_1);
92
- }, function () {
93
- _this.onFail(command_1);
94
- });
95
- }
96
- }
97
- }
98
- else {
99
- var isClear = isCommandClear(command_1);
100
- var isStorable = isCommandStorable(command_1);
101
- if (isClear || isStorable) {
102
- var size = isClear ? this._done.length : this._position;
103
- if (0 < size) {
104
- this.remove(size);
105
- this._position = 0;
106
- this.emit("change", this);
107
- }
108
- this.cleanup();
109
- }
110
- var result = command_1.execute();
111
- if (result === true) {
112
- this.onSuccess(command_1);
113
- }
114
- else if (result === false) {
115
- this.onFail(command_1);
116
- }
117
- else {
118
- this._executing = result.then(function () {
119
- _this.onSuccess(command_1);
120
- }, function () {
121
- _this.onFail(command_1);
122
- });
123
- }
124
- }
125
- }
79
+ var done = this._done;
80
+ if (this._position < done.length) {
81
+ var current_1 = done[done.length - 1 - this._position];
82
+ this._position += 1;
83
+ this.emit("change", this);
84
+ var result = current_1.undo();
85
+ if (result === true) {
86
+ this.onSuccessUndo(current_1);
87
+ }
88
+ else if (result === false) {
89
+ this.onFail(command);
90
+ }
91
+ else {
92
+ this._executing = result.then(function () {
93
+ _this.onSuccessUndo(current_1);
94
+ }, function () {
95
+ _this.onFail(command);
96
+ });
97
+ }
98
+ }
99
+ };
100
+ DControllerDefaultCommand.prototype.executeRedo = function (command) {
101
+ var _this = this;
102
+ var done = this._done;
103
+ if (0 < this._position) {
104
+ var current_2 = done[done.length - this._position];
105
+ this._position -= 1;
106
+ this.emit("change", this);
107
+ var result = current_2.redo();
108
+ if (result === true) {
109
+ this.onSuccessRedo(current_2);
126
110
  }
111
+ else if (result === false) {
112
+ this.onFail(command);
113
+ }
114
+ else {
115
+ this._executing = result.then(function () {
116
+ _this.onSuccessRedo(current_2);
117
+ }, function () {
118
+ _this.onFail(command);
119
+ });
120
+ }
121
+ }
122
+ };
123
+ DControllerDefaultCommand.prototype.execute = function (command) {
124
+ var _this = this;
125
+ var isClear = isCommandClear(command);
126
+ var isStorable = isCommandStorable(command);
127
+ if (isClear || isStorable) {
128
+ var size = isClear ? this._done.length : this._position;
129
+ if (0 < size) {
130
+ this.remove(size);
131
+ this._position = 0;
132
+ this.emit("change", this);
133
+ }
134
+ this.cleanup();
135
+ }
136
+ var result = command.execute();
137
+ if (result === true) {
138
+ this.onSuccess(command);
139
+ }
140
+ else if (result === false) {
141
+ this.onFail(command);
142
+ }
143
+ else {
144
+ this._executing = result.then(function () {
145
+ _this.onSuccess(command);
146
+ }, function () {
147
+ _this.onFail(command);
148
+ });
127
149
  }
128
150
  };
129
151
  DControllerDefaultCommand.prototype.cleanup = function () {
@@ -155,9 +177,24 @@ var DControllerDefaultCommand = /** @class */ (function (_super) {
155
177
  this._executing = null;
156
178
  if (isCommandStorable(command)) {
157
179
  this._done.push(command);
180
+ if (!isCommandClean(command)) {
181
+ this.emit("dirty", this);
182
+ }
183
+ }
184
+ this.emit("change", this);
185
+ this.next();
186
+ };
187
+ DControllerDefaultCommand.prototype.onSuccessUndo = function (undoed) {
188
+ this._executing = null;
189
+ if (!isCommandClean(undoed)) {
158
190
  this.emit("dirty", this);
159
191
  }
160
- else if (command instanceof DCommandUndo || command instanceof DCommandRedo) {
192
+ this.emit("change", this);
193
+ this.next();
194
+ };
195
+ DControllerDefaultCommand.prototype.onSuccessRedo = function (redoed) {
196
+ this._executing = null;
197
+ if (!isCommandClean(redoed)) {
161
198
  this.emit("dirty", this);
162
199
  }
163
200
  this.emit("change", this);
@@ -1 +1 @@
1
- {"version":3,"file":"d-controller-default-command.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/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;QACD,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,wCAAI,GAAJ;QACC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED,yCAAK,GAAL;QACC,IAAI,CAAC,IAAI,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,wCAAI,GAAJ;QACC,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE;YACtB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC;YACvC,IAAI,CAAC,IAAI,EAAE,CAAC;SACZ;IACF,CAAC;IAED,wCAAI,GAAJ;QACC,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE;YACtB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC;YACvC,IAAI,CAAC,IAAI,EAAE,CAAC;SACZ;IACF,CAAC;IAED,8CAAU,GAAV;QACC,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;IACtD,CAAC;IAED,8CAAU,GAAV;QACC,OAAO,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;IACtE,CAAC;IACF,gCAAC;AAAD,CAAC,AAvMD,CAA+C,KAAK,CAAC,YAAY,GAuMhE","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { utils } from \"pixi.js\";\nimport { DCommand } from \"./d-command\";\nimport { DCommandClear } from \"./d-command-clear\";\nimport { DCommandFlag } from \"./d-command-flag\";\nimport { DCommandRedo } from \"./d-command-redo\";\nimport { DCommandUndo } from \"./d-command-undo\";\nimport { DControllerCommand } from \"./d-controller-command\";\n\nconst isCommandStorable = (command: DCommand): boolean => {\n\treturn !(command.getFlag() & DCommandFlag.UNSTORABLE);\n};\n\nconst isCommandClear = (command: DCommand): boolean => {\n\treturn !!(command.getFlag() & DCommandFlag.CLEAR);\n};\n\nexport class DControllerDefaultCommand extends utils.EventEmitter implements DControllerCommand {\n\tprotected _position: number;\n\tprotected _done: DCommand[];\n\tprotected _waiting: DCommand[];\n\tprotected _executing: Promise<void> | null;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis._position = 0;\n\t\tthis._done = [];\n\t\tthis._waiting = [];\n\t\tthis._executing = null;\n\t}\n\n\tlast(): DCommand | null {\n\t\tconst done = this._done;\n\t\tconst waiting = this._waiting;\n\n\t\tif (waiting.length <= 0) {\n\t\t\tif (0 < done.length) {\n\t\t\t\treturn done[done.length - 1];\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} else {\n\t\t\treturn waiting[waiting.length - 1];\n\t\t}\n\t}\n\n\tpush(command: DCommand): void {\n\t\tconst waiting = this._waiting;\n\t\twaiting.push(command);\n\t\tthis.next();\n\t}\n\n\tnext(): void {\n\t\tif (this._executing == null) {\n\t\t\tconst waiting = this._waiting;\n\t\t\tif (0 < waiting.length) {\n\t\t\t\tconst command = waiting.shift();\n\t\t\t\tif (command != null) {\n\t\t\t\t\tif (command instanceof DCommandUndo) {\n\t\t\t\t\t\tconst done = this._done;\n\t\t\t\t\t\tif (this._position < done.length) {\n\t\t\t\t\t\t\tconst current = done[done.length - 1 - this._position];\n\t\t\t\t\t\t\tthis._position += 1;\n\t\t\t\t\t\t\tthis.emit(\"change\", this);\n\t\t\t\t\t\t\tconst result = current.undo();\n\t\t\t\t\t\t\tif (result === true) {\n\t\t\t\t\t\t\t\tthis.onSuccess(command);\n\t\t\t\t\t\t\t} else if (result === false) {\n\t\t\t\t\t\t\t\tthis.onFail(command);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis._executing = result.then(\n\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\tthis.onSuccess(command);\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\tthis.onFail(command);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (command instanceof DCommandRedo) {\n\t\t\t\t\t\tconst done = this._done;\n\t\t\t\t\t\tif (0 < this._position) {\n\t\t\t\t\t\t\tconst current = done[done.length - this._position];\n\t\t\t\t\t\t\tthis._position -= 1;\n\t\t\t\t\t\t\tthis.emit(\"change\", this);\n\t\t\t\t\t\t\tconst result = current.redo();\n\t\t\t\t\t\t\tif (result === true) {\n\t\t\t\t\t\t\t\tthis.onSuccess(command);\n\t\t\t\t\t\t\t} else if (result === false) {\n\t\t\t\t\t\t\t\tthis.onFail(command);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthis._executing = result.then(\n\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\tthis.onSuccess(command);\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\tthis.onFail(command);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst isClear = isCommandClear(command);\n\t\t\t\t\t\tconst isStorable = isCommandStorable(command);\n\t\t\t\t\t\tif (isClear || isStorable) {\n\t\t\t\t\t\t\tconst size = isClear ? this._done.length : this._position;\n\t\t\t\t\t\t\tif (0 < size) {\n\t\t\t\t\t\t\t\tthis.remove(size);\n\t\t\t\t\t\t\t\tthis._position = 0;\n\t\t\t\t\t\t\t\tthis.emit(\"change\", this);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.cleanup();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst result = command.execute();\n\t\t\t\t\t\tif (result === true) {\n\t\t\t\t\t\t\tthis.onSuccess(command);\n\t\t\t\t\t\t} else if (result === false) {\n\t\t\t\t\t\t\tthis.onFail(command);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis._executing = result.then(\n\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\tthis.onSuccess(command);\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\tthis.onFail(command);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected cleanup(): void {\n\t\tconst done = this._done;\n\t\tconst size = done.length - 100;\n\t\tif (0 < size) {\n\t\t\tfor (let i = 0; i < size; ++i) {\n\t\t\t\tdone[i].destroy();\n\t\t\t\tdone.shift();\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected remove(size: number): boolean {\n\t\tconst done = this._done;\n\t\tif (0 < size) {\n\t\t\tconst ifrom = Math.max(0, done.length - size);\n\t\t\tsize = done.length - ifrom;\n\t\t\tif (0 < size) {\n\t\t\t\tfor (let i = ifrom, imax = done.length; i < imax; ++i) {\n\t\t\t\t\tdone[i].destroy();\n\t\t\t\t}\n\n\t\t\t\tdone.splice(ifrom, done.length - ifrom);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected onSuccess(command: DCommand): void {\n\t\tthis._executing = null;\n\t\tif (isCommandStorable(command)) {\n\t\t\tthis._done.push(command);\n\t\t\tthis.emit(\"dirty\", this);\n\t\t} else if (command instanceof DCommandUndo || command instanceof DCommandRedo) {\n\t\t\tthis.emit(\"dirty\", this);\n\t\t}\n\t\tthis.emit(\"change\", this);\n\t\tthis.next();\n\t}\n\n\tprotected onFail(command: DCommand): void {\n\t\tthis._executing = null;\n\t\tconst waiting = this._waiting;\n\t\tcommand.destroy();\n\t\tfor (let i = 0, imax = waiting.length; i < imax; ++i) {\n\t\t\twaiting[i].destroy();\n\t\t}\n\t\twaiting.length = 0;\n\t\tthis.emit(\"change\", this);\n\t}\n\n\tsize(): number {\n\t\treturn this._done.length;\n\t}\n\n\tclear(): void {\n\t\tthis.push(new DCommandClear());\n\t}\n\n\tredo(): void {\n\t\tif (this.isRedoable()) {\n\t\t\tthis._waiting.push(new DCommandRedo());\n\t\t\tthis.next();\n\t\t}\n\t}\n\n\tundo(): void {\n\t\tif (this.isUndoable()) {\n\t\t\tthis._waiting.push(new DCommandUndo());\n\t\t\tthis.next();\n\t\t}\n\t}\n\n\tisRedoable(): boolean {\n\t\treturn 0 < this._position && this._executing == null;\n\t}\n\n\tisUndoable(): boolean {\n\t\treturn this._position < this._done.length && this._executing == null;\n\t}\n}\n"]}
1
+ {"version":3,"file":"d-controller-default-command.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-controller-default-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,IAAM,iBAAiB,GAAG,UAAC,OAAiB;IAC3C,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,IAAM,cAAc,GAAG,UAAC,OAAiB;IACxC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,IAAM,cAAc,G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I,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;IACtE,CAAC;IACF,gCAAC;AAAD,CAAC,AAhPD,CAA+C,KAAK,CAAC,YAAY,GAgPhE","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { utils } from \"pixi.js\";\nimport { DCommand } from \"./d-command\";\nimport { DCommandClear } from \"./d-command-clear\";\nimport { DCommandFlag } from \"./d-command-flag\";\nimport { DCommandRedo } from \"./d-command-redo\";\nimport { DCommandUndo } from \"./d-command-undo\";\nimport { DControllerCommand } from \"./d-controller-command\";\n\nconst isCommandStorable = (command: DCommand): boolean => {\n\treturn !(command.getFlag() & DCommandFlag.UNSTORABLE);\n};\n\nconst isCommandClear = (command: DCommand): boolean => {\n\treturn !!(command.getFlag() & DCommandFlag.CLEAR);\n};\n\nconst isCommandClean = (command: DCommand): boolean => {\n\treturn !!(command.getFlag() & DCommandFlag.CLEAN);\n};\n\nexport class DControllerDefaultCommand extends utils.EventEmitter implements DControllerCommand {\n\tprotected _position: number;\n\tprotected _done: DCommand[];\n\tprotected _waiting: DCommand[];\n\tprotected _executing: Promise<void> | null;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis._position = 0;\n\t\tthis._done = [];\n\t\tthis._waiting = [];\n\t\tthis._executing = null;\n\t}\n\n\tlast(): DCommand | null {\n\t\tconst done = this._done;\n\t\tconst waiting = this._waiting;\n\n\t\tif (waiting.length <= 0) {\n\t\t\tif (0 < done.length) {\n\t\t\t\treturn done[done.length - 1];\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} else {\n\t\t\treturn waiting[waiting.length - 1];\n\t\t}\n\t}\n\n\tpush(command: DCommand): void {\n\t\tthis._waiting.push(command);\n\t\tthis.next();\n\t}\n\n\tnext(): void {\n\t\tif (this._executing != null) {\n\t\t\t// Still executing a command.\n\t\t\t// So do nothing.\n\t\t\treturn;\n\t\t}\n\n\t\tconst waiting = this._waiting;\n\t\tif (waiting.length <= 0) {\n\t\t\t// There is no waiting commands.\n\t\t\t// So do nothing.\n\t\t\treturn;\n\t\t}\n\n\t\tconst command = waiting.shift();\n\t\tif (command == null) {\n\t\t\t// There is no waiting commands.\n\t\t\t// So do nothing.\n\t\t\treturn;\n\t\t}\n\n\t\tif (command instanceof DCommandUndo) {\n\t\t\tthis.executeUndo(command);\n\t\t} else if (command instanceof DCommandRedo) {\n\t\t\tthis.executeRedo(command);\n\t\t} else {\n\t\t\tthis.execute(command);\n\t\t}\n\t}\n\n\tprotected executeUndo(command: DCommandUndo): void {\n\t\tconst done = this._done;\n\t\tif (this._position < done.length) {\n\t\t\tconst current = done[done.length - 1 - this._position];\n\t\t\tthis._position += 1;\n\t\t\tthis.emit(\"change\", this);\n\t\t\tconst result = current.undo();\n\t\t\tif (result === true) {\n\t\t\t\tthis.onSuccessUndo(current);\n\t\t\t} else if (result === false) {\n\t\t\t\tthis.onFail(command);\n\t\t\t} else {\n\t\t\t\tthis._executing = result.then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.onSuccessUndo(current);\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.onFail(command);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected executeRedo(command: DCommandRedo): void {\n\t\tconst done = this._done;\n\t\tif (0 < this._position) {\n\t\t\tconst current = done[done.length - this._position];\n\t\t\tthis._position -= 1;\n\t\t\tthis.emit(\"change\", this);\n\t\t\tconst result = current.redo();\n\t\t\tif (result === true) {\n\t\t\t\tthis.onSuccessRedo(current);\n\t\t\t} else if (result === false) {\n\t\t\t\tthis.onFail(command);\n\t\t\t} else {\n\t\t\t\tthis._executing = result.then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.onSuccessRedo(current);\n\t\t\t\t\t},\n\t\t\t\t\t() => {\n\t\t\t\t\t\tthis.onFail(command);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected execute(command: DCommand): void {\n\t\tconst isClear = isCommandClear(command);\n\t\tconst isStorable = isCommandStorable(command);\n\t\tif (isClear || isStorable) {\n\t\t\tconst size = isClear ? this._done.length : this._position;\n\t\t\tif (0 < size) {\n\t\t\t\tthis.remove(size);\n\t\t\t\tthis._position = 0;\n\t\t\t\tthis.emit(\"change\", this);\n\t\t\t}\n\t\t\tthis.cleanup();\n\t\t}\n\t\tconst result = command.execute();\n\t\tif (result === true) {\n\t\t\tthis.onSuccess(command);\n\t\t} else if (result === false) {\n\t\t\tthis.onFail(command);\n\t\t} else {\n\t\t\tthis._executing = result.then(\n\t\t\t\t() => {\n\t\t\t\t\tthis.onSuccess(command);\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tthis.onFail(command);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\tprotected cleanup(): void {\n\t\tconst done = this._done;\n\t\tconst size = done.length - 100;\n\t\tif (0 < size) {\n\t\t\tfor (let i = 0; i < size; ++i) {\n\t\t\t\tdone[i].destroy();\n\t\t\t\tdone.shift();\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected remove(size: number): boolean {\n\t\tconst done = this._done;\n\t\tif (0 < size) {\n\t\t\tconst ifrom = Math.max(0, done.length - size);\n\t\t\tsize = done.length - ifrom;\n\t\t\tif (0 < size) {\n\t\t\t\tfor (let i = ifrom, imax = done.length; i < imax; ++i) {\n\t\t\t\t\tdone[i].destroy();\n\t\t\t\t}\n\n\t\t\t\tdone.splice(ifrom, done.length - ifrom);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected onSuccess(command: DCommand): void {\n\t\tthis._executing = null;\n\t\tif (isCommandStorable(command)) {\n\t\t\tthis._done.push(command);\n\t\t\tif (!isCommandClean(command)) {\n\t\t\t\tthis.emit(\"dirty\", this);\n\t\t\t}\n\t\t}\n\t\tthis.emit(\"change\", this);\n\t\tthis.next();\n\t}\n\n\tprotected onSuccessUndo(undoed: DCommand): void {\n\t\tthis._executing = null;\n\t\tif (!isCommandClean(undoed)) {\n\t\t\tthis.emit(\"dirty\", this);\n\t\t}\n\t\tthis.emit(\"change\", this);\n\t\tthis.next();\n\t}\n\n\tprotected onSuccessRedo(redoed: DCommand): void {\n\t\tthis._executing = null;\n\t\tif (!isCommandClean(redoed)) {\n\t\t\tthis.emit(\"dirty\", this);\n\t\t}\n\t\tthis.emit(\"change\", this);\n\t\tthis.next();\n\t}\n\n\tprotected onFail(command: DCommand): void {\n\t\tthis._executing = null;\n\t\tconst waiting = this._waiting;\n\t\tcommand.destroy();\n\t\tfor (let i = 0, imax = waiting.length; i < imax; ++i) {\n\t\t\twaiting[i].destroy();\n\t\t}\n\t\twaiting.length = 0;\n\t\tthis.emit(\"change\", this);\n\t}\n\n\tsize(): number {\n\t\treturn this._done.length;\n\t}\n\n\tclear(): void {\n\t\tthis.push(new DCommandClear());\n\t}\n\n\tredo(): void {\n\t\tif (this.isRedoable()) {\n\t\t\tthis._waiting.push(new DCommandRedo());\n\t\t\tthis.next();\n\t\t}\n\t}\n\n\tundo(): void {\n\t\tif (this.isUndoable()) {\n\t\t\tthis._waiting.push(new DCommandUndo());\n\t\t\tthis.next();\n\t\t}\n\t}\n\n\tisRedoable(): boolean {\n\t\treturn 0 < this._position && this._executing == null;\n\t}\n\n\tisUndoable(): boolean {\n\t\treturn this._position < this._done.length && this._executing == null;\n\t}\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.168.0
2
+ Winter Cardinal UI v0.169.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.168.0
2
+ Winter Cardinal UI v0.169.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.168.0
2
+ Winter Cardinal UI v0.169.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.168.0
2
+ Winter Cardinal UI v0.169.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Winter Cardinal UI v0.168.0
2
+ Winter Cardinal UI v0.169.0
3
3
  Copyright (C) 2019 Toshiba Corporation
4
4
  SPDX-License-Identifier: Apache-2.0
5
5
 
@@ -61602,9 +61602,13 @@ var DCommandFlag = {
61602
61602
  */
61603
61603
  UNSTORABLE: 1,
61604
61604
  /**
61605
- * Commands with a `CLEAR` flag clears the command queue.
61605
+ * Commands with a `CLEAR` flag clear the command queue.
61606
61606
  */
61607
- CLEAR: 2
61607
+ CLEAR: 2,
61608
+ /**
61609
+ * Commands with a `CLEAN` flag are not considered as modifications to documents
61610
+ */
61611
+ CLEAN: 4
61608
61612
  };
61609
61613
 
61610
61614
  /*
@@ -61692,6 +61696,9 @@ var isCommandStorable = function (command) {
61692
61696
  var isCommandClear = function (command) {
61693
61697
  return !!(command.getFlag() & DCommandFlag.CLEAR);
61694
61698
  };
61699
+ var isCommandClean = function (command) {
61700
+ return !!(command.getFlag() & DCommandFlag.CLEAN);
61701
+ };
61695
61702
  var DControllerDefaultCommand = /** @class */ (function (_super) {
61696
61703
  __extends(DControllerDefaultCommand, _super);
61697
61704
  function DControllerDefaultCommand() {
@@ -61718,92 +61725,111 @@ var DControllerDefaultCommand = /** @class */ (function (_super) {
61718
61725
  }
61719
61726
  };
61720
61727
  DControllerDefaultCommand.prototype.push = function (command) {
61721
- var waiting = this._waiting;
61722
- waiting.push(command);
61728
+ this._waiting.push(command);
61723
61729
  this.next();
61724
61730
  };
61725
61731
  DControllerDefaultCommand.prototype.next = function () {
61732
+ if (this._executing != null) {
61733
+ // Still executing a command.
61734
+ // So do nothing.
61735
+ return;
61736
+ }
61737
+ var waiting = this._waiting;
61738
+ if (waiting.length <= 0) {
61739
+ // There is no waiting commands.
61740
+ // So do nothing.
61741
+ return;
61742
+ }
61743
+ var command = waiting.shift();
61744
+ if (command == null) {
61745
+ // There is no waiting commands.
61746
+ // So do nothing.
61747
+ return;
61748
+ }
61749
+ if (command instanceof DCommandUndo) {
61750
+ this.executeUndo(command);
61751
+ }
61752
+ else if (command instanceof DCommandRedo) {
61753
+ this.executeRedo(command);
61754
+ }
61755
+ else {
61756
+ this.execute(command);
61757
+ }
61758
+ };
61759
+ DControllerDefaultCommand.prototype.executeUndo = function (command) {
61726
61760
  var _this = this;
61727
- if (this._executing == null) {
61728
- var waiting = this._waiting;
61729
- if (0 < waiting.length) {
61730
- var command_1 = waiting.shift();
61731
- if (command_1 != null) {
61732
- if (command_1 instanceof DCommandUndo) {
61733
- var done = this._done;
61734
- if (this._position < done.length) {
61735
- var current = done[done.length - 1 - this._position];
61736
- this._position += 1;
61737
- this.emit("change", this);
61738
- var result = current.undo();
61739
- if (result === true) {
61740
- this.onSuccess(command_1);
61741
- }
61742
- else if (result === false) {
61743
- this.onFail(command_1);
61744
- }
61745
- else {
61746
- this._executing = result.then(function () {
61747
- _this.onSuccess(command_1);
61748
- }, function () {
61749
- _this.onFail(command_1);
61750
- });
61751
- }
61752
- }
61753
- }
61754
- else if (command_1 instanceof DCommandRedo) {
61755
- var done = this._done;
61756
- if (0 < this._position) {
61757
- var current = done[done.length - this._position];
61758
- this._position -= 1;
61759
- this.emit("change", this);
61760
- var result = current.redo();
61761
- if (result === true) {
61762
- this.onSuccess(command_1);
61763
- }
61764
- else if (result === false) {
61765
- this.onFail(command_1);
61766
- }
61767
- else {
61768
- this._executing = result.then(function () {
61769
- _this.onSuccess(command_1);
61770
- }, function () {
61771
- _this.onFail(command_1);
61772
- });
61773
- }
61774
- }
61775
- }
61776
- else {
61777
- var isClear = isCommandClear(command_1);
61778
- var isStorable = isCommandStorable(command_1);
61779
- if (isClear || isStorable) {
61780
- var size = isClear ? this._done.length : this._position;
61781
- if (0 < size) {
61782
- this.remove(size);
61783
- this._position = 0;
61784
- this.emit("change", this);
61785
- }
61786
- this.cleanup();
61787
- }
61788
- var result = command_1.execute();
61789
- if (result === true) {
61790
- this.onSuccess(command_1);
61791
- }
61792
- else if (result === false) {
61793
- this.onFail(command_1);
61794
- }
61795
- else {
61796
- this._executing = result.then(function () {
61797
- _this.onSuccess(command_1);
61798
- }, function () {
61799
- _this.onFail(command_1);
61800
- });
61801
- }
61802
- }
61803
- }
61761
+ var done = this._done;
61762
+ if (this._position < done.length) {
61763
+ var current_1 = done[done.length - 1 - this._position];
61764
+ this._position += 1;
61765
+ this.emit("change", this);
61766
+ var result = current_1.undo();
61767
+ if (result === true) {
61768
+ this.onSuccessUndo(current_1);
61769
+ }
61770
+ else if (result === false) {
61771
+ this.onFail(command);
61772
+ }
61773
+ else {
61774
+ this._executing = result.then(function () {
61775
+ _this.onSuccessUndo(current_1);
61776
+ }, function () {
61777
+ _this.onFail(command);
61778
+ });
61779
+ }
61780
+ }
61781
+ };
61782
+ DControllerDefaultCommand.prototype.executeRedo = function (command) {
61783
+ var _this = this;
61784
+ var done = this._done;
61785
+ if (0 < this._position) {
61786
+ var current_2 = done[done.length - this._position];
61787
+ this._position -= 1;
61788
+ this.emit("change", this);
61789
+ var result = current_2.redo();
61790
+ if (result === true) {
61791
+ this.onSuccessRedo(current_2);
61792
+ }
61793
+ else if (result === false) {
61794
+ this.onFail(command);
61795
+ }
61796
+ else {
61797
+ this._executing = result.then(function () {
61798
+ _this.onSuccessRedo(current_2);
61799
+ }, function () {
61800
+ _this.onFail(command);
61801
+ });
61804
61802
  }
61805
61803
  }
61806
61804
  };
61805
+ DControllerDefaultCommand.prototype.execute = function (command) {
61806
+ var _this = this;
61807
+ var isClear = isCommandClear(command);
61808
+ var isStorable = isCommandStorable(command);
61809
+ if (isClear || isStorable) {
61810
+ var size = isClear ? this._done.length : this._position;
61811
+ if (0 < size) {
61812
+ this.remove(size);
61813
+ this._position = 0;
61814
+ this.emit("change", this);
61815
+ }
61816
+ this.cleanup();
61817
+ }
61818
+ var result = command.execute();
61819
+ if (result === true) {
61820
+ this.onSuccess(command);
61821
+ }
61822
+ else if (result === false) {
61823
+ this.onFail(command);
61824
+ }
61825
+ else {
61826
+ this._executing = result.then(function () {
61827
+ _this.onSuccess(command);
61828
+ }, function () {
61829
+ _this.onFail(command);
61830
+ });
61831
+ }
61832
+ };
61807
61833
  DControllerDefaultCommand.prototype.cleanup = function () {
61808
61834
  var done = this._done;
61809
61835
  var size = done.length - 100;
@@ -61833,9 +61859,24 @@ var DControllerDefaultCommand = /** @class */ (function (_super) {
61833
61859
  this._executing = null;
61834
61860
  if (isCommandStorable(command)) {
61835
61861
  this._done.push(command);
61862
+ if (!isCommandClean(command)) {
61863
+ this.emit("dirty", this);
61864
+ }
61865
+ }
61866
+ this.emit("change", this);
61867
+ this.next();
61868
+ };
61869
+ DControllerDefaultCommand.prototype.onSuccessUndo = function (undoed) {
61870
+ this._executing = null;
61871
+ if (!isCommandClean(undoed)) {
61836
61872
  this.emit("dirty", this);
61837
61873
  }
61838
- else if (command instanceof DCommandUndo || command instanceof DCommandRedo) {
61874
+ this.emit("change", this);
61875
+ this.next();
61876
+ };
61877
+ DControllerDefaultCommand.prototype.onSuccessRedo = function (redoed) {
61878
+ this._executing = null;
61879
+ if (!isCommandClean(redoed)) {
61839
61880
  this.emit("dirty", this);
61840
61881
  }
61841
61882
  this.emit("change", this);