Compare commits

...

16 Commits

Author SHA1 Message Date
Kevin Jahns
51c8d3bdc6 Deploy 9.0.4 2016-02-24 12:00:45 +01:00
Kevin Jahns
0f86b71f78 add readme? 2016-02-24 12:00:02 +01:00
Kevin Jahns
fafda2726f Deploy 9.0.3 2016-02-23 15:50:16 +01:00
Kevin Jahns
116770fbce fix gitignore, fix Examples/bower.json 2016-02-23 15:47:53 +01:00
Kevin Jahns
5286f507c8 Deploy 9.0.2 2016-02-23 15:42:09 +01:00
Kevin Jahns
2f7349b712 fixed bower & added dependencies & cleanup 2016-02-23 15:41:22 +01:00
Kevin Jahns
54529ab1e7 Deploy 9.0.1 2016-02-23 11:58:10 +01:00
Kevin Jahns
e165c5ee2a added peer dependencies, upgraded version to major (new versioning scheme) 2016-02-23 11:57:27 +01:00
Kevin Jahns
7b3693aff3 Deploy 0.8.28 2016-02-23 11:27:26 +01:00
Kevin Jahns
f75f47646b Deploy 0.8.27 2016-02-22 13:08:01 +01:00
Kevin Jahns
64044123e3 Deploy 0.8.26 2016-02-22 13:06:11 +01:00
Kevin Jahns
a286162ace Deploy 0.8.25 2016-02-22 13:04:32 +01:00
Kevin Jahns
f739f3b5d7 Deploy 0.8.23 2016-02-22 12:40:21 +01:00
Kevin Jahns
f2052f95f8 Deploy 0.8.22 2016-02-22 12:38:21 +01:00
Kevin Jahns
81324dc7d4 Deploy 0.8.21 2016-02-18 16:57:27 +01:00
Kevin Jahns
6599cb20b4 Deploy 0.8.20 2016-02-16 16:08:50 +01:00
9 changed files with 93 additions and 53 deletions

7
.gitignore vendored
View File

@@ -1,8 +1 @@
node_modules
bower_components bower_components
.directory
.codio
.settings
.jshintignore
.jshintrc
.validate.json

View File

@@ -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>

View File

