Compare commits

..

1 Commits

Author SHA1 Message Date
Kevin Jahns
a0b81c336e v13.0.0-58 -- distribution files 2018-05-05 15:35:07 +02:00
9 changed files with 52 additions and 282 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "yjs",
"version": "13.0.0-59",
"version": "13.0.0-58",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "yjs",
"version": "13.0.0-59",
"version": "13.0.0-58",
"description": "A framework for real-time p2p shared editing on any data",
"main": "./y.node.js",
"browser": "./y.js",

View File

@@ -90,20 +90,21 @@ export default function domObserver (mutations, _document) {
mutations.forEach(mutation => {
const dom = mutation.target
const yxml = this.domToType.get(dom)
if (yxml === undefined) { // In case yxml is undefined, we double check if we forgot to bind the dom
let parent
let yParent
do {
parent = dom.parentNode
yParent = this.domToType.get(parent)
} while (yParent === undefined && parent !== null)
if (yParent !== false && yParent !== undefined && yParent.constructor !== YXmlHook) {
diffChildren.add(parent)
if (yxml === false || yxml === undefined || yxml.constructor === YXmlHook) {
// dom element is filtered
if (yxml === undefined) { // In case yxml is undefined, we double check if we forgot to bind the dom
console.error('Yjs DomBinding: Reconstructing DomBinding, please report how to reproduce this.')
let parent
let yParent
do {
parent = dom.parentNode
yParent = this.domToType.get(parent)
} while (yParent === undefined)
if (yParent !== false && yParent !== undefined && yParent.constructor !== YXmlHook) {
diffChildren.add(parent)
}
}
return
} else if (yxml === false || yxml.constructor === YXmlHook) {
// dom element is filtered / a dom hook
return
}
switch (mutation.type) {
case 'characterData':

8
y.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,7 @@
/**
* yjs - A framework for real-time p2p shared editing on any data
* @version v13.0.0-59
* @version v13.0.0-58
* @license MIT
*/
@@ -5494,20 +5494,21 @@ function domObserver (mutations, _document) {
mutations.forEach(mutation => {
const dom = mutation.target;
const yxml = this.domToType.get(dom);
if (yxml === undefined) { // In case yxml is undefined, we double check if we forgot to bind the dom
let parent;
let yParent;
do {
parent = dom.parentNode;
yParent = this.domToType.get(parent);
} while (yParent === undefined && parent !== null)
if (yParent !== false && yParent !== undefined && yParent.constructor !== YXmlHook) {
diffChildren.add(parent);
if (yxml === false || yxml === undefined || yxml.constructor === YXmlHook) {
// dom element is filtered
if (yxml === undefined) { // In case yxml is undefined, we double check if we forgot to bind the dom
console.error('Yjs DomBinding: Reconstructing DomBinding, please report how to reproduce this.');
let parent;
let yParent;
do {
parent = dom.parentNode;
yParent = this.domToType.get(parent);
} while (yParent === undefined)
if (yParent !== false && yParent !== undefined && yParent.constructor !== YXmlHook) {
diffChildren.add(parent);
}
}
return
} else if (yxml === false || yxml.constructor === YXmlHook) {
// dom element is filtered / a dom hook
return
}
switch (mutation.type) {
case 'characterData':

File diff suppressed because one or more lines are too long

264
y.test.js
View File

@@ -13552,6 +13552,9 @@ function test (testDescription, ...args) {
testHandler.register(testCase);
}
//# sourceMappingURL=cutest.mjs.map
proxyConsole();
var numberOfRBTreeTests = 10000;
@@ -13827,9 +13830,6 @@ class DeleteStore extends Tree {
}
}
/**
* A BinaryDecoder handles the decoding of an ArrayBuffer.
*/
class BinaryDecoder {
/**
* @param {Uint8Array|Buffer} buffer The binary data that this instance
@@ -13976,7 +13976,6 @@ class BinaryDecoder {
}
}
// TODO should have the same base class as Item
class GC {
constructor () {
this._id = null;
@@ -14613,11 +14612,6 @@ function logItemHelper (name, item, append) {
return `${name}(id:${logID(item._id)},start:${logID(item._start)},left:${logID(left)},origin:${logID(origin)},right:${logID(item._right)},parent:${logID(item._parent)},parentSub:${item._parentSub}${append !== undefined ? ' - ' + append : ''})`
}
/**
* @private
* Delete all items in an ID-range
* TODO: implement getItemCleanStartNode for better performance (only one lookup)
*/
function deleteItemRange (y, user, clock, range, gcChildren) {
const createDelete = y.connector !== null && y.connector._forwardAppliedStructs;
let item = y.os.getItemCleanStart(new ID(user, clock));
@@ -14810,14 +14804,6 @@ function transactionTypeChanged (y, type, sub) {
}
}
/**
* @private
* Helper utility to split an Item (see {@link Item#_splitAt})
* - copies all properties from a to b
* - connects a to b
* - assigns the correct _id
* - saves b to os
*/
function splitHelper (y, a, b, diff) {
const aID = a._id;
b._id = new ID(aID.user, aID.clock + diff);
@@ -15400,7 +15386,6 @@ class EventHandler {
}
}
// restructure children as if they were inserted one after another
function integrateChildren (y, start) {
let right;
do {
@@ -15774,13 +15759,6 @@ class YEvent {
}
}
/**
* Event that describes the changes on a YArray
*
* @param {YArray} yarray The changed type
* @param {Boolean} remote Whether the changed was caused by a remote peer
* @param {Transaction} transaction The transaction object
*/
class YArrayEvent extends YEvent {
constructor (yarray, remote, transaction) {
super(yarray);
@@ -16147,13 +16125,6 @@ class YArray extends Type {
}
}
/**
* Event that describes the changes on a YMap.
*
* @param {YMap} ymap The YArray that changed.
* @param {Set<any>} subs The keys that changed.
* @param {boolean} remote Whether the change was created by a remote peer.
*/
class YMapEvent extends YEvent {
constructor (ymap, subs, remote) {
super(ymap);
@@ -16390,9 +16361,6 @@ class ItemFormat extends Item {
}
}
/**
* @private
*/
function integrateItem (item, parent, y, left, right) {
item._origin = left;
item._left = left;
@@ -17059,14 +17027,6 @@ function isParentOf (parent, child) {
return false
}
/**
* Default filter method (does nothing).
*
* @param {String} nodeName The nodeName of the element
* @param {Map} attrs Map of key-value pairs that are attributes of the node.
* @return {Map | null} The allowed attributes or null, if the element should be
* filtered.
*/
function defaultFilter (nodeName, attrs) {
// TODO: implement basic filter that filters out dangerous properties!
return attrs
@@ -17118,16 +17078,6 @@ function applyFilterOnType (y, binding, type) {
}
}
/**
* Creates a Yjs type (YXml) based on the contents of a DOM Element.
*
* @param {Element|TextNode} element The DOM Element
* @param {?Document} _document Optional. Provide the global document object
* @param {Hooks} [hooks = {}] Optional. Set of Yjs Hooks
* @param {Filter} [filter=defaultFilter] Optional. Dom element filter
* @param {?DomBinding} binding Warning: This property is for internal use only!
* @return {YXmlElement | YXmlText}
*/
function domToType (element, _document = document, hooks = {}, filter = defaultFilter, binding) {
let type;
switch (element.nodeType) {
@@ -17173,11 +17123,6 @@ function domToType (element, _document = document, hooks = {}, filter = defaultF
return type
}
/**
* Iterates items until an undeleted item is found.
*
* @private
*/
function iterateUntilUndeleted (item) {
while (item !== null && item._deleted) {
item = item._right;
@@ -17295,26 +17240,6 @@ function removeDomChildrenUntilElementFound (parent, currentChild, elem) {
}
}
/**
* Define the elements to which a set of CSS queries apply.
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}
*
* @example
* query = '.classSelector'
* query = 'nodeSelector'
* query = '#idSelector'
*
* @typedef {string} CSS_Selector
*/
/**
* Represents a subset of the nodes of a YXmlElement / YXmlFragment and a
* position within them.
*
* Can be created with {@link YXmlFragment#createTreeWalker}
*
* @public
*/
class YXmlTreeWalker {
constructor (root, f) {
this._filter = f || (() => true);
@@ -17370,11 +17295,6 @@ class YXmlTreeWalker {
}
}
/**
* An Event that describes changes on a YXml Element or Yxml Fragment
*
* @protected
*/
class YXmlEvent extends YEvent {
/**
* @param {YType} target The target on which the event is created.
@@ -17416,35 +17336,6 @@ class YXmlEvent extends YEvent {
}
}
/**
* Dom filter function.
*
* @callback domFilter
* @param {string} nodeName The nodeName of the element
* @param {Map} attributes The map of attributes.
* @return {boolean} Whether to include the Dom node in the YXmlElement.
*/
/**
* Define the elements to which a set of CSS queries apply.
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}
*
* @example
* query = '.classSelector'
* query = 'nodeSelector'
* query = '#idSelector'
*
* @typedef {string} CSS_Selector
*/
/**
* Represents a list of {@link YXmlElement}.and {@link YXmlText} types.
* A YxmlFragment is similar to a {@link YXmlElement}, but it does not have a
* nodeName and it does not have attributes. Though it can be bound to a DOM
* element - in this case the attributes and the nodeName are not shared.
*
* @public
*/
class YXmlFragment extends YArray {
/**
* Create a subtree of childNodes.
@@ -17577,15 +17468,6 @@ class YXmlFragment extends YArray {
}
}
/**
* An YXmlElement imitates the behavior of a
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}.
*
* * An YXmlElement has attributes (key value pairs)
* * An YXmlElement has childElements that must inherit from YXmlElement
*
* @param {String} nodeName Node name
*/
class YXmlElement extends YXmlFragment {
constructor (nodeName = 'UNDEFINED') {
super();
@@ -17762,11 +17644,6 @@ class YXmlElement extends YXmlFragment {
}
}
/**
* You can manage binding to a custom type with YXmlHook.
*
* @public
*/
class YXmlHook extends YMap {
/**
* @param {String} hookName nodeName of the Dom Node.
@@ -17868,12 +17745,6 @@ class YXmlHook extends YMap {
}
}
/**
* Represents text in a Dom Element. In the future this type will also handle
* simple formatting information like bold and italic.
*
* @param {String} arg1 Initial value.
*/
class YXmlText extends YText {
/**
* Creates a Dom Element that mirrors this YXmlText.
@@ -18281,21 +18152,6 @@ function createMutualExclude () {
}
}
/**
* Abstract class for bindings.
*
* A binding handles data binding from a Yjs type to a data object. For example,
* you can bind a Quill editor instance to a YText instance with the `QuillBinding` class.
*
* It is expected that a concrete implementation accepts two parameters
* (type and binding target).
*
* @example
* const quill = new Quill(document.createElement('div'))
* const type = y.define('quill', Y.Text)
* const binding = new Y.QuillBinding(quill, type)
*
*/
class Binding {
/**
* @param {YType} type Yjs type.
@@ -18326,43 +18182,6 @@ class Binding {
}
}
// TODO: Implement function to describe ranges
/**
* A relative position that is based on the Yjs model. In contrast to an
* absolute position (position by index), the relative position can be
* recomputed when remote changes are received. For example:
*
* ```Insert(0, 'x')('a|bc') = 'xa|bc'``` Where | is the cursor position.
*
* A relative cursor position can be obtained with the function
* {@link getRelativePosition} and it can be transformed to an absolute position
* with {@link fromRelativePosition}.
*
* Pro tip: Use this to implement shared cursor locations in YText or YXml!
* The relative position is {@link encodable}, so you can send it to other
* clients.
*
* @example
* // Current cursor position is at position 10
* let relativePosition = getRelativePosition(yText, 10)
* // modify yText
* yText.insert(0, 'abc')
* yText.delete(3, 10)
* // Compute the cursor position
* let absolutePosition = fromRelativePosition(y, relativePosition)
* absolutePosition.type // => yText
* console.log('cursor location is ' + absolutePosition.offset) // => cursor location is 3
*
* @typedef {encodable} RelativePosition
*/
/**
* Create a relativePosition based on a absolute position.
*
* @param {YType} type The base type (e.g. YText or YArray).
* @param {Integer} offset The absolute position.
*/
function getRelativePosition (type, offset) {
// TODO: rename to createRelativePosition
let t = type._start;
@@ -18742,20 +18561,21 @@ function domObserver (mutations, _document) {
mutations.forEach(mutation => {
const dom = mutation.target;
const yxml = this.domToType.get(dom);
if (yxml === undefined) { // In case yxml is undefined, we double check if we forgot to bind the dom
let parent;
let yParent;
do {
parent = dom.parentNode;
yParent = this.domToType.get(parent);
} while (yParent === undefined && parent !== null)
if (yParent !== false && yParent !== undefined && yParent.constructor !== YXmlHook) {
diffChildren.add(parent);
if (yxml === false || yxml === undefined || yxml.constructor === YXmlHook) {
// dom element is filtered
if (yxml === undefined) { // In case yxml is undefined, we double check if we forgot to bind the dom
console.error('Yjs DomBinding: Reconstructing DomBinding, please report how to reproduce this.');
let parent;
let yParent;
do {
parent = dom.parentNode;
yParent = this.domToType.get(parent);
} while (yParent === undefined)
if (yParent !== false && yParent !== undefined && yParent.constructor !== YXmlHook) {
diffChildren.add(parent);
}
}
return
} else if (yxml === false || yxml.constructor === YXmlHook) {
// dom element is filtered / a dom hook
return
}
switch (mutation.type) {
case 'characterData':
@@ -18797,17 +18617,6 @@ function domObserver (mutations, _document) {
/* global MutationObserver */
/**
* A binding that binds the children of a YXmlFragment to a DOM element.
*
* This binding is automatically destroyed when its parent is deleted.
*
* @example
* const div = document.createElement('div')
* const type = y.define('xml', Y.XmlFragment)
* const binding = new Y.QuillBinding(type, div)
*
*/
class DomBinding extends Binding {
/**
* @param {YXmlFragment} type The bind source. This is the ultimate source of
@@ -18930,25 +18739,6 @@ class DomBinding extends Binding {
* @typedef {function(nodeName: String, attrs: Map): Map|null} FilterFunction
*/
/**
* Anything that can be encoded with `JSON.stringify` and can be decoded with
* `JSON.parse`.
*
* The following property should hold:
* `JSON.parse(JSON.stringify(key))===key`
*
* At the moment the only safe values are number and string.
*
* @typedef {(number|string)} encodable
*/
/**
* A Yjs instance handles the state of shared data.
*
* @param {string} room Users in the same room share the same content
* @param {Object} opts Connector definition
* @param {AbstractPersistence} persistence Persistence adapter instance
*/
class Y$1 extends NamedEventHandler {
constructor (room, opts, persistence, conf = {}) {
super();
@@ -19895,8 +19685,6 @@ var browser_5 = browser.useColors;
var browser_6 = browser.storage;
var browser_7 = browser.colors;
// TODO: rename Connector
class AbstractConnector {
constructor (y, opts) {
this.y = y;
@@ -20184,12 +19972,6 @@ class AbstractConnector {
}
}
/**
* Read the Decoder and fill the Yjs instance with data in the decoder.
*
* @param {Y} y The Yjs instance
* @param {BinaryDecoder} decoder The BinaryDecoder to read from.
*/
function fromBinary (y, decoder) {
y.transact(function () {
integrateRemoteStructs(y, decoder);
@@ -20432,7 +20214,6 @@ class QuillBinding extends Binding {
}
}
// TODO: The following assignments should be moved to yjs-dist
Y$1.AbstractConnector = AbstractConnector;
Y$1.AbstractPersistence = AbstractPersistence;
Y$1.Array = YArray;
@@ -20625,19 +20406,6 @@ class TestConnector extends AbstractConnector {
}
}
/**
* 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) {
const os = y.os;
if (os.length < 2) {

File diff suppressed because one or more lines are too long