Deploy 0.8.1
This commit is contained in:
15
Examples/bower_components/y-array/.bower.json
vendored
15
Examples/bower_components/y-array/.bower.json
vendored
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "y-array",
|
||||
"homepage": "https://github.com/y-js/y-array",
|
||||
"version": "0.7.5",
|
||||
"_release": "0.7.5",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v0.7.5",
|
||||
"commit": "616d21127c3aece7c1c3619b9f7ffe2f20f03f23"
|
||||
},
|
||||
"_source": "git://github.com/y-js/y-array.git",
|
||||
"_target": "~0.7.5",
|
||||
"_originalSource": "y-array",
|
||||
"_direct": true
|
||||
}
|
||||
3
Examples/bower_components/y-array/.bowerrc
vendored
3
Examples/bower_components/y-array/.bowerrc
vendored
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"directory": "../"
|
||||
}
|
||||
6
Examples/bower_components/y-array/.gitignore
vendored
6
Examples/bower_components/y-array/.gitignore
vendored
@@ -1,6 +0,0 @@
|
||||
/node_modules/
|
||||
bower_components
|
||||
.directory
|
||||
.c9
|
||||
.codio
|
||||
.settings
|
||||
11
Examples/bower_components/y-array/.travis.yml
vendored
11
Examples/bower_components/y-array/.travis.yml
vendored
@@ -1,11 +0,0 @@
|
||||
language: node_js
|
||||
before_install:
|
||||
- "npm install -g bower coffee-script"
|
||||
- "bower install"
|
||||
node_js:
|
||||
- "0.12"
|
||||
- "0.11"
|
||||
- "0.10"
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
92
Examples/bower_components/y-array/README.md
vendored
92
Examples/bower_components/y-array/README.md
vendored
@@ -1,92 +0,0 @@
|
||||
|
||||
# List Type for [Yjs](https://github.com/y-js/yjs)
|
||||
|
||||
Manage list-like data with this shareable list type. You can insert and delete arbitrary objects (also custom types for Yjs) in the list type.
|
||||
|
||||
## Use it!
|
||||
Retrieve this with bower or npm.
|
||||
|
||||
##### Bower
|
||||
```
|
||||
bower install y-list --save
|
||||
```
|
||||
|
||||
and include the js library.
|
||||
|
||||
```
|
||||
<script src="./bower_components/y-list/y-list.js"></script>
|
||||
```
|
||||
|
||||
##### NPM
|
||||
```
|
||||
npm install y-list --save
|
||||
```
|
||||
and put it on the `Y` object.
|
||||
|
||||
```
|
||||
Y.List = require("y-list");
|
||||
```
|
||||
|
||||
|
||||
### List Object
|
||||
|
||||
##### Reference
|
||||
* Create
|
||||
```
|
||||
var ylist = new Y.List()
|
||||
```
|
||||
* .insert(position, content)
|
||||
* Insert content at a position
|
||||
* .insertContents(position, contents)
|
||||
* Insert a set of content at a position. This expects that contents is an array of content.
|
||||
* .push(content)
|
||||
* Insert content at the end of the list
|
||||
* .delete(position, length)
|
||||
* Delete content. The *length* parameter is optional and defaults to 1
|
||||
* .val()
|
||||
* Retrieve all content as an Array Object
|
||||
* .val(position)
|
||||
* Retrieve content from a position
|
||||
* .ref(position)
|
||||
* Retrieve a reference to the element on a *position*.
|
||||
* You can call `ref.getNext()` and `ref.getPrev()` to get the next/previous reference
|
||||
* You can call `ref.getNext(i)` and `ref.getPrev(i)` to get the i-th next/previous reference
|
||||
* You can call `ref.val()` to get the element, to which the reference points (`y.ref(1).val() === y.val(1)`)
|
||||
* .observe(f)
|
||||
* The observer is called whenever something on this list changed. (throws insert, and delete events)
|
||||
* .unobserve(f)
|
||||
* Delete an observer
|
||||
|
||||
|
||||
# A note on intention preservation
|
||||
If two users insert something at the same position concurrently, the content that was inserted by the user with the higher user-id will be to the right of the other content. In the OT world we often speak of *intention preservation*, which is very loosely defined in most cases. This type has the following notion of intention preservation: When a user inserts content *c* after a set of content *C_left*, and before a set of content *C_right*, then *C_left* will be always to the left of c, and *C_right* will be always to the right of *c*. This property will also hold when content is deleted or when a deletion is undone.
|
||||
|
||||
# A note on time complexities
|
||||
* .insert(position, content)
|
||||
* O(position)
|
||||
* .insertContents(position, contents)
|
||||
* O(position + |contents|)
|
||||
* .push(content)
|
||||
* O(1)
|
||||
* .delete(position, length)
|
||||
* O(position)
|
||||
* .val()
|
||||
* O(|ylist|)
|
||||
* .val(position)
|
||||
* O(position|)
|
||||
* Apply a delete operation from another user
|
||||
* O(1)
|
||||
* Apply an insert operation from another user
|
||||
* Yjs does not transform against operations that do not conflict with each other.
|
||||
* An operation conflicts with another operation if it intends to be inserted at the same position.
|
||||
* Overall worst case complexety: O(|conflicts|!)
|
||||
|
||||
|
||||
# Issues
|
||||
* Support moving of objects
|
||||
* Create a polymer element
|
||||
|
||||
## License
|
||||
Yjs is licensed under the [MIT License](./LICENSE.txt).
|
||||
|
||||
<kevin.jahns@rwth-aachen.de>
|
||||
197
Examples/bower_components/y-array/y-array.es6
vendored
197
Examples/bower_components/y-array/y-array.es6
vendored
@@ -1,197 +0,0 @@
|
||||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
/* global Y */
|
||||
'use strict'
|
||||
|
||||
function extend (Y) {
|
||||
class YArray {
|
||||
constructor (os, _model, idArray, valArray) {
|
||||
this.os = os
|
||||
this._model = _model
|
||||
// Array of all the operation id's
|
||||
this.idArray = idArray
|
||||
// Array of all the values
|
||||
this.valArray = valArray
|
||||
this.eventHandler = new Y.utils.EventHandler(ops => {
|
||||
var userEvents = []
|
||||
for (var i in ops) {
|
||||
var op = ops[i]
|
||||
if (op.struct === 'Insert') {
|
||||
let pos
|
||||
// we check op.left only!,
|
||||
// because op.right might not be defined when this is called
|
||||
if (op.left === null) {
|
||||
pos = 0
|
||||
} else {
|
||||
var sid = JSON.stringify(op.left)
|
||||
pos = this.idArray.indexOf(sid) + 1
|
||||
if (pos <= 0) {
|
||||
throw new Error('Unexpected operation!')
|
||||
}
|
||||
}
|
||||
this.idArray.splice(pos, 0, JSON.stringify(op.id))
|
||||
this.valArray.splice(pos, 0, op.content)
|
||||
userEvents.push({
|
||||
type: 'insert',
|
||||
object: this,
|
||||
index: pos,
|
||||
value: op.content,
|
||||
length: 1
|
||||
})
|
||||
} else if (op.struct === 'Delete') {
|
||||
let pos = this.idArray.indexOf(JSON.stringify(op.target))
|
||||
if (pos >= 0) {
|
||||
var val = this.valArray[pos]
|
||||
this.idArray.splice(pos, 1)
|
||||
this.valArray.splice(pos, 1)
|
||||
userEvents.push({
|
||||
type: 'delete',
|
||||
object: this,
|
||||
index: pos,
|
||||
value: val,
|
||||
length: 1
|
||||
})
|
||||
}
|
||||
} else {
|
||||
throw new Error('Unexpected struct!')
|
||||
}
|
||||
}
|
||||
this.eventHandler.callEventListeners(userEvents)
|
||||
})
|
||||
}
|
||||
get length () {
|
||||
return this.idArray.length
|
||||
}
|
||||
get (pos) {
|
||||
if (pos == null || typeof pos !== 'number') {
|
||||
throw new Error('pos must be a number!')
|
||||
}
|
||||
return this.valArray[pos]
|
||||
}
|
||||
toArray () {
|
||||
return this.valArray.slice()
|
||||
}
|
||||
push (contents) {
|
||||
this.insert(this.idArray.length, contents)
|
||||
}
|
||||
insert (pos, contents) {
|
||||
if (typeof pos !== 'number') {
|
||||
throw new Error('pos must be a number!')
|
||||
}
|
||||
if (!(contents instanceof Array)) {
|
||||
throw new Error('contents must be an Array of objects!')
|
||||
}
|
||||
if (contents.length === 0) {
|
||||
return
|
||||
}
|
||||
if (pos > this.idArray.length || pos < 0) {
|
||||
throw new Error('This position exceeds the range of the array!')
|
||||
}
|
||||
var mostLeft = pos === 0 ? null : JSON.parse(this.idArray[pos - 1])
|
||||
|
||||
var ops = []
|
||||
var prevId = mostLeft
|
||||
for (var i = 0; i < contents.length; i++) {
|
||||
var op = {
|
||||
left: prevId,
|
||||
origin: prevId,
|
||||
// right: mostRight,
|
||||
// NOTE: I intentionally do not define right here, because it could be deleted
|
||||
// at the time of creating this operation, and is therefore not defined in idArray
|
||||
parent: this._model,
|
||||
content: contents[i],
|
||||
struct: 'Insert',
|
||||
id: this.os.getNextOpId()
|
||||
}
|
||||
ops.push(op)
|
||||
prevId = op.id
|
||||
}
|
||||
var eventHandler = this.eventHandler
|
||||
eventHandler.awaitAndPrematurelyCall(ops)
|
||||
this.os.requestTransaction(function *() {
|
||||
// now we can set the right reference.
|
||||
var mostRight
|
||||
if (mostLeft != null) {
|
||||
mostRight = (yield* this.getOperation(mostLeft)).right
|
||||
} else {
|
||||
mostRight = (yield* this.getOperation(ops[0].parent)).start
|
||||
}
|
||||
for (var j in ops) {
|
||||
ops[j].right = mostRight
|
||||
}
|
||||
yield* this.applyCreatedOperations(ops)
|
||||
eventHandler.awaitedInserts(ops.length)
|
||||
})
|
||||
}
|
||||
delete (pos, length) {
|
||||
if (length == null) { length = 1 }
|
||||
if (typeof length !== 'number') {
|
||||
throw new Error('pos must be a number!')
|
||||
}
|
||||
if (typeof pos !== 'number') {
|
||||
throw new Error('pos must be a number!')
|
||||
}
|
||||
if (pos + length > this.idArray.length || pos < 0 || length < 0) {
|
||||
throw new Error('The deletion range exceeds the range of the array!')
|
||||
}
|
||||
if (length === 0) {
|
||||
return
|
||||
}
|
||||
var eventHandler = this.eventHandler
|
||||
var newLeft = pos > 0 ? JSON.parse(this.idArray[pos - 1]) : null
|
||||
var dels = []
|
||||
for (var i = 0; i < length; i++) {
|
||||
dels.push({
|
||||
target: JSON.parse(this.idArray[pos + i]),
|
||||
struct: 'Delete'
|
||||
})
|
||||
}
|
||||
eventHandler.awaitAndPrematurelyCall(dels)
|
||||
this.os.requestTransaction(function *() {
|
||||
yield* this.applyCreatedOperations(dels)
|
||||
eventHandler.awaitedDeletes(dels.length, newLeft)
|
||||
})
|
||||
}
|
||||
observe (f) {
|
||||
this.eventHandler.addEventListener(f)
|
||||
}
|
||||
* _changed (transaction, op) {
|
||||
if (!op.deleted) {
|
||||
if (op.struct === 'Insert') {
|
||||
var l = op.left
|
||||
var left
|
||||
while (l != null) {
|
||||
left = yield* transaction.getOperation(l)
|
||||
if (!left.deleted) {
|
||||
break
|
||||
}
|
||||
l = left.left
|
||||
}
|
||||
op.left = l
|
||||
}
|
||||
this.eventHandler.receivedOp(op)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Y.extend('Array', new Y.utils.CustomType({
|
||||
name: 'Array', // TODO: copy the name when extending the object.. (see one line above)
|
||||
class: YArray,
|
||||
struct: 'List',
|
||||
initType: function * YArrayInitializer (os, model) {
|
||||
var valArray = []
|
||||
var idArray = yield* Y.Struct.List.map.call(this, model, function (c) {
|
||||
valArray.push(c.content)
|
||||
return JSON.stringify(c.id)
|
||||
})
|
||||
return new YArray(os, model.id, idArray, valArray)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
module.exports = extend
|
||||
if (typeof Y !== 'undefined') {
|
||||
extend(Y)
|
||||
}
|
||||
|
||||
},{}]},{},[1])
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
Examples/bower_components/y-array/y-array.js
vendored
2
Examples/bower_components/y-array/y-array.js
vendored
@@ -1,2 +0,0 @@
|
||||
!function e(r,t,n){function a(s,o){if(!t[s]){if(!r[s]){var u="function"==typeof require&&require;if(!o&&u)return u(s,!0);if(i)return i(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=t[s]={exports:{}};r[s][0].call(c.exports,function(e){var t=r[s][1][e];return a(t?t:e)},c,c.exports,e,r,t,n)}return t[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)a(n[s]);return a}({1:[function(e,r,t){"use strict";function n(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function a(e){var r=function(){function r(t,a,i,s){var o=this;n(this,r),this.os=t,this._model=a,this.idArray=i,this.valArray=s,this.eventHandler=new e.utils.EventHandler(function(e){var r=[];for(var t in e){var n=e[t];if("Insert"===n.struct){var a=void 0;if(null===n.left)a=0;else{var i=JSON.stringify(n.left);if(a=o.idArray.indexOf(i)+1,0>=a)throw new Error("Unexpected operation!")}o.idArray.splice(a,0,JSON.stringify(n.id)),o.valArray.splice(a,0,n.content),r.push({type:"insert",object:o,index:a,value:n.content,length:1})}else{if("Delete"!==n.struct)throw new Error("Unexpected struct!");var a=o.idArray.indexOf(JSON.stringify(n.target));if(a>=0){var s=o.valArray[a];o.idArray.splice(a,1),o.valArray.splice(a,1),r.push({type:"delete",object:o,index:a,value:s,length:1})}}}o.eventHandler.callEventListeners(r)})}return i(r,[{key:"get",value:function(e){if(null==e||"number"!=typeof e)throw new Error("pos must be a number!");return this.valArray[e]}},{key:"toArray",value:function(){return this.valArray.slice()}},{key:"push",value:function(e){this.insert(this.idArray.length,e)}},{key:"insert",value:function(e,r){if("number"!=typeof e)throw new Error("pos must be a number!");if(!(r instanceof Array))throw new Error("contents must be an Array of objects!");if(0!==r.length){if(e>this.idArray.length||0>e)throw new Error("This position exceeds the range of the array!");for(var t=0===e?null:JSON.parse(this.idArray[e-1]),n=[],a=t,i=0;i<r.length;i++){var s={left:a,origin:a,parent:this._model,content:r[i],struct:"Insert",id:this.os.getNextOpId()};n.push(s),a=s.id}var o=this.eventHandler;o.awaitAndPrematurelyCall(n),this.os.requestTransaction(regeneratorRuntime.mark(function u(){var e,r;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(null==t){a.next=5;break}return a.delegateYield(this.getOperation(t),"t0",2);case 2:e=a.t0.right,a.next=7;break;case 5:return a.delegateYield(this.getOperation(n[0].parent),"t1",6);case 6:e=a.t1.start;case 7:for(r in n)n[r].right=e;return a.delegateYield(this.applyCreatedOperations(n),"t2",9);case 9:o.awaitedInserts(n.length);case 10:case"end":return a.stop()}},u,this)}))}}},{key:"delete",value:function(e,r){if(null==r&&(r=1),"number"!=typeof r)throw new Error("pos must be a number!");if("number"!=typeof e)throw new Error("pos must be a number!");if(e+r>this.idArray.length||0>e||0>r)throw new Error("The deletion range exceeds the range of the array!");if(0!==r){for(var t=this.eventHandler,n=e>0?JSON.parse(this.idArray[e-1]):null,a=[],i=0;r>i;i++)a.push({target:JSON.parse(this.idArray[e+i]),struct:"Delete"});t.awaitAndPrematurelyCall(a),this.os.requestTransaction(regeneratorRuntime.mark(function s(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(this.applyCreatedOperations(a),"t0",1);case 1:t.awaitedDeletes(a.length,n);case 2:case"end":return e.stop()}},s,this)}))}}},{key:"observe",value:function(e){this.eventHandler.addEventListener(e)}},{key:"_changed",value:regeneratorRuntime.mark(function t(e,r){var n,a;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r.deleted){t.next=13;break}if("Insert"!==r.struct){t.next=12;break}n=r.left;case 3:if(null==n){t.next=11;break}return t.delegateYield(e.getOperation(n),"t0",5);case 5:if(a=t.t0,a.deleted){t.next=8;break}return t.abrupt("break",11);case 8:n=a.left,t.next=3;break;case 11:r.left=n;case 12:this.eventHandler.receivedOp(r);case 13:case"end":return t.stop()}},t,this)})},{key:"length",get:function(){return this.idArray.length}}]),r}();e.extend("Array",new e.utils.CustomType({name:"Array","class":r,struct:"List",initType:regeneratorRuntime.mark(function t(n,a){var i,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return i=[],t.delegateYield(e.Struct.List.map.call(this,a,function(e){return i.push(e.content),JSON.stringify(e.id)}),"t0",2);case 2:return s=t.t0,t.abrupt("return",new r(n,a.id,s,i));case 4:case"end":return t.stop()}},t,this)})}))}var i=function(){function e(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),r}}();r.exports=a,"undefined"!=typeof Y&&a(Y)},{}]},{},[1]);
|
||||
//# sourceMappingURL=y-array.js.map
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user