@wcardinal/wcardinal-ui 0.166.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.
- package/dist/types/wcardinal/ui/d-button-select.d.ts +4 -3
- package/dist/types/wcardinal/ui/d-command-flag.d.ts +5 -1
- package/dist/types/wcardinal/ui/d-controller-default-command.d.ts +7 -0
- package/dist/types/wcardinal/ui/d-dialog.d.ts +18 -5
- package/dist/types/wcardinal/ui/d-table-column.d.ts +2 -2
- package/dist/wcardinal/ui/d-button-select.js +1 -1
- package/dist/wcardinal/ui/d-button-select.js.map +1 -1
- package/dist/wcardinal/ui/d-command-flag.js +6 -2
- package/dist/wcardinal/ui/d-command-flag.js.map +1 -1
- package/dist/wcardinal/ui/d-controller-default-command.js +117 -80
- package/dist/wcardinal/ui/d-controller-default-command.js.map +1 -1
- package/dist/wcardinal/ui/d-dialog.js +71 -23
- package/dist/wcardinal/ui/d-dialog.js.map +1 -1
- package/dist/wcardinal/ui/d-table-column.js.map +1 -1
- package/dist/wcardinal/ui/theme/dark/d-theme-dark-dialog.js +1 -7
- package/dist/wcardinal/ui/theme/dark/d-theme-dark-dialog.js.map +1 -1
- package/dist/wcardinal/ui/theme/white/d-theme-white-dialog.js +1 -7
- package/dist/wcardinal/ui/theme/white/d-theme-white-dialog.js.map +1 -1
- package/dist/wcardinal-ui-theme-dark.js +2 -8
- package/dist/wcardinal-ui-theme-dark.min.js +2 -2
- package/dist/wcardinal-ui-theme-dark.min.js.map +1 -1
- package/dist/wcardinal-ui-theme-white.js +2 -8
- package/dist/wcardinal-ui-theme-white.min.js +2 -2
- package/dist/wcardinal-ui-theme-white.min.js.map +1 -1
- package/dist/wcardinal-ui.cjs.js +3074 -2998
- package/dist/wcardinal-ui.js +19102 -19014
- package/dist/wcardinal-ui.min.js +2 -2
- package/dist/wcardinal-ui.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { interaction } from "pixi.js";
|
|
2
2
|
import { DButton, DButtonEvents, DButtonOptions, DThemeButton } from "./d-button";
|
|
3
|
+
import { DDialogOpener } from "./d-dialog";
|
|
3
4
|
import { DDialogSelectOptions } from "./d-dialog-select";
|
|
4
5
|
import { DOnOptions } from "./d-on-options";
|
|
5
6
|
/**
|
|
@@ -7,7 +8,7 @@ import { DOnOptions } from "./d-on-options";
|
|
|
7
8
|
*/
|
|
8
9
|
export interface DButtonSelectDialog<VALUE> {
|
|
9
10
|
readonly value: VALUE | null;
|
|
10
|
-
open(): Promise<unknown>;
|
|
11
|
+
open(opener?: DDialogOpener): Promise<unknown>;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* A function to retrieve a selected value from a dialog.
|
|
@@ -39,7 +40,7 @@ export interface DButtonSelectOnOptions<VALUE, EMITTER> extends Partial<DButtonS
|
|
|
39
40
|
/**
|
|
40
41
|
* {@link DButtonSelect} options.
|
|
41
42
|
*/
|
|
42
|
-
export interface DButtonSelectOptions<VALUE
|
|
43
|
+
export interface DButtonSelectOptions<VALUE = unknown, DIALOG_VALUE = unknown, DIALOG extends DButtonSelectDialog<DIALOG_VALUE> = DButtonSelectDialog<DIALOG_VALUE>, THEME extends DThemeButtonSelect<VALUE> = DThemeButtonSelect<VALUE>, EMITTER = any> extends DButtonOptions<VALUE | null, THEME, EMITTER> {
|
|
43
44
|
/**
|
|
44
45
|
* A function to retrieve a selected value from a dialog.
|
|
45
46
|
*/
|
|
@@ -60,7 +61,7 @@ export interface DButtonSelectOptions<VALUE extends unknown = unknown, DIALOG_VA
|
|
|
60
61
|
*/
|
|
61
62
|
export interface DThemeButtonSelect<VALUE = unknown> extends DThemeButton<VALUE | null> {
|
|
62
63
|
}
|
|
63
|
-
export declare class DButtonSelect<VALUE
|
|
64
|
+
export declare class DButtonSelect<VALUE = unknown, DIALOG_VALUE = unknown, DIALOG extends DButtonSelectDialog<DIALOG_VALUE> = DButtonSelectDialog<DIALOG_VALUE>, THEME extends DThemeButtonSelect<VALUE> = DThemeButtonSelect<VALUE>, OPTIONS extends DButtonSelectOptions<VALUE, DIALOG_VALUE, DIALOG, THEME> = DButtonSelectOptions<VALUE, DIALOG_VALUE, DIALOG, THEME>> extends DButton<VALUE | null, THEME, OPTIONS> {
|
|
64
65
|
protected _dialog?: DIALOG;
|
|
65
66
|
protected _dialogGetter: DButtonSelectGetter<VALUE, DIALOG>;
|
|
66
67
|
protected _dialogSetter: DButtonSelectSetter<VALUE, DIALOG>;
|
|
@@ -5,8 +5,12 @@ export declare const DCommandFlag: {
|
|
|
5
5
|
*/
|
|
6
6
|
readonly UNSTORABLE: 1;
|
|
7
7
|
/**
|
|
8
|
-
* Commands with a `CLEAR` flag
|
|
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;
|
|
@@ -37,7 +37,7 @@ export interface DDialogOnOptions<EMITTER> extends Partial<DDialogEvents<EMITTER
|
|
|
37
37
|
* {@link DDialog} options.
|
|
38
38
|
*/
|
|
39
39
|
export interface DDialogOptions<THEME extends DThemeDialog = DThemeDialog, EMITTER = any> extends DBaseOptions<THEME> {
|
|
40
|
-
closeOn?: DDialogCloseOn;
|
|
40
|
+
closeOn?: DDialogCloseOn | Array<keyof typeof DDialogCloseOn> | keyof typeof DDialogCloseOn;
|
|
41
41
|
animation?: DAnimation<DBase>;
|
|
42
42
|
/**
|
|
43
43
|
* A dialog mode.
|
|
@@ -45,7 +45,7 @@ export interface DDialogOptions<THEME extends DThemeDialog = DThemeDialog, EMITT
|
|
|
45
45
|
mode?: DDialogMode | keyof typeof DDialogMode;
|
|
46
46
|
sticky?: boolean;
|
|
47
47
|
gesture?: boolean | DDialogGestureOptions;
|
|
48
|
-
align?: DDialogAlign | null;
|
|
48
|
+
align?: DDialogAlign | null | keyof typeof DDialogAlign;
|
|
49
49
|
/**
|
|
50
50
|
* Mappings of event names and handlers.
|
|
51
51
|
*/
|
|
@@ -65,7 +65,7 @@ export interface DThemeDialog extends DThemeBase {
|
|
|
65
65
|
getAlign(mode: DDialogMode): DDialogAlign | null;
|
|
66
66
|
newAnimation(mode: DDialogMode): DAnimation<DBase> | null;
|
|
67
67
|
}
|
|
68
|
-
export interface
|
|
68
|
+
export interface DDialogOpener {
|
|
69
69
|
getBounds(skipUpdate: boolean, result: Rectangle): Rectangle;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
@@ -89,18 +89,31 @@ export declare class DDialog<VALUE = void, THEME extends DThemeDialog = DThemeDi
|
|
|
89
89
|
protected _sticky: boolean;
|
|
90
90
|
protected _onPrerenderBound: () => void;
|
|
91
91
|
protected _align: DDialogAlign | null;
|
|
92
|
-
protected
|
|
92
|
+
protected _opener?: DDialogOpener | null;
|
|
93
93
|
protected _gesture: DDialogGesture<this>;
|
|
94
94
|
protected _layer: DApplicationLayerLike | null;
|
|
95
95
|
protected init(options?: OPTIONS): void;
|
|
96
|
+
protected toCloseOn(mode: DDialogMode, theme: THEME, options?: OPTIONS): DDialogCloseOn;
|
|
97
|
+
protected toAlign(mode: DDialogMode, theme: THEME, options?: OPTIONS): DDialogAlign | null;
|
|
96
98
|
get mode(): DDialogMode;
|
|
99
|
+
get align(): DDialogAlign | null;
|
|
100
|
+
set algin(align: DDialogAlign | null);
|
|
97
101
|
get gesture(): DDialogGesture<this>;
|
|
98
102
|
get layer(): DApplicationLayerLike | null;
|
|
99
103
|
protected toGestureOptions(mode: DDialogMode, theme: THEME, options?: OPTIONS): DDialogGestureOptions;
|
|
100
104
|
onParentResize(parentWidth: number, parentHeight: number, parentPadding: DPadding): void;
|
|
101
105
|
protected getAnimation(): DAnimation | null;
|
|
102
106
|
protected onAnimationEnd(isReverse: boolean): void;
|
|
103
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Opens a dialog.
|
|
109
|
+
*
|
|
110
|
+
* @param opener An opener of a dialog.
|
|
111
|
+
* The dialog position is determined based on a position and a size of the opener.
|
|
112
|
+
* If the opener is undefined, the dialog is placed at the center of the screen.
|
|
113
|
+
*
|
|
114
|
+
* @returns a value of this dialog
|
|
115
|
+
*/
|
|
116
|
+
open(opener?: DDialogOpener): Promise<VALUE>;
|
|
104
117
|
protected onPrerender(): void;
|
|
105
118
|
protected onOpen(): void;
|
|
106
119
|
isOpened(): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DAlignHorizontal } from "./d-align-horizontal";
|
|
2
|
-
import {
|
|
2
|
+
import { DDialogOpener } from "./d-dialog";
|
|
3
3
|
import { DDialogSelectOptions } from "./d-dialog-select";
|
|
4
4
|
import { DMenu, DMenuOptions } from "./d-menu";
|
|
5
5
|
import { DTableBodyCellButtonOptions } from "./d-table-body-cell-button";
|
|
@@ -72,7 +72,7 @@ export interface DTableColumnSorting<ROW_VALUE> {
|
|
|
72
72
|
}
|
|
73
73
|
export interface DTableColumnSelectingDialog<DIALOG_VALUE> {
|
|
74
74
|
readonly value: DIALOG_VALUE;
|
|
75
|
-
open(owner?:
|
|
75
|
+
open(owner?: DDialogOpener): Promise<DIALOG_VALUE>;
|
|
76
76
|
}
|
|
77
77
|
export interface DTableColumnSelectingOptions<CELL_VALUE, DIALOG_VALUE, DIALOG extends DTableColumnSelectingDialog<DIALOG_VALUE>> {
|
|
78
78
|
getter?: DTableSelectingGetter<CELL_VALUE, DIALOG>;
|
|
@@ -64,7 +64,7 @@ var DButtonSelect = /** @class */ (function (_super) {
|
|
|
64
64
|
var dialog = this.dialog;
|
|
65
65
|
var oldValue = (_a = this._textValueComputed) !== null && _a !== void 0 ? _a : null;
|
|
66
66
|
this._dialogSetter(dialog, oldValue);
|
|
67
|
-
dialog.open().then(function () {
|
|
67
|
+
dialog.open(this).then(function () {
|
|
68
68
|
var newValue = _this._dialogGetter(dialog);
|
|
69
69
|
if (newValue !== oldValue) {
|
|
70
70
|
_this.text = newValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d-button-select.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-button-select.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAGH,OAAO,EAAE,OAAO,EAA+C,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"d-button-select.js","sourceRoot":"","sources":["../../../src/main/typescript/wcardinal/ui/d-button-select.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAGH,OAAO,EAAE,OAAO,EAA+C,MAAM,YAAY,CAAC;AAElF,OAAO,EAAE,aAAa,EAAwB,MAAM,mBAAmB,CAAC;AA6ExE,IAAM,aAAa,GA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,0CAAE,MAAM,CAAC;gBACtC,IAAI,OAAO,IAAI,MAAM,IAAI,OAAO,EAAE;oBACjC,MAAM,GAAG,OAAO,CAAC;iBACjB;qBAAM;oBACN,kDAAkD;oBAClD,MAAM,GAAG,IAAI,aAAa,CAAe,OAAO,CAAkB,CAAC;iBACnE;gBACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;aACtB;YACD,OAAO,MAAM,CAAC;QACf,CAAC;;;OAAA;IAED,sBAAI,gCAAK;aAAT;;YACC,OAAO,MAAA,IAAI,CAAC,kBAAkB,mCAAI,IAAI,CAAC;QACxC,CAAC;aAED,UAAU,KAAmB;YAC5B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QACnB,CAAC;;;OAJA;IAMS,+BAAO,GAAjB;QACC,OAAO,eAAe,CAAC;IACxB,CAAC;IACF,oBAAC;AAAD,CAAC,AAhED,CAWU,OAAO,GAqDhB","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { interaction } from \"pixi.js\";\nimport { DButton, DButtonEvents, DButtonOptions, DThemeButton } from \"./d-button\";\nimport { DDialogOpener } from \"./d-dialog\";\nimport { DDialogSelect, DDialogSelectOptions } from \"./d-dialog-select\";\nimport { DOnOptions } from \"./d-on-options\";\n\n/**\n * A dialog to select values.\n */\nexport interface DButtonSelectDialog<VALUE> {\n\treadonly value: VALUE | null;\n\topen(opener?: DDialogOpener): Promise<unknown>;\n}\n\n/**\n * A function to retrieve a selected value from a dialog.\n */\nexport type DButtonSelectGetter<VALUE, DIALOG> = (dialog: DIALOG) => VALUE | null;\n\n/**\n * A function to set a selecte value to a dialog.\n * Called before opening a dialog.\n */\nexport type DButtonSelectSetter<VALUE, DIALOG> = (dialog: DIALOG, value: VALUE | null) => void;\n\n/**\n * {@link DButtonSelect} events.\n */\nexport interface DButtonSelectEvents<VALUE, EMITTER> extends DButtonEvents<VALUE, EMITTER> {\n\t/**\n\t * Triggered when a selection is changed.\n\t *\n\t * @param newValue a newly selected value\n\t * @param oldValue a previously selected value\n\t * @param emitter an emitter\n\t */\n\tchange(newValue: VALUE | null, oldValue: VALUE | null, emitter: EMITTER): void;\n}\n\n/**\n * {@link DButtonSelect} \"on\" options.\n */\nexport interface DButtonSelectOnOptions<VALUE, EMITTER>\n\textends Partial<DButtonSelectEvents<VALUE, EMITTER>>,\n\t\tDOnOptions {}\n\n/**\n * {@link DButtonSelect} options.\n */\nexport interface DButtonSelectOptions<\n\tVALUE = unknown,\n\tDIALOG_VALUE = unknown,\n\tDIALOG extends DButtonSelectDialog<DIALOG_VALUE> = DButtonSelectDialog<DIALOG_VALUE>,\n\tTHEME extends DThemeButtonSelect<VALUE> = DThemeButtonSelect<VALUE>,\n\tEMITTER = any\n> extends DButtonOptions<VALUE | null, THEME, EMITTER> {\n\t/**\n\t * A function to retrieve a selected value from a dialog.\n\t */\n\tgetter?: DButtonSelectGetter<VALUE, DIALOG>;\n\n\t/**\n\t * A function to set a selected value to a dialog.\n\t * Called before opening a dialog.\n\t */\n\tsetter?: DButtonSelectSetter<VALUE, DIALOG>;\n\n\t/**\n\t * A dialog to select values.\n\t */\n\tdialog?: DDialogSelectOptions<DIALOG_VALUE> | DIALOG;\n\n\ton?: DButtonSelectOnOptions<VALUE, EMITTER>;\n}\n\n/**\n * {@link DButtonSelect} theme.\n */\nexport interface DThemeButtonSelect<VALUE = unknown> extends DThemeButton<VALUE | null> {}\n\nconst defaultGetter = (dialog: DButtonSelectDialog<any>): any => {\n\t// Assumes the dialog.value is VALUE.\n\treturn dialog.value;\n};\n\nconst defaultSetter = (): void => {\n\t// DO NOTHING\n};\n\nconst toOptions = <OPTIONS extends DButtonSelectOptions<any, any, any, any>>(\n\toptions?: OPTIONS\n): OPTIONS | undefined => {\n\tif (options) {\n\t\t// Try to copy text.formatter to dialog.item.text.formatter at first\n\t\tconst formatter = options.text?.formatter;\n\t\tif (formatter !== undefined) {\n\t\t\tlet dialog = options.dialog;\n\t\t\tif (!(dialog && \"open\" in dialog)) {\n\t\t\t\tdialog = dialog || {};\n\t\t\t\tconst item = (dialog.item = dialog.item || {});\n\t\t\t\tconst text = (item.text = item.text || {});\n\t\t\t\tif (text.formatter === undefined) {\n\t\t\t\t\t// Assumes formatter is ( value: DIALOG_VALUE | null, caller: any ) => string.\n\t\t\t\t\ttext.formatter = formatter as any;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Try to copy dialog.item.text.formatter to text.formatter\n\t\t\tconst dialog = options.dialog;\n\t\t\tif (!(dialog && \"open\" in dialog)) {\n\t\t\t\tconst dialogFormatter = dialog?.item?.text?.formatter;\n\t\t\t\tif (dialogFormatter !== undefined) {\n\t\t\t\t\tconst text = options.text || {};\n\t\t\t\t\toptions.text = text;\n\t\t\t\t\tif (text.formatter === undefined) {\n\t\t\t\t\t\t// Assumes dialogFormatter is ( value: VALUE | null, caller: any ) => string.\n\t\t\t\t\t\ttext.formatter = dialogFormatter as any;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn options;\n};\n\nexport class DButtonSelect<\n\tVALUE = unknown,\n\tDIALOG_VALUE = unknown,\n\tDIALOG extends DButtonSelectDialog<DIALOG_VALUE> = DButtonSelectDialog<DIALOG_VALUE>,\n\tTHEME extends DThemeButtonSelect<VALUE> = DThemeButtonSelect<VALUE>,\n\tOPTIONS extends DButtonSelectOptions<VALUE, DIALOG_VALUE, DIALOG, THEME> = DButtonSelectOptions<\n\t\tVALUE,\n\t\tDIALOG_VALUE,\n\t\tDIALOG,\n\t\tTHEME\n\t>\n> extends DButton<VALUE | null, THEME, OPTIONS> {\n\tprotected _dialog?: DIALOG;\n\tprotected _dialogGetter: DButtonSelectGetter<VALUE, DIALOG>;\n\tprotected _dialogSetter: DButtonSelectSetter<VALUE, DIALOG>;\n\n\tconstructor(options?: OPTIONS) {\n\t\tsuper(toOptions(options));\n\t\tthis._dialogGetter = options?.getter ?? defaultGetter;\n\t\tthis._dialogSetter = options?.setter ?? defaultSetter;\n\t}\n\n\tprotected onActivate(\n\t\te?: interaction.InteractionEvent | KeyboardEvent | MouseEvent | TouchEvent\n\t): void {\n\t\tsuper.onActivate(e);\n\t\tconst dialog = this.dialog;\n\t\tconst oldValue = this._textValueComputed ?? null;\n\t\tthis._dialogSetter(dialog, oldValue);\n\t\tdialog.open(this).then((): void => {\n\t\t\tconst newValue = this._dialogGetter(dialog);\n\t\t\tif (newValue !== oldValue) {\n\t\t\t\tthis.text = newValue;\n\t\t\t\tthis.emit(\"change\", newValue, oldValue, this);\n\t\t\t}\n\t\t});\n\t}\n\n\tget dialog(): DIALOG {\n\t\tlet dialog = this._dialog;\n\t\tif (dialog == null) {\n\t\t\tconst options = this._options?.dialog;\n\t\t\tif (options && \"open\" in options) {\n\t\t\t\tdialog = options;\n\t\t\t} else {\n\t\t\t\t// Assumes DIALOG === DDialogSelect<DIALOG_VALUE>.\n\t\t\t\tdialog = new DDialogSelect<DIALOG_VALUE>(options) as any as DIALOG;\n\t\t\t}\n\t\t\tthis._dialog = dialog;\n\t\t}\n\t\treturn dialog;\n\t}\n\n\tget value(): VALUE | null {\n\t\treturn this._textValueComputed ?? null;\n\t}\n\n\tset value(value: VALUE | null) {\n\t\tthis.text = value;\n\t}\n\n\tprotected getType(): string {\n\t\treturn \"DButtonSelect\";\n\t}\n}\n"]}
|
|
@@ -9,8 +9,12 @@ export var DCommandFlag = {
|
|
|
9
9
|
*/
|
|
10
10
|
UNSTORABLE: 1,
|
|
11
11
|
/**
|
|
12
|
-
* Commands with a `CLEAR` flag
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
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/ui/d-controller-default-command.ts"],"names":[],"mappings":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AAC,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,GAAG,UAAC,OAAiB;IACxC,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M,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"]}
|