How to use the yjs.debug function in yjs

To help you get started, we’ve selected a few yjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spacecraft-repl / SpaceCraft / yjs-ws-server.js View on Github external
'use strict'

// @todo: Refactor / clean up code.
// @todo: Combine the two debugs into one.
const debug = require('debug')('YjsWS')

const Y = require('yjs')

// @todo: Verify what these two lines are doing.
debug(Y)
debug('Y.debug:', Y.debug)

const minimist = require('minimist')
require('y-memory')(Y)
try {
  require('y-leveldb')(Y)
} catch (err) {}

try {
  require('./y-websockets-server.js')(Y) // Doesn't exist...
} catch (err) {
  require('y-websockets-server')(Y) // <-- ...this one is called.
}

global.yInstances = {}

module.exports = (io, socket) => {
github akshaykmr / oorja / app / imports / modules / Yjs / AbstractConnector.js View on Github external
this.y = y
    if (opts == null) {
      opts = {}
    }
    // Prefer to receive untransformed operations. This does only work if
    // this client receives operations from only one other client.
    // In particular, this does not work with y-webrtc.
    // It will work with y-websockets-client
    if (opts.role == null || opts.role === 'master') {
      this.role = 'master'
    } else if (opts.role === 'slave') {
      this.role = 'slave'
    } else {
      throw new Error("Role must be either 'master' or 'slave'!")
    }
    this.log = Y.debug('y:connector')
    this.logMessage = Y.debug('y:connector-message')
    this.y.db.forwardAppliedOperations = opts.forwardAppliedOperations || false
    this.role = opts.role
    this.connections = {}
    this.isSynced = false
    this.userEventListeners = []
    this.whenSyncedListeners = []
    this.currentSyncTarget = null
    this.syncingClients = []
    this.forwardToSyncingClients = opts.forwardToSyncingClients !== false
    this.debug = opts.debug === true
    this.syncStep2 = Promise.resolve()
    this.broadcastOpBuffer = []
    this.protocolVersion = 11
    this.authInfo = opts.auth || null
    this.checkAuth = opts.checkAuth || function () { return Promise.resolve('write') } // default is everyone has write access
github akshaykmr / oorja / app / imports / modules / Yjs / AbstractConnector.js View on Github external
if (opts == null) {
      opts = {}
    }
    // Prefer to receive untransformed operations. This does only work if
    // this client receives operations from only one other client.
    // In particular, this does not work with y-webrtc.
    // It will work with y-websockets-client
    if (opts.role == null || opts.role === 'master') {
      this.role = 'master'
    } else if (opts.role === 'slave') {
      this.role = 'slave'
    } else {
      throw new Error("Role must be either 'master' or 'slave'!")
    }
    this.log = Y.debug('y:connector')
    this.logMessage = Y.debug('y:connector-message')
    this.y.db.forwardAppliedOperations = opts.forwardAppliedOperations || false
    this.role = opts.role
    this.connections = {}
    this.isSynced = false
    this.userEventListeners = []
    this.whenSyncedListeners = []
    this.currentSyncTarget = null
    this.syncingClients = []
    this.forwardToSyncingClients = opts.forwardToSyncingClients !== false
    this.debug = opts.debug === true
    this.syncStep2 = Promise.resolve()
    this.broadcastOpBuffer = []
    this.protocolVersion = 11
    this.authInfo = opts.auth || null
    this.checkAuth = opts.checkAuth || function () { return Promise.resolve('write') } // default is everyone has write access
    if (opts.generateUserId === true) {