updated READMEs
This commit is contained in:
parent
5ce4fbe950
commit
c6ca102bce
10
README.md
10
README.md
@ -6,13 +6,14 @@ Yatta! provides similar functionality as [ShareJs](https://github.com/share/Shar
|
||||
but does not require you to understand how the internals work. The predefined data structures provide a simple API to access your shared data structures.
|
||||
|
||||
Predefined data structures:
|
||||
* Text
|
||||
* Json - [example](./examples/IwcJson/)
|
||||
* Text - [Collaborative Text Editing Example](./examples/TextEditing/)
|
||||
* Json - [example](./examples/Json/)
|
||||
* XML (coming soon)
|
||||
|
||||
Unlike other frameworks, Yatta! supports P2P message propagation and is not bound to a specific communication protocol.
|
||||
|
||||
Currently supported communication protocols:
|
||||
* [PeerJs](http://peerjs.com/) - WebRTC library
|
||||
* [IWC](http://dbis.rwth-aachen.de/cms/projects/the-xmpp-experience#interwidget-communication) - Inter-widget Communication
|
||||
|
||||
# Use it!
|
||||
@ -53,14 +54,15 @@ Yatta! means "I did it!" in Japanese. You scream it when you accomplish somethin
|
||||
There is also this awesome video on the Internet that will change your life [Yatta](https://www.youtube.com/watch?v=kL5DDSglM_s).
|
||||
|
||||
# Status
|
||||
Yatta! is still in an early development phase.
|
||||
Yatta! is still in an early development phase. Don't expect that everything is working fine.
|
||||
But I would become really motivated if you give me some feedback ([github](https://github.com/DadaMonad/Yatta/issues) or mail).
|
||||
|
||||
# Support
|
||||
Please report any issues to the [Github issue page](https://github.com/DadaMonad/Yatta/issues)!
|
||||
|
||||
# License
|
||||
Yatta! is licensed under the [MIT License](./LICENSE.txt).
|
||||
|
||||
<kevin.jahns@rwth-aachen.de>
|
||||
|
||||
|
||||
|
||||
|
110
build/browser/Engine.js
Normal file
110
build/browser/Engine.js
Normal file
File diff suppressed because one or more lines are too long
1
build/browser/Engine.min.js
vendored
Normal file
1
build/browser/Engine.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function r(e,t,o){function p(s,i){if(!t[s]){if(!e[s]){var u="function"==typeof require&&require;if(!i&&u)return u(s,!0);if(n)return n(s,!0);throw new Error("Cannot find module '"+s+"'")}var h=t[s]={exports:{}};e[s][0].call(h.exports,function(r){var t=e[s][1][r];return p(t?t:r)},h,h.exports,r,e,t,o)}return t[s].exports}for(var n="function"==typeof require&&require,s=0;s<o.length;s++)p(o[s]);return p}({1:[function(r,e){var t;t=function(){function r(r,e){this.HB=r,this.parser=e,this.unprocessed_ops=[]}return r.prototype.parseOperation=function(r){var e;if(e=this.parser[r.type],null!=e)return e(r);throw new Error("You forgot to specify a parser for type "+r.type+". The message is "+JSON.stringify(r)+".")},r.prototype.applyOpsBundle=function(r){var e,t,o,p,n,s,i,u;for(t=[],o=0,s=r.length;s>o;o++)e=r[o],t.push(this.parseOperation(e));for(p=0,i=t.length;i>p;p++)e=t[p],this.HB.addOperation(e);for(n=0,u=t.length;u>n;n++)e=t[n],e.execute()||this.unprocessed_ops.push(e);return this.tryUnprocessed()},r.prototype.applyOpsCheckDouble=function(r){var e,t,o,p;for(p=[],t=0,o=r.length;o>t;t++)e=r[t],p.push(null==this.HB.getOperation(e.uid)?this.applyOp(e):void 0);return p},r.prototype.applyOps=function(r){var e,t,o,p;for(p=[],t=0,o=r.length;o>t;t++)e=r[t],p.push(this.applyOp(e));return p},r.prototype.applyOp=function(r){var e;return e=this.parseOperation(r),this.HB.addToCounter(e),e.execute()?this.HB.addOperation(e):this.unprocessed_ops.push(e),this.tryUnprocessed()},r.prototype.tryUnprocessed=function(){var r,e,t,o,p,n,s;for(s=[];;){for(r=this.unprocessed_ops.length,t=[],n=this.unprocessed_ops,o=0,p=n.length;p>o;o++)e=n[o],e.execute()?this.HB.addOperation(e):t.push(e);if(this.unprocessed_ops=t,this.unprocessed_ops.length===r)break;s.push(void 0)}return s},r}(),e.exports=t},{}]},{},[1]);
|
128
build/browser/HistoryBuffer.js
Normal file
128
build/browser/HistoryBuffer.js
Normal file
File diff suppressed because one or more lines are too long
1
build/browser/HistoryBuffer.min.js
vendored
Normal file
1
build/browser/HistoryBuffer.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function r(e,t,n){function o(u,f){if(!t[u]){if(!e[u]){var p="function"==typeof require&&require;if(!f&&p)return p(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var c=t[u]={exports:{}};e[u][0].call(c.exports,function(r){var t=e[u][1][r];return o(t?t:r)},c,c.exports,r,e,t,n)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(r,e){var t;t=function(){function r(r){this.user_id=r,this.operation_counter={},this.buffer={},this.change_listeners=[]}return r.prototype.getUserId=function(){return this.user_id},r.prototype.getReservedUniqueIdentifier=function(){return{creator:"_",op_number:"_"}},r.prototype.getOperationCounter=function(){var r,e,t,n;e={},n=this.operation_counter;for(t in n)r=n[t],e[t]=r;return e},r.prototype._encode=function(r){var e,t,n,o,i,u,f,p,c,a;null==r&&(r={}),e=[],p=function(e,t){if(null==e||null==t)throw new Error("dah!");return null==r[e]||r[e]<=t},a=this.buffer;for(f in a){c=a[f];for(i in c)if(t=c[i],!isNaN(parseInt(i))&&p(f,i)){if(n=t._encode(),null!=t.next_cl){for(o=t.next_cl;null!=o.next_cl&&p(o.creator,o.op_number);)o=o.next_cl;n.next=o.getUid()}else if(null!=t.prev_cl){for(u=t.prev_cl;null!=u.prev_cl&&p(o.creator,o.op_number);)u=u.prev_cl;n.prev=u.getUid()}e.push(n)}}return e},r.prototype.getNextOperationIdentifier=function(r){var e;return null==r&&(r=this.user_id),null==this.operation_counter[r]&&(this.operation_counter[r]=0),e={creator:r,op_number:this.operation_counter[r]},this.operation_counter[r]++,e},r.prototype.getOperation=function(r){var e;if(r instanceof Object)return null!=(e=this.buffer[r.creator])?e[r.op_number]:void 0;if(null!=r)throw new Error("This type of uid is not defined!")},r.prototype.addOperation=function(r){if(null==this.buffer[r.creator]&&(this.buffer[r.creator]={}),null!=this.buffer[r.creator][r.op_number])throw new Error("You must not overwrite operations!");return this.buffer[r.creator][r.op_number]=r,r},r.prototype.addToCounter=function(r){return null==this.operation_counter[r.creator]&&(this.operation_counter[r.creator]=0),"number"==typeof r.op_number&&r.creator!==this.getUserId()?this.operation_counter[r.creator]++:void 0},r}(),e.exports=t},{}]},{},[1]);
|
3088
build/browser/index.js
Normal file
3088
build/browser/index.js
Normal file
File diff suppressed because one or more lines are too long
2
build/browser/index.min.js
vendored
Normal file
2
build/browser/index.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
build/node/Engine.js
Normal file
2
build/node/Engine.js
Normal file
@ -0,0 +1,2 @@
|
||||
(function(){var t;t=function(){function t(t,e){this.HB=t,this.parser=e,this.unprocessed_ops=[]}return t.prototype.parseOperation=function(t){var e;if(e=this.parser[t.type],null!=e)return e(t);throw new Error("You forgot to specify a parser for type "+t.type+". The message is "+JSON.stringify(t)+".")},t.prototype.applyOpsBundle=function(t){var e,r,p,s,o,n,i,u;for(r=[],p=0,n=t.length;n>p;p++)e=t[p],r.push(this.parseOperation(e));for(s=0,i=r.length;i>s;s++)e=r[s],this.HB.addOperation(e);for(o=0,u=r.length;u>o;o++)e=r[o],e.execute()||this.unprocessed_ops.push(e);return this.tryUnprocessed()},t.prototype.applyOpsCheckDouble=function(t){var e,r,p,s;for(s=[],r=0,p=t.length;p>r;r++)e=t[r],s.push(null==this.HB.getOperation(e.uid)?this.applyOp(e):void 0);return s},t.prototype.applyOps=function(t){var e,r,p,s;for(s=[],r=0,p=t.length;p>r;r++)e=t[r],s.push(this.applyOp(e));return s},t.prototype.applyOp=function(t){var e;return e=this.parseOperation(t),this.HB.addToCounter(e),e.execute()?this.HB.addOperation(e):this.unprocessed_ops.push(e),this.tryUnprocessed()},t.prototype.tryUnprocessed=function(){var t,e,r,p,s,o,n;for(n=[];;){for(t=this.unprocessed_ops.length,r=[],o=this.unprocessed_ops,p=0,s=o.length;s>p;p++)e=o[p],e.execute()?this.HB.addOperation(e):r.push(e);if(this.unprocessed_ops=r,this.unprocessed_ops.length===t)break;n.push(void 0)}return n},t}(),module.exports=t}).call(this);
|
||||
//# sourceMappingURL=Engine.js.map
|
1
build/node/Engine.js.map
Executable file
1
build/node/Engine.js.map
Executable file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Engine.js","sources":["Engine.coffee"],"names":[],"mappings":"CAIA,WAAA,GAAA,EAAM,GAAA,WAMS,QAAA,GAAE,EAAK,GAAN,KAAC,GAAA,EAAI,KAAC,OAAA,EAClB,KAAC,yBADH,GAAA,UAMA,eAAgB,SAAC,GACf,GAAA,EACA,IADA,EAAa,KAAC,OAAO,EAAK,MACvB,MAAA,QACD,GAAW,EAEX,MAAU,IAAA,OAAO,2CAAyC,EAAK,KAAM,oBAAkB,KAAK,UAAU,GAAM,MAXhH,EAAA,UAiBA,eAAgB,SAAC,GACf,GAAA,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CACA,KADA,KACA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,WACE,EAAI,KAAK,KAAC,eAAe,GAC3B,KAAA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,WACE,KAAC,GAAG,aAAa,EACnB,KAAA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,WACK,EAAM,WACP,KAAC,gBAAgB,KAAK,SAC1B,MAAC,kBA1BH,EAAA,UAgCA,oBAAqB,SAAC,GACpB,GAAA,GAAA,EAAA,EAAA,MAAA,KAAA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,kBACS,MAAA,KAAA,GAAA,aAAA,EAAA,KACL,KAAC,QAAQ,qBAnCf,EAAA,UAwCA,SAAU,SAAC,GACT,GAAA,GAAA,EAAA,EAAA,MAAA,KAAA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,WACE,EAAA,KAAA,KAAC,QAAQ,cA1Cb,EAAA,UA+CA,QAAS,SAAC,GAER,GAAA,SAAA,GAAI,KAAC,eAAe,GACpB,KAAC,GAAG,aAAa,GAEd,EAAM,UAGP,KAAC,GAAG,aAAa,GAFjB,KAAC,gBAAgB,KAAK,GAGxB,KAAC,kBAxDH,EAAA,UA8DA,eAAgB,WACd,GAAA,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,MAAA,OAAA,CAGE,IAFA,EAAa,KAAC,gBAAgB,OAC9B,KACA,EAAA,KAAA,gBAAA,EAAA,EAAA,EAAA,EAAA,OAAA,EAAA,EAAA,WACK,EAAO,UAGR,KAAC,GAAG,aAAa,GAFjB,EAAY,KAAK,EAIrB,IADA,KAAC,gBAAkB,EAChB,KAAC,gBAAgB,SAAU,EAC5B,oCAKR,OAAO,QAAU","sourcesContent":["\r\n#\r\n# The Engine handles how and in which order to execute operations and add operations to the HistoryBuffer.\r\n#\r\nclass Engine\r\n\r\n #\r\n # @param {HistoryBuffer} HB\r\n # @param {Array} parser Defines how to parse encoded messages.\r\n #\r\n constructor: (@HB, @parser)->\r\n @unprocessed_ops = []\r\n\r\n #\r\n # Parses an operatio from the json format. It uses the specified parser in your OperationType module.\r\n #\r\n parseOperation: (json)->\r\n typeParser = @parser[json.type]\r\n if typeParser?\r\n typeParser json\r\n else\r\n throw new Error \"You forgot to specify a parser for type #{json.type}. The message is #{JSON.stringify json}.\"\r\n\r\n #\r\n # Apply a set of operations. E.g. the operations you received from another users HB.toJson().\r\n # @note You must not use this method when you already have ops in your HB!\r\n #\r\n applyOpsBundle: (ops_json)->\r\n ops = []\r\n for o in ops_json\r\n ops.push @parseOperation o\r\n for o in ops\r\n @HB.addOperation o\r\n for o in ops\r\n if not o.execute()\r\n @unprocessed_ops.push o\r\n @tryUnprocessed()\r\n\r\n #\r\n # Same as applyOps but operations that are already in the HB are not applied.\r\n # @see Engine.applyOps\r\n #\r\n applyOpsCheckDouble: (ops_json)->\r\n for o in ops_json\r\n if not @HB.getOperation(o.uid)?\r\n @applyOp o\r\n\r\n #\r\n # Apply a set of operations. (Helper for using applyOp on Arrays)\r\n # @see Engine.applyOp\r\n applyOps: (ops_json)->\r\n for o in ops_json\r\n @applyOp o\r\n\r\n #\r\n # Apply an operation that you received from another peer.\r\n #\r\n applyOp: (op_json)->\r\n # $parse_and_execute will return false if $o_json was parsed and executed, otherwise the parsed operadion\r\n o = @parseOperation op_json\r\n @HB.addToCounter o\r\n # @HB.addOperation o\r\n if not o.execute()\r\n @unprocessed_ops.push o\r\n else\r\n @HB.addOperation o\r\n @tryUnprocessed()\r\n\r\n #\r\n # Call this method when you applied a new operation.\r\n # It checks if operations that were previously not executable are now executable.\r\n #\r\n tryUnprocessed: ()->\r\n while true\r\n old_length = @unprocessed_ops.length\r\n unprocessed = []\r\n for op in @unprocessed_ops\r\n if not op.execute()\r\n unprocessed.push op\r\n else\r\n @HB.addOperation op\r\n @unprocessed_ops = unprocessed\r\n if @unprocessed_ops.length is old_length\r\n break\r\n\r\n\r\n\r\n\r\nmodule.exports = Engine\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"],"sourceRoot":"/source/"}
|
@ -1,2 +1,2 @@
|
||||
(function(){var e,t,n,o;o=require("../Types/TextTypes"),t=require("../HistoryBuffer"),e=require("../Engine"),n=function(){function n(n,r){var i,u;this.HB=new t(n),u=o(this.HB),this.engine=new e(this.HB,u.parser),this.connector=new r(this.engine,this.HB,u.execution_listener,this),i=new u.types.Word({creator:"_",op_number:"_"}),this.HB.addOperation(i).execute(),this.root_element=i}return n.prototype.getRootElement=function(){return this.root_element},n.prototype.getEngine=function(){return this.engine},n.prototype.getConnector=function(){return this.connector},n.prototype.getHistoryBuffer=function(){return this.HB},n.prototype.getUserId=function(){return this.HB.getUserId()},n.prototype.val=function(){return this.root_element.val()},n.prototype.insertText=function(e,t){return this.root_element.insertText(e,t)},n.prototype.deleteText=function(e,t){return this.root_element.deleteText(e,t)},n.prototype.bind=function(e){return this.root_element.bind(e)},n.prototype.replaceText=function(e){return this.root_element.replaceText(e)},n}(),module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.TextYatta=n)}).call(this);
|
||||
(function(){var e,t,n,o;o=require("../Types/TextTypes"),t=require("../HistoryBuffer"),e=require("../Engine"),n=function(){function n(n,r){var i,u,s,p,c;this.HB=new t(n),p=o(this.HB),c=p.types,this.engine=new e(this.HB,p.parser),this.connector=new r(this.engine,this.HB,p.execution_listener,this),i=this.HB.addOperation(new c.Delimiter({creator:"_",op_number:"_beginning"},void 0,void 0)),u=this.HB.addOperation(new c.Delimiter({creator:"_",op_number:"_end"},i,void 0)),i.next_cl=u,i.execute(),u.execute(),s=new p.types.Word({creator:"_",op_number:"_"},i,u),this.HB.addOperation(s).execute(),this.root_element=s}return n.prototype.getRootElement=function(){return this.root_element},n.prototype.getEngine=function(){return this.engine},n.prototype.getConnector=function(){return this.connector},n.prototype.getHistoryBuffer=function(){return this.HB},n.prototype.getUserId=function(){return this.HB.getUserId()},n.prototype.val=function(){return this.root_element.val()},n.prototype.insertText=function(e,t){return this.root_element.insertText(e,t)},n.prototype.deleteText=function(e,t){return this.root_element.deleteText(e,t)},n.prototype.bind=function(e){return this.root_element.bind(e)},n.prototype.replaceText=function(e){return this.root_element.replaceText(e)},n}(),module.exports=n,"undefined"!=typeof window&&null!==window&&(null==window.Y&&(window.Y={}),window.Y.TextYatta=n)}).call(this);
|
||||
//# sourceMappingURL=../Frameworks/TextYatta.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"Frameworks/TextYatta.js","sources":["Frameworks/TextYatta.coffee"],"names":[],"mappings":"CACA,WAAA,GAAA,GAAA,EAAA,EAAA,CAAA,GAA2B,QAAQ,sBACnC,EAAgB,QAAQ,oBACxB,EAAS,QAAQ,aAKX,EAAA,WAMS,QAAA,GAAC,EAAS,GACrB,GAAA,GAAA,CAAA,MAAC,GAAS,GAAA,GAAc,GACxB,EAAa,EAAyB,KAAC,IACvC,KAAC,OAAa,GAAA,GAAO,KAAC,GAAI,EAAW,QACrC,KAAC,UAAgB,GAAA,GAAU,KAAC,OAAQ,KAAC,GAAI,EAAW,mBAAoB,MAExE,EAAiB,GAAA,GAAW,MAAM,MAAM,QAAS,IAAK,UAAW,MACjE,KAAC,GAAG,aAAa,GAAY,UAC7B,KAAC,aAAe,QARlB,GAAA,UAaA,eAAgB,iBACd,MAAC,cAdH,EAAA,UAmBA,UAAW,iBACT,MAAC,QApBH,EAAA,UAyBA,aAAc,iBACZ,MAAC,WA1BH,EAAA,UA+BA,iBAAkB,iBAChB,MAAC,IAhCH,EAAA,UAuCA,UAAW,iBACT,MAAC,GAAG,aAxCN,EAAA,UA6CA,IAAK,iBACH,MAAC,aAAa,OA9ChB,EAAA,UAmDA,WAAY,SAAC,EAAK,SAChB,MAAC,aAAa,WAAW,EAAK,IApDhC,EAAA,UAyDA,WAAY,SAAC,EAAK,SAChB,MAAC,aAAa,WAAW,EAAK,IA1DhC,EAAA,UA+DA,KAAM,SAAC,SACL,MAAC,aAAa,KAAK,IAhErB,EAAA,UAqEA,YAAa,SAAC,SACZ,MAAC,aAAa,YAAY,SAG9B,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,UAAY","sourcesContent":["\ntext_types_uninitialized = require \"../Types/TextTypes\"\nHistoryBuffer = require \"../HistoryBuffer\"\nEngine = require \"../Engine\"\n\n#\n# Framework for Text Datastructures.\n#\nclass TextYatta\n\n #\n # @param {String} user_id Uniqe user id that defines this peer.\n # @param {Connector} Connector The connector defines how you connect to the other peers.\n #\n constructor: (user_id, Connector)->\n @HB = new HistoryBuffer user_id\n text_types = text_types_uninitialized @HB\n @engine = new Engine @HB, text_types.parser\n @connector = new Connector @engine, @HB, text_types.execution_listener, @\n\n first_word = new text_types.types.Word {creator: '_', op_number: '_'}\n @HB.addOperation(first_word).execute()\n @root_element = first_word\n\n #\n # @result Word\n #\n getRootElement: ()->\n @root_element\n\n #\n # @see Engine\n #\n getEngine: ()->\n @engine\n\n #\n # Get the initialized connector.\n #\n getConnector: ()->\n @connector\n\n #\n # @see HistoryBuffer\n #\n getHistoryBuffer: ()->\n @HB\n\n #\n # Get the UserId from the HistoryBuffer object.\n # In most cases this will be the same as the user_id value with which\n # JsonYatta was initialized (Depending on the HistoryBuffer implementation).\n #\n getUserId: ()->\n @HB.getUserId()\n\n #\n # @see JsonType.val\n #\n val: ()->\n @root_element.val()\n\n #\n # @see Word.insertText\n #\n insertText: (pos, content)->\n @root_element.insertText pos, content\n\n #\n # @see Word.deleteText\n #\n deleteText: (pos, length)->\n @root_element.deleteText pos, length\n\n #\n # @see Word.bind\n #\n bind: (textarea)->\n @root_element.bind textarea\n\n #\n # @see Word.replaceText\n #\n replaceText: (text)->\n @root_element.replaceText text\n\n\nmodule.exports = TextYatta\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.TextYatta = TextYatta\n"],"sourceRoot":"/source/"}
|
||||
{"version":3,"file":"Frameworks/TextYatta.js","sources":["Frameworks/TextYatta.coffee"],"names":[],"mappings":"CACA,WAAA,GAAA,GAAA,EAAA,EAAA,CAAA,GAA2B,QAAQ,sBACnC,EAAgB,QAAQ,oBACxB,EAAS,QAAQ,aAKX,EAAA,WAMS,QAAA,GAAC,EAAS,GACrB,GAAA,GAAA,EAAA,EAAA,EAAA,CAAA,MAAC,GAAS,GAAA,GAAc,GACxB,EAAa,EAAyB,KAAC,IACvC,EAAQ,EAAW,MACnB,KAAC,OAAa,GAAA,GAAO,KAAC,GAAI,EAAW,QACrC,KAAC,UAAgB,GAAA,GAAU,KAAC,OAAQ,KAAC,GAAI,EAAW,mBAAoB,MAExE,EAAY,KAAC,GAAG,aAAiB,GAAA,GAAM,WAAW,QAAS,IAAK,UAAW,cAAgB,OAAW,SACtG,EAAY,KAAC,GAAG,aAAiB,GAAA,GAAM,WAAW,QAAS,IAAK,UAAW,QAAgB,EAAW,SACtG,EAAU,QAAU,EACpB,EAAU,UACV,EAAI,UACJ,EAAiB,GAAA,GAAW,MAAM,MAAM,QAAS,IAAK,UAAW,KAAM,EAAW,GAClF,KAAC,GAAG,aAAa,GAAY,UAC7B,KAAC,aAAe,QAdlB,GAAA,UAmBA,eAAgB,iBACd,MAAC,cApBH,EAAA,UAyBA,UAAW,iBACT,MAAC,QA1BH,EAAA,UA+BA,aAAc,iBACZ,MAAC,WAhCH,EAAA,UAqCA,iBAAkB,iBAChB,MAAC,IAtCH,EAAA,UA6CA,UAAW,iBACT,MAAC,GAAG,aA9CN,EAAA,UAmDA,IAAK,iBACH,MAAC,aAAa,OApDhB,EAAA,UAyDA,WAAY,SAAC,EAAK,SAChB,MAAC,aAAa,WAAW,EAAK,IA1DhC,EAAA,UA+DA,WAAY,SAAC,EAAK,SAChB,MAAC,aAAa,WAAW,EAAK,IAhEhC,EAAA,UAqEA,KAAM,SAAC,SACL,MAAC,aAAa,KAAK,IAtErB,EAAA,UA2EA,YAAa,SAAC,SACZ,MAAC,aAAa,YAAY,SAG9B,OAAO,QAAU,EACd,mBAAA,SAAA,OAAA,SACM,MAAA,OAAA,IACL,OAAO,MACT,OAAO,EAAE,UAAY","sourcesContent":["\ntext_types_uninitialized = require \"../Types/TextTypes\"\nHistoryBuffer = require \"../HistoryBuffer\"\nEngine = require \"../Engine\"\n\n#\n# Framework for Text Datastructures.\n#\nclass TextYatta\n\n #\n # @param {String} user_id Uniqe user id that defines this peer.\n # @param {Connector} Connector The connector defines how you connect to the other peers.\n #\n constructor: (user_id, Connector)->\n @HB = new HistoryBuffer user_id\n text_types = text_types_uninitialized @HB\n types = text_types.types\n @engine = new Engine @HB, text_types.parser\n @connector = new Connector @engine, @HB, text_types.execution_listener, @\n\n beginning = @HB.addOperation new types.Delimiter {creator: '_', op_number: '_beginning'} , undefined, undefined\n end = @HB.addOperation new types.Delimiter {creator: '_', op_number: '_end'} , beginning, undefined\n beginning.next_cl = end\n beginning.execute()\n end.execute()\n first_word = new text_types.types.Word {creator: '_', op_number: '_'}, beginning, end\n @HB.addOperation(first_word).execute()\n @root_element = first_word\n\n #\n # @result Word\n #\n getRootElement: ()->\n @root_element\n\n #\n # @see Engine\n #\n getEngine: ()->\n @engine\n\n #\n # Get the initialized connector.\n #\n getConnector: ()->\n @connector\n\n #\n # @see HistoryBuffer\n #\n getHistoryBuffer: ()->\n @HB\n\n #\n # Get the UserId from the HistoryBuffer object.\n # In most cases this will be the same as the user_id value with which\n # JsonYatta was initialized (Depending on the HistoryBuffer implementation).\n #\n getUserId: ()->\n @HB.getUserId()\n\n #\n # @see JsonType.val\n #\n val: ()->\n @root_element.val()\n\n #\n # @see Word.insertText\n #\n insertText: (pos, content)->\n @root_element.insertText pos, content\n\n #\n # @see Word.deleteText\n #\n deleteText: (pos, length)->\n @root_element.deleteText pos, length\n\n #\n # @see Word.bind\n #\n bind: (textarea)->\n @root_element.bind textarea\n\n #\n # @see Word.replaceText\n #\n replaceText: (text)->\n @root_element.replaceText text\n\n\nmodule.exports = TextYatta\nif window?\n if not window.Y?\n window.Y = {}\n window.Y.TextYatta = TextYatta\n"],"sourceRoot":"/source/"}
|
2
build/node/HistoryBuffer.js
Normal file
2
build/node/HistoryBuffer.js
Normal file
@ -0,0 +1,2 @@
|
||||
(function(){var r;r=function(){function r(r){this.user_id=r,this.operation_counter={},this.buffer={},this.change_listeners=[]}return r.prototype.getUserId=function(){return this.user_id},r.prototype.getReservedUniqueIdentifier=function(){return{creator:"_",op_number:"_"}},r.prototype.getOperationCounter=function(){var r,t,e,o;t={},o=this.operation_counter;for(e in o)r=o[e],t[e]=r;return t},r.prototype._encode=function(r){var t,e,o,n,i,u,c,p,f,l;null==r&&(r={}),t=[],p=function(t,e){if(null==t||null==e)throw new Error("dah!");return null==r[t]||r[t]<=e},l=this.buffer;for(c in l){f=l[c];for(i in f)if(e=f[i],!isNaN(parseInt(i))&&p(c,i)){if(o=e._encode(),null!=e.next_cl){for(n=e.next_cl;null!=n.next_cl&&p(n.creator,n.op_number);)n=n.next_cl;o.next=n.getUid()}else if(null!=e.prev_cl){for(u=e.prev_cl;null!=u.prev_cl&&p(n.creator,n.op_number);)u=u.prev_cl;o.prev=u.getUid()}t.push(o)}}return t},r.prototype.getNextOperationIdentifier=function(r){var t;return null==r&&(r=this.user_id),null==this.operation_counter[r]&&(this.operation_counter[r]=0),t={creator:r,op_number:this.operation_counter[r]},this.operation_counter[r]++,t},r.prototype.getOperation=function(r){var t;if(r instanceof Object)return null!=(t=this.buffer[r.creator])?t[r.op_number]:void 0;if(null!=r)throw new Error("This type of uid is not defined!")},r.prototype.addOperation=function(r){if(null==this.buffer[r.creator]&&(this.buffer[r.creator]={}),null!=this.buffer[r.creator][r.op_number])throw new Error("You must not overwrite operations!");return this.buffer[r.creator][r.op_number]=r,r},r.prototype.addToCounter=function(r){return null==this.operation_counter[r.creator]&&(this.operation_counter[r.creator]=0),"number"==typeof r.op_number&&r.creator!==this.getUserId()?this.operation_counter[r.creator]++:void 0},r}(),module.exports=r}).call(this);
|
||||
//# sourceMappingURL=HistoryBuffer.js.map
|
1
build/node/HistoryBuffer.js.map
Executable file
1
build/node/HistoryBuffer.js.map
Executable file
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
(function(){var e,t={}.hasOwnProperty,n=function(e,n){function r(){this.constructor=e}for(var i in n)t.call(n,i)&&(e[i]=n[i]);return r.prototype=n.prototype,e.prototype=new r,e.__super__=n.prototype,e};e=require("./StructuredTypes"),module.exports=function(t){var r,i,o,l,s,a;return s=e(t),a=s.types,l=s.parser,r=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return n(t,e),t}(a.Delete),l.TextDelete=l.Delete,i=function(e){function t(e,n,r,i,o){if(this.content=e,null==r||null==i)throw new Error("You must define prev, and next for TextInsert-types!");t.__super__.constructor.call(this,n,r,i,o)}return n(t,e),t.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},t.prototype.val=function(){return this.isDeleted()?"":this.content},t.prototype._encode=function(){var e;return e={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},t}(a.Insert),l.TextInsert=function(e){var t,n,r,o,l;return t=e.content,l=e.uid,o=e.prev,n=e.next,r=e.origin,new i(t,l,o,n,r)},o=function(e){function o(e,t,n,r,i,l){o.__super__.constructor.call(this,e,t,n,r,i,l)}return n(o,e),o.prototype.insertText=function(e,n){var r,o,l,s,a,u;for(o=this.getOperationByPosition(e),u=[],s=0,a=n.length;a>s;s++)r=n[s],l=new i(r,void 0,o.prev_cl,o),u.push(t.addOperation(l).execute());return u},o.prototype.deleteText=function(e,n){var i,o,l,s,u,c;for(s=this.getOperationByPosition(e),o=[],c=[],l=u=0;n>=0?n>u:u>n;l=n>=0?++u:--u){for(i=t.addOperation(new r(void 0,s)).execute(),s=s.next_cl;s.isDeleted()&&!(s instanceof a.Delimiter);){if(s instanceof a.Delimiter)throw new Error("You can't delete more than there is..");s=s.next_cl}if(o.push(i._encode()),s instanceof a.Delimiter)break;c.push(void 0)}return c},o.prototype.replaceText=function(e){var n;if(null!=this.replace_manager)return n=t.addOperation(new o(void 0)).execute(),n.insertText(0,e),this.replace_manager.replace(n);throw new Error("This type is currently not maintained by a ReplaceManager!")},o.prototype.val=function(){var e,t;return e=function(){var e,n,r,i;for(r=this.toArray(),i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(null!=t.val?t.val():"");return i}.call(this),e.join("")},o.prototype.setReplaceManager=function(e){return this.saveOperation("replace_manager",e),this.validateSavedOperations},o.prototype.bind=function(e){var n;return n=this,e.value=this.val(),this.on("insert",function(r,i){var o,l,s,a;return i.creator!==t.getUserId()?(s=i.getPosition(),o=function(e){return s>=e?e:e+=1},l=o(e.selectionStart),a=o(e.selectionEnd),e.value=n.val(),e.setSelectionRange(l,a)):void 0}),this.on("delete",function(t,r){var i,o,l,s;return l=r.getPosition(),i=function(e){return l>e?e:e-=1},o=i(e.selectionStart),s=i(e.selectionEnd),e.value=n.val(),e.setSelectionRange(o,s)}),e.onkeypress=function(t){var r,i,o;return r=String.fromCharCode(t.keyCode),r.length>0?(console.log(r.length),o=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),n.deleteText(o,i),n.insertText(o,r)):t.preventDefault()},e.onkeydown=function(t){var r,i,o,l,s;if(l=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),null!=t.keyCode&&8===t.keyCode){if(i>0)n.deleteText(l,i);else if(null!=t.ctrlKey&&t.ctrlKey){for(s=e.value,o=l,r=0,l>0&&(o--,r++);o>0&&" "!==s[o]&&"\n"!==s[o];)o--,r++;n.deleteText(o,l-o),e.setSelectionRange(o,o)}else n.deleteText(l-1,1);return t.preventDefault()}return null!=t.keyCode&&46===t.keyCode?(i>0?n.deleteText(l,i):n.deleteText(l,1),t.preventDefault()):void 0}},o.prototype._encode=function(){var e;return e={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(e.prev=this.prev_cl.getUid()),null!=this.next_cl&&(e.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},o}(a.ListManager),l.Word=function(e){var t,n,r,i,l,s;return s=e.uid,t=e.beginning,n=e.end,l=e.prev,r=e.next,i=e.origin,new o(s,t,n,l,r,i)},a.TextInsert=i,a.TextDelete=r,a.Word=o,s}}).call(this);
|
||||
(function(){var e,t={}.hasOwnProperty,n=function(e,n){function r(){this.constructor=e}for(var i in n)t.call(n,i)&&(e[i]=n[i]);return r.prototype=n.prototype,e.prototype=new r,e.__super__=n.prototype,e};e=require("./StructuredTypes"),module.exports=function(t){var r,i,o,l,s,a;return s=e(t),a=s.types,l=s.parser,r=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return n(t,e),t}(a.Delete),l.TextDelete=l.Delete,i=function(e){function t(e,n,r,i,o){if(this.content=e,null==r||null==i)throw new Error("You must define prev, and next for TextInsert-types!");t.__super__.constructor.call(this,n,r,i,o)}return n(t,e),t.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},t.prototype.val=function(){return this.isDeleted()?"":this.content},t.prototype._encode=function(){var e;return e={type:"TextInsert",content:this.content,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid()},null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},t}(a.Insert),l.TextInsert=function(e){var t,n,r,o,l;return t=e.content,l=e.uid,o=e.prev,n=e.next,r=e.origin,new i(t,l,o,n,r)},o=function(e){function o(e,t,n,r,i,l){o.__super__.constructor.call(this,e,t,n,r,i,l)}return n(o,e),o.prototype.insertText=function(e,n){var r,o,l,s,a,u;for(o=this.getOperationByPosition(e),u=[],s=0,a=n.length;a>s;s++)r=n[s],l=new i(r,void 0,o.prev_cl,o),u.push(t.addOperation(l).execute());return u},o.prototype.deleteText=function(e,n){var i,o,l,s,u,c;for(s=this.getOperationByPosition(e),o=[],c=[],l=u=0;n>=0?n>u:u>n;l=n>=0?++u:--u){for(i=t.addOperation(new r(void 0,s)).execute(),s=s.next_cl;s.isDeleted()&&!(s instanceof a.Delimiter);){if(s instanceof a.Delimiter)throw new Error("You can't delete more than there is..");s=s.next_cl}if(o.push(i._encode()),s instanceof a.Delimiter)break;c.push(void 0)}return c},o.prototype.replaceText=function(e){var n;if(null!=this.replace_manager)return n=t.addOperation(new o(void 0)).execute(),n.insertText(0,e),this.replace_manager.replace(n);throw new Error("This type is currently not maintained by a ReplaceManager!")},o.prototype.val=function(){var e,t;return e=function(){var e,n,r,i;for(r=this.toArray(),i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(null!=t.val?t.val():"");return i}.call(this),e.join("")},o.prototype.setReplaceManager=function(e){return this.saveOperation("replace_manager",e),this.validateSavedOperations},o.prototype.bind=function(e){var n;return n=this,e.value=this.val(),this.on("insert",function(r,i){var o,l,s,a;return i.creator!==t.getUserId()?(s=i.getPosition(),o=function(e){return s>=e?e:e+=1},l=o(e.selectionStart),a=o(e.selectionEnd),e.value=n.val(),e.setSelectionRange(l,a)):void 0}),this.on("delete",function(t,r){var i,o,l,s;return l=r.getPosition(),i=function(e){return l>e?e:e-=1},o=i(e.selectionStart),s=i(e.selectionEnd),e.value=n.val(),e.setSelectionRange(o,s)}),e.onkeypress=function(t){var r,i,o;return r=String.fromCharCode(t.keyCode),r.length>0?(o=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),n.deleteText(o,i),n.insertText(o,r)):t.preventDefault()},e.onkeydown=function(t){var r,i,o,l,s;if(l=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),null!=t.keyCode&&8===t.keyCode){if(i>0)n.deleteText(l,i);else if(null!=t.ctrlKey&&t.ctrlKey){for(s=e.value,o=l,r=0,l>0&&(o--,r++);o>0&&" "!==s[o]&&"\n"!==s[o];)o--,r++;n.deleteText(o,l-o),e.setSelectionRange(o,o)}else n.deleteText(l-1,1);return t.preventDefault()}return null!=t.keyCode&&46===t.keyCode?(i>0?n.deleteText(l,i):n.deleteText(l,1),t.preventDefault()):void 0}},o.prototype._encode=function(){var e;return e={type:"Word",uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()},null!=this.prev_cl&&(e.prev=this.prev_cl.getUid()),null!=this.next_cl&&(e.next=this.next_cl.getUid()),null!=this.origin&&this.origin!==this.prev_cl&&(e.origin=this.origin.getUid()),e},o}(a.ListManager),l.Word=function(e){var t,n,r,i,l,s;return s=e.uid,t=e.beginning,n=e.end,l=e.prev,r=e.next,i=e.origin,new o(s,t,n,l,r,i)},a.TextInsert=i,a.TextDelete=r,a.Word=o,s}}).call(this);
|
||||
//# sourceMappingURL=../Types/TextTypes.js.map
|
File diff suppressed because one or more lines are too long
2
build/node/index.js
Normal file
2
build/node/index.js
Normal file
@ -0,0 +1,2 @@
|
||||
(function(){exports.IwcConnector=require("./Connectors/IwcConnector"),exports.TestConnector=require("./Connectors/TestConnector"),exports.JsonYatta=require("./Frameworks/JsonYatta"),exports.TextYatta=require("./Frameworks/TextYatta")}).call(this);
|
||||
//# sourceMappingURL=index.js.map
|
1
build/node/index.js.map
Executable file
1
build/node/index.js.map
Executable file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":["index.coffee"],"names":[],"mappings":"CACA,WAAA,QAAQ,aACN,QAAQ,6BACV,QAAQ,cACN,QAAQ,8BACV,QAAQ,UACN,QAAQ,0BACV,QAAQ,UACN,QAAQ","sourcesContent":["\nexports['IwcConnector'] =\n require './Connectors/IwcConnector'\nexports['TestConnector'] =\n require './Connectors/TestConnector'\nexports['JsonYatta'] =\n require './Frameworks/JsonYatta'\nexports['TextYatta'] =\n require './Frameworks/TextYatta'\n\n"],"sourceRoot":"/source/"}
|
13882
build/test/Yatta_test.js
Normal file
13882
build/test/Yatta_test.js
Normal file
File diff suppressed because one or more lines are too long
@ -1,5 +1,6 @@
|
||||
## Text Editing Example
|
||||
Here, I will give a short overview on how to enable collaborative text editing with the PeerJs Connector and the TextYatta Framework.
|
||||
Here, I will give a short overview on how to enable collaborative text editing with the
|
||||
[PeerJs](http://peerjs.com/) Connector and the TextYatta Framework.
|
||||
First you have to include the following libraries in your html file:
|
||||
```
|
||||
<script src="http://cdn.peerjs.com/0.3/peer.js"></script>
|
||||
|
@ -1,7 +1,8 @@
|
||||
|
||||
/**
|
||||
## Text Editing Example
|
||||
Here, I will give a short overview on how to enable collaborative text editing with the PeerJs Connector and the TextYatta Framework.
|
||||
Here, I will give a short overview on how to enable collaborative text editing with the
|
||||
[PeerJs](http://peerjs.com/) Connector and the TextYatta Framework.
|
||||
First you have to include the following libraries in your html file:
|
||||
```
|
||||
<script src="http://cdn.peerjs.com/0.3/peer.js"></script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user