Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f739f3b5d7 | ||
|
|
f2052f95f8 | ||
|
|
81324dc7d4 | ||
|
|
6599cb20b4 | ||
|
|
74ed9e4107 | ||
|
|
ef6d63c19a | ||
|
|
941dd36e74 |
@@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<textarea style="width:80%;" rows=40 id="textfield" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
<textarea style="width:80%;" rows=40 id="textfield" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||||
<script src="../bower_components/yjs/y.js"></script>
|
<script src="../bower_components/yjs/y.es6"></script>
|
||||||
<script src="./index.js"></script>
|
<script src="./index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ Y({
|
|||||||
},
|
},
|
||||||
connector: {
|
connector: {
|
||||||
name: 'websockets-client',
|
name: 'websockets-client',
|
||||||
room: 'Textarea-example'
|
room: 'Textarea-example',
|
||||||
|
url: '127.0.0.1:1234'
|
||||||
},
|
},
|
||||||
sourceDir: '/bower_components',
|
sourceDir: '/bower_components',
|
||||||
share: {
|
share: {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ We already provide abstract data types for
|
|||||||
|[map](https://github.com/y-js/y-map) | A shared Map implementation. Maps from text to any stringify-able object |
|
|[map](https://github.com/y-js/y-map) | A shared Map implementation. Maps from text to any stringify-able object |
|
||||||
|[array](https://github.com/y-js/y-array) | A shared Array implementation |
|
|[array](https://github.com/y-js/y-array) | A shared Array implementation |
|
||||||
|[xml](https://github.com/y-js/y-xml) | An implementation of the DOM. You can create a two way binding to Browser DOM objects |
|
|[xml](https://github.com/y-js/y-xml) | An implementation of the DOM. You can create a two way binding to Browser DOM objects |
|
||||||
|[text](https://github.com/y-js/y-text) | Collaborate on text. Supports two way binding to textareas, input elements, or HTML elements (e.g. *<h1/>*, or *<p/>*). Also supports the [Ace Editor](https://ace.c9.io) |
|
|[text](https://github.com/y-js/y-text) | Collaborate on text. Supports two way binding to textareas, input elements, or HTML elements (e.g. <*h1*>, or <*p*>). Also supports the [Ace Editor](https://ace.c9.io) |
|
||||||
|[richtext](https://github.com/y-js/y-richtext) | Collaborate on rich text. Supports two way binding to the [Quill Rich Text Editor](http://quilljs.com/)|
|
|[richtext](https://github.com/y-js/y-richtext) | Collaborate on rich text. Supports two way binding to the [Quill Rich Text Editor](http://quilljs.com/)|
|
||||||
|
|
||||||
Yjs supports P2P message propagation, and is not bound to a specific communication protocol. Therefore, Yjs is extremely scalable and can be used in a wide range of application scenarios.
|
Yjs supports P2P message propagation, and is not bound to a specific communication protocol. Therefore, Yjs is extremely scalable and can be used in a wide range of application scenarios.
|
||||||
@@ -49,7 +49,7 @@ Install yjs and its modules with [bower](http://bower.io/), or with [npm](https:
|
|||||||
|
|
||||||
### Bower
|
### Bower
|
||||||
```
|
```
|
||||||
bower install yjs
|
bower install yjs --save
|
||||||
```
|
```
|
||||||
Then you include the libraries directly from the installation folder.
|
Then you include the libraries directly from the installation folder.
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "0.8.16",
|
"version": "0.8.24",
|
||||||
"homepage": "y-js.org",
|
"homepage": "y-js.org",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Kevin Jahns <kevin.jahns@rwth-aachen.de>"
|
"Kevin Jahns <kevin.jahns@rwth-aachen.de>"
|
||||||
|
|||||||
44
y.es6
44
y.es6
@@ -718,9 +718,17 @@ module.exports = function (Y /* :any */) {
|
|||||||
this.gc2 = this.gc2.filter(filter)
|
this.gc2 = this.gc2.filter(filter)
|
||||||
delete op.gc
|
delete op.gc
|
||||||
}
|
}
|
||||||
destroy () {
|
* destroy () {
|
||||||
clearInterval(this.gcInterval)
|
clearInterval(this.gcInterval)
|
||||||
this.gcInterval = null
|
this.gcInterval = null
|
||||||
|
for (var key in this.initializedTypes) {
|
||||||
|
var type = this.initializedTypes[key]
|
||||||
|
if (type._destroy != null) {
|
||||||
|
type._destroy()
|
||||||
|
} else {
|
||||||
|
console.error('The type you included does not provide destroy functionality, it will remain in memory (updating your packages will help).')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setUserId (userId) {
|
setUserId (userId) {
|
||||||
if (!this.userIdPromise.inProgress) {
|
if (!this.userIdPromise.inProgress) {
|
||||||
@@ -756,8 +764,8 @@ module.exports = function (Y /* :any */) {
|
|||||||
* check if was deleted, apply a delete operation after op was applied
|
* check if was deleted, apply a delete operation after op was applied
|
||||||
*/
|
*/
|
||||||
apply (ops) {
|
apply (ops) {
|
||||||
for (var key in ops) {
|
for (var i = 0; i < ops.length; i++) {
|
||||||
var o = ops[key]
|
var o = ops[i]
|
||||||
if (o.id == null || o.id[0] !== this.y.connector.userId) {
|
if (o.id == null || o.id[0] !== this.y.connector.userId) {
|
||||||
var required = Y.Struct[o.struct].requiredOps(o)
|
var required = Y.Struct[o.struct].requiredOps(o)
|
||||||
this.whenOperationsExist(required, o)
|
this.whenOperationsExist(required, o)
|
||||||
@@ -775,8 +783,8 @@ module.exports = function (Y /* :any */) {
|
|||||||
missing: ids.length
|
missing: ids.length
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let key in ids) {
|
for (let i = 0; i < ids.length; i++) {
|
||||||
let id = ids[key]
|
let id = ids[i]
|
||||||
let sid = JSON.stringify(id)
|
let sid = JSON.stringify(id)
|
||||||
let l = this.listenersById[sid]
|
let l = this.listenersById[sid]
|
||||||
if (l == null) {
|
if (l == null) {
|
||||||
@@ -819,8 +827,8 @@ module.exports = function (Y /* :any */) {
|
|||||||
if (op == null) {
|
if (op == null) {
|
||||||
store.listenersById[sid] = l
|
store.listenersById[sid] = l
|
||||||
} else {
|
} else {
|
||||||
for (let key in l) {
|
for (let i = 0; i < l.length; i++) {
|
||||||
let listener = l[key]
|
let listener = l[i]
|
||||||
let o = listener.op
|
let o = listener.op
|
||||||
if (--listener.missing === 0) {
|
if (--listener.missing === 0) {
|
||||||
yield* store.tryExecute.call(this, o)
|
yield* store.tryExecute.call(this, o)
|
||||||
@@ -2252,6 +2260,12 @@ module.exports = function (Y /* : any*/) {
|
|||||||
this.onevent = onevent
|
this.onevent = onevent
|
||||||
this.eventListeners = []
|
this.eventListeners = []
|
||||||
}
|
}
|
||||||
|
destroy () {
|
||||||
|
this.waiting = null
|
||||||
|
this.awaiting = null
|
||||||
|
this.onevent = null
|
||||||
|
this.eventListeners = null
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
Call this when a new operation arrives. It will be executed right away if
|
Call this when a new operation arrives. It will be executed right away if
|
||||||
there are no waiting operations, that you prematurely executed
|
there are no waiting operations, that you prematurely executed
|
||||||
@@ -2697,6 +2711,7 @@ class YConfig {
|
|||||||
db: Y.AbstractDatabase;
|
db: Y.AbstractDatabase;
|
||||||
connector: Y.AbstractConnector;
|
connector: Y.AbstractConnector;
|
||||||
share: {[key: string]: any};
|
share: {[key: string]: any};
|
||||||
|
options: Object;
|
||||||
*/
|
*/
|
||||||
constructor (opts, callback) {
|
constructor (opts, callback) {
|
||||||
this.options = opts
|
this.options = opts
|
||||||
@@ -2734,10 +2749,17 @@ class YConfig {
|
|||||||
return this.connector.reconnect()
|
return this.connector.reconnect()
|
||||||
}
|
}
|
||||||
destroy () {
|
destroy () {
|
||||||
this.disconnect()
|
if (this.connector.destroy != null) {
|
||||||
this.db.destroy()
|
this.connector.destroy()
|
||||||
this.connector = null
|
} else {
|
||||||
this.db = null
|
this.connector.disconnect()
|
||||||
|
}
|
||||||
|
var self = this
|
||||||
|
this.db.requestTransaction(function * () {
|
||||||
|
yield* self.db.destroy()
|
||||||
|
self.connector = null
|
||||||
|
self.db = null
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user