|
|
@ -5,15 +5,16 @@ define([
|
|
|
|
var JsonOT = {};
|
|
|
|
var JsonOT = {};
|
|
|
|
|
|
|
|
|
|
|
|
var validate = JsonOT.validate = function (text, toTransform, transformBy) {
|
|
|
|
var validate = JsonOT.validate = function (text, toTransform, transformBy) {
|
|
|
|
|
|
|
|
var resultOp, text2, text3;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// text = O (mutual common ancestor)
|
|
|
|
// text = O (mutual common ancestor)
|
|
|
|
// toTransform = A (the first incoming operation)
|
|
|
|
// toTransform = A (the first incoming operation)
|
|
|
|
// transformBy = B (the second incoming operation)
|
|
|
|
// transformBy = B (the second incoming operation)
|
|
|
|
// threeway merge (0, A, B)
|
|
|
|
// threeway merge (0, A, B)
|
|
|
|
|
|
|
|
|
|
|
|
var resultOp = ChainPad.Operation.transform0(text, toTransform, transformBy);
|
|
|
|
resultOp = ChainPad.Operation.transform0(text, toTransform, transformBy);
|
|
|
|
var text2 = ChainPad.Operation.apply(transformBy, text);
|
|
|
|
text2 = ChainPad.Operation.apply(transformBy, text);
|
|
|
|
var text3 = ChainPad.Operation.apply(resultOp, text2);
|
|
|
|
text3 = ChainPad.Operation.apply(resultOp, text2);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSON.parse(text3);
|
|
|
|
JSON.parse(text3);
|
|
|
|
return resultOp;
|
|
|
|
return resultOp;
|
|
|
@ -35,8 +36,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (x) {
|
|
|
|
} catch (x) {
|
|
|
|
console.error(x);
|
|
|
|
console.error(x);
|
|
|
|
console.error(e);
|
|
|
|
window.REALTIME_MODULE.ot_applyError = {
|
|
|
|
var info = window.REALTIME_MODULE.ot_applyError = {
|
|
|
|
|
|
|
|
type: 'resultParseError',
|
|
|
|
type: 'resultParseError',
|
|
|
|
resultOp: resultOp,
|
|
|
|
resultOp: resultOp,
|
|
|
|
|
|
|
|
|
|
|
@ -46,7 +46,7 @@ define([
|
|
|
|
text1: text,
|
|
|
|
text1: text,
|
|
|
|
text2: text2,
|
|
|
|
text2: text2,
|
|
|
|
text3: text3,
|
|
|
|
text3: text3,
|
|
|
|
error: e
|
|
|
|
error: x
|
|
|
|
};
|
|
|
|
};
|
|
|
|
console.log('Debugging info available at `window.REALTIME_MODULE.ot_applyError`');
|
|
|
|
console.log('Debugging info available at `window.REALTIME_MODULE.ot_applyError`');
|
|
|
|
}
|
|
|
|
}
|
|
|
|