Compare commits
12 Commits
v13.0.0-25
...
v13.0.0-30
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e36305245 | ||
|
|
3d6050d8a2 | ||
|
|
3d5ba7b4cc | ||
|
|
415b66607c | ||
|
|
05cd1d0575 | ||
|
|
4edc22bedb | ||
|
|
16f84c67d5 | ||
|
|
290d3c8ffe | ||
|
|
c51e8b46c2 | ||
|
|
0cda1630d2 | ||
|
|
d232b883e9 | ||
|
|
3a0e65403f |
@@ -1,4 +1,15 @@
|
|||||||
/* global Y */
|
/* global Y, HTMLElement, customElements */
|
||||||
|
|
||||||
|
class MagicTable extends HTMLElement {
|
||||||
|
constructor () {
|
||||||
|
super()
|
||||||
|
var shadow = this.attachShadow({mode: 'open'})
|
||||||
|
setTimeout(() => {
|
||||||
|
shadow.append(this.childNodes[0])
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
customElements.define('magic-table', MagicTable)
|
||||||
|
|
||||||
// initialize a shared object. This function call returns a promise!
|
// initialize a shared object. This function call returns a promise!
|
||||||
let y = new Y({
|
let y = new Y({
|
||||||
@@ -17,16 +28,14 @@ window.onload = function () {
|
|||||||
window.yXmlType.bindToDom(document.body)
|
window.yXmlType.bindToDom(document.body)
|
||||||
}
|
}
|
||||||
window.undoManager = new Y.utils.UndoManager(window.yXmlType, {
|
window.undoManager = new Y.utils.UndoManager(window.yXmlType, {
|
||||||
captureTimeout: 1000
|
captureTimeout: 500
|
||||||
})
|
})
|
||||||
|
|
||||||
document.onkeydown = function interceptUndoRedo (e) {
|
document.onkeydown = function interceptUndoRedo (e) {
|
||||||
if (e.keyCode === 90 && e.ctrlKey) {
|
if (e.keyCode === 90 && e.metaKey) {
|
||||||
if (!e.shiftKey) {
|
if (!e.shiftKey) {
|
||||||
console.info('Undo!')
|
|
||||||
window.undoManager.undo()
|
window.undoManager.undo()
|
||||||
} else {
|
} else {
|
||||||
console.info('Redo!')
|
|
||||||
window.undoManager.redo()
|
window.undoManager.redo()
|
||||||
}
|
}
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|||||||
36
package-lock.json
generated
36
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.0.0-25",
|
"version": "13.0.0-30",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2808,14 +2808,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"string_decoder": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"bundled": true,
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"safe-buffer": "5.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"string-width": {
|
"string-width": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
@@ -2826,6 +2818,14 @@
|
|||||||
"strip-ansi": "3.0.1"
|
"strip-ansi": "3.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"string_decoder": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"bundled": true,
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"safe-buffer": "5.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"stringstream": {
|
"stringstream": {
|
||||||
"version": "0.0.5",
|
"version": "0.0.5",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
@@ -4868,15 +4868,6 @@
|
|||||||
"duplexer": "0.1.1"
|
"duplexer": "0.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"string_decoder": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"safe-buffer": "5.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"string-width": {
|
"string-width": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
||||||
@@ -4898,6 +4889,15 @@
|
|||||||
"resolved": "https://registry.npmjs.org/string.prototype.codepointat/-/string.prototype.codepointat-0.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/string.prototype.codepointat/-/string.prototype.codepointat-0.2.0.tgz",
|
||||||
"integrity": "sha1-aybpvTr8qnvjtCabUm3huCAArHg="
|
"integrity": "sha1-aybpvTr8qnvjtCabUm3huCAArHg="
|
||||||
},
|
},
|
||||||
|
"string_decoder": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"safe-buffer": "5.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"strip-ansi": {
|
"strip-ansi": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.0.0-25",
|
"version": "13.0.0-30",
|
||||||
"description": "A framework for real-time p2p shared editing on any data",
|
"description": "A framework for real-time p2p shared editing on any data",
|
||||||
"main": "./y.node.js",
|
"main": "./y.node.js",
|
||||||
"browser": "./y.js",
|
"browser": "./y.js",
|
||||||
|
|||||||
@@ -5,9 +5,13 @@ import commonjs from 'rollup-plugin-commonjs'
|
|||||||
var pkg = require('./package.json')
|
var pkg = require('./package.json')
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
entry: 'src/Y.js',
|
input: 'src/Y.js',
|
||||||
moduleName: 'Y',
|
name: 'Y',
|
||||||
format: 'umd',
|
sourcemap: true,
|
||||||
|
output: {
|
||||||
|
file: 'y.js',
|
||||||
|
format: 'umd'
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
nodeResolve({
|
nodeResolve({
|
||||||
main: true,
|
main: true,
|
||||||
@@ -32,8 +36,6 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
dest: 'y.js',
|
|
||||||
sourceMap: true,
|
|
||||||
banner: `
|
banner: `
|
||||||
/**
|
/**
|
||||||
* ${pkg.name} - ${pkg.description}
|
* ${pkg.name} - ${pkg.description}
|
||||||
|
|||||||
@@ -3,9 +3,13 @@ import commonjs from 'rollup-plugin-commonjs'
|
|||||||
var pkg = require('./package.json')
|
var pkg = require('./package.json')
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
entry: 'src/y-dist.cjs.js',
|
input: 'src/y-dist.cjs.js',
|
||||||
moduleName: 'Y',
|
nameame: 'Y',
|
||||||
format: 'cjs',
|
sourcemap: true,
|
||||||
|
output: {
|
||||||
|
file: 'y.node.js',
|
||||||
|
format: 'cjs'
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
nodeResolve({
|
nodeResolve({
|
||||||
main: true,
|
main: true,
|
||||||
@@ -14,8 +18,6 @@ export default {
|
|||||||
}),
|
}),
|
||||||
commonjs()
|
commonjs()
|
||||||
],
|
],
|
||||||
dest: 'y.node.js',
|
|
||||||
sourceMap: true,
|
|
||||||
banner: `
|
banner: `
|
||||||
/**
|
/**
|
||||||
* ${pkg.name} - ${pkg.description}
|
* ${pkg.name} - ${pkg.description}
|
||||||
|
|||||||
@@ -3,9 +3,13 @@ import commonjs from 'rollup-plugin-commonjs'
|
|||||||
import multiEntry from 'rollup-plugin-multi-entry'
|
import multiEntry from 'rollup-plugin-multi-entry'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
entry: 'test/y-xml.tests.js',
|
input: 'test/y-xml.tests.js',
|
||||||
moduleName: 'y-tests',
|
name: 'y-tests',
|
||||||
format: 'umd',
|
sourcemap: true,
|
||||||
|
output: {
|
||||||
|
file: 'y.test.js',
|
||||||
|
format: 'umd'
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
nodeResolve({
|
nodeResolve({
|
||||||
main: true,
|
main: true,
|
||||||
@@ -14,7 +18,5 @@ export default {
|
|||||||
}),
|
}),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
multiEntry()
|
multiEntry()
|
||||||
],
|
]
|
||||||
dest: 'y.test.js',
|
|
||||||
sourceMap: true
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,13 @@ export default class ItemJSON extends Item {
|
|||||||
this._content = new Array(len)
|
this._content = new Array(len)
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
const ctnt = decoder.readVarString()
|
const ctnt = decoder.readVarString()
|
||||||
this._content[i] = JSON.parse(ctnt)
|
let parsed
|
||||||
|
if (ctnt === 'undefined') {
|
||||||
|
parsed = undefined
|
||||||
|
} else {
|
||||||
|
parsed = JSON.parse(ctnt)
|
||||||
|
}
|
||||||
|
this._content[i] = parsed
|
||||||
}
|
}
|
||||||
return missing
|
return missing
|
||||||
}
|
}
|
||||||
@@ -29,7 +35,14 @@ export default class ItemJSON extends Item {
|
|||||||
let len = this._content.length
|
let len = this._content.length
|
||||||
encoder.writeVarUint(len)
|
encoder.writeVarUint(len)
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
encoder.writeVarString(JSON.stringify(this._content[i]))
|
let encoded
|
||||||
|
let content = this._content[i]
|
||||||
|
if (content === undefined) {
|
||||||
|
encoded = 'undefined'
|
||||||
|
} else {
|
||||||
|
encoded = JSON.stringify(content)
|
||||||
|
}
|
||||||
|
encoder.writeVarString(encoded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_logString () {
|
_logString () {
|
||||||
|
|||||||
@@ -65,9 +65,9 @@ export default class Type extends Item {
|
|||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
_callEventHandler (event) {
|
_callEventHandler (transaction, event) {
|
||||||
const changedParentTypes = this._y._transaction.changedParentTypes
|
const changedParentTypes = transaction.changedParentTypes
|
||||||
this._eventHandler.callEventListeners(event)
|
this._eventHandler.callEventListeners(transaction, event)
|
||||||
let type = this
|
let type = this
|
||||||
while (type !== this._y) {
|
while (type !== this._y) {
|
||||||
let events = changedParentTypes.get(type)
|
let events = changedParentTypes.get(type)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Type from '../Struct/Type.js'
|
import Type from '../Struct/Type.js'
|
||||||
import ItemJSON from '../Struct/ItemJSON.js'
|
import ItemJSON from '../Struct/ItemJSON.js'
|
||||||
|
import ItemString from '../Struct/ItemString.js'
|
||||||
import { logID } from '../MessageHandler/messageToString.js'
|
import { logID } from '../MessageHandler/messageToString.js'
|
||||||
import YEvent from '../Util/YEvent.js'
|
import YEvent from '../Util/YEvent.js'
|
||||||
|
|
||||||
@@ -11,15 +12,19 @@ class YArrayEvent extends YEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class YArray extends Type {
|
export default class YArray extends Type {
|
||||||
_callObserver (parentSubs, remote) {
|
_callObserver (transaction, parentSubs, remote) {
|
||||||
this._callEventHandler(new YArrayEvent(this, remote))
|
this._callEventHandler(transaction, new YArrayEvent(this, remote))
|
||||||
}
|
}
|
||||||
get (pos) {
|
get (pos) {
|
||||||
let n = this._start
|
let n = this._start
|
||||||
while (n !== null) {
|
while (n !== null) {
|
||||||
if (!n._deleted) {
|
if (!n._deleted) {
|
||||||
if (pos < n._length) {
|
if (pos < n._length) {
|
||||||
return n._content[n._length - pos]
|
if (n.constructor === ItemJSON || n.constructor === ItemString) {
|
||||||
|
return n._content[pos]
|
||||||
|
} else {
|
||||||
|
return n
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pos -= n._length
|
pos -= n._length
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ class YMapEvent extends YEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class YMap extends Type {
|
export default class YMap extends Type {
|
||||||
_callObserver (parentSubs, remote) {
|
_callObserver (transaction, parentSubs, remote) {
|
||||||
this._callEventHandler(new YMapEvent(this, parentSubs, remote))
|
this._callEventHandler(transaction, new YMapEvent(this, parentSubs, remote))
|
||||||
}
|
}
|
||||||
toJSON () {
|
toJSON () {
|
||||||
const map = {}
|
const map = {}
|
||||||
|
|||||||
@@ -142,8 +142,8 @@ export default class YXmlFragment extends YArray {
|
|||||||
xml.setDomFilter(f)
|
xml.setDomFilter(f)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_callObserver (parentSubs, remote) {
|
_callObserver (transaction, parentSubs, remote) {
|
||||||
this._callEventHandler(new YXmlEvent(this, parentSubs, remote))
|
this._callEventHandler(transaction, new YXmlEvent(this, parentSubs, remote))
|
||||||
}
|
}
|
||||||
toString () {
|
toString () {
|
||||||
return this.map(xml => xml.toString()).join('')
|
return this.map(xml => xml.toString()).join('')
|
||||||
@@ -255,7 +255,7 @@ export default class YXmlFragment extends YArray {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
for (let dom of diffChildren) {
|
for (let dom of diffChildren) {
|
||||||
if (dom._yxml != null) {
|
if (dom._yxml != null && dom._yxml !== false) {
|
||||||
applyChangesFromDom(dom)
|
applyChangesFromDom(dom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ let relativeSelection = null
|
|||||||
|
|
||||||
export let beforeTransactionSelectionFixer
|
export let beforeTransactionSelectionFixer
|
||||||
if (typeof getSelection !== 'undefined') {
|
if (typeof getSelection !== 'undefined') {
|
||||||
beforeTransactionSelectionFixer = function _beforeTransactionSelectionFixer (y, remote) {
|
beforeTransactionSelectionFixer = function _beforeTransactionSelectionFixer (y, transaction, remote) {
|
||||||
if (!remote) {
|
if (!remote) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ if (typeof getSelection !== 'undefined') {
|
|||||||
beforeTransactionSelectionFixer = function _fakeBeforeTransactionSelectionFixer () {}
|
beforeTransactionSelectionFixer = function _fakeBeforeTransactionSelectionFixer () {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function afterTransactionSelectionFixer (y, remote) {
|
export function afterTransactionSelectionFixer (y, transaction, remote) {
|
||||||
if (relativeSelection === null || !remote) {
|
if (relativeSelection === null || !remote) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,32 @@ export function applyChangesFromDom (dom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function reflectChangesOnDom (events) {
|
export function reflectChangesOnDom (events) {
|
||||||
|
// Make sure that no filtered attributes are applied to the structure
|
||||||
|
// if they were, delete them
|
||||||
|
/*
|
||||||
|
events.forEach(event => {
|
||||||
|
const target = event.target
|
||||||
|
if (event.attributesChanged === undefined) {
|
||||||
|
// event.target is Y.XmlText
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const keys = this._domFilter(target.nodeName, Array.from(event.attributesChanged))
|
||||||
|
if (keys === null) {
|
||||||
|
target._delete()
|
||||||
|
} else {
|
||||||
|
const removeKeys = new Set() // is a copy of event.attributesChanged
|
||||||
|
event.attributesChanged.forEach(key => { removeKeys.add(key) })
|
||||||
|
keys.forEach(key => {
|
||||||
|
// remove all accepted keys from removeKeys
|
||||||
|
removeKeys.delete(key)
|
||||||
|
})
|
||||||
|
// remove the filtered attribute
|
||||||
|
removeKeys.forEach(key => {
|
||||||
|
target.removeAttribute(key)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
*/
|
||||||
this._mutualExclude(() => {
|
this._mutualExclude(() => {
|
||||||
events.forEach(event => {
|
events.forEach(event => {
|
||||||
const yxml = event.target
|
const yxml = event.target
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export default class EventHandler {
|
|||||||
removeAllEventListeners () {
|
removeAllEventListeners () {
|
||||||
this.eventListeners = []
|
this.eventListeners = []
|
||||||
}
|
}
|
||||||
callEventListeners (event) {
|
callEventListeners (transaction, event) {
|
||||||
for (var i = 0; i < this.eventListeners.length; i++) {
|
for (var i = 0; i < this.eventListeners.length; i++) {
|
||||||
try {
|
try {
|
||||||
const f = this.eventListeners[i]
|
const f = this.eventListeners[i]
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import ID from './ID.js'
|
import ID from './ID.js'
|
||||||
|
|
||||||
class ReverseOperation {
|
class ReverseOperation {
|
||||||
constructor (y) {
|
constructor (y, transaction) {
|
||||||
this.created = new Date()
|
this.created = new Date()
|
||||||
const beforeState = y._transaction.beforeState
|
const beforeState = transaction.beforeState
|
||||||
this.toState = new ID(y.userID, y.ss.getState(y.userID) - 1)
|
this.toState = new ID(y.userID, y.ss.getState(y.userID) - 1)
|
||||||
if (beforeState.has(y.userID)) {
|
if (beforeState.has(y.userID)) {
|
||||||
this.fromState = new ID(y.userID, beforeState.get(y.userID))
|
this.fromState = new ID(y.userID, beforeState.get(y.userID))
|
||||||
} else {
|
} else {
|
||||||
this.fromState = this.toState
|
this.fromState = this.toState
|
||||||
}
|
}
|
||||||
this.deletedStructs = y._transaction.deletedStructs
|
this.deletedStructs = transaction.deletedStructs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,10 +24,45 @@ function isStructInScope (y, struct, scope) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyReverseOperation (y, scope, reverseBuffer) {
|
||||||
|
let performedUndo = false
|
||||||
|
y.transact(() => {
|
||||||
|
while (!performedUndo && reverseBuffer.length > 0) {
|
||||||
|
let undoOp = reverseBuffer.pop()
|
||||||
|
// make sure that it is possible to iterate {from}-{to}
|
||||||
|
y.os.getItemCleanStart(undoOp.fromState)
|
||||||
|
y.os.getItemCleanEnd(undoOp.toState)
|
||||||
|
y.os.iterate(undoOp.fromState, undoOp.toState, op => {
|
||||||
|
if (!op._deleted && isStructInScope(y, op, scope)) {
|
||||||
|
performedUndo = true
|
||||||
|
op._delete(y)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
for (let op of undoOp.deletedStructs) {
|
||||||
|
if (
|
||||||
|
isStructInScope(y, op, scope) &&
|
||||||
|
op._parent !== y &&
|
||||||
|
!op._parent._deleted &&
|
||||||
|
(
|
||||||
|
op._parent._id.user !== y.userID ||
|
||||||
|
op._parent._id.clock < undoOp.fromState.clock ||
|
||||||
|
op._parent._id.clock > undoOp.fromState.clock
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
performedUndo = true
|
||||||
|
op = op._copy(undoOp.deletedStructs)
|
||||||
|
op._integrate(y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return performedUndo
|
||||||
|
}
|
||||||
|
|
||||||
export default class UndoManager {
|
export default class UndoManager {
|
||||||
constructor (scope, options = {}) {
|
constructor (scope, options = {}) {
|
||||||
this.options = options
|
this.options = options
|
||||||
options.captureTimeout = options.captureTimeout || 0
|
options.captureTimeout = options.captureTimeout == null ? 500 : options.captureTimeout
|
||||||
this._undoBuffer = []
|
this._undoBuffer = []
|
||||||
this._redoBuffer = []
|
this._redoBuffer = []
|
||||||
this._scope = scope
|
this._scope = scope
|
||||||
@@ -35,13 +70,12 @@ export default class UndoManager {
|
|||||||
this._redoing = false
|
this._redoing = false
|
||||||
const y = scope._y
|
const y = scope._y
|
||||||
this.y = y
|
this.y = y
|
||||||
y.on('afterTransaction', (y, remote) => {
|
y.on('afterTransaction', (y, transaction, remote) => {
|
||||||
if (!remote && (y._transaction.beforeState.has(y.userID) || y._transaction.deletedStructs.size > 0)) {
|
if (!remote && transaction.changedParentTypes.has(scope)) {
|
||||||
let reverseOperation = new ReverseOperation(y)
|
let reverseOperation = new ReverseOperation(y, transaction)
|
||||||
if (!this._undoing) {
|
if (!this._undoing) {
|
||||||
let lastUndoOp = this._undoBuffer.length > 0 ? this._undoBuffer[this._undoBuffer.length - 1] : null
|
let lastUndoOp = this._undoBuffer.length > 0 ? this._undoBuffer[this._undoBuffer.length - 1] : null
|
||||||
if (lastUndoOp !== null && lastUndoOp.created - reverseOperation.created <= options.captureTimeout) {
|
if (lastUndoOp !== null && reverseOperation.created - lastUndoOp.created <= options.captureTimeout) {
|
||||||
console.log('appending', lastUndoOp, reverseOperation)
|
|
||||||
lastUndoOp.created = reverseOperation.created
|
lastUndoOp.created = reverseOperation.created
|
||||||
lastUndoOp.toState = reverseOperation.toState
|
lastUndoOp.toState = reverseOperation.toState
|
||||||
reverseOperation.deletedStructs.forEach(lastUndoOp.deletedStructs.add, lastUndoOp.deletedStructs)
|
reverseOperation.deletedStructs.forEach(lastUndoOp.deletedStructs.add, lastUndoOp.deletedStructs)
|
||||||
@@ -58,47 +92,15 @@ export default class UndoManager {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
undo () {
|
undo () {
|
||||||
console.log('undoing')
|
|
||||||
this._undoing = true
|
this._undoing = true
|
||||||
this._applyReverseOperation(this._undoBuffer)
|
const performedUndo = applyReverseOperation(this.y, this._scope, this._undoBuffer)
|
||||||
this._undoing = false
|
this._undoing = false
|
||||||
|
return performedUndo
|
||||||
}
|
}
|
||||||
redo () {
|
redo () {
|
||||||
this._redoing = true
|
this._redoing = true
|
||||||
this._applyReverseOperation(this._redoBuffer)
|
const performedRedo = applyReverseOperation(this.y, this._scope, this._redoBuffer)
|
||||||
this._redoing = false
|
this._redoing = false
|
||||||
}
|
return performedRedo
|
||||||
_applyReverseOperation (reverseBuffer) {
|
|
||||||
this.y.transact(() => {
|
|
||||||
let performedUndo = false
|
|
||||||
while (!performedUndo && reverseBuffer.length > 0) {
|
|
||||||
let undoOp = reverseBuffer.pop()
|
|
||||||
// make sure that it is possible to iterate {from}-{to}
|
|
||||||
this.y.os.getItemCleanStart(undoOp.fromState)
|
|
||||||
this.y.os.getItemCleanEnd(undoOp.toState)
|
|
||||||
this.y.os.iterate(undoOp.fromState, undoOp.toState, op => {
|
|
||||||
if (!op._deleted && isStructInScope(this.y, op, this._scope)) {
|
|
||||||
performedUndo = true
|
|
||||||
op._delete(this.y)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
for (let op of undoOp.deletedStructs) {
|
|
||||||
if (
|
|
||||||
isStructInScope(this.y, op, this._scope) &&
|
|
||||||
op._parent !== this.y &&
|
|
||||||
!op._parent._deleted &&
|
|
||||||
(
|
|
||||||
op._parent._id.user !== this.y.userID ||
|
|
||||||
op._parent._id.clock < undoOp.fromState.clock ||
|
|
||||||
op._parent._id.clock > undoOp.fromState.clock
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
performedUndo = true
|
|
||||||
op = op._copy(undoOp.deletedStructs)
|
|
||||||
op._integrate(this.y)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ export default class YEvent {
|
|||||||
const path = []
|
const path = []
|
||||||
let type = this.target
|
let type = this.target
|
||||||
const y = type._y
|
const y = type._y
|
||||||
while (type._parent !== this._currentTarget && type._parent !== y) {
|
while (type !== this.currentTarget && type !== y) {
|
||||||
let parent = type._parent
|
let parent = type._parent
|
||||||
if (type._parentSub !== null) {
|
if (type._parentSub !== null) {
|
||||||
path.push(type._parentSub)
|
path.unshift(type._parentSub)
|
||||||
} else {
|
} else {
|
||||||
// parent is array-ish
|
// parent is array-ish
|
||||||
for (let [i, child] of parent) {
|
for (let [i, child] of parent) {
|
||||||
if (child === type) {
|
if (child === type) {
|
||||||
path.push(i)
|
path.unshift(i)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
src/Y.js
20
src/Y.js
@@ -15,6 +15,7 @@ import YMap from './Type/YMap.js'
|
|||||||
import YText from './Type/YText.js'
|
import YText from './Type/YText.js'
|
||||||
import { YXmlFragment, YXmlElement, YXmlText } from './Type/y-xml/y-xml.js'
|
import { YXmlFragment, YXmlElement, YXmlText } from './Type/y-xml/y-xml.js'
|
||||||
import BinaryDecoder from './Binary/Decoder.js'
|
import BinaryDecoder from './Binary/Decoder.js'
|
||||||
|
import { getRelativePosition, fromRelativePosition } from './Util/relativePosition.js'
|
||||||
|
|
||||||
import debug from 'debug'
|
import debug from 'debug'
|
||||||
import Transaction from './Transaction.js'
|
import Transaction from './Transaction.js'
|
||||||
@@ -44,8 +45,8 @@ export default class Y extends NamedEventHandler {
|
|||||||
transact (f, remote = false) {
|
transact (f, remote = false) {
|
||||||
let initialCall = this._transaction === null
|
let initialCall = this._transaction === null
|
||||||
if (initialCall) {
|
if (initialCall) {
|
||||||
this.emit('beforeTransaction', this, remote)
|
|
||||||
this._transaction = new Transaction(this)
|
this._transaction = new Transaction(this)
|
||||||
|
this.emit('beforeTransaction', this, this._transaction, remote)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
f(this)
|
f(this)
|
||||||
@@ -53,13 +54,15 @@ export default class Y extends NamedEventHandler {
|
|||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
if (initialCall) {
|
if (initialCall) {
|
||||||
|
const transaction = this._transaction
|
||||||
|
this._transaction = null
|
||||||
// emit change events on changed types
|
// emit change events on changed types
|
||||||
this._transaction.changedTypes.forEach(function (subs, type) {
|
transaction.changedTypes.forEach(function (subs, type) {
|
||||||
if (!type._deleted) {
|
if (!type._deleted) {
|
||||||
type._callObserver(subs, remote)
|
type._callObserver(transaction, subs, remote)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this._transaction.changedParentTypes.forEach(function (events, type) {
|
transaction.changedParentTypes.forEach(function (events, type) {
|
||||||
if (!type._deleted) {
|
if (!type._deleted) {
|
||||||
events = events
|
events = events
|
||||||
.filter(event =>
|
.filter(event =>
|
||||||
@@ -71,12 +74,11 @@ export default class Y extends NamedEventHandler {
|
|||||||
})
|
})
|
||||||
// we don't have to check for events.length
|
// we don't have to check for events.length
|
||||||
// because there is no way events is empty..
|
// because there is no way events is empty..
|
||||||
type._deepEventHandler.callEventListeners(events)
|
type._deepEventHandler.callEventListeners(transaction, events)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// when all changes & events are processed, emit afterTransaction event
|
// when all changes & events are processed, emit afterTransaction event
|
||||||
this.emit('afterTransaction', this, remote)
|
this.emit('afterTransaction', this, transaction, remote)
|
||||||
this._transaction = null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fake _start for root properties (y.set('name', type))
|
// fake _start for root properties (y.set('name', type))
|
||||||
@@ -168,7 +170,9 @@ Y.XmlText = YXmlText
|
|||||||
|
|
||||||
Y.utils = {
|
Y.utils = {
|
||||||
BinaryDecoder,
|
BinaryDecoder,
|
||||||
UndoManager
|
UndoManager,
|
||||||
|
getRelativePosition,
|
||||||
|
fromRelativePosition
|
||||||
}
|
}
|
||||||
|
|
||||||
Y.debug = debug
|
Y.debug = debug
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ test('basic map tests', async function map0 (t) {
|
|||||||
test('Basic get&set of Map property (converge via sync)', async function map1 (t) {
|
test('Basic get&set of Map property (converge via sync)', async function map1 (t) {
|
||||||
let { users, map0 } = await initArrays(t, { users: 2 })
|
let { users, map0 } = await initArrays(t, { users: 2 })
|
||||||
map0.set('stuff', 'stuffy')
|
map0.set('stuff', 'stuffy')
|
||||||
|
map0.set('undefined', undefined)
|
||||||
|
map0.set('null', null)
|
||||||
t.compare(map0.get('stuff'), 'stuffy')
|
t.compare(map0.get('stuff'), 'stuffy')
|
||||||
|
|
||||||
await flushAll(t, users)
|
await flushAll(t, users)
|
||||||
@@ -48,6 +50,8 @@ test('Basic get&set of Map property (converge via sync)', async function map1 (t
|
|||||||
for (let user of users) {
|
for (let user of users) {
|
||||||
var u = user.get('map', Y.Map)
|
var u = user.get('map', Y.Map)
|
||||||
t.compare(u.get('stuff'), 'stuffy')
|
t.compare(u.get('stuff'), 'stuffy')
|
||||||
|
t.assert(u.get('undefined') === undefined, 'undefined')
|
||||||
|
t.compare(u.get('null'), null, 'null')
|
||||||
}
|
}
|
||||||
await compareUsers(t, users)
|
await compareUsers(t, users)
|
||||||
})
|
})
|
||||||
@@ -172,31 +176,36 @@ test('observePath properties', async function map10 (t) {
|
|||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* TODO: reimplement observeDeep
|
|
||||||
test('observe deep properties', async function map11 (t) {
|
test('observe deep properties', async function map11 (t) {
|
||||||
let { users, map1, map2, map3 } = await initArrays(t, { users: 4 })
|
let { users, map1, map2, map3 } = await initArrays(t, { users: 4 })
|
||||||
var _map1 = map1.set('map', new Y.Map())
|
var _map1 = map1.set('map', new Y.Map())
|
||||||
var calls = 0
|
var calls = 0
|
||||||
var dmapid
|
var dmapid
|
||||||
_map1.observe(function (event) {
|
map1.observeDeep(function (events) {
|
||||||
calls++
|
events.forEach(event => {
|
||||||
t.compare(event.name, 'deepmap')
|
calls++
|
||||||
dmapid = event.target.opContents.deepmap
|
t.assert(event.keysChanged.has('deepmap'))
|
||||||
|
t.assert(event.path.length === 1)
|
||||||
|
t.assert(event.path[0] === 'map')
|
||||||
|
dmapid = event.target.get('deepmap')._id
|
||||||
|
})
|
||||||
})
|
})
|
||||||
await flushAll(t, users)
|
await flushAll(t, users)
|
||||||
|
await flushAll(t, users)
|
||||||
var _map3 = map3.get('map')
|
var _map3 = map3.get('map')
|
||||||
_map3.set('deepmap', new Y.Map())
|
_map3.set('deepmap', new Y.Map())
|
||||||
await flushAll(t, users)
|
await flushAll(t, users)
|
||||||
var _map2 = map2.get('map')
|
var _map2 = map2.get('map')
|
||||||
_map2.set('deepmap', new Y.Map())
|
_map2.set('deepmap', new Y.Map())
|
||||||
await flushAll(t, users)
|
await flushAll(t, users)
|
||||||
|
await flushAll(t, users)
|
||||||
var dmap1 = _map1.get('deepmap')
|
var dmap1 = _map1.get('deepmap')
|
||||||
var dmap2 = _map2.get('deepmap')
|
var dmap2 = _map2.get('deepmap')
|
||||||
var dmap3 = _map3.get('deepmap')
|
var dmap3 = _map3.get('deepmap')
|
||||||
t.assert(calls > 0)
|
t.assert(calls > 0)
|
||||||
t.compare(dmap1._model, dmap2._model)
|
t.assert(dmap1._id.equals(dmap2._id))
|
||||||
t.compare(dmap1._model, dmap3._model)
|
t.assert(dmap1._id.equals(dmap3._id))
|
||||||
t.compare(dmap1._model, dmapid)
|
t.assert(dmap1._id.equals(dmapid))
|
||||||
await compareUsers(t, users)
|
await compareUsers(t, users)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -204,8 +213,10 @@ test('observes using observeDeep', async function map12 (t) {
|
|||||||
let { users, map0 } = await initArrays(t, { users: 2 })
|
let { users, map0 } = await initArrays(t, { users: 2 })
|
||||||
var pathes = []
|
var pathes = []
|
||||||
var calls = 0
|
var calls = 0
|
||||||
map0.observeDeep(function (event) {
|
map0.observeDeep(function (events) {
|
||||||
pathes.push(event.path)
|
events.forEach(event => {
|
||||||
|
pathes.push(event.path)
|
||||||
|
})
|
||||||
calls++
|
calls++
|
||||||
})
|
})
|
||||||
map0.set('map', new Y.Map())
|
map0.set('map', new Y.Map())
|
||||||
@@ -215,7 +226,6 @@ test('observes using observeDeep', async function map12 (t) {
|
|||||||
t.compare(pathes, [[], ['map'], ['map', 'array']])
|
t.compare(pathes, [[], ['map'], ['map', 'array']])
|
||||||
await compareUsers(t, users)
|
await compareUsers(t, users)
|
||||||
})
|
})
|
||||||
*/
|
|
||||||
|
|
||||||
/* TODO: Test events in Y.Map
|
/* TODO: Test events in Y.Map
|
||||||
function compareEvent (t, is, should) {
|
function compareEvent (t, is, should) {
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ export async function flushAll (t, users) {
|
|||||||
if (users.length === 0) {
|
if (users.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await wait(0)
|
await wait(10)
|
||||||
if (users[0].connector.testRoom != null) {
|
if (users[0].connector.testRoom != null) {
|
||||||
// use flushAll method specified in Test Connector
|
// use flushAll method specified in Test Connector
|
||||||
await users[0].connector.testRoom.flushAll(users)
|
await users[0].connector.testRoom.flushAll(users)
|
||||||
|
|||||||
294
y.node.js
294
y.node.js
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 v13.0.0-25
|
* @version v13.0.0-30
|
||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -687,7 +687,6 @@ if (!String.fromCodePoint) {
|
|||||||
/*! http://mths.be/codepointat v0.2.0 by @mathias */
|
/*! http://mths.be/codepointat v0.2.0 by @mathias */
|
||||||
if (!String.prototype.codePointAt) {
|
if (!String.prototype.codePointAt) {
|
||||||
(function() {
|
(function() {
|
||||||
'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
|
|
||||||
var defineProperty = (function() {
|
var defineProperty = (function() {
|
||||||
// IE 8 only supports `Object.defineProperty` on DOM elements
|
// IE 8 only supports `Object.defineProperty` on DOM elements
|
||||||
try {
|
try {
|
||||||
@@ -1900,7 +1899,7 @@ class EventHandler {
|
|||||||
removeAllEventListeners () {
|
removeAllEventListeners () {
|
||||||
this.eventListeners = [];
|
this.eventListeners = [];
|
||||||
}
|
}
|
||||||
callEventListeners (event) {
|
callEventListeners (transaction, event) {
|
||||||
for (var i = 0; i < this.eventListeners.length; i++) {
|
for (var i = 0; i < this.eventListeners.length; i++) {
|
||||||
try {
|
try {
|
||||||
const f = this.eventListeners[i];
|
const f = this.eventListeners[i];
|
||||||
@@ -1967,9 +1966,9 @@ class Type extends Item {
|
|||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
_callEventHandler (event) {
|
_callEventHandler (transaction, event) {
|
||||||
const changedParentTypes = this._y._transaction.changedParentTypes;
|
const changedParentTypes = transaction.changedParentTypes;
|
||||||
this._eventHandler.callEventListeners(event);
|
this._eventHandler.callEventListeners(transaction, event);
|
||||||
let type = this;
|
let type = this;
|
||||||
while (type !== this._y) {
|
while (type !== this._y) {
|
||||||
let events = changedParentTypes.get(type);
|
let events = changedParentTypes.get(type);
|
||||||
@@ -2092,7 +2091,13 @@ class ItemJSON extends Item {
|
|||||||
this._content = new Array(len);
|
this._content = new Array(len);
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
const ctnt = decoder.readVarString();
|
const ctnt = decoder.readVarString();
|
||||||
this._content[i] = JSON.parse(ctnt);
|
let parsed;
|
||||||
|
if (ctnt === 'undefined') {
|
||||||
|
parsed = undefined;
|
||||||
|
} else {
|
||||||
|
parsed = JSON.parse(ctnt);
|
||||||
|
}
|
||||||
|
this._content[i] = parsed;
|
||||||
}
|
}
|
||||||
return missing
|
return missing
|
||||||
}
|
}
|
||||||
@@ -2101,7 +2106,14 @@ class ItemJSON extends Item {
|
|||||||
let len = this._content.length;
|
let len = this._content.length;
|
||||||
encoder.writeVarUint(len);
|
encoder.writeVarUint(len);
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
encoder.writeVarString(JSON.stringify(this._content[i]));
|
let encoded;
|
||||||
|
let content = this._content[i];
|
||||||
|
if (content === undefined) {
|
||||||
|
encoded = 'undefined';
|
||||||
|
} else {
|
||||||
|
encoded = JSON.stringify(content);
|
||||||
|
}
|
||||||
|
encoder.writeVarString(encoded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_logString () {
|
_logString () {
|
||||||
@@ -2122,6 +2134,47 @@ class ItemJSON extends Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ItemString extends Item {
|
||||||
|
constructor () {
|
||||||
|
super();
|
||||||
|
this._content = null;
|
||||||
|
}
|
||||||
|
_copy () {
|
||||||
|
let struct = super._copy();
|
||||||
|
struct._content = this._content;
|
||||||
|
return struct
|
||||||
|
}
|
||||||
|
get _length () {
|
||||||
|
return this._content.length
|
||||||
|
}
|
||||||
|
_fromBinary (y, decoder) {
|
||||||
|
let missing = super._fromBinary(y, decoder);
|
||||||
|
this._content = decoder.readVarString();
|
||||||
|
return missing
|
||||||
|
}
|
||||||
|
_toBinary (encoder) {
|
||||||
|
super._toBinary(encoder);
|
||||||
|
encoder.writeVarString(this._content);
|
||||||
|
}
|
||||||
|
_logString () {
|
||||||
|
const left = this._left !== null ? this._left._lastId : null;
|
||||||
|
const origin = this._origin !== null ? this._origin._lastId : null;
|
||||||
|
return `ItemJSON(id:${logID(this._id)},content:${JSON.stringify(this._content)},left:${logID(left)},origin:${logID(origin)},right:${logID(this._right)},parent:${logID(this._parent)},parentSub:${this._parentSub})`
|
||||||
|
}
|
||||||
|
_splitAt (y, diff) {
|
||||||
|
if (diff === 0) {
|
||||||
|
return this
|
||||||
|
} else if (diff >= this._length) {
|
||||||
|
return this._right
|
||||||
|
}
|
||||||
|
let item = new ItemString();
|
||||||
|
item._content = this._content.slice(diff);
|
||||||
|
this._content = this._content.slice(0, diff);
|
||||||
|
splitHelper(y, this, item, diff);
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class YEvent {
|
class YEvent {
|
||||||
constructor (target) {
|
constructor (target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
@@ -2131,15 +2184,15 @@ class YEvent {
|
|||||||
const path = [];
|
const path = [];
|
||||||
let type = this.target;
|
let type = this.target;
|
||||||
const y = type._y;
|
const y = type._y;
|
||||||
while (type._parent !== this._currentTarget && type._parent !== y) {
|
while (type !== this.currentTarget && type !== y) {
|
||||||
let parent = type._parent;
|
let parent = type._parent;
|
||||||
if (type._parentSub !== null) {
|
if (type._parentSub !== null) {
|
||||||
path.push(type._parentSub);
|
path.unshift(type._parentSub);
|
||||||
} else {
|
} else {
|
||||||
// parent is array-ish
|
// parent is array-ish
|
||||||
for (let [i, child] of parent) {
|
for (let [i, child] of parent) {
|
||||||
if (child === type) {
|
if (child === type) {
|
||||||
path.push(i);
|
path.unshift(i);
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2158,15 +2211,19 @@ class YArrayEvent extends YEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class YArray extends Type {
|
class YArray extends Type {
|
||||||
_callObserver (parentSubs, remote) {
|
_callObserver (transaction, parentSubs, remote) {
|
||||||
this._callEventHandler(new YArrayEvent(this, remote));
|
this._callEventHandler(transaction, new YArrayEvent(this, remote));
|
||||||
}
|
}
|
||||||
get (pos) {
|
get (pos) {
|
||||||
let n = this._start;
|
let n = this._start;
|
||||||
while (n !== null) {
|
while (n !== null) {
|
||||||
if (!n._deleted) {
|
if (!n._deleted) {
|
||||||
if (pos < n._length) {
|
if (pos < n._length) {
|
||||||
return n._content[n._length - pos]
|
if (n.constructor === ItemJSON || n.constructor === ItemString) {
|
||||||
|
return n._content[pos]
|
||||||
|
} else {
|
||||||
|
return n
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pos -= n._length;
|
pos -= n._length;
|
||||||
}
|
}
|
||||||
@@ -2372,8 +2429,8 @@ class YMapEvent extends YEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class YMap extends Type {
|
class YMap extends Type {
|
||||||
_callObserver (parentSubs, remote) {
|
_callObserver (transaction, parentSubs, remote) {
|
||||||
this._callEventHandler(new YMapEvent(this, parentSubs, remote));
|
this._callEventHandler(transaction, new YMapEvent(this, parentSubs, remote));
|
||||||
}
|
}
|
||||||
toJSON () {
|
toJSON () {
|
||||||
const map = {};
|
const map = {};
|
||||||
@@ -2472,47 +2529,6 @@ class YMap extends Type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ItemString extends Item {
|
|
||||||
constructor () {
|
|
||||||
super();
|
|
||||||
this._content = null;
|
|
||||||
}
|
|
||||||
_copy () {
|
|
||||||
let struct = super._copy();
|
|
||||||
struct._content = this._content;
|
|
||||||
return struct
|
|
||||||
}
|
|
||||||
get _length () {
|
|
||||||
return this._content.length
|
|
||||||
}
|
|
||||||
_fromBinary (y, decoder) {
|
|
||||||
let missing = super._fromBinary(y, decoder);
|
|
||||||
this._content = decoder.readVarString();
|
|
||||||
return missing
|
|
||||||
}
|
|
||||||
_toBinary (encoder) {
|
|
||||||
super._toBinary(encoder);
|
|
||||||
encoder.writeVarString(this._content);
|
|
||||||
}
|
|
||||||
_logString () {
|
|
||||||
const left = this._left !== null ? this._left._lastId : null;
|
|
||||||
const origin = this._origin !== null ? this._origin._lastId : null;
|
|
||||||
return `ItemJSON(id:${logID(this._id)},content:${JSON.stringify(this._content)},left:${logID(left)},origin:${logID(origin)},right:${logID(this._right)},parent:${logID(this._parent)},parentSub:${this._parentSub})`
|
|
||||||
}
|
|
||||||
_splitAt (y, diff) {
|
|
||||||
if (diff === 0) {
|
|
||||||
return this
|
|
||||||
} else if (diff >= this._length) {
|
|
||||||
return this._right
|
|
||||||
}
|
|
||||||
let item = new ItemString();
|
|
||||||
item._content = this._content.slice(diff);
|
|
||||||
this._content = this._content.slice(0, diff);
|
|
||||||
splitHelper(y, this, item, diff);
|
|
||||||
return item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class YText extends YArray {
|
class YText extends YArray {
|
||||||
constructor (string) {
|
constructor (string) {
|
||||||
super();
|
super();
|
||||||
@@ -2761,6 +2777,32 @@ function applyChangesFromDom (dom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reflectChangesOnDom (events) {
|
function reflectChangesOnDom (events) {
|
||||||
|
// Make sure that no filtered attributes are applied to the structure
|
||||||
|
// if they were, delete them
|
||||||
|
/*
|
||||||
|
events.forEach(event => {
|
||||||
|
const target = event.target
|
||||||
|
if (event.attributesChanged === undefined) {
|
||||||
|
// event.target is Y.XmlText
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const keys = this._domFilter(target.nodeName, Array.from(event.attributesChanged))
|
||||||
|
if (keys === null) {
|
||||||
|
target._delete()
|
||||||
|
} else {
|
||||||
|
const removeKeys = new Set() // is a copy of event.attributesChanged
|
||||||
|
event.attributesChanged.forEach(key => { removeKeys.add(key) })
|
||||||
|
keys.forEach(key => {
|
||||||
|
// remove all accepted keys from removeKeys
|
||||||
|
removeKeys.delete(key)
|
||||||
|
})
|
||||||
|
// remove the filtered attribute
|
||||||
|
removeKeys.forEach(key => {
|
||||||
|
target.removeAttribute(key)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
*/
|
||||||
this._mutualExclude(() => {
|
this._mutualExclude(() => {
|
||||||
events.forEach(event => {
|
events.forEach(event => {
|
||||||
const yxml = event.target;
|
const yxml = event.target;
|
||||||
@@ -2914,7 +2956,7 @@ let relativeSelection = null;
|
|||||||
|
|
||||||
let beforeTransactionSelectionFixer;
|
let beforeTransactionSelectionFixer;
|
||||||
if (typeof getSelection !== 'undefined') {
|
if (typeof getSelection !== 'undefined') {
|
||||||
beforeTransactionSelectionFixer = function _beforeTransactionSelectionFixer (y, remote) {
|
beforeTransactionSelectionFixer = function _beforeTransactionSelectionFixer (y, transaction, remote) {
|
||||||
if (!remote) {
|
if (!remote) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -2937,7 +2979,7 @@ if (typeof getSelection !== 'undefined') {
|
|||||||
beforeTransactionSelectionFixer = function _fakeBeforeTransactionSelectionFixer () {};
|
beforeTransactionSelectionFixer = function _fakeBeforeTransactionSelectionFixer () {};
|
||||||
}
|
}
|
||||||
|
|
||||||
function afterTransactionSelectionFixer (y, remote) {
|
function afterTransactionSelectionFixer (y, transaction, remote) {
|
||||||
if (relativeSelection === null || !remote) {
|
if (relativeSelection === null || !remote) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -3869,8 +3911,8 @@ class YXmlFragment extends YArray {
|
|||||||
xml.setDomFilter(f);
|
xml.setDomFilter(f);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_callObserver (parentSubs, remote) {
|
_callObserver (transaction, parentSubs, remote) {
|
||||||
this._callEventHandler(new YXmlEvent(this, parentSubs, remote));
|
this._callEventHandler(transaction, new YXmlEvent(this, parentSubs, remote));
|
||||||
}
|
}
|
||||||
toString () {
|
toString () {
|
||||||
return this.map(xml => xml.toString()).join('')
|
return this.map(xml => xml.toString()).join('')
|
||||||
@@ -3982,7 +4024,7 @@ class YXmlFragment extends YArray {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
for (let dom of diffChildren) {
|
for (let dom of diffChildren) {
|
||||||
if (dom._yxml != null) {
|
if (dom._yxml != null && dom._yxml !== false) {
|
||||||
applyChangesFromDom(dom);
|
applyChangesFromDom(dom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4367,16 +4409,16 @@ class NamedEventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ReverseOperation {
|
class ReverseOperation {
|
||||||
constructor (y) {
|
constructor (y, transaction) {
|
||||||
this.created = new Date();
|
this.created = new Date();
|
||||||
const beforeState = y._transaction.beforeState;
|
const beforeState = transaction.beforeState;
|
||||||
this.toState = new ID(y.userID, y.ss.getState(y.userID) - 1);
|
this.toState = new ID(y.userID, y.ss.getState(y.userID) - 1);
|
||||||
if (beforeState.has(y.userID)) {
|
if (beforeState.has(y.userID)) {
|
||||||
this.fromState = new ID(y.userID, beforeState.get(y.userID));
|
this.fromState = new ID(y.userID, beforeState.get(y.userID));
|
||||||
} else {
|
} else {
|
||||||
this.fromState = this.toState;
|
this.fromState = this.toState;
|
||||||
}
|
}
|
||||||
this.deletedStructs = y._transaction.deletedStructs;
|
this.deletedStructs = transaction.deletedStructs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4390,10 +4432,45 @@ function isStructInScope (y, struct, scope) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyReverseOperation (y, scope, reverseBuffer) {
|
||||||
|
let performedUndo = false;
|
||||||
|
y.transact(() => {
|
||||||
|
while (!performedUndo && reverseBuffer.length > 0) {
|
||||||
|
let undoOp = reverseBuffer.pop();
|
||||||
|
// make sure that it is possible to iterate {from}-{to}
|
||||||
|
y.os.getItemCleanStart(undoOp.fromState);
|
||||||
|
y.os.getItemCleanEnd(undoOp.toState);
|
||||||
|
y.os.iterate(undoOp.fromState, undoOp.toState, op => {
|
||||||
|
if (!op._deleted && isStructInScope(y, op, scope)) {
|
||||||
|
performedUndo = true;
|
||||||
|
op._delete(y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (let op of undoOp.deletedStructs) {
|
||||||
|
if (
|
||||||
|
isStructInScope(y, op, scope) &&
|
||||||
|
op._parent !== y &&
|
||||||
|
!op._parent._deleted &&
|
||||||
|
(
|
||||||
|
op._parent._id.user !== y.userID ||
|
||||||
|
op._parent._id.clock < undoOp.fromState.clock ||
|
||||||
|
op._parent._id.clock > undoOp.fromState.clock
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
performedUndo = true;
|
||||||
|
op = op._copy(undoOp.deletedStructs);
|
||||||
|
op._integrate(y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return performedUndo
|
||||||
|
}
|
||||||
|
|
||||||
class UndoManager {
|
class UndoManager {
|
||||||
constructor (scope, options = {}) {
|
constructor (scope, options = {}) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
options.captureTimeout = options.captureTimeout || 0;
|
options.captureTimeout = options.captureTimeout == null ? 500 : options.captureTimeout;
|
||||||
this._undoBuffer = [];
|
this._undoBuffer = [];
|
||||||
this._redoBuffer = [];
|
this._redoBuffer = [];
|
||||||
this._scope = scope;
|
this._scope = scope;
|
||||||
@@ -4401,13 +4478,12 @@ class UndoManager {
|
|||||||
this._redoing = false;
|
this._redoing = false;
|
||||||
const y = scope._y;
|
const y = scope._y;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
y.on('afterTransaction', (y, remote) => {
|
y.on('afterTransaction', (y, transaction, remote) => {
|
||||||
if (!remote && (y._transaction.beforeState.has(y.userID) || y._transaction.deletedStructs.size > 0)) {
|
if (!remote && transaction.changedParentTypes.has(scope)) {
|
||||||
let reverseOperation = new ReverseOperation(y);
|
let reverseOperation = new ReverseOperation(y, transaction);
|
||||||
if (!this._undoing) {
|
if (!this._undoing) {
|
||||||
let lastUndoOp = this._undoBuffer.length > 0 ? this._undoBuffer[this._undoBuffer.length - 1] : null;
|
let lastUndoOp = this._undoBuffer.length > 0 ? this._undoBuffer[this._undoBuffer.length - 1] : null;
|
||||||
if (lastUndoOp !== null && lastUndoOp.created - reverseOperation.created <= options.captureTimeout) {
|
if (lastUndoOp !== null && reverseOperation.created - lastUndoOp.created <= options.captureTimeout) {
|
||||||
console.log('appending', lastUndoOp, reverseOperation);
|
|
||||||
lastUndoOp.created = reverseOperation.created;
|
lastUndoOp.created = reverseOperation.created;
|
||||||
lastUndoOp.toState = reverseOperation.toState;
|
lastUndoOp.toState = reverseOperation.toState;
|
||||||
reverseOperation.deletedStructs.forEach(lastUndoOp.deletedStructs.add, lastUndoOp.deletedStructs);
|
reverseOperation.deletedStructs.forEach(lastUndoOp.deletedStructs.add, lastUndoOp.deletedStructs);
|
||||||
@@ -4424,48 +4500,16 @@ class UndoManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
undo () {
|
undo () {
|
||||||
console.log('undoing');
|
|
||||||
this._undoing = true;
|
this._undoing = true;
|
||||||
this._applyReverseOperation(this._undoBuffer);
|
const performedUndo = applyReverseOperation(this.y, this._scope, this._undoBuffer);
|
||||||
this._undoing = false;
|
this._undoing = false;
|
||||||
|
return performedUndo
|
||||||
}
|
}
|
||||||
redo () {
|
redo () {
|
||||||
this._redoing = true;
|
this._redoing = true;
|
||||||
this._applyReverseOperation(this._redoBuffer);
|
const performedRedo = applyReverseOperation(this.y, this._scope, this._redoBuffer);
|
||||||
this._redoing = false;
|
this._redoing = false;
|
||||||
}
|
return performedRedo
|
||||||
_applyReverseOperation (reverseBuffer) {
|
|
||||||
this.y.transact(() => {
|
|
||||||
let performedUndo = false;
|
|
||||||
while (!performedUndo && reverseBuffer.length > 0) {
|
|
||||||
let undoOp = reverseBuffer.pop();
|
|
||||||
// make sure that it is possible to iterate {from}-{to}
|
|
||||||
this.y.os.getItemCleanStart(undoOp.fromState);
|
|
||||||
this.y.os.getItemCleanEnd(undoOp.toState);
|
|
||||||
this.y.os.iterate(undoOp.fromState, undoOp.toState, op => {
|
|
||||||
if (!op._deleted && isStructInScope(this.y, op, this._scope)) {
|
|
||||||
performedUndo = true;
|
|
||||||
op._delete(this.y);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
for (let op of undoOp.deletedStructs) {
|
|
||||||
if (
|
|
||||||
isStructInScope(this.y, op, this._scope) &&
|
|
||||||
op._parent !== this.y &&
|
|
||||||
!op._parent._deleted &&
|
|
||||||
(
|
|
||||||
op._parent._id.user !== this.y.userID ||
|
|
||||||
op._parent._id.clock < undoOp.fromState.clock ||
|
|
||||||
op._parent._id.clock > undoOp.fromState.clock
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
performedUndo = true;
|
|
||||||
op = op._copy(undoOp.deletedStructs);
|
|
||||||
op._integrate(this.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4826,6 +4870,15 @@ function coerce(val) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var debug_1 = debug$1.coerce;
|
||||||
|
var debug_2 = debug$1.disable;
|
||||||
|
var debug_3 = debug$1.enable;
|
||||||
|
var debug_4 = debug$1.enabled;
|
||||||
|
var debug_5 = debug$1.humanize;
|
||||||
|
var debug_6 = debug$1.names;
|
||||||
|
var debug_7 = debug$1.skips;
|
||||||
|
var debug_8 = debug$1.formatters;
|
||||||
|
|
||||||
var browser = createCommonjsModule(function (module, exports) {
|
var browser = createCommonjsModule(function (module, exports) {
|
||||||
/**
|
/**
|
||||||
* This is the web browser implementation of `debug()`.
|
* This is the web browser implementation of `debug()`.
|
||||||
@@ -5014,6 +5067,14 @@ function localstorage() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var browser_1 = browser.log;
|
||||||
|
var browser_2 = browser.formatArgs;
|
||||||
|
var browser_3 = browser.save;
|
||||||
|
var browser_4 = browser.load;
|
||||||
|
var browser_5 = browser.useColors;
|
||||||
|
var browser_6 = browser.storage;
|
||||||
|
var browser_7 = browser.colors;
|
||||||
|
|
||||||
class AbstractConnector {
|
class AbstractConnector {
|
||||||
constructor (y, opts) {
|
constructor (y, opts) {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@@ -5375,8 +5436,8 @@ class Y$1 extends NamedEventHandler {
|
|||||||
transact (f, remote = false) {
|
transact (f, remote = false) {
|
||||||
let initialCall = this._transaction === null;
|
let initialCall = this._transaction === null;
|
||||||
if (initialCall) {
|
if (initialCall) {
|
||||||
this.emit('beforeTransaction', this, remote);
|
|
||||||
this._transaction = new Transaction(this);
|
this._transaction = new Transaction(this);
|
||||||
|
this.emit('beforeTransaction', this, this._transaction, remote);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
f(this);
|
f(this);
|
||||||
@@ -5384,13 +5445,15 @@ class Y$1 extends NamedEventHandler {
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
if (initialCall) {
|
if (initialCall) {
|
||||||
|
const transaction = this._transaction;
|
||||||
|
this._transaction = null;
|
||||||
// emit change events on changed types
|
// emit change events on changed types
|
||||||
this._transaction.changedTypes.forEach(function (subs, type) {
|
transaction.changedTypes.forEach(function (subs, type) {
|
||||||
if (!type._deleted) {
|
if (!type._deleted) {
|
||||||
type._callObserver(subs, remote);
|
type._callObserver(transaction, subs, remote);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this._transaction.changedParentTypes.forEach(function (events, type) {
|
transaction.changedParentTypes.forEach(function (events, type) {
|
||||||
if (!type._deleted) {
|
if (!type._deleted) {
|
||||||
events = events
|
events = events
|
||||||
.filter(event =>
|
.filter(event =>
|
||||||
@@ -5402,12 +5465,11 @@ class Y$1 extends NamedEventHandler {
|
|||||||
});
|
});
|
||||||
// we don't have to check for events.length
|
// we don't have to check for events.length
|
||||||
// because there is no way events is empty..
|
// because there is no way events is empty..
|
||||||
type._deepEventHandler.callEventListeners(events);
|
type._deepEventHandler.callEventListeners(transaction, events);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// when all changes & events are processed, emit afterTransaction event
|
// when all changes & events are processed, emit afterTransaction event
|
||||||
this.emit('afterTransaction', this, remote);
|
this.emit('afterTransaction', this, transaction, remote);
|
||||||
this._transaction = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fake _start for root properties (y.set('name', type))
|
// fake _start for root properties (y.set('name', type))
|
||||||
@@ -5499,7 +5561,9 @@ Y$1.XmlText = YXmlText;
|
|||||||
|
|
||||||
Y$1.utils = {
|
Y$1.utils = {
|
||||||
BinaryDecoder,
|
BinaryDecoder,
|
||||||
UndoManager
|
UndoManager,
|
||||||
|
getRelativePosition,
|
||||||
|
fromRelativePosition
|
||||||
};
|
};
|
||||||
|
|
||||||
Y$1.debug = browser;
|
Y$1.debug = browser;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
565
y.test.js
565
y.test.js
@@ -1,7 +1,7 @@
|
|||||||
(function (global, factory) {
|
(function (global, factory) {
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||||
(factory((global['y-tests'] = global['y-tests'] || {})));
|
(factory((global['y-tests'] = {})));
|
||||||
}(this, (function (exports) { 'use strict';
|
}(this, (function (exports) { 'use strict';
|
||||||
|
|
||||||
class N {
|
class N {
|
||||||
@@ -684,7 +684,6 @@ if (!String.fromCodePoint) {
|
|||||||
/*! http://mths.be/codepointat v0.2.0 by @mathias */
|
/*! http://mths.be/codepointat v0.2.0 by @mathias */
|
||||||
if (!String.prototype.codePointAt) {
|
if (!String.prototype.codePointAt) {
|
||||||
(function() {
|
(function() {
|
||||||
'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
|
|
||||||
var defineProperty = (function() {
|
var defineProperty = (function() {
|
||||||
// IE 8 only supports `Object.defineProperty` on DOM elements
|
// IE 8 only supports `Object.defineProperty` on DOM elements
|
||||||
try {
|
try {
|
||||||
@@ -1449,6 +1448,10 @@ function logID (id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all items in an ID-range
|
||||||
|
* TODO: implement getItemCleanStartNode for better performance (only one lookup)
|
||||||
|
*/
|
||||||
function deleteItemRange (y, user, clock, range) {
|
function deleteItemRange (y, user, clock, range) {
|
||||||
const createDelete = y.connector._forwardAppliedStructs;
|
const createDelete = y.connector._forwardAppliedStructs;
|
||||||
let item = y.os.getItemCleanStart(new ID(user, clock));
|
let item = y.os.getItemCleanStart(new ID(user, clock));
|
||||||
@@ -1553,6 +1556,13 @@ function transactionTypeChanged (y, type, sub) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper utility to split an Item (see _splitAt)
|
||||||
|
* - copy all properties from a to b
|
||||||
|
* - connect a to b
|
||||||
|
* - assigns the correct _id
|
||||||
|
* - save b to os
|
||||||
|
*/
|
||||||
function splitHelper (y, a, b, diff) {
|
function splitHelper (y, a, b, diff) {
|
||||||
const aID = a._id;
|
const aID = a._id;
|
||||||
b._id = new ID(aID.user, aID.clock + diff);
|
b._id = new ID(aID.user, aID.clock + diff);
|
||||||
@@ -1886,7 +1896,7 @@ class EventHandler {
|
|||||||
removeAllEventListeners () {
|
removeAllEventListeners () {
|
||||||
this.eventListeners = [];
|
this.eventListeners = [];
|
||||||
}
|
}
|
||||||
callEventListeners (event) {
|
callEventListeners (transaction, event) {
|
||||||
for (var i = 0; i < this.eventListeners.length; i++) {
|
for (var i = 0; i < this.eventListeners.length; i++) {
|
||||||
try {
|
try {
|
||||||
const f = this.eventListeners[i];
|
const f = this.eventListeners[i];
|
||||||
@@ -1903,6 +1913,7 @@ class EventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// restructure children as if they were inserted one after another
|
||||||
function integrateChildren (y, start) {
|
function integrateChildren (y, start) {
|
||||||
let right;
|
let right;
|
||||||
do {
|
do {
|
||||||
@@ -1926,9 +1937,35 @@ class Type extends Item {
|
|||||||
this._eventHandler = new EventHandler();
|
this._eventHandler = new EventHandler();
|
||||||
this._deepEventHandler = new EventHandler();
|
this._deepEventHandler = new EventHandler();
|
||||||
}
|
}
|
||||||
_callEventHandler (event) {
|
getPathTo (type) {
|
||||||
const changedParentTypes = this._y._transaction.changedParentTypes;
|
if (type === this) {
|
||||||
this._eventHandler.callEventListeners(event);
|
return []
|
||||||
|
}
|
||||||
|
const path = [];
|
||||||
|
const y = this._y;
|
||||||
|
while (type._parent !== this && this._parent !== y) {
|
||||||
|
let parent = type._parent;
|
||||||
|
if (type._parentSub !== null) {
|
||||||
|
path.push(type._parentSub);
|
||||||
|
} else {
|
||||||
|
// parent is array-ish
|
||||||
|
for (let [i, child] of parent) {
|
||||||
|
if (child === type) {
|
||||||
|
path.push(i);
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type = parent;
|
||||||
|
}
|
||||||
|
if (this._parent !== this) {
|
||||||
|
throw new Error('The type is not a child of this node')
|
||||||
|
}
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
_callEventHandler (transaction, event) {
|
||||||
|
const changedParentTypes = transaction.changedParentTypes;
|
||||||
|
this._eventHandler.callEventListeners(transaction, event);
|
||||||
let type = this;
|
let type = this;
|
||||||
while (type !== this._y) {
|
while (type !== this._y) {
|
||||||
let events = changedParentTypes.get(type);
|
let events = changedParentTypes.get(type);
|
||||||
@@ -2051,7 +2088,13 @@ class ItemJSON extends Item {
|
|||||||
this._content = new Array(len);
|
this._content = new Array(len);
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
const ctnt = decoder.readVarString();
|
const ctnt = decoder.readVarString();
|
||||||
this._content[i] = JSON.parse(ctnt);
|
let parsed;
|
||||||
|
if (ctnt === 'undefined') {
|
||||||
|
parsed = undefined;
|
||||||
|
} else {
|
||||||
|
parsed = JSON.parse(ctnt);
|
||||||
|
}
|
||||||
|
this._content[i] = parsed;
|
||||||
}
|
}
|
||||||
return missing
|
return missing
|
||||||
}
|
}
|
||||||
@@ -2060,7 +2103,14 @@ class ItemJSON extends Item {
|
|||||||
let len = this._content.length;
|
let len = this._content.length;
|
||||||
encoder.writeVarUint(len);
|
encoder.writeVarUint(len);
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
encoder.writeVarString(JSON.stringify(this._content[i]));
|
let encoded;
|
||||||
|
let content = this._content[i];
|
||||||
|
if (content === undefined) {
|
||||||
|
encoded = 'undefined';
|
||||||
|
} else {
|
||||||
|
encoded = JSON.stringify(content);
|
||||||
|
}
|
||||||
|
encoder.writeVarString(encoded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_logString () {
|
_logString () {
|
||||||
@@ -2081,36 +2131,72 @@ class ItemJSON extends Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ItemString extends Item {
|
||||||
|
constructor () {
|
||||||
|
super();
|
||||||
|
this._content = null;
|
||||||
|
}
|
||||||
|
_copy () {
|
||||||
|
let struct = super._copy();
|
||||||
|
struct._content = this._content;
|
||||||
|
return struct
|
||||||
|
}
|
||||||
|
get _length () {
|
||||||
|
return this._content.length
|
||||||
|
}
|
||||||
|
_fromBinary (y, decoder) {
|
||||||
|
let missing = super._fromBinary(y, decoder);
|
||||||
|
this._content = decoder.readVarString();
|
||||||
|
return missing
|
||||||
|
}
|
||||||
|
_toBinary (encoder) {
|
||||||
|
super._toBinary(encoder);
|
||||||
|
encoder.writeVarString(this._content);
|
||||||
|
}
|
||||||
|
_logString () {
|
||||||
|
const left = this._left !== null ? this._left._lastId : null;
|
||||||
|
const origin = this._origin !== null ? this._origin._lastId : null;
|
||||||
|
return `ItemJSON(id:${logID(this._id)},content:${JSON.stringify(this._content)},left:${logID(left)},origin:${logID(origin)},right:${logID(this._right)},parent:${logID(this._parent)},parentSub:${this._parentSub})`
|
||||||
|
}
|
||||||
|
_splitAt (y, diff) {
|
||||||
|
if (diff === 0) {
|
||||||
|
return this
|
||||||
|
} else if (diff >= this._length) {
|
||||||
|
return this._right
|
||||||
|
}
|
||||||
|
let item = new ItemString();
|
||||||
|
item._content = this._content.slice(diff);
|
||||||
|
this._content = this._content.slice(0, diff);
|
||||||
|
splitHelper(y, this, item, diff);
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class YEvent {
|
class YEvent {
|
||||||
constructor (target) {
|
constructor (target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this._path = null;
|
this.currentTarget = target;
|
||||||
}
|
}
|
||||||
get path () {
|
get path () {
|
||||||
if (this._path !== null) {
|
const path = [];
|
||||||
return this._path
|
let type = this.target;
|
||||||
} else {
|
const y = type._y;
|
||||||
const path = [];
|
while (type !== this.currentTarget && type !== y) {
|
||||||
let type = this.target;
|
let parent = type._parent;
|
||||||
const y = type._y;
|
if (type._parentSub !== null) {
|
||||||
while (type._parent !== y) {
|
path.unshift(type._parentSub);
|
||||||
let parent = type._parent;
|
} else {
|
||||||
if (type._parentSub !== null) {
|
// parent is array-ish
|
||||||
path.push(type._parentSub);
|
for (let [i, child] of parent) {
|
||||||
} else {
|
if (child === type) {
|
||||||
// parent is array-ish
|
path.unshift(i);
|
||||||
for (let [i, child] of parent) {
|
break
|
||||||
if (child === type) {
|
|
||||||
path.push(i);
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
type = parent;
|
|
||||||
}
|
}
|
||||||
this._path = path;
|
type = parent;
|
||||||
return path
|
|
||||||
}
|
}
|
||||||
|
return path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2122,15 +2208,19 @@ class YArrayEvent extends YEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class YArray extends Type {
|
class YArray extends Type {
|
||||||
_callObserver (parentSubs, remote) {
|
_callObserver (transaction, parentSubs, remote) {
|
||||||
this._callEventHandler(new YArrayEvent(this, remote));
|
this._callEventHandler(transaction, new YArrayEvent(this, remote));
|
||||||
}
|
}
|
||||||
get (pos) {
|
get (pos) {
|
||||||
let n = this._start;
|
let n = this._start;
|
||||||
while (n !== null) {
|
while (n !== null) {
|
||||||
if (!n._deleted) {
|
if (!n._deleted) {
|
||||||
if (pos < n._length) {
|
if (pos < n._length) {
|
||||||
return n._content[n._length - pos]
|
if (n.constructor === ItemJSON || n.constructor === ItemString) {
|
||||||
|
return n._content[pos]
|
||||||
|
} else {
|
||||||
|
return n
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pos -= n._length;
|
pos -= n._length;
|
||||||
}
|
}
|
||||||
@@ -2336,8 +2426,8 @@ class YMapEvent extends YEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class YMap extends Type {
|
class YMap extends Type {
|
||||||
_callObserver (parentSubs, remote) {
|
_callObserver (transaction, parentSubs, remote) {
|
||||||
this._callEventHandler(new YMapEvent(this, parentSubs, remote));
|
this._callEventHandler(transaction, new YMapEvent(this, parentSubs, remote));
|
||||||
}
|
}
|
||||||
toJSON () {
|
toJSON () {
|
||||||
const map = {};
|
const map = {};
|
||||||
@@ -2436,47 +2526,6 @@ class YMap extends Type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ItemString extends Item {
|
|
||||||
constructor () {
|
|
||||||
super();
|
|
||||||
this._content = null;
|
|
||||||
}
|
|
||||||
_copy () {
|
|
||||||
let struct = super._copy();
|
|
||||||
struct._content = this._content;
|
|
||||||
return struct
|
|
||||||
}
|
|
||||||
get _length () {
|
|
||||||
return this._content.length
|
|
||||||
}
|
|
||||||
_fromBinary (y, decoder) {
|
|
||||||
let missing = super._fromBinary(y, decoder);
|
|
||||||
this._content = decoder.readVarString();
|
|
||||||
return missing
|
|
||||||
}
|
|
||||||
_toBinary (encoder) {
|
|
||||||
super._toBinary(encoder);
|
|
||||||
encoder.writeVarString(this._content);
|
|
||||||
}
|
|
||||||
_logString () {
|
|
||||||
const left = this._left !== null ? this._left._lastId : null;
|
|
||||||
const origin = this._origin !== null ? this._origin._lastId : null;
|
|
||||||
return `ItemJSON(id:${logID(this._id)},content:${JSON.stringify(this._content)},left:${logID(left)},origin:${logID(origin)},right:${logID(this._right)},parent:${logID(this._parent)},parentSub:${this._parentSub})`
|
|
||||||
}
|
|
||||||
_splitAt (y, diff) {
|
|
||||||
if (diff === 0) {
|
|
||||||
return this
|
|
||||||
} else if (diff >= this._length) {
|
|
||||||
return this._right
|
|
||||||
}
|
|
||||||
let item = new ItemString();
|
|
||||||
item._content = this._content.slice(diff);
|
|
||||||
this._content = this._content.slice(0, diff);
|
|
||||||
splitHelper(y, this, item, diff);
|
|
||||||
return item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class YText extends YArray {
|
class YText extends YArray {
|
||||||
constructor (string) {
|
constructor (string) {
|
||||||
super();
|
super();
|
||||||
@@ -2725,6 +2774,32 @@ function applyChangesFromDom (dom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reflectChangesOnDom (events) {
|
function reflectChangesOnDom (events) {
|
||||||
|
// Make sure that no filtered attributes are applied to the structure
|
||||||
|
// if they were, delete them
|
||||||
|
/*
|
||||||
|
events.forEach(event => {
|
||||||
|
const target = event.target
|
||||||
|
if (event.attributesChanged === undefined) {
|
||||||
|
// event.target is Y.XmlText
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const keys = this._domFilter(target.nodeName, Array.from(event.attributesChanged))
|
||||||
|
if (keys === null) {
|
||||||
|
target._delete()
|
||||||
|
} else {
|
||||||
|
const removeKeys = new Set() // is a copy of event.attributesChanged
|
||||||
|
event.attributesChanged.forEach(key => { removeKeys.add(key) })
|
||||||
|
keys.forEach(key => {
|
||||||
|
// remove all accepted keys from removeKeys
|
||||||
|
removeKeys.delete(key)
|
||||||
|
})
|
||||||
|
// remove the filtered attribute
|
||||||
|
removeKeys.forEach(key => {
|
||||||
|
target.removeAttribute(key)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
*/
|
||||||
this._mutualExclude(() => {
|
this._mutualExclude(() => {
|
||||||
events.forEach(event => {
|
events.forEach(event => {
|
||||||
const yxml = event.target;
|
const yxml = event.target;
|
||||||
@@ -3833,8 +3908,8 @@ class YXmlFragment extends YArray {
|
|||||||
xml.setDomFilter(f);
|
xml.setDomFilter(f);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_callObserver (parentSubs, remote) {
|
_callObserver (transaction, parentSubs, remote) {
|
||||||
this._callEventHandler(new YXmlEvent(this, parentSubs, remote));
|
this._callEventHandler(transaction, new YXmlEvent(this, parentSubs, remote));
|
||||||
}
|
}
|
||||||
toString () {
|
toString () {
|
||||||
return this.map(xml => xml.toString()).join('')
|
return this.map(xml => xml.toString()).join('')
|
||||||
@@ -3946,7 +4021,7 @@ class YXmlFragment extends YArray {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
for (let dom of diffChildren) {
|
for (let dom of diffChildren) {
|
||||||
if (dom._yxml != null) {
|
if (dom._yxml != null && dom._yxml !== false) {
|
||||||
applyChangesFromDom(dom);
|
applyChangesFromDom(dom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4332,6 +4407,7 @@ class NamedEventHandler {
|
|||||||
|
|
||||||
class ReverseOperation {
|
class ReverseOperation {
|
||||||
constructor (y) {
|
constructor (y) {
|
||||||
|
this.created = new Date();
|
||||||
const beforeState = y._transaction.beforeState;
|
const beforeState = y._transaction.beforeState;
|
||||||
this.toState = new ID(y.userID, y.ss.getState(y.userID) - 1);
|
this.toState = new ID(y.userID, y.ss.getState(y.userID) - 1);
|
||||||
if (beforeState.has(y.userID)) {
|
if (beforeState.has(y.userID)) {
|
||||||
@@ -4353,8 +4429,45 @@ function isStructInScope (y, struct, scope) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyReverseOperation (y, scope, reverseBuffer) {
|
||||||
|
let performedUndo = false;
|
||||||
|
y.transact(() => {
|
||||||
|
while (!performedUndo && reverseBuffer.length > 0) {
|
||||||
|
let undoOp = reverseBuffer.pop();
|
||||||
|
// make sure that it is possible to iterate {from}-{to}
|
||||||
|
y.os.getItemCleanStart(undoOp.fromState);
|
||||||
|
y.os.getItemCleanEnd(undoOp.toState);
|
||||||
|
y.os.iterate(undoOp.fromState, undoOp.toState, op => {
|
||||||
|
if (!op._deleted && isStructInScope(y, op, scope)) {
|
||||||
|
performedUndo = true;
|
||||||
|
op._delete(y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (let op of undoOp.deletedStructs) {
|
||||||
|
if (
|
||||||
|
isStructInScope(y, op, scope) &&
|
||||||
|
op._parent !== y &&
|
||||||
|
!op._parent._deleted &&
|
||||||
|
(
|
||||||
|
op._parent._id.user !== y.userID ||
|
||||||
|
op._parent._id.clock < undoOp.fromState.clock ||
|
||||||
|
op._parent._id.clock > undoOp.fromState.clock
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
performedUndo = true;
|
||||||
|
op = op._copy(undoOp.deletedStructs);
|
||||||
|
op._integrate(y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return performedUndo
|
||||||
|
}
|
||||||
|
|
||||||
class UndoManager {
|
class UndoManager {
|
||||||
constructor (scope) {
|
constructor (scope, options = {}) {
|
||||||
|
this.options = options;
|
||||||
|
options.captureTimeout = options.captureTimeout == null ? 500 : options.captureTimeout;
|
||||||
this._undoBuffer = [];
|
this._undoBuffer = [];
|
||||||
this._redoBuffer = [];
|
this._redoBuffer = [];
|
||||||
this._scope = scope;
|
this._scope = scope;
|
||||||
@@ -4363,10 +4476,17 @@ class UndoManager {
|
|||||||
const y = scope._y;
|
const y = scope._y;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
y.on('afterTransaction', (y, remote) => {
|
y.on('afterTransaction', (y, remote) => {
|
||||||
if (!remote && (y._transaction.beforeState.has(y.userID) || y._transaction.deletedStructs.size > 0)) {
|
if (!remote && y._transaction.changedParentTypes.has(scope)) {
|
||||||
let reverseOperation = new ReverseOperation(y);
|
let reverseOperation = new ReverseOperation(y);
|
||||||
if (!this._undoing) {
|
if (!this._undoing) {
|
||||||
this._undoBuffer.push(reverseOperation);
|
let lastUndoOp = this._undoBuffer.length > 0 ? this._undoBuffer[this._undoBuffer.length - 1] : null;
|
||||||
|
if (lastUndoOp !== null && reverseOperation.created - lastUndoOp.created <= options.captureTimeout) {
|
||||||
|
lastUndoOp.created = reverseOperation.created;
|
||||||
|
lastUndoOp.toState = reverseOperation.toState;
|
||||||
|
reverseOperation.deletedStructs.forEach(lastUndoOp.deletedStructs.add, lastUndoOp.deletedStructs);
|
||||||
|
} else {
|
||||||
|
this._undoBuffer.push(reverseOperation);
|
||||||
|
}
|
||||||
if (!this._redoing) {
|
if (!this._redoing) {
|
||||||
this._redoBuffer = [];
|
this._redoBuffer = [];
|
||||||
}
|
}
|
||||||
@@ -4378,46 +4498,15 @@ class UndoManager {
|
|||||||
}
|
}
|
||||||
undo () {
|
undo () {
|
||||||
this._undoing = true;
|
this._undoing = true;
|
||||||
this._applyReverseOperation(this._undoBuffer);
|
const performedUndo = applyReverseOperation(this.y, this._scope, this._undoBuffer);
|
||||||
this._undoing = false;
|
this._undoing = false;
|
||||||
|
return performedUndo
|
||||||
}
|
}
|
||||||
redo () {
|
redo () {
|
||||||
this._redoing = true;
|
this._redoing = true;
|
||||||
this._applyReverseOperation(this._redoBuffer);
|
const performedRedo = applyReverseOperation(this.y, this._scope, this._redoBuffer);
|
||||||
this._redoing = false;
|
this._redoing = false;
|
||||||
}
|
return performedRedo
|
||||||
_applyReverseOperation (reverseBuffer) {
|
|
||||||
this.y.transact(() => {
|
|
||||||
let performedUndo = false;
|
|
||||||
while (!performedUndo && reverseBuffer.length > 0) {
|
|
||||||
let undoOp = reverseBuffer.pop();
|
|
||||||
// make sure that it is possible to iterate {from}-{to}
|
|
||||||
this.y.os.getItemCleanStart(undoOp.fromState);
|
|
||||||
this.y.os.getItemCleanEnd(undoOp.toState);
|
|
||||||
this.y.os.iterate(undoOp.fromState, undoOp.toState, op => {
|
|
||||||
if (!op._deleted && isStructInScope(this.y, op, this._scope)) {
|
|
||||||
performedUndo = true;
|
|
||||||
op._delete(this.y);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
for (let op of undoOp.deletedStructs) {
|
|
||||||
if (
|
|
||||||
isStructInScope(this.y, op, this._scope) &&
|
|
||||||
op._parent !== this.y &&
|
|
||||||
!op._parent._deleted &&
|
|
||||||
(
|
|
||||||
op._parent._id.user !== this.y.userID ||
|
|
||||||
op._parent._id.clock < undoOp.fromState.clock ||
|
|
||||||
op._parent._id.clock > undoOp.fromState.clock
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
performedUndo = true;
|
|
||||||
op = op._copy(undoOp.deletedStructs);
|
|
||||||
op._integrate(this.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4445,7 +4534,7 @@ var y = d * 365.25;
|
|||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var index = function(val, options) {
|
var ms = function(val, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var type = typeof val;
|
var type = typeof val;
|
||||||
if (type === 'string' && val.length > 0) {
|
if (type === 'string' && val.length > 0) {
|
||||||
@@ -4587,7 +4676,7 @@ exports.coerce = coerce;
|
|||||||
exports.disable = disable;
|
exports.disable = disable;
|
||||||
exports.enable = enable;
|
exports.enable = enable;
|
||||||
exports.enabled = enabled;
|
exports.enabled = enabled;
|
||||||
exports.humanize = index;
|
exports.humanize = ms;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The currently active debug mode names, and names to skip.
|
* The currently active debug mode names, and names to skip.
|
||||||
@@ -4646,8 +4735,8 @@ function createDebug(namespace) {
|
|||||||
|
|
||||||
// set `diff` timestamp
|
// set `diff` timestamp
|
||||||
var curr = +new Date();
|
var curr = +new Date();
|
||||||
var ms = curr - (prevTime || curr);
|
var ms$$1 = curr - (prevTime || curr);
|
||||||
self.diff = ms;
|
self.diff = ms$$1;
|
||||||
self.prev = prevTime;
|
self.prev = prevTime;
|
||||||
self.curr = curr;
|
self.curr = curr;
|
||||||
prevTime = curr;
|
prevTime = curr;
|
||||||
@@ -4666,19 +4755,19 @@ function createDebug(namespace) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// apply any `formatters` transformations
|
// apply any `formatters` transformations
|
||||||
var index$$1 = 0;
|
var index = 0;
|
||||||
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
|
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
|
||||||
// if we encounter an escaped % then don't increase the array index
|
// if we encounter an escaped % then don't increase the array index
|
||||||
if (match === '%%') return match;
|
if (match === '%%') return match;
|
||||||
index$$1++;
|
index++;
|
||||||
var formatter = exports.formatters[format];
|
var formatter = exports.formatters[format];
|
||||||
if ('function' === typeof formatter) {
|
if ('function' === typeof formatter) {
|
||||||
var val = args[index$$1];
|
var val = args[index];
|
||||||
match = formatter.call(self, val);
|
match = formatter.call(self, val);
|
||||||
|
|
||||||
// now we need to remove `args[index]` since it's inlined in the `format`
|
// now we need to remove `args[index]` since it's inlined in the `format`
|
||||||
args.splice(index$$1, 1);
|
args.splice(index, 1);
|
||||||
index$$1--;
|
index--;
|
||||||
}
|
}
|
||||||
return match;
|
return match;
|
||||||
});
|
});
|
||||||
@@ -4778,6 +4867,15 @@ function coerce(val) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var debug_1 = debug$1.coerce;
|
||||||
|
var debug_2 = debug$1.disable;
|
||||||
|
var debug_3 = debug$1.enable;
|
||||||
|
var debug_4 = debug$1.enabled;
|
||||||
|
var debug_5 = debug$1.humanize;
|
||||||
|
var debug_6 = debug$1.names;
|
||||||
|
var debug_7 = debug$1.skips;
|
||||||
|
var debug_8 = debug$1.formatters;
|
||||||
|
|
||||||
var browser = createCommonjsModule(function (module, exports) {
|
var browser = createCommonjsModule(function (module, exports) {
|
||||||
/**
|
/**
|
||||||
* This is the web browser implementation of `debug()`.
|
* This is the web browser implementation of `debug()`.
|
||||||
@@ -4966,6 +5064,14 @@ function localstorage() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var browser_1 = browser.log;
|
||||||
|
var browser_2 = browser.formatArgs;
|
||||||
|
var browser_3 = browser.save;
|
||||||
|
var browser_4 = browser.load;
|
||||||
|
var browser_5 = browser.useColors;
|
||||||
|
var browser_6 = browser.storage;
|
||||||
|
var browser_7 = browser.colors;
|
||||||
|
|
||||||
class AbstractConnector {
|
class AbstractConnector {
|
||||||
constructor (y, opts) {
|
constructor (y, opts) {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@@ -5336,25 +5442,34 @@ class Y$2 extends NamedEventHandler {
|
|||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
if (initialCall) {
|
if (initialCall) {
|
||||||
|
const transaction = this._transaction;
|
||||||
|
this._transaction = null;
|
||||||
// emit change events on changed types
|
// emit change events on changed types
|
||||||
this._transaction.changedTypes.forEach(function (subs, type) {
|
transaction.changedTypes.forEach(function (subs, type) {
|
||||||
if (!type._deleted) {
|
if (!type._deleted) {
|
||||||
type._callObserver(subs, remote);
|
type._callObserver(transaction, subs, remote);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this._transaction.changedParentTypes.forEach(function (events, type) {
|
transaction.changedParentTypes.forEach(function (events, type) {
|
||||||
if (!type._deleted) {
|
if (!type._deleted) {
|
||||||
events = events.filter(event =>
|
events = events
|
||||||
!event.target._deleted
|
.filter(event =>
|
||||||
);
|
!event.target._deleted
|
||||||
|
);
|
||||||
|
events
|
||||||
|
.forEach(event => {
|
||||||
|
event.currentTarget = type;
|
||||||
|
});
|
||||||
// we don't have to check for events.length
|
// we don't have to check for events.length
|
||||||
// because there is no way events is empty..
|
// because there is no way events is empty..
|
||||||
type._deepEventHandler.callEventListeners(events);
|
type._deepEventHandler.callEventListeners(transaction, events);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// when all changes & events are processed, emit afterTransaction event
|
if (this._transaction === null) {
|
||||||
this.emit('afterTransaction', this, remote);
|
// when all changes & events are processed, emit afterTransaction event
|
||||||
this._transaction = null;
|
// only when there are no more transactions
|
||||||
|
this.emit('afterTransaction', this, remote);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fake _start for root properties (y.set('name', type))
|
// fake _start for root properties (y.set('name', type))
|
||||||
@@ -5446,7 +5561,9 @@ Y$2.XmlText = YXmlText;
|
|||||||
|
|
||||||
Y$2.utils = {
|
Y$2.utils = {
|
||||||
BinaryDecoder,
|
BinaryDecoder,
|
||||||
UndoManager
|
UndoManager,
|
||||||
|
getRelativePosition,
|
||||||
|
fromRelativePosition
|
||||||
};
|
};
|
||||||
|
|
||||||
Y$2.debug = browser;
|
Y$2.debug = browser;
|
||||||
@@ -5622,7 +5739,7 @@ if (typeof Y !== 'undefined') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var chance_1 = createCommonjsModule(function (module, exports) {
|
var chance_1 = createCommonjsModule(function (module, exports) {
|
||||||
// Chance.js 1.0.10
|
// Chance.js 1.0.12
|
||||||
// http://chancejs.com
|
// http://chancejs.com
|
||||||
// (c) 2013 Victor Quinn
|
// (c) 2013 Victor Quinn
|
||||||
// Chance may be freely distributed or modified under the MIT license.
|
// Chance may be freely distributed or modified under the MIT license.
|
||||||
@@ -5687,7 +5804,7 @@ var chance_1 = createCommonjsModule(function (module, exports) {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chance.prototype.VERSION = "1.0.10";
|
Chance.prototype.VERSION = "1.0.12";
|
||||||
|
|
||||||
// Random helper functions
|
// Random helper functions
|
||||||
function initOptions(options, defaults) {
|
function initOptions(options, defaults) {
|
||||||
@@ -5906,6 +6023,16 @@ var chance_1 = createCommonjsModule(function (module, exports) {
|
|||||||
return integer.toString(16);
|
return integer.toString(16);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Chance.prototype.letter = function(options) {
|
||||||
|
options = initOptions(options, {casing: 'lower'});
|
||||||
|
var pool = "abcdefghijklmnopqrstuvwxyz";
|
||||||
|
var letter = this.character({pool: pool});
|
||||||
|
if (options.casing === 'upper') {
|
||||||
|
letter = letter.toUpperCase();
|
||||||
|
}
|
||||||
|
return letter;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a random string
|
* Return a random string
|
||||||
*
|
*
|
||||||
@@ -6848,8 +6975,25 @@ var chance_1 = createCommonjsModule(function (module, exports) {
|
|||||||
return this.word({length: options.length}) + '@' + (options.domain || this.domain());
|
return this.word({length: options.length}) + '@' + (options.domain || this.domain());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #Description:
|
||||||
|
* ===============================================
|
||||||
|
* Generate a random Facebook id, aka fbid.
|
||||||
|
*
|
||||||
|
* NOTE: At the moment (Sep 2017), Facebook ids are
|
||||||
|
* "numeric strings" of length 16.
|
||||||
|
* However, Facebook Graph API documentation states that
|
||||||
|
* "it is extremely likely to change over time".
|
||||||
|
* @see https://developers.facebook.com/docs/graph-api/overview/
|
||||||
|
*
|
||||||
|
* #Examples:
|
||||||
|
* ===============================================
|
||||||
|
* chance.fbid() => '1000035231661304'
|
||||||
|
*
|
||||||
|
* @return [string] facebook id
|
||||||
|
*/
|
||||||
Chance.prototype.fbid = function () {
|
Chance.prototype.fbid = function () {
|
||||||
return parseInt('10000' + this.natural({max: 100000000000}), 10);
|
return '10000' + this.string({pool: "1234567890", length: 11});
|
||||||
};
|
};
|
||||||
|
|
||||||
Chance.prototype.google_analytics = function () {
|
Chance.prototype.google_analytics = function () {
|
||||||
@@ -7690,8 +7834,72 @@ var chance_1 = createCommonjsModule(function (module, exports) {
|
|||||||
|
|
||||||
// -- End Regional
|
// -- End Regional
|
||||||
|
|
||||||
|
// -- Music --
|
||||||
|
|
||||||
|
Chance.prototype.note = function(options) {
|
||||||
|
// choices for 'notes' option:
|
||||||
|
// flatKey - chromatic scale with flat notes (default)
|
||||||
|
// sharpKey - chromatic scale with sharp notes
|
||||||
|
// flats - just flat notes
|
||||||
|
// sharps - just sharp notes
|
||||||
|
// naturals - just natural notes
|
||||||
|
// all - naturals, sharps and flats
|
||||||
|
options = initOptions(options, { notes : 'flatKey'});
|
||||||
|
var scales = {
|
||||||
|
naturals: ['C', 'D', 'E', 'F', 'G', 'A', 'B'],
|
||||||
|
flats: ['D♭', 'E♭', 'G♭', 'A♭', 'B♭'],
|
||||||
|
sharps: ['C♯', 'D♯', 'F♯', 'G♯', 'A♯']
|
||||||
|
};
|
||||||
|
scales.all = scales.naturals.concat(scales.flats.concat(scales.sharps));
|
||||||
|
scales.flatKey = scales.naturals.concat(scales.flats);
|
||||||
|
scales.sharpKey = scales.naturals.concat(scales.sharps);
|
||||||
|
return this.pickone(scales[options.notes]);
|
||||||
|
};
|
||||||
|
|
||||||
|
Chance.prototype.midi_note = function(options) {
|
||||||
|
var min = 0;
|
||||||
|
var max = 127;
|
||||||
|
options = initOptions(options, { min : min, max : max });
|
||||||
|
return this.integer({min: options.min, max: options.max});
|
||||||
|
};
|
||||||
|
|
||||||
|
Chance.prototype.chord_quality = function(options) {
|
||||||
|
options = initOptions(options, { jazz: true });
|
||||||
|
var chord_qualities = ['maj', 'min', 'aug', 'dim'];
|
||||||
|
if (options.jazz){
|
||||||
|
chord_qualities = [
|
||||||
|
'maj7',
|
||||||
|
'min7',
|
||||||
|
'7',
|
||||||
|
'sus',
|
||||||
|
'dim',
|
||||||
|
'ø'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return this.pickone(chord_qualities);
|
||||||
|
};
|
||||||
|
|
||||||
|
Chance.prototype.chord = function (options) {
|
||||||
|
options = initOptions(options);
|
||||||
|
return this.note(options) + this.chord_quality(options);
|
||||||
|
};
|
||||||
|
|
||||||
|
Chance.prototype.tempo = function (options) {
|
||||||
|
var min = 40;
|
||||||
|
var max = 320;
|
||||||
|
options = initOptions(options, {min: min, max: max});
|
||||||
|
return this.integer({min: options.min, max: options.max});
|
||||||
|
};
|
||||||
|
|
||||||
|
// -- End Music
|
||||||
|
|
||||||
// -- Miscellaneous --
|
// -- Miscellaneous --
|
||||||
|
|
||||||
|
// Coin - Flip, flip, flipadelphia
|
||||||
|
Chance.prototype.coin = function(options) {
|
||||||
|
return this.bool() ? "heads" : "tails";
|
||||||
|
};
|
||||||
|
|
||||||
// Dice - For all the board game geeks out there, myself included ;)
|
// Dice - For all the board game geeks out there, myself included ;)
|
||||||
function diceFn (range) {
|
function diceFn (range) {
|
||||||
return function () {
|
return function () {
|
||||||
@@ -12879,6 +13087,21 @@ var chance_1 = createCommonjsModule(function (module, exports) {
|
|||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var chance_2 = chance_1.Chance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to merge all items in os with their successors.
|
||||||
|
*
|
||||||
|
* Some transformations (like delete) fragment items.
|
||||||
|
* Item(c: 'ab') + Delete(1,1) + Delete(0, 1) -> Item(c: 'a',deleted);Item(c: 'b',deleted)
|
||||||
|
*
|
||||||
|
* This functions merges the fragmented nodes together:
|
||||||
|
* Item(c: 'a',deleted);Item(c: 'b',deleted) -> Item(c: 'ab', deleted)
|
||||||
|
*
|
||||||
|
* TODO: The Tree implementation does not support deletions in-spot.
|
||||||
|
* This is why all deletions must be performed after the traversal.
|
||||||
|
*
|
||||||
|
*/
|
||||||
function defragmentItemContent (y) {
|
function defragmentItemContent (y) {
|
||||||
const os = y.os;
|
const os = y.os;
|
||||||
if (os.length < 2) {
|
if (os.length < 2) {
|
||||||
@@ -13070,7 +13293,7 @@ async function flushAll (t, users) {
|
|||||||
if (users.length === 0) {
|
if (users.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await wait(0);
|
await wait(10);
|
||||||
if (users[0].connector.testRoom != null) {
|
if (users[0].connector.testRoom != null) {
|
||||||
// use flushAll method specified in Test Connector
|
// use flushAll method specified in Test Connector
|
||||||
await users[0].connector.testRoom.flushAll(users);
|
await users[0].connector.testRoom.flushAll(users);
|
||||||
@@ -13157,7 +13380,7 @@ async function applyRandomTests (t, mods, iterations) {
|
|||||||
return initInformation
|
return initInformation
|
||||||
}
|
}
|
||||||
|
|
||||||
var index$1$1 = function (str) {
|
var index$1 = function (str) {
|
||||||
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
|
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
|
||||||
return '%' + c.charCodeAt(0).toString(16).toUpperCase();
|
return '%' + c.charCodeAt(0).toString(16).toUpperCase();
|
||||||
});
|
});
|
||||||
@@ -13343,7 +13566,7 @@ function parserForArrayFormat(opts) {
|
|||||||
|
|
||||||
function encode(value, opts) {
|
function encode(value, opts) {
|
||||||
if (opts.encode) {
|
if (opts.encode) {
|
||||||
return opts.strict ? index$1$1(value) : encodeURIComponent(value);
|
return opts.strict ? index$1(value) : encodeURIComponent(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
@@ -13455,7 +13678,7 @@ var stringify = function (obj, opts) {
|
|||||||
}).join('&') : '';
|
}).join('&') : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
var index$2 = {
|
var index = {
|
||||||
extract: extract,
|
extract: extract,
|
||||||
parse: parse$1,
|
parse: parse$1,
|
||||||
stringify: stringify
|
stringify: stringify
|
||||||
@@ -13470,7 +13693,7 @@ const browserSupport =
|
|||||||
|
|
||||||
function createTestLink (params) {
|
function createTestLink (params) {
|
||||||
if (typeof location !== 'undefined') {
|
if (typeof location !== 'undefined') {
|
||||||
var query = index$2.parse(location.search);
|
var query = index.parse(location.search);
|
||||||
delete query.test;
|
delete query.test;
|
||||||
delete query.seed;
|
delete query.seed;
|
||||||
delete query.args;
|
delete query.args;
|
||||||
@@ -13480,7 +13703,7 @@ function createTestLink (params) {
|
|||||||
query[name] = params[name];
|
query[name] = params[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return location.protocol + '//' + location.host + location.pathname + '?' + index$2.stringify(query) + location.hash
|
return location.protocol + '//' + location.host + location.pathname + '?' + index.stringify(query) + location.hash
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13491,7 +13714,7 @@ class TestHandler {
|
|||||||
this.repeatingRun = 0;
|
this.repeatingRun = 0;
|
||||||
this.tests = {};
|
this.tests = {};
|
||||||
if (typeof location !== 'undefined') {
|
if (typeof location !== 'undefined') {
|
||||||
this.opts = index$2.parse(location.search);
|
this.opts = index.parse(location.search);
|
||||||
if (this.opts.case != null) {
|
if (this.opts.case != null) {
|
||||||
this.opts.case = Number(this.opts.case);
|
this.opts.case = Number(this.opts.case);
|
||||||
}
|
}
|
||||||
@@ -13632,7 +13855,7 @@ function createCommonjsModule$1(fn, module) {
|
|||||||
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isBrowser = typeof index$2 !== 'undefined';
|
var isBrowser = typeof index !== 'undefined';
|
||||||
|
|
||||||
var environment = {
|
var environment = {
|
||||||
isBrowser: isBrowser
|
isBrowser: isBrowser
|
||||||
@@ -14890,7 +15113,7 @@ patchFilter$3.filterName = 'texts';
|
|||||||
var textDeltaReverse = function(delta) {
|
var textDeltaReverse = function(delta) {
|
||||||
var i, l, lines, line, lineTmp, header = null,
|
var i, l, lines, line, lineTmp, header = null,
|
||||||
headerRegex = /^@@ +\-(\d+),(\d+) +\+(\d+),(\d+) +@@$/,
|
headerRegex = /^@@ +\-(\d+),(\d+) +\+(\d+),(\d+) +@@$/,
|
||||||
lineHeader, lineAdd, lineRemove;
|
lineHeader;
|
||||||
lines = delta.split('\n');
|
lines = delta.split('\n');
|
||||||
for (i = 0, l = lines.length; i < l; i++) {
|
for (i = 0, l = lines.length; i < l; i++) {
|
||||||
line = lines[i];
|
line = lines[i];
|
||||||
@@ -14898,13 +15121,8 @@ var textDeltaReverse = function(delta) {
|
|||||||
if (lineStart === '@') {
|
if (lineStart === '@') {
|
||||||
header = headerRegex.exec(line);
|
header = headerRegex.exec(line);
|
||||||
lineHeader = i;
|
lineHeader = i;
|
||||||
lineAdd = null;
|
|
||||||
lineRemove = null;
|
|
||||||
|
|
||||||
// fix header
|
|
||||||
lines[lineHeader] = '@@ -' + header[3] + ',' + header[4] + ' +' + header[1] + ',' + header[2] + ' @@';
|
lines[lineHeader] = '@@ -' + header[3] + ',' + header[4] + ' +' + header[1] + ',' + header[2] + ' @@';
|
||||||
} else if (lineStart === '+') {
|
} else if (lineStart === '+') {
|
||||||
lineAdd = i;
|
|
||||||
lines[i] = '-' + lines[i].slice(1);
|
lines[i] = '-' + lines[i].slice(1);
|
||||||
if (lines[i - 1].slice(0, 1) === '+') {
|
if (lines[i - 1].slice(0, 1) === '+') {
|
||||||
// swap lines to keep default order (-+)
|
// swap lines to keep default order (-+)
|
||||||
@@ -14913,7 +15131,6 @@ var textDeltaReverse = function(delta) {
|
|||||||
lines[i - 1] = lineTmp;
|
lines[i - 1] = lineTmp;
|
||||||
}
|
}
|
||||||
} else if (lineStart === '-') {
|
} else if (lineStart === '-') {
|
||||||
lineRemove = i;
|
|
||||||
lines[i] = '+' + lines[i].slice(1);
|
lines[i] = '+' + lines[i].slice(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15748,17 +15965,12 @@ class TestCase extends Logger {
|
|||||||
|
|
||||||
var stackframe = createCommonjsModule$1(function (module, exports) {
|
var stackframe = createCommonjsModule$1(function (module, exports) {
|
||||||
(function(root, factory) {
|
(function(root, factory) {
|
||||||
'use strict';
|
|
||||||
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (typeof undefined === 'function' && undefined.amd) {
|
if (typeof undefined === 'function' && undefined.amd) {
|
||||||
undefined('stackframe', [], factory);
|
undefined('stackframe', [], factory);
|
||||||
} else {
|
} else {
|
||||||
module.exports = factory();
|
module.exports = factory();
|
||||||
}
|
}
|
||||||
}(commonjsGlobal$1, function() {
|
}(commonjsGlobal$1, function() {
|
||||||
'use strict';
|
|
||||||
function _isNumber(n) {
|
function _isNumber(n) {
|
||||||
return !isNaN(parseFloat(n)) && isFinite(n);
|
return !isNaN(parseFloat(n)) && isFinite(n);
|
||||||
}
|
}
|
||||||
@@ -15860,18 +16072,12 @@ var stackframe = createCommonjsModule$1(function (module, exports) {
|
|||||||
|
|
||||||
var errorStackParser = createCommonjsModule$1(function (module, exports) {
|
var errorStackParser = createCommonjsModule$1(function (module, exports) {
|
||||||
(function(root, factory) {
|
(function(root, factory) {
|
||||||
'use strict';
|
|
||||||
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (typeof undefined === 'function' && undefined.amd) {
|
if (typeof undefined === 'function' && undefined.amd) {
|
||||||
undefined('error-stack-parser', ['stackframe'], factory);
|
undefined('error-stack-parser', ['stackframe'], factory);
|
||||||
} else {
|
} else {
|
||||||
module.exports = factory(stackframe);
|
module.exports = factory(stackframe);
|
||||||
}
|
}
|
||||||
}(commonjsGlobal$1, function ErrorStackParser(StackFrame) {
|
}(commonjsGlobal$1, function ErrorStackParser(StackFrame) {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+\:\d+/;
|
var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+\:\d+/;
|
||||||
var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+\:\d+|\(native\))/m;
|
var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+\:\d+|\(native\))/m;
|
||||||
var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code\])?$/;
|
var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code\])?$/;
|
||||||
@@ -16052,10 +16258,6 @@ var errorStackParser = createCommonjsModule$1(function (module, exports) {
|
|||||||
|
|
||||||
var stackGenerator = createCommonjsModule$1(function (module, exports) {
|
var stackGenerator = createCommonjsModule$1(function (module, exports) {
|
||||||
(function(root, factory) {
|
(function(root, factory) {
|
||||||
'use strict';
|
|
||||||
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (typeof undefined === 'function' && undefined.amd) {
|
if (typeof undefined === 'function' && undefined.amd) {
|
||||||
undefined('stack-generator', ['stackframe'], factory);
|
undefined('stack-generator', ['stackframe'], factory);
|
||||||
} else {
|
} else {
|
||||||
@@ -18168,24 +18370,12 @@ var sourceMapConsumer = {
|
|||||||
|
|
||||||
var stacktraceGps = createCommonjsModule$1(function (module, exports) {
|
var stacktraceGps = createCommonjsModule$1(function (module, exports) {
|
||||||
(function(root, factory) {
|
(function(root, factory) {
|
||||||
'use strict';
|
|
||||||
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (typeof undefined === 'function' && undefined.amd) {
|
if (typeof undefined === 'function' && undefined.amd) {
|
||||||
undefined('stacktrace-gps', ['source-map', 'stackframe'], factory);
|
undefined('stacktrace-gps', ['source-map', 'stackframe'], factory);
|
||||||
} else {
|
} else {
|
||||||
module.exports = factory(sourceMapConsumer, stackframe);
|
module.exports = factory(sourceMapConsumer, stackframe);
|
||||||
}
|
}
|
||||||
}(commonjsGlobal$1, function(SourceMap, StackFrame) {
|
}(commonjsGlobal$1, function(SourceMap, StackFrame) {
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make a X-Domain request to url and callback.
|
|
||||||
*
|
|
||||||
* @param {String} url
|
|
||||||
* @returns {Promise} with response text if fulfilled
|
|
||||||
*/
|
|
||||||
function _xdr(url) {
|
function _xdr(url) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
@@ -18214,8 +18404,8 @@ var stacktraceGps = createCommonjsModule$1(function (module, exports) {
|
|||||||
* @returns {String} original representation of the base64-encoded string.
|
* @returns {String} original representation of the base64-encoded string.
|
||||||
*/
|
*/
|
||||||
function _atob(b64str) {
|
function _atob(b64str) {
|
||||||
if (typeof index$2 !== 'undefined' && index$2.atob) {
|
if (typeof index !== 'undefined' && index.atob) {
|
||||||
return index$2.atob(b64str);
|
return index.atob(b64str);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('You must supply a polyfill for window.atob in this environment');
|
throw new Error('You must supply a polyfill for window.atob in this environment');
|
||||||
}
|
}
|
||||||
@@ -18503,10 +18693,6 @@ var stacktraceGps = createCommonjsModule$1(function (module, exports) {
|
|||||||
|
|
||||||
var stacktrace = createCommonjsModule$1(function (module, exports) {
|
var stacktrace = createCommonjsModule$1(function (module, exports) {
|
||||||
(function(root, factory) {
|
(function(root, factory) {
|
||||||
'use strict';
|
|
||||||
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (typeof undefined === 'function' && undefined.amd) {
|
if (typeof undefined === 'function' && undefined.amd) {
|
||||||
undefined('stacktrace', ['error-stack-parser', 'stack-generator', 'stacktrace-gps'], factory);
|
undefined('stacktrace', ['error-stack-parser', 'stack-generator', 'stacktrace-gps'], factory);
|
||||||
} else {
|
} else {
|
||||||
@@ -18729,7 +18915,7 @@ var stacktrace = createCommonjsModule$1(function (module, exports) {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
index$2.stacktrace = stacktrace;
|
index.stacktrace = stacktrace;
|
||||||
|
|
||||||
function test (testDescription, ...args) {
|
function test (testDescription, ...args) {
|
||||||
let location = stacktrace.getSync()[1];
|
let location = stacktrace.getSync()[1];
|
||||||
@@ -18738,9 +18924,6 @@ function test (testDescription, ...args) {
|
|||||||
testHandler.register(testCase);
|
testHandler.register(testCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//# sourceMappingURL=cutest.mjs.map
|
|
||||||
|
|
||||||
test('set property', async function xml0 (t) {
|
test('set property', async function xml0 (t) {
|
||||||
var { users, xml0, xml1 } = await initArrays(t, { users: 2 });
|
var { users, xml0, xml1 } = await initArrays(t, { users: 2 });
|
||||||
xml0.setAttribute('height', 10);
|
xml0.setAttribute('height', 10);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user