@chix/flow
Version:
78 lines • 3.03 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var _debug = require("debug");
var common_1 = require("../common");
var port_1 = require("../sandbox/port");
var util_1 = require("../util");
var dependency_1 = require("./dependency");
var nodebox_1 = require("./nodebox");
var output_1 = require("./output");
var ports_1 = require("./ports");
var debug = _debug('chix:node');
function $Port(Base) {
return (function (_super) {
__extends(Port$, _super);
function Port$() {
return _super !== null && _super.apply(this, arguments) || this;
}
Port$.prototype._createPortBox = function (fn, name) {
debug('%s: creating portBox `%s`', this.identifier, name);
var portBox = new port_1.PortBox(name);
portBox.set('state', this.nodebox.state);
portBox.set('output', this._asyncOutput.bind(this));
if (this.dependencies && this.dependencies.npm) {
portBox.addDependencies(this.dependencies.npm, this.dependencyLoader);
}
if (this.expose) {
portBox.expose(this.expose);
}
if (typeof fn !== 'function') {
fn = fn.slice(fn.indexOf('{') + 1, fn.lastIndexOf('}'));
portBox.compile(fn);
}
else {
portBox.fill(fn);
}
return portBox;
};
Port$.prototype.$portIsFilled = function (port) {
var inputPorts = this.ports.input;
if (inputPorts) {
var inputPort = inputPorts[port];
return inputPort.isFilled();
}
return false;
};
Port$.prototype.handlePortSettings = function (_port) {
throw Error('Method not implemented...');
};
Port$.prototype.portIsOpen = function (_name) {
return true;
};
Port$.prototype.inputPortAvailable = function (_target) {
return true;
};
return Port$;
}(Base));
}
exports.$Port = $Port;
(function ($Port) {
function create(Base) {
return util_1.mixin($Port, dependency_1.$Dependency.create, common_1.$Identity.create, nodebox_1.$Nodebox.create, ports_1.$Ports.create, output_1.$Output.create)(Base);
}
$Port.create = create;
})($Port = exports.$Port || (exports.$Port = {}));
//# sourceMappingURL=port.js.map