Compare commits

...

2 Commits

Author SHA1 Message Date
Kevin Jahns
8739fd3a9c Deploy 12.3.3 2017-08-04 20:36:37 +02:00
Kevin Jahns
b3b12958fa Deploy 12.3.2 2017-07-19 18:50:48 +02:00
6 changed files with 40 additions and 31 deletions

View File

@@ -22,6 +22,7 @@ is a list of the modules we know of:
|[webrtc](https://github.com/y-js/y-webrtc) | Propagate updates Browser2Browser via WebRTC| |[webrtc](https://github.com/y-js/y-webrtc) | Propagate updates Browser2Browser via WebRTC|
|[websockets](https://github.com/y-js/y-websockets-client) | Set up [a central server](https://github.com/y-js/y-websockets-client), and connect to it via websockets | |[websockets](https://github.com/y-js/y-websockets-client) | Set up [a central server](https://github.com/y-js/y-websockets-client), and connect to it via websockets |
|[xmpp](https://github.com/y-js/y-xmpp) | Propagate updates in a XMPP multi-user-chat room ([XEP-0045](http://xmpp.org/extensions/xep-0045.html))| |[xmpp](https://github.com/y-js/y-xmpp) | Propagate updates in a XMPP multi-user-chat room ([XEP-0045](http://xmpp.org/extensions/xep-0045.html))|
|[ipfs](https://github.com/ipfs-labs/y-ipfs-connector) | Connector for the [Interplanetary File System](https://ipfs.io/)!|
|[test](https://github.com/y-js/y-test) | A Connector for testing purposes. It is designed to simulate delays that happen in worst case scenarios| |[test](https://github.com/y-js/y-test) | A Connector for testing purposes. It is designed to simulate delays that happen in worst case scenarios|
##### Database adapters ##### Database adapters
@@ -54,23 +55,23 @@ Install Yjs, and its modules with [bower](http://bower.io/), or
[npm](https://www.npmjs.org/package/yjs). [npm](https://www.npmjs.org/package/yjs).
### Bower ### Bower
``` ```sh
bower install --save yjs y-array % add all y-* modules you want to use bower install --save yjs y-array % add all y-* modules you want to use
``` ```
You only need to include the `y.js` file. Yjs is able to automatically require You only need to include the `y.js` file. Yjs is able to automatically require
missing modules. missing modules.
``` ```html
<script src="./bower_components/yjs/y.js"></script> <script src="./bower_components/yjs/y.js"></script>
``` ```
### Npm ### Npm
``` ```sh
npm install --save yjs % add all y-* modules you want to use npm install --save yjs % add all y-* modules you want to use
``` ```
If you don't include via script tag, you have to explicitly include all modules! If you don't include via script tag, you have to explicitly include all modules!
(Same goes for other module systems) (Same goes for other module systems)
``` ```js
var Y = require('yjs') var Y = require('yjs')
require('y-array')(Y) // add the y-array type to Yjs require('y-array')(Y) // add the y-array type to Yjs
require('y-websockets-client')(Y) require('y-websockets-client')(Y)
@@ -83,7 +84,7 @@ require('y-text')(Y)
``` ```
### ES6 Syntax ### ES6 Syntax
``` ```js
import Y from 'yjs' import Y from 'yjs'
import yArray from 'y-array' import yArray from 'y-array'
import yWebsocketsClient from 'y-webrtc' import yWebsocketsClient from 'y-webrtc'
@@ -97,7 +98,7 @@ Y.extend(yArray, yWebsocketsClient, yMemory, yArray, yMap, yText /*, .. */)
# Text editing example # Text editing example
Install dependencies Install dependencies
``` ```sh
bower i yjs y-memory y-webrtc y-array y-text bower i yjs y-memory y-webrtc y-array y-text
``` ```
@@ -165,6 +166,25 @@ soon, if possible.
endpoint of the used connector. endpoint of the used connector.
* All of our connectors also have a default connection endpoint that you can * All of our connectors also have a default connection endpoint that you can
use for development. use for development.
* We provide basic authentification for all connectors. The value of
`options.connector.auth` (this can be a passphase) is sent to all connected
Yjs instances. `options.connector.checkAuth` may grant read or write access
depending on the `auth` information.
Example: A client specifies `options.connector.auth = 'superSecretPassword`.
A server specifies
```js
options.connector.checkAuth = function (auth, yjsInstance, sender) {
return new Promise(function (resolve, reject){
if (auth === 'superSecretPassword') {
resolve('write') // grant read-write access
} else if (auth === 'different password') {
resolve('read') // grant read-only access
} else {
reject('wrong password!') // reject connection
}
})
}
```
* Set `options.connector.generateUserId = true` in order to genenerate a * Set `options.connector.generateUserId = true` in order to genenerate a
userid, instead of receiving one from the server. This way the `Y(..)` is userid, instead of receiving one from the server. This way the `Y(..)` is
immediately going to be resolved, without waiting for any confirmation from immediately going to be resolved, without waiting for any confirmation from
@@ -180,7 +200,7 @@ soon, if possible.
* Defaults to `/bower_components` * Defaults to `/bower_components`
* Not required when running on `nodejs` / `iojs` * Not required when running on `nodejs` / `iojs`
* When using nodejs you need to manually extend Yjs: * When using nodejs you need to manually extend Yjs:
``` ```js
var Y = require('yjs') var Y = require('yjs')
// you have to require a db, connector, and *all* types you use! // you have to require a db, connector, and *all* types you use!
require('y-memory')(Y) require('y-memory')(Y)

View File

@@ -1,6 +1,6 @@
{ {
"name": "yjs", "name": "yjs",
"version": "12.3.1", "version": "12.3.3",
"homepage": "y-js.org", "homepage": "y-js.org",
"authors": [ "authors": [
"Kevin Jahns <kevin.jahns@rwth-aachen.de>" "Kevin Jahns <kevin.jahns@rwth-aachen.de>"

21
y.es6
View File

@@ -1,6 +1,6 @@
/** /**
* yjs - A framework for real-time p2p shared editing on any data * yjs - A framework for real-time p2p shared editing on any data
* @version v12.3.0 * @version v12.3.2
* @link http://y-js.org * @link http://y-js.org
* @license MIT * @license MIT
*/ */
@@ -739,9 +739,6 @@ process.chdir = function (dir) {
process.umask = function() { return 0; }; process.umask = function() { return 0; };
},{}],5:[function(require,module,exports){ },{}],5:[function(require,module,exports){
/* @flow */
'use strict'
function canRead (auth) { return auth === 'read' || auth === 'write' } function canRead (auth) { return auth === 'read' || auth === 'write' }
function canWrite (auth) { return auth === 'write' } function canWrite (auth) { return auth === 'write' }
@@ -780,7 +777,6 @@ module.exports = function (Y/* :any */) {
// this client receives operations from only one other client. // this client receives operations from only one other client.
// In particular, this does not work with y-webrtc. // In particular, this does not work with y-webrtc.
// It will work with y-websockets-client // It will work with y-websockets-client
this.preferUntransformed = opts.preferUntransformed || false
if (opts.role == null || opts.role === 'master') { if (opts.role == null || opts.role === 'master') {
this.role = 'master' this.role = 'master'
} else if (opts.role === 'slave') { } else if (opts.role === 'slave') {
@@ -932,9 +928,6 @@ module.exports = function (Y/* :any */) {
protocolVersion: conn.protocolVersion, protocolVersion: conn.protocolVersion,
auth: conn.authInfo auth: conn.authInfo
} }
if (conn.preferUntransformed && Object.keys(stateSet).length === 0) {
answer.preferUntransformed = true
}
conn.send(syncUser, answer) conn.send(syncUser, answer)
}) })
} else { } else {
@@ -1013,7 +1006,7 @@ module.exports = function (Y/* :any */) {
} }
if (message.auth != null && this.connections[sender] != null) { if (message.auth != null && this.connections[sender] != null) {
// authenticate using auth in message // authenticate using auth in message
var auth = this.checkAuth(message.auth, this.y) var auth = this.checkAuth(message.auth, this.y, sender)
this.connections[sender].auth = auth this.connections[sender].auth = auth
auth.then(auth => { auth.then(auth => {
for (var f of this.userEventListeners) { for (var f of this.userEventListeners) {
@@ -1026,7 +1019,7 @@ module.exports = function (Y/* :any */) {
}) })
} else if (this.connections[sender] != null && this.connections[sender].auth == null) { } else if (this.connections[sender] != null && this.connections[sender].auth == null) {
// authenticate without otherwise // authenticate without otherwise
this.connections[sender].auth = this.checkAuth(null, this.y) this.connections[sender].auth = this.checkAuth(null, this.y, sender)
} }
if (this.connections[sender] != null && this.connections[sender].auth != null) { if (this.connections[sender] != null && this.connections[sender].auth != null) {
return this.connections[sender].auth.then((auth) => { return this.connections[sender].auth.then((auth) => {
@@ -1048,11 +1041,7 @@ module.exports = function (Y/* :any */) {
protocolVersion: this.protocolVersion, protocolVersion: this.protocolVersion,
auth: this.authInfo auth: this.authInfo
} }
if (message.preferUntransformed === true && Object.keys(m.stateSet).length === 0) {
answer.osUntransformed = yield* this.getOperationsUntransformed()
} else {
answer.os = yield* this.getOperations(m.stateSet) answer.os = yield* this.getOperations(m.stateSet)
}
conn.send(sender, answer) conn.send(sender, answer)
if (this.forwardToSyncingClients) { if (this.forwardToSyncingClients) {
conn.syncingClients.push(sender) conn.syncingClients.push(sender)
@@ -2537,7 +2526,7 @@ module.exports = function (Y/* :any */) {
send.push(Y.Struct[op.struct].encode(op)) send.push(Y.Struct[op.struct].encode(op))
} }
} }
if (this.store.y.connector.isSynced && send.length > 0) { // TODO: && !this.store.forwardAppliedOperations (but then i don't send delete ops) if (send.length > 0) { // TODO: && !this.store.forwardAppliedOperations (but then i don't send delete ops)
// is connected, and this is not going to be send in addOperation // is connected, and this is not going to be send in addOperation
this.store.y.connector.broadcastOps(send) this.store.y.connector.broadcastOps(send)
} }
@@ -3158,7 +3147,7 @@ module.exports = function (Y/* :any */) {
} }
* addOperation (op) { * addOperation (op) {
yield* this.os.put(op) yield* this.os.put(op)
if (this.store.y.connector.isSynced && this.store.forwardAppliedOperations && typeof op.id[1] !== 'string') { if (this.store.forwardAppliedOperations && typeof op.id[1] !== 'string') {
// is connected, and this is not going to be send in addOperation // is connected, and this is not going to be send in addOperation
this.store.y.connector.broadcastOps([op]) this.store.y.connector.broadcastOps([op])
} }

File diff suppressed because one or more lines are too long

8
y.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long