41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
var Engine, HistoryBuffer, adaptConnector, createY, json_ops_uninitialized;
|
|
|
|
json_ops_uninitialized = require("./Operations/Json");
|
|
|
|
HistoryBuffer = require("./HistoryBuffer");
|
|
|
|
Engine = require("./Engine");
|
|
|
|
adaptConnector = require("./ConnectorAdapter");
|
|
|
|
createY = function(connector) {
|
|
var HB, engine, ops, ops_manager, user_id;
|
|
user_id = null;
|
|
if (connector.user_id != null) {
|
|
user_id = connector.user_id;
|
|
} else {
|
|
user_id = "_temp";
|
|
connector.on_user_id_set = function(id) {
|
|
user_id = id;
|
|
return HB.resetUserId(id);
|
|
};
|
|
}
|
|
HB = new HistoryBuffer(user_id);
|
|
ops_manager = json_ops_uninitialized(HB, this.constructor);
|
|
ops = ops_manager.operations;
|
|
engine = new Engine(HB, ops);
|
|
adaptConnector(connector, engine, HB, ops_manager.execution_listener);
|
|
ops.Operation.prototype.HB = HB;
|
|
ops.Operation.prototype.operations = ops;
|
|
ops.Operation.prototype.engine = engine;
|
|
ops.Operation.prototype.connector = connector;
|
|
ops.Operation.prototype.custom_ops = this.constructor;
|
|
return new ops.Object(HB.getReservedUniqueIdentifier()).execute();
|
|
};
|
|
|
|
module.exports = createY;
|
|
|
|
if ((typeof window !== "undefined" && window !== null) && (window.Y == null)) {
|
|
window.Y = createY;
|
|
}
|