add serviceworker demo

This commit is contained in:
Kevin Jahns 2017-04-11 16:20:13 +02:00
parent 20e3491a64
commit e30e16c91b
6 changed files with 8009 additions and 10 deletions

View File

@ -1,21 +1,31 @@
/* global Y, Quill */
// register yjs service worker
if('serviceWorker' in navigator){
// Register service worker
// it is important to copy yjs-sw-template to the root directory!
navigator.serviceWorker.register('./yjs-sw-template.js').then(function(reg){
console.log("Yjs service worker registration succeeded. Scope is " + reg.scope);
}).catch(function(err){
console.error("Yjs service worker registration failed with error " + err);
})
}
// initialize a shared object. This function call returns a promise!
Y({
db: {
name: 'memory'
},
connector: {
name: 'webworker',
url: '../bower_components/y-webworker/yjs-webworker.js',
room: 'WebWorkerExample2'
name: 'serviceworker',
room: 'ServiceWorkerExample2'
},
sourceDir: '/bower_components',
share: {
richtext: 'Richtext' // y.share.richtext is of type Y.Richtext
}
}).then(function (y) {
window.yQuill = y
window.yServiceWorker = y
// create quill element
window.quill = new Quill('#quill', {

View File

@ -0,0 +1,22 @@
/* eslint-env worker */
// copy and modify this file
self.DBConfig = {
name: 'indexeddb'
}
self.ConnectorConfig = {
name: 'websockets-client',
// url: '..',
options: {
jsonp: false
}
}
importScripts(
'/bower_components/yjs/y.js',
'/bower_components/y-memory/y-memory.js',
'/bower_components/y-indexeddb/y-indexeddb.js',
'/bower_components/y-websockets-client/y-websockets-client.js',
'/bower_components/y-serviceworker/yjs-sw-include.js'
)

2
y.es6
View File

@ -1,6 +1,6 @@
/**
* yjs - A framework for real-time p2p shared editing on any data
* @version v12.1.6
* @version v12.1.7
* @link http://y-js.org
* @license MIT
*/

7975
y.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long