first commit

This commit is contained in:
2026-09-08 20:28:54 +08:00
commit 2ada8d3d5a
37380 changed files with 4886169 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
var Command, ForwardCommand, Protocol,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Command = require('../../command');
Protocol = require('../../protocol');
ForwardCommand = (function(superClass) {
extend(ForwardCommand, superClass);
function ForwardCommand() {
return ForwardCommand.__super__.constructor.apply(this, arguments);
}
ForwardCommand.prototype.execute = function(serial, local, remote) {
this._send("host-serial:" + serial + ":forward:" + local + ";" + remote);
return this.parser.readAscii(4).then((function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readAscii(4).then(function(reply) {
switch (reply) {
case Protocol.OKAY:
return true;
case Protocol.FAIL:
return _this.parser.readError();
default:
return _this.parser.unexpected(reply, 'OKAY or FAIL');
}
});
case Protocol.FAIL:
return _this.parser.readError();
default:
return _this.parser.unexpected(reply, 'OKAY or FAIL');
}
};
})(this));
};
return ForwardCommand;
})(Command);
module.exports = ForwardCommand;
+38
View File
@@ -0,0 +1,38 @@
var Command, GetDevicePathCommand, Protocol,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Command = require('../../command');
Protocol = require('../../protocol');
GetDevicePathCommand = (function(superClass) {
extend(GetDevicePathCommand, superClass);
function GetDevicePathCommand() {
return GetDevicePathCommand.__super__.constructor.apply(this, arguments);
}
GetDevicePathCommand.prototype.execute = function(serial) {
this._send("host-serial:" + serial + ":get-devpath");
return this.parser.readAscii(4).then((function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue().then(function(value) {
return value.toString();
});
case Protocol.FAIL:
return _this.parser.readError();
default:
return _this.parser.unexpected(reply, 'OKAY or FAIL');
}
};
})(this));
};
return GetDevicePathCommand;
})(Command);
module.exports = GetDevicePathCommand;
+38
View File
@@ -0,0 +1,38 @@
var Command, GetSerialNoCommand, Protocol,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Command = require('../../command');
Protocol = require('../../protocol');
GetSerialNoCommand = (function(superClass) {
extend(GetSerialNoCommand, superClass);
function GetSerialNoCommand() {
return GetSerialNoCommand.__super__.constructor.apply(this, arguments);
}
GetSerialNoCommand.prototype.execute = function(serial) {
this._send("host-serial:" + serial + ":get-serialno");
return this.parser.readAscii(4).then((function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue().then(function(value) {
return value.toString();
});
case Protocol.FAIL:
return _this.parser.readError();
default:
return _this.parser.unexpected(reply, 'OKAY or FAIL');
}
};
})(this));
};
return GetSerialNoCommand;
})(Command);
module.exports = GetSerialNoCommand;
+38
View File
@@ -0,0 +1,38 @@
var Command, GetStateCommand, Protocol,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Command = require('../../command');
Protocol = require('../../protocol');
GetStateCommand = (function(superClass) {
extend(GetStateCommand, superClass);
function GetStateCommand() {
return GetStateCommand.__super__.constructor.apply(this, arguments);
}
GetStateCommand.prototype.execute = function(serial) {
this._send("host-serial:" + serial + ":get-state");
return this.parser.readAscii(4).then((function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue().then(function(value) {
return value.toString();
});
case Protocol.FAIL:
return _this.parser.readError();
default:
return _this.parser.unexpected(reply, 'OKAY or FAIL');
}
};
})(this));
};
return GetStateCommand;
})(Command);
module.exports = GetStateCommand;
+56
View File
@@ -0,0 +1,56 @@
var Command, ListForwardsCommand, Protocol,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Command = require('../../command');
Protocol = require('../../protocol');
ListForwardsCommand = (function(superClass) {
extend(ListForwardsCommand, superClass);
function ListForwardsCommand() {
return ListForwardsCommand.__super__.constructor.apply(this, arguments);
}
ListForwardsCommand.prototype.execute = function(serial) {
this._send("host-serial:" + serial + ":list-forward");
return this.parser.readAscii(4).then((function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readValue().then(function(value) {
return _this._parseForwards(value);
});
case Protocol.FAIL:
return _this.parser.readError();
default:
return _this.parser.unexpected(reply, 'OKAY or FAIL');
}
};
})(this));
};
ListForwardsCommand.prototype._parseForwards = function(value) {
var forward, forwards, i, len, local, ref, ref1, remote, serial;
forwards = [];
ref = value.toString().split('\n');
for (i = 0, len = ref.length; i < len; i++) {
forward = ref[i];
if (forward) {
ref1 = forward.split(/\s+/), serial = ref1[0], local = ref1[1], remote = ref1[2];
forwards.push({
serial: serial,
local: local,
remote: remote
});
}
}
return forwards;
};
return ListForwardsCommand;
})(Command);
module.exports = ListForwardsCommand;
+45
View File
@@ -0,0 +1,45 @@
var Command, Protocol, WaitForDeviceCommand,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Command = require('../../command');
Protocol = require('../../protocol');
WaitForDeviceCommand = (function(superClass) {
extend(WaitForDeviceCommand, superClass);
function WaitForDeviceCommand() {
return WaitForDeviceCommand.__super__.constructor.apply(this, arguments);
}
WaitForDeviceCommand.prototype.execute = function(serial) {
this._send("host-serial:" + serial + ":wait-for-any");
return this.parser.readAscii(4).then((function(_this) {
return function(reply) {
switch (reply) {
case Protocol.OKAY:
return _this.parser.readAscii(4).then(function(reply) {
switch (reply) {
case Protocol.OKAY:
return serial;
case Protocol.FAIL:
return _this.parser.readError();
default:
return _this.parser.unexpected(reply, 'OKAY or FAIL');
}
});
case Protocol.FAIL:
return _this.parser.readError();
default:
return _this.parser.unexpected(reply, 'OKAY or FAIL');
}
};
})(this));
};
return WaitForDeviceCommand;
})(Command);
module.exports = WaitForDeviceCommand;