@@ -9,15 +9,15 @@
"license": "MIT", "license": "MIT",
"ignore": [], "ignore": [],
"dependencies": { "dependencies": {
"yjs": "~0.7.6", "yjs": "latest",
"y-array": "~0.7.5", "y-array": "latest",
"y-map": "~0.7.2", "y-map": "latest",
"y-memory": "~0.7.0", "y-memory": "latest",
"y-richtext": "~0.7.5", "y-richtext": "latest",
"y-webrtc": "~0.7.1", "y-webrtc": "latest",
"y-websockets-client": "~0.7.10", "y-websockets-client": "latest",
"y-text": "~0.7.1", "y-text": "latest",
"y-indexeddb": "~0.7.1", "y-indexeddb": "latest",
"quill": "~0.20.1", "quill": "~0.20.1",
"ace": "~1.2.3", "ace": "~1.2.3",
"ace-builds": "~1.2.3" "ace-builds": "~1.2.3"

View File

@@ -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.
``` ```
@@ -168,18 +168,20 @@ The promise returns an instance of Y. We denote it with a lower case `y`.
* y.db.userId :: String * y.db.userId :: String
* The used user id for this client. **Never overwrite this** * The used user id for this client. **Never overwrite this**
# Status
Yjs is a work in progress. Different versions of the *y-* repositories may not work together. Just drop me a line if you run into troubles.
## Get help ## Get help
There are some friendly people on [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/y-js/yjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) who may help you with your problem, and answer your questions. There are some friendly people on [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/y-js/yjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) who may help you with your problem, and answer your questions.
Please report _any_ issues to the [Github issue page](https://github.com/y-js/yjs/issues)! I try to fix them very soon, if possible. Please report _any_ issues to the [Github issue page](https://github.com/y-js/yjs/issues)! I try to fix them very soon, if possible.
If you want to see an issue fixed, please subscribe to the thread (or remind me via gitter).
## Changelog ## Changelog
### 1.0.0
This is a complete rewrite of the 0.5 version of Yjs. Since Yjs 1.0 it is possible to work asynchronously on a persistent database, which enables offline support. ### 9.0.0
There were several rolling updates from 0.6 to 0.8. We'll now follow the semver versioning scheme. This is all what this jump from 0.8 to 9.0 is about.
### 0.6.0
This is a complete rewrite of the 0.5 version of Yjs. Since Yjs 0.6.0 it is possible to work asynchronously on a persistent database, which enables offline support.
* Switched to semver versioning * Switched to semver versioning
* Requires a promise implementation in environment (es6 promises suffice, included in all the major browsers). Otherwise you have to include a polyfill * Requires a promise implementation in environment (es6 promises suffice, included in all the major browsers). Otherwise you have to include a polyfill
* Y.Object has been renamed to Y.Map * Y.Object has been renamed to Y.Map

View File

@@ -1,19 +1,21 @@
{ {
"name": "yjs", "name": "yjs",
"version": "0.8.19", "version": "9.0.4",
"homepage": "y-js.org", "homepage": "y-js.org",
"authors": [ "authors": [
"Kevin Jahns <kevin.jahns@rwth-aachen.de>" "Kevin Jahns <kevin.jahns@rwth-aachen.de>"
], ],
"description": "A Framework that enables Real-Time collaboration on arbitrary data structures.", "description": "A Framework for shared editing on any data",
"main": "y.js", "main": "./y.js",
"keywords": [ "keywords": [
"Yjs",
"OT", "OT",
"collaboration", "Collaboration",
"synchronization", "Synchronization",
"sharejs", "ShareJS",
"coweb", "Coweb",
"concurrency" "Concurrency"
], ],
"license": "MIT" "license": "MIT",
"ignore": []
} }

73
y.es6
View File

@@ -52,6 +52,7 @@ module.exports = function (Y/* :any */) {
this.broadcastedHB = false this.broadcastedHB = false
this.syncStep2 = Promise.resolve() this.syncStep2 = Promise.resolve()
this.broadcastOpBuffer = [] this.broadcastOpBuffer = []
this.protocolVersion = 8
} }
reconnect () { reconnect () {
} }
@@ -208,6 +209,18 @@ module.exports = function (Y/* :any */) {
if (this.debug) { if (this.debug) {
console.log(`receive ${sender} -> ${this.userId}: ${message.type}`, JSON.parse(JSON.stringify(message))) // eslint-disable-line console.log(`receive ${sender} -> ${this.userId}: ${message.type}`, JSON.parse(JSON.stringify(message))) // eslint-disable-line
} }
if (message.protocolVersion != null && message.protocolVersion !== this.protocolVersion) {
console.error(
`You tried to sync with a yjs instance that has a different protocol version
(You: ${this.protocolVersion}, Client: ${message.protocolVersion}).
The sync was stopped. You need to upgrade your dependencies (especially Yjs & the Connector)!
`)
this.send(sender, {
type: 'sync stop',
protocolVersion: this.protocolVersion
})
return
}
if (message.type === 'sync step 1') { if (message.type === 'sync step 1') {
// TODO: make transaction, stream the ops // TODO: make transaction, stream the ops
let conn = this let conn = this
@@ -718,9 +731,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) {
@@ -775,8 +796,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 +840,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 +2273,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
@@ -2681,13 +2708,21 @@ function Y (opts/* :YOptions */) /* :Promise<YConfig> */ {
} }
Y.sourceDir = opts.sourceDir Y.sourceDir = opts.sourceDir
return Y.requestModules(modules).then(function () { return Y.requestModules(modules).then(function () {
return new Promise(function (resolve) { return new Promise(function (resolve, reject) {
var yconfig = new YConfig(opts) if (opts == null) reject('An options object is expected! ')
yconfig.db.whenUserIdSet(function () { else if (opts.connector == null) reject('You must specify a connector! (missing connector property)')
yconfig.init(function () { else if (opts.connector.name == null) reject('You must specify connector name! (missing connector.name property)')
resolve(yconfig) else if (opts.db == null) reject('You must specify a database! (missing db property)')
else if (opts.connector.name == null) reject('You must specify db name! (missing db.name property)')
else if (opts.share == null) reject('You must specify a set of shared types!')
else {
var yconfig = new YConfig(opts)
yconfig.db.whenUserIdSet(function () {
yconfig.init(function () {
resolve(yconfig)
})
}) })
}) }
}) })
}) })
} }
@@ -2697,6 +2732,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 +2770,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
})
} }
} }

File diff suppressed because one or more lines are too long

6
y.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long