Import classes in the proper way to not cause runtime errors.
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
/// <reference path="KeyActionNone.ts" />
|
||||
/// <reference path="KeystrokeAction.ts" />
|
||||
|
||||
class KeyAction {
|
||||
|
||||
static fromJsObject(jsObject: any): KeyAction {
|
||||
switch (jsObject.keyActionType) {
|
||||
case KeystrokeAction.actionTypeString:
|
||||
return new KeyActionNone().fromJsObject(jsObject);
|
||||
case KeystrokeAction.actionTypeString:
|
||||
return new KeystrokeAction().fromJsObject(jsObject);
|
||||
case KeyActionNone.actionTypeString:
|
||||
return new KeyActionNone().fromJsObject(jsObject);
|
||||
default:
|
||||
throw 'Unknown KeyAction actionType "${jsObject.actionType}"';
|
||||
throw 'Invalid KeyAction.keyActionType: "${jsObject.actionType}"';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +20,7 @@ class KeyAction {
|
||||
} else if (keyActionFirstByte === KeyActionNone.keyActionNoneId) {
|
||||
return new KeyActionNone().fromBinary(buffer);
|
||||
} else {
|
||||
throw 'Unknown KeyAction first byte "${keyActionFirstByte}"';
|
||||
throw 'Invalid KeyAction first byte "${keyActionFirstByte}"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/// <reference path="KeyAction.ts" />
|
||||
/// <reference path="Serializable.ts" />
|
||||
|
||||
class KeyActionNone extends KeyAction implements Serializable<KeyActionNone> {
|
||||
|
||||
static actionTypeString = 'none';
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/// <reference path="KeyAction.ts" />
|
||||
/// <reference path="Serializable.ts" />
|
||||
|
||||
class KeystrokeAction extends KeyAction implements Serializable<KeystrokeAction> {
|
||||
|
||||
static actionTypeString = 'keystroke';
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/// <reference path="UhkBuffer.ts" />
|
||||
|
||||
interface Serializable<T> {
|
||||
fromJsObject(jsObject: any): T;
|
||||
fromBinary(buffer: UhkBuffer): T;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
/// <reference path="Serializable.ts" />
|
||||
/// <reference path="UhkBuffer.ts" />
|
||||
/// <reference path="KeyAction.ts" />
|
||||
/// <reference path="KeystrokeAction.ts" />
|
||||
/// <reference path="KeyActionNone.ts" />
|
||||
|
||||
let fs = require('fs');
|
||||
let writer = new UhkBuffer();
|
||||
@@ -147,6 +150,5 @@ function serializeSwitchLayerAction(switchLayerAction) {
|
||||
}[switchLayerAction] | switchLayerAction.toggle ? SWITCH_LAYER_TOGGLE : 0);
|
||||
}
|
||||
|
||||
new KeystrokeAction();
|
||||
serializeKeyActions(keyActions);
|
||||
//serializeKeyActions(keyActions);
|
||||
fs.writeFileSync('uhk-config.bin', writer.buffer);
|
||||
|
||||
Reference in New Issue
Block a user