build: Fix reflection and minification conflict (#399)
The minification change the class name so constructor.name not give back the correct class name. Introduced getName() method in KeyAction and MacroAction Abstract class
This commit is contained in:
committed by
László Monda
parent
be3e116130
commit
ee93466a08
@@ -5,7 +5,7 @@
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build --prod --aot",
|
||||
"build": "ng build --prod --aot --base-href=\"\"",
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"e2e": "ng e2e",
|
||||
|
||||
@@ -32,7 +32,7 @@ export let keyActionType = {
|
||||
export abstract class KeyAction {
|
||||
|
||||
assertKeyActionType(jsObject: any): void {
|
||||
const keyActionClassname: string = this.constructor.name;
|
||||
const keyActionClassname: string = this.getName();
|
||||
const keyActionTypeString: string = keyActionType[keyActionClassname];
|
||||
if (jsObject.keyActionType !== keyActionTypeString) {
|
||||
throw `Invalid ${keyActionClassname}.keyActionType: ${jsObject.keyActionType}`;
|
||||
@@ -40,7 +40,7 @@ export abstract class KeyAction {
|
||||
}
|
||||
|
||||
readAndAssertKeyActionId(buffer: UhkBuffer): KeyActionId {
|
||||
const classname: string = this.constructor.name;
|
||||
const classname: string = this.getName();
|
||||
const readKeyActionId: number = buffer.readUInt8();
|
||||
const keyActionId: number = KeyActionId[classname];
|
||||
if (keyActionId === KeyActionId.KeystrokeAction) {
|
||||
@@ -54,8 +54,11 @@ export abstract class KeyAction {
|
||||
}
|
||||
|
||||
abstract toJsonObject(macros?: Macro[]): any;
|
||||
|
||||
abstract toBinary(buffer: UhkBuffer, userConfiguration?: UserConfiguration): void;
|
||||
|
||||
abstract getName(): string;
|
||||
|
||||
renameKeymap(oldAbbr: string, newAbbr: string): KeyAction {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -208,4 +208,8 @@ export class KeystrokeAction extends KeyAction {
|
||||
}
|
||||
return modifierList;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'KeystrokeAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,4 +58,8 @@ export class MouseAction extends KeyAction {
|
||||
toString(): string {
|
||||
return `<MouseAction mouseAction="${this.mouseAction}">`;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'MouseAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,8 @@ export class NoneAction extends KeyAction {
|
||||
toString(): string {
|
||||
return '<NoneAction>';
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'NoneAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,4 +49,8 @@ export class PlayMacroAction extends KeyAction {
|
||||
toString(): string {
|
||||
return `<PlayMacroAction macroId="${this.macroId}">`;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'PlayMacroAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ export class SwitchKeymapAction extends KeyAction {
|
||||
}
|
||||
return new SwitchKeymapAction(newAbbr);
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'SwitchKeymapAction';
|
||||
}
|
||||
}
|
||||
|
||||
export class UnresolvedSwitchKeymapAction extends KeyAction {
|
||||
@@ -81,4 +85,8 @@ export class UnresolvedSwitchKeymapAction extends KeyAction {
|
||||
resolve(keymaps: Keymap[]): SwitchKeymapAction {
|
||||
return new SwitchKeymapAction(keymaps[this.keymapIndex]);
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'UnresolvedSwitchKeymapAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,4 +56,7 @@ export class SwitchLayerAction extends KeyAction {
|
||||
return `<SwitchLayerAction layer="${this.layer}" toggle="${this.isLayerToggleable}">`;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'SwitchLayerAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,4 +42,8 @@ export class DelayMacroAction extends MacroAction {
|
||||
toString(): string {
|
||||
return `<DelayMacroAction delay="${this.delay}">`;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'DelayMacroAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,4 +132,8 @@ export class KeyMacroAction extends MacroAction {
|
||||
isReleaseAction(): boolean {
|
||||
return this.action === MacroSubAction.release;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'KeyMacroAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ export let macroActionType = {
|
||||
|
||||
export abstract class MacroAction {
|
||||
assertMacroActionType(jsObject: any) {
|
||||
const macroActionClassname = this.constructor.name;
|
||||
const macroActionClassname = this.getName();
|
||||
const macroActionTypeString = macroActionType[macroActionClassname];
|
||||
if (jsObject.macroActionType !== macroActionTypeString) {
|
||||
throw `Invalid ${macroActionClassname}.macroActionType: ${jsObject.macroActionType}`;
|
||||
@@ -48,7 +48,7 @@ export abstract class MacroAction {
|
||||
}
|
||||
|
||||
readAndAssertMacroActionId(buffer: UhkBuffer): MacroActionId {
|
||||
const classname: string = this.constructor.name;
|
||||
const classname: string = this.getName();
|
||||
const readMacroActionId: MacroActionId = buffer.readUInt8();
|
||||
const macroActionId: MacroActionId = MacroActionId[classname];
|
||||
if (macroActionId === MacroActionId.KeyMacroAction) {
|
||||
@@ -67,5 +67,8 @@ export abstract class MacroAction {
|
||||
}
|
||||
|
||||
abstract toJsonObject(): any;
|
||||
|
||||
abstract toBinary(buffer: UhkBuffer): void;
|
||||
|
||||
abstract getName(): string;
|
||||
}
|
||||
|
||||
@@ -92,4 +92,8 @@ export class MouseButtonMacroAction extends MacroAction {
|
||||
isOnlyReleaseAction(): boolean {
|
||||
return this.action === MacroSubAction.release;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'MouseButtonMacroAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,4 +50,8 @@ export class MoveMouseMacroAction extends MacroAction {
|
||||
toString(): string {
|
||||
return `<MoveMouseMacroAction pos="(${this.x},${this.y})">`;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'MoveMouseMacroAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,4 +50,8 @@ export class ScrollMouseMacroAction extends MacroAction {
|
||||
toString(): string {
|
||||
return `<ScrollMouseMacroAction pos="(${this.x},${this.y})">`;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'ScrollMouseMacroAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,4 +40,8 @@ export class TextMacroAction extends MacroAction {
|
||||
toString(): string {
|
||||
return `<TextMacroAction text="${this.text}">`;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return 'TextMacroAction';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,7 +384,14 @@ module.exports = {
|
||||
"inject": true,
|
||||
"compile": true,
|
||||
"favicon": false,
|
||||
"minify": false,
|
||||
"minify": !AOT_BUILD ? false : {
|
||||
removeAttributeQuotes: true,
|
||||
collapseWhitespace: true,
|
||||
html5: true,
|
||||
minifyCSS: true,
|
||||
removeComments: true,
|
||||
removeEmptyAttributes: true,
|
||||
},
|
||||
"cache": true,
|
||||
"showErrors": true,
|
||||
"chunks": "all",
|
||||
|
||||
Reference in New Issue
Block a user