yjs/docs/index.json
2018-04-27 18:45:01 +02:00

15220 lines
571 KiB
JSON

[
{
"__docId__": 1,
"kind": "external",
"name": "Infinity",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Infinity",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 2,
"kind": "external",
"name": "NaN",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~NaN",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 3,
"kind": "external",
"name": "undefined",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~undefined",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 4,
"kind": "external",
"name": "null",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~null",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 5,
"kind": "external",
"name": "Object",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Object",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 6,
"kind": "external",
"name": "object",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~object",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 7,
"kind": "external",
"name": "Function",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Function",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 8,
"kind": "external",
"name": "function",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~function",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 9,
"kind": "external",
"name": "Boolean",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Boolean",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 10,
"kind": "external",
"name": "boolean",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~boolean",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 11,
"kind": "external",
"name": "Symbol",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Symbol",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 12,
"kind": "external",
"name": "Error",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Error",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 13,
"kind": "external",
"name": "EvalError",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~EvalError",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 14,
"kind": "external",
"name": "InternalError",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/InternalError",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~InternalError",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 15,
"kind": "external",
"name": "RangeError",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~RangeError",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 16,
"kind": "external",
"name": "ReferenceError",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~ReferenceError",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 17,
"kind": "external",
"name": "SyntaxError",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~SyntaxError",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 18,
"kind": "external",
"name": "TypeError",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~TypeError",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 19,
"kind": "external",
"name": "URIError",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~URIError",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 20,
"kind": "external",
"name": "Number",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Number",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 21,
"kind": "external",
"name": "number",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~number",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 22,
"kind": "external",
"name": "Date",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Date",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 23,
"kind": "external",
"name": "String",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~String",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 24,
"kind": "external",
"name": "string",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~string",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 25,
"kind": "external",
"name": "RegExp",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~RegExp",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 26,
"kind": "external",
"name": "Array",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Array",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 27,
"kind": "external",
"name": "Int8Array",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Int8Array",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 28,
"kind": "external",
"name": "Uint8Array",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Uint8Array",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 29,
"kind": "external",
"name": "Uint8ClampedArray",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Uint8ClampedArray",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 30,
"kind": "external",
"name": "Int16Array",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Int16Array",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 31,
"kind": "external",
"name": "Uint16Array",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Uint16Array",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 32,
"kind": "external",
"name": "Int32Array",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Int32Array",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 33,
"kind": "external",
"name": "Uint32Array",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Uint32Array",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 34,
"kind": "external",
"name": "Float32Array",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Float32Array",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 35,
"kind": "external",
"name": "Float64Array",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Float64Array",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 36,
"kind": "external",
"name": "Map",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Map",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 37,
"kind": "external",
"name": "Set",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Set",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 38,
"kind": "external",
"name": "WeakMap",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~WeakMap",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 39,
"kind": "external",
"name": "WeakSet",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~WeakSet",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 40,
"kind": "external",
"name": "ArrayBuffer",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~ArrayBuffer",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 41,
"kind": "external",
"name": "DataView",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~DataView",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 42,
"kind": "external",
"name": "JSON",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~JSON",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 43,
"kind": "external",
"name": "Promise",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Promise",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 44,
"kind": "external",
"name": "Generator",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Generator",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 45,
"kind": "external",
"name": "GeneratorFunction",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~GeneratorFunction",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 46,
"kind": "external",
"name": "Reflect",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Reflect",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 47,
"kind": "external",
"name": "Proxy",
"externalLink": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy",
"memberof": "src/.external-ecmascript.js",
"static": true,
"longname": "src/.external-ecmascript.js~Proxy",
"access": "public",
"description": "",
"builtinExternal": true
},
{
"__docId__": 48,
"kind": "file",
"name": "src/Bindings/Binding.js",
"content": "\nimport { createMutualExclude } from '../Util/mutualExclude.js'\n\n/**\n * Abstract class for bindings.\n *\n * A binding handles data binding from a Yjs type to a data object. For example,\n * you can bind a Quill editor instance to a YText instance with the `QuillBinding` class.\n *\n * It is expected that a concrete implementation accepts two parameters\n * (type and binding target).\n *\n * @example\n * const quill = new Quill(document.createElement('div'))\n * const type = y.define('quill', Y.Text)\n * const binding = new Y.QuillBinding(quill, type)\n *\n */\nexport default class Binding {\n /**\n * @param {YType} type Yjs type.\n * @param {any} target Binding Target.\n */\n constructor (type, target) {\n /**\n * The Yjs type that is bound to `target`\n * @type {YType}\n */\n this.type = type\n /**\n * The target that `type` is bound to.\n * @type {*}\n */\n this.target = target\n /**\n * @private\n */\n this._mutualExclude = createMutualExclude()\n }\n /**\n * Remove all data observers (both from the type and the target).\n */\n destroy () {\n this.type = null\n this.target = null\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Bindings/Binding.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 49,
"kind": "class",
"name": "Binding",
"memberof": "src/Bindings/Binding.js",
"static": true,
"longname": "src/Bindings/Binding.js~Binding",
"access": "public",
"export": true,
"importPath": "yjs/src/Bindings/Binding.js",
"importStyle": "Binding",
"description": "Abstract class for bindings.\n\nA binding handles data binding from a Yjs type to a data object. For example,\nyou can bind a Quill editor instance to a YText instance with the `QuillBinding` class.\n\nIt is expected that a concrete implementation accepts two parameters\n(type and binding target).",
"examples": [
" const quill = new Quill(document.createElement('div'))\n const type = y.define('quill', Y.Text)\n const binding = new Y.QuillBinding(quill, type)"
],
"lineNumber": 19,
"interface": false
},
{
"__docId__": 50,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Bindings/Binding.js~Binding",
"generator": false,
"async": false,
"static": false,
"longname": "src/Bindings/Binding.js~Binding#constructor",
"access": "public",
"description": "",
"lineNumber": 24,
"params": [
{
"nullable": null,
"types": [
"YType"
],
"spread": false,
"optional": false,
"name": "type",
"description": "Yjs type."
},
{
"nullable": null,
"types": [
"any"
],
"spread": false,
"optional": false,
"name": "target",
"description": "Binding Target."
}
]
},
{
"__docId__": 51,
"kind": "member",
"name": "type",
"memberof": "src/Bindings/Binding.js~Binding",
"static": false,
"longname": "src/Bindings/Binding.js~Binding#type",
"access": "public",
"description": "The Yjs type that is bound to `target`",
"lineNumber": 29,
"type": {
"nullable": null,
"types": [
"YType"
],
"spread": false,
"description": null
}
},
{
"__docId__": 52,
"kind": "member",
"name": "target",
"memberof": "src/Bindings/Binding.js~Binding",
"static": false,
"longname": "src/Bindings/Binding.js~Binding#target",
"access": "public",
"description": "The target that `type` is bound to.",
"lineNumber": 34,
"type": {
"nullable": null,
"types": [
"*"
],
"spread": false,
"description": null
}
},
{
"__docId__": 53,
"kind": "member",
"name": "_mutualExclude",
"memberof": "src/Bindings/Binding.js~Binding",
"static": false,
"longname": "src/Bindings/Binding.js~Binding#_mutualExclude",
"access": "private",
"description": "",
"lineNumber": 38,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 54,
"kind": "method",
"name": "destroy",
"memberof": "src/Bindings/Binding.js~Binding",
"generator": false,
"async": false,
"static": false,
"longname": "src/Bindings/Binding.js~Binding#destroy",
"access": "public",
"description": "Remove all data observers (both from the type and the target).",
"lineNumber": 43,
"params": [],
"return": null
},
{
"__docId__": 57,
"kind": "file",
"name": "src/Bindings/DomBinding/DomBinding.js",
"content": "/* global MutationObserver */\n\nimport Binding from '../Binding.js'\nimport { createAssociation, removeAssociation } from './util.js'\nimport { beforeTransactionSelectionFixer, afterTransactionSelectionFixer } from './selection.js'\nimport { defaultFilter, applyFilterOnType } from './filter.js'\nimport typeObserver from './typeObserver.js'\nimport domObserver from './domObserver.js'\n\n/**\n * A binding that binds the children of a YXmlFragment to a DOM element.\n *\n * This binding is automatically destroyed when its parent is deleted.\n *\n * @example\n * const div = document.createElement('div')\n * const type = y.define('xml', Y.XmlFragment)\n * const binding = new Y.QuillBinding(type, div)\n *\n */\nexport default class DomBinding extends Binding {\n /**\n * @param {YXmlFragment} type The bind source. This is the ultimate source of\n * truth.\n * @param {Element} target The bind target. Mirrors the target.\n * @param {Object} [opts] Optional configurations\n\n * @param {FilterFunction} [opts.filter=defaultFilter] The filter function to use.\n */\n constructor (type, target, opts = {}) {\n // Binding handles textType as this.type and domTextarea as this.target\n super(type, target)\n this.opts = opts\n opts.document = opts.document || document\n opts.hooks = opts.hooks || {}\n /**\n * Maps each DOM element to the type that it is associated with.\n * @type {Map}\n */\n this.domToType = new Map()\n /**\n * Maps each YXml type to the DOM element that it is associated with.\n * @type {Map}\n */\n this.typeToDom = new Map()\n /**\n * Defines which DOM attributes and elements to filter out.\n * Also filters remote changes.\n * @type {FilterFunction}\n */\n this.filter = opts.filter || defaultFilter\n // set initial value\n target.innerHTML = ''\n type.forEach(child => {\n target.insertBefore(child.toDom(opts.document, opts.hooks, this), null)\n })\n this._typeObserver = typeObserver.bind(this)\n this._domObserver = (mutations) => {\n domObserver.call(this, mutations, opts.document)\n }\n type.observeDeep(this._typeObserver)\n this._mutationObserver = new MutationObserver(this._domObserver)\n this._mutationObserver.observe(target, {\n childList: true,\n attributes: true,\n characterData: true,\n subtree: true\n })\n const y = type._y\n // Force flush dom changes before Type changes are applied (they might\n // modify the dom)\n this._beforeTransactionHandler = (y, transaction, remote) => {\n this._domObserver(this._mutationObserver.takeRecords())\n beforeTransactionSelectionFixer(y, this, transaction, remote)\n }\n y.on('beforeTransaction', this._beforeTransactionHandler)\n this._afterTransactionHandler = (y, transaction, remote) => {\n afterTransactionSelectionFixer(y, this, transaction, remote)\n // remove associations\n // TODO: this could be done more efficiently\n // e.g. Always delete using the following approach, or removeAssociation\n // in dom/type-observer..\n transaction.deletedStructs.forEach(type => {\n const dom = this.typeToDom.get(type)\n if (dom !== undefined) {\n removeAssociation(this, dom, type)\n }\n })\n }\n y.on('afterTransaction', this._afterTransactionHandler)\n // Before calling observers, apply dom filter to all changed and new types.\n this._beforeObserverCallsHandler = (y, transaction) => {\n // Apply dom filter to new and changed types\n transaction.changedTypes.forEach((subs, type) => {\n // Only check attributes. New types are filtered below.\n if ((subs.size > 1 || (subs.size === 1 && subs.has(null) === false))) {\n applyFilterOnType(y, this, type)\n }\n })\n transaction.newTypes.forEach(type => {\n applyFilterOnType(y, this, type)\n })\n }\n y.on('beforeObserverCalls', this._beforeObserverCallsHandler)\n createAssociation(this, target, type)\n }\n\n /**\n * Enables the smart scrolling functionality for a Dom Binding.\n * This is useful when YXml is bound to a shared editor. When activated,\n * the viewport will be changed to accommodate remote changes.\n *\n * @param {Element} scrollElement The node that is\n */\n enableSmartScrolling (scrollElement) {\n // @TODO: implement smart scrolling\n }\n\n /**\n * NOTE: currently does not apply filter to existing elements!\n * @param {FilterFunction} filter The filter function to use from now on.\n */\n setFilter (filter) {\n this.filter = filter\n // TODO: apply filter to all elements\n }\n\n /**\n * Remove all properties that are handled by this class.\n */\n destroy () {\n this.domToType = null\n this.typeToDom = null\n this.type.unobserve(this._typeObserver)\n this._mutationObserver.disconnect()\n const y = this.type._y\n y.off('beforeTransaction', this._beforeTransactionHandler)\n y.off('beforeObserverCalls', this._beforeObserverCallsHandler)\n y.off('afterObserverCalls', this._afterObserverCallsHandler)\n y.off('afterTransaction', this._afterTransactionHandler)\n super.destroy()\n }\n}\n\n /**\n * A filter defines which elements and attributes to share.\n * Return null if the node should be filtered. Otherwise return the Map of\n * accepted attributes.\n *\n * @typedef {function(nodeName: String, attrs: Map): Map|null} FilterFunction\n */\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Bindings/DomBinding/DomBinding.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 58,
"kind": "class",
"name": "DomBinding",
"memberof": "src/Bindings/DomBinding/DomBinding.js",
"static": true,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"access": "public",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/DomBinding.js",
"importStyle": "DomBinding",
"description": "A binding that binds the children of a YXmlFragment to a DOM element.\n\nThis binding is automatically destroyed when its parent is deleted.",
"examples": [
"const div = document.createElement('div')\nconst type = y.define('xml', Y.XmlFragment)\nconst binding = new Y.QuillBinding(type, div)"
],
"lineNumber": 21,
"interface": false,
"extends": [
"src/Bindings/Binding.js~Binding"
]
},
{
"__docId__": 59,
"kind": "typedef",
"name": "FilterFunction",
"memberof": "src/Bindings/DomBinding/DomBinding.js",
"static": true,
"longname": "src/Bindings/DomBinding/DomBinding.js~FilterFunction",
"access": "public",
"description": "A filter defines which elements and attributes to share.\nReturn null if the node should be filtered. Otherwise return the Map of\naccepted attributes.",
"type": {
"types": [
"function(nodeName: String, attrs: Map): Map",
"null"
],
"optional": false,
"name": "FilterFunction"
}
},
{
"__docId__": 60,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"generator": false,
"async": false,
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#constructor",
"access": "public",
"description": "",
"lineNumber": 30,
"params": [
{
"nullable": null,
"types": [
"YXmlFragment"
],
"spread": false,
"optional": false,
"name": "type",
"description": "The bind source. This is the ultimate source of\n truth."
},
{
"nullable": null,
"types": [
"Element"
],
"spread": false,
"optional": false,
"name": "target",
"description": "The bind target. Mirrors the target."
},
{
"nullable": null,
"types": [
"Object"
],
"spread": false,
"optional": true,
"name": "opts",
"description": "Optional configurations"
},
{
"nullable": null,
"types": [
"FilterFunction"
],
"spread": false,
"optional": true,
"defaultValue": "defaultFilter",
"defaultRaw": "defaultFilter",
"name": "opts.filter",
"description": "The filter function to use."
}
]
},
{
"__docId__": 61,
"kind": "member",
"name": "opts",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#opts",
"access": "public",
"description": null,
"lineNumber": 33,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 62,
"kind": "member",
"name": "domToType",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#domToType",
"access": "public",
"description": "Maps each DOM element to the type that it is associated with.",
"lineNumber": 40,
"type": {
"nullable": null,
"types": [
"Map"
],
"spread": false,
"description": null
}
},
{
"__docId__": 63,
"kind": "member",
"name": "typeToDom",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#typeToDom",
"access": "public",
"description": "Maps each YXml type to the DOM element that it is associated with.",
"lineNumber": 45,
"type": {
"nullable": null,
"types": [
"Map"
],
"spread": false,
"description": null
}
},
{
"__docId__": 64,
"kind": "member",
"name": "filter",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#filter",
"access": "public",
"description": "Defines which DOM attributes and elements to filter out.\nAlso filters remote changes.",
"lineNumber": 51,
"type": {
"nullable": null,
"types": [
"FilterFunction"
],
"spread": false,
"description": null
}
},
{
"__docId__": 65,
"kind": "member",
"name": "_typeObserver",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#_typeObserver",
"access": "private",
"description": null,
"lineNumber": 57,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 66,
"kind": "member",
"name": "_domObserver",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#_domObserver",
"access": "private",
"description": null,
"lineNumber": 58,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 67,
"kind": "member",
"name": "_mutationObserver",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#_mutationObserver",
"access": "private",
"description": null,
"lineNumber": 62,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 68,
"kind": "member",
"name": "_beforeTransactionHandler",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#_beforeTransactionHandler",
"access": "private",
"description": null,
"lineNumber": 72,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 69,
"kind": "member",
"name": "_afterTransactionHandler",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#_afterTransactionHandler",
"access": "private",
"description": null,
"lineNumber": 77,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 70,
"kind": "member",
"name": "_beforeObserverCallsHandler",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#_beforeObserverCallsHandler",
"access": "private",
"description": null,
"lineNumber": 92,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 71,
"kind": "method",
"name": "enableSmartScrolling",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"generator": false,
"async": false,
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#enableSmartScrolling",
"access": "public",
"description": "Enables the smart scrolling functionality for a Dom Binding.\nThis is useful when YXml is bound to a shared editor. When activated,\nthe viewport will be changed to accommodate remote changes.",
"lineNumber": 115,
"params": [
{
"nullable": null,
"types": [
"Element"
],
"spread": false,
"optional": false,
"name": "scrollElement",
"description": "The node that is"
}
],
"return": null
},
{
"__docId__": 72,
"kind": "method",
"name": "setFilter",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"generator": false,
"async": false,
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#setFilter",
"access": "public",
"description": "NOTE: currently does not apply filter to existing elements!",
"lineNumber": 123,
"params": [
{
"nullable": null,
"types": [
"FilterFunction"
],
"spread": false,
"optional": false,
"name": "filter",
"description": "The filter function to use from now on."
}
],
"return": null
},
{
"__docId__": 74,
"kind": "method",
"name": "destroy",
"memberof": "src/Bindings/DomBinding/DomBinding.js~DomBinding",
"generator": false,
"async": false,
"static": false,
"longname": "src/Bindings/DomBinding/DomBinding.js~DomBinding#destroy",
"access": "public",
"description": "Remove all properties that are handled by this class.",
"lineNumber": 131,
"params": [],
"return": null
},
{
"__docId__": 77,
"kind": "file",
"name": "src/Bindings/DomBinding/domObserver.js",
"content": "\nimport YXmlHook from '../../Types/YXml/YXmlHook.js'\nimport {\n iterateUntilUndeleted,\n removeAssociation,\n insertNodeHelper } from './util.js'\nimport diff from '../../Util/simpleDiff.js'\nimport YXmlFragment from '../../Types/YXml/YXmlFragment.js'\n\n/**\n * 1. Check if any of the nodes was deleted\n * 2. Iterate over the children.\n * 2.1 If a node exists that is not yet bound to a type, insert a new node\n * 2.2 If _contents.length < dom.childNodes.length, fill the\n * rest of _content with childNodes\n * 2.3 If a node was moved, delete it and\n * recreate a new yxml element that is bound to that node.\n * You can detect that a node was moved because expectedId\n * !== actualId in the list\n * @private\n */\nfunction applyChangesFromDom (binding, dom, yxml, _document) {\n if (yxml == null || yxml === false || yxml.constructor === YXmlHook) {\n return\n }\n const y = yxml._y\n const knownChildren = new Set()\n for (let i = dom.childNodes.length - 1; i >= 0; i--) {\n const type = binding.domToType.get(dom.childNodes[i])\n if (type !== undefined && type !== false) {\n knownChildren.add(type)\n }\n }\n // 1. Check if any of the nodes was deleted\n yxml.forEach(function (childType) {\n if (knownChildren.has(childType) === false) {\n childType._delete(y)\n removeAssociation(binding, binding.typeToDom.get(childType), childType)\n }\n })\n // 2. iterate\n const childNodes = dom.childNodes\n const len = childNodes.length\n let prevExpectedType = null\n let expectedType = iterateUntilUndeleted(yxml._start)\n for (let domCnt = 0; domCnt < len; domCnt++) {\n const childNode = childNodes[domCnt]\n const childType = binding.domToType.get(childNode)\n if (childType !== undefined) {\n if (childType === false) {\n // should be ignored or is going to be deleted\n continue\n }\n if (expectedType !== null) {\n if (expectedType !== childType) {\n // 2.3 Not expected node\n if (childType._parent !== yxml) {\n // child was moved from another parent\n // childType is going to be deleted by its previous parent\n removeAssociation(binding, childNode, childType)\n } else {\n // child was moved to a different position.\n childType._delete(y)\n removeAssociation(binding, childNode, childType)\n }\n prevExpectedType = insertNodeHelper(yxml, prevExpectedType, childNode, _document, binding)\n } else {\n // Found expected node. Continue.\n prevExpectedType = expectedType\n expectedType = iterateUntilUndeleted(expectedType._right)\n }\n } else {\n // 2.2 Fill _content with child nodes\n prevExpectedType = insertNodeHelper(yxml, prevExpectedType, childNode, _document, binding)\n }\n } else {\n // 2.1 A new node was found\n prevExpectedType = insertNodeHelper(yxml, prevExpectedType, childNode, _document, binding)\n }\n }\n}\n\n/**\n * @private\n */\nexport default function domObserver (mutations, _document) {\n this._mutualExclude(() => {\n this.type._y.transact(() => {\n let diffChildren = new Set()\n mutations.forEach(mutation => {\n const dom = mutation.target\n const yxml = this.domToType.get(dom)\n if (yxml === false || yxml === undefined || yxml.constructor === YXmlHook) {\n // dom element is filtered\n return\n }\n switch (mutation.type) {\n case 'characterData':\n var change = diff(yxml.toString(), dom.nodeValue)\n yxml.delete(change.pos, change.remove)\n yxml.insert(change.pos, change.insert)\n break\n case 'attributes':\n if (yxml.constructor === YXmlFragment) {\n break\n }\n let name = mutation.attributeName\n let val = dom.getAttribute(name)\n // check if filter accepts attribute\n let attributes = new Map()\n attributes.set(name, val)\n if (yxml.constructor !== YXmlFragment && this.filter(dom.nodeName, attributes).size > 0) {\n if (yxml.getAttribute(name) !== val) {\n if (val == null) {\n yxml.removeAttribute(name)\n } else {\n yxml.setAttribute(name, val)\n }\n }\n }\n break\n case 'childList':\n diffChildren.add(mutation.target)\n break\n }\n })\n for (let dom of diffChildren) {\n if (dom.yOnChildrenChanged !== undefined) {\n dom.yOnChildrenChanged()\n }\n const yxml = this.domToType.get(dom)\n applyChangesFromDom(this, dom, yxml, _document)\n }\n })\n })\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Bindings/DomBinding/domObserver.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 78,
"kind": "function",
"name": "applyChangesFromDom",
"memberof": "src/Bindings/DomBinding/domObserver.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/domObserver.js~applyChangesFromDom",
"access": "private",
"export": false,
"importPath": "yjs/src/Bindings/DomBinding/domObserver.js",
"importStyle": null,
"description": "1. Check if any of the nodes was deleted\n2. Iterate over the children.\n 2.1 If a node exists that is not yet bound to a type, insert a new node\n 2.2 If _contents.length < dom.childNodes.length, fill the\n rest of _content with childNodes\n 2.3 If a node was moved, delete it and\n recreate a new yxml element that is bound to that node.\n You can detect that a node was moved because expectedId\n !== actualId in the list",
"lineNumber": 22,
"ignore": true,
"params": [
{
"name": "binding",
"types": [
"*"
]
},
{
"name": "dom",
"types": [
"*"
]
},
{
"name": "yxml",
"types": [
"*"
]
},
{
"name": "_document",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 79,
"kind": "function",
"name": "domObserver",
"memberof": "src/Bindings/DomBinding/domObserver.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/domObserver.js~domObserver",
"access": "private",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/domObserver.js",
"importStyle": "domObserver",
"description": "",
"lineNumber": 86,
"ignore": true,
"params": [
{
"name": "mutations",
"types": [
"*"
]
},
{
"name": "_document",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 80,
"kind": "file",
"name": "src/Bindings/DomBinding/domToType.js",
"content": "\nimport { YXmlText, YXmlElement, YXmlHook } from '../../Types/YXml/YXml.js'\nimport { createAssociation, domsToTypes } from './util.js'\nimport { filterDomAttributes, defaultFilter } from './filter.js'\n\n/**\n * Creates a Yjs type (YXml) based on the contents of a DOM Element.\n *\n * @param {Element|TextNode} element The DOM Element\n * @param {?Document} _document Optional. Provide the global document object\n * @param {Hooks} [hooks = {}] Optional. Set of Yjs Hooks\n * @param {Filter} [filter=defaultFilter] Optional. Dom element filter\n * @param {?DomBinding} binding Warning: This property is for internal use only!\n * @return {YXmlElement | YXmlText}\n */\nexport default function domToType (element, _document = document, hooks = {}, filter = defaultFilter, binding) {\n let type\n switch (element.nodeType) {\n case _document.ELEMENT_NODE:\n let hookName = null\n let hook\n // configure `hookName !== undefined` if element is a hook.\n if (element.hasAttribute('data-yjs-hook')) {\n hookName = element.getAttribute('data-yjs-hook')\n hook = hooks[hookName]\n if (hook === undefined) {\n console.error(`Unknown hook \"${hookName}\". Deleting yjsHook dataset property.`)\n delete element.removeAttribute('data-yjs-hook')\n hookName = null\n }\n }\n if (hookName === null) {\n // Not a hook\n const attrs = filterDomAttributes(element, filter)\n if (attrs === null) {\n type = false\n } else {\n type = new YXmlElement(element.nodeName)\n attrs.forEach((val, key) => {\n type.setAttribute(key, val)\n })\n type.insert(0, domsToTypes(element.childNodes, document, hooks, filter, binding))\n }\n } else {\n // Is a hook\n type = new YXmlHook(hookName)\n hook.fillType(element, type)\n }\n break\n case _document.TEXT_NODE:\n type = new YXmlText()\n type.insert(0, element.nodeValue)\n break\n default:\n throw new Error('Can\\'t transform this node type to a YXml type!')\n }\n createAssociation(binding, element, type)\n return type\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Bindings/DomBinding/domToType.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 81,
"kind": "function",
"name": "domToType",
"memberof": "src/Bindings/DomBinding/domToType.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/domToType.js~domToType",
"access": "public",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/domToType.js",
"importStyle": "domToType",
"description": "Creates a Yjs type (YXml) based on the contents of a DOM Element.",
"lineNumber": 16,
"params": [
{
"nullable": null,
"types": [
"Element",
"TextNode"
],
"spread": false,
"optional": false,
"name": "element",
"description": "The DOM Element"
},
{
"nullable": true,
"types": [
"Document"
],
"spread": false,
"optional": false,
"name": "_document",
"description": "Optional. Provide the global document object"
},
{
"nullable": null,
"types": [
"Hooks"
],
"spread": false,
"optional": true,
"defaultValue": " {}",
"defaultRaw": {},
"name": "hooks",
"description": "Optional. Set of Yjs Hooks"
},
{
"nullable": null,
"types": [
"Filter"
],
"spread": false,
"optional": true,
"defaultValue": "defaultFilter",
"defaultRaw": "defaultFilter",
"name": "filter",
"description": "Optional. Dom element filter"
},
{
"nullable": true,
"types": [
"DomBinding"
],
"spread": false,
"optional": false,
"name": "binding",
"description": "Warning: This property is for internal use only!"
}
],
"return": {
"nullable": null,
"types": [
"YXmlElement ",
" YXmlText"
],
"spread": false,
"description": ""
}
},
{
"__docId__": 82,
"kind": "file",
"name": "src/Bindings/DomBinding/filter.js",
"content": "import isParentOf from '../../Util/isParentOf.js'\n\n/**\n * Default filter method (does nothing).\n *\n * @param {String} nodeName The nodeName of the element\n * @param {Map} attrs Map of key-value pairs that are attributes of the node.\n * @return {Map | null} The allowed attributes or null, if the element should be\n * filtered.\n */\nexport function defaultFilter (nodeName, attrs) {\n // TODO: implement basic filter that filters out dangerous properties!\n return attrs\n}\n\n/**\n *\n */\nexport function filterDomAttributes (dom, filter) {\n const attrs = new Map()\n for (let i = dom.attributes.length - 1; i >= 0; i--) {\n const attr = dom.attributes[i]\n attrs.set(attr.name, attr.value)\n }\n return filter(dom.nodeName, attrs)\n}\n\n/**\n * Applies a filter on a type.\n *\n * @param {Y} y The Yjs instance.\n * @param {DomBinding} binding The DOM binding instance that has the dom filter.\n * @param {YXmlElement | YXmlFragment } type The type to apply the filter to.\n *\n * @private\n */\nexport function applyFilterOnType (y, binding, type) {\n if (isParentOf(binding.type, type)) {\n const nodeName = type.nodeName\n let attributes = new Map()\n if (type.getAttributes !== undefined) {\n let attrs = type.getAttributes()\n for (let key in attrs) {\n attributes.set(key, attrs[key])\n }\n }\n const filteredAttributes = binding.filter(nodeName, new Map(attributes))\n if (filteredAttributes === null) {\n type._delete(y)\n } else {\n // iterate original attributes\n attributes.forEach((value, key) => {\n // delete all attributes that are not in filteredAttributes\n if (filteredAttributes.has(key) === false) {\n type.removeAttribute(key)\n }\n })\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Bindings/DomBinding/filter.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 83,
"kind": "function",
"name": "defaultFilter",
"memberof": "src/Bindings/DomBinding/filter.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/filter.js~defaultFilter",
"access": "public",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/filter.js",
"importStyle": "{defaultFilter}",
"description": "Default filter method (does nothing).",
"lineNumber": 11,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "nodeName",
"description": "The nodeName of the element"
},
{
"nullable": null,
"types": [
"Map"
],
"spread": false,
"optional": false,
"name": "attrs",
"description": "Map of key-value pairs that are attributes of the node."
}
],
"return": {
"nullable": null,
"types": [
"Map ",
" null"
],
"spread": false,
"description": "The allowed attributes or null, if the element should be\n filtered."
}
},
{
"__docId__": 84,
"kind": "function",
"name": "filterDomAttributes",
"memberof": "src/Bindings/DomBinding/filter.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/filter.js~filterDomAttributes",
"access": "public",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/filter.js",
"importStyle": "{filterDomAttributes}",
"description": "",
"lineNumber": 19,
"params": [
{
"name": "dom",
"types": [
"*"
]
},
{
"name": "filter",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 85,
"kind": "function",
"name": "applyFilterOnType",
"memberof": "src/Bindings/DomBinding/filter.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/filter.js~applyFilterOnType",
"access": "private",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/filter.js",
"importStyle": "{applyFilterOnType}",
"description": "Applies a filter on a type.",
"lineNumber": 37,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance."
},
{
"nullable": null,
"types": [
"DomBinding"
],
"spread": false,
"optional": false,
"name": "binding",
"description": "The DOM binding instance that has the dom filter."
},
{
"nullable": null,
"types": [
"YXmlElement ",
" YXmlFragment "
],
"spread": false,
"optional": false,
"name": "type",
"description": "The type to apply the filter to."
}
],
"ignore": true,
"return": null
},
{
"__docId__": 86,
"kind": "file",
"name": "src/Bindings/DomBinding/selection.js",
"content": "/* globals getSelection */\n\nimport { getRelativePosition, fromRelativePosition } from '../../Util/relativePosition.js'\n\nlet browserSelection = null\nlet relativeSelection = null\n\n/**\n * @private\n */\nexport let beforeTransactionSelectionFixer\nif (typeof getSelection !== 'undefined') {\n beforeTransactionSelectionFixer = function _beforeTransactionSelectionFixer (y, domBinding, transaction, remote) {\n if (!remote) {\n return\n }\n relativeSelection = { from: null, to: null, fromY: null, toY: null }\n browserSelection = getSelection()\n const anchorNode = browserSelection.anchorNode\n const anchorNodeType = domBinding.domToType.get(anchorNode)\n if (anchorNode !== null && anchorNodeType !== undefined) {\n relativeSelection.from = getRelativePosition(anchorNodeType, browserSelection.anchorOffset)\n relativeSelection.fromY = anchorNodeType._y\n }\n const focusNode = browserSelection.focusNode\n const focusNodeType = domBinding.domToType.get(focusNode)\n if (focusNode !== null && focusNodeType !== undefined) {\n relativeSelection.to = getRelativePosition(focusNodeType, browserSelection.focusOffset)\n relativeSelection.toY = focusNodeType._y\n }\n }\n} else {\n beforeTransactionSelectionFixer = function _fakeBeforeTransactionSelectionFixer () {}\n}\n\n/**\n * @private\n */\nexport function afterTransactionSelectionFixer (y, domBinding, transaction, remote) {\n if (relativeSelection === null || !remote) {\n return\n }\n const to = relativeSelection.to\n const from = relativeSelection.from\n const fromY = relativeSelection.fromY\n const toY = relativeSelection.toY\n let shouldUpdate = false\n let anchorNode = browserSelection.anchorNode\n let anchorOffset = browserSelection.anchorOffset\n let focusNode = browserSelection.focusNode\n let focusOffset = browserSelection.focusOffset\n if (from !== null) {\n let sel = fromRelativePosition(fromY, from)\n if (sel !== null) {\n let node = domBinding.typeToDom.get(sel.type)\n let offset = sel.offset\n if (node !== anchorNode || offset !== anchorOffset) {\n anchorNode = node\n anchorOffset = offset\n shouldUpdate = true\n }\n }\n }\n if (to !== null) {\n let sel = fromRelativePosition(toY, to)\n if (sel !== null) {\n let node = domBinding.typeToDom.get(sel.type)\n let offset = sel.offset\n if (node !== focusNode || offset !== focusOffset) {\n focusNode = node\n focusOffset = offset\n shouldUpdate = true\n }\n }\n }\n if (shouldUpdate) {\n browserSelection.setBaseAndExtent(\n anchorNode,\n anchorOffset,\n focusNode,\n focusOffset\n )\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Bindings/DomBinding/selection.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 87,
"kind": "variable",
"name": "browserSelection",
"memberof": "src/Bindings/DomBinding/selection.js",
"static": true,
"longname": "src/Bindings/DomBinding/selection.js~browserSelection",
"access": "public",
"export": false,
"importPath": "yjs/src/Bindings/DomBinding/selection.js",
"importStyle": null,
"description": null,
"lineNumber": 5,
"undocument": true,
"type": {
"types": [
"*"
]
},
"ignore": true
},
{
"__docId__": 88,
"kind": "variable",
"name": "relativeSelection",
"memberof": "src/Bindings/DomBinding/selection.js",
"static": true,
"longname": "src/Bindings/DomBinding/selection.js~relativeSelection",
"access": "public",
"export": false,
"importPath": "yjs/src/Bindings/DomBinding/selection.js",
"importStyle": null,
"description": null,
"lineNumber": 6,
"undocument": true,
"type": {
"types": [
"*"
]
},
"ignore": true
},
{
"__docId__": 89,
"kind": "function",
"name": "afterTransactionSelectionFixer",
"memberof": "src/Bindings/DomBinding/selection.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/selection.js~afterTransactionSelectionFixer",
"access": "private",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/selection.js",
"importStyle": "{afterTransactionSelectionFixer}",
"description": "",
"lineNumber": 39,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "domBinding",
"types": [
"*"
]
},
{
"name": "transaction",
"types": [
"*"
]
},
{
"name": "remote",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 90,
"kind": "file",
"name": "src/Bindings/DomBinding/typeObserver.js",
"content": "\nimport YXmlText from '../../Types/YXml/YXmlText.js'\nimport YXmlHook from '../../Types/YXml/YXmlHook.js'\nimport { removeDomChildrenUntilElementFound } from './util.js'\n\n/**\n * @private\n */\nexport default function typeObserver (events) {\n this._mutualExclude(() => {\n events.forEach(event => {\n const yxml = event.target\n const dom = this.typeToDom.get(yxml)\n if (dom !== undefined && dom !== false) {\n if (yxml.constructor === YXmlText) {\n dom.nodeValue = yxml.toString()\n // TODO: use hasOwnProperty instead of === undefined check\n } else if (event.attributesChanged !== undefined) {\n // update attributes\n event.attributesChanged.forEach(attributeName => {\n const value = yxml.getAttribute(attributeName)\n if (value === undefined) {\n dom.removeAttribute(attributeName)\n } else {\n dom.setAttribute(attributeName, value)\n }\n })\n /*\n * TODO: instead of hard-checking the types, it would be best to\n * specify the type's features. E.g.\n * - _yxmlHasAttributes\n * - _yxmlHasChildren\n * Furthermore, the features shouldn't be encoded in the types,\n * only in the attributes (above)\n */\n if (event.childListChanged && yxml.constructor !== YXmlHook) {\n let currentChild = dom.firstChild\n yxml.forEach(childType => {\n const childNode = this.typeToDom.get(childType)\n switch (childNode) {\n case undefined:\n // Does not exist. Create it.\n const node = childType.toDom(this.opts.document, this.opts.hooks, this)\n dom.insertBefore(node, currentChild)\n break\n case false:\n // nop\n break\n default:\n // Is already attached to the dom.\n // Find it and remove all dom nodes in-between.\n removeDomChildrenUntilElementFound(dom, currentChild, childNode)\n currentChild = childNode.nextSibling\n break\n }\n })\n removeDomChildrenUntilElementFound(dom, currentChild, null)\n }\n }\n }\n })\n })\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Bindings/DomBinding/typeObserver.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 91,
"kind": "function",
"name": "typeObserver",
"memberof": "src/Bindings/DomBinding/typeObserver.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/typeObserver.js~typeObserver",
"access": "private",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/typeObserver.js",
"importStyle": "typeObserver",
"description": "",
"lineNumber": 9,
"ignore": true,
"params": [
{
"name": "events",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 92,
"kind": "file",
"name": "src/Bindings/DomBinding/util.js",
"content": "\nimport domToType from './domToType.js'\n\n/**\n * Iterates items until an undeleted item is found.\n *\n * @private\n */\nexport function iterateUntilUndeleted (item) {\n while (item !== null && item._deleted) {\n item = item._right\n }\n return item\n}\n\n/**\n * Removes an association (the information that a DOM element belongs to a\n * type).\n *\n * @param {DomBinding} domBinding The binding object\n * @param {Element} dom The dom that is to be associated with type\n * @param {YXmlElement|YXmlHook} type The type that is to be associated with dom\n *\n */\nexport function removeAssociation (domBinding, dom, type) {\n domBinding.domToType.delete(dom)\n domBinding.typeToDom.delete(type)\n}\n\n/**\n * Creates an association (the information that a DOM element belongs to a\n * type).\n *\n * @param {DomBinding} domBinding The binding object\n * @param {Element} dom The dom that is to be associated with type\n * @param {YXmlElement|YXmlHook} type The type that is to be associated with dom\n *\n */\nexport function createAssociation (domBinding, dom, type) {\n if (domBinding !== undefined) {\n domBinding.domToType.set(dom, type)\n domBinding.typeToDom.set(type, dom)\n }\n}\n\n/**\n * If oldDom is associated with a type, associate newDom with the type and\n * forget about oldDom. If oldDom is not associated with any type, nothing happens.\n *\n * @param {DomBinding} domBinding The binding object\n * @param {Element} oldDom The existing dom\n * @param {Element} newDom The new dom object\n */\nexport function switchAssociation (domBinding, oldDom, newDom) {\n if (domBinding !== undefined) {\n const type = domBinding.domToType.get(oldDom)\n if (type !== undefined) {\n removeAssociation(domBinding, oldDom, type)\n createAssociation(domBinding, newDom, type)\n }\n }\n}\n\n/**\n * Insert Dom Elements after one of the children of this YXmlFragment.\n * The Dom elements will be bound to a new YXmlElement and inserted at the\n * specified position.\n *\n * @param {YXmlElement} type The type in which to insert DOM elements.\n * @param {YXmlElement|null} prev The reference node. New YxmlElements are\n * inserted after this node. Set null to insert at\n * the beginning.\n * @param {Array<Element>} doms The Dom elements to insert.\n * @param {?Document} _document Optional. Provide the global document object.\n * @param {DomBinding} binding The dom binding\n * @return {Array<YXmlElement>} The YxmlElements that are inserted.\n *\n * @private\n */\nexport function insertDomElementsAfter (type, prev, doms, _document, binding) {\n const types = domsToTypes(doms, _document, binding.opts.hooks, binding.filter, binding)\n return type.insertAfter(prev, types)\n}\n\nexport function domsToTypes (doms, _document, hooks, filter, binding) {\n const types = []\n for (let dom of doms) {\n const t = domToType(dom, _document, hooks, filter, binding)\n if (t !== false) {\n types.push(t)\n }\n }\n return types\n}\n\n/**\n * @private\n */\nexport function insertNodeHelper (yxml, prevExpectedNode, child, _document, binding) {\n let insertedNodes = insertDomElementsAfter(yxml, prevExpectedNode, [child], _document, binding)\n if (insertedNodes.length > 0) {\n return insertedNodes[0]\n } else {\n return prevExpectedNode\n }\n}\n\n/**\n * Remove children until `elem` is found.\n *\n * @param {Element} parent The parent of `elem` and `currentChild`.\n * @param {Element} currentChild Start removing elements with `currentChild`. If\n * `currentChild` is `elem` it won't be removed.\n * @param {Element|null} elem The elemnt to look for.\n *\n * @private\n */\nexport function removeDomChildrenUntilElementFound (parent, currentChild, elem) {\n while (currentChild !== elem) {\n const del = currentChild\n currentChild = currentChild.nextSibling\n parent.removeChild(del)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Bindings/DomBinding/util.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 93,
"kind": "function",
"name": "iterateUntilUndeleted",
"memberof": "src/Bindings/DomBinding/util.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/util.js~iterateUntilUndeleted",
"access": "private",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/util.js",
"importStyle": "{iterateUntilUndeleted}",
"description": "Iterates items until an undeleted item is found.",
"lineNumber": 9,
"ignore": true,
"params": [
{
"name": "item",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 94,
"kind": "function",
"name": "removeAssociation",
"memberof": "src/Bindings/DomBinding/util.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/util.js~removeAssociation",
"access": "public",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/util.js",
"importStyle": "{removeAssociation}",
"description": "Removes an association (the information that a DOM element belongs to a\ntype).",
"lineNumber": 25,
"params": [
{
"nullable": null,
"types": [
"DomBinding"
],
"spread": false,
"optional": false,
"name": "domBinding",
"description": "The binding object"
},
{
"nullable": null,
"types": [
"Element"
],
"spread": false,
"optional": false,
"name": "dom",
"description": "The dom that is to be associated with type"
},
{
"nullable": null,
"types": [
"YXmlElement",
"YXmlHook"
],
"spread": false,
"optional": false,
"name": "type",
"description": "The type that is to be associated with dom"
}
],
"return": null
},
{
"__docId__": 95,
"kind": "function",
"name": "createAssociation",
"memberof": "src/Bindings/DomBinding/util.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/util.js~createAssociation",
"access": "public",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/util.js",
"importStyle": "{createAssociation}",
"description": "Creates an association (the information that a DOM element belongs to a\ntype).",
"lineNumber": 39,
"params": [
{
"nullable": null,
"types": [
"DomBinding"
],
"spread": false,
"optional": false,
"name": "domBinding",
"description": "The binding object"
},
{
"nullable": null,
"types": [
"Element"
],
"spread": false,
"optional": false,
"name": "dom",
"description": "The dom that is to be associated with type"
},
{
"nullable": null,
"types": [
"YXmlElement",
"YXmlHook"
],
"spread": false,
"optional": false,
"name": "type",
"description": "The type that is to be associated with dom"
}
],
"return": null
},
{
"__docId__": 96,
"kind": "function",
"name": "switchAssociation",
"memberof": "src/Bindings/DomBinding/util.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/util.js~switchAssociation",
"access": "public",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/util.js",
"importStyle": "{switchAssociation}",
"description": "If oldDom is associated with a type, associate newDom with the type and\nforget about oldDom. If oldDom is not associated with any type, nothing happens.",
"lineNumber": 54,
"params": [
{
"nullable": null,
"types": [
"DomBinding"
],
"spread": false,
"optional": false,
"name": "domBinding",
"description": "The binding object"
},
{
"nullable": null,
"types": [
"Element"
],
"spread": false,
"optional": false,
"name": "oldDom",
"description": "The existing dom"
},
{
"nullable": null,
"types": [
"Element"
],
"spread": false,
"optional": false,
"name": "newDom",
"description": "The new dom object"
}
],
"return": null
},
{
"__docId__": 97,
"kind": "function",
"name": "insertDomElementsAfter",
"memberof": "src/Bindings/DomBinding/util.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/util.js~insertDomElementsAfter",
"access": "private",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/util.js",
"importStyle": "{insertDomElementsAfter}",
"description": "Insert Dom Elements after one of the children of this YXmlFragment.\nThe Dom elements will be bound to a new YXmlElement and inserted at the\nspecified position.",
"lineNumber": 80,
"params": [
{
"nullable": null,
"types": [
"YXmlElement"
],
"spread": false,
"optional": false,
"name": "type",
"description": "The type in which to insert DOM elements."
},
{
"nullable": null,
"types": [
"YXmlElement",
"null"
],
"spread": false,
"optional": false,
"name": "prev",
"description": "The reference node. New YxmlElements are\n inserted after this node. Set null to insert at\n the beginning."
},
{
"nullable": null,
"types": [
"Array<Element>"
],
"spread": false,
"optional": false,
"name": "doms",
"description": "The Dom elements to insert."
},
{
"nullable": true,
"types": [
"Document"
],
"spread": false,
"optional": false,
"name": "_document",
"description": "Optional. Provide the global document object."
},
{
"nullable": null,
"types": [
"DomBinding"
],
"spread": false,
"optional": false,
"name": "binding",
"description": "The dom binding"
}
],
"return": {
"nullable": null,
"types": [
"Array<YXmlElement>"
],
"spread": false,
"description": "The YxmlElements that are inserted."
},
"ignore": true
},
{
"__docId__": 98,
"kind": "function",
"name": "domsToTypes",
"memberof": "src/Bindings/DomBinding/util.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/util.js~domsToTypes",
"access": "public",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/util.js",
"importStyle": "{domsToTypes}",
"description": null,
"lineNumber": 85,
"undocument": true,
"params": [
{
"name": "doms",
"types": [
"*"
]
},
{
"name": "_document",
"types": [
"*"
]
},
{
"name": "hooks",
"types": [
"*"
]
},
{
"name": "filter",
"types": [
"*"
]
},
{
"name": "binding",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 99,
"kind": "function",
"name": "insertNodeHelper",
"memberof": "src/Bindings/DomBinding/util.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/util.js~insertNodeHelper",
"access": "private",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/util.js",
"importStyle": "{insertNodeHelper}",
"description": "",
"lineNumber": 99,
"ignore": true,
"params": [
{
"name": "yxml",
"types": [
"*"
]
},
{
"name": "prevExpectedNode",
"types": [
"*"
]
},
{
"name": "child",
"types": [
"*"
]
},
{
"name": "_document",
"types": [
"*"
]
},
{
"name": "binding",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 100,
"kind": "function",
"name": "removeDomChildrenUntilElementFound",
"memberof": "src/Bindings/DomBinding/util.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/DomBinding/util.js~removeDomChildrenUntilElementFound",
"access": "private",
"export": true,
"importPath": "yjs/src/Bindings/DomBinding/util.js",
"importStyle": "{removeDomChildrenUntilElementFound}",
"description": "Remove children until `elem` is found.",
"lineNumber": 118,
"params": [
{
"nullable": null,
"types": [
"Element"
],
"spread": false,
"optional": false,
"name": "parent",
"description": "The parent of `elem` and `currentChild`."
},
{
"nullable": null,
"types": [
"Element"
],
"spread": false,
"optional": false,
"name": "currentChild",
"description": "Start removing elements with `currentChild`. If\n `currentChild` is `elem` it won't be removed."
},
{
"nullable": null,
"types": [
"Element",
"null"
],
"spread": false,
"optional": false,
"name": "elem",
"description": "The elemnt to look for."
}
],
"ignore": true,
"return": null
},
{
"__docId__": 101,
"kind": "file",
"name": "src/Bindings/QuillBinding/QuillBinding.js",
"content": "import Binding from '../Binding.js'\n\nfunction typeObserver (event) {\n const quill = this.target\n // Force flush Quill changes.\n quill.update('yjs')\n this._mutualExclude(function () {\n // Apply computed delta.\n quill.updateContents(event.delta, 'yjs')\n // Force flush Quill changes. Ignore applied changes.\n quill.update('yjs')\n })\n}\n\nfunction quillObserver (delta) {\n this._mutualExclude(() => {\n this.type.applyDelta(delta.ops)\n })\n}\n\n/**\n * A Binding that binds a YText type to a Quill editor.\n *\n * @example\n * const quill = new Quill(document.createElement('div'))\n * const type = y.define('quill', Y.Text)\n * const binding = new Y.QuillBinding(quill, type)\n * // Now modifications on the DOM will be reflected in the Type, and the other\n * // way around!\n */\nexport default class QuillBinding extends Binding {\n /**\n * @param {YText} textType\n * @param {Quill} quill\n */\n constructor (textType, quill) {\n // Binding handles textType as this.type and quill as this.target.\n super(textType, quill)\n // Set initial value.\n quill.setContents(textType.toDelta(), 'yjs')\n // Observers are handled by this class.\n this._typeObserver = typeObserver.bind(this)\n this._quillObserver = quillObserver.bind(this)\n textType.observe(this._typeObserver)\n quill.on('text-change', this._quillObserver)\n }\n destroy () {\n // Remove everything that is handled by this class.\n this.type.unobserve(this._typeObserver)\n this.target.off('text-change', this._quillObserver)\n super.destroy()\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Bindings/QuillBinding/QuillBinding.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 102,
"kind": "function",
"name": "typeObserver",
"memberof": "src/Bindings/QuillBinding/QuillBinding.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/QuillBinding/QuillBinding.js~typeObserver",
"access": "public",
"export": false,
"importPath": "yjs/src/Bindings/QuillBinding/QuillBinding.js",
"importStyle": null,
"description": null,
"lineNumber": 3,
"undocument": true,
"params": [
{
"name": "event",
"types": [
"*"
]
}
],
"return": null,
"ignore": true
},
{
"__docId__": 103,
"kind": "function",
"name": "quillObserver",
"memberof": "src/Bindings/QuillBinding/QuillBinding.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/QuillBinding/QuillBinding.js~quillObserver",
"access": "public",
"export": false,
"importPath": "yjs/src/Bindings/QuillBinding/QuillBinding.js",
"importStyle": null,
"description": null,
"lineNumber": 15,
"undocument": true,
"params": [
{
"name": "delta",
"types": [
"*"
]
}
],
"return": null,
"ignore": true
},
{
"__docId__": 104,
"kind": "class",
"name": "QuillBinding",
"memberof": "src/Bindings/QuillBinding/QuillBinding.js",
"static": true,
"longname": "src/Bindings/QuillBinding/QuillBinding.js~QuillBinding",
"access": "public",
"export": true,
"importPath": "yjs/src/Bindings/QuillBinding/QuillBinding.js",
"importStyle": "QuillBinding",
"description": "A Binding that binds a YText type to a Quill editor.",
"examples": [
"const quill = new Quill(document.createElement('div'))\nconst type = y.define('quill', Y.Text)\nconst binding = new Y.QuillBinding(quill, type)\n// Now modifications on the DOM will be reflected in the Type, and the other\n// way around!"
],
"lineNumber": 31,
"interface": false,
"extends": [
"src/Bindings/Binding.js~Binding"
]
},
{
"__docId__": 105,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Bindings/QuillBinding/QuillBinding.js~QuillBinding",
"generator": false,
"async": false,
"static": false,
"longname": "src/Bindings/QuillBinding/QuillBinding.js~QuillBinding#constructor",
"access": "public",
"description": "",
"lineNumber": 36,
"params": [
{
"nullable": null,
"types": [
"YText"
],
"spread": false,
"optional": false,
"name": "textType",
"description": ""
},
{
"nullable": null,
"types": [
"Quill"
],
"spread": false,
"optional": false,
"name": "quill",
"description": ""
}
]
},
{
"__docId__": 106,
"kind": "member",
"name": "_typeObserver",
"memberof": "src/Bindings/QuillBinding/QuillBinding.js~QuillBinding",
"static": false,
"longname": "src/Bindings/QuillBinding/QuillBinding.js~QuillBinding#_typeObserver",
"access": "private",
"description": null,
"lineNumber": 42,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 107,
"kind": "member",
"name": "_quillObserver",
"memberof": "src/Bindings/QuillBinding/QuillBinding.js~QuillBinding",
"static": false,
"longname": "src/Bindings/QuillBinding/QuillBinding.js~QuillBinding#_quillObserver",
"access": "private",
"description": null,
"lineNumber": 43,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 108,
"kind": "method",
"name": "destroy",
"memberof": "src/Bindings/QuillBinding/QuillBinding.js~QuillBinding",
"generator": false,
"async": false,
"static": false,
"longname": "src/Bindings/QuillBinding/QuillBinding.js~QuillBinding#destroy",
"access": "public",
"description": null,
"lineNumber": 47,
"undocument": true,
"params": [],
"return": null
},
{
"__docId__": 109,
"kind": "file",
"name": "src/Bindings/TextareaBinding/TextareaBinding.js",
"content": "\nimport Binding from '../Binding.js'\nimport simpleDiff from '../../Util/simpleDiff.js'\nimport { getRelativePosition, fromRelativePosition } from '../../Util/relativePosition.js'\n\nfunction typeObserver () {\n this._mutualExclude(() => {\n const textarea = this.target\n const textType = this.type\n const relativeStart = getRelativePosition(textType, textarea.selectionStart)\n const relativeEnd = getRelativePosition(textType, textarea.selectionEnd)\n textarea.value = textType.toString()\n const start = fromRelativePosition(textType._y, relativeStart)\n const end = fromRelativePosition(textType._y, relativeEnd)\n textarea.setSelectionRange(start, end)\n })\n}\n\nfunction domObserver () {\n this._mutualExclude(() => {\n let diff = simpleDiff(this.type.toString(), this.target.value)\n this.type.delete(diff.pos, diff.remove)\n this.type.insert(diff.pos, diff.insert)\n })\n}\n\n/**\n * A binding that binds a YText to a dom textarea.\n *\n * This binding is automatically destroyed when its parent is deleted.\n *\n * @example\n * const textare = document.createElement('textarea')\n * const type = y.define('textarea', Y.Text)\n * const binding = new Y.QuillBinding(type, textarea)\n *\n */\nexport default class TextareaBinding extends Binding {\n constructor (textType, domTextarea) {\n // Binding handles textType as this.type and domTextarea as this.target\n super(textType, domTextarea)\n // set initial value\n domTextarea.value = textType.toString()\n // Observers are handled by this class\n this._typeObserver = typeObserver.bind(this)\n this._domObserver = domObserver.bind(this)\n textType.observe(this._typeObserver)\n domTextarea.addEventListener('input', this._domObserver)\n }\n destroy () {\n // Remove everything that is handled by this class\n this.type.unobserve(this._typeObserver)\n this.target.unobserve(this._domObserver)\n super.destroy()\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Bindings/TextareaBinding/TextareaBinding.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 110,
"kind": "function",
"name": "typeObserver",
"memberof": "src/Bindings/TextareaBinding/TextareaBinding.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/TextareaBinding/TextareaBinding.js~typeObserver",
"access": "public",
"export": false,
"importPath": "yjs/src/Bindings/TextareaBinding/TextareaBinding.js",
"importStyle": null,
"description": null,
"lineNumber": 6,
"undocument": true,
"params": [],
"return": null,
"ignore": true
},
{
"__docId__": 111,
"kind": "function",
"name": "domObserver",
"memberof": "src/Bindings/TextareaBinding/TextareaBinding.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Bindings/TextareaBinding/TextareaBinding.js~domObserver",
"access": "public",
"export": false,
"importPath": "yjs/src/Bindings/TextareaBinding/TextareaBinding.js",
"importStyle": null,
"description": null,
"lineNumber": 19,
"undocument": true,
"params": [],
"return": null,
"ignore": true
},
{
"__docId__": 112,
"kind": "class",
"name": "TextareaBinding",
"memberof": "src/Bindings/TextareaBinding/TextareaBinding.js",
"static": true,
"longname": "src/Bindings/TextareaBinding/TextareaBinding.js~TextareaBinding",
"access": "public",
"export": true,
"importPath": "yjs/src/Bindings/TextareaBinding/TextareaBinding.js",
"importStyle": "TextareaBinding",
"description": "A binding that binds a YText to a dom textarea.\n\nThis binding is automatically destroyed when its parent is deleted.",
"examples": [
" const textare = document.createElement('textarea')\n const type = y.define('textarea', Y.Text)\n const binding = new Y.QuillBinding(type, textarea)"
],
"lineNumber": 38,
"interface": false,
"extends": [
"src/Bindings/Binding.js~Binding"
]
},
{
"__docId__": 113,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Bindings/TextareaBinding/TextareaBinding.js~TextareaBinding",
"generator": false,
"async": false,
"static": false,
"longname": "src/Bindings/TextareaBinding/TextareaBinding.js~TextareaBinding#constructor",
"access": "public",
"description": null,
"lineNumber": 39,
"undocument": true
},
{
"__docId__": 114,
"kind": "member",
"name": "_typeObserver",
"memberof": "src/Bindings/TextareaBinding/TextareaBinding.js~TextareaBinding",
"static": false,
"longname": "src/Bindings/TextareaBinding/TextareaBinding.js~TextareaBinding#_typeObserver",
"access": "private",
"description": null,
"lineNumber": 45,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 115,
"kind": "member",
"name": "_domObserver",
"memberof": "src/Bindings/TextareaBinding/TextareaBinding.js~TextareaBinding",
"static": false,
"longname": "src/Bindings/TextareaBinding/TextareaBinding.js~TextareaBinding#_domObserver",
"access": "private",
"description": null,
"lineNumber": 46,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 116,
"kind": "method",
"name": "destroy",
"memberof": "src/Bindings/TextareaBinding/TextareaBinding.js~TextareaBinding",
"generator": false,
"async": false,
"static": false,
"longname": "src/Bindings/TextareaBinding/TextareaBinding.js~TextareaBinding#destroy",
"access": "public",
"description": null,
"lineNumber": 50,
"undocument": true,
"params": [],
"return": null
},
{
"__docId__": 117,
"kind": "file",
"name": "src/Connector.js",
"content": "import BinaryEncoder from './Util/Binary/Encoder.js'\nimport BinaryDecoder from './Util/Binary/Decoder.js'\n\nimport { sendSyncStep1, readSyncStep1 } from './MessageHandler/syncStep1.js'\nimport { readSyncStep2 } from './MessageHandler/syncStep2.js'\nimport { integrateRemoteStructs } from './MessageHandler/integrateRemoteStructs.js'\n\nimport debug from 'debug'\n\n// TODO: rename Connector\n\nexport default class AbstractConnector {\n constructor (y, opts) {\n this.y = y\n this.opts = opts\n if (opts.role == null || opts.role === 'master') {\n this.role = 'master'\n } else if (opts.role === 'slave') {\n this.role = 'slave'\n } else {\n throw new Error(\"Role must be either 'master' or 'slave'!\")\n }\n this.log = debug('y:connector')\n this.logMessage = debug('y:connector-message')\n this._forwardAppliedStructs = opts.forwardAppliedOperations || false // TODO: rename\n this.role = opts.role\n this.connections = new Map()\n this.isSynced = false\n this.userEventListeners = []\n this.whenSyncedListeners = []\n this.currentSyncTarget = null\n this.debug = opts.debug === true\n this.broadcastBuffer = new BinaryEncoder()\n this.broadcastBufferSize = 0\n this.protocolVersion = 11\n this.authInfo = opts.auth || null\n this.checkAuth = opts.checkAuth || function () { return Promise.resolve('write') } // default is everyone has write access\n if (opts.maxBufferLength == null) {\n this.maxBufferLength = -1\n } else {\n this.maxBufferLength = opts.maxBufferLength\n }\n }\n\n reconnect () {\n this.log('reconnecting..')\n }\n\n disconnect () {\n this.log('discronnecting..')\n this.connections = new Map()\n this.isSynced = false\n this.currentSyncTarget = null\n this.whenSyncedListeners = []\n return Promise.resolve()\n }\n\n onUserEvent (f) {\n this.userEventListeners.push(f)\n }\n\n removeUserEventListener (f) {\n this.userEventListeners = this.userEventListeners.filter(g => f !== g)\n }\n\n userLeft (user) {\n if (this.connections.has(user)) {\n this.log('%s: User left %s', this.y.userID, user)\n this.connections.delete(user)\n // check if isSynced event can be sent now\n this._setSyncedWith(null)\n for (var f of this.userEventListeners) {\n f({\n action: 'userLeft',\n user: user\n })\n }\n }\n }\n\n userJoined (user, role, auth) {\n if (role == null) {\n throw new Error('You must specify the role of the joined user!')\n }\n if (this.connections.has(user)) {\n throw new Error('This user already joined!')\n }\n this.log('%s: User joined %s', this.y.userID, user)\n this.connections.set(user, {\n uid: user,\n isSynced: false,\n role: role,\n processAfterAuth: [],\n processAfterSync: [],\n auth: auth || null,\n receivedSyncStep2: false\n })\n let defer = {}\n defer.promise = new Promise(function (resolve) { defer.resolve = resolve })\n this.connections.get(user).syncStep2 = defer\n for (var f of this.userEventListeners) {\n f({\n action: 'userJoined',\n user: user,\n role: role\n })\n }\n this._syncWithUser(user)\n }\n\n // Execute a function _when_ we are connected.\n // If not connected, wait until connected\n whenSynced (f) {\n if (this.isSynced) {\n f()\n } else {\n this.whenSyncedListeners.push(f)\n }\n }\n\n _syncWithUser (userID) {\n if (this.role === 'slave') {\n return // \"The current sync has not finished or this is controlled by a master!\"\n }\n sendSyncStep1(this, userID)\n }\n\n _fireIsSyncedListeners () {\n if (!this.isSynced) {\n this.isSynced = true\n // It is safer to remove this!\n // call whensynced listeners\n for (var f of this.whenSyncedListeners) {\n f()\n }\n this.whenSyncedListeners = []\n this.y._setContentReady()\n this.y.emit('synced')\n }\n }\n\n send (uid, buffer) {\n const y = this.y\n if (!(buffer instanceof ArrayBuffer || buffer instanceof Uint8Array)) {\n throw new Error('Expected Message to be an ArrayBuffer or Uint8Array - don\\'t use this method to send custom messages')\n }\n this.log('User%s to User%s: Send \\'%y\\'', y.userID, uid, buffer)\n this.logMessage('User%s to User%s: Send %Y', y.userID, uid, [y, buffer])\n }\n\n broadcast (buffer) {\n const y = this.y\n if (!(buffer instanceof ArrayBuffer || buffer instanceof Uint8Array)) {\n throw new Error('Expected Message to be an ArrayBuffer or Uint8Array - don\\'t use this method to send custom messages')\n }\n this.log('User%s: Broadcast \\'%y\\'', y.userID, buffer)\n this.logMessage('User%s: Broadcast: %Y', y.userID, [y, buffer])\n }\n\n /*\n Buffer operations, and broadcast them when ready.\n */\n broadcastStruct (struct) {\n const firstContent = this.broadcastBuffer.length === 0\n if (firstContent) {\n this.broadcastBuffer.writeVarString(this.y.room)\n this.broadcastBuffer.writeVarString('update')\n this.broadcastBufferSize = 0\n this.broadcastBufferSizePos = this.broadcastBuffer.pos\n this.broadcastBuffer.writeUint32(0)\n }\n this.broadcastBufferSize++\n struct._toBinary(this.broadcastBuffer)\n if (this.maxBufferLength > 0 && this.broadcastBuffer.length > this.maxBufferLength) {\n // it is necessary to send the buffer now\n // cache the buffer and check if server is responsive\n const buffer = this.broadcastBuffer\n buffer.setUint32(this.broadcastBufferSizePos, this.broadcastBufferSize)\n this.broadcastBuffer = new BinaryEncoder()\n this.whenRemoteResponsive().then(() => {\n this.broadcast(buffer.createBuffer())\n })\n } else if (firstContent) {\n // send the buffer when all transactions are finished\n // (or buffer exceeds maxBufferLength)\n setTimeout(() => {\n if (this.broadcastBuffer.length > 0) {\n const buffer = this.broadcastBuffer\n buffer.setUint32(this.broadcastBufferSizePos, this.broadcastBufferSize)\n this.broadcast(buffer.createBuffer())\n this.broadcastBuffer = new BinaryEncoder()\n }\n }, 0)\n }\n }\n\n /*\n * Somehow check the responsiveness of the remote clients/server\n * Default behavior:\n * Wait 100ms before broadcasting the next batch of operations\n *\n * Only used when maxBufferLength is set\n *\n */\n whenRemoteResponsive () {\n return new Promise(function (resolve) {\n setTimeout(resolve, 100)\n })\n }\n\n /*\n You received a raw message, and you know that it is intended for Yjs. Then call this function.\n */\n receiveMessage (sender, buffer, skipAuth) {\n const y = this.y\n const userID = y.userID\n skipAuth = skipAuth || false\n if (!(buffer instanceof ArrayBuffer || buffer instanceof Uint8Array)) {\n return Promise.reject(new Error('Expected Message to be an ArrayBuffer or Uint8Array!'))\n }\n if (sender === userID) {\n return Promise.resolve()\n }\n let decoder = new BinaryDecoder(buffer)\n let encoder = new BinaryEncoder()\n let roomname = decoder.readVarString() // read room name\n encoder.writeVarString(roomname)\n let messageType = decoder.readVarString()\n let senderConn = this.connections.get(sender)\n this.log('User%s from User%s: Receive \\'%s\\'', userID, sender, messageType)\n this.logMessage('User%s from User%s: Receive %Y', userID, sender, [y, buffer])\n if (senderConn == null && !skipAuth) {\n throw new Error('Received message from unknown peer!')\n }\n if (messageType === 'sync step 1' || messageType === 'sync step 2') {\n let auth = decoder.readVarUint()\n if (senderConn.auth == null) {\n senderConn.processAfterAuth.push([messageType, senderConn, decoder, encoder, sender])\n // check auth\n return this.checkAuth(auth, y, sender).then(authPermissions => {\n if (senderConn.auth == null) {\n senderConn.auth = authPermissions\n y.emit('userAuthenticated', {\n user: senderConn.uid,\n auth: authPermissions\n })\n }\n let messages = senderConn.processAfterAuth\n senderConn.processAfterAuth = []\n\n messages.forEach(m =>\n this.computeMessage(m[0], m[1], m[2], m[3], m[4])\n )\n })\n }\n }\n if ((skipAuth || senderConn.auth != null) && (messageType !== 'update' || senderConn.isSynced)) {\n this.computeMessage(messageType, senderConn, decoder, encoder, sender, skipAuth)\n } else {\n senderConn.processAfterSync.push([messageType, senderConn, decoder, encoder, sender, false])\n }\n }\n\n computeMessage (messageType, senderConn, decoder, encoder, sender, skipAuth) {\n if (messageType === 'sync step 1' && (senderConn.auth === 'write' || senderConn.auth === 'read')) {\n // cannot wait for sync step 1 to finish, because we may wait for sync step 2 in sync step 1 (->lock)\n readSyncStep1(decoder, encoder, this.y, senderConn, sender)\n } else {\n const y = this.y\n y.transact(function () {\n if (messageType === 'sync step 2' && senderConn.auth === 'write') {\n readSyncStep2(decoder, encoder, y, senderConn, sender)\n } else if (messageType === 'update' && (skipAuth || senderConn.auth === 'write')) {\n integrateRemoteStructs(y, decoder)\n } else {\n throw new Error('Unable to receive message')\n }\n }, true)\n }\n }\n\n _setSyncedWith (user) {\n if (user != null) {\n const userConn = this.connections.get(user)\n userConn.isSynced = true\n const messages = userConn.processAfterSync\n userConn.processAfterSync = []\n messages.forEach(m => {\n this.computeMessage(m[0], m[1], m[2], m[3], m[4])\n })\n }\n const conns = Array.from(this.connections.values())\n if (conns.length > 0 && conns.every(u => u.isSynced)) {\n this._fireIsSyncedListeners()\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Connector.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 118,
"kind": "class",
"name": "AbstractConnector",
"memberof": "src/Connector.js",
"static": true,
"longname": "src/Connector.js~AbstractConnector",
"access": "public",
"export": true,
"importPath": "yjs/src/Connector.js",
"importStyle": "AbstractConnector",
"description": null,
"lineNumber": 12,
"undocument": true,
"interface": false
},
{
"__docId__": 119,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#constructor",
"access": "public",
"description": null,
"lineNumber": 13,
"undocument": true
},
{
"__docId__": 120,
"kind": "member",
"name": "y",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#y",
"access": "public",
"description": null,
"lineNumber": 14,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 121,
"kind": "member",
"name": "opts",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#opts",
"access": "public",
"description": null,
"lineNumber": 15,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 122,
"kind": "member",
"name": "role",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#role",
"access": "public",
"description": null,
"lineNumber": 17,
"undocument": true,
"type": {
"types": [
"string"
]
}
},
{
"__docId__": 124,
"kind": "member",
"name": "log",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#log",
"access": "public",
"description": null,
"lineNumber": 23,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 125,
"kind": "member",
"name": "logMessage",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#logMessage",
"access": "public",
"description": null,
"lineNumber": 24,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 126,
"kind": "member",
"name": "_forwardAppliedStructs",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#_forwardAppliedStructs",
"access": "private",
"description": null,
"lineNumber": 25,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 128,
"kind": "member",
"name": "connections",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#connections",
"access": "public",
"description": null,
"lineNumber": 27,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 129,
"kind": "member",
"name": "isSynced",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#isSynced",
"access": "public",
"description": null,
"lineNumber": 28,
"undocument": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 130,
"kind": "member",
"name": "userEventListeners",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#userEventListeners",
"access": "public",
"description": null,
"lineNumber": 29,
"undocument": true,
"type": {
"types": [
"*[]"
]
}
},
{
"__docId__": 131,
"kind": "member",
"name": "whenSyncedListeners",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#whenSyncedListeners",
"access": "public",
"description": null,
"lineNumber": 30,
"undocument": true,
"type": {
"types": [
"*[]"
]
}
},
{
"__docId__": 132,
"kind": "member",
"name": "currentSyncTarget",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#currentSyncTarget",
"access": "public",
"description": null,
"lineNumber": 31,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 133,
"kind": "member",
"name": "debug",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#debug",
"access": "public",
"description": null,
"lineNumber": 32,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 134,
"kind": "member",
"name": "broadcastBuffer",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#broadcastBuffer",
"access": "public",
"description": null,
"lineNumber": 33,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 135,
"kind": "member",
"name": "broadcastBufferSize",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#broadcastBufferSize",
"access": "public",
"description": null,
"lineNumber": 34,
"undocument": true,
"type": {
"types": [
"number"
]
}
},
{
"__docId__": 136,
"kind": "member",
"name": "protocolVersion",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#protocolVersion",
"access": "public",
"description": null,
"lineNumber": 35,
"undocument": true,
"type": {
"types": [
"number"
]
}
},
{
"__docId__": 137,
"kind": "member",
"name": "authInfo",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#authInfo",
"access": "public",
"description": null,
"lineNumber": 36,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 138,
"kind": "member",
"name": "checkAuth",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#checkAuth",
"access": "public",
"description": null,
"lineNumber": 37,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 139,
"kind": "member",
"name": "maxBufferLength",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#maxBufferLength",
"access": "public",
"description": null,
"lineNumber": 39,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 141,
"kind": "method",
"name": "reconnect",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#reconnect",
"access": "public",
"description": null,
"lineNumber": 45,
"undocument": true,
"params": [],
"return": null
},
{
"__docId__": 142,
"kind": "method",
"name": "disconnect",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#disconnect",
"access": "public",
"description": null,
"lineNumber": 49,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 147,
"kind": "method",
"name": "onUserEvent",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#onUserEvent",
"access": "public",
"description": null,
"lineNumber": 58,
"undocument": true,
"params": [
{
"name": "f",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 148,
"kind": "method",
"name": "removeUserEventListener",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#removeUserEventListener",
"access": "public",
"description": null,
"lineNumber": 62,
"undocument": true,
"params": [
{
"name": "f",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 150,
"kind": "method",
"name": "userLeft",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#userLeft",
"access": "public",
"description": null,
"lineNumber": 66,
"undocument": true,
"params": [
{
"name": "user",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 151,
"kind": "method",
"name": "userJoined",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#userJoined",
"access": "public",
"description": null,
"lineNumber": 81,
"undocument": true,
"params": [
{
"name": "user",
"types": [
"*"
]
},
{
"name": "role",
"types": [
"*"
]
},
{
"name": "auth",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 152,
"kind": "method",
"name": "whenSynced",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#whenSynced",
"access": "public",
"description": null,
"lineNumber": 113,
"undocument": true,
"params": [
{
"name": "f",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 153,
"kind": "method",
"name": "_syncWithUser",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#_syncWithUser",
"access": "private",
"description": null,
"lineNumber": 121,
"undocument": true,
"ignore": true,
"params": [
{
"name": "userID",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 154,
"kind": "method",
"name": "_fireIsSyncedListeners",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#_fireIsSyncedListeners",
"access": "private",
"description": null,
"lineNumber": 128,
"undocument": true,
"ignore": true,
"params": [],
"return": null
},
{
"__docId__": 157,
"kind": "method",
"name": "send",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#send",
"access": "public",
"description": null,
"lineNumber": 142,
"undocument": true,
"params": [
{
"name": "uid",
"types": [
"*"
]
},
{
"name": "buffer",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 158,
"kind": "method",
"name": "broadcast",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#broadcast",
"access": "public",
"description": null,
"lineNumber": 151,
"undocument": true,
"params": [
{
"name": "buffer",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 159,
"kind": "method",
"name": "broadcastStruct",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#broadcastStruct",
"access": "public",
"description": null,
"lineNumber": 163,
"undocument": true,
"params": [
{
"name": "struct",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 161,
"kind": "member",
"name": "broadcastBufferSizePos",
"memberof": "src/Connector.js~AbstractConnector",
"static": false,
"longname": "src/Connector.js~AbstractConnector#broadcastBufferSizePos",
"access": "public",
"description": null,
"lineNumber": 169,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 164,
"kind": "method",
"name": "whenRemoteResponsive",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#whenRemoteResponsive",
"access": "public",
"description": null,
"lineNumber": 205,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 165,
"kind": "method",
"name": "receiveMessage",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#receiveMessage",
"access": "public",
"description": null,
"lineNumber": 214,
"undocument": true,
"params": [
{
"name": "sender",
"types": [
"*"
]
},
{
"name": "buffer",
"types": [
"*"
]
},
{
"name": "skipAuth",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 166,
"kind": "method",
"name": "computeMessage",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#computeMessage",
"access": "public",
"description": null,
"lineNumber": 264,
"undocument": true,
"params": [
{
"name": "messageType",
"types": [
"*"
]
},
{
"name": "senderConn",
"types": [
"*"
]
},
{
"name": "decoder",
"types": [
"*"
]
},
{
"name": "encoder",
"types": [
"*"
]
},
{
"name": "sender",
"types": [
"*"
]
},
{
"name": "skipAuth",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 167,
"kind": "method",
"name": "_setSyncedWith",
"memberof": "src/Connector.js~AbstractConnector",
"generator": false,
"async": false,
"static": false,
"longname": "src/Connector.js~AbstractConnector#_setSyncedWith",
"access": "private",
"description": null,
"lineNumber": 282,
"undocument": true,
"ignore": true,
"params": [
{
"name": "user",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 168,
"kind": "file",
"name": "src/MessageHandler/binaryEncode.js",
"content": "\nimport { writeStructs } from './syncStep1.js'\nimport { integrateRemoteStructs } from './integrateRemoteStructs.js'\nimport { readDeleteSet, writeDeleteSet } from './deleteSet.js'\nimport BinaryEncoder from '../Util/Binary/Encoder.js'\n\n/**\n * Read the Decoder and fill the Yjs instance with data in the decoder.\n *\n * @param {Y} y The Yjs instance\n * @param {BinaryDecoder} decoder The BinaryDecoder to read from.\n */\nexport function fromBinary (y, decoder) {\n y.transact(function () {\n integrateRemoteStructs(y, decoder)\n readDeleteSet(y, decoder)\n })\n}\n\n/**\n * Encode the Yjs model to binary format.\n *\n * @param {Y} y The Yjs instance\n * @return {BinaryEncoder} The encoder instance that can be transformed\n * to ArrayBuffer or Buffer.\n */\nexport function toBinary (y) {\n let encoder = new BinaryEncoder()\n writeStructs(y, encoder, new Map())\n writeDeleteSet(y, encoder)\n return encoder\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/MessageHandler/binaryEncode.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 169,
"kind": "function",
"name": "fromBinary",
"memberof": "src/MessageHandler/binaryEncode.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/binaryEncode.js~fromBinary",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/binaryEncode.js",
"importStyle": "{fromBinary}",
"description": "Read the Decoder and fill the Yjs instance with data in the decoder.",
"lineNumber": 13,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance"
},
{
"nullable": null,
"types": [
"BinaryDecoder"
],
"spread": false,
"optional": false,
"name": "decoder",
"description": "The BinaryDecoder to read from."
}
],
"return": null
},
{
"__docId__": 170,
"kind": "function",
"name": "toBinary",
"memberof": "src/MessageHandler/binaryEncode.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/binaryEncode.js~toBinary",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/binaryEncode.js",
"importStyle": "{toBinary}",
"description": "Encode the Yjs model to binary format.",
"lineNumber": 27,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance"
}
],
"return": {
"nullable": null,
"types": [
"BinaryEncoder"
],
"spread": false,
"description": "The encoder instance that can be transformed\n to ArrayBuffer or Buffer."
}
},
{
"__docId__": 171,
"kind": "file",
"name": "src/MessageHandler/deleteSet.js",
"content": "import { deleteItemRange } from '../Struct/Delete.js'\nimport ID from '../Util/ID/ID.js'\n\nexport function stringifyDeleteSet (y, decoder, strBuilder) {\n let dsLength = decoder.readUint32()\n for (let i = 0; i < dsLength; i++) {\n let user = decoder.readVarUint()\n strBuilder.push(' -' + user + ':')\n let dvLength = decoder.readVarUint()\n for (let j = 0; j < dvLength; j++) {\n let from = decoder.readVarUint()\n let len = decoder.readVarUint()\n let gc = decoder.readUint8() === 1\n strBuilder.push(`clock: ${from}, length: ${len}, gc: ${gc}`)\n }\n }\n return strBuilder\n}\n\nexport function writeDeleteSet (y, encoder) {\n let currentUser = null\n let currentLength\n let lastLenPos\n\n let numberOfUsers = 0\n let laterDSLenPus = encoder.pos\n encoder.writeUint32(0)\n\n y.ds.iterate(null, null, function (n) {\n var user = n._id.user\n var clock = n._id.clock\n var len = n.len\n var gc = n.gc\n if (currentUser !== user) {\n numberOfUsers++\n // a new user was found\n if (currentUser !== null) { // happens on first iteration\n encoder.setUint32(lastLenPos, currentLength)\n }\n currentUser = user\n encoder.writeVarUint(user)\n // pseudo-fill pos\n lastLenPos = encoder.pos\n encoder.writeUint32(0)\n currentLength = 0\n }\n encoder.writeVarUint(clock)\n encoder.writeVarUint(len)\n encoder.writeUint8(gc ? 1 : 0)\n currentLength++\n })\n if (currentUser !== null) { // happens on first iteration\n encoder.setUint32(lastLenPos, currentLength)\n }\n encoder.setUint32(laterDSLenPus, numberOfUsers)\n}\n\nexport function readDeleteSet (y, decoder) {\n let dsLength = decoder.readUint32()\n for (let i = 0; i < dsLength; i++) {\n let user = decoder.readVarUint()\n let dv = []\n let dvLength = decoder.readUint32()\n for (let j = 0; j < dvLength; j++) {\n let from = decoder.readVarUint()\n let len = decoder.readVarUint()\n let gc = decoder.readUint8() === 1\n dv.push([from, len, gc])\n }\n if (dvLength > 0) {\n let pos = 0\n let d = dv[pos]\n let deletions = []\n y.ds.iterate(new ID(user, 0), new ID(user, Number.MAX_VALUE), function (n) {\n // cases:\n // 1. d deletes something to the right of n\n // => go to next n (break)\n // 2. d deletes something to the left of n\n // => create deletions\n // => reset d accordingly\n // *)=> if d doesn't delete anything anymore, go to next d (continue)\n // 3. not 2) and d deletes something that also n deletes\n // => reset d so that it doesn't contain n's deletion\n // *)=> if d does not delete anything anymore, go to next d (continue)\n while (d != null) {\n var diff = 0 // describe the diff of length in 1) and 2)\n if (n._id.clock + n.len <= d[0]) {\n // 1)\n break\n } else if (d[0] < n._id.clock) {\n // 2)\n // delete maximum the len of d\n // else delete as much as possible\n diff = Math.min(n._id.clock - d[0], d[1])\n // deleteItemRange(y, user, d[0], diff, true)\n deletions.push([user, d[0], diff])\n } else {\n // 3)\n diff = n._id.clock + n.len - d[0] // never null (see 1)\n if (d[2] && !n.gc) {\n // d marks as gc'd but n does not\n // then delete either way\n // deleteItemRange(y, user, d[0], Math.min(diff, d[1]), true)\n deletions.push([user, d[0], Math.min(diff, d[1])])\n }\n }\n if (d[1] <= diff) {\n // d doesn't delete anything anymore\n d = dv[++pos]\n } else {\n d[0] = d[0] + diff // reset pos\n d[1] = d[1] - diff // reset length\n }\n }\n })\n // TODO: It would be more performant to apply the deletes in the above loop\n // Adapt the Tree implementation to support delete while iterating\n for (let i = deletions.length - 1; i >= 0; i--) {\n const del = deletions[i]\n deleteItemRange(y, del[0], del[1], del[2], true)\n }\n // for the rest.. just apply it\n for (; pos < dv.length; pos++) {\n d = dv[pos]\n deleteItemRange(y, user, d[0], d[1], true)\n // deletions.push([user, d[0], d[1], d[2]])\n }\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/MessageHandler/deleteSet.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 172,
"kind": "function",
"name": "stringifyDeleteSet",
"memberof": "src/MessageHandler/deleteSet.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/deleteSet.js~stringifyDeleteSet",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/deleteSet.js",
"importStyle": "{stringifyDeleteSet}",
"description": null,
"lineNumber": 4,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "decoder",
"types": [
"*"
]
},
{
"name": "strBuilder",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 173,
"kind": "function",
"name": "writeDeleteSet",
"memberof": "src/MessageHandler/deleteSet.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/deleteSet.js~writeDeleteSet",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/deleteSet.js",
"importStyle": "{writeDeleteSet}",
"description": null,
"lineNumber": 20,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "encoder",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 174,
"kind": "function",
"name": "readDeleteSet",
"memberof": "src/MessageHandler/deleteSet.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/deleteSet.js~readDeleteSet",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/deleteSet.js",
"importStyle": "{readDeleteSet}",
"description": null,
"lineNumber": 58,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "decoder",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 175,
"kind": "file",
"name": "src/MessageHandler/integrateRemoteStructs.js",
"content": "import { getStruct } from '../Util/structReferences.js'\nimport BinaryDecoder from '../Util/Binary/Decoder.js'\nimport { logID } from './messageToString.js'\nimport GC from '../Struct/GC.js'\n\nclass MissingEntry {\n constructor (decoder, missing, struct) {\n this.decoder = decoder\n this.missing = missing.length\n this.struct = struct\n }\n}\n\n/**\n * @private\n * Integrate remote struct\n * When a remote struct is integrated, other structs might be ready to ready to\n * integrate.\n */\nfunction _integrateRemoteStructHelper (y, struct) {\n const id = struct._id\n if (id === undefined) {\n struct._integrate(y)\n } else {\n if (y.ss.getState(id.user) > id.clock) {\n return\n }\n if (struct.constructor === GC || (struct._parent.constructor !== GC && struct._parent._deleted === false)) {\n // Is either a GC or Item with an undeleted parent\n // save to integrate\n struct._integrate(y)\n } else {\n // Is an Item. parent was deleted.\n struct._gc(y)\n }\n let msu = y._missingStructs.get(id.user)\n if (msu != null) {\n let clock = id.clock\n const finalClock = clock + struct._length\n for (;clock < finalClock; clock++) {\n const missingStructs = msu.get(clock)\n if (missingStructs !== undefined) {\n missingStructs.forEach(missingDef => {\n missingDef.missing--\n if (missingDef.missing === 0) {\n const decoder = missingDef.decoder\n let oldPos = decoder.pos\n let missing = missingDef.struct._fromBinary(y, decoder)\n decoder.pos = oldPos\n if (missing.length === 0) {\n y._readyToIntegrate.push(missingDef.struct)\n }\n }\n })\n msu.delete(clock)\n }\n }\n }\n }\n}\n\nexport function stringifyStructs (y, decoder, strBuilder) {\n const len = decoder.readUint32()\n for (let i = 0; i < len; i++) {\n let reference = decoder.readVarUint()\n let Constr = getStruct(reference)\n let struct = new Constr()\n let missing = struct._fromBinary(y, decoder)\n let logMessage = ' ' + struct._logString()\n if (missing.length > 0) {\n logMessage += ' .. missing: ' + missing.map(logID).join(', ')\n }\n strBuilder.push(logMessage)\n }\n}\n\nexport function integrateRemoteStructs (y, decoder) {\n const len = decoder.readUint32()\n for (let i = 0; i < len; i++) {\n let reference = decoder.readVarUint()\n let Constr = getStruct(reference)\n let struct = new Constr()\n let decoderPos = decoder.pos\n let missing = struct._fromBinary(y, decoder)\n if (missing.length === 0) {\n while (struct != null) {\n _integrateRemoteStructHelper(y, struct)\n struct = y._readyToIntegrate.shift()\n }\n } else {\n let _decoder = new BinaryDecoder(decoder.uint8arr)\n _decoder.pos = decoderPos\n let missingEntry = new MissingEntry(_decoder, missing, struct)\n let missingStructs = y._missingStructs\n for (let i = missing.length - 1; i >= 0; i--) {\n let m = missing[i]\n if (!missingStructs.has(m.user)) {\n missingStructs.set(m.user, new Map())\n }\n let msu = missingStructs.get(m.user)\n if (!msu.has(m.clock)) {\n msu.set(m.clock, [])\n }\n let mArray = msu = msu.get(m.clock)\n mArray.push(missingEntry)\n }\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/MessageHandler/integrateRemoteStructs.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 176,
"kind": "class",
"name": "MissingEntry",
"memberof": "src/MessageHandler/integrateRemoteStructs.js",
"static": true,
"longname": "src/MessageHandler/integrateRemoteStructs.js~MissingEntry",
"access": "public",
"export": false,
"importPath": "yjs/src/MessageHandler/integrateRemoteStructs.js",
"importStyle": null,
"description": null,
"lineNumber": 6,
"undocument": true,
"interface": false,
"ignore": true
},
{
"__docId__": 177,
"kind": "constructor",
"name": "constructor",
"memberof": "src/MessageHandler/integrateRemoteStructs.js~MissingEntry",
"generator": false,
"async": false,
"static": false,
"longname": "src/MessageHandler/integrateRemoteStructs.js~MissingEntry#constructor",
"access": "public",
"description": null,
"lineNumber": 7,
"undocument": true
},
{
"__docId__": 178,
"kind": "member",
"name": "decoder",
"memberof": "src/MessageHandler/integrateRemoteStructs.js~MissingEntry",
"static": false,
"longname": "src/MessageHandler/integrateRemoteStructs.js~MissingEntry#decoder",
"access": "public",
"description": null,
"lineNumber": 8,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 179,
"kind": "member",
"name": "missing",
"memberof": "src/MessageHandler/integrateRemoteStructs.js~MissingEntry",
"static": false,
"longname": "src/MessageHandler/integrateRemoteStructs.js~MissingEntry#missing",
"access": "public",
"description": null,
"lineNumber": 9,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 180,
"kind": "member",
"name": "struct",
"memberof": "src/MessageHandler/integrateRemoteStructs.js~MissingEntry",
"static": false,
"longname": "src/MessageHandler/integrateRemoteStructs.js~MissingEntry#struct",
"access": "public",
"description": null,
"lineNumber": 10,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 181,
"kind": "function",
"name": "_integrateRemoteStructHelper",
"memberof": "src/MessageHandler/integrateRemoteStructs.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/integrateRemoteStructs.js~_integrateRemoteStructHelper",
"access": "private",
"export": false,
"importPath": "yjs/src/MessageHandler/integrateRemoteStructs.js",
"importStyle": null,
"description": "",
"lineNumber": 20,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "struct",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 182,
"kind": "function",
"name": "stringifyStructs",
"memberof": "src/MessageHandler/integrateRemoteStructs.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/integrateRemoteStructs.js~stringifyStructs",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/integrateRemoteStructs.js",
"importStyle": "{stringifyStructs}",
"description": null,
"lineNumber": 62,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "decoder",
"types": [
"*"
]
},
{
"name": "strBuilder",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 183,
"kind": "function",
"name": "integrateRemoteStructs",
"memberof": "src/MessageHandler/integrateRemoteStructs.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/integrateRemoteStructs.js~integrateRemoteStructs",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/integrateRemoteStructs.js",
"importStyle": "{integrateRemoteStructs}",
"description": null,
"lineNumber": 77,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "decoder",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 184,
"kind": "file",
"name": "src/MessageHandler/messageToString.js",
"content": "import BinaryDecoder from '../Util/Binary/Decoder.js'\nimport { stringifyStructs } from './integrateRemoteStructs.js'\nimport { stringifySyncStep1 } from './syncStep1.js'\nimport { stringifySyncStep2 } from './syncStep2.js'\nimport ID from '../Util/ID/ID.js'\nimport RootID from '../Util/ID/RootID.js'\nimport Y from '../Y.js'\n\nexport function messageToString ([y, buffer]) {\n let decoder = new BinaryDecoder(buffer)\n decoder.readVarString() // read roomname\n let type = decoder.readVarString()\n let strBuilder = []\n strBuilder.push('\\n === ' + type + ' ===')\n if (type === 'update') {\n stringifyStructs(y, decoder, strBuilder)\n } else if (type === 'sync step 1') {\n stringifySyncStep1(y, decoder, strBuilder)\n } else if (type === 'sync step 2') {\n stringifySyncStep2(y, decoder, strBuilder)\n } else {\n strBuilder.push('-- Unknown message type - probably an encoding issue!!!')\n }\n return strBuilder.join('\\n')\n}\n\nexport function messageToRoomname (buffer) {\n let decoder = new BinaryDecoder(buffer)\n decoder.readVarString() // roomname\n return decoder.readVarString() // messageType\n}\n\nexport function logID (id) {\n if (id !== null && id._id != null) {\n id = id._id\n }\n if (id === null) {\n return '()'\n } else if (id instanceof ID) {\n return `(${id.user},${id.clock})`\n } else if (id instanceof RootID) {\n return `(${id.name},${id.type})`\n } else if (id.constructor === Y) {\n return `y`\n } else {\n throw new Error('This is not a valid ID!')\n }\n}\n\n/**\n * Helper utility to convert an item to a readable format.\n *\n * @param {String} name The name of the item class (YText, ItemString, ..).\n * @param {Item} item The item instance.\n * @param {String} [append] Additional information to append to the returned\n * string.\n * @return {String} A readable string that represents the item object.\n *\n * @private\n */\nexport function logItemHelper (name, item, append) {\n const left = item._left !== null ? item._left._lastId : null\n const origin = item._origin !== null ? item._origin._lastId : null\n 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 : ''})`\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/MessageHandler/messageToString.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 185,
"kind": "function",
"name": "messageToString",
"memberof": "src/MessageHandler/messageToString.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/messageToString.js~messageToString",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/messageToString.js",
"importStyle": "{messageToString}",
"description": null,
"lineNumber": 9,
"undocument": true,
"params": [
{
"name": "arrayPattern",
"types": [
"*[]"
],
"defaultRaw": [
"null",
"null"
],
"defaultValue": "[null, null]"
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 186,
"kind": "function",
"name": "messageToRoomname",
"memberof": "src/MessageHandler/messageToString.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/messageToString.js~messageToRoomname",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/messageToString.js",
"importStyle": "{messageToRoomname}",
"description": null,
"lineNumber": 27,
"undocument": true,
"params": [
{
"name": "buffer",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 187,
"kind": "function",
"name": "logID",
"memberof": "src/MessageHandler/messageToString.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/messageToString.js~logID",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/messageToString.js",
"importStyle": "{logID}",
"description": null,
"lineNumber": 33,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"string"
]
}
},
{
"__docId__": 188,
"kind": "function",
"name": "logItemHelper",
"memberof": "src/MessageHandler/messageToString.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/messageToString.js~logItemHelper",
"access": "private",
"export": true,
"importPath": "yjs/src/MessageHandler/messageToString.js",
"importStyle": "{logItemHelper}",
"description": "Helper utility to convert an item to a readable format.",
"lineNumber": 61,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "name",
"description": "The name of the item class (YText, ItemString, ..)."
},
{
"nullable": null,
"types": [
"Item"
],
"spread": false,
"optional": false,
"name": "item",
"description": "The item instance."
},
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": true,
"name": "append",
"description": "Additional information to append to the returned\n string."
}
],
"return": {
"nullable": null,
"types": [
"String"
],
"spread": false,
"description": "A readable string that represents the item object."
},
"ignore": true
},
{
"__docId__": 189,
"kind": "file",
"name": "src/MessageHandler/stateSet.js",
"content": "\nexport function readStateSet (decoder) {\n let ss = new Map()\n let ssLength = decoder.readUint32()\n for (let i = 0; i < ssLength; i++) {\n let user = decoder.readVarUint()\n let clock = decoder.readVarUint()\n ss.set(user, clock)\n }\n return ss\n}\n\nexport function writeStateSet (y, encoder) {\n let lenPosition = encoder.pos\n let len = 0\n encoder.writeUint32(0)\n for (let [user, clock] of y.ss.state) {\n encoder.writeVarUint(user)\n encoder.writeVarUint(clock)\n len++\n }\n encoder.setUint32(lenPosition, len)\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/MessageHandler/stateSet.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 190,
"kind": "function",
"name": "readStateSet",
"memberof": "src/MessageHandler/stateSet.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/stateSet.js~readStateSet",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/stateSet.js",
"importStyle": "{readStateSet}",
"description": null,
"lineNumber": 2,
"undocument": true,
"params": [
{
"name": "decoder",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 191,
"kind": "function",
"name": "writeStateSet",
"memberof": "src/MessageHandler/stateSet.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/stateSet.js~writeStateSet",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/stateSet.js",
"importStyle": "{writeStateSet}",
"description": null,
"lineNumber": 13,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "encoder",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 192,
"kind": "file",
"name": "src/MessageHandler/syncStep1.js",
"content": "import BinaryEncoder from '../Util/Binary/Encoder.js'\nimport { readStateSet, writeStateSet } from './stateSet.js'\nimport { writeDeleteSet } from './deleteSet.js'\nimport ID from '../Util/ID/ID.js'\nimport { RootFakeUserID } from '../Util/ID/RootID.js'\n\nexport function stringifySyncStep1 (y, decoder, strBuilder) {\n let auth = decoder.readVarString()\n let protocolVersion = decoder.readVarUint()\n strBuilder.push(` - auth: \"${auth}\"`)\n strBuilder.push(` - protocolVersion: ${protocolVersion}`)\n // write SS\n let ssBuilder = []\n let len = decoder.readUint32()\n for (let i = 0; i < len; i++) {\n let user = decoder.readVarUint()\n let clock = decoder.readVarUint()\n ssBuilder.push(`(${user}:${clock})`)\n }\n strBuilder.push(' == SS: ' + ssBuilder.join(','))\n}\n\nexport function sendSyncStep1 (connector, syncUser) {\n let encoder = new BinaryEncoder()\n encoder.writeVarString(connector.y.room)\n encoder.writeVarString('sync step 1')\n encoder.writeVarString(connector.authInfo || '')\n encoder.writeVarUint(connector.protocolVersion)\n writeStateSet(connector.y, encoder)\n connector.send(syncUser, encoder.createBuffer())\n}\n\n/**\n * @private\n * Write all Items that are not not included in ss to\n * the encoder object.\n */\nexport function writeStructs (y, encoder, ss) {\n const lenPos = encoder.pos\n encoder.writeUint32(0)\n let len = 0\n for (let user of y.ss.state.keys()) {\n let clock = ss.get(user) || 0\n if (user !== RootFakeUserID) {\n const minBound = new ID(user, clock)\n const overlappingLeft = y.os.findPrev(minBound)\n const rightID = overlappingLeft === null ? null : overlappingLeft._id\n if (rightID !== null && rightID.user === user && rightID.clock + overlappingLeft._length > clock) {\n const struct = overlappingLeft._clonePartial(clock - rightID.clock)\n struct._toBinary(encoder)\n len++\n }\n y.os.iterate(minBound, new ID(user, Number.MAX_VALUE), function (struct) {\n struct._toBinary(encoder)\n len++\n })\n }\n }\n encoder.setUint32(lenPos, len)\n}\n\nexport function readSyncStep1 (decoder, encoder, y, senderConn, sender) {\n let protocolVersion = decoder.readVarUint()\n // check protocol version\n if (protocolVersion !== y.connector.protocolVersion) {\n console.warn(\n `You tried to sync with a Yjs instance that has a different protocol version\n (You: ${protocolVersion}, Client: ${protocolVersion}).\n `)\n y.destroy()\n }\n // write sync step 2\n encoder.writeVarString('sync step 2')\n encoder.writeVarString(y.connector.authInfo || '')\n const ss = readStateSet(decoder)\n writeStructs(y, encoder, ss)\n writeDeleteSet(y, encoder)\n y.connector.send(senderConn.uid, encoder.createBuffer())\n senderConn.receivedSyncStep2 = true\n if (y.connector.role === 'slave') {\n sendSyncStep1(y.connector, sender)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/MessageHandler/syncStep1.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 193,
"kind": "function",
"name": "stringifySyncStep1",
"memberof": "src/MessageHandler/syncStep1.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/syncStep1.js~stringifySyncStep1",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/syncStep1.js",
"importStyle": "{stringifySyncStep1}",
"description": null,
"lineNumber": 7,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "decoder",
"types": [
"*"
]
},
{
"name": "strBuilder",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 194,
"kind": "function",
"name": "sendSyncStep1",
"memberof": "src/MessageHandler/syncStep1.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/syncStep1.js~sendSyncStep1",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/syncStep1.js",
"importStyle": "{sendSyncStep1}",
"description": null,
"lineNumber": 23,
"undocument": true,
"params": [
{
"name": "connector",
"types": [
"*"
]
},
{
"name": "syncUser",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 195,
"kind": "function",
"name": "writeStructs",
"memberof": "src/MessageHandler/syncStep1.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/syncStep1.js~writeStructs",
"access": "private",
"export": true,
"importPath": "yjs/src/MessageHandler/syncStep1.js",
"importStyle": "{writeStructs}",
"description": "",
"lineNumber": 38,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "encoder",
"types": [
"*"
]
},
{
"name": "ss",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 196,
"kind": "function",
"name": "readSyncStep1",
"memberof": "src/MessageHandler/syncStep1.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/syncStep1.js~readSyncStep1",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/syncStep1.js",
"importStyle": "{readSyncStep1}",
"description": null,
"lineNumber": 62,
"undocument": true,
"params": [
{
"name": "decoder",
"types": [
"*"
]
},
{
"name": "encoder",
"types": [
"*"
]
},
{
"name": "y",
"types": [
"*"
]
},
{
"name": "senderConn",
"types": [
"*"
]
},
{
"name": "sender",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 197,
"kind": "file",
"name": "src/MessageHandler/syncStep2.js",
"content": "import { stringifyStructs, integrateRemoteStructs } from './integrateRemoteStructs.js'\nimport { readDeleteSet } from './deleteSet.js'\n\nexport function stringifySyncStep2 (y, decoder, strBuilder) {\n strBuilder.push(' - auth: ' + decoder.readVarString())\n strBuilder.push(' == OS:')\n stringifyStructs(y, decoder, strBuilder)\n // write DS to string\n strBuilder.push(' == DS:')\n let len = decoder.readUint32()\n for (let i = 0; i < len; i++) {\n let user = decoder.readVarUint()\n strBuilder.push(` User: ${user}: `)\n let len2 = decoder.readUint32()\n for (let j = 0; j < len2; j++) {\n let from = decoder.readVarUint()\n let to = decoder.readVarUint()\n let gc = decoder.readUint8() === 1\n strBuilder.push(`[${from}, ${to}, ${gc}]`)\n }\n }\n}\n\nexport function readSyncStep2 (decoder, encoder, y, senderConn, sender) {\n integrateRemoteStructs(y, decoder)\n readDeleteSet(y, decoder)\n y.connector._setSyncedWith(sender)\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/MessageHandler/syncStep2.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 198,
"kind": "function",
"name": "stringifySyncStep2",
"memberof": "src/MessageHandler/syncStep2.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/syncStep2.js~stringifySyncStep2",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/syncStep2.js",
"importStyle": "{stringifySyncStep2}",
"description": null,
"lineNumber": 4,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "decoder",
"types": [
"*"
]
},
{
"name": "strBuilder",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 199,
"kind": "function",
"name": "readSyncStep2",
"memberof": "src/MessageHandler/syncStep2.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/MessageHandler/syncStep2.js~readSyncStep2",
"access": "public",
"export": true,
"importPath": "yjs/src/MessageHandler/syncStep2.js",
"importStyle": "{readSyncStep2}",
"description": null,
"lineNumber": 24,
"undocument": true,
"params": [
{
"name": "decoder",
"types": [
"*"
]
},
{
"name": "encoder",
"types": [
"*"
]
},
{
"name": "y",
"types": [
"*"
]
},
{
"name": "senderConn",
"types": [
"*"
]
},
{
"name": "sender",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 200,
"kind": "file",
"name": "src/Persistence.js",
"content": "import BinaryEncoder from './Util/Binary/Encoder.js'\nimport BinaryDecoder from './Util/Binary/Decoder.js'\nimport { toBinary, fromBinary } from './MessageHandler/binaryEncode.js'\nimport { integrateRemoteStructs } from './MessageHandler/integrateRemoteStructs.js'\nimport { createMutualExclude } from './Util/mutualExclude.js'\n\nfunction getFreshCnf () {\n let buffer = new BinaryEncoder()\n buffer.writeUint32(0)\n return {\n len: 0,\n buffer\n }\n}\n\n/**\n * Abstract persistence class.\n */\nexport default class AbstractPersistence {\n constructor (opts) {\n this.opts = opts\n this.ys = new Map()\n }\n\n _init (y) {\n let cnf = this.ys.get(y)\n if (cnf === undefined) {\n cnf = getFreshCnf()\n cnf.mutualExclude = createMutualExclude()\n this.ys.set(y, cnf)\n return this.init(y).then(() => {\n y.on('afterTransaction', (y, transaction) => {\n let cnf = this.ys.get(y)\n if (cnf.len > 0) {\n cnf.buffer.setUint32(0, cnf.len)\n this.saveUpdate(y, cnf.buffer.createBuffer(), transaction)\n let _cnf = getFreshCnf()\n for (let key in _cnf) {\n cnf[key] = _cnf[key]\n }\n }\n })\n return this.retrieve(y)\n }).then(function () {\n return Promise.resolve(cnf)\n })\n } else {\n return Promise.resolve(cnf)\n }\n }\n deinit (y) {\n this.ys.delete(y)\n y.persistence = null\n }\n\n destroy () {\n this.ys = null\n }\n\n /**\n * Remove all persisted data that belongs to a room.\n * Automatically destroys all Yjs all Yjs instances that persist to\n * the room. If `destroyYjsInstances = false` the persistence functionality\n * will be removed from the Yjs instances.\n *\n * ** Must be overwritten! **\n */\n removePersistedData (room, destroyYjsInstances = true) {\n this.ys.forEach((cnf, y) => {\n if (y.room === room) {\n if (destroyYjsInstances) {\n y.destroy()\n } else {\n this.deinit(y)\n }\n }\n })\n }\n\n /* overwrite */\n saveUpdate (buffer) {\n }\n\n /**\n * Save struct to update buffer.\n * saveUpdate is called when transaction ends\n */\n saveStruct (y, struct) {\n let cnf = this.ys.get(y)\n if (cnf !== undefined) {\n cnf.mutualExclude(function () {\n struct._toBinary(cnf.buffer)\n cnf.len++\n })\n }\n }\n\n /* overwrite */\n retrieve (y, model, updates) {\n let cnf = this.ys.get(y)\n if (cnf !== undefined) {\n cnf.mutualExclude(function () {\n y.transact(function () {\n if (model != null) {\n fromBinary(y, new BinaryDecoder(new Uint8Array(model)))\n }\n if (updates != null) {\n for (let i = 0; i < updates.length; i++) {\n integrateRemoteStructs(y, new BinaryDecoder(new Uint8Array(updates[i])))\n }\n }\n })\n y.emit('persistenceReady')\n })\n }\n }\n\n /* overwrite */\n persist (y) {\n return toBinary(y).createBuffer()\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Persistence.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 201,
"kind": "function",
"name": "getFreshCnf",
"memberof": "src/Persistence.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Persistence.js~getFreshCnf",
"access": "public",
"export": false,
"importPath": "yjs/src/Persistence.js",
"importStyle": null,
"description": null,
"lineNumber": 7,
"undocument": true,
"params": [],
"return": {
"types": [
"{\"len\": *, \"buffer\": *}"
]
},
"ignore": true
},
{
"__docId__": 202,
"kind": "class",
"name": "AbstractPersistence",
"memberof": "src/Persistence.js",
"static": true,
"longname": "src/Persistence.js~AbstractPersistence",
"access": "public",
"export": true,
"importPath": "yjs/src/Persistence.js",
"importStyle": "AbstractPersistence",
"description": "Abstract persistence class.",
"lineNumber": 19,
"interface": false
},
{
"__docId__": 203,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Persistence.js~AbstractPersistence",
"generator": false,
"async": false,
"static": false,
"longname": "src/Persistence.js~AbstractPersistence#constructor",
"access": "public",
"description": null,
"lineNumber": 20,
"undocument": true
},
{
"__docId__": 204,
"kind": "member",
"name": "opts",
"memberof": "src/Persistence.js~AbstractPersistence",
"static": false,
"longname": "src/Persistence.js~AbstractPersistence#opts",
"access": "public",
"description": null,
"lineNumber": 21,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 205,
"kind": "member",
"name": "ys",
"memberof": "src/Persistence.js~AbstractPersistence",
"static": false,
"longname": "src/Persistence.js~AbstractPersistence#ys",
"access": "public",
"description": null,
"lineNumber": 22,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 206,
"kind": "method",
"name": "_init",
"memberof": "src/Persistence.js~AbstractPersistence",
"generator": false,
"async": false,
"static": false,
"longname": "src/Persistence.js~AbstractPersistence#_init",
"access": "private",
"description": null,
"lineNumber": 25,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 207,
"kind": "method",
"name": "deinit",
"memberof": "src/Persistence.js~AbstractPersistence",
"generator": false,
"async": false,
"static": false,
"longname": "src/Persistence.js~AbstractPersistence#deinit",
"access": "public",
"description": null,
"lineNumber": 51,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 208,
"kind": "method",
"name": "destroy",
"memberof": "src/Persistence.js~AbstractPersistence",
"generator": false,
"async": false,
"static": false,
"longname": "src/Persistence.js~AbstractPersistence#destroy",
"access": "public",
"description": null,
"lineNumber": 56,
"undocument": true,
"params": [],
"return": null
},
{
"__docId__": 210,
"kind": "method",
"name": "removePersistedData",
"memberof": "src/Persistence.js~AbstractPersistence",
"generator": false,
"async": false,
"static": false,
"longname": "src/Persistence.js~AbstractPersistence#removePersistedData",
"access": "public",
"description": "Remove all persisted data that belongs to a room.\nAutomatically destroys all Yjs all Yjs instances that persist to\nthe room. If `destroyYjsInstances = false` the persistence functionality\nwill be removed from the Yjs instances.\n\n** Must be overwritten! **",
"lineNumber": 68,
"params": [
{
"name": "room",
"types": [
"*"
]
},
{
"name": "destroyYjsInstances",
"optional": true,
"types": [
"boolean"
],
"defaultRaw": true,
"defaultValue": "true"
}
],
"return": null
},
{
"__docId__": 211,
"kind": "method",
"name": "saveUpdate",
"memberof": "src/Persistence.js~AbstractPersistence",
"generator": false,
"async": false,
"static": false,
"longname": "src/Persistence.js~AbstractPersistence#saveUpdate",
"access": "public",
"description": null,
"lineNumber": 81,
"undocument": true,
"params": [
{
"name": "buffer",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 212,
"kind": "method",
"name": "saveStruct",
"memberof": "src/Persistence.js~AbstractPersistence",
"generator": false,
"async": false,
"static": false,
"longname": "src/Persistence.js~AbstractPersistence#saveStruct",
"access": "public",
"description": "Save struct to update buffer.\nsaveUpdate is called when transaction ends",
"lineNumber": 88,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "struct",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 213,
"kind": "method",
"name": "retrieve",
"memberof": "src/Persistence.js~AbstractPersistence",
"generator": false,
"async": false,
"static": false,
"longname": "src/Persistence.js~AbstractPersistence#retrieve",
"access": "public",
"description": null,
"lineNumber": 99,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "model",
"types": [
"*"
]
},
{
"name": "updates",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 214,
"kind": "method",
"name": "persist",
"memberof": "src/Persistence.js~AbstractPersistence",
"generator": false,
"async": false,
"static": false,
"longname": "src/Persistence.js~AbstractPersistence#persist",
"access": "public",
"description": null,
"lineNumber": 119,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 215,
"kind": "file",
"name": "src/Store/DeleteStore.js",
"content": "\nimport Tree from '../Util/Tree.js'\nimport ID from '../Util/ID/ID.js'\n\nclass DSNode {\n constructor (id, len, gc) {\n this._id = id\n this.len = len\n this.gc = gc\n }\n clone () {\n return new DSNode(this._id, this.len, this.gc)\n }\n}\n\nexport default class DeleteStore extends Tree {\n logTable () {\n const deletes = []\n this.iterate(null, null, function (n) {\n deletes.push({\n user: n._id.user,\n clock: n._id.clock,\n len: n.len,\n gc: n.gc\n })\n })\n console.table(deletes)\n }\n isDeleted (id) {\n var n = this.findWithUpperBound(id)\n return n !== null && n._id.user === id.user && id.clock < n._id.clock + n.len\n }\n mark (id, length, gc) {\n if (length === 0) return\n // Step 1. Unmark range\n const leftD = this.findWithUpperBound(new ID(id.user, id.clock - 1))\n // Resize left DSNode if necessary\n if (leftD !== null && leftD._id.user === id.user) {\n if (leftD._id.clock < id.clock && id.clock < leftD._id.clock + leftD.len) {\n // node is overlapping. need to resize\n if (id.clock + length < leftD._id.clock + leftD.len) {\n // overlaps new mark range and some more\n // create another DSNode to the right of new mark\n this.put(new DSNode(new ID(id.user, id.clock + length), leftD._id.clock + leftD.len - id.clock - length, leftD.gc))\n }\n // resize left DSNode\n leftD.len = id.clock - leftD._id.clock\n } // Otherwise there is no overlapping\n }\n // Resize right DSNode if necessary\n const upper = new ID(id.user, id.clock + length - 1)\n const rightD = this.findWithUpperBound(upper)\n if (rightD !== null && rightD._id.user === id.user) {\n if (rightD._id.clock < id.clock + length && id.clock <= rightD._id.clock && id.clock + length < rightD._id.clock + rightD.len) { // we only consider the case where we resize the node\n const d = id.clock + length - rightD._id.clock\n rightD._id = new ID(rightD._id.user, rightD._id.clock + d)\n rightD.len -= d\n }\n }\n // Now we only have to delete all inner marks\n const deleteNodeIds = []\n this.iterate(id, upper, m => {\n deleteNodeIds.push(m._id)\n })\n for (let i = deleteNodeIds.length - 1; i >= 0; i--) {\n this.delete(deleteNodeIds[i])\n }\n let newMark = new DSNode(id, length, gc)\n // Step 2. Check if we can extend left or right\n if (leftD !== null && leftD._id.user === id.user && leftD._id.clock + leftD.len === id.clock && leftD.gc === gc) {\n // We can extend left\n leftD.len += length\n newMark = leftD\n }\n const rightNext = this.find(new ID(id.user, id.clock + length))\n if (rightNext !== null && rightNext._id.user === id.user && id.clock + length === rightNext._id.clock && gc === rightNext.gc) {\n // We can merge newMark and rightNext\n newMark.len += rightNext.len\n this.delete(rightNext._id)\n }\n if (leftD !== newMark) {\n // only put if we didn't extend left\n this.put(newMark)\n }\n }\n // TODO: exchange markDeleted for mark()\n markDeleted (id, length) {\n this.mark(id, length, false)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Store/DeleteStore.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 216,
"kind": "class",
"name": "DSNode",
"memberof": "src/Store/DeleteStore.js",
"static": true,
"longname": "src/Store/DeleteStore.js~DSNode",
"access": "public",
"export": false,
"importPath": "yjs/src/Store/DeleteStore.js",
"importStyle": null,
"description": null,
"lineNumber": 5,
"undocument": true,
"interface": false,
"ignore": true
},
{
"__docId__": 217,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Store/DeleteStore.js~DSNode",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/DeleteStore.js~DSNode#constructor",
"access": "public",
"description": null,
"lineNumber": 6,
"undocument": true
},
{
"__docId__": 218,
"kind": "member",
"name": "_id",
"memberof": "src/Store/DeleteStore.js~DSNode",
"static": false,
"longname": "src/Store/DeleteStore.js~DSNode#_id",
"access": "private",
"description": null,
"lineNumber": 7,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 219,
"kind": "member",
"name": "len",
"memberof": "src/Store/DeleteStore.js~DSNode",
"static": false,
"longname": "src/Store/DeleteStore.js~DSNode#len",
"access": "public",
"description": null,
"lineNumber": 8,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 220,
"kind": "member",
"name": "gc",
"memberof": "src/Store/DeleteStore.js~DSNode",
"static": false,
"longname": "src/Store/DeleteStore.js~DSNode#gc",
"access": "public",
"description": null,
"lineNumber": 9,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 221,
"kind": "method",
"name": "clone",
"memberof": "src/Store/DeleteStore.js~DSNode",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/DeleteStore.js~DSNode#clone",
"access": "public",
"description": null,
"lineNumber": 11,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 222,
"kind": "class",
"name": "DeleteStore",
"memberof": "src/Store/DeleteStore.js",
"static": true,
"longname": "src/Store/DeleteStore.js~DeleteStore",
"access": "public",
"export": true,
"importPath": "yjs/src/Store/DeleteStore.js",
"importStyle": "DeleteStore",
"description": null,
"lineNumber": 16,
"undocument": true,
"interface": false,
"extends": [
"src/Util/Tree.js~Tree"
]
},
{
"__docId__": 223,
"kind": "method",
"name": "logTable",
"memberof": "src/Store/DeleteStore.js~DeleteStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/DeleteStore.js~DeleteStore#logTable",
"access": "public",
"description": null,
"lineNumber": 17,
"undocument": true,
"params": [],
"return": null
},
{
"__docId__": 224,
"kind": "method",
"name": "isDeleted",
"memberof": "src/Store/DeleteStore.js~DeleteStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/DeleteStore.js~DeleteStore#isDeleted",
"access": "public",
"description": null,
"lineNumber": 29,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 225,
"kind": "method",
"name": "mark",
"memberof": "src/Store/DeleteStore.js~DeleteStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/DeleteStore.js~DeleteStore#mark",
"access": "public",
"description": null,
"lineNumber": 33,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
},
{
"name": "length",
"types": [
"*"
]
},
{
"name": "gc",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 226,
"kind": "method",
"name": "markDeleted",
"memberof": "src/Store/DeleteStore.js~DeleteStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/DeleteStore.js~DeleteStore#markDeleted",
"access": "public",
"description": null,
"lineNumber": 87,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
},
{
"name": "length",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 227,
"kind": "file",
"name": "src/Store/OperationStore.js",
"content": "import Tree from '../Util/Tree.js'\nimport RootID from '../Util/ID/RootID.js'\nimport { getStruct } from '../Util/structReferences.js'\nimport { logID } from '../MessageHandler/messageToString.js'\nimport GC from '../Struct/GC.js'\n\nexport default class OperationStore extends Tree {\n constructor (y) {\n super()\n this.y = y\n }\n logTable () {\n const items = []\n this.iterate(null, null, function (item) {\n if (item.constructor === GC) {\n items.push({\n id: logID(item),\n content: item._length,\n deleted: 'GC'\n })\n } else {\n items.push({\n id: logID(item),\n origin: logID(item._origin === null ? null : item._origin._lastId),\n left: logID(item._left === null ? null : item._left._lastId),\n right: logID(item._right),\n right_origin: logID(item._right_origin),\n parent: logID(item._parent),\n parentSub: item._parentSub,\n deleted: item._deleted,\n content: JSON.stringify(item._content)\n })\n }\n })\n console.table(items)\n }\n get (id) {\n let struct = this.find(id)\n if (struct === null && id instanceof RootID) {\n const Constr = getStruct(id.type)\n const y = this.y\n struct = new Constr()\n struct._id = id\n struct._parent = y\n y.transact(() => {\n struct._integrate(y)\n })\n this.put(struct)\n }\n return struct\n }\n // Use getItem for structs with _length > 1\n getItem (id) {\n var item = this.findWithUpperBound(id)\n if (item === null) {\n return null\n }\n const itemID = item._id\n if (id.user === itemID.user && id.clock < itemID.clock + item._length) {\n return item\n } else {\n return null\n }\n }\n // Return an insertion such that id is the first element of content\n // This function manipulates an item, if necessary\n getItemCleanStart (id) {\n var ins = this.getItem(id)\n if (ins === null || ins._length === 1) {\n return ins\n }\n const insID = ins._id\n if (insID.clock === id.clock) {\n return ins\n } else {\n return ins._splitAt(this.y, id.clock - insID.clock)\n }\n }\n // Return an insertion such that id is the last element of content\n // This function manipulates an operation, if necessary\n getItemCleanEnd (id) {\n var ins = this.getItem(id)\n if (ins === null || ins._length === 1) {\n return ins\n }\n const insID = ins._id\n if (insID.clock + ins._length - 1 === id.clock) {\n return ins\n } else {\n ins._splitAt(this.y, id.clock - insID.clock + 1)\n return ins\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Store/OperationStore.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 228,
"kind": "class",
"name": "OperationStore",
"memberof": "src/Store/OperationStore.js",
"static": true,
"longname": "src/Store/OperationStore.js~OperationStore",
"access": "public",
"export": true,
"importPath": "yjs/src/Store/OperationStore.js",
"importStyle": "OperationStore",
"description": null,
"lineNumber": 7,
"undocument": true,
"interface": false,
"extends": [
"src/Util/Tree.js~Tree"
]
},
{
"__docId__": 229,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Store/OperationStore.js~OperationStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/OperationStore.js~OperationStore#constructor",
"access": "public",
"description": null,
"lineNumber": 8,
"undocument": true
},
{
"__docId__": 230,
"kind": "member",
"name": "y",
"memberof": "src/Store/OperationStore.js~OperationStore",
"static": false,
"longname": "src/Store/OperationStore.js~OperationStore#y",
"access": "public",
"description": null,
"lineNumber": 10,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 231,
"kind": "method",
"name": "logTable",
"memberof": "src/Store/OperationStore.js~OperationStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/OperationStore.js~OperationStore#logTable",
"access": "public",
"description": null,
"lineNumber": 12,
"undocument": true,
"params": [],
"return": null
},
{
"__docId__": 232,
"kind": "method",
"name": "get",
"memberof": "src/Store/OperationStore.js~OperationStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/OperationStore.js~OperationStore#get",
"access": "public",
"description": null,
"lineNumber": 37,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 233,
"kind": "method",
"name": "getItem",
"memberof": "src/Store/OperationStore.js~OperationStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/OperationStore.js~OperationStore#getItem",
"access": "public",
"description": null,
"lineNumber": 53,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 234,
"kind": "method",
"name": "getItemCleanStart",
"memberof": "src/Store/OperationStore.js~OperationStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/OperationStore.js~OperationStore#getItemCleanStart",
"access": "public",
"description": null,
"lineNumber": 67,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 235,
"kind": "method",
"name": "getItemCleanEnd",
"memberof": "src/Store/OperationStore.js~OperationStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/OperationStore.js~OperationStore#getItemCleanEnd",
"access": "public",
"description": null,
"lineNumber": 81,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 236,
"kind": "file",
"name": "src/Store/StateStore.js",
"content": "import ID from '../Util/ID/ID.js'\n\nexport default class StateStore {\n constructor (y) {\n this.y = y\n this.state = new Map()\n }\n logTable () {\n const entries = []\n for (let [user, state] of this.state) {\n entries.push({\n user, state\n })\n }\n console.table(entries)\n }\n getNextID (len) {\n const user = this.y.userID\n const state = this.getState(user)\n this.setState(user, state + len)\n return new ID(user, state)\n }\n updateRemoteState (struct) {\n let user = struct._id.user\n let userState = this.state.get(user)\n while (struct !== null && struct._id.clock === userState) {\n userState += struct._length\n struct = this.y.os.get(new ID(user, userState))\n }\n this.state.set(user, userState)\n }\n getState (user) {\n let state = this.state.get(user)\n if (state == null) {\n return 0\n }\n return state\n }\n setState (user, state) {\n // TODO: modify missingi structs here\n const beforeState = this.y._transaction.beforeState\n if (!beforeState.has(user)) {\n beforeState.set(user, this.getState(user))\n }\n this.state.set(user, state)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Store/StateStore.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 237,
"kind": "class",
"name": "StateStore",
"memberof": "src/Store/StateStore.js",
"static": true,
"longname": "src/Store/StateStore.js~StateStore",
"access": "public",
"export": true,
"importPath": "yjs/src/Store/StateStore.js",
"importStyle": "StateStore",
"description": null,
"lineNumber": 3,
"undocument": true,
"interface": false
},
{
"__docId__": 238,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Store/StateStore.js~StateStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/StateStore.js~StateStore#constructor",
"access": "public",
"description": null,
"lineNumber": 4,
"undocument": true
},
{
"__docId__": 239,
"kind": "member",
"name": "y",
"memberof": "src/Store/StateStore.js~StateStore",
"static": false,
"longname": "src/Store/StateStore.js~StateStore#y",
"access": "public",
"description": null,
"lineNumber": 5,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 240,
"kind": "member",
"name": "state",
"memberof": "src/Store/StateStore.js~StateStore",
"static": false,
"longname": "src/Store/StateStore.js~StateStore#state",
"access": "public",
"description": null,
"lineNumber": 6,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 241,
"kind": "method",
"name": "logTable",
"memberof": "src/Store/StateStore.js~StateStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/StateStore.js~StateStore#logTable",
"access": "public",
"description": null,
"lineNumber": 8,
"undocument": true,
"params": [],
"return": null
},
{
"__docId__": 242,
"kind": "method",
"name": "getNextID",
"memberof": "src/Store/StateStore.js~StateStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/StateStore.js~StateStore#getNextID",
"access": "public",
"description": null,
"lineNumber": 17,
"undocument": true,
"params": [
{
"name": "len",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 243,
"kind": "method",
"name": "updateRemoteState",
"memberof": "src/Store/StateStore.js~StateStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/StateStore.js~StateStore#updateRemoteState",
"access": "public",
"description": null,
"lineNumber": 23,
"undocument": true,
"params": [
{
"name": "struct",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 244,
"kind": "method",
"name": "getState",
"memberof": "src/Store/StateStore.js~StateStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/StateStore.js~StateStore#getState",
"access": "public",
"description": null,
"lineNumber": 32,
"undocument": true,
"params": [
{
"name": "user",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 245,
"kind": "method",
"name": "setState",
"memberof": "src/Store/StateStore.js~StateStore",
"generator": false,
"async": false,
"static": false,
"longname": "src/Store/StateStore.js~StateStore#setState",
"access": "public",
"description": null,
"lineNumber": 39,
"undocument": true,
"params": [
{
"name": "user",
"types": [
"*"
]
},
{
"name": "state",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 246,
"kind": "file",
"name": "src/Struct/Delete.js",
"content": "import { getStructReference } from '../Util/structReferences.js'\nimport ID from '../Util/ID/ID.js'\nimport { logID } from '../MessageHandler/messageToString.js'\n\n/**\n * @private\n * Delete all items in an ID-range\n * TODO: implement getItemCleanStartNode for better performance (only one lookup)\n */\nexport function deleteItemRange (y, user, clock, range, gcChildren) {\n const createDelete = y.connector !== null && y.connector._forwardAppliedStructs\n let item = y.os.getItemCleanStart(new ID(user, clock))\n if (item !== null) {\n if (!item._deleted) {\n item._splitAt(y, range)\n item._delete(y, createDelete, true)\n }\n let itemLen = item._length\n range -= itemLen\n clock += itemLen\n if (range > 0) {\n let node = y.os.findNode(new ID(user, clock))\n while (node !== null && node.val !== null && range > 0 && node.val._id.equals(new ID(user, clock))) {\n const nodeVal = node.val\n if (!nodeVal._deleted) {\n nodeVal._splitAt(y, range)\n nodeVal._delete(y, createDelete, gcChildren)\n }\n const nodeLen = nodeVal._length\n range -= nodeLen\n clock += nodeLen\n node = node.next()\n }\n }\n }\n}\n\n/**\n * @private\n * A Delete change is not a real Item, but it provides the same interface as an\n * Item. The only difference is that it will not be saved in the ItemStore\n * (OperationStore), but instead it is safed in the DeleteStore.\n */\nexport default class Delete {\n constructor () {\n this._target = null\n this._length = null\n }\n\n /**\n * @private\n * Read the next Item in a Decoder and fill this Item with the read data.\n *\n * This is called when data is received from a remote peer.\n *\n * @param {Y} y The Yjs instance that this Item belongs to.\n * @param {BinaryDecoder} decoder The decoder object to read data from.\n */\n _fromBinary (y, decoder) {\n // TODO: set target, and add it to missing if not found\n // There is an edge case in p2p networks!\n const targetID = decoder.readID()\n this._targetID = targetID\n this._length = decoder.readVarUint()\n if (y.os.getItem(targetID) === null) {\n return [targetID]\n } else {\n return []\n }\n }\n\n /**\n * @private\n * Transform the properties of this type to binary and write it to an\n * BinaryEncoder.\n *\n * This is called when this Item is sent to a remote peer.\n *\n * @param {BinaryEncoder} encoder The encoder to write data to.\n */\n _toBinary (encoder) {\n encoder.writeUint8(getStructReference(this.constructor))\n encoder.writeID(this._targetID)\n encoder.writeVarUint(this._length)\n }\n\n /**\n * @private\n * Integrates this Item into the shared structure.\n *\n * This method actually applies the change to the Yjs instance. In the case of\n * Delete it marks the delete target as deleted.\n *\n * * If created remotely (a remote user deleted something),\n * this Delete is applied to all structs in id-range.\n * * If created lokally (e.g. when y-array deletes a range of elements),\n * this struct is broadcasted only (it is already executed)\n */\n _integrate (y, locallyCreated = false) {\n if (!locallyCreated) {\n // from remote\n const id = this._targetID\n deleteItemRange(y, id.user, id.clock, this._length, false)\n } else if (y.connector !== null) {\n // from local\n y.connector.broadcastStruct(this)\n }\n if (y.persistence !== null) {\n y.persistence.saveStruct(y, this)\n }\n }\n\n /**\n * Transform this YXml Type to a readable format.\n * Useful for logging as all Items and Delete implement this method.\n *\n * @private\n */\n _logString () {\n return `Delete - target: ${logID(this._targetID)}, len: ${this._length}`\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Struct/Delete.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 247,
"kind": "function",
"name": "deleteItemRange",
"memberof": "src/Struct/Delete.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Struct/Delete.js~deleteItemRange",
"access": "private",
"export": true,
"importPath": "yjs/src/Struct/Delete.js",
"importStyle": "{deleteItemRange}",
"description": "",
"lineNumber": 10,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "user",
"types": [
"*"
]
},
{
"name": "clock",
"types": [
"*"
]
},
{
"name": "range",
"types": [
"*"
]
},
{
"name": "gcChildren",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 248,
"kind": "class",
"name": "Delete",
"memberof": "src/Struct/Delete.js",
"static": true,
"longname": "src/Struct/Delete.js~Delete",
"access": "private",
"export": true,
"importPath": "yjs/src/Struct/Delete.js",
"importStyle": "Delete",
"description": "",
"lineNumber": 44,
"interface": false,
"ignore": true
},
{
"__docId__": 249,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Struct/Delete.js~Delete",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Delete.js~Delete#constructor",
"access": "public",
"description": null,
"lineNumber": 45,
"undocument": true
},
{
"__docId__": 250,
"kind": "member",
"name": "_target",
"memberof": "src/Struct/Delete.js~Delete",
"static": false,
"longname": "src/Struct/Delete.js~Delete#_target",
"access": "private",
"description": null,
"lineNumber": 46,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 251,
"kind": "member",
"name": "_length",
"memberof": "src/Struct/Delete.js~Delete",
"static": false,
"longname": "src/Struct/Delete.js~Delete#_length",
"access": "private",
"description": null,
"lineNumber": 47,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 252,
"kind": "method",
"name": "_fromBinary",
"memberof": "src/Struct/Delete.js~Delete",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Delete.js~Delete#_fromBinary",
"access": "private",
"description": "",
"lineNumber": 59,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance that this Item belongs to."
},
{
"nullable": null,
"types": [
"BinaryDecoder"
],
"spread": false,
"optional": false,
"name": "decoder",
"description": "The decoder object to read data from."
}
],
"ignore": true,
"return": {
"types": [
"*[]"
]
}
},
{
"__docId__": 253,
"kind": "member",
"name": "_targetID",
"memberof": "src/Struct/Delete.js~Delete",
"static": false,
"longname": "src/Struct/Delete.js~Delete#_targetID",
"access": "private",
"description": null,
"lineNumber": 63,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 255,
"kind": "method",
"name": "_toBinary",
"memberof": "src/Struct/Delete.js~Delete",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Delete.js~Delete#_toBinary",
"access": "private",
"description": "",
"lineNumber": 81,
"params": [
{
"nullable": null,
"types": [
"BinaryEncoder"
],
"spread": false,
"optional": false,
"name": "encoder",
"description": "The encoder to write data to."
}
],
"ignore": true,
"return": null
},
{
"__docId__": 256,
"kind": "method",
"name": "_integrate",
"memberof": "src/Struct/Delete.js~Delete",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Delete.js~Delete#_integrate",
"access": "private",
"description": "",
"lineNumber": 99,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "locallyCreated",
"optional": true,
"types": [
"boolean"
],
"defaultRaw": false,
"defaultValue": "false"
}
],
"return": null
},
{
"__docId__": 257,
"kind": "method",
"name": "_logString",
"memberof": "src/Struct/Delete.js~Delete",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Delete.js~Delete#_logString",
"access": "private",
"description": "Transform this YXml Type to a readable format.\nUseful for logging as all Items and Delete implement this method.",
"lineNumber": 119,
"ignore": true,
"params": [],
"return": {
"types": [
"string"
]
}
},
{
"__docId__": 258,
"kind": "file",
"name": "src/Struct/GC.js",
"content": "import { getStructReference } from '../Util/structReferences.js'\nimport { RootFakeUserID } from '../Util/ID/RootID.js'\nimport ID from '../Util/ID/ID.js'\n\n// TODO should have the same base class as Item\nexport default class GC {\n constructor () {\n this._id = null\n this._length = 0\n }\n\n get _deleted () {\n return true\n }\n\n _integrate (y) {\n const id = this._id\n const userState = y.ss.getState(id.user)\n if (id.clock === userState) {\n y.ss.setState(id.user, id.clock + this._length)\n }\n y.ds.mark(this._id, this._length, true)\n let n = y.os.put(this)\n const prev = n.prev().val\n if (prev !== null && prev.constructor === GC && prev._id.user === n.val._id.user && prev._id.clock + prev._length === n.val._id.clock) {\n // TODO: do merging for all items!\n prev._length += n.val._length\n y.os.delete(n.val._id)\n n = prev\n }\n if (n.val) {\n n = n.val\n }\n const next = y.os.findNext(n._id)\n if (next !== null && next.constructor === GC && next._id.user === n._id.user && next._id.clock === n._id.clock + n._length) {\n n._length += next._length\n y.os.delete(next._id)\n }\n if (id.user !== RootFakeUserID) {\n if (y.connector !== null && (y.connector._forwardAppliedStructs || id.user === y.userID)) {\n y.connector.broadcastStruct(this)\n }\n if (y.persistence !== null) {\n y.persistence.saveStruct(y, this)\n }\n }\n }\n\n /**\n * Transform the properties of this type to binary and write it to an\n * BinaryEncoder.\n *\n * This is called when this Item is sent to a remote peer.\n *\n * @param {BinaryEncoder} encoder The encoder to write data to.\n * @private\n */\n _toBinary (encoder) {\n encoder.writeUint8(getStructReference(this.constructor))\n encoder.writeID(this._id)\n encoder.writeVarUint(this._length)\n }\n\n /**\n * Read the next Item in a Decoder and fill this Item with the read data.\n *\n * This is called when data is received from a remote peer.\n *\n * @param {Y} y The Yjs instance that this Item belongs to.\n * @param {BinaryDecoder} decoder The decoder object to read data from.\n * @private\n */\n _fromBinary (y, decoder) {\n const id = decoder.readID()\n this._id = id\n this._length = decoder.readVarUint()\n const missing = []\n if (y.ss.getState(id.user) < id.clock) {\n missing.push(new ID(id.user, id.clock - 1))\n }\n return missing\n }\n\n _splitAt () {\n return this\n }\n\n _clonePartial (diff) {\n const gc = new GC()\n gc._id = new ID(this._id.user, this._id.clock + diff)\n gc._length = this._length - diff\n return gc\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Struct/GC.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 259,
"kind": "class",
"name": "GC",
"memberof": "src/Struct/GC.js",
"static": true,
"longname": "src/Struct/GC.js~GC",
"access": "public",
"export": true,
"importPath": "yjs/src/Struct/GC.js",
"importStyle": "GC",
"description": null,
"lineNumber": 6,
"undocument": true,
"interface": false
},
{
"__docId__": 260,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Struct/GC.js~GC",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/GC.js~GC#constructor",
"access": "public",
"description": null,
"lineNumber": 7,
"undocument": true
},
{
"__docId__": 261,
"kind": "member",
"name": "_id",
"memberof": "src/Struct/GC.js~GC",
"static": false,
"longname": "src/Struct/GC.js~GC#_id",
"access": "private",
"description": null,
"lineNumber": 8,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 262,
"kind": "member",
"name": "_length",
"memberof": "src/Struct/GC.js~GC",
"static": false,
"longname": "src/Struct/GC.js~GC#_length",
"access": "private",
"description": null,
"lineNumber": 9,
"undocument": true,
"ignore": true,
"type": {
"types": [
"number"
]
}
},
{
"__docId__": 263,
"kind": "get",
"name": "_deleted",
"memberof": "src/Struct/GC.js~GC",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/GC.js~GC#_deleted",
"access": "private",
"description": null,
"lineNumber": 12,
"undocument": true,
"ignore": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 264,
"kind": "method",
"name": "_integrate",
"memberof": "src/Struct/GC.js~GC",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/GC.js~GC#_integrate",
"access": "private",
"description": null,
"lineNumber": 16,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 265,
"kind": "method",
"name": "_toBinary",
"memberof": "src/Struct/GC.js~GC",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/GC.js~GC#_toBinary",
"access": "private",
"description": "Transform the properties of this type to binary and write it to an\nBinaryEncoder.\n\nThis is called when this Item is sent to a remote peer.",
"lineNumber": 58,
"params": [
{
"nullable": null,
"types": [
"BinaryEncoder"
],
"spread": false,
"optional": false,
"name": "encoder",
"description": "The encoder to write data to."
}
],
"ignore": true,
"return": null
},
{
"__docId__": 266,
"kind": "method",
"name": "_fromBinary",
"memberof": "src/Struct/GC.js~GC",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/GC.js~GC#_fromBinary",
"access": "private",
"description": "Read the next Item in a Decoder and fill this Item with the read data.\n\nThis is called when data is received from a remote peer.",
"lineNumber": 73,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance that this Item belongs to."
},
{
"nullable": null,
"types": [
"BinaryDecoder"
],
"spread": false,
"optional": false,
"name": "decoder",
"description": "The decoder object to read data from."
}
],
"ignore": true,
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 269,
"kind": "method",
"name": "_splitAt",
"memberof": "src/Struct/GC.js~GC",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/GC.js~GC#_splitAt",
"access": "private",
"description": null,
"lineNumber": 84,
"undocument": true,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 270,
"kind": "method",
"name": "_clonePartial",
"memberof": "src/Struct/GC.js~GC",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/GC.js~GC#_clonePartial",
"access": "private",
"description": null,
"lineNumber": 88,
"undocument": true,
"ignore": true,
"params": [
{
"name": "diff",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 271,
"kind": "file",
"name": "src/Struct/Item.js",
"content": "import { getStructReference } from '../Util/structReferences.js'\nimport ID from '../Util/ID/ID.js'\nimport { default as RootID, RootFakeUserID } from '../Util/ID/RootID.js'\nimport Delete from './Delete.js'\nimport { transactionTypeChanged } from '../Transaction.js'\nimport GC from './GC.js'\n\n/**\n * @private\n * Helper utility to split an Item (see {@link Item#_splitAt})\n * - copies all properties from a to b\n * - connects a to b\n * - assigns the correct _id\n * - saves b to os\n */\nexport function splitHelper (y, a, b, diff) {\n const aID = a._id\n b._id = new ID(aID.user, aID.clock + diff)\n b._origin = a\n b._left = a\n b._right = a._right\n if (b._right !== null) {\n b._right._left = b\n }\n b._right_origin = a._right_origin\n // do not set a._right_origin, as this will lead to problems when syncing\n a._right = b\n b._parent = a._parent\n b._parentSub = a._parentSub\n b._deleted = a._deleted\n // now search all relevant items to the right and update origin\n // if origin is not it foundOrigins, we don't have to search any longer\n let foundOrigins = new Set()\n foundOrigins.add(a)\n let o = b._right\n while (o !== null && foundOrigins.has(o._origin)) {\n if (o._origin === a) {\n o._origin = b\n }\n foundOrigins.add(o)\n o = o._right\n }\n y.os.put(b)\n if (y._transaction.newTypes.has(a)) {\n y._transaction.newTypes.add(b)\n } else if (y._transaction.deletedStructs.has(a)) {\n y._transaction.deletedStructs.add(b)\n }\n}\n\n/**\n * Abstract class that represents any content.\n */\nexport default class Item {\n constructor () {\n /**\n * The uniqe identifier of this type.\n * @type {ID}\n */\n this._id = null\n /**\n * The item that was originally to the left of this item.\n * @type {Item}\n */\n this._origin = null\n /**\n * The item that is currently to the left of this item.\n * @type {Item}\n */\n this._left = null\n /**\n * The item that is currently to the right of this item.\n * @type {Item}\n */\n this._right = null\n /**\n * The item that was originally to the right of this item.\n * @type {Item}\n */\n this._right_origin = null\n /**\n * The parent type.\n * @type {Y|YType}\n */\n this._parent = null\n /**\n * If the parent refers to this item with some kind of key (e.g. YMap, the\n * key is specified here. The key is then used to refer to the list in which\n * to insert this item. If `parentSub = null` type._start is the list in\n * which to insert to. Otherwise it is `parent._start`.\n * @type {String}\n */\n this._parentSub = null\n /**\n * Whether this item was deleted or not.\n * @type {Boolean}\n */\n this._deleted = false\n /**\n * If this type's effect is reundone this type refers to the type that undid\n * this operation.\n * @type {Item}\n */\n this._redone = null\n }\n\n /**\n * Creates an Item with the same effect as this Item (without position effect)\n *\n * @private\n */\n _copy () {\n return new this.constructor()\n }\n\n /**\n * Redoes the effect of this operation.\n *\n * @param {Y} y The Yjs instance.\n *\n * @private\n */\n _redo (y) {\n if (this._redone !== null) {\n return this._redone\n }\n let struct = this._copy()\n let left = this._left\n let right = this\n let parent = this._parent\n // make sure that parent is redone\n if (parent._deleted === true && parent._redone === null) {\n parent._redo(y)\n }\n if (parent._redone !== null) {\n parent = parent._redone\n // find next cloned items\n while (left !== null) {\n if (left._redone !== null && left._redone._parent === parent) {\n left = left._redone\n break\n }\n left = left._left\n }\n while (right !== null) {\n if (right._redone !== null && right._redone._parent === parent) {\n right = right._redone\n }\n right = right._right\n }\n }\n struct._origin = left\n struct._left = left\n struct._right = right\n struct._right_origin = right\n struct._parent = parent\n struct._parentSub = this._parentSub\n struct._integrate(y)\n this._redone = struct\n return struct\n }\n\n /**\n * Computes the last content address of this Item.\n *\n * @private\n */\n get _lastId () {\n return new ID(this._id.user, this._id.clock + this._length - 1)\n }\n\n /**\n * Computes the length of this Item.\n *\n * @private\n */\n get _length () {\n return 1\n }\n\n /**\n * Should return false if this Item is some kind of meta information\n * (e.g. format information).\n *\n * * Whether this Item should be addressable via `yarray.get(i)`\n * * Whether this Item should be counted when computing yarray.length\n *\n * @private\n */\n get _countable () {\n return true\n }\n\n /**\n * Splits this Item so that another Items can be inserted in-between.\n * This must be overwritten if _length > 1\n * Returns right part after split\n * * diff === 0 => this\n * * diff === length => this._right\n * * otherwise => split _content and return right part of split\n * (see {@link ItemJSON}/{@link ItemString} for implementation)\n *\n * @private\n */\n _splitAt (y, diff) {\n if (diff === 0) {\n return this\n }\n return this._right\n }\n\n /**\n * Mark this Item as deleted.\n *\n * @param {Y} y The Yjs instance\n * @param {boolean} createDelete Whether to propagate a message that this\n * Type was deleted.\n *\n * @private\n */\n _delete (y, createDelete = true) {\n if (!this._deleted) {\n this._deleted = true\n y.ds.mark(this._id, this._length, false)\n let del = new Delete()\n del._targetID = this._id\n del._length = this._length\n if (createDelete) {\n // broadcast and persists Delete\n del._integrate(y, true)\n } else if (y.persistence !== null) {\n // only persist Delete\n y.persistence.saveStruct(y, del)\n }\n transactionTypeChanged(y, this._parent, this._parentSub)\n y._transaction.deletedStructs.add(this)\n }\n }\n\n _gcChildren (y) {}\n\n _gc (y) {\n const gc = new GC()\n gc._id = this._id\n gc._length = this._length\n y.os.delete(this._id)\n gc._integrate(y)\n }\n\n /**\n * This is called right before this Item receives any children.\n * It can be overwritten to apply pending changes before applying remote changes\n *\n * @private\n */\n _beforeChange () {\n // nop\n }\n\n /**\n * Integrates this Item into the shared structure.\n *\n * This method actually applies the change to the Yjs instance. In case of\n * Item it connects _left and _right to this Item and calls the\n * {@link Item#beforeChange} method.\n *\n * * Integrate the struct so that other types/structs can see it\n * * Add this struct to y.os\n * * Check if this is struct deleted\n *\n * @private\n */\n _integrate (y) {\n y._transaction.newTypes.add(this)\n const parent = this._parent\n const selfID = this._id\n const user = selfID === null ? y.userID : selfID.user\n const userState = y.ss.getState(user)\n if (selfID === null) {\n this._id = y.ss.getNextID(this._length)\n } else if (selfID.user === RootFakeUserID) {\n // nop\n } else if (selfID.clock < userState) {\n // already applied..\n return []\n } else if (selfID.clock === userState) {\n y.ss.setState(selfID.user, userState + this._length)\n } else {\n // missing content from user\n throw new Error('Can not apply yet!')\n }\n if (!parent._deleted && !y._transaction.changedTypes.has(parent) && !y._transaction.newTypes.has(parent)) {\n // this is the first time parent is updated\n // or this types is new\n this._parent._beforeChange()\n }\n\n /*\n # $this has to find a unique position between origin and the next known character\n # case 1: $origin equals $o.origin: the $creator parameter decides if left or right\n # let $OL= [o1,o2,o3,o4], whereby $this is to be inserted between o1 and o4\n # o2,o3 and o4 origin is 1 (the position of o2)\n # there is the case that $this.creator < o2.creator, but o3.creator < $this.creator\n # then o2 knows o3. Since on another client $OL could be [o1,o3,o4] the problem is complex\n # therefore $this would be always to the right of o3\n # case 2: $origin < $o.origin\n # if current $this insert_position > $o origin: $this ins\n # else $insert_position will not change\n # (maybe we encounter case 1 later, then this will be to the right of $o)\n # case 3: $origin > $o.origin\n # $this insert_position is to the left of $o (forever!)\n */\n // handle conflicts\n let o\n // set o to the first conflicting item\n if (this._left !== null) {\n o = this._left._right\n } else if (this._parentSub !== null) {\n o = this._parent._map.get(this._parentSub) || null\n } else {\n o = this._parent._start\n }\n let conflictingItems = new Set()\n let itemsBeforeOrigin = new Set()\n // Let c in conflictingItems, b in itemsBeforeOrigin\n // ***{origin}bbbb{this}{c,b}{c,b}{o}***\n // Note that conflictingItems is a subset of itemsBeforeOrigin\n while (o !== null && o !== this._right) {\n itemsBeforeOrigin.add(o)\n conflictingItems.add(o)\n if (this._origin === o._origin) {\n // case 1\n if (o._id.user < this._id.user) {\n this._left = o\n conflictingItems.clear()\n }\n } else if (itemsBeforeOrigin.has(o._origin)) {\n // case 2\n if (!conflictingItems.has(o._origin)) {\n this._left = o\n conflictingItems.clear()\n }\n } else {\n break\n }\n // TODO: try to use right_origin instead.\n // Then you could basically omit conflictingItems!\n // Note: you probably can't use right_origin in every case.. only when setting _left\n o = o._right\n }\n // reconnect left/right + update parent map/start if necessary\n const parentSub = this._parentSub\n if (this._left === null) {\n let right\n if (parentSub !== null) {\n const pmap = parent._map\n right = pmap.get(parentSub) || null\n pmap.set(parentSub, this)\n } else {\n right = parent._start\n parent._start = this\n }\n this._right = right\n if (right !== null) {\n right._left = this\n }\n } else {\n const left = this._left\n const right = left._right\n this._right = right\n left._right = this\n if (right !== null) {\n right._left = this\n }\n }\n if (parent._deleted) {\n this._delete(y, false)\n }\n y.os.put(this)\n transactionTypeChanged(y, parent, parentSub)\n if (this._id.user !== RootFakeUserID) {\n if (y.connector !== null && (y.connector._forwardAppliedStructs || this._id.user === y.userID)) {\n y.connector.broadcastStruct(this)\n }\n if (y.persistence !== null) {\n y.persistence.saveStruct(y, this)\n }\n }\n }\n\n /**\n * Transform the properties of this type to binary and write it to an\n * BinaryEncoder.\n *\n * This is called when this Item is sent to a remote peer.\n *\n * @param {BinaryEncoder} encoder The encoder to write data to.\n *\n * @private\n */\n _toBinary (encoder) {\n encoder.writeUint8(getStructReference(this.constructor))\n let info = 0\n if (this._origin !== null) {\n info += 0b1 // origin is defined\n }\n // TODO: remove\n /* no longer send _left\n if (this._left !== this._origin) {\n info += 0b10 // do not copy origin to left\n }\n */\n if (this._right_origin !== null) {\n info += 0b100\n }\n if (this._parentSub !== null) {\n info += 0b1000\n }\n encoder.writeUint8(info)\n encoder.writeID(this._id)\n if (info & 0b1) {\n encoder.writeID(this._origin._lastId)\n }\n // TODO: remove\n /* see above\n if (info & 0b10) {\n encoder.writeID(this._left._lastId)\n }\n */\n if (info & 0b100) {\n encoder.writeID(this._right_origin._id)\n }\n if ((info & 0b101) === 0) {\n // neither origin nor right is defined\n encoder.writeID(this._parent._id)\n }\n if (info & 0b1000) {\n encoder.writeVarString(JSON.stringify(this._parentSub))\n }\n }\n\n /**\n * Read the next Item in a Decoder and fill this Item with the read data.\n *\n * This is called when data is received from a remote peer.\n *\n * @param {Y} y The Yjs instance that this Item belongs to.\n * @param {BinaryDecoder} decoder The decoder object to read data from.\n *\n * @private\n */\n _fromBinary (y, decoder) {\n let missing = []\n const info = decoder.readUint8()\n const id = decoder.readID()\n this._id = id\n // read origin\n if (info & 0b1) {\n // origin != null\n const originID = decoder.readID()\n // we have to query for left again because it might have been split/merged..\n const origin = y.os.getItemCleanEnd(originID)\n if (origin === null) {\n missing.push(originID)\n } else {\n this._origin = origin\n this._left = this._origin\n }\n }\n // read right\n if (info & 0b100) {\n // right != null\n const rightID = decoder.readID()\n // we have to query for right again because it might have been split/merged..\n const right = y.os.getItemCleanStart(rightID)\n if (right === null) {\n missing.push(rightID)\n } else {\n this._right = right\n this._right_origin = right\n }\n }\n // read parent\n if ((info & 0b101) === 0) {\n // neither origin nor right is defined\n const parentID = decoder.readID()\n // parent does not change, so we don't have to search for it again\n if (this._parent === null) {\n let parent\n if (parentID.constructor === RootID) {\n parent = y.os.get(parentID)\n } else {\n parent = y.os.getItem(parentID)\n }\n if (parent === null) {\n missing.push(parentID)\n } else {\n this._parent = parent\n }\n }\n } else if (this._parent === null) {\n if (this._origin !== null) {\n if (this._origin.constructor === GC) {\n // if origin is a gc, set parent also gc'd\n this._parent = this._origin\n } else {\n this._parent = this._origin._parent\n }\n } else if (this._right_origin !== null) {\n // if origin is a gc, set parent also gc'd\n if (this._right_origin.constructor === GC) {\n this._parent = this._right_origin\n } else {\n this._parent = this._right_origin._parent\n }\n }\n }\n if (info & 0b1000) {\n // TODO: maybe put this in read parent condition (you can also read parentsub from left/right)\n this._parentSub = JSON.parse(decoder.readVarString())\n }\n if (y.ss.getState(id.user) < id.clock) {\n missing.push(new ID(id.user, id.clock - 1))\n }\n return missing\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Struct/Item.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 272,
"kind": "function",
"name": "splitHelper",
"memberof": "src/Struct/Item.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Struct/Item.js~splitHelper",
"access": "private",
"export": true,
"importPath": "yjs/src/Struct/Item.js",
"importStyle": "{splitHelper}",
"description": "",
"lineNumber": 16,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "a",
"types": [
"*"
]
},
{
"name": "b",
"types": [
"*"
]
},
{
"name": "diff",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 273,
"kind": "class",
"name": "Item",
"memberof": "src/Struct/Item.js",
"static": true,
"longname": "src/Struct/Item.js~Item",
"access": "public",
"export": true,
"importPath": "yjs/src/Struct/Item.js",
"importStyle": "Item",
"description": "Abstract class that represents any content.",
"lineNumber": 54,
"interface": false
},
{
"__docId__": 274,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#constructor",
"access": "public",
"description": null,
"lineNumber": 55,
"undocument": true
},
{
"__docId__": 275,
"kind": "member",
"name": "_id",
"memberof": "src/Struct/Item.js~Item",
"static": false,
"longname": "src/Struct/Item.js~Item#_id",
"access": "private",
"description": "The uniqe identifier of this type.",
"lineNumber": 60,
"type": {
"nullable": null,
"types": [
"ID"
],
"spread": false,
"description": null
},
"ignore": true
},
{
"__docId__": 276,
"kind": "member",
"name": "_origin",
"memberof": "src/Struct/Item.js~Item",
"static": false,
"longname": "src/Struct/Item.js~Item#_origin",
"access": "private",
"description": "The item that was originally to the left of this item.",
"lineNumber": 65,
"type": {
"nullable": null,
"types": [
"Item"
],
"spread": false,
"description": null
},
"ignore": true
},
{
"__docId__": 277,
"kind": "member",
"name": "_left",
"memberof": "src/Struct/Item.js~Item",
"static": false,
"longname": "src/Struct/Item.js~Item#_left",
"access": "private",
"description": "The item that is currently to the left of this item.",
"lineNumber": 70,
"type": {
"nullable": null,
"types": [
"Item"
],
"spread": false,
"description": null
},
"ignore": true
},
{
"__docId__": 278,
"kind": "member",
"name": "_right",
"memberof": "src/Struct/Item.js~Item",
"static": false,
"longname": "src/Struct/Item.js~Item#_right",
"access": "private",
"description": "The item that is currently to the right of this item.",
"lineNumber": 75,
"type": {
"nullable": null,
"types": [
"Item"
],
"spread": false,
"description": null
},
"ignore": true
},
{
"__docId__": 279,
"kind": "member",
"name": "_right_origin",
"memberof": "src/Struct/Item.js~Item",
"static": false,
"longname": "src/Struct/Item.js~Item#_right_origin",
"access": "private",
"description": "The item that was originally to the right of this item.",
"lineNumber": 80,
"type": {
"nullable": null,
"types": [
"Item"
],
"spread": false,
"description": null
},
"ignore": true
},
{
"__docId__": 280,
"kind": "member",
"name": "_parent",
"memberof": "src/Struct/Item.js~Item",
"static": false,
"longname": "src/Struct/Item.js~Item#_parent",
"access": "private",
"description": "The parent type.",
"lineNumber": 85,
"type": {
"nullable": null,
"types": [
"Y",
"YType"
],
"spread": false,
"description": null
},
"ignore": true
},
{
"__docId__": 281,
"kind": "member",
"name": "_parentSub",
"memberof": "src/Struct/Item.js~Item",
"static": false,
"longname": "src/Struct/Item.js~Item#_parentSub",
"access": "private",
"description": "If the parent refers to this item with some kind of key (e.g. YMap, the\nkey is specified here. The key is then used to refer to the list in which\nto insert this item. If `parentSub = null` type._start is the list in\nwhich to insert to. Otherwise it is `parent._start`.",
"lineNumber": 93,
"type": {
"nullable": null,
"types": [
"String"
],
"spread": false,
"description": null
},
"ignore": true
},
{
"__docId__": 282,
"kind": "member",
"name": "_deleted",
"memberof": "src/Struct/Item.js~Item",
"static": false,
"longname": "src/Struct/Item.js~Item#_deleted",
"access": "private",
"description": "Whether this item was deleted or not.",
"lineNumber": 98,
"type": {
"nullable": null,
"types": [
"Boolean"
],
"spread": false,
"description": null
},
"ignore": true
},
{
"__docId__": 283,
"kind": "member",
"name": "_redone",
"memberof": "src/Struct/Item.js~Item",
"static": false,
"longname": "src/Struct/Item.js~Item#_redone",
"access": "private",
"description": "If this type's effect is reundone this type refers to the type that undid\nthis operation.",
"lineNumber": 104,
"type": {
"nullable": null,
"types": [
"Item"
],
"spread": false,
"description": null
},
"ignore": true
},
{
"__docId__": 284,
"kind": "method",
"name": "_copy",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_copy",
"access": "private",
"description": "Creates an Item with the same effect as this Item (without position effect)",
"lineNumber": 112,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 285,
"kind": "method",
"name": "_redo",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_redo",
"access": "private",
"description": "Redoes the effect of this operation.",
"lineNumber": 123,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance."
}
],
"ignore": true,
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 287,
"kind": "get",
"name": "_lastId",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_lastId",
"access": "private",
"description": "Computes the last content address of this Item.",
"lineNumber": 168,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 288,
"kind": "get",
"name": "_length",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_length",
"access": "private",
"description": "Computes the length of this Item.",
"lineNumber": 177,
"ignore": true,
"type": {
"types": [
"number"
]
}
},
{
"__docId__": 289,
"kind": "get",
"name": "_countable",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_countable",
"access": "private",
"description": "Should return false if this Item is some kind of meta information\n(e.g. format information).\n\n* Whether this Item should be addressable via `yarray.get(i)`\n* Whether this Item should be counted when computing yarray.length",
"lineNumber": 190,
"ignore": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 290,
"kind": "method",
"name": "_splitAt",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_splitAt",
"access": "private",
"description": "Splits this Item so that another Items can be inserted in-between.\nThis must be overwritten if _length > 1\nReturns right part after split\n* diff === 0 => this\n* diff === length => this._right\n* otherwise => split _content and return right part of split\n(see {@link ItemJSON}/{@link ItemString} for implementation)",
"lineNumber": 205,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "diff",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 291,
"kind": "method",
"name": "_delete",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_delete",
"access": "private",
"description": "Mark this Item as deleted.",
"lineNumber": 221,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance"
},
{
"nullable": null,
"types": [
"boolean"
],
"spread": false,
"optional": false,
"name": "createDelete",
"description": "Whether to propagate a message that this\n Type was deleted."
}
],
"ignore": true,
"return": null
},
{
"__docId__": 293,
"kind": "method",
"name": "_gcChildren",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_gcChildren",
"access": "private",
"description": null,
"lineNumber": 240,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 294,
"kind": "method",
"name": "_gc",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_gc",
"access": "private",
"description": null,
"lineNumber": 242,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 295,
"kind": "method",
"name": "_beforeChange",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_beforeChange",
"access": "private",
"description": "This is called right before this Item receives any children.\nIt can be overwritten to apply pending changes before applying remote changes",
"lineNumber": 256,
"ignore": true,
"params": [],
"return": null
},
{
"__docId__": 296,
"kind": "method",
"name": "_integrate",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_integrate",
"access": "private",
"description": "Integrates this Item into the shared structure.\n\nThis method actually applies the change to the Yjs instance. In case of\nItem it connects _left and _right to this Item and calls the\n{@link Item#beforeChange} method.\n\n* Integrate the struct so that other types/structs can see it\n* Add this struct to y.os\n* Check if this is struct deleted",
"lineNumber": 273,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
}
],
"return": {
"types": [
"*[]"
]
}
},
{
"__docId__": 302,
"kind": "method",
"name": "_toBinary",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_toBinary",
"access": "private",
"description": "Transform the properties of this type to binary and write it to an\nBinaryEncoder.\n\nThis is called when this Item is sent to a remote peer.",
"lineNumber": 401,
"params": [
{
"nullable": null,
"types": [
"BinaryEncoder"
],
"spread": false,
"optional": false,
"name": "encoder",
"description": "The encoder to write data to."
}
],
"ignore": true,
"return": null
},
{
"__docId__": 303,
"kind": "method",
"name": "_fromBinary",
"memberof": "src/Struct/Item.js~Item",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Item.js~Item#_fromBinary",
"access": "private",
"description": "Read the next Item in a Decoder and fill this Item with the read data.\n\nThis is called when data is received from a remote peer.",
"lineNumber": 452,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance that this Item belongs to."
},
{
"nullable": null,
"types": [
"BinaryDecoder"
],
"spread": false,
"optional": false,
"name": "decoder",
"description": "The decoder object to read data from."
}
],
"ignore": true,
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 315,
"kind": "file",
"name": "src/Struct/ItemEmbed.js",
"content": "import { default as Item } from './Item.js'\nimport { logItemHelper } from '../MessageHandler/messageToString.js'\n\nexport default class ItemEmbed extends Item {\n constructor () {\n super()\n this.embed = null\n }\n _copy (undeleteChildren, copyPosition) {\n let struct = super._copy(undeleteChildren, copyPosition)\n struct.embed = this.embed\n return struct\n }\n get _length () {\n return 1\n }\n _fromBinary (y, decoder) {\n const missing = super._fromBinary(y, decoder)\n this.embed = JSON.parse(decoder.readVarString())\n return missing\n }\n _toBinary (encoder) {\n super._toBinary(encoder)\n encoder.writeVarString(JSON.stringify(this.embed))\n }\n /**\n * Transform this YXml Type to a readable format.\n * Useful for logging as all Items and Delete implement this method.\n *\n * @private\n */\n _logString () {\n return logItemHelper('ItemEmbed', this, `embed:${JSON.stringify(this.embed)}`)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Struct/ItemEmbed.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 316,
"kind": "class",
"name": "ItemEmbed",
"memberof": "src/Struct/ItemEmbed.js",
"static": true,
"longname": "src/Struct/ItemEmbed.js~ItemEmbed",
"access": "public",
"export": true,
"importPath": "yjs/src/Struct/ItemEmbed.js",
"importStyle": "ItemEmbed",
"description": null,
"lineNumber": 4,
"undocument": true,
"interface": false,
"extends": [
"src/Struct/Item.js~Item"
]
},
{
"__docId__": 317,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Struct/ItemEmbed.js~ItemEmbed",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemEmbed.js~ItemEmbed#constructor",
"access": "public",
"description": null,
"lineNumber": 5,
"undocument": true
},
{
"__docId__": 318,
"kind": "member",
"name": "embed",
"memberof": "src/Struct/ItemEmbed.js~ItemEmbed",
"static": false,
"longname": "src/Struct/ItemEmbed.js~ItemEmbed#embed",
"access": "public",
"description": null,
"lineNumber": 7,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 319,
"kind": "method",
"name": "_copy",
"memberof": "src/Struct/ItemEmbed.js~ItemEmbed",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemEmbed.js~ItemEmbed#_copy",
"access": "private",
"description": null,
"lineNumber": 9,
"undocument": true,
"ignore": true,
"params": [
{
"name": "undeleteChildren",
"types": [
"*"
]
},
{
"name": "copyPosition",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 320,
"kind": "get",
"name": "_length",
"memberof": "src/Struct/ItemEmbed.js~ItemEmbed",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemEmbed.js~ItemEmbed#_length",
"access": "private",
"description": null,
"lineNumber": 14,
"undocument": true,
"ignore": true,
"type": {
"types": [
"number"
]
}
},
{
"__docId__": 321,
"kind": "method",
"name": "_fromBinary",
"memberof": "src/Struct/ItemEmbed.js~ItemEmbed",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemEmbed.js~ItemEmbed#_fromBinary",
"access": "private",
"description": null,
"lineNumber": 17,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "decoder",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 323,
"kind": "method",
"name": "_toBinary",
"memberof": "src/Struct/ItemEmbed.js~ItemEmbed",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemEmbed.js~ItemEmbed#_toBinary",
"access": "private",
"description": null,
"lineNumber": 22,
"undocument": true,
"ignore": true,
"params": [
{
"name": "encoder",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 324,
"kind": "method",
"name": "_logString",
"memberof": "src/Struct/ItemEmbed.js~ItemEmbed",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemEmbed.js~ItemEmbed#_logString",
"access": "private",
"description": "Transform this YXml Type to a readable format.\nUseful for logging as all Items and Delete implement this method.",
"lineNumber": 32,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 325,
"kind": "file",
"name": "src/Struct/ItemFormat.js",
"content": "import { default as Item } from './Item.js'\nimport { logItemHelper } from '../MessageHandler/messageToString.js'\n\nexport default class ItemFormat extends Item {\n constructor () {\n super()\n this.key = null\n this.value = null\n }\n _copy (undeleteChildren, copyPosition) {\n let struct = super._copy(undeleteChildren, copyPosition)\n struct.key = this.key\n struct.value = this.value\n return struct\n }\n get _length () {\n return 1\n }\n get _countable () {\n return false\n }\n _fromBinary (y, decoder) {\n const missing = super._fromBinary(y, decoder)\n this.key = decoder.readVarString()\n this.value = JSON.parse(decoder.readVarString())\n return missing\n }\n _toBinary (encoder) {\n super._toBinary(encoder)\n encoder.writeVarString(this.key)\n encoder.writeVarString(JSON.stringify(this.value))\n }\n /**\n * Transform this YXml Type to a readable format.\n * Useful for logging as all Items and Delete implement this method.\n *\n * @private\n */\n _logString () {\n return logItemHelper('ItemFormat', this, `key:${JSON.stringify(this.key)},value:${JSON.stringify(this.value)}`)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Struct/ItemFormat.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 326,
"kind": "class",
"name": "ItemFormat",
"memberof": "src/Struct/ItemFormat.js",
"static": true,
"longname": "src/Struct/ItemFormat.js~ItemFormat",
"access": "public",
"export": true,
"importPath": "yjs/src/Struct/ItemFormat.js",
"importStyle": "ItemFormat",
"description": null,
"lineNumber": 4,
"undocument": true,
"interface": false,
"extends": [
"src/Struct/Item.js~Item"
]
},
{
"__docId__": 327,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Struct/ItemFormat.js~ItemFormat",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemFormat.js~ItemFormat#constructor",
"access": "public",
"description": null,
"lineNumber": 5,
"undocument": true
},
{
"__docId__": 328,
"kind": "member",
"name": "key",
"memberof": "src/Struct/ItemFormat.js~ItemFormat",
"static": false,
"longname": "src/Struct/ItemFormat.js~ItemFormat#key",
"access": "public",
"description": null,
"lineNumber": 7,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 329,
"kind": "member",
"name": "value",
"memberof": "src/Struct/ItemFormat.js~ItemFormat",
"static": false,
"longname": "src/Struct/ItemFormat.js~ItemFormat#value",
"access": "public",
"description": null,
"lineNumber": 8,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 330,
"kind": "method",
"name": "_copy",
"memberof": "src/Struct/ItemFormat.js~ItemFormat",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemFormat.js~ItemFormat#_copy",
"access": "private",
"description": null,
"lineNumber": 10,
"undocument": true,
"ignore": true,
"params": [
{
"name": "undeleteChildren",
"types": [
"*"
]
},
{
"name": "copyPosition",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 331,
"kind": "get",
"name": "_length",
"memberof": "src/Struct/ItemFormat.js~ItemFormat",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemFormat.js~ItemFormat#_length",
"access": "private",
"description": null,
"lineNumber": 16,
"undocument": true,
"ignore": true,
"type": {
"types": [
"number"
]
}
},
{
"__docId__": 332,
"kind": "get",
"name": "_countable",
"memberof": "src/Struct/ItemFormat.js~ItemFormat",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemFormat.js~ItemFormat#_countable",
"access": "private",
"description": null,
"lineNumber": 19,
"undocument": true,
"ignore": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 333,
"kind": "method",
"name": "_fromBinary",
"memberof": "src/Struct/ItemFormat.js~ItemFormat",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemFormat.js~ItemFormat#_fromBinary",
"access": "private",
"description": null,
"lineNumber": 22,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "decoder",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 336,
"kind": "method",
"name": "_toBinary",
"memberof": "src/Struct/ItemFormat.js~ItemFormat",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemFormat.js~ItemFormat#_toBinary",
"access": "private",
"description": null,
"lineNumber": 28,
"undocument": true,
"ignore": true,
"params": [
{
"name": "encoder",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 337,
"kind": "method",
"name": "_logString",
"memberof": "src/Struct/ItemFormat.js~ItemFormat",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemFormat.js~ItemFormat#_logString",
"access": "private",
"description": "Transform this YXml Type to a readable format.\nUseful for logging as all Items and Delete implement this method.",
"lineNumber": 39,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 338,
"kind": "file",
"name": "src/Struct/ItemJSON.js",
"content": "import { splitHelper, default as Item } from './Item.js'\nimport { logItemHelper } from '../MessageHandler/messageToString.js'\n\nexport default class ItemJSON extends Item {\n constructor () {\n super()\n this._content = null\n }\n _copy () {\n let struct = super._copy()\n struct._content = this._content\n return struct\n }\n get _length () {\n return this._content.length\n }\n _fromBinary (y, decoder) {\n let missing = super._fromBinary(y, decoder)\n let len = decoder.readVarUint()\n this._content = new Array(len)\n for (let i = 0; i < len; i++) {\n const ctnt = decoder.readVarString()\n let parsed\n if (ctnt === 'undefined') {\n parsed = undefined\n } else {\n parsed = JSON.parse(ctnt)\n }\n this._content[i] = parsed\n }\n return missing\n }\n _toBinary (encoder) {\n super._toBinary(encoder)\n let len = this._content.length\n encoder.writeVarUint(len)\n for (let i = 0; i < len; i++) {\n let encoded\n let content = this._content[i]\n if (content === undefined) {\n encoded = 'undefined'\n } else {\n encoded = JSON.stringify(content)\n }\n encoder.writeVarString(encoded)\n }\n }\n /**\n * Transform this YXml Type to a readable format.\n * Useful for logging as all Items and Delete implement this method.\n *\n * @private\n */\n _logString () {\n return logItemHelper('ItemJSON', this, `content:${JSON.stringify(this._content)}`)\n }\n _splitAt (y, diff) {\n if (diff === 0) {\n return this\n } else if (diff >= this._length) {\n return this._right\n }\n let item = new ItemJSON()\n item._content = this._content.splice(diff)\n splitHelper(y, this, item, diff)\n return item\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Struct/ItemJSON.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 339,
"kind": "class",
"name": "ItemJSON",
"memberof": "src/Struct/ItemJSON.js",
"static": true,
"longname": "src/Struct/ItemJSON.js~ItemJSON",
"access": "public",
"export": true,
"importPath": "yjs/src/Struct/ItemJSON.js",
"importStyle": "ItemJSON",
"description": null,
"lineNumber": 4,
"undocument": true,
"interface": false,
"extends": [
"src/Struct/Item.js~Item"
]
},
{
"__docId__": 340,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Struct/ItemJSON.js~ItemJSON",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemJSON.js~ItemJSON#constructor",
"access": "public",
"description": null,
"lineNumber": 5,
"undocument": true
},
{
"__docId__": 341,
"kind": "member",
"name": "_content",
"memberof": "src/Struct/ItemJSON.js~ItemJSON",
"static": false,
"longname": "src/Struct/ItemJSON.js~ItemJSON#_content",
"access": "private",
"description": null,
"lineNumber": 7,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 342,
"kind": "method",
"name": "_copy",
"memberof": "src/Struct/ItemJSON.js~ItemJSON",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemJSON.js~ItemJSON#_copy",
"access": "private",
"description": null,
"lineNumber": 9,
"undocument": true,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 343,
"kind": "get",
"name": "_length",
"memberof": "src/Struct/ItemJSON.js~ItemJSON",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemJSON.js~ItemJSON#_length",
"access": "private",
"description": null,
"lineNumber": 14,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 344,
"kind": "method",
"name": "_fromBinary",
"memberof": "src/Struct/ItemJSON.js~ItemJSON",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemJSON.js~ItemJSON#_fromBinary",
"access": "private",
"description": null,
"lineNumber": 17,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "decoder",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 346,
"kind": "method",
"name": "_toBinary",
"memberof": "src/Struct/ItemJSON.js~ItemJSON",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemJSON.js~ItemJSON#_toBinary",
"access": "private",
"description": null,
"lineNumber": 33,
"undocument": true,
"ignore": true,
"params": [
{
"name": "encoder",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 347,
"kind": "method",
"name": "_logString",
"memberof": "src/Struct/ItemJSON.js~ItemJSON",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemJSON.js~ItemJSON#_logString",
"access": "private",
"description": "Transform this YXml Type to a readable format.\nUseful for logging as all Items and Delete implement this method.",
"lineNumber": 54,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 348,
"kind": "method",
"name": "_splitAt",
"memberof": "src/Struct/ItemJSON.js~ItemJSON",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemJSON.js~ItemJSON#_splitAt",
"access": "private",
"description": null,
"lineNumber": 57,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "diff",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 349,
"kind": "file",
"name": "src/Struct/ItemString.js",
"content": "import { splitHelper, default as Item } from './Item.js'\nimport { logItemHelper } from '../MessageHandler/messageToString.js'\n\nexport default class ItemString extends Item {\n constructor () {\n super()\n this._content = null\n }\n _copy () {\n let struct = super._copy()\n struct._content = this._content\n return struct\n }\n get _length () {\n return this._content.length\n }\n _fromBinary (y, decoder) {\n let missing = super._fromBinary(y, decoder)\n this._content = decoder.readVarString()\n return missing\n }\n _toBinary (encoder) {\n super._toBinary(encoder)\n encoder.writeVarString(this._content)\n }\n /**\n * Transform this YXml Type to a readable format.\n * Useful for logging as all Items and Delete implement this method.\n *\n * @private\n */\n _logString () {\n return logItemHelper('ItemString', this, `content:\"${this._content}\"`)\n }\n _splitAt (y, diff) {\n if (diff === 0) {\n return this\n } else if (diff >= this._length) {\n return this._right\n }\n let item = new ItemString()\n item._content = this._content.slice(diff)\n this._content = this._content.slice(0, diff)\n splitHelper(y, this, item, diff)\n return item\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Struct/ItemString.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 350,
"kind": "class",
"name": "ItemString",
"memberof": "src/Struct/ItemString.js",
"static": true,
"longname": "src/Struct/ItemString.js~ItemString",
"access": "public",
"export": true,
"importPath": "yjs/src/Struct/ItemString.js",
"importStyle": "ItemString",
"description": null,
"lineNumber": 4,
"undocument": true,
"interface": false,
"extends": [
"src/Struct/Item.js~Item"
]
},
{
"__docId__": 351,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Struct/ItemString.js~ItemString",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemString.js~ItemString#constructor",
"access": "public",
"description": null,
"lineNumber": 5,
"undocument": true
},
{
"__docId__": 352,
"kind": "member",
"name": "_content",
"memberof": "src/Struct/ItemString.js~ItemString",
"static": false,
"longname": "src/Struct/ItemString.js~ItemString#_content",
"access": "private",
"description": null,
"lineNumber": 7,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 353,
"kind": "method",
"name": "_copy",
"memberof": "src/Struct/ItemString.js~ItemString",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemString.js~ItemString#_copy",
"access": "private",
"description": null,
"lineNumber": 9,
"undocument": true,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 354,
"kind": "get",
"name": "_length",
"memberof": "src/Struct/ItemString.js~ItemString",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemString.js~ItemString#_length",
"access": "private",
"description": null,
"lineNumber": 14,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 355,
"kind": "method",
"name": "_fromBinary",
"memberof": "src/Struct/ItemString.js~ItemString",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemString.js~ItemString#_fromBinary",
"access": "private",
"description": null,
"lineNumber": 17,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "decoder",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 357,
"kind": "method",
"name": "_toBinary",
"memberof": "src/Struct/ItemString.js~ItemString",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemString.js~ItemString#_toBinary",
"access": "private",
"description": null,
"lineNumber": 22,
"undocument": true,
"ignore": true,
"params": [
{
"name": "encoder",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 358,
"kind": "method",
"name": "_logString",
"memberof": "src/Struct/ItemString.js~ItemString",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemString.js~ItemString#_logString",
"access": "private",
"description": "Transform this YXml Type to a readable format.\nUseful for logging as all Items and Delete implement this method.",
"lineNumber": 32,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 359,
"kind": "method",
"name": "_splitAt",
"memberof": "src/Struct/ItemString.js~ItemString",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/ItemString.js~ItemString#_splitAt",
"access": "private",
"description": null,
"lineNumber": 35,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "diff",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 361,
"kind": "file",
"name": "src/Struct/Type.js",
"content": "import Item from './Item.js'\nimport EventHandler from '../Util/EventHandler.js'\nimport ID from '../Util/ID/ID.js'\n\n// restructure children as if they were inserted one after another\nfunction integrateChildren (y, start) {\n let right\n do {\n right = start._right\n start._right = null\n start._right_origin = null\n start._origin = start._left\n start._integrate(y)\n start = right\n } while (right !== null)\n}\n\nexport function getListItemIDByPosition (type, i) {\n let pos = 0\n let n = type._start\n while (n !== null) {\n if (!n._deleted) {\n if (pos <= i && i < pos + n._length) {\n const id = n._id\n return new ID(id.user, id.clock + i - pos)\n }\n pos++\n }\n n = n._right\n }\n}\n\nfunction gcChildren (y, item) {\n while (item !== null) {\n item._delete(y, false, true)\n item._gc(y)\n item = item._right\n }\n}\n\n/**\n * Abstract Yjs Type class\n */\nexport default class Type extends Item {\n constructor () {\n super()\n this._map = new Map()\n this._start = null\n this._y = null\n this._eventHandler = new EventHandler()\n this._deepEventHandler = new EventHandler()\n }\n\n /**\n * Compute the path from this type to the specified target.\n *\n * @example\n * It should be accessible via `this.get(result[0]).get(result[1])..`\n * const path = type.getPathTo(child)\n * // assuming `type instanceof YArray`\n * console.log(path) // might look like => [2, 'key1']\n * child === type.get(path[0]).get(path[1])\n *\n * @param {YType} type Type target\n * @return {Array<string>} Path to the target\n */\n getPathTo (type) {\n if (type === this) {\n return []\n }\n const path = []\n const y = this._y\n while (type !== this && type !== y) {\n let parent = type._parent\n if (type._parentSub !== null) {\n path.unshift(type._parentSub)\n } else {\n // parent is array-ish\n for (let [i, child] of parent) {\n if (child === type) {\n path.unshift(i)\n break\n }\n }\n }\n type = parent\n }\n if (type !== this) {\n throw new Error('The type is not a child of this node')\n }\n return path\n }\n\n /**\n * @private\n * Call event listeners with an event. This will also add an event to all\n * parents (for `.observeDeep` handlers).\n */\n _callEventHandler (transaction, event) {\n const changedParentTypes = transaction.changedParentTypes\n this._eventHandler.callEventListeners(transaction, event)\n let type = this\n while (type !== this._y) {\n let events = changedParentTypes.get(type)\n if (events === undefined) {\n events = []\n changedParentTypes.set(type, events)\n }\n events.push(event)\n type = type._parent\n }\n }\n\n /**\n * @private\n * Helper method to transact if the y instance is available.\n *\n * TODO: Currently event handlers are not thrown when a type is not registered\n * with a Yjs instance.\n */\n _transact (f) {\n const y = this._y\n if (y !== null) {\n y.transact(f)\n } else {\n f(y)\n }\n }\n\n /**\n * Observe all events that are created on this type.\n *\n * @param {Function} f Observer function\n */\n observe (f) {\n this._eventHandler.addEventListener(f)\n }\n\n /**\n * Observe all events that are created by this type and its children.\n *\n * @param {Function} f Observer function\n */\n observeDeep (f) {\n this._deepEventHandler.addEventListener(f)\n }\n\n /**\n * Unregister an observer function.\n *\n * @param {Function} f Observer function\n */\n unobserve (f) {\n this._eventHandler.removeEventListener(f)\n }\n\n /**\n * Unregister an observer function.\n *\n * @param {Function} f Observer function\n */\n unobserveDeep (f) {\n this._deepEventHandler.removeEventListener(f)\n }\n\n /**\n * @private\n * Integrate this type into the Yjs instance.\n *\n * * Save this struct in the os\n * * This type is sent to other client\n * * Observer functions are fired\n *\n * @param {Y} y The Yjs instance\n */\n _integrate (y) {\n super._integrate(y)\n this._y = y\n // when integrating children we must make sure to\n // integrate start\n const start = this._start\n if (start !== null) {\n this._start = null\n integrateChildren(y, start)\n }\n // integrate map children\n const map = this._map\n this._map = new Map()\n for (let t of map.values()) {\n // TODO make sure that right elements are deleted!\n integrateChildren(y, t)\n }\n }\n\n _gcChildren (y) {\n gcChildren(y, this._start)\n this._start = null\n this._map.forEach(item => {\n gcChildren(y, item)\n })\n this._map = new Map()\n }\n\n _gc (y) {\n this._gcChildren(y)\n super._gc(y)\n }\n\n /**\n * @private\n * Mark this Item as deleted.\n *\n * @param {Y} y The Yjs instance\n * @param {boolean} createDelete Whether to propagate a message that this\n * Type was deleted.\n * @param {boolean} [gcChildren=y._hasUndoManager===false] Whether to garbage\n * collect the children of this type.\n */\n _delete (y, createDelete, gcChildren) {\n if (gcChildren === undefined) {\n gcChildren = y._hasUndoManager === false\n }\n super._delete(y, createDelete, gcChildren)\n y._transaction.changedTypes.delete(this)\n // delete map types\n for (let value of this._map.values()) {\n if (value instanceof Item && !value._deleted) {\n value._delete(y, false, gcChildren)\n }\n }\n // delete array types\n let t = this._start\n while (t !== null) {\n if (!t._deleted) {\n t._delete(y, false, gcChildren)\n }\n t = t._right\n }\n if (gcChildren) {\n this._gcChildren(y)\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Struct/Type.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 362,
"kind": "function",
"name": "integrateChildren",
"memberof": "src/Struct/Type.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Struct/Type.js~integrateChildren",
"access": "public",
"export": false,
"importPath": "yjs/src/Struct/Type.js",
"importStyle": null,
"description": null,
"lineNumber": 6,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "start",
"types": [
"*"
]
}
],
"return": null,
"ignore": true
},
{
"__docId__": 363,
"kind": "function",
"name": "getListItemIDByPosition",
"memberof": "src/Struct/Type.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Struct/Type.js~getListItemIDByPosition",
"access": "public",
"export": true,
"importPath": "yjs/src/Struct/Type.js",
"importStyle": "{getListItemIDByPosition}",
"description": null,
"lineNumber": 18,
"undocument": true,
"params": [
{
"name": "type",
"types": [
"*"
]
},
{
"name": "i",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 364,
"kind": "function",
"name": "gcChildren",
"memberof": "src/Struct/Type.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Struct/Type.js~gcChildren",
"access": "public",
"export": false,
"importPath": "yjs/src/Struct/Type.js",
"importStyle": null,
"description": null,
"lineNumber": 33,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "item",
"types": [
"*"
]
}
],
"return": null,
"ignore": true
},
{
"__docId__": 365,
"kind": "class",
"name": "Type",
"memberof": "src/Struct/Type.js",
"static": true,
"longname": "src/Struct/Type.js~Type",
"access": "public",
"export": true,
"importPath": "yjs/src/Struct/Type.js",
"importStyle": "Type",
"description": "Abstract Yjs Type class",
"lineNumber": 44,
"interface": false,
"extends": [
"src/Struct/Item.js~Item"
]
},
{
"__docId__": 366,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#constructor",
"access": "public",
"description": null,
"lineNumber": 45,
"undocument": true
},
{
"__docId__": 367,
"kind": "member",
"name": "_map",
"memberof": "src/Struct/Type.js~Type",
"static": false,
"longname": "src/Struct/Type.js~Type#_map",
"access": "private",
"description": null,
"lineNumber": 47,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 368,
"kind": "member",
"name": "_start",
"memberof": "src/Struct/Type.js~Type",
"static": false,
"longname": "src/Struct/Type.js~Type#_start",
"access": "private",
"description": null,
"lineNumber": 48,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 369,
"kind": "member",
"name": "_y",
"memberof": "src/Struct/Type.js~Type",
"static": false,
"longname": "src/Struct/Type.js~Type#_y",
"access": "private",
"description": null,
"lineNumber": 49,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 370,
"kind": "member",
"name": "_eventHandler",
"memberof": "src/Struct/Type.js~Type",
"static": false,
"longname": "src/Struct/Type.js~Type#_eventHandler",
"access": "private",
"description": null,
"lineNumber": 50,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 371,
"kind": "member",
"name": "_deepEventHandler",
"memberof": "src/Struct/Type.js~Type",
"static": false,
"longname": "src/Struct/Type.js~Type#_deepEventHandler",
"access": "private",
"description": null,
"lineNumber": 51,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 372,
"kind": "method",
"name": "getPathTo",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#getPathTo",
"access": "public",
"description": "Compute the path from this type to the specified target.",
"examples": [
"It should be accessible via `this.get(result[0]).get(result[1])..`\nconst path = type.getPathTo(child)\n// assuming `type instanceof YArray`\nconsole.log(path) // might look like => [2, 'key1']\nchild === type.get(path[0]).get(path[1])"
],
"lineNumber": 67,
"params": [
{
"nullable": null,
"types": [
"YType"
],
"spread": false,
"optional": false,
"name": "type",
"description": "Type target"
}
],
"return": {
"nullable": null,
"types": [
"Array<string>"
],
"spread": false,
"description": "Path to the target"
}
},
{
"__docId__": 373,
"kind": "method",
"name": "_callEventHandler",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#_callEventHandler",
"access": "private",
"description": "",
"lineNumber": 99,
"ignore": true,
"params": [
{
"name": "transaction",
"types": [
"*"
]
},
{
"name": "event",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 374,
"kind": "method",
"name": "_transact",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#_transact",
"access": "private",
"description": "",
"lineNumber": 121,
"ignore": true,
"params": [
{
"name": "f",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 375,
"kind": "method",
"name": "observe",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#observe",
"access": "public",
"description": "Observe all events that are created on this type.",
"lineNumber": 135,
"params": [
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "f",
"description": "Observer function"
}
],
"return": null
},
{
"__docId__": 376,
"kind": "method",
"name": "observeDeep",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#observeDeep",
"access": "public",
"description": "Observe all events that are created by this type and its children.",
"lineNumber": 144,
"params": [
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "f",
"description": "Observer function"
}
],
"return": null
},
{
"__docId__": 377,
"kind": "method",
"name": "unobserve",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#unobserve",
"access": "public",
"description": "Unregister an observer function.",
"lineNumber": 153,
"params": [
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "f",
"description": "Observer function"
}
],
"return": null
},
{
"__docId__": 378,
"kind": "method",
"name": "unobserveDeep",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#unobserveDeep",
"access": "public",
"description": "Unregister an observer function.",
"lineNumber": 162,
"params": [
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "f",
"description": "Observer function"
}
],
"return": null
},
{
"__docId__": 379,
"kind": "method",
"name": "_integrate",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#_integrate",
"access": "private",
"description": "",
"lineNumber": 176,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance"
}
],
"ignore": true,
"return": null
},
{
"__docId__": 383,
"kind": "method",
"name": "_gcChildren",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#_gcChildren",
"access": "private",
"description": null,
"lineNumber": 195,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 386,
"kind": "method",
"name": "_gc",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#_gc",
"access": "private",
"description": null,
"lineNumber": 204,
"undocument": true,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 387,
"kind": "method",
"name": "_delete",
"memberof": "src/Struct/Type.js~Type",
"generator": false,
"async": false,
"static": false,
"longname": "src/Struct/Type.js~Type#_delete",
"access": "private",
"description": "",
"lineNumber": 219,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance"
},
{
"nullable": null,
"types": [
"boolean"
],
"spread": false,
"optional": false,
"name": "createDelete",
"description": "Whether to propagate a message that this\n Type was deleted."
},
{
"nullable": null,
"types": [
"boolean"
],
"spread": false,
"optional": true,
"name": "gcChildren",
"description": "Whether to garbage\n collect the children of this type."
}
],
"ignore": true,
"return": null
},
{
"__docId__": 388,
"kind": "file",
"name": "src/Transaction.js",
"content": "\n/**\n * A transaction is created for every change on the Yjs model. It is possible\n * to bundle changes on the Yjs model in a single transaction to\n * minimize the number on messages sent and the number of observer calls.\n * If possible the user of this library should bundle as many changes as\n * possible. Here is an example to illustrate the advantages of bundling:\n *\n * @example\n * const map = y.define('map', YMap)\n * // Log content when change is triggered\n * map.observe(function () {\n * console.log('change triggered')\n * })\n * // Each change on the map type triggers a log message:\n * map.set('a', 0) // => \"change triggered\"\n * map.set('b', 0) // => \"change triggered\"\n * // When put in a transaction, it will trigger the log after the transaction:\n * y.transact(function () {\n * map.set('a', 1)\n * map.set('b', 1)\n * }) // => \"change triggered\"\n *\n */\nexport default class Transaction {\n constructor (y) {\n /**\n * @type {Y} The Yjs instance.\n */\n this.y = y\n /**\n * All new types that are added during a transaction.\n * @type {Set<Item>}\n */\n this.newTypes = new Set()\n /**\n * All types that were directly modified (property added or child\n * inserted/deleted). New types are not included in this Set.\n * Maps from type to parentSubs (`item._parentSub = null` for YArray)\n * @type {Set<YType,String>}\n */\n this.changedTypes = new Map()\n // TODO: rename deletedTypes\n /**\n * Set of all deleted Types and Structs.\n * @type {Set<Item>}\n */\n this.deletedStructs = new Set()\n /**\n * Saves the old state set of the Yjs instance. If a state was modified,\n * the original value is saved here.\n * @type {Map<Number,Number>}\n */\n this.beforeState = new Map()\n /**\n * Stores the events for the types that observe also child elements.\n * It is mainly used by `observeDeep`.\n * @type {Map<YType,Array<YEvent>>}\n */\n this.changedParentTypes = new Map()\n }\n}\n\n/**\n * @private\n */\nexport function transactionTypeChanged (y, type, sub) {\n if (type !== y && !type._deleted && !y._transaction.newTypes.has(type)) {\n const changedTypes = y._transaction.changedTypes\n let subs = changedTypes.get(type)\n if (subs === undefined) {\n // create if it doesn't exist yet\n subs = new Set()\n changedTypes.set(type, subs)\n }\n subs.add(sub)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Transaction.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 389,
"kind": "class",
"name": "Transaction",
"memberof": "src/Transaction.js",
"static": true,
"longname": "src/Transaction.js~Transaction",
"access": "public",
"export": true,
"importPath": "yjs/src/Transaction.js",
"importStyle": "Transaction",
"description": "A transaction is created for every change on the Yjs model. It is possible\nto bundle changes on the Yjs model in a single transaction to\nminimize the number on messages sent and the number of observer calls.\nIf possible the user of this library should bundle as many changes as\npossible. Here is an example to illustrate the advantages of bundling:",
"examples": [
"const map = y.define('map', YMap)\n// Log content when change is triggered\nmap.observe(function () {\n console.log('change triggered')\n})\n// Each change on the map type triggers a log message:\nmap.set('a', 0) // => \"change triggered\"\nmap.set('b', 0) // => \"change triggered\"\n// When put in a transaction, it will trigger the log after the transaction:\ny.transact(function () {\n map.set('a', 1)\n map.set('b', 1)\n}) // => \"change triggered\""
],
"lineNumber": 25,
"interface": false
},
{
"__docId__": 390,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Transaction.js~Transaction",
"generator": false,
"async": false,
"static": false,
"longname": "src/Transaction.js~Transaction#constructor",
"access": "public",
"description": null,
"lineNumber": 26,
"undocument": true
},
{
"__docId__": 391,
"kind": "member",
"name": "y",
"memberof": "src/Transaction.js~Transaction",
"static": false,
"longname": "src/Transaction.js~Transaction#y",
"access": "public",
"description": "",
"lineNumber": 30,
"type": {
"nullable": null,
"types": [
"Y"
],
"spread": false,
"description": null
}
},
{
"__docId__": 392,
"kind": "member",
"name": "newTypes",
"memberof": "src/Transaction.js~Transaction",
"static": false,
"longname": "src/Transaction.js~Transaction#newTypes",
"access": "public",
"description": "All new types that are added during a transaction.",
"lineNumber": 35,
"type": {
"nullable": null,
"types": [
"Set<Item>"
],
"spread": false,
"description": null
}
},
{
"__docId__": 393,
"kind": "member",
"name": "changedTypes",
"memberof": "src/Transaction.js~Transaction",
"static": false,
"longname": "src/Transaction.js~Transaction#changedTypes",
"access": "public",
"description": "All types that were directly modified (property added or child\ninserted/deleted). New types are not included in this Set.\nMaps from type to parentSubs (`item._parentSub = null` for YArray)",
"lineNumber": 42,
"type": {
"nullable": null,
"types": [
"Set<YType,String>"
],
"spread": false,
"description": null
}
},
{
"__docId__": 394,
"kind": "member",
"name": "deletedStructs",
"memberof": "src/Transaction.js~Transaction",
"static": false,
"longname": "src/Transaction.js~Transaction#deletedStructs",
"access": "public",
"description": "Set of all deleted Types and Structs.",
"lineNumber": 48,
"type": {
"nullable": null,
"types": [
"Set<Item>"
],
"spread": false,
"description": null
}
},
{
"__docId__": 395,
"kind": "member",
"name": "beforeState",
"memberof": "src/Transaction.js~Transaction",
"static": false,
"longname": "src/Transaction.js~Transaction#beforeState",
"access": "public",
"description": "Saves the old state set of the Yjs instance. If a state was modified,\nthe original value is saved here.",
"lineNumber": 54,
"type": {
"nullable": null,
"types": [
"Map<Number,Number>"
],
"spread": false,
"description": null
}
},
{
"__docId__": 396,
"kind": "member",
"name": "changedParentTypes",
"memberof": "src/Transaction.js~Transaction",
"static": false,
"longname": "src/Transaction.js~Transaction#changedParentTypes",
"access": "public",
"description": "Stores the events for the types that observe also child elements.\nIt is mainly used by `observeDeep`.",
"lineNumber": 60,
"type": {
"nullable": null,
"types": [
"Map<YType,Array<YEvent>>"
],
"spread": false,
"description": null
}
},
{
"__docId__": 397,
"kind": "function",
"name": "transactionTypeChanged",
"memberof": "src/Transaction.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Transaction.js~transactionTypeChanged",
"access": "private",
"export": true,
"importPath": "yjs/src/Transaction.js",
"importStyle": "{transactionTypeChanged}",
"description": "",
"lineNumber": 67,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "type",
"types": [
"*"
]
},
{
"name": "sub",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 398,
"kind": "file",
"name": "src/Types/YArray/YArray.js",
"content": "import Type from '../../Struct/Type.js'\nimport ItemJSON from '../../Struct/ItemJSON.js'\nimport ItemString from '../../Struct/ItemString.js'\nimport { logID, logItemHelper } from '../../MessageHandler/messageToString.js'\nimport YEvent from '../../Util/YEvent.js'\n\n/**\n * Event that describes the changes on a YArray\n *\n * @param {YArray} yarray The changed type\n * @param {Boolean} remote Whether the changed was caused by a remote peer\n * @param {Transaction} transaction The transaction object\n */\nexport class YArrayEvent extends YEvent {\n constructor (yarray, remote, transaction) {\n super(yarray)\n this.remote = remote\n this._transaction = transaction\n this._addedElements = null\n this._removedElements = null\n }\n\n /**\n * Child elements that were added in this transaction.\n *\n * @return {Set}\n */\n get addedElements () {\n if (this._addedElements === null) {\n const target = this.target\n const transaction = this._transaction\n const addedElements = new Set()\n transaction.newTypes.forEach(function (type) {\n if (type._parent === target && !transaction.deletedStructs.has(type)) {\n addedElements.add(type)\n }\n })\n this._addedElements = addedElements\n }\n return this._addedElements\n }\n\n /**\n * Child elements that were removed in this transaction.\n *\n * @return {Set}\n */\n get removedElements () {\n if (this._removedElements === null) {\n const target = this.target\n const transaction = this._transaction\n const removedElements = new Set()\n transaction.deletedStructs.forEach(function (struct) {\n if (struct._parent === target && !transaction.newTypes.has(struct)) {\n removedElements.add(struct)\n }\n })\n this._removedElements = removedElements\n }\n return this._removedElements\n }\n}\n\n/**\n * A shared Array implementation.\n */\nexport default class YArray extends Type {\n /**\n * @private\n * Creates YArray Event and calls observers.\n */\n _callObserver (transaction, parentSubs, remote) {\n this._callEventHandler(transaction, new YArrayEvent(this, remote, transaction))\n }\n\n /**\n * Returns the i-th element from a YArray.\n *\n * @param {Integer} index The index of the element to return from the YArray\n */\n get (index) {\n let n = this._start\n while (n !== null) {\n if (!n._deleted && n._countable) {\n if (index < n._length) {\n if (n.constructor === ItemJSON || n.constructor === ItemString) {\n return n._content[index]\n } else {\n return n\n }\n }\n index -= n._length\n }\n n = n._right\n }\n }\n\n /**\n * Transforms this YArray to a JavaScript Array.\n *\n * @return {Array}\n */\n toArray () {\n return this.map(c => c)\n }\n\n /**\n * Transforms this Shared Type to a JSON object.\n *\n * @return {Array}\n */\n toJSON () {\n return this.map(c => {\n if (c instanceof Type) {\n if (c.toJSON !== null) {\n return c.toJSON()\n } else {\n return c.toString()\n }\n }\n return c\n })\n }\n\n /**\n * Returns an Array with the result of calling a provided function on every\n * element of this YArray.\n *\n * @param {Function} f Function that produces an element of the new Array\n * @return {Array} A new array with each element being the result of the\n * callback function\n */\n map (f) {\n const res = []\n this.forEach((c, i) => {\n res.push(f(c, i, this))\n })\n return res\n }\n\n /**\n * Executes a provided function on once on overy element of this YArray.\n *\n * @param {Function} f A function to execute on every element of this YArray.\n */\n forEach (f) {\n let index = 0\n let n = this._start\n while (n !== null) {\n if (!n._deleted && n._countable) {\n if (n instanceof Type) {\n f(n, index++, this)\n } else {\n const content = n._content\n const contentLen = content.length\n for (let i = 0; i < contentLen; i++) {\n index++\n f(content[i], index, this)\n }\n }\n }\n n = n._right\n }\n }\n\n /**\n * Computes the length of this YArray.\n */\n get length () {\n let length = 0\n let n = this._start\n while (n !== null) {\n if (!n._deleted && n._countable) {\n length += n._length\n }\n n = n._right\n }\n return length\n }\n\n [Symbol.iterator] () {\n return {\n next: function () {\n while (this._item !== null && (this._item._deleted || this._item._length <= this._itemElement)) {\n // item is deleted or itemElement does not exist (is deleted)\n this._item = this._item._right\n this._itemElement = 0\n }\n if (this._item === null) {\n return {\n done: true\n }\n }\n let content\n if (this._item instanceof Type) {\n content = this._item\n } else {\n content = this._item._content[this._itemElement++]\n }\n return {\n value: content,\n done: false\n }\n },\n _item: this._start,\n _itemElement: 0,\n _count: 0\n }\n }\n\n /**\n * Deletes elements starting from an index.\n *\n * @param {Integer} index Index at which to start deleting elements\n * @param {Integer} length The number of elements to remove. Defaults to 1.\n */\n delete (index, length = 1) {\n this._y.transact(() => {\n let item = this._start\n let count = 0\n while (item !== null && length > 0) {\n if (!item._deleted && item._countable) {\n if (count <= index && index < count + item._length) {\n const diffDel = index - count\n item = item._splitAt(this._y, diffDel)\n item._splitAt(this._y, length)\n length -= item._length\n item._delete(this._y)\n count += diffDel\n } else {\n count += item._length\n }\n }\n item = item._right\n }\n })\n if (length > 0) {\n throw new Error('Delete exceeds the range of the YArray')\n }\n }\n\n /**\n * @private\n * Inserts content after an element container.\n *\n * @param {Item} left The element container to use as a reference.\n * @param {Array} content The Array of content to insert (see {@see insert})\n */\n insertAfter (left, content) {\n this._transact(y => {\n let right\n if (left === null) {\n right = this._start\n } else {\n right = left._right\n }\n let prevJsonIns = null\n for (let i = 0; i < content.length; i++) {\n let c = content[i]\n if (typeof c === 'function') {\n c = new c() // eslint-disable-line new-cap\n }\n if (c instanceof Type) {\n if (prevJsonIns !== null) {\n if (y !== null) {\n prevJsonIns._integrate(y)\n }\n left = prevJsonIns\n prevJsonIns = null\n }\n c._origin = left\n c._left = left\n c._right = right\n c._right_origin = right\n c._parent = this\n if (y !== null) {\n c._integrate(y)\n } else if (left === null) {\n this._start = c\n } else {\n left._right = c\n }\n left = c\n } else {\n if (prevJsonIns === null) {\n prevJsonIns = new ItemJSON()\n prevJsonIns._origin = left\n prevJsonIns._left = left\n prevJsonIns._right = right\n prevJsonIns._right_origin = right\n prevJsonIns._parent = this\n prevJsonIns._content = []\n }\n prevJsonIns._content.push(c)\n }\n }\n if (prevJsonIns !== null) {\n if (y !== null) {\n prevJsonIns._integrate(y)\n } else if (prevJsonIns._left === null) {\n this._start = prevJsonIns\n }\n }\n })\n return content\n }\n\n /**\n * Inserts new content at an index.\n *\n * Important: This function expects an array of content. Not just a content\n * object. The reason for this \"weirdness\" is that inserting several elements\n * is very efficient when it is done as a single operation.\n *\n * @example\n * // Insert character 'a' at position 0\n * yarray.insert(0, ['a'])\n * // Insert numbers 1, 2 at position 1\n * yarray.insert(2, [1, 2])\n *\n * @param {Integer} index The index to insert content at.\n * @param {Array} content The array of content\n */\n insert (index, content) {\n this._transact(() => {\n let left = null\n let right = this._start\n let count = 0\n const y = this._y\n while (right !== null) {\n const rightLen = right._deleted ? 0 : (right._length - 1)\n if (count <= index && index <= count + rightLen) {\n const splitDiff = index - count\n right = right._splitAt(y, splitDiff)\n left = right._left\n count += splitDiff\n break\n }\n if (!right._deleted) {\n count += right._length\n }\n left = right\n right = right._right\n }\n if (index > count) {\n throw new Error('Index exceeds array range!')\n }\n this.insertAfter(left, content)\n })\n }\n\n /**\n * Appends content to this YArray.\n *\n * @param {Array} content Array of content to append.\n */\n push (content) {\n let n = this._start\n let lastUndeleted = null\n while (n !== null) {\n if (!n._deleted) {\n lastUndeleted = n\n }\n n = n._right\n }\n this.insertAfter(lastUndeleted, content)\n }\n\n /**\n * Transform this YXml Type to a readable format.\n * Useful for logging as all Items and Delete implement this method.\n *\n * @private\n */\n _logString () {\n return logItemHelper('YArray', this, `start:${logID(this._start)}\"`)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Types/YArray/YArray.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 399,
"kind": "class",
"name": "YArrayEvent",
"memberof": "src/Types/YArray/YArray.js",
"static": true,
"longname": "src/Types/YArray/YArray.js~YArrayEvent",
"access": "public",
"export": true,
"importPath": "yjs/src/Types/YArray/YArray.js",
"importStyle": "{YArrayEvent}",
"description": "Event that describes the changes on a YArray",
"lineNumber": 14,
"params": [
{
"nullable": null,
"types": [
"YArray"
],
"spread": false,
"optional": false,
"name": "yarray",
"description": "The changed type"
},
{
"nullable": null,
"types": [
"Boolean"
],
"spread": false,
"optional": false,
"name": "remote",
"description": "Whether the changed was caused by a remote peer"
},
{
"nullable": null,
"types": [
"Transaction"
],
"spread": false,
"optional": false,
"name": "transaction",
"description": "The transaction object"
}
],
"interface": false,
"extends": [
"src/Util/YEvent.js~YEvent"
]
},
{
"__docId__": 400,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Types/YArray/YArray.js~YArrayEvent",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArrayEvent#constructor",
"access": "public",
"description": null,
"lineNumber": 15,
"undocument": true
},
{
"__docId__": 401,
"kind": "member",
"name": "remote",
"memberof": "src/Types/YArray/YArray.js~YArrayEvent",
"static": false,
"longname": "src/Types/YArray/YArray.js~YArrayEvent#remote",
"access": "public",
"description": null,
"lineNumber": 17,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 402,
"kind": "member",
"name": "_transaction",
"memberof": "src/Types/YArray/YArray.js~YArrayEvent",
"static": false,
"longname": "src/Types/YArray/YArray.js~YArrayEvent#_transaction",
"access": "private",
"description": null,
"lineNumber": 18,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 403,
"kind": "member",
"name": "_addedElements",
"memberof": "src/Types/YArray/YArray.js~YArrayEvent",
"static": false,
"longname": "src/Types/YArray/YArray.js~YArrayEvent#_addedElements",
"access": "private",
"description": null,
"lineNumber": 19,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 404,
"kind": "member",
"name": "_removedElements",
"memberof": "src/Types/YArray/YArray.js~YArrayEvent",
"static": false,
"longname": "src/Types/YArray/YArray.js~YArrayEvent#_removedElements",
"access": "private",
"description": null,
"lineNumber": 20,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 405,
"kind": "get",
"name": "addedElements",
"memberof": "src/Types/YArray/YArray.js~YArrayEvent",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArrayEvent#addedElements",
"access": "public",
"description": "Child elements that were added in this transaction.",
"lineNumber": 28,
"return": {
"nullable": null,
"types": [
"Set"
],
"spread": false,
"description": ""
},
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 407,
"kind": "get",
"name": "removedElements",
"memberof": "src/Types/YArray/YArray.js~YArrayEvent",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArrayEvent#removedElements",
"access": "public",
"description": "Child elements that were removed in this transaction.",
"lineNumber": 48,
"return": {
"nullable": null,
"types": [
"Set"
],
"spread": false,
"description": ""
},
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 409,
"kind": "class",
"name": "YArray",
"memberof": "src/Types/YArray/YArray.js",
"static": true,
"longname": "src/Types/YArray/YArray.js~YArray",
"access": "public",
"export": true,
"importPath": "yjs/src/Types/YArray/YArray.js",
"importStyle": "YArray",
"description": "A shared Array implementation.",
"lineNumber": 67,
"interface": false,
"extends": [
"src/Struct/Type.js~Type"
]
},
{
"__docId__": 410,
"kind": "method",
"name": "_callObserver",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#_callObserver",
"access": "private",
"description": "",
"lineNumber": 72,
"ignore": true,
"params": [
{
"name": "transaction",
"types": [
"*"
]
},
{
"name": "parentSubs",
"types": [
"*"
]
},
{
"name": "remote",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 411,
"kind": "method",
"name": "get",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#get",
"access": "public",
"description": "Returns the i-th element from a YArray.",
"lineNumber": 81,
"params": [
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "index",
"description": "The index of the element to return from the YArray"
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 412,
"kind": "method",
"name": "toArray",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#toArray",
"access": "public",
"description": "Transforms this YArray to a JavaScript Array.",
"lineNumber": 103,
"return": {
"nullable": null,
"types": [
"Array"
],
"spread": false,
"description": ""
},
"params": []
},
{
"__docId__": 413,
"kind": "method",
"name": "toJSON",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#toJSON",
"access": "public",
"description": "Transforms this Shared Type to a JSON object.",
"lineNumber": 112,
"return": {
"nullable": null,
"types": [
"Array"
],
"spread": false,
"description": ""
},
"params": []
},
{
"__docId__": 414,
"kind": "method",
"name": "map",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#map",
"access": "public",
"description": "Returns an Array with the result of calling a provided function on every\nelement of this YArray.",
"lineNumber": 133,
"params": [
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "f",
"description": "Function that produces an element of the new Array"
}
],
"return": {
"nullable": null,
"types": [
"Array"
],
"spread": false,
"description": "A new array with each element being the result of the\n callback function"
}
},
{
"__docId__": 415,
"kind": "method",
"name": "forEach",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#forEach",
"access": "public",
"description": "Executes a provided function on once on overy element of this YArray.",
"lineNumber": 146,
"params": [
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "f",
"description": "A function to execute on every element of this YArray."
}
],
"return": null
},
{
"__docId__": 416,
"kind": "get",
"name": "length",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#length",
"access": "public",
"description": "Computes the length of this YArray.",
"lineNumber": 169,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 417,
"kind": "method",
"name": "[Symbol.iterator]",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#[Symbol.iterator]",
"access": "public",
"description": null,
"lineNumber": 181,
"undocument": true,
"params": [],
"return": {
"types": [
"{\"next\": *, \"_item\": *, \"_itemElement\": *, \"_count\": *}"
]
}
},
{
"__docId__": 418,
"kind": "member",
"name": "_item",
"memberof": "src/Types/YArray/YArray.js~YArray",
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#_item",
"access": "private",
"description": null,
"lineNumber": 186,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 419,
"kind": "member",
"name": "_itemElement",
"memberof": "src/Types/YArray/YArray.js~YArray",
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#_itemElement",
"access": "private",
"description": null,
"lineNumber": 187,
"undocument": true,
"ignore": true,
"type": {
"types": [
"number"
]
}
},
{
"__docId__": 420,
"kind": "method",
"name": "delete",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#delete",
"access": "public",
"description": "Deletes elements starting from an index.",
"lineNumber": 217,
"params": [
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "index",
"description": "Index at which to start deleting elements"
},
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "length",
"description": "The number of elements to remove. Defaults to 1."
}
],
"return": null
},
{
"__docId__": 421,
"kind": "method",
"name": "insertAfter",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#insertAfter",
"access": "private",
"description": "",
"lineNumber": 249,
"params": [
{
"nullable": null,
"types": [
"Item"
],
"spread": false,
"optional": false,
"name": "left",
"description": "The element container to use as a reference."
},
{
"nullable": null,
"types": [
"Array"
],
"spread": false,
"optional": false,
"name": "content",
"description": "The Array of content to insert (see {@see insert})"
}
],
"ignore": true,
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 422,
"kind": "member",
"name": "_start",
"memberof": "src/Types/YArray/YArray.js~YArray",
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#_start",
"access": "private",
"description": null,
"lineNumber": 279,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 424,
"kind": "method",
"name": "insert",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#insert",
"access": "public",
"description": "Inserts new content at an index.\n\nImportant: This function expects an array of content. Not just a content\nobject. The reason for this \"weirdness\" is that inserting several elements\nis very efficient when it is done as a single operation.",
"examples": [
" // Insert character 'a' at position 0\n yarray.insert(0, ['a'])\n // Insert numbers 1, 2 at position 1\n yarray.insert(2, [1, 2])"
],
"lineNumber": 324,
"params": [
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "index",
"description": "The index to insert content at."
},
{
"nullable": null,
"types": [
"Array"
],
"spread": false,
"optional": false,
"name": "content",
"description": "The array of content"
}
],
"return": null
},
{
"__docId__": 425,
"kind": "method",
"name": "push",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#push",
"access": "public",
"description": "Appends content to this YArray.",
"lineNumber": 357,
"params": [
{
"nullable": null,
"types": [
"Array"
],
"spread": false,
"optional": false,
"name": "content",
"description": "Array of content to append."
}
],
"return": null
},
{
"__docId__": 426,
"kind": "method",
"name": "_logString",
"memberof": "src/Types/YArray/YArray.js~YArray",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YArray/YArray.js~YArray#_logString",
"access": "private",
"description": "Transform this YXml Type to a readable format.\nUseful for logging as all Items and Delete implement this method.",
"lineNumber": 375,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 427,
"kind": "file",
"name": "src/Types/YMap/YMap.js",
"content": "import Type from '../../Struct/Type.js'\nimport Item from '../../Struct/Item.js'\nimport ItemJSON from '../../Struct/ItemJSON.js'\nimport { logItemHelper } from '../../MessageHandler/messageToString.js'\nimport YEvent from '../../Util/YEvent.js'\n\n/**\n * Event that describes the changes on a YMap.\n *\n * @param {YMap} ymap The YArray that changed.\n * @param {Set<any>} subs The keys that changed.\n * @param {boolean} remote Whether the change was created by a remote peer.\n */\nexport class YMapEvent extends YEvent {\n constructor (ymap, subs, remote) {\n super(ymap)\n this.keysChanged = subs\n this.remote = remote\n }\n}\n\n/**\n * A shared Map implementation.\n */\nexport default class YMap extends Type {\n /**\n * @private\n * Creates YMap Event and calls observers.\n */\n _callObserver (transaction, parentSubs, remote) {\n this._callEventHandler(transaction, new YMapEvent(this, parentSubs, remote))\n }\n\n /**\n * Transforms this Shared Type to a JSON object.\n *\n * @return {Object}\n */\n toJSON () {\n const map = {}\n for (let [key, item] of this._map) {\n if (!item._deleted) {\n let res\n if (item instanceof Type) {\n if (item.toJSON !== undefined) {\n res = item.toJSON()\n } else {\n res = item.toString()\n }\n } else {\n res = item._content[0]\n }\n map[key] = res\n }\n }\n return map\n }\n\n /**\n * Returns the keys for each element in the YMap Type.\n *\n * @return {Array}\n */\n keys () {\n // TODO: Should return either Iterator or Set!\n let keys = []\n for (let [key, value] of this._map) {\n if (!value._deleted) {\n keys.push(key)\n }\n }\n return keys\n }\n\n /**\n * Remove a specified element from this YMap.\n *\n * @param {encodable} key The key of the element to remove.\n */\n delete (key) {\n this._transact((y) => {\n let c = this._map.get(key)\n if (y !== null && c !== undefined) {\n c._delete(y)\n }\n })\n }\n\n /**\n * Adds or updates an element with a specified key and value.\n *\n * @param {encodable} key The key of the element to add to this YMap.\n * @param {encodable | YType} value The value of the element to add to this\n * YMap.\n */\n set (key, value) {\n this._transact(y => {\n const old = this._map.get(key) || null\n if (old !== null) {\n if (\n old.constructor === ItemJSON &&\n !old._deleted && old._content[0] === value\n ) {\n // Trying to overwrite with same value\n // break here\n return value\n }\n if (y !== null) {\n old._delete(y)\n }\n }\n let v\n if (typeof value === 'function') {\n v = new value() // eslint-disable-line new-cap\n value = v\n } else if (value instanceof Item) {\n v = value\n } else {\n v = new ItemJSON()\n v._content = [value]\n }\n v._right = old\n v._right_origin = old\n v._parent = this\n v._parentSub = key\n if (y !== null) {\n v._integrate(y)\n } else {\n this._map.set(key, v)\n }\n })\n return value\n }\n\n /**\n * Returns a specified element from this YMap.\n *\n * @param {encodable} key The key of the element to return.\n */\n get (key) {\n let v = this._map.get(key)\n if (v === undefined || v._deleted) {\n return undefined\n }\n if (v instanceof Type) {\n return v\n } else {\n return v._content[v._content.length - 1]\n }\n }\n\n /**\n * Returns a boolean indicating whether the specified key exists or not.\n *\n * @param {encodable} key The key to test.\n */\n has (key) {\n let v = this._map.get(key)\n if (v === undefined || v._deleted) {\n return false\n } else {\n return true\n }\n }\n\n /**\n * Transform this YXml Type to a readable format.\n * Useful for logging as all Items and Delete implement this method.\n *\n * @private\n */\n _logString () {\n return logItemHelper('YMap', this, `mapSize:${this._map.size}`)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Types/YMap/YMap.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 428,
"kind": "class",
"name": "YMapEvent",
"memberof": "src/Types/YMap/YMap.js",
"static": true,
"longname": "src/Types/YMap/YMap.js~YMapEvent",
"access": "public",
"export": true,
"importPath": "yjs/src/Types/YMap/YMap.js",
"importStyle": "{YMapEvent}",
"description": "Event that describes the changes on a YMap.",
"lineNumber": 14,
"params": [
{
"nullable": null,
"types": [
"YMap"
],
"spread": false,
"optional": false,
"name": "ymap",
"description": "The YArray that changed."
},
{
"nullable": null,
"types": [
"Set<any>"
],
"spread": false,
"optional": false,
"name": "subs",
"description": "The keys that changed."
},
{
"nullable": null,
"types": [
"boolean"
],
"spread": false,
"optional": false,
"name": "remote",
"description": "Whether the change was created by a remote peer."
}
],
"interface": false,
"extends": [
"src/Util/YEvent.js~YEvent"
]
},
{
"__docId__": 429,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Types/YMap/YMap.js~YMapEvent",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YMap/YMap.js~YMapEvent#constructor",
"access": "public",
"description": null,
"lineNumber": 15,
"undocument": true
},
{
"__docId__": 430,
"kind": "member",
"name": "keysChanged",
"memberof": "src/Types/YMap/YMap.js~YMapEvent",
"static": false,
"longname": "src/Types/YMap/YMap.js~YMapEvent#keysChanged",
"access": "public",
"description": null,
"lineNumber": 17,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 431,
"kind": "member",
"name": "remote",
"memberof": "src/Types/YMap/YMap.js~YMapEvent",
"static": false,
"longname": "src/Types/YMap/YMap.js~YMapEvent#remote",
"access": "public",
"description": null,
"lineNumber": 18,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 432,
"kind": "class",
"name": "YMap",
"memberof": "src/Types/YMap/YMap.js",
"static": true,
"longname": "src/Types/YMap/YMap.js~YMap",
"access": "public",
"export": true,
"importPath": "yjs/src/Types/YMap/YMap.js",
"importStyle": "YMap",
"description": "A shared Map implementation.",
"lineNumber": 25,
"interface": false,
"extends": [
"src/Struct/Type.js~Type"
]
},
{
"__docId__": 433,
"kind": "method",
"name": "_callObserver",
"memberof": "src/Types/YMap/YMap.js~YMap",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YMap/YMap.js~YMap#_callObserver",
"access": "private",
"description": "",
"lineNumber": 30,
"ignore": true,
"params": [
{
"name": "transaction",
"types": [
"*"
]
},
{
"name": "parentSubs",
"types": [
"*"
]
},
{
"name": "remote",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 434,
"kind": "method",
"name": "toJSON",
"memberof": "src/Types/YMap/YMap.js~YMap",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YMap/YMap.js~YMap#toJSON",
"access": "public",
"description": "Transforms this Shared Type to a JSON object.",
"lineNumber": 39,
"return": {
"nullable": null,
"types": [
"Object"
],
"spread": false,
"description": ""
},
"params": []
},
{
"__docId__": 435,
"kind": "method",
"name": "keys",
"memberof": "src/Types/YMap/YMap.js~YMap",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YMap/YMap.js~YMap#keys",
"access": "public",
"description": "Returns the keys for each element in the YMap Type.",
"lineNumber": 64,
"return": {
"nullable": null,
"types": [
"Array"
],
"spread": false,
"description": ""
},
"params": []
},
{
"__docId__": 436,
"kind": "method",
"name": "delete",
"memberof": "src/Types/YMap/YMap.js~YMap",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YMap/YMap.js~YMap#delete",
"access": "public",
"description": "Remove a specified element from this YMap.",
"lineNumber": 80,
"params": [
{
"nullable": null,
"types": [
"encodable"
],
"spread": false,
"optional": false,
"name": "key",
"description": "The key of the element to remove."
}
],
"return": null
},
{
"__docId__": 437,
"kind": "method",
"name": "set",
"memberof": "src/Types/YMap/YMap.js~YMap",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YMap/YMap.js~YMap#set",
"access": "public",
"description": "Adds or updates an element with a specified key and value.",
"lineNumber": 96,
"params": [
{
"nullable": null,
"types": [
"encodable"
],
"spread": false,
"optional": false,
"name": "key",
"description": "The key of the element to add to this YMap."
},
{
"nullable": null,
"types": [
"encodable ",
" YType"
],
"spread": false,
"optional": false,
"name": "value",
"description": "The value of the element to add to this\n YMap."
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 438,
"kind": "method",
"name": "get",
"memberof": "src/Types/YMap/YMap.js~YMap",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YMap/YMap.js~YMap#get",
"access": "public",
"description": "Returns a specified element from this YMap.",
"lineNumber": 140,
"params": [
{
"nullable": null,
"types": [
"encodable"
],
"spread": false,
"optional": false,
"name": "key",
"description": "The key of the element to return."
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 439,
"kind": "method",
"name": "has",
"memberof": "src/Types/YMap/YMap.js~YMap",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YMap/YMap.js~YMap#has",
"access": "public",
"description": "Returns a boolean indicating whether the specified key exists or not.",
"lineNumber": 157,
"params": [
{
"nullable": null,
"types": [
"encodable"
],
"spread": false,
"optional": false,
"name": "key",
"description": "The key to test."
}
],
"return": {
"types": [
"boolean"
]
}
},
{
"__docId__": 440,
"kind": "method",
"name": "_logString",
"memberof": "src/Types/YMap/YMap.js~YMap",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YMap/YMap.js~YMap#_logString",
"access": "private",
"description": "Transform this YXml Type to a readable format.\nUseful for logging as all Items and Delete implement this method.",
"lineNumber": 172,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 441,
"kind": "file",
"name": "src/Types/YText/YText.js",
"content": "import ItemString from '../../Struct/ItemString.js'\nimport ItemEmbed from '../../Struct/ItemEmbed.js'\nimport ItemFormat from '../../Struct/ItemFormat.js'\nimport { logItemHelper } from '../../MessageHandler/messageToString.js'\nimport { YArrayEvent, default as YArray } from '../YArray/YArray.js'\n\n/**\n * @private\n */\nfunction integrateItem (item, parent, y, left, right) {\n item._origin = left\n item._left = left\n item._right = right\n item._right_origin = right\n item._parent = parent\n if (y !== null) {\n item._integrate(y)\n } else if (left === null) {\n parent._start = item\n } else {\n left._right = item\n }\n}\n\n/**\n * @private\n */\nfunction findNextPosition (currentAttributes, parent, left, right, count) {\n while (right !== null && count > 0) {\n switch (right.constructor) {\n case ItemEmbed:\n case ItemString:\n const rightLen = right._deleted ? 0 : (right._length - 1)\n if (count <= rightLen) {\n right = right._splitAt(parent._y, count)\n left = right._left\n return [left, right, currentAttributes]\n }\n if (right._deleted === false) {\n count -= right._length\n }\n break\n case ItemFormat:\n if (right._deleted === false) {\n updateCurrentAttributes(currentAttributes, right)\n }\n break\n }\n left = right\n right = right._right\n }\n return [left, right, currentAttributes]\n}\n\n/**\n * @private\n */\nfunction findPosition (parent, index) {\n let currentAttributes = new Map()\n let left = null\n let right = parent._start\n return findNextPosition(currentAttributes, parent, left, right, index)\n}\n\n/**\n * Negate applied formats\n *\n * @private\n */\nfunction insertNegatedAttributes (y, parent, left, right, negatedAttributes) {\n // check if we really need to remove attributes\n while (\n right !== null && (\n right._deleted === true || (\n right.constructor === ItemFormat &&\n (negatedAttributes.get(right.key) === right.value)\n )\n )\n ) {\n if (right._deleted === false) {\n negatedAttributes.delete(right.key)\n }\n left = right\n right = right._right\n }\n for (let [key, val] of negatedAttributes) {\n let format = new ItemFormat()\n format.key = key\n format.value = val\n integrateItem(format, parent, y, left, right)\n left = format\n }\n return [left, right]\n}\n\n/**\n * @private\n */\nfunction updateCurrentAttributes (currentAttributes, item) {\n const value = item.value\n const key = item.key\n if (value === null) {\n currentAttributes.delete(key)\n } else {\n currentAttributes.set(key, value)\n }\n}\n\n/**\n * @private\n */\nfunction minimizeAttributeChanges (left, right, currentAttributes, attributes) {\n // go right while attributes[right.key] === right.value (or right is deleted)\n while (true) {\n if (right === null) {\n break\n } else if (right._deleted === true) {\n // continue\n } else if (right.constructor === ItemFormat && (attributes[right.key] || null) === right.value) {\n // found a format, update currentAttributes and continue\n updateCurrentAttributes(currentAttributes, right)\n } else {\n break\n }\n left = right\n right = right._right\n }\n return [left, right]\n}\n\n/**\n * @private\n */\nfunction insertAttributes (y, parent, left, right, attributes, currentAttributes) {\n const negatedAttributes = new Map()\n // insert format-start items\n for (let key in attributes) {\n const val = attributes[key]\n const currentVal = currentAttributes.get(key)\n if (currentVal !== val) {\n // save negated attribute (set null if currentVal undefined)\n negatedAttributes.set(key, currentVal || null)\n let format = new ItemFormat()\n format.key = key\n format.value = val\n integrateItem(format, parent, y, left, right)\n left = format\n }\n }\n return [left, right, negatedAttributes]\n}\n\n/**\n * @private\n */\nfunction insertText (y, text, parent, left, right, currentAttributes, attributes) {\n for (let [key] of currentAttributes) {\n if (attributes.hasOwnProperty(key) === false) {\n attributes[key] = null\n }\n }\n [left, right] = minimizeAttributeChanges(left, right, currentAttributes, attributes)\n let negatedAttributes\n [left, right, negatedAttributes] = insertAttributes(y, parent, left, right, attributes, currentAttributes)\n // insert content\n let item\n if (text.constructor === String) {\n item = new ItemString()\n item._content = text\n } else {\n item = new ItemEmbed()\n item.embed = text\n }\n integrateItem(item, parent, y, left, right)\n left = item\n return insertNegatedAttributes(y, parent, left, right, negatedAttributes)\n}\n\n/**\n * @private\n */\nfunction formatText (y, length, parent, left, right, currentAttributes, attributes) {\n [left, right] = minimizeAttributeChanges(left, right, currentAttributes, attributes)\n let negatedAttributes\n [left, right, negatedAttributes] = insertAttributes(y, parent, left, right, attributes, currentAttributes)\n // iterate until first non-format or null is found\n // delete all formats with attributes[format.key] != null\n while (length > 0 && right !== null) {\n if (right._deleted === false) {\n switch (right.constructor) {\n case ItemFormat:\n if (attributes.hasOwnProperty(right.key)) {\n if (attributes[right.key] === right.value) {\n negatedAttributes.delete(right.key)\n } else {\n negatedAttributes.set(right.key, right.value)\n }\n right._delete(y)\n }\n updateCurrentAttributes(currentAttributes, right)\n break\n case ItemEmbed:\n case ItemString:\n right._splitAt(y, length)\n length -= right._length\n break\n }\n }\n left = right\n right = right._right\n }\n return insertNegatedAttributes(y, parent, left, right, negatedAttributes)\n}\n\n/**\n * @private\n */\nfunction deleteText (y, length, parent, left, right, currentAttributes) {\n while (length > 0 && right !== null) {\n if (right._deleted === false) {\n switch (right.constructor) {\n case ItemFormat:\n updateCurrentAttributes(currentAttributes, right)\n break\n case ItemEmbed:\n case ItemString:\n right._splitAt(y, length)\n length -= right._length\n right._delete(y)\n break\n }\n }\n left = right\n right = right._right\n }\n return [left, right]\n}\n\n// TODO: In the quill delta representation we should also use the format {ops:[..]}\n/**\n * The Quill Delta format represents changes on a text document with\n * formatting information. For mor information visit {@link https://quilljs.com/docs/delta/|Quill Delta}\n *\n * @example\n * {\n * ops: [\n * { insert: 'Gandalf', attributes: { bold: true } },\n * { insert: ' the ' },\n * { insert: 'Grey', attributes: { color: '#cccccc' } }\n * ]\n * }\n *\n * @typedef {Array<Object>} Delta\n */\n\n /**\n * Attributes that can be assigned to a selection of text.\n *\n * @example\n * {\n * bold: true,\n * font-size: '40px'\n * }\n *\n * @typedef {Object} TextAttributes\n */\n\n/**\n * Event that describes the changes on a YText type.\n *\n * @private\n */\nclass YTextEvent extends YArrayEvent {\n constructor (ytext, remote, transaction) {\n super(ytext, remote, transaction)\n this._delta = null\n }\n // TODO: Should put this in a separate function. toDelta shouldn't be included\n // in every Yjs distribution\n /**\n * Compute the changes in the delta format.\n *\n * @return {Delta} A {@link https://quilljs.com/docs/delta/|Quill Delta}) that\n * represents the changes on the document.\n *\n * @public\n */\n get delta () {\n if (this._delta === null) {\n const y = this.target._y\n y.transact(() => {\n let item = this.target._start\n const delta = []\n const added = this.addedElements\n const removed = this.removedElements\n this._delta = delta\n let action = null\n let attributes = {} // counts added or removed new attributes for retain\n const currentAttributes = new Map() // saves all current attributes for insert\n const oldAttributes = new Map()\n let insert = ''\n let retain = 0\n let deleteLen = 0\n const addOp = function addOp () {\n if (action !== null) {\n let op\n switch (action) {\n case 'delete':\n op = { delete: deleteLen }\n deleteLen = 0\n break\n case 'insert':\n op = { insert }\n if (currentAttributes.size > 0) {\n op.attributes = {}\n for (let [key, value] of currentAttributes) {\n if (value !== null) {\n op.attributes[key] = value\n }\n }\n }\n insert = ''\n break\n case 'retain':\n op = { retain }\n if (Object.keys(attributes).length > 0) {\n op.attributes = {}\n for (let key in attributes) {\n op.attributes[key] = attributes[key]\n }\n }\n retain = 0\n break\n }\n delta.push(op)\n action = null\n }\n }\n while (item !== null) {\n switch (item.constructor) {\n case ItemEmbed:\n if (added.has(item)) {\n addOp()\n action = 'insert'\n insert = item.embed\n addOp()\n } else if (removed.has(item)) {\n if (action !== 'delete') {\n addOp()\n action = 'delete'\n }\n deleteLen += 1\n } else if (item._deleted === false) {\n if (action !== 'retain') {\n addOp()\n action = 'retain'\n }\n retain += 1\n }\n break\n case ItemString:\n if (added.has(item)) {\n if (action !== 'insert') {\n addOp()\n action = 'insert'\n }\n insert += item._content\n } else if (removed.has(item)) {\n if (action !== 'delete') {\n addOp()\n action = 'delete'\n }\n deleteLen += item._length\n } else if (item._deleted === false) {\n if (action !== 'retain') {\n addOp()\n action = 'retain'\n }\n retain += item._length\n }\n break\n case ItemFormat:\n if (added.has(item)) {\n const curVal = currentAttributes.get(item.key) || null\n if (curVal !== item.value) {\n if (action === 'retain') {\n addOp()\n }\n if (item.value === (oldAttributes.get(item.key) || null)) {\n delete attributes[item.key]\n } else {\n attributes[item.key] = item.value\n }\n } else {\n item._delete(y)\n }\n } else if (removed.has(item)) {\n oldAttributes.set(item.key, item.value)\n const curVal = currentAttributes.get(item.key) || null\n if (curVal !== item.value) {\n if (action === 'retain') {\n addOp()\n }\n attributes[item.key] = curVal\n }\n } else if (item._deleted === false) {\n oldAttributes.set(item.key, item.value)\n if (attributes.hasOwnProperty(item.key)) {\n if (attributes[item.key] !== item.value) {\n if (action === 'retain') {\n addOp()\n }\n if (item.value === null) {\n attributes[item.key] = item.value\n } else {\n delete attributes[item.key]\n }\n } else {\n item._delete(y)\n }\n }\n }\n if (item._deleted === false) {\n if (action === 'insert') {\n addOp()\n }\n updateCurrentAttributes(currentAttributes, item)\n }\n break\n }\n item = item._right\n }\n addOp()\n while (this._delta.length > 0) {\n let lastOp = this._delta[this._delta.length - 1]\n if (lastOp.hasOwnProperty('retain') && !lastOp.hasOwnProperty('attributes')) {\n // retain delta's if they don't assign attributes\n this._delta.pop()\n } else {\n break\n }\n }\n })\n }\n return this._delta\n }\n}\n\n/**\n * Type that represents text with formatting information.\n *\n * This type replaces y-richtext as this implementation is able to handle\n * block formats (format information on a paragraph), embeds (complex elements\n * like pictures and videos), and text formats (**bold**, *italic*).\n *\n * @param {String} string The initial value of the YText.\n */\nexport default class YText extends YArray {\n constructor (string) {\n super()\n if (typeof string === 'string') {\n const start = new ItemString()\n start._parent = this\n start._content = string\n this._start = start\n }\n }\n\n /**\n * @private\n * Creates YMap Event and calls observers.\n */\n _callObserver (transaction, parentSubs, remote) {\n this._callEventHandler(transaction, new YTextEvent(this, remote, transaction))\n }\n\n /**\n * Returns the unformatted string representation of this YText type.\n *\n * @public\n */\n toString () {\n let str = ''\n let n = this._start\n while (n !== null) {\n if (!n._deleted && n._countable) {\n str += n._content\n }\n n = n._right\n }\n return str\n }\n\n /**\n * Apply a {@link Delta} on this shared YText type.\n *\n * @param {Delta} delta The changes to apply on this element.\n *\n * @public\n */\n applyDelta (delta) {\n this._transact(y => {\n let left = null\n let right = this._start\n const currentAttributes = new Map()\n for (let i = 0; i < delta.length; i++) {\n let op = delta[i]\n if (op.hasOwnProperty('insert')) {\n ;[left, right] = insertText(y, op.insert, this, left, right, currentAttributes, op.attributes || {})\n } else if (op.hasOwnProperty('retain')) {\n ;[left, right] = formatText(y, op.retain, this, left, right, currentAttributes, op.attributes || {})\n } else if (op.hasOwnProperty('delete')) {\n ;[left, right] = deleteText(y, op.delete, this, left, right, currentAttributes)\n }\n }\n })\n }\n\n /**\n * Returns the Delta representation of this YText type.\n *\n * @return {Delta} The Delta representation of this type.\n *\n * @public\n */\n toDelta () {\n let ops = []\n let currentAttributes = new Map()\n let str = ''\n let n = this._start\n function packStr () {\n if (str.length > 0) {\n // pack str with attributes to ops\n let attributes = {}\n let addAttributes = false\n for (let [key, value] of currentAttributes) {\n addAttributes = true\n attributes[key] = value\n }\n let op = { insert: str }\n if (addAttributes) {\n op.attributes = attributes\n }\n ops.push(op)\n str = ''\n }\n }\n while (n !== null) {\n if (!n._deleted) {\n switch (n.constructor) {\n case ItemString:\n str += n._content\n break\n case ItemFormat:\n packStr()\n updateCurrentAttributes(currentAttributes, n)\n break\n }\n }\n n = n._right\n }\n packStr()\n return ops\n }\n\n /**\n * Insert text at a given index.\n *\n * @param {Integer} index The index at which to start inserting.\n * @param {String} text The text to insert at the specified position.\n * @param {TextAttributes} attributes Optionally define some formatting\n * information to apply on the inserted\n * Text.\n *\n * @public\n */\n insert (index, text, attributes = {}) {\n if (text.length <= 0) {\n return\n }\n this._transact(y => {\n let [left, right, currentAttributes] = findPosition(this, index)\n insertText(y, text, this, left, right, currentAttributes, attributes)\n })\n }\n\n /**\n * Inserts an embed at a index.\n *\n * @param {Integer} index The index to insert the embed at.\n * @param {Object} embed The Object that represents the embed.\n * @param {TextAttributes} attributes Attribute information to apply on the\n * embed\n *\n * @public\n */\n insertEmbed (index, embed, attributes = {}) {\n if (embed.constructor !== Object) {\n throw new Error('Embed must be an Object')\n }\n this._transact(y => {\n let [left, right, currentAttributes] = findPosition(this, index)\n insertText(y, embed, this, left, right, currentAttributes, attributes)\n })\n }\n\n /**\n * Deletes text starting from an index.\n *\n * @param {Integer} index Index at which to start deleting.\n * @param {Integer} length The number of characters to remove. Defaults to 1.\n *\n * @public\n */\n delete (index, length) {\n if (length === 0) {\n return\n }\n this._transact(y => {\n let [left, right, currentAttributes] = findPosition(this, index)\n deleteText(y, length, this, left, right, currentAttributes)\n })\n }\n\n /**\n * Assigns properties to a range of text.\n *\n * @param {Integer} index The position where to start formatting.\n * @param {Integer} length The amount of characters to assign properties to.\n * @param {TextAttributes} attributes Attribute information to apply on the\n * text.\n *\n * @public\n */\n format (index, length, attributes) {\n this._transact(y => {\n let [left, right, currentAttributes] = findPosition(this, index)\n if (right === null) {\n return\n }\n formatText(y, length, this, left, right, currentAttributes, attributes)\n })\n }\n // TODO: De-duplicate code. The following code is in every type.\n /**\n * Transform this YText to a readable format.\n * Useful for logging as all Items implement this method.\n *\n * @private\n */\n _logString () {\n return logItemHelper('YText', this)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Types/YText/YText.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 442,
"kind": "function",
"name": "integrateItem",
"memberof": "src/Types/YText/YText.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Types/YText/YText.js~integrateItem",
"access": "private",
"export": false,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": null,
"description": "",
"lineNumber": 10,
"ignore": true,
"params": [
{
"name": "item",
"types": [
"*"
]
},
{
"name": "parent",
"types": [
"*"
]
},
{
"name": "y",
"types": [
"*"
]
},
{
"name": "left",
"types": [
"*"
]
},
{
"name": "right",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 443,
"kind": "function",
"name": "findNextPosition",
"memberof": "src/Types/YText/YText.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Types/YText/YText.js~findNextPosition",
"access": "private",
"export": false,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": null,
"description": "",
"lineNumber": 28,
"ignore": true,
"params": [
{
"name": "currentAttributes",
"types": [
"*"
]
},
{
"name": "parent",
"types": [
"*"
]
},
{
"name": "left",
"types": [
"*"
]
},
{
"name": "right",
"types": [
"*"
]
},
{
"name": "count",
"types": [
"*"
]
}
],
"return": {
"types": [
"undefined[]"
]
}
},
{
"__docId__": 444,
"kind": "function",
"name": "findPosition",
"memberof": "src/Types/YText/YText.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Types/YText/YText.js~findPosition",
"access": "private",
"export": false,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": null,
"description": "",
"lineNumber": 58,
"ignore": true,
"params": [
{
"name": "parent",
"types": [
"*"
]
},
{
"name": "index",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 445,
"kind": "function",
"name": "insertNegatedAttributes",
"memberof": "src/Types/YText/YText.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Types/YText/YText.js~insertNegatedAttributes",
"access": "private",
"export": false,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": null,
"description": "Negate applied formats",
"lineNumber": 70,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "parent",
"types": [
"*"
]
},
{
"name": "left",
"types": [
"*"
]
},
{
"name": "right",
"types": [
"*"
]
},
{
"name": "negatedAttributes",
"types": [
"*"
]
}
],
"return": {
"types": [
"undefined[]"
]
}
},
{
"__docId__": 446,
"kind": "function",
"name": "updateCurrentAttributes",
"memberof": "src/Types/YText/YText.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Types/YText/YText.js~updateCurrentAttributes",
"access": "private",
"export": false,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": null,
"description": "",
"lineNumber": 99,
"ignore": true,
"params": [
{
"name": "currentAttributes",
"types": [
"*"
]
},
{
"name": "item",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 447,
"kind": "function",
"name": "minimizeAttributeChanges",
"memberof": "src/Types/YText/YText.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Types/YText/YText.js~minimizeAttributeChanges",
"access": "private",
"export": false,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": null,
"description": "",
"lineNumber": 112,
"ignore": true,
"params": [
{
"name": "left",
"types": [
"*"
]
},
{
"name": "right",
"types": [
"*"
]
},
{
"name": "currentAttributes",
"types": [
"*"
]
},
{
"name": "attributes",
"types": [
"*"
]
}
],
"return": {
"types": [
"undefined[]"
]
}
},
{
"__docId__": 448,
"kind": "function",
"name": "insertAttributes",
"memberof": "src/Types/YText/YText.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Types/YText/YText.js~insertAttributes",
"access": "private",
"export": false,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": null,
"description": "",
"lineNumber": 134,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "parent",
"types": [
"*"
]
},
{
"name": "left",
"types": [
"*"
]
},
{
"name": "right",
"types": [
"*"
]
},
{
"name": "attributes",
"types": [
"*"
]
},
{
"name": "currentAttributes",
"types": [
"*"
]
}
],
"return": {
"types": [
"undefined[]"
]
}
},
{
"__docId__": 449,
"kind": "function",
"name": "insertText",
"memberof": "src/Types/YText/YText.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Types/YText/YText.js~insertText",
"access": "private",
"export": false,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": null,
"description": "",
"lineNumber": 156,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "text",
"types": [
"*"
]
},
{
"name": "parent",
"types": [
"*"
]
},
{
"name": "left",
"types": [
"*"
]
},
{
"name": "right",
"types": [
"*"
]
},
{
"name": "currentAttributes",
"types": [
"*"
]
},
{
"name": "attributes",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 450,
"kind": "function",
"name": "formatText",
"memberof": "src/Types/YText/YText.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Types/YText/YText.js~formatText",
"access": "private",
"export": false,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": null,
"description": "",
"lineNumber": 182,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "length",
"types": [
"*"
]
},
{
"name": "parent",
"types": [
"*"
]
},
{
"name": "left",
"types": [
"*"
]
},
{
"name": "right",
"types": [
"*"
]
},
{
"name": "currentAttributes",
"types": [
"*"
]
},
{
"name": "attributes",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 451,
"kind": "function",
"name": "deleteText",
"memberof": "src/Types/YText/YText.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Types/YText/YText.js~deleteText",
"access": "private",
"export": false,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": null,
"description": "",
"lineNumber": 218,
"ignore": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "length",
"types": [
"*"
]
},
{
"name": "parent",
"types": [
"*"
]
},
{
"name": "left",
"types": [
"*"
]
},
{
"name": "right",
"types": [
"*"
]
},
{
"name": "currentAttributes",
"types": [
"*"
]
}
],
"return": {
"types": [
"undefined[]"
]
}
},
{
"__docId__": 452,
"kind": "typedef",
"name": "Delta",
"memberof": "src/Types/YText/YText.js",
"static": true,
"longname": "src/Types/YText/YText.js~Delta",
"access": "public",
"description": "The Quill Delta format represents changes on a text document with\nformatting information. For mor information visit {@link https://quilljs.com/docs/delta/|Quill Delta}",
"examples": [
" {\n ops: [\n { insert: 'Gandalf', attributes: { bold: true } },\n { insert: ' the ' },\n { insert: 'Grey', attributes: { color: '#cccccc' } }\n ]\n }"
],
"type": {
"types": [
"Array<Object>"
],
"optional": false,
"name": "Delta"
}
},
{
"__docId__": 453,
"kind": "typedef",
"name": "TextAttributes",
"memberof": "src/Types/YText/YText.js",
"static": true,
"longname": "src/Types/YText/YText.js~TextAttributes",
"access": "public",
"description": "Attributes that can be assigned to a selection of text.",
"examples": [
" {\n bold: true,\n font-size: '40px'\n }"
],
"type": {
"types": [
"Object"
],
"optional": false,
"name": "TextAttributes"
}
},
{
"__docId__": 454,
"kind": "class",
"name": "YTextEvent",
"memberof": "src/Types/YText/YText.js",
"static": true,
"longname": "src/Types/YText/YText.js~YTextEvent",
"access": "private",
"export": false,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": null,
"description": "Event that describes the changes on a YText type.",
"lineNumber": 273,
"interface": false,
"extends": [
"src/Types/YArray/YArray.js~YArrayEvent"
],
"ignore": true
},
{
"__docId__": 455,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Types/YText/YText.js~YTextEvent",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YTextEvent#constructor",
"access": "public",
"description": null,
"lineNumber": 274,
"undocument": true
},
{
"__docId__": 456,
"kind": "member",
"name": "_delta",
"memberof": "src/Types/YText/YText.js~YTextEvent",
"static": false,
"longname": "src/Types/YText/YText.js~YTextEvent#_delta",
"access": "private",
"description": null,
"lineNumber": 276,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 457,
"kind": "get",
"name": "delta",
"memberof": "src/Types/YText/YText.js~YTextEvent",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YTextEvent#delta",
"access": "public",
"description": "Compute the changes in the delta format.",
"lineNumber": 288,
"return": {
"nullable": null,
"types": [
"Delta"
],
"spread": false,
"description": "A {@link https://quilljs.com/docs/delta/|Quill Delta}) that\n represents the changes on the document."
},
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 459,
"kind": "class",
"name": "YText",
"memberof": "src/Types/YText/YText.js",
"static": true,
"longname": "src/Types/YText/YText.js~YText",
"access": "public",
"export": true,
"importPath": "yjs/src/Types/YText/YText.js",
"importStyle": "YText",
"description": "Type that represents text with formatting information.\n\nThis type replaces y-richtext as this implementation is able to handle\nblock formats (format information on a paragraph), embeds (complex elements\nlike pictures and videos), and text formats (**bold**, *italic*).",
"lineNumber": 458,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "string",
"description": "The initial value of the YText."
}
],
"interface": false,
"extends": [
"src/Types/YArray/YArray.js~YArray"
]
},
{
"__docId__": 460,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Types/YText/YText.js~YText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YText#constructor",
"access": "public",
"description": null,
"lineNumber": 459,
"undocument": true
},
{
"__docId__": 461,
"kind": "member",
"name": "_start",
"memberof": "src/Types/YText/YText.js~YText",
"static": false,
"longname": "src/Types/YText/YText.js~YText#_start",
"access": "private",
"description": null,
"lineNumber": 465,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 462,
"kind": "method",
"name": "_callObserver",
"memberof": "src/Types/YText/YText.js~YText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YText#_callObserver",
"access": "private",
"description": "",
"lineNumber": 473,
"ignore": true,
"params": [
{
"name": "transaction",
"types": [
"*"
]
},
{
"name": "parentSubs",
"types": [
"*"
]
},
{
"name": "remote",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 463,
"kind": "method",
"name": "toString",
"memberof": "src/Types/YText/YText.js~YText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YText#toString",
"access": "public",
"description": "Returns the unformatted string representation of this YText type.",
"lineNumber": 482,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 464,
"kind": "method",
"name": "applyDelta",
"memberof": "src/Types/YText/YText.js~YText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YText#applyDelta",
"access": "public",
"description": "Apply a {@link Delta} on this shared YText type.",
"lineNumber": 501,
"params": [
{
"nullable": null,
"types": [
"Delta"
],
"spread": false,
"optional": false,
"name": "delta",
"description": "The changes to apply on this element."
}
],
"return": null
},
{
"__docId__": 465,
"kind": "method",
"name": "toDelta",
"memberof": "src/Types/YText/YText.js~YText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YText#toDelta",
"access": "public",
"description": "Returns the Delta representation of this YText type.",
"lineNumber": 526,
"return": {
"nullable": null,
"types": [
"Delta"
],
"spread": false,
"description": "The Delta representation of this type."
},
"params": []
},
{
"__docId__": 466,
"kind": "method",
"name": "insert",
"memberof": "src/Types/YText/YText.js~YText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YText#insert",
"access": "public",
"description": "Insert text at a given index.",
"lineNumber": 577,
"params": [
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "index",
"description": "The index at which to start inserting."
},
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "text",
"description": "The text to insert at the specified position."
},
{
"nullable": null,
"types": [
"TextAttributes"
],
"spread": false,
"optional": false,
"name": "attributes",
"description": "Optionally define some formatting\n information to apply on the inserted\n Text."
}
],
"return": null
},
{
"__docId__": 467,
"kind": "method",
"name": "insertEmbed",
"memberof": "src/Types/YText/YText.js~YText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YText#insertEmbed",
"access": "public",
"description": "Inserts an embed at a index.",
"lineNumber": 597,
"params": [
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "index",
"description": "The index to insert the embed at."
},
{
"nullable": null,
"types": [
"Object"
],
"spread": false,
"optional": false,
"name": "embed",
"description": "The Object that represents the embed."
},
{
"nullable": null,
"types": [
"TextAttributes"
],
"spread": false,
"optional": false,
"name": "attributes",
"description": "Attribute information to apply on the\n embed"
}
],
"return": null
},
{
"__docId__": 468,
"kind": "method",
"name": "delete",
"memberof": "src/Types/YText/YText.js~YText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YText#delete",
"access": "public",
"description": "Deletes text starting from an index.",
"lineNumber": 615,
"params": [
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "index",
"description": "Index at which to start deleting."
},
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "length",
"description": "The number of characters to remove. Defaults to 1."
}
],
"return": null
},
{
"__docId__": 469,
"kind": "method",
"name": "format",
"memberof": "src/Types/YText/YText.js~YText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YText#format",
"access": "public",
"description": "Assigns properties to a range of text.",
"lineNumber": 635,
"params": [
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "index",
"description": "The position where to start formatting."
},
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "length",
"description": "The amount of characters to assign properties to."
},
{
"nullable": null,
"types": [
"TextAttributes"
],
"spread": false,
"optional": false,
"name": "attributes",
"description": "Attribute information to apply on the\n text."
}
],
"return": null
},
{
"__docId__": 470,
"kind": "method",
"name": "_logString",
"memberof": "src/Types/YText/YText.js~YText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YText/YText.js~YText#_logString",
"access": "private",
"description": "Transform this YText to a readable format.\nUseful for logging as all Items implement this method.",
"lineNumber": 651,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 471,
"kind": "file",
"name": "src/Types/YXml/YXml.js",
"content": "\nimport YXmlFragment from './YXmlFragment.js'\nimport YXmlElement from './YXmlElement.js'\nimport YXmlHook from './YXmlHook.js'\n\nexport { default as YXmlFragment } from './YXmlFragment.js'\nexport { default as YXmlElement } from './YXmlElement.js'\nexport { default as YXmlText } from './YXmlText.js'\nexport { default as YXmlHook } from './YXmlHook.js'\n\nYXmlFragment._YXmlElement = YXmlElement\nYXmlFragment._YXmlHook = YXmlHook\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Types/YXml/YXml.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 472,
"kind": "file",
"name": "src/Types/YXml/YXmlElement.js",
"content": "import YMap from '../YMap/YMap.js'\nimport { YXmlFragment } from './YXml.js'\nimport { createAssociation } from '../../Bindings/DomBinding/util.js'\n\n/**\n * An YXmlElement imitates the behavior of a\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}.\n *\n * * An YXmlElement has attributes (key value pairs)\n * * An YXmlElement has childElements that must inherit from YXmlElement\n *\n * @param {String} nodeName Node name\n */\nexport default class YXmlElement extends YXmlFragment {\n constructor (nodeName = 'UNDEFINED') {\n super()\n this.nodeName = nodeName.toUpperCase()\n }\n\n /**\n * @private\n * Creates an Item with the same effect as this Item (without position effect)\n */\n _copy () {\n let struct = super._copy()\n struct.nodeName = this.nodeName\n return struct\n }\n\n /**\n * @private\n * Read the next Item in a Decoder and fill this Item with the read data.\n *\n * This is called when data is received from a remote peer.\n *\n * @param {Y} y The Yjs instance that this Item belongs to.\n * @param {BinaryDecoder} decoder The decoder object to read data from.\n */\n _fromBinary (y, decoder) {\n const missing = super._fromBinary(y, decoder)\n this.nodeName = decoder.readVarString()\n return missing\n }\n\n /**\n * Transform the properties of this type to binary and write it to an\n * BinaryEncoder.\n *\n * This is called when this Item is sent to a remote peer.\n *\n * @param {BinaryEncoder} encoder The encoder to write data to.\n *\n * @private\n */\n _toBinary (encoder) {\n super._toBinary(encoder)\n encoder.writeVarString(this.nodeName)\n }\n\n /**\n * Integrates this Item into the shared structure.\n *\n * This method actually applies the change to the Yjs instance. In case of\n * Item it connects _left and _right to this Item and calls the\n * {@link Item#beforeChange} method.\n *\n * * Checks for nodeName\n * * Sets domFilter\n *\n * @param {Y} y The Yjs instance\n *\n * @private\n */\n _integrate (y) {\n if (this.nodeName === null) {\n throw new Error('nodeName must be defined!')\n }\n super._integrate(y)\n }\n\n /**\n * Returns the string representation of this YXmlElement.\n * The attributes are ordered by attribute-name, so you can easily use this\n * method to compare YXmlElements\n *\n * @return {String} The string representation of this type.\n *\n * @public\n */\n toString () {\n const attrs = this.getAttributes()\n const stringBuilder = []\n const keys = []\n for (let key in attrs) {\n keys.push(key)\n }\n keys.sort()\n const keysLen = keys.length\n for (let i = 0; i < keysLen; i++) {\n const key = keys[i]\n stringBuilder.push(key + '=\"' + attrs[key] + '\"')\n }\n const nodeName = this.nodeName.toLocaleLowerCase()\n const attrsString = stringBuilder.length > 0 ? ' ' + stringBuilder.join(' ') : ''\n return `<${nodeName}${attrsString}>${super.toString()}</${nodeName}>`\n }\n\n /**\n * Removes an attribute from this YXmlElement.\n *\n * @param {String} attributeName The attribute name that is to be removed.\n *\n * @public\n */\n removeAttribute (attributeName) {\n return YMap.prototype.delete.call(this, attributeName)\n }\n\n /**\n * Sets or updates an attribute.\n *\n * @param {String} attributeName The attribute name that is to be set.\n * @param {String} attributeValue The attribute value that is to be set.\n *\n * @public\n */\n setAttribute (attributeName, attributeValue) {\n return YMap.prototype.set.call(this, attributeName, attributeValue)\n }\n\n /**\n * Returns an attribute value that belongs to the attribute name.\n *\n * @param {String} attributeName The attribute name that identifies the\n * queried value.\n * @return {String} The queried attribute value.\n *\n * @public\n */\n getAttribute (attributeName) {\n return YMap.prototype.get.call(this, attributeName)\n }\n\n /**\n * Returns all attribute name/value pairs in a JSON Object.\n *\n * @return {Object} A JSON Object that describes the attributes.\n *\n * @public\n */\n getAttributes () {\n const obj = {}\n for (let [key, value] of this._map) {\n if (!value._deleted) {\n obj[key] = value._content[0]\n }\n }\n return obj\n }\n // TODO: outsource the binding property.\n /**\n * Creates a Dom Element that mirrors this YXmlElement.\n *\n * @param {Document} [_document=document] The document object (you must define\n * this when calling this method in\n * nodejs)\n * @param {Object<key:hookDefinition>} [hooks={}] Optional property to customize how hooks\n * are presented in the DOM\n * @param {DomBinding} [binding] You should not set this property. This is\n * used if DomBinding wants to create a\n * association to the created DOM type.\n * @return {Element} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}\n *\n * @public\n */\n toDom (_document = document, hooks = {}, binding) {\n const dom = _document.createElement(this.nodeName)\n let attrs = this.getAttributes()\n for (let key in attrs) {\n dom.setAttribute(key, attrs[key])\n }\n this.forEach(yxml => {\n dom.appendChild(yxml.toDom(_document, hooks, binding))\n })\n createAssociation(binding, dom, this)\n return dom\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Types/YXml/YXmlElement.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 473,
"kind": "class",
"name": "YXmlElement",
"memberof": "src/Types/YXml/YXmlElement.js",
"static": true,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement",
"access": "public",
"export": true,
"importPath": "yjs/src/Types/YXml/YXmlElement.js",
"importStyle": "YXmlElement",
"description": "An YXmlElement imitates the behavior of a\n{@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}.\n\n* An YXmlElement has attributes (key value pairs)\n* An YXmlElement has childElements that must inherit from YXmlElement",
"lineNumber": 14,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "nodeName",
"description": "Node name"
}
],
"interface": false,
"extends": [
"src/Types/YXml/YXml.js~YXmlFragment"
]
},
{
"__docId__": 474,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#constructor",
"access": "public",
"description": null,
"lineNumber": 15,
"undocument": true
},
{
"__docId__": 475,
"kind": "member",
"name": "nodeName",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#nodeName",
"access": "public",
"description": null,
"lineNumber": 17,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 476,
"kind": "method",
"name": "_copy",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#_copy",
"access": "private",
"description": "",
"lineNumber": 24,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 477,
"kind": "method",
"name": "_fromBinary",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#_fromBinary",
"access": "private",
"description": "",
"lineNumber": 39,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance that this Item belongs to."
},
{
"nullable": null,
"types": [
"BinaryDecoder"
],
"spread": false,
"optional": false,
"name": "decoder",
"description": "The decoder object to read data from."
}
],
"ignore": true,
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 479,
"kind": "method",
"name": "_toBinary",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#_toBinary",
"access": "private",
"description": "Transform the properties of this type to binary and write it to an\nBinaryEncoder.\n\nThis is called when this Item is sent to a remote peer.",
"lineNumber": 55,
"params": [
{
"nullable": null,
"types": [
"BinaryEncoder"
],
"spread": false,
"optional": false,
"name": "encoder",
"description": "The encoder to write data to."
}
],
"ignore": true,
"return": null
},
{
"__docId__": 480,
"kind": "method",
"name": "_integrate",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#_integrate",
"access": "private",
"description": "Integrates this Item into the shared structure.\n\nThis method actually applies the change to the Yjs instance. In case of\nItem it connects _left and _right to this Item and calls the\n{@link Item#beforeChange} method.\n\n* Checks for nodeName\n* Sets domFilter",
"lineNumber": 74,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance"
}
],
"ignore": true,
"return": null
},
{
"__docId__": 481,
"kind": "method",
"name": "toString",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#toString",
"access": "public",
"description": "Returns the string representation of this YXmlElement.\nThe attributes are ordered by attribute-name, so you can easily use this\nmethod to compare YXmlElements",
"lineNumber": 90,
"return": {
"nullable": null,
"types": [
"String"
],
"spread": false,
"description": "The string representation of this type."
},
"params": []
},
{
"__docId__": 482,
"kind": "method",
"name": "removeAttribute",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#removeAttribute",
"access": "public",
"description": "Removes an attribute from this YXmlElement.",
"lineNumber": 115,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "attributeName",
"description": "The attribute name that is to be removed."
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 483,
"kind": "method",
"name": "setAttribute",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#setAttribute",
"access": "public",
"description": "Sets or updates an attribute.",
"lineNumber": 127,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "attributeName",
"description": "The attribute name that is to be set."
},
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "attributeValue",
"description": "The attribute value that is to be set."
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 484,
"kind": "method",
"name": "getAttribute",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#getAttribute",
"access": "public",
"description": "Returns an attribute value that belongs to the attribute name.",
"lineNumber": 140,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "attributeName",
"description": "The attribute name that identifies the\n queried value."
}
],
"return": {
"nullable": null,
"types": [
"String"
],
"spread": false,
"description": "The queried attribute value."
}
},
{
"__docId__": 485,
"kind": "method",
"name": "getAttributes",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#getAttributes",
"access": "public",
"description": "Returns all attribute name/value pairs in a JSON Object.",
"lineNumber": 151,
"return": {
"nullable": null,
"types": [
"Object"
],
"spread": false,
"description": "A JSON Object that describes the attributes."
},
"params": []
},
{
"__docId__": 486,
"kind": "method",
"name": "toDom",
"memberof": "src/Types/YXml/YXmlElement.js~YXmlElement",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlElement.js~YXmlElement#toDom",
"access": "public",
"description": "Creates a Dom Element that mirrors this YXmlElement.",
"lineNumber": 176,
"params": [
{
"nullable": null,
"types": [
"Document"
],
"spread": false,
"optional": true,
"defaultValue": "document",
"defaultRaw": "document",
"name": "_document",
"description": "The document object (you must define\n this when calling this method in\n nodejs)"
},
{
"nullable": null,
"types": [
"Object<key:hookDefinition>"
],
"spread": false,
"optional": true,
"defaultValue": "{}",
"defaultRaw": {},
"name": "hooks",
"description": "Optional property to customize how hooks\n are presented in the DOM"
},
{
"nullable": null,
"types": [
"DomBinding"
],
"spread": false,
"optional": true,
"name": "binding",
"description": "You should not set this property. This is\n used if DomBinding wants to create a\n association to the created DOM type."
}
],
"return": {
"nullable": null,
"types": [
"Element"
],
"spread": false,
"description": "The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}"
}
},
{
"__docId__": 487,
"kind": "file",
"name": "src/Types/YXml/YXmlEvent.js",
"content": "import YEvent from '../../Util/YEvent.js'\n\n/**\n * An Event that describes changes on a YXml Element or Yxml Fragment\n *\n * @protected\n */\nexport default class YXmlEvent extends YEvent {\n /**\n * @param {YType} target The target on which the event is created.\n * @param {Set} subs The set of changed attributes. `null` is included if the\n * child list changed.\n * @param {Boolean} remote Whether this change was created by a remote peer.\n * @param {Transaction} transaction The transaction instance with wich the\n * change was created.\n */\n constructor (target, subs, remote, transaction) {\n super(target)\n /**\n * The transaction instance for the computed change.\n * @type {Transaction}\n */\n this._transaction = transaction\n /**\n * Whether the children changed.\n * @type {Boolean}\n */\n this.childListChanged = false\n /**\n * Set of all changed attributes.\n * @type {Set}\n */\n this.attributesChanged = new Set()\n /**\n * Whether this change was created by a remote peer.\n * @type {Boolean}\n */\n this.remote = remote\n subs.forEach((sub) => {\n if (sub === null) {\n this.childListChanged = true\n } else {\n this.attributesChanged.add(sub)\n }\n })\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Types/YXml/YXmlEvent.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 488,
"kind": "class",
"name": "YXmlEvent",
"memberof": "src/Types/YXml/YXmlEvent.js",
"static": true,
"longname": "src/Types/YXml/YXmlEvent.js~YXmlEvent",
"access": "protected",
"export": true,
"importPath": "yjs/src/Types/YXml/YXmlEvent.js",
"importStyle": "YXmlEvent",
"description": "An Event that describes changes on a YXml Element or Yxml Fragment",
"lineNumber": 8,
"interface": false,
"extends": [
"src/Util/YEvent.js~YEvent"
],
"ignore": true
},
{
"__docId__": 489,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Types/YXml/YXmlEvent.js~YXmlEvent",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlEvent.js~YXmlEvent#constructor",
"access": "public",
"description": "",
"lineNumber": 17,
"params": [
{
"nullable": null,
"types": [
"YType"
],
"spread": false,
"optional": false,
"name": "target",
"description": "The target on which the event is created."
},
{
"nullable": null,
"types": [
"Set"
],
"spread": false,
"optional": false,
"name": "subs",
"description": "The set of changed attributes. `null` is included if the\n child list changed."
},
{
"nullable": null,
"types": [
"Boolean"
],
"spread": false,
"optional": false,
"name": "remote",
"description": "Whether this change was created by a remote peer."
},
{
"nullable": null,
"types": [
"Transaction"
],
"spread": false,
"optional": false,
"name": "transaction",
"description": "The transaction instance with wich the\n change was created."
}
]
},
{
"__docId__": 490,
"kind": "member",
"name": "_transaction",
"memberof": "src/Types/YXml/YXmlEvent.js~YXmlEvent",
"static": false,
"longname": "src/Types/YXml/YXmlEvent.js~YXmlEvent#_transaction",
"access": "private",
"description": "The transaction instance for the computed change.",
"lineNumber": 23,
"type": {
"nullable": null,
"types": [
"Transaction"
],
"spread": false,
"description": null
},
"ignore": true
},
{
"__docId__": 491,
"kind": "member",
"name": "childListChanged",
"memberof": "src/Types/YXml/YXmlEvent.js~YXmlEvent",
"static": false,
"longname": "src/Types/YXml/YXmlEvent.js~YXmlEvent#childListChanged",
"access": "public",
"description": "Whether the children changed.",
"lineNumber": 28,
"type": {
"nullable": null,
"types": [
"Boolean"
],
"spread": false,
"description": null
}
},
{
"__docId__": 492,
"kind": "member",
"name": "attributesChanged",
"memberof": "src/Types/YXml/YXmlEvent.js~YXmlEvent",
"static": false,
"longname": "src/Types/YXml/YXmlEvent.js~YXmlEvent#attributesChanged",
"access": "public",
"description": "Set of all changed attributes.",
"lineNumber": 33,
"type": {
"nullable": null,
"types": [
"Set"
],
"spread": false,
"description": null
}
},
{
"__docId__": 493,
"kind": "member",
"name": "remote",
"memberof": "src/Types/YXml/YXmlEvent.js~YXmlEvent",
"static": false,
"longname": "src/Types/YXml/YXmlEvent.js~YXmlEvent#remote",
"access": "public",
"description": "Whether this change was created by a remote peer.",
"lineNumber": 38,
"type": {
"nullable": null,
"types": [
"Boolean"
],
"spread": false,
"description": null
}
},
{
"__docId__": 495,
"kind": "file",
"name": "src/Types/YXml/YXmlFragment.js",
"content": "import { createAssociation } from '../../Bindings/DomBinding/util.js'\nimport YXmlTreeWalker from './YXmlTreeWalker.js'\n\nimport YArray from '../YArray/YArray.js'\nimport YXmlEvent from './YXmlEvent.js'\nimport { logItemHelper } from '../../MessageHandler/messageToString.js'\n\n/**\n * Dom filter function.\n *\n * @callback domFilter\n * @param {string} nodeName The nodeName of the element\n * @param {Map} attributes The map of attributes.\n * @return {boolean} Whether to include the Dom node in the YXmlElement.\n */\n\n/**\n * Define the elements to which a set of CSS queries apply.\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}\n *\n * @example\n * query = '.classSelector'\n * query = 'nodeSelector'\n * query = '#idSelector'\n *\n * @typedef {string} CSS_Selector\n */\n\n/**\n * Represents a list of {@link YXmlElement}.and {@link YXmlText} types.\n * A YxmlFragment is similar to a {@link YXmlElement}, but it does not have a\n * nodeName and it does not have attributes. Though it can be bound to a DOM\n * element - in this case the attributes and the nodeName are not shared.\n *\n * @public\n */\nexport default class YXmlFragment extends YArray {\n /**\n * Create a subtree of childNodes.\n *\n * @example\n * const walker = elem.createTreeWalker(dom => dom.nodeName === 'div')\n * for (let node in walker) {\n * // `node` is a div node\n * nop(node)\n * }\n *\n * @param {Function} filter Function that is called on each child element and\n * returns a Boolean indicating whether the child\n * is to be included in the subtree.\n * @return {TreeWalker} A subtree and a position within it.\n *\n * @public\n */\n createTreeWalker (filter) {\n return new YXmlTreeWalker(this, filter)\n }\n\n /**\n * Returns the first YXmlElement that matches the query.\n * Similar to DOM's {@link querySelector}.\n *\n * Query support:\n * - tagname\n * TODO:\n * - id\n * - attribute\n *\n * @param {CSS_Selector} query The query on the children.\n * @return {?YXmlElement} The first element that matches the query or null.\n *\n * @public\n */\n querySelector (query) {\n query = query.toUpperCase()\n const iterator = new YXmlTreeWalker(this, element => element.nodeName === query)\n const next = iterator.next()\n if (next.done) {\n return null\n } else {\n return next.value\n }\n }\n\n /**\n * Returns all YXmlElements that match the query.\n * Similar to Dom's {@link querySelectorAll}.\n *\n * TODO: Does not yet support all queries. Currently only query by tagName.\n *\n * @param {CSS_Selector} query The query on the children\n * @return {Array<YXmlElement>} The elements that match this query.\n *\n * @public\n */\n querySelectorAll (query) {\n query = query.toUpperCase()\n return Array.from(new YXmlTreeWalker(this, element => element.nodeName === query))\n }\n\n /**\n * Creates YArray Event and calls observers.\n *\n * @private\n */\n _callObserver (transaction, parentSubs, remote) {\n this._callEventHandler(transaction, new YXmlEvent(this, parentSubs, remote, transaction))\n }\n\n /**\n * Get the string representation of all the children of this YXmlFragment.\n *\n * @return {string} The string representation of all children.\n */\n toString () {\n return this.map(xml => xml.toString()).join('')\n }\n\n /**\n * @private\n * Unbind from Dom and mark this Item as deleted.\n *\n * @param {Y} y The Yjs instance\n * @param {boolean} createDelete Whether to propagate a message that this\n * Type was deleted.\n * @param {boolean} [gcChildren=y._hasUndoManager===false] Whether to garbage\n * collect the children of this type.\n *\n * @private\n */\n _delete (y, createDelete, gcChildren) {\n super._delete(y, createDelete, gcChildren)\n }\n\n /**\n * Creates a Dom Element that mirrors this YXmlElement.\n *\n * @param {Document} [_document=document] The document object (you must define\n * this when calling this method in\n * nodejs)\n * @param {Object<key:hookDefinition>} [hooks={}] Optional property to customize how hooks\n * are presented in the DOM\n * @param {DomBinding} [binding] You should not set this property. This is\n * used if DomBinding wants to create a\n * association to the created DOM type\n * @return {Element} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}\n *\n * @public\n */\n toDom (_document = document, hooks = {}, binding) {\n const fragment = _document.createDocumentFragment()\n createAssociation(binding, fragment, this)\n this.forEach(xmlType => {\n fragment.insertBefore(xmlType.toDom(_document, hooks, binding), null)\n })\n return fragment\n }\n /**\n * Transform this YXml Type to a readable format.\n * Useful for logging as all Items and Delete implement this method.\n *\n * @private\n */\n _logString () {\n return logItemHelper('YXml', this)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Types/YXml/YXmlFragment.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 496,
"kind": "typedef",
"name": "CSS_Selector",
"memberof": "src/Types/YXml/YXmlFragment.js",
"static": true,
"longname": "src/Types/YXml/YXmlFragment.js~CSS_Selector",
"access": "public",
"description": "Define the elements to which a set of CSS queries apply.\n{@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}",
"examples": [
" query = '.classSelector'\n query = 'nodeSelector'\n query = '#idSelector'"
],
"type": {
"types": [
"string"
],
"optional": false,
"name": "CSS_Selector"
}
},
{
"__docId__": 497,
"kind": "class",
"name": "YXmlFragment",
"memberof": "src/Types/YXml/YXmlFragment.js",
"static": true,
"longname": "src/Types/YXml/YXmlFragment.js~YXmlFragment",
"access": "public",
"export": true,
"importPath": "yjs/src/Types/YXml/YXmlFragment.js",
"importStyle": "YXmlFragment",
"description": "Represents a list of {@link YXmlElement}.and {@link YXmlText} types.\nA YxmlFragment is similar to a {@link YXmlElement}, but it does not have a\nnodeName and it does not have attributes. Though it can be bound to a DOM\nelement - in this case the attributes and the nodeName are not shared.",
"lineNumber": 37,
"interface": false,
"extends": [
"src/Types/YArray/YArray.js~YArray"
]
},
{
"__docId__": 498,
"kind": "method",
"name": "createTreeWalker",
"memberof": "src/Types/YXml/YXmlFragment.js~YXmlFragment",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlFragment.js~YXmlFragment#createTreeWalker",
"access": "public",
"description": "Create a subtree of childNodes.",
"examples": [
"const walker = elem.createTreeWalker(dom => dom.nodeName === 'div')\nfor (let node in walker) {\n // `node` is a div node\n nop(node)\n}"
],
"lineNumber": 55,
"params": [
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "filter",
"description": "Function that is called on each child element and\n returns a Boolean indicating whether the child\n is to be included in the subtree."
}
],
"return": {
"nullable": null,
"types": [
"TreeWalker"
],
"spread": false,
"description": "A subtree and a position within it."
}
},
{
"__docId__": 499,
"kind": "method",
"name": "querySelector",
"memberof": "src/Types/YXml/YXmlFragment.js~YXmlFragment",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlFragment.js~YXmlFragment#querySelector",
"access": "public",
"description": "Returns the first YXmlElement that matches the query.\nSimilar to DOM's {@link querySelector}.\n\nQuery support:\n - tagname\nTODO:\n - id\n - attribute",
"lineNumber": 74,
"params": [
{
"nullable": null,
"types": [
"CSS_Selector"
],
"spread": false,
"optional": false,
"name": "query",
"description": "The query on the children."
}
],
"return": {
"nullable": true,
"types": [
"YXmlElement"
],
"spread": false,
"description": "The first element that matches the query or null."
}
},
{
"__docId__": 500,
"kind": "method",
"name": "querySelectorAll",
"memberof": "src/Types/YXml/YXmlFragment.js~YXmlFragment",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlFragment.js~YXmlFragment#querySelectorAll",
"access": "public",
"description": "Returns all YXmlElements that match the query.\nSimilar to Dom's {@link querySelectorAll}.\n\nTODO: Does not yet support all queries. Currently only query by tagName.",
"lineNumber": 96,
"params": [
{
"nullable": null,
"types": [
"CSS_Selector"
],
"spread": false,
"optional": false,
"name": "query",
"description": "The query on the children"
}
],
"return": {
"nullable": null,
"types": [
"Array<YXmlElement>"
],
"spread": false,
"description": "The elements that match this query."
}
},
{
"__docId__": 501,
"kind": "method",
"name": "_callObserver",
"memberof": "src/Types/YXml/YXmlFragment.js~YXmlFragment",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlFragment.js~YXmlFragment#_callObserver",
"access": "private",
"description": "Creates YArray Event and calls observers.",
"lineNumber": 106,
"ignore": true,
"params": [
{
"name": "transaction",
"types": [
"*"
]
},
{
"name": "parentSubs",
"types": [
"*"
]
},
{
"name": "remote",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 502,
"kind": "method",
"name": "toString",
"memberof": "src/Types/YXml/YXmlFragment.js~YXmlFragment",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlFragment.js~YXmlFragment#toString",
"access": "public",
"description": "Get the string representation of all the children of this YXmlFragment.",
"lineNumber": 115,
"return": {
"nullable": null,
"types": [
"string"
],
"spread": false,
"description": "The string representation of all children."
},
"params": []
},
{
"__docId__": 503,
"kind": "method",
"name": "_delete",
"memberof": "src/Types/YXml/YXmlFragment.js~YXmlFragment",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlFragment.js~YXmlFragment#_delete",
"access": "private",
"description": "",
"lineNumber": 131,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance"
},
{
"nullable": null,
"types": [
"boolean"
],
"spread": false,
"optional": false,
"name": "createDelete",
"description": "Whether to propagate a message that this\n Type was deleted."
},
{
"nullable": null,
"types": [
"boolean"
],
"spread": false,
"optional": true,
"name": "gcChildren",
"description": "Whether to garbage\n collect the children of this type."
}
],
"ignore": true,
"return": null
},
{
"__docId__": 504,
"kind": "method",
"name": "toDom",
"memberof": "src/Types/YXml/YXmlFragment.js~YXmlFragment",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlFragment.js~YXmlFragment#toDom",
"access": "public",
"description": "Creates a Dom Element that mirrors this YXmlElement.",
"lineNumber": 150,
"params": [
{
"nullable": null,
"types": [
"Document"
],
"spread": false,
"optional": true,
"defaultValue": "document",
"defaultRaw": "document",
"name": "_document",
"description": "The document object (you must define\n this when calling this method in\n nodejs)"
},
{
"nullable": null,
"types": [
"Object<key:hookDefinition>"
],
"spread": false,
"optional": true,
"defaultValue": "{}",
"defaultRaw": {},
"name": "hooks",
"description": "Optional property to customize how hooks\n are presented in the DOM"
},
{
"nullable": null,
"types": [
"DomBinding"
],
"spread": false,
"optional": true,
"name": "binding",
"description": "You should not set this property. This is\n used if DomBinding wants to create a\n association to the created DOM type"
}
],
"return": {
"nullable": null,
"types": [
"Element"
],
"spread": false,
"description": "The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}"
}
},
{
"__docId__": 505,
"kind": "method",
"name": "_logString",
"memberof": "src/Types/YXml/YXmlFragment.js~YXmlFragment",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlFragment.js~YXmlFragment#_logString",
"access": "private",
"description": "Transform this YXml Type to a readable format.\nUseful for logging as all Items and Delete implement this method.",
"lineNumber": 164,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 506,
"kind": "file",
"name": "src/Types/YXml/YXmlHook.js",
"content": "import YMap from '../YMap/YMap.js'\nimport { createAssociation } from '../../Bindings/DomBinding/util.js'\n\n/**\n * You can manage binding to a custom type with YXmlHook.\n *\n * @public\n */\nexport default class YXmlHook extends YMap {\n /**\n * @param {String} hookName nodeName of the Dom Node.\n */\n constructor (hookName) {\n super()\n this.hookName = null\n if (hookName !== undefined) {\n this.hookName = hookName\n }\n }\n\n /**\n * Creates an Item with the same effect as this Item (without position effect)\n *\n * @private\n */\n _copy () {\n const struct = super._copy()\n struct.hookName = this.hookName\n return struct\n }\n\n /**\n * Creates a Dom Element that mirrors this YXmlElement.\n *\n * @param {Document} [_document=document] The document object (you must define\n * this when calling this method in\n * nodejs)\n * @param {Object<key:hookDefinition>} [hooks] Optional property to customize how hooks\n * are presented in the DOM\n * @param {DomBinding} [binding] You should not set this property. This is\n * used if DomBinding wants to create a\n * association to the created DOM type\n * @return {Element} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}\n *\n * @public\n */\n toDom (_document = document, hooks = {}, binding) {\n const hook = hooks[this.hookName]\n let dom\n if (hook !== undefined) {\n dom = hook.createDom(this)\n } else {\n dom = document.createElement(this.hookName)\n }\n dom.setAttribute('data-yjs-hook', this.hookName)\n createAssociation(binding, dom, this)\n return dom\n }\n\n /**\n * Read the next Item in a Decoder and fill this Item with the read data.\n *\n * This is called when data is received from a remote peer.\n *\n * @param {Y} y The Yjs instance that this Item belongs to.\n * @param {BinaryDecoder} decoder The decoder object to read data from.\n *\n * @private\n */\n _fromBinary (y, decoder) {\n const missing = super._fromBinary(y, decoder)\n this.hookName = decoder.readVarString()\n return missing\n }\n\n /**\n * Transform the properties of this type to binary and write it to an\n * BinaryEncoder.\n *\n * This is called when this Item is sent to a remote peer.\n *\n * @param {BinaryEncoder} encoder The encoder to write data to.\n *\n * @private\n */\n _toBinary (encoder) {\n super._toBinary(encoder)\n encoder.writeVarString(this.hookName)\n }\n\n /**\n * Integrate this type into the Yjs instance.\n *\n * * Save this struct in the os\n * * This type is sent to other client\n * * Observer functions are fired\n *\n * @param {Y} y The Yjs instance\n *\n * @private\n */\n _integrate (y) {\n if (this.hookName === null) {\n throw new Error('hookName must be defined!')\n }\n super._integrate(y)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Types/YXml/YXmlHook.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 507,
"kind": "class",
"name": "YXmlHook",
"memberof": "src/Types/YXml/YXmlHook.js",
"static": true,
"longname": "src/Types/YXml/YXmlHook.js~YXmlHook",
"access": "public",
"export": true,
"importPath": "yjs/src/Types/YXml/YXmlHook.js",
"importStyle": "YXmlHook",
"description": "You can manage binding to a custom type with YXmlHook.",
"lineNumber": 9,
"interface": false,
"extends": [
"src/Types/YMap/YMap.js~YMap"
]
},
{
"__docId__": 508,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Types/YXml/YXmlHook.js~YXmlHook",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlHook.js~YXmlHook#constructor",
"access": "public",
"description": "",
"lineNumber": 13,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "hookName",
"description": "nodeName of the Dom Node."
}
]
},
{
"__docId__": 509,
"kind": "member",
"name": "hookName",
"memberof": "src/Types/YXml/YXmlHook.js~YXmlHook",
"static": false,
"longname": "src/Types/YXml/YXmlHook.js~YXmlHook#hookName",
"access": "public",
"description": null,
"lineNumber": 15,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 511,
"kind": "method",
"name": "_copy",
"memberof": "src/Types/YXml/YXmlHook.js~YXmlHook",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlHook.js~YXmlHook#_copy",
"access": "private",
"description": "Creates an Item with the same effect as this Item (without position effect)",
"lineNumber": 26,
"ignore": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 512,
"kind": "method",
"name": "toDom",
"memberof": "src/Types/YXml/YXmlHook.js~YXmlHook",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlHook.js~YXmlHook#toDom",
"access": "public",
"description": "Creates a Dom Element that mirrors this YXmlElement.",
"lineNumber": 47,
"params": [
{
"nullable": null,
"types": [
"Document"
],
"spread": false,
"optional": true,
"defaultValue": "document",
"defaultRaw": "document",
"name": "_document",
"description": "The document object (you must define\n this when calling this method in\n nodejs)"
},
{
"nullable": null,
"types": [
"Object<key:hookDefinition>"
],
"spread": false,
"optional": true,
"name": "hooks",
"description": "Optional property to customize how hooks\n are presented in the DOM"
},
{
"nullable": null,
"types": [
"DomBinding"
],
"spread": false,
"optional": true,
"name": "binding",
"description": "You should not set this property. This is\n used if DomBinding wants to create a\n association to the created DOM type"
}
],
"return": {
"nullable": null,
"types": [
"Element"
],
"spread": false,
"description": "The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}"
}
},
{
"__docId__": 513,
"kind": "method",
"name": "_fromBinary",
"memberof": "src/Types/YXml/YXmlHook.js~YXmlHook",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlHook.js~YXmlHook#_fromBinary",
"access": "private",
"description": "Read the next Item in a Decoder and fill this Item with the read data.\n\nThis is called when data is received from a remote peer.",
"lineNumber": 70,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance that this Item belongs to."
},
{
"nullable": null,
"types": [
"BinaryDecoder"
],
"spread": false,
"optional": false,
"name": "decoder",
"description": "The decoder object to read data from."
}
],
"ignore": true,
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 515,
"kind": "method",
"name": "_toBinary",
"memberof": "src/Types/YXml/YXmlHook.js~YXmlHook",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlHook.js~YXmlHook#_toBinary",
"access": "private",
"description": "Transform the properties of this type to binary and write it to an\nBinaryEncoder.\n\nThis is called when this Item is sent to a remote peer.",
"lineNumber": 86,
"params": [
{
"nullable": null,
"types": [
"BinaryEncoder"
],
"spread": false,
"optional": false,
"name": "encoder",
"description": "The encoder to write data to."
}
],
"ignore": true,
"return": null
},
{
"__docId__": 516,
"kind": "method",
"name": "_integrate",
"memberof": "src/Types/YXml/YXmlHook.js~YXmlHook",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlHook.js~YXmlHook#_integrate",
"access": "private",
"description": "Integrate this type into the Yjs instance.\n\n* Save this struct in the os\n* This type is sent to other client\n* Observer functions are fired",
"lineNumber": 102,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance"
}
],
"ignore": true,
"return": null
},
{
"__docId__": 517,
"kind": "file",
"name": "src/Types/YXml/YXmlText.js",
"content": "import YText from '../YText/YText.js'\nimport { createAssociation } from '../../Bindings/DomBinding/util.js'\n\n/**\n * Represents text in a Dom Element. In the future this type will also handle\n * simple formatting information like bold and italic.\n *\n * @param {String} arg1 Initial value.\n */\nexport default class YXmlText extends YText {\n /**\n * Creates a Dom Element that mirrors this YXmlText.\n *\n * @param {Document} [_document=document] The document object (you must define\n * this when calling this method in\n * nodejs)\n * @param {Object<key:hookDefinition>} [hooks] Optional property to customize how hooks\n * are presented in the DOM\n * @param {DomBinding} [binding] You should not set this property. This is\n * used if DomBinding wants to create a\n * association to the created DOM type.\n * @return {Element} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}\n *\n * @public\n */\n toDom (_document = document, hooks, binding) {\n const dom = _document.createTextNode(this.toString())\n createAssociation(binding, dom, this)\n return dom\n }\n\n /**\n * Mark this Item as deleted.\n *\n * @param {Y} y The Yjs instance\n * @param {boolean} createDelete Whether to propagate a message that this\n * Type was deleted.\n * @param {boolean} [gcChildren=y._hasUndoManager===false] Whether to garbage\n * collect the children of this type.\n *\n * @private\n */\n _delete (y, createDelete, gcChildren) {\n super._delete(y, createDelete, gcChildren)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Types/YXml/YXmlText.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 518,
"kind": "class",
"name": "YXmlText",
"memberof": "src/Types/YXml/YXmlText.js",
"static": true,
"longname": "src/Types/YXml/YXmlText.js~YXmlText",
"access": "public",
"export": true,
"importPath": "yjs/src/Types/YXml/YXmlText.js",
"importStyle": "YXmlText",
"description": "Represents text in a Dom Element. In the future this type will also handle\nsimple formatting information like bold and italic.",
"lineNumber": 10,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "arg1",
"description": "Initial value."
}
],
"interface": false,
"extends": [
"src/Types/YText/YText.js~YText"
]
},
{
"__docId__": 519,
"kind": "method",
"name": "toDom",
"memberof": "src/Types/YXml/YXmlText.js~YXmlText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlText.js~YXmlText#toDom",
"access": "public",
"description": "Creates a Dom Element that mirrors this YXmlText.",
"lineNumber": 26,
"params": [
{
"nullable": null,
"types": [
"Document"
],
"spread": false,
"optional": true,
"defaultValue": "document",
"defaultRaw": "document",
"name": "_document",
"description": "The document object (you must define\n this when calling this method in\n nodejs)"
},
{
"nullable": null,
"types": [
"Object<key:hookDefinition>"
],
"spread": false,
"optional": true,
"name": "hooks",
"description": "Optional property to customize how hooks\n are presented in the DOM"
},
{
"nullable": null,
"types": [
"DomBinding"
],
"spread": false,
"optional": true,
"name": "binding",
"description": "You should not set this property. This is\n used if DomBinding wants to create a\n association to the created DOM type."
}
],
"return": {
"nullable": null,
"types": [
"Element"
],
"spread": false,
"description": "The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}"
}
},
{
"__docId__": 520,
"kind": "method",
"name": "_delete",
"memberof": "src/Types/YXml/YXmlText.js~YXmlText",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlText.js~YXmlText#_delete",
"access": "private",
"description": "Mark this Item as deleted.",
"lineNumber": 43,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance"
},
{
"nullable": null,
"types": [
"boolean"
],
"spread": false,
"optional": false,
"name": "createDelete",
"description": "Whether to propagate a message that this\n Type was deleted."
},
{
"nullable": null,
"types": [
"boolean"
],
"spread": false,
"optional": true,
"name": "gcChildren",
"description": "Whether to garbage\n collect the children of this type."
}
],
"ignore": true,
"return": null
},
{
"__docId__": 521,
"kind": "file",
"name": "src/Types/YXml/YXmlTreeWalker.js",
"content": "import YXmlFragment from './YXmlFragment.js'\n\n/**\n * Define the elements to which a set of CSS queries apply.\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}\n *\n * @example\n * query = '.classSelector'\n * query = 'nodeSelector'\n * query = '#idSelector'\n *\n * @typedef {string} CSS_Selector\n */\n\n/**\n * Represents a subset of the nodes of a YXmlElement / YXmlFragment and a\n * position within them.\n *\n * Can be created with {@link YXmlFragment#createTreeWalker}\n *\n * @public\n */\nexport default class YXmlTreeWalker {\n constructor (root, f) {\n this._filter = f || (() => true)\n this._root = root\n this._currentNode = root\n this._firstCall = true\n }\n [Symbol.iterator] () {\n return this\n }\n /**\n * Get the next node.\n *\n * @return {YXmlElement} The next node.\n *\n * @public\n */\n next () {\n let n = this._currentNode\n if (this._firstCall) {\n this._firstCall = false\n if (!n._deleted && this._filter(n)) {\n return { value: n, done: false }\n }\n }\n do {\n if (!n._deleted && (n.constructor === YXmlFragment._YXmlElement || n.constructor === YXmlFragment) && n._start !== null) {\n // walk down in the tree\n n = n._start\n } else {\n // walk right or up in the tree\n while (n !== this._root) {\n if (n._right !== null) {\n n = n._right\n break\n }\n n = n._parent\n }\n if (n === this._root) {\n n = null\n }\n }\n if (n === this._root) {\n break\n }\n } while (n !== null && (n._deleted || !this._filter(n)))\n this._currentNode = n\n if (n === null) {\n return { done: true }\n } else {\n return { value: n, done: false }\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Types/YXml/YXmlTreeWalker.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 522,
"kind": "typedef",
"name": "CSS_Selector",
"memberof": "src/Types/YXml/YXmlTreeWalker.js",
"static": true,
"longname": "src/Types/YXml/YXmlTreeWalker.js~CSS_Selector",
"access": "public",
"description": "Define the elements to which a set of CSS queries apply.\n{@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}",
"examples": [
" query = '.classSelector'\n query = 'nodeSelector'\n query = '#idSelector'"
],
"type": {
"types": [
"string"
],
"optional": false,
"name": "CSS_Selector"
}
},
{
"__docId__": 523,
"kind": "class",
"name": "YXmlTreeWalker",
"memberof": "src/Types/YXml/YXmlTreeWalker.js",
"static": true,
"longname": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker",
"access": "public",
"export": true,
"importPath": "yjs/src/Types/YXml/YXmlTreeWalker.js",
"importStyle": "YXmlTreeWalker",
"description": "Represents a subset of the nodes of a YXmlElement / YXmlFragment and a\nposition within them.\n\nCan be created with {@link YXmlFragment#createTreeWalker}",
"lineNumber": 23,
"interface": false
},
{
"__docId__": 524,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker#constructor",
"access": "public",
"description": null,
"lineNumber": 24,
"undocument": true
},
{
"__docId__": 525,
"kind": "member",
"name": "_filter",
"memberof": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker",
"static": false,
"longname": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker#_filter",
"access": "private",
"description": null,
"lineNumber": 25,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 526,
"kind": "member",
"name": "_root",
"memberof": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker",
"static": false,
"longname": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker#_root",
"access": "private",
"description": null,
"lineNumber": 26,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 527,
"kind": "member",
"name": "_currentNode",
"memberof": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker",
"static": false,
"longname": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker#_currentNode",
"access": "private",
"description": null,
"lineNumber": 27,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 528,
"kind": "member",
"name": "_firstCall",
"memberof": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker",
"static": false,
"longname": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker#_firstCall",
"access": "private",
"description": null,
"lineNumber": 28,
"undocument": true,
"ignore": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 529,
"kind": "method",
"name": "[Symbol.iterator]",
"memberof": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker#[Symbol.iterator]",
"access": "public",
"description": null,
"lineNumber": 30,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 530,
"kind": "method",
"name": "next",
"memberof": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker",
"generator": false,
"async": false,
"static": false,
"longname": "src/Types/YXml/YXmlTreeWalker.js~YXmlTreeWalker#next",
"access": "public",
"description": "Get the next node.",
"lineNumber": 40,
"return": {
"nullable": null,
"types": [
"YXmlElement"
],
"spread": false,
"description": "The next node."
},
"params": []
},
{
"__docId__": 533,
"kind": "file",
"name": "src/Util/Binary/Decoder.js",
"content": "import ID from '../ID/ID.js'\nimport { default as RootID, RootFakeUserID } from '../ID/RootID.js'\n\n/**\n * A BinaryDecoder handles the decoding of an ArrayBuffer.\n */\nexport default class BinaryDecoder {\n /**\n * @param {Uint8Array|Buffer} buffer The binary data that this instance\n * decodes.\n */\n constructor (buffer) {\n if (buffer instanceof ArrayBuffer) {\n this.uint8arr = new Uint8Array(buffer)\n } else if (\n buffer instanceof Uint8Array ||\n (\n typeof Buffer !== 'undefined' && buffer instanceof Buffer\n )\n ) {\n this.uint8arr = buffer\n } else {\n throw new Error('Expected an ArrayBuffer or Uint8Array!')\n }\n this.pos = 0\n }\n\n /**\n * Clone this decoder instance.\n * Optionally set a new position parameter.\n */\n clone (newPos = this.pos) {\n let decoder = new BinaryDecoder(this.uint8arr)\n decoder.pos = newPos\n return decoder\n }\n\n /**\n * Number of bytes.\n */\n get length () {\n return this.uint8arr.length\n }\n\n /**\n * Skip one byte, jump to the next position.\n */\n skip8 () {\n this.pos++\n }\n\n /**\n * Read one byte as unsigned integer.\n */\n readUint8 () {\n return this.uint8arr[this.pos++]\n }\n\n /**\n * Read 4 bytes as unsigned integer.\n *\n * @return {number} An unsigned integer.\n */\n readUint32 () {\n let uint =\n this.uint8arr[this.pos] +\n (this.uint8arr[this.pos + 1] << 8) +\n (this.uint8arr[this.pos + 2] << 16) +\n (this.uint8arr[this.pos + 3] << 24)\n this.pos += 4\n return uint\n }\n\n /**\n * Look ahead without incrementing position.\n * to the next byte and read it as unsigned integer.\n *\n * @return {number} An unsigned integer.\n */\n peekUint8 () {\n return this.uint8arr[this.pos]\n }\n\n /**\n * Read unsigned integer (32bit) with variable length.\n * 1/8th of the storage is used as encoding overhead.\n * * numbers < 2^7 is stored in one byte.\n * * numbers < 2^14 is stored in two bytes.\n *\n * @return {number} An unsigned integer.\n */\n readVarUint () {\n let num = 0\n let len = 0\n while (true) {\n let r = this.uint8arr[this.pos++]\n num = num | ((r & 0b1111111) << len)\n len += 7\n if (r < 1 << 7) {\n return num >>> 0 // return unsigned number!\n }\n if (len > 35) {\n throw new Error('Integer out of range!')\n }\n }\n }\n\n /**\n * Read string of variable length\n * * varUint is used to store the length of the string\n *\n * @return {String} The read String.\n */\n readVarString () {\n let len = this.readVarUint()\n let bytes = new Array(len)\n for (let i = 0; i < len; i++) {\n bytes[i] = this.uint8arr[this.pos++]\n }\n let encodedString = bytes.map(b => String.fromCodePoint(b)).join('')\n return decodeURIComponent(escape(encodedString))\n }\n\n /**\n * Look ahead and read varString without incrementing position\n */\n peekVarString () {\n let pos = this.pos\n let s = this.readVarString()\n this.pos = pos\n return s\n }\n\n /**\n * Read ID.\n * * If first varUint read is 0xFFFFFF a RootID is returned.\n * * Otherwise an ID is returned.\n *\n * @return ID\n */\n readID () {\n let user = this.readVarUint()\n if (user === RootFakeUserID) {\n // read property name and type id\n const rid = new RootID(this.readVarString(), null)\n rid.type = this.readVarUint()\n return rid\n }\n return new ID(user, this.readVarUint())\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/Binary/Decoder.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 534,
"kind": "class",
"name": "BinaryDecoder",
"memberof": "src/Util/Binary/Decoder.js",
"static": true,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/Binary/Decoder.js",
"importStyle": "BinaryDecoder",
"description": "A BinaryDecoder handles the decoding of an ArrayBuffer.",
"lineNumber": 7,
"interface": false
},
{
"__docId__": 535,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#constructor",
"access": "public",
"description": "",
"lineNumber": 12,
"params": [
{
"nullable": null,
"types": [
"Uint8Array",
"Buffer"
],
"spread": false,
"optional": false,
"name": "buffer",
"description": "The binary data that this instance\n decodes."
}
]
},
{
"__docId__": 536,
"kind": "member",
"name": "uint8arr",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#uint8arr",
"access": "public",
"description": null,
"lineNumber": 14,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 538,
"kind": "member",
"name": "pos",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#pos",
"access": "public",
"description": null,
"lineNumber": 25,
"undocument": true,
"type": {
"types": [
"number"
]
}
},
{
"__docId__": 539,
"kind": "method",
"name": "clone",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#clone",
"access": "public",
"description": "Clone this decoder instance.\nOptionally set a new position parameter.",
"lineNumber": 32,
"params": [
{
"name": "newPos",
"optional": true,
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 540,
"kind": "get",
"name": "length",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#length",
"access": "public",
"description": "Number of bytes.",
"lineNumber": 41,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 541,
"kind": "method",
"name": "skip8",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#skip8",
"access": "public",
"description": "Skip one byte, jump to the next position.",
"lineNumber": 48,
"params": [],
"return": null
},
{
"__docId__": 542,
"kind": "method",
"name": "readUint8",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#readUint8",
"access": "public",
"description": "Read one byte as unsigned integer.",
"lineNumber": 55,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 543,
"kind": "method",
"name": "readUint32",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#readUint32",
"access": "public",
"description": "Read 4 bytes as unsigned integer.",
"lineNumber": 64,
"return": {
"nullable": null,
"types": [
"number"
],
"spread": false,
"description": "An unsigned integer."
},
"params": []
},
{
"__docId__": 545,
"kind": "method",
"name": "peekUint8",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#peekUint8",
"access": "public",
"description": "Look ahead without incrementing position.\nto the next byte and read it as unsigned integer.",
"lineNumber": 80,
"return": {
"nullable": null,
"types": [
"number"
],
"spread": false,
"description": "An unsigned integer."
},
"params": []
},
{
"__docId__": 546,
"kind": "method",
"name": "readVarUint",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#readVarUint",
"access": "public",
"description": "Read unsigned integer (32bit) with variable length.\n1/8th of the storage is used as encoding overhead.\n * numbers < 2^7 is stored in one byte.\n * numbers < 2^14 is stored in two bytes.",
"lineNumber": 92,
"return": {
"nullable": null,
"types": [
"number"
],
"spread": false,
"description": "An unsigned integer."
},
"params": []
},
{
"__docId__": 547,
"kind": "method",
"name": "readVarString",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#readVarString",
"access": "public",
"description": "Read string of variable length\n* varUint is used to store the length of the string",
"lineNumber": 114,
"return": {
"nullable": null,
"types": [
"String"
],
"spread": false,
"description": "The read String."
},
"params": []
},
{
"__docId__": 548,
"kind": "method",
"name": "peekVarString",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#peekVarString",
"access": "public",
"description": "Look ahead and read varString without incrementing position",
"lineNumber": 127,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 550,
"kind": "method",
"name": "readID",
"memberof": "src/Util/Binary/Decoder.js~BinaryDecoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Decoder.js~BinaryDecoder#readID",
"access": "public",
"description": "Read ID.\n* If first varUint read is 0xFFFFFF a RootID is returned.\n* Otherwise an ID is returned.",
"lineNumber": 141,
"return": {
"nullable": null,
"types": [
"*"
],
"spread": false,
"description": "ID"
},
"params": []
},
{
"__docId__": 551,
"kind": "file",
"name": "src/Util/Binary/Encoder.js",
"content": "import { RootFakeUserID } from '../ID/RootID.js'\n\nconst bits7 = 0b1111111\nconst bits8 = 0b11111111\n\n/**\n * A BinaryEncoder handles the encoding to an ArrayBuffer.\n */\nexport default class BinaryEncoder {\n constructor () {\n // TODO: implement chained Uint8Array buffers instead of Array buffer\n // TODO: Rewrite all methods as functions!\n this.data = []\n }\n\n /**\n * The current length of the encoded data.\n */\n get length () {\n return this.data.length\n }\n\n /**\n * The current write pointer (the same as {@link length}).\n */\n get pos () {\n return this.data.length\n }\n\n /**\n * Create an ArrayBuffer.\n *\n * @return {Uint8Array} A Uint8Array that represents the written data.\n */\n createBuffer () {\n return Uint8Array.from(this.data).buffer\n }\n\n /**\n * Write one byte as an unsigned integer.\n *\n * @param {number} num The number that is to be encoded.\n */\n writeUint8 (num) {\n this.data.push(num & bits8)\n }\n\n /**\n * Write one byte as an unsigned Integer at a specific location.\n *\n * @param {number} pos The location where the data will be written.\n * @param {number} num The number that is to be encoded.\n */\n setUint8 (pos, num) {\n this.data[pos] = num & bits8\n }\n\n /**\n * Write two bytes as an unsigned integer.\n *\n * @param {number} num The number that is to be encoded.\n */\n writeUint16 (num) {\n this.data.push(num & bits8, (num >>> 8) & bits8)\n }\n /**\n * Write two bytes as an unsigned integer at a specific location.\n *\n * @param {number} pos The location where the data will be written.\n * @param {number} num The number that is to be encoded.\n */\n setUint16 (pos, num) {\n this.data[pos] = num & bits8\n this.data[pos + 1] = (num >>> 8) & bits8\n }\n\n /**\n * Write two bytes as an unsigned integer\n *\n * @param {number} num The number that is to be encoded.\n */\n writeUint32 (num) {\n for (let i = 0; i < 4; i++) {\n this.data.push(num & bits8)\n num >>>= 8\n }\n }\n\n /**\n * Write two bytes as an unsigned integer at a specific location.\n *\n * @param {number} pos The location where the data will be written.\n * @param {number} num The number that is to be encoded.\n */\n setUint32 (pos, num) {\n for (let i = 0; i < 4; i++) {\n this.data[pos + i] = num & bits8\n num >>>= 8\n }\n }\n\n /**\n * Write a variable length unsigned integer.\n *\n * @param {number} num The number that is to be encoded.\n */\n writeVarUint (num) {\n while (num >= 0b10000000) {\n this.data.push(0b10000000 | (bits7 & num))\n num >>>= 7\n }\n this.data.push(bits7 & num)\n }\n\n /**\n * Write a variable length string.\n *\n * @param {String} str The string that is to be encoded.\n */\n writeVarString (str) {\n let encodedString = unescape(encodeURIComponent(str))\n let bytes = encodedString.split('').map(c => c.codePointAt())\n let len = bytes.length\n this.writeVarUint(len)\n for (let i = 0; i < len; i++) {\n this.data.push(bytes[i])\n }\n }\n\n /**\n * Write an ID at the current position.\n *\n * @param {ID} id The ID that is to be written.\n */\n writeID (id) {\n const user = id.user\n this.writeVarUint(user)\n if (user !== RootFakeUserID) {\n this.writeVarUint(id.clock)\n } else {\n this.writeVarString(id.name)\n this.writeVarUint(id.type)\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/Binary/Encoder.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 552,
"kind": "variable",
"name": "bits7",
"memberof": "src/Util/Binary/Encoder.js",
"static": true,
"longname": "src/Util/Binary/Encoder.js~bits7",
"access": "public",
"export": false,
"importPath": "yjs/src/Util/Binary/Encoder.js",
"importStyle": null,
"description": null,
"lineNumber": 3,
"undocument": true,
"type": {
"types": [
"number"
]
},
"ignore": true
},
{
"__docId__": 553,
"kind": "variable",
"name": "bits8",
"memberof": "src/Util/Binary/Encoder.js",
"static": true,
"longname": "src/Util/Binary/Encoder.js~bits8",
"access": "public",
"export": false,
"importPath": "yjs/src/Util/Binary/Encoder.js",
"importStyle": null,
"description": null,
"lineNumber": 4,
"undocument": true,
"type": {
"types": [
"number"
]
},
"ignore": true
},
{
"__docId__": 554,
"kind": "class",
"name": "BinaryEncoder",
"memberof": "src/Util/Binary/Encoder.js",
"static": true,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/Binary/Encoder.js",
"importStyle": "BinaryEncoder",
"description": "A BinaryEncoder handles the encoding to an ArrayBuffer.",
"lineNumber": 9,
"interface": false
},
{
"__docId__": 555,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#constructor",
"access": "public",
"description": null,
"lineNumber": 10,
"undocument": true
},
{
"__docId__": 556,
"kind": "member",
"name": "data",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#data",
"access": "public",
"description": null,
"lineNumber": 13,
"undocument": true,
"type": {
"types": [
"*[]"
]
}
},
{
"__docId__": 557,
"kind": "get",
"name": "length",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#length",
"access": "public",
"description": "The current length of the encoded data.",
"lineNumber": 19,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 558,
"kind": "get",
"name": "pos",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#pos",
"access": "public",
"description": "The current write pointer (the same as {@link length}).",
"lineNumber": 26,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 559,
"kind": "method",
"name": "createBuffer",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#createBuffer",
"access": "public",
"description": "Create an ArrayBuffer.",
"lineNumber": 35,
"return": {
"nullable": null,
"types": [
"Uint8Array"
],
"spread": false,
"description": "A Uint8Array that represents the written data."
},
"params": []
},
{
"__docId__": 560,
"kind": "method",
"name": "writeUint8",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#writeUint8",
"access": "public",
"description": "Write one byte as an unsigned integer.",
"lineNumber": 44,
"params": [
{
"nullable": null,
"types": [
"number"
],
"spread": false,
"optional": false,
"name": "num",
"description": "The number that is to be encoded."
}
],
"return": null
},
{
"__docId__": 561,
"kind": "method",
"name": "setUint8",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#setUint8",
"access": "public",
"description": "Write one byte as an unsigned Integer at a specific location.",
"lineNumber": 54,
"params": [
{
"nullable": null,
"types": [
"number"
],
"spread": false,
"optional": false,
"name": "pos",
"description": "The location where the data will be written."
},
{
"nullable": null,
"types": [
"number"
],
"spread": false,
"optional": false,
"name": "num",
"description": "The number that is to be encoded."
}
],
"return": null
},
{
"__docId__": 562,
"kind": "method",
"name": "writeUint16",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#writeUint16",
"access": "public",
"description": "Write two bytes as an unsigned integer.",
"lineNumber": 63,
"params": [
{
"nullable": null,
"types": [
"number"
],
"spread": false,
"optional": false,
"name": "num",
"description": "The number that is to be encoded."
}
],
"return": null
},
{
"__docId__": 563,
"kind": "method",
"name": "setUint16",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#setUint16",
"access": "public",
"description": "Write two bytes as an unsigned integer at a specific location.",
"lineNumber": 72,
"params": [
{
"nullable": null,
"types": [
"number"
],
"spread": false,
"optional": false,
"name": "pos",
"description": "The location where the data will be written."
},
{
"nullable": null,
"types": [
"number"
],
"spread": false,
"optional": false,
"name": "num",
"description": "The number that is to be encoded."
}
],
"return": null
},
{
"__docId__": 564,
"kind": "method",
"name": "writeUint32",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#writeUint32",
"access": "public",
"description": "Write two bytes as an unsigned integer",
"lineNumber": 82,
"params": [
{
"nullable": null,
"types": [
"number"
],
"spread": false,
"optional": false,
"name": "num",
"description": "The number that is to be encoded."
}
],
"return": null
},
{
"__docId__": 565,
"kind": "method",
"name": "setUint32",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#setUint32",
"access": "public",
"description": "Write two bytes as an unsigned integer at a specific location.",
"lineNumber": 95,
"params": [
{
"nullable": null,
"types": [
"number"
],
"spread": false,
"optional": false,
"name": "pos",
"description": "The location where the data will be written."
},
{
"nullable": null,
"types": [
"number"
],
"spread": false,
"optional": false,
"name": "num",
"description": "The number that is to be encoded."
}
],
"return": null
},
{
"__docId__": 566,
"kind": "method",
"name": "writeVarUint",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#writeVarUint",
"access": "public",
"description": "Write a variable length unsigned integer.",
"lineNumber": 107,
"params": [
{
"nullable": null,
"types": [
"number"
],
"spread": false,
"optional": false,
"name": "num",
"description": "The number that is to be encoded."
}
],
"return": null
},
{
"__docId__": 567,
"kind": "method",
"name": "writeVarString",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#writeVarString",
"access": "public",
"description": "Write a variable length string.",
"lineNumber": 120,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "str",
"description": "The string that is to be encoded."
}
],
"return": null
},
{
"__docId__": 568,
"kind": "method",
"name": "writeID",
"memberof": "src/Util/Binary/Encoder.js~BinaryEncoder",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Binary/Encoder.js~BinaryEncoder#writeID",
"access": "public",
"description": "Write an ID at the current position.",
"lineNumber": 135,
"params": [
{
"nullable": null,
"types": [
"ID"
],
"spread": false,
"optional": false,
"name": "id",
"description": "The ID that is to be written."
}
],
"return": null
},
{
"__docId__": 569,
"kind": "file",
"name": "src/Util/EventHandler.js",
"content": "\n/**\n * General event handler implementation.\n */\nexport default class EventHandler {\n constructor () {\n this.eventListeners = []\n }\n\n /**\n * To prevent memory leaks, call this method when the eventListeners won't be\n * used anymore.\n */\n destroy () {\n this.eventListeners = null\n }\n\n /**\n * Adds an event listener that is called when\n * {@link EventHandler#callEventListeners} is called.\n *\n * @param {Function} f The event handler.\n */\n addEventListener (f) {\n this.eventListeners.push(f)\n }\n\n /**\n * Removes an event listener.\n *\n * @param {Function} f The event handler that was added with\n * {@link EventHandler#addEventListener}\n */\n removeEventListener (f) {\n this.eventListeners = this.eventListeners.filter(function (g) {\n return f !== g\n })\n }\n\n /**\n * Removes all event listeners.\n */\n removeAllEventListeners () {\n this.eventListeners = []\n }\n\n /**\n * Call all event listeners that were added via\n * {@link EventHandler#addEventListener}.\n *\n * @param {Transaction} transaction The transaction object // TODO: do we need this?\n * @param {YEvent} event An event object that describes the change on a type.\n */\n callEventListeners (transaction, event) {\n for (var i = 0; i < this.eventListeners.length; i++) {\n try {\n const f = this.eventListeners[i]\n f(event)\n } catch (e) {\n /*\n Your observer threw an error. This error was caught so that Yjs\n can ensure data consistency! In order to debug this error you\n have to check \"Pause On Caught Exceptions\" in developer tools.\n */\n console.error(e)\n }\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/EventHandler.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 570,
"kind": "class",
"name": "EventHandler",
"memberof": "src/Util/EventHandler.js",
"static": true,
"longname": "src/Util/EventHandler.js~EventHandler",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/EventHandler.js",
"importStyle": "EventHandler",
"description": "General event handler implementation.",
"lineNumber": 5,
"interface": false
},
{
"__docId__": 571,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Util/EventHandler.js~EventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/EventHandler.js~EventHandler#constructor",
"access": "public",
"description": null,
"lineNumber": 6,
"undocument": true
},
{
"__docId__": 572,
"kind": "member",
"name": "eventListeners",
"memberof": "src/Util/EventHandler.js~EventHandler",
"static": false,
"longname": "src/Util/EventHandler.js~EventHandler#eventListeners",
"access": "public",
"description": null,
"lineNumber": 7,
"undocument": true,
"type": {
"types": [
"*[]"
]
}
},
{
"__docId__": 573,
"kind": "method",
"name": "destroy",
"memberof": "src/Util/EventHandler.js~EventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/EventHandler.js~EventHandler#destroy",
"access": "public",
"description": "To prevent memory leaks, call this method when the eventListeners won't be\nused anymore.",
"lineNumber": 14,
"params": [],
"return": null
},
{
"__docId__": 575,
"kind": "method",
"name": "addEventListener",
"memberof": "src/Util/EventHandler.js~EventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/EventHandler.js~EventHandler#addEventListener",
"access": "public",
"description": "Adds an event listener that is called when\n{@link EventHandler#callEventListeners} is called.",
"lineNumber": 24,
"params": [
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "f",
"description": "The event handler."
}
],
"return": null
},
{
"__docId__": 576,
"kind": "method",
"name": "removeEventListener",
"memberof": "src/Util/EventHandler.js~EventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/EventHandler.js~EventHandler#removeEventListener",
"access": "public",
"description": "Removes an event listener.",
"lineNumber": 34,
"params": [
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "f",
"description": "The event handler that was added with\n {@link EventHandler#addEventListener}"
}
],
"return": null
},
{
"__docId__": 578,
"kind": "method",
"name": "removeAllEventListeners",
"memberof": "src/Util/EventHandler.js~EventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/EventHandler.js~EventHandler#removeAllEventListeners",
"access": "public",
"description": "Removes all event listeners.",
"lineNumber": 43,
"params": [],
"return": null
},
{
"__docId__": 580,
"kind": "method",
"name": "callEventListeners",
"memberof": "src/Util/EventHandler.js~EventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/EventHandler.js~EventHandler#callEventListeners",
"access": "public",
"description": "Call all event listeners that were added via\n{@link EventHandler#addEventListener}.",
"lineNumber": 54,
"params": [
{
"nullable": null,
"types": [
"Transaction"
],
"spread": false,
"optional": false,
"name": "transaction",
"description": "The transaction object // TODO: do we need this?"
},
{
"nullable": null,
"types": [
"YEvent"
],
"spread": false,
"optional": false,
"name": "event",
"description": "An event object that describes the change on a type."
}
],
"return": null
},
{
"__docId__": 581,
"kind": "file",
"name": "src/Util/ID/ID.js",
"content": "\nexport default class ID {\n constructor (user, clock) {\n this.user = user // TODO: rename to client\n this.clock = clock\n }\n clone () {\n return new ID(this.user, this.clock)\n }\n equals (id) {\n return id !== null && id.user === this.user && id.clock === this.clock\n }\n lessThan (id) {\n if (id.constructor === ID) {\n return this.user < id.user || (this.user === id.user && this.clock < id.clock)\n } else {\n return false\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/ID/ID.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 582,
"kind": "class",
"name": "ID",
"memberof": "src/Util/ID/ID.js",
"static": true,
"longname": "src/Util/ID/ID.js~ID",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/ID/ID.js",
"importStyle": "ID",
"description": null,
"lineNumber": 2,
"undocument": true,
"interface": false
},
{
"__docId__": 583,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Util/ID/ID.js~ID",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/ID/ID.js~ID#constructor",
"access": "public",
"description": null,
"lineNumber": 3,
"undocument": true
},
{
"__docId__": 584,
"kind": "member",
"name": "user",
"memberof": "src/Util/ID/ID.js~ID",
"static": false,
"longname": "src/Util/ID/ID.js~ID#user",
"access": "public",
"description": null,
"lineNumber": 4,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 585,
"kind": "member",
"name": "clock",
"memberof": "src/Util/ID/ID.js~ID",
"static": false,
"longname": "src/Util/ID/ID.js~ID#clock",
"access": "public",
"description": null,
"lineNumber": 5,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 586,
"kind": "method",
"name": "clone",
"memberof": "src/Util/ID/ID.js~ID",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/ID/ID.js~ID#clone",
"access": "public",
"description": null,
"lineNumber": 7,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 587,
"kind": "method",
"name": "equals",
"memberof": "src/Util/ID/ID.js~ID",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/ID/ID.js~ID#equals",
"access": "public",
"description": null,
"lineNumber": 10,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 588,
"kind": "method",
"name": "lessThan",
"memberof": "src/Util/ID/ID.js~ID",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/ID/ID.js~ID#lessThan",
"access": "public",
"description": null,
"lineNumber": 13,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"boolean"
]
}
},
{
"__docId__": 589,
"kind": "file",
"name": "src/Util/ID/RootID.js",
"content": "import { getStructReference } from '../structReferences.js'\n\nexport const RootFakeUserID = 0xFFFFFF\n\nexport default class RootID {\n constructor (name, typeConstructor) {\n this.user = RootFakeUserID\n this.name = name\n this.type = getStructReference(typeConstructor)\n }\n equals (id) {\n return id !== null && id.user === this.user && id.name === this.name && id.type === this.type\n }\n lessThan (id) {\n if (id.constructor === RootID) {\n return this.user < id.user || (this.user === id.user && (this.name < id.name || (this.name === id.name && this.type < id.type)))\n } else {\n return true\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/ID/RootID.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 590,
"kind": "variable",
"name": "RootFakeUserID",
"memberof": "src/Util/ID/RootID.js",
"static": true,
"longname": "src/Util/ID/RootID.js~RootFakeUserID",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/ID/RootID.js",
"importStyle": "{RootFakeUserID}",
"description": null,
"lineNumber": 3,
"undocument": true,
"type": {
"types": [
"number"
]
}
},
{
"__docId__": 591,
"kind": "class",
"name": "RootID",
"memberof": "src/Util/ID/RootID.js",
"static": true,
"longname": "src/Util/ID/RootID.js~RootID",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/ID/RootID.js",
"importStyle": "RootID",
"description": null,
"lineNumber": 5,
"undocument": true,
"interface": false
},
{
"__docId__": 592,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Util/ID/RootID.js~RootID",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/ID/RootID.js~RootID#constructor",
"access": "public",
"description": null,
"lineNumber": 6,
"undocument": true
},
{
"__docId__": 593,
"kind": "member",
"name": "user",
"memberof": "src/Util/ID/RootID.js~RootID",
"static": false,
"longname": "src/Util/ID/RootID.js~RootID#user",
"access": "public",
"description": null,
"lineNumber": 7,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 594,
"kind": "member",
"name": "name",
"memberof": "src/Util/ID/RootID.js~RootID",
"static": false,
"longname": "src/Util/ID/RootID.js~RootID#name",
"access": "public",
"description": null,
"lineNumber": 8,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 595,
"kind": "member",
"name": "type",
"memberof": "src/Util/ID/RootID.js~RootID",
"static": false,
"longname": "src/Util/ID/RootID.js~RootID#type",
"access": "public",
"description": null,
"lineNumber": 9,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 596,
"kind": "method",
"name": "equals",
"memberof": "src/Util/ID/RootID.js~RootID",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/ID/RootID.js~RootID#equals",
"access": "public",
"description": null,
"lineNumber": 11,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 597,
"kind": "method",
"name": "lessThan",
"memberof": "src/Util/ID/RootID.js~RootID",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/ID/RootID.js~RootID#lessThan",
"access": "public",
"description": null,
"lineNumber": 14,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"boolean"
]
}
},
{
"__docId__": 598,
"kind": "file",
"name": "src/Util/NamedEventHandler.js",
"content": "\n/**\n * Handles named events.\n */\nexport default class NamedEventHandler {\n constructor () {\n this._eventListener = new Map()\n this._stateListener = new Map()\n }\n\n /**\n * @private\n * Returns all listeners that listen to a specified name.\n *\n * @param {String} name The query event name.\n */\n _getListener (name) {\n let listeners = this._eventListener.get(name)\n if (listeners === undefined) {\n listeners = {\n once: new Set(),\n on: new Set()\n }\n this._eventListener.set(name, listeners)\n }\n return listeners\n }\n\n /**\n * Adds a named event listener. The listener is removed after it has been\n * called once.\n *\n * @param {String} name The event name to listen to.\n * @param {Function} f The function that is executed when the event is fired.\n */\n once (name, f) {\n let listeners = this._getListener(name)\n listeners.once.add(f)\n }\n\n /**\n * Adds a named event listener.\n *\n * @param {String} name The event name to listen to.\n * @param {Function} f The function that is executed when the event is fired.\n */\n on (name, f) {\n let listeners = this._getListener(name)\n listeners.on.add(f)\n }\n\n /**\n * @private\n * Init the saved state for an event name.\n */\n _initStateListener (name) {\n let state = this._stateListener.get(name)\n if (state === undefined) {\n state = {}\n state.promise = new Promise(function (resolve) {\n state.resolve = resolve\n })\n this._stateListener.set(name, state)\n }\n return state\n }\n\n /**\n * Returns a Promise that is resolved when the event name is called.\n * The Promise is immediately resolved when the event name was called in the\n * past.\n */\n when (name) {\n return this._initStateListener(name).promise\n }\n\n /**\n * Remove an event listener that was registered with either\n * {@link EventHandler#on} or {@link EventHandler#once}.\n */\n off (name, f) {\n if (name == null || f == null) {\n throw new Error('You must specify event name and function!')\n }\n const listener = this._eventListener.get(name)\n if (listener !== undefined) {\n listener.on.delete(f)\n listener.once.delete(f)\n }\n }\n\n /**\n * Emit a named event. All registered event listeners that listen to the\n * specified name will receive the event.\n *\n * @param {String} name The event name.\n * @param {Array} args The arguments that are applied to the event listener.\n */\n emit (name, ...args) {\n this._initStateListener(name).resolve()\n const listener = this._eventListener.get(name)\n if (listener !== undefined) {\n listener.on.forEach(f => f.apply(null, args))\n listener.once.forEach(f => f.apply(null, args))\n listener.once = new Set()\n } else if (name === 'error') {\n console.error(args[0])\n }\n }\n destroy () {\n this._eventListener = null\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/NamedEventHandler.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 599,
"kind": "class",
"name": "NamedEventHandler",
"memberof": "src/Util/NamedEventHandler.js",
"static": true,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/NamedEventHandler.js",
"importStyle": "NamedEventHandler",
"description": "Handles named events.",
"lineNumber": 5,
"interface": false
},
{
"__docId__": 600,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Util/NamedEventHandler.js~NamedEventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler#constructor",
"access": "public",
"description": null,
"lineNumber": 6,
"undocument": true
},
{
"__docId__": 601,
"kind": "member",
"name": "_eventListener",
"memberof": "src/Util/NamedEventHandler.js~NamedEventHandler",
"static": false,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler#_eventListener",
"access": "private",
"description": null,
"lineNumber": 7,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 602,
"kind": "member",
"name": "_stateListener",
"memberof": "src/Util/NamedEventHandler.js~NamedEventHandler",
"static": false,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler#_stateListener",
"access": "private",
"description": null,
"lineNumber": 8,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 603,
"kind": "method",
"name": "_getListener",
"memberof": "src/Util/NamedEventHandler.js~NamedEventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler#_getListener",
"access": "private",
"description": "",
"lineNumber": 17,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "name",
"description": "The query event name."
}
],
"ignore": true,
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 604,
"kind": "method",
"name": "once",
"memberof": "src/Util/NamedEventHandler.js~NamedEventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler#once",
"access": "public",
"description": "Adds a named event listener. The listener is removed after it has been\ncalled once.",
"lineNumber": 36,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "name",
"description": "The event name to listen to."
},
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "f",
"description": "The function that is executed when the event is fired."
}
],
"return": null
},
{
"__docId__": 605,
"kind": "method",
"name": "on",
"memberof": "src/Util/NamedEventHandler.js~NamedEventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler#on",
"access": "public",
"description": "Adds a named event listener.",
"lineNumber": 47,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "name",
"description": "The event name to listen to."
},
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "f",
"description": "The function that is executed when the event is fired."
}
],
"return": null
},
{
"__docId__": 606,
"kind": "method",
"name": "_initStateListener",
"memberof": "src/Util/NamedEventHandler.js~NamedEventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler#_initStateListener",
"access": "private",
"description": "",
"lineNumber": 56,
"ignore": true,
"params": [
{
"name": "name",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 607,
"kind": "method",
"name": "when",
"memberof": "src/Util/NamedEventHandler.js~NamedEventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler#when",
"access": "public",
"description": "Returns a Promise that is resolved when the event name is called.\nThe Promise is immediately resolved when the event name was called in the\npast.",
"lineNumber": 73,
"params": [
{
"name": "name",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 608,
"kind": "method",
"name": "off",
"memberof": "src/Util/NamedEventHandler.js~NamedEventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler#off",
"access": "public",
"description": "Remove an event listener that was registered with either\n{@link EventHandler#on} or {@link EventHandler#once}.",
"lineNumber": 81,
"params": [
{
"name": "name",
"types": [
"*"
]
},
{
"name": "f",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 609,
"kind": "method",
"name": "emit",
"memberof": "src/Util/NamedEventHandler.js~NamedEventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler#emit",
"access": "public",
"description": "Emit a named event. All registered event listeners that listen to the\nspecified name will receive the event.",
"lineNumber": 99,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "name",
"description": "The event name."
},
{
"nullable": null,
"types": [
"Array"
],
"spread": false,
"optional": false,
"name": "args",
"description": "The arguments that are applied to the event listener."
}
],
"return": null
},
{
"__docId__": 610,
"kind": "method",
"name": "destroy",
"memberof": "src/Util/NamedEventHandler.js~NamedEventHandler",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/NamedEventHandler.js~NamedEventHandler#destroy",
"access": "public",
"description": null,
"lineNumber": 110,
"undocument": true,
"params": [],
"return": null
},
{
"__docId__": 612,
"kind": "file",
"name": "src/Util/Tree.js",
"content": "\nfunction rotate (tree, parent, newParent, n) {\n if (parent === null) {\n tree.root = newParent\n newParent._parent = null\n } else if (parent.left === n) {\n parent.left = newParent\n } else if (parent.right === n) {\n parent.right = newParent\n } else {\n throw new Error('The elements are wrongly connected!')\n }\n}\n\nclass N {\n // A created node is always red!\n constructor (val) {\n this.val = val\n this.color = true\n this._left = null\n this._right = null\n this._parent = null\n }\n isRed () { return this.color }\n isBlack () { return !this.color }\n redden () { this.color = true; return this }\n blacken () { this.color = false; return this }\n get grandparent () {\n return this.parent.parent\n }\n get parent () {\n return this._parent\n }\n get sibling () {\n return (this === this.parent.left)\n ? this.parent.right : this.parent.left\n }\n get left () {\n return this._left\n }\n get right () {\n return this._right\n }\n set left (n) {\n if (n !== null) {\n n._parent = this\n }\n this._left = n\n }\n set right (n) {\n if (n !== null) {\n n._parent = this\n }\n this._right = n\n }\n rotateLeft (tree) {\n const parent = this.parent\n const newParent = this.right\n const newRight = this.right.left\n newParent.left = this\n this.right = newRight\n rotate(tree, parent, newParent, this)\n }\n next () {\n if (this.right !== null) {\n // search the most left node in the right tree\n var o = this.right\n while (o.left !== null) {\n o = o.left\n }\n return o\n } else {\n var p = this\n while (p.parent !== null && p !== p.parent.left) {\n p = p.parent\n }\n return p.parent\n }\n }\n prev () {\n if (this.left !== null) {\n // search the most right node in the left tree\n var o = this.left\n while (o.right !== null) {\n o = o.right\n }\n return o\n } else {\n var p = this\n while (p.parent !== null && p !== p.parent.right) {\n p = p.parent\n }\n return p.parent\n }\n }\n rotateRight (tree) {\n const parent = this.parent\n const newParent = this.left\n const newLeft = this.left.right\n newParent.right = this\n this.left = newLeft\n rotate(tree, parent, newParent, this)\n }\n getUncle () {\n // we can assume that grandparent exists when this is called!\n if (this.parent === this.parent.parent.left) {\n return this.parent.parent.right\n } else {\n return this.parent.parent.left\n }\n }\n}\n\n/*\n * This is a Red Black Tree implementation\n */\nexport default class Tree {\n constructor () {\n this.root = null\n this.length = 0\n }\n findNext (id) {\n var nextID = id.clone()\n nextID.clock += 1\n return this.findWithLowerBound(nextID)\n }\n findPrev (id) {\n let prevID = id.clone()\n prevID.clock -= 1\n return this.findWithUpperBound(prevID)\n }\n findNodeWithLowerBound (from) {\n var o = this.root\n if (o === null) {\n return null\n } else {\n while (true) {\n if (from === null || (from.lessThan(o.val._id) && o.left !== null)) {\n // o is included in the bound\n // try to find an element that is closer to the bound\n o = o.left\n } else if (from !== null && o.val._id.lessThan(from)) {\n // o is not within the bound, maybe one of the right elements is..\n if (o.right !== null) {\n o = o.right\n } else {\n // there is no right element. Search for the next bigger element,\n // this should be within the bounds\n return o.next()\n }\n } else {\n return o\n }\n }\n }\n }\n findNodeWithUpperBound (to) {\n if (to === void 0) {\n throw new Error('You must define from!')\n }\n var o = this.root\n if (o === null) {\n return null\n } else {\n while (true) {\n if ((to === null || o.val._id.lessThan(to)) && o.right !== null) {\n // o is included in the bound\n // try to find an element that is closer to the bound\n o = o.right\n } else if (to !== null && to.lessThan(o.val._id)) {\n // o is not within the bound, maybe one of the left elements is..\n if (o.left !== null) {\n o = o.left\n } else {\n // there is no left element. Search for the prev smaller element,\n // this should be within the bounds\n return o.prev()\n }\n } else {\n return o\n }\n }\n }\n }\n findSmallestNode () {\n var o = this.root\n while (o != null && o.left != null) {\n o = o.left\n }\n return o\n }\n findWithLowerBound (from) {\n var n = this.findNodeWithLowerBound(from)\n return n == null ? null : n.val\n }\n findWithUpperBound (to) {\n var n = this.findNodeWithUpperBound(to)\n return n == null ? null : n.val\n }\n iterate (from, to, f) {\n var o\n if (from === null) {\n o = this.findSmallestNode()\n } else {\n o = this.findNodeWithLowerBound(from)\n }\n while (\n o !== null &&\n (\n to === null || // eslint-disable-line no-unmodified-loop-condition\n o.val._id.lessThan(to) ||\n o.val._id.equals(to)\n )\n ) {\n f(o.val)\n o = o.next()\n }\n }\n find (id) {\n let n = this.findNode(id)\n if (n !== null) {\n return n.val\n } else {\n return null\n }\n }\n findNode (id) {\n var o = this.root\n if (o === null) {\n return null\n } else {\n while (true) {\n if (o === null) {\n return null\n }\n if (id.lessThan(o.val._id)) {\n o = o.left\n } else if (o.val._id.lessThan(id)) {\n o = o.right\n } else {\n return o\n }\n }\n }\n }\n delete (id) {\n var d = this.findNode(id)\n if (d == null) {\n // throw new Error('Element does not exist!')\n return\n }\n this.length--\n if (d.left !== null && d.right !== null) {\n // switch d with the greates element in the left subtree.\n // o should have at most one child.\n var o = d.left\n // find\n while (o.right !== null) {\n o = o.right\n }\n // switch\n d.val = o.val\n d = o\n }\n // d has at most one child\n // let n be the node that replaces d\n var isFakeChild\n var child = d.left || d.right\n if (child === null) {\n isFakeChild = true\n child = new N(null)\n child.blacken()\n d.right = child\n } else {\n isFakeChild = false\n }\n\n if (d.parent === null) {\n if (!isFakeChild) {\n this.root = child\n child.blacken()\n child._parent = null\n } else {\n this.root = null\n }\n return\n } else if (d.parent.left === d) {\n d.parent.left = child\n } else if (d.parent.right === d) {\n d.parent.right = child\n } else {\n throw new Error('Impossible!')\n }\n if (d.isBlack()) {\n if (child.isRed()) {\n child.blacken()\n } else {\n this._fixDelete(child)\n }\n }\n this.root.blacken()\n if (isFakeChild) {\n if (child.parent.left === child) {\n child.parent.left = null\n } else if (child.parent.right === child) {\n child.parent.right = null\n } else {\n throw new Error('Impossible #3')\n }\n }\n }\n _fixDelete (n) {\n function isBlack (node) {\n return node !== null ? node.isBlack() : true\n }\n function isRed (node) {\n return node !== null ? node.isRed() : false\n }\n if (n.parent === null) {\n // this can only be called after the first iteration of fixDelete.\n return\n }\n // d was already replaced by the child\n // d is not the root\n // d and child are black\n var sibling = n.sibling\n if (isRed(sibling)) {\n // make sibling the grandfather\n n.parent.redden()\n sibling.blacken()\n if (n === n.parent.left) {\n n.parent.rotateLeft(this)\n } else if (n === n.parent.right) {\n n.parent.rotateRight(this)\n } else {\n throw new Error('Impossible #2')\n }\n sibling = n.sibling\n }\n // parent, sibling, and children of n are black\n if (n.parent.isBlack() &&\n sibling.isBlack() &&\n isBlack(sibling.left) &&\n isBlack(sibling.right)\n ) {\n sibling.redden()\n this._fixDelete(n.parent)\n } else if (n.parent.isRed() &&\n sibling.isBlack() &&\n isBlack(sibling.left) &&\n isBlack(sibling.right)\n ) {\n sibling.redden()\n n.parent.blacken()\n } else {\n if (n === n.parent.left &&\n sibling.isBlack() &&\n isRed(sibling.left) &&\n isBlack(sibling.right)\n ) {\n sibling.redden()\n sibling.left.blacken()\n sibling.rotateRight(this)\n sibling = n.sibling\n } else if (n === n.parent.right &&\n sibling.isBlack() &&\n isRed(sibling.right) &&\n isBlack(sibling.left)\n ) {\n sibling.redden()\n sibling.right.blacken()\n sibling.rotateLeft(this)\n sibling = n.sibling\n }\n sibling.color = n.parent.color\n n.parent.blacken()\n if (n === n.parent.left) {\n sibling.right.blacken()\n n.parent.rotateLeft(this)\n } else {\n sibling.left.blacken()\n n.parent.rotateRight(this)\n }\n }\n }\n put (v) {\n var node = new N(v)\n if (this.root !== null) {\n var p = this.root // p abbrev. parent\n while (true) {\n if (node.val._id.lessThan(p.val._id)) {\n if (p.left === null) {\n p.left = node\n break\n } else {\n p = p.left\n }\n } else if (p.val._id.lessThan(node.val._id)) {\n if (p.right === null) {\n p.right = node\n break\n } else {\n p = p.right\n }\n } else {\n p.val = node.val\n return p\n }\n }\n this._fixInsert(node)\n } else {\n this.root = node\n }\n this.length++\n this.root.blacken()\n return node\n }\n _fixInsert (n) {\n if (n.parent === null) {\n n.blacken()\n return\n } else if (n.parent.isBlack()) {\n return\n }\n var uncle = n.getUncle()\n if (uncle !== null && uncle.isRed()) {\n // Note: parent: red, uncle: red\n n.parent.blacken()\n uncle.blacken()\n n.grandparent.redden()\n this._fixInsert(n.grandparent)\n } else {\n // Note: parent: red, uncle: black or null\n // Now we transform the tree in such a way that\n // either of these holds:\n // 1) grandparent.left.isRed\n // and grandparent.left.left.isRed\n // 2) grandparent.right.isRed\n // and grandparent.right.right.isRed\n if (n === n.parent.right && n.parent === n.grandparent.left) {\n n.parent.rotateLeft(this)\n // Since we rotated and want to use the previous\n // cases, we need to set n in such a way that\n // n.parent.isRed again\n n = n.left\n } else if (n === n.parent.left && n.parent === n.grandparent.right) {\n n.parent.rotateRight(this)\n // see above\n n = n.right\n }\n // Case 1) or 2) hold from here on.\n // Now traverse grandparent, make parent a black node\n // on the highest level which holds two red nodes.\n n.parent.blacken()\n n.grandparent.redden()\n if (n === n.parent.left) {\n // Case 1\n n.grandparent.rotateRight(this)\n } else {\n // Case 2\n n.grandparent.rotateLeft(this)\n }\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/Tree.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 613,
"kind": "function",
"name": "rotate",
"memberof": "src/Util/Tree.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/Tree.js~rotate",
"access": "public",
"export": false,
"importPath": "yjs/src/Util/Tree.js",
"importStyle": null,
"description": null,
"lineNumber": 2,
"undocument": true,
"params": [
{
"name": "tree",
"types": [
"*"
]
},
{
"name": "parent",
"types": [
"*"
]
},
{
"name": "newParent",
"types": [
"*"
]
},
{
"name": "n",
"types": [
"*"
]
}
],
"return": null,
"ignore": true
},
{
"__docId__": 614,
"kind": "class",
"name": "N",
"memberof": "src/Util/Tree.js",
"static": true,
"longname": "src/Util/Tree.js~N",
"access": "public",
"export": false,
"importPath": "yjs/src/Util/Tree.js",
"importStyle": null,
"description": null,
"lineNumber": 15,
"undocument": true,
"interface": false,
"ignore": true
},
{
"__docId__": 615,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#constructor",
"access": "public",
"description": null,
"lineNumber": 17,
"undocument": true
},
{
"__docId__": 616,
"kind": "member",
"name": "val",
"memberof": "src/Util/Tree.js~N",
"static": false,
"longname": "src/Util/Tree.js~N#val",
"access": "public",
"description": null,
"lineNumber": 18,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 617,
"kind": "member",
"name": "color",
"memberof": "src/Util/Tree.js~N",
"static": false,
"longname": "src/Util/Tree.js~N#color",
"access": "public",
"description": null,
"lineNumber": 19,
"undocument": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 618,
"kind": "member",
"name": "_left",
"memberof": "src/Util/Tree.js~N",
"static": false,
"longname": "src/Util/Tree.js~N#_left",
"access": "private",
"description": null,
"lineNumber": 20,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 619,
"kind": "member",
"name": "_right",
"memberof": "src/Util/Tree.js~N",
"static": false,
"longname": "src/Util/Tree.js~N#_right",
"access": "private",
"description": null,
"lineNumber": 21,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 620,
"kind": "member",
"name": "_parent",
"memberof": "src/Util/Tree.js~N",
"static": false,
"longname": "src/Util/Tree.js~N#_parent",
"access": "private",
"description": null,
"lineNumber": 22,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 621,
"kind": "method",
"name": "isRed",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#isRed",
"access": "public",
"description": null,
"lineNumber": 24,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 622,
"kind": "method",
"name": "isBlack",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#isBlack",
"access": "public",
"description": null,
"lineNumber": 25,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 623,
"kind": "method",
"name": "redden",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#redden",
"access": "public",
"description": null,
"lineNumber": 26,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 625,
"kind": "method",
"name": "blacken",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#blacken",
"access": "public",
"description": null,
"lineNumber": 27,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 627,
"kind": "get",
"name": "grandparent",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#grandparent",
"access": "public",
"description": null,
"lineNumber": 28,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 628,
"kind": "get",
"name": "parent",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#parent",
"access": "public",
"description": null,
"lineNumber": 31,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 629,
"kind": "get",
"name": "sibling",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#sibling",
"access": "public",
"description": null,
"lineNumber": 34,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 630,
"kind": "get",
"name": "left",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#left",
"access": "public",
"description": null,
"lineNumber": 38,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 631,
"kind": "get",
"name": "right",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#right",
"access": "public",
"description": null,
"lineNumber": 41,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 632,
"kind": "set",
"name": "left",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#left",
"access": "public",
"description": null,
"lineNumber": 44,
"undocument": true
},
{
"__docId__": 634,
"kind": "set",
"name": "right",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#right",
"access": "public",
"description": null,
"lineNumber": 50,
"undocument": true
},
{
"__docId__": 636,
"kind": "method",
"name": "rotateLeft",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#rotateLeft",
"access": "public",
"description": null,
"lineNumber": 56,
"undocument": true,
"params": [
{
"name": "tree",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 638,
"kind": "method",
"name": "next",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#next",
"access": "public",
"description": null,
"lineNumber": 64,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 639,
"kind": "method",
"name": "prev",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#prev",
"access": "public",
"description": null,
"lineNumber": 80,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 640,
"kind": "method",
"name": "rotateRight",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#rotateRight",
"access": "public",
"description": null,
"lineNumber": 96,
"undocument": true,
"params": [
{
"name": "tree",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 642,
"kind": "method",
"name": "getUncle",
"memberof": "src/Util/Tree.js~N",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~N#getUncle",
"access": "public",
"description": null,
"lineNumber": 104,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 643,
"kind": "class",
"name": "Tree",
"memberof": "src/Util/Tree.js",
"static": true,
"longname": "src/Util/Tree.js~Tree",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/Tree.js",
"importStyle": "Tree",
"description": null,
"lineNumber": 117,
"undocument": true,
"interface": false
},
{
"__docId__": 644,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#constructor",
"access": "public",
"description": null,
"lineNumber": 118,
"undocument": true
},
{
"__docId__": 645,
"kind": "member",
"name": "root",
"memberof": "src/Util/Tree.js~Tree",
"static": false,
"longname": "src/Util/Tree.js~Tree#root",
"access": "public",
"description": null,
"lineNumber": 119,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 646,
"kind": "member",
"name": "length",
"memberof": "src/Util/Tree.js~Tree",
"static": false,
"longname": "src/Util/Tree.js~Tree#length",
"access": "public",
"description": null,
"lineNumber": 120,
"undocument": true,
"type": {
"types": [
"number"
]
}
},
{
"__docId__": 647,
"kind": "method",
"name": "findNext",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#findNext",
"access": "public",
"description": null,
"lineNumber": 122,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 648,
"kind": "method",
"name": "findPrev",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#findPrev",
"access": "public",
"description": null,
"lineNumber": 127,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 649,
"kind": "method",
"name": "findNodeWithLowerBound",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#findNodeWithLowerBound",
"access": "public",
"description": null,
"lineNumber": 132,
"undocument": true,
"params": [
{
"name": "from",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 650,
"kind": "method",
"name": "findNodeWithUpperBound",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#findNodeWithUpperBound",
"access": "public",
"description": null,
"lineNumber": 157,
"undocument": true,
"params": [
{
"name": "to",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 651,
"kind": "method",
"name": "findSmallestNode",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#findSmallestNode",
"access": "public",
"description": null,
"lineNumber": 185,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 652,
"kind": "method",
"name": "findWithLowerBound",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#findWithLowerBound",
"access": "public",
"description": null,
"lineNumber": 192,
"undocument": true,
"params": [
{
"name": "from",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 653,
"kind": "method",
"name": "findWithUpperBound",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#findWithUpperBound",
"access": "public",
"description": null,
"lineNumber": 196,
"undocument": true,
"params": [
{
"name": "to",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 654,
"kind": "method",
"name": "iterate",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#iterate",
"access": "public",
"description": null,
"lineNumber": 200,
"undocument": true,
"params": [
{
"name": "from",
"types": [
"*"
]
},
{
"name": "to",
"types": [
"*"
]
},
{
"name": "f",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 655,
"kind": "method",
"name": "find",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#find",
"access": "public",
"description": null,
"lineNumber": 219,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 656,
"kind": "method",
"name": "findNode",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#findNode",
"access": "public",
"description": null,
"lineNumber": 227,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 657,
"kind": "method",
"name": "delete",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#delete",
"access": "public",
"description": null,
"lineNumber": 246,
"undocument": true,
"params": [
{
"name": "id",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 660,
"kind": "method",
"name": "_fixDelete",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#_fixDelete",
"access": "private",
"description": null,
"lineNumber": 312,
"undocument": true,
"ignore": true,
"params": [
{
"name": "n",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 661,
"kind": "method",
"name": "put",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#put",
"access": "public",
"description": null,
"lineNumber": 386,
"undocument": true,
"params": [
{
"name": "v",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 663,
"kind": "method",
"name": "_fixInsert",
"memberof": "src/Util/Tree.js~Tree",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/Tree.js~Tree#_fixInsert",
"access": "private",
"description": null,
"lineNumber": 418,
"undocument": true,
"ignore": true,
"params": [
{
"name": "n",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 664,
"kind": "file",
"name": "src/Util/UndoManager.js",
"content": "import ID from './ID/ID.js'\nimport isParentOf from './isParentOf.js'\n\nclass ReverseOperation {\n constructor (y, transaction) {\n this.created = new Date()\n const beforeState = transaction.beforeState\n if (beforeState.has(y.userID)) {\n this.toState = new ID(y.userID, y.ss.getState(y.userID) - 1)\n this.fromState = new ID(y.userID, beforeState.get(y.userID))\n } else {\n this.toState = null\n this.fromState = null\n }\n this.deletedStructs = transaction.deletedStructs\n }\n}\n\nfunction applyReverseOperation (y, scope, reverseBuffer) {\n let performedUndo = false\n y.transact(() => {\n while (!performedUndo && reverseBuffer.length > 0) {\n let undoOp = reverseBuffer.pop()\n // make sure that it is possible to iterate {from}-{to}\n if (undoOp.fromState !== null) {\n y.os.getItemCleanStart(undoOp.fromState)\n y.os.getItemCleanEnd(undoOp.toState)\n y.os.iterate(undoOp.fromState, undoOp.toState, op => {\n while (op._deleted && op._redone !== null) {\n op = op._redone\n }\n if (op._deleted === false && isParentOf(scope, op)) {\n performedUndo = true\n op._delete(y)\n }\n })\n }\n for (let op of undoOp.deletedStructs) {\n if (\n isParentOf(scope, op) &&\n op._parent !== y &&\n (\n op._id.user !== y.userID ||\n undoOp.fromState === null ||\n op._id.clock < undoOp.fromState.clock ||\n op._id.clock > undoOp.toState.clock\n )\n ) {\n performedUndo = true\n op._redo(y)\n }\n }\n }\n })\n return performedUndo\n}\n\n/**\n * Saves a history of locally applied operations. The UndoManager handles the\n * undoing and redoing of locally created changes.\n */\nexport default class UndoManager {\n /**\n * @param {YType} scope The scope on which to listen for changes.\n * @param {Object} options Optionally provided configuration.\n */\n constructor (scope, options = {}) {\n this.options = options\n options.captureTimeout = options.captureTimeout == null ? 500 : options.captureTimeout\n this._undoBuffer = []\n this._redoBuffer = []\n this._scope = scope\n this._undoing = false\n this._redoing = false\n this._lastTransactionWasUndo = false\n const y = scope._y\n this.y = y\n y._hasUndoManager = true\n y.on('afterTransaction', (y, transaction, remote) => {\n if (!remote && transaction.changedParentTypes.has(scope)) {\n let reverseOperation = new ReverseOperation(y, transaction)\n if (!this._undoing) {\n let lastUndoOp = this._undoBuffer.length > 0 ? this._undoBuffer[this._undoBuffer.length - 1] : null\n if (\n this._redoing === false &&\n this._lastTransactionWasUndo === false &&\n lastUndoOp !== null &&\n reverseOperation.created - lastUndoOp.created <= options.captureTimeout\n ) {\n lastUndoOp.created = reverseOperation.created\n if (reverseOperation.toState !== null) {\n lastUndoOp.toState = reverseOperation.toState\n if (lastUndoOp.fromState === null) {\n lastUndoOp.fromState = reverseOperation.fromState\n }\n }\n reverseOperation.deletedStructs.forEach(lastUndoOp.deletedStructs.add, lastUndoOp.deletedStructs)\n } else {\n this._lastTransactionWasUndo = false\n this._undoBuffer.push(reverseOperation)\n }\n if (!this._redoing) {\n this._redoBuffer = []\n }\n } else {\n this._lastTransactionWasUndo = true\n this._redoBuffer.push(reverseOperation)\n }\n }\n })\n }\n\n /**\n * Undo the last locally created change.\n */\n undo () {\n this._undoing = true\n const performedUndo = applyReverseOperation(this.y, this._scope, this._undoBuffer)\n this._undoing = false\n return performedUndo\n }\n\n /**\n * Redo the last locally created change.\n */\n redo () {\n this._redoing = true\n const performedRedo = applyReverseOperation(this.y, this._scope, this._redoBuffer)\n this._redoing = false\n return performedRedo\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/UndoManager.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 665,
"kind": "class",
"name": "ReverseOperation",
"memberof": "src/Util/UndoManager.js",
"static": true,
"longname": "src/Util/UndoManager.js~ReverseOperation",
"access": "public",
"export": false,
"importPath": "yjs/src/Util/UndoManager.js",
"importStyle": null,
"description": null,
"lineNumber": 4,
"undocument": true,
"interface": false,
"ignore": true
},
{
"__docId__": 666,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Util/UndoManager.js~ReverseOperation",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/UndoManager.js~ReverseOperation#constructor",
"access": "public",
"description": null,
"lineNumber": 5,
"undocument": true
},
{
"__docId__": 667,
"kind": "member",
"name": "created",
"memberof": "src/Util/UndoManager.js~ReverseOperation",
"static": false,
"longname": "src/Util/UndoManager.js~ReverseOperation#created",
"access": "public",
"description": null,
"lineNumber": 6,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 668,
"kind": "member",
"name": "toState",
"memberof": "src/Util/UndoManager.js~ReverseOperation",
"static": false,
"longname": "src/Util/UndoManager.js~ReverseOperation#toState",
"access": "public",
"description": null,
"lineNumber": 9,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 669,
"kind": "member",
"name": "fromState",
"memberof": "src/Util/UndoManager.js~ReverseOperation",
"static": false,
"longname": "src/Util/UndoManager.js~ReverseOperation#fromState",
"access": "public",
"description": null,
"lineNumber": 10,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 672,
"kind": "member",
"name": "deletedStructs",
"memberof": "src/Util/UndoManager.js~ReverseOperation",
"static": false,
"longname": "src/Util/UndoManager.js~ReverseOperation#deletedStructs",
"access": "public",
"description": null,
"lineNumber": 15,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 673,
"kind": "function",
"name": "applyReverseOperation",
"memberof": "src/Util/UndoManager.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/UndoManager.js~applyReverseOperation",
"access": "public",
"export": false,
"importPath": "yjs/src/Util/UndoManager.js",
"importStyle": null,
"description": null,
"lineNumber": 19,
"undocument": true,
"params": [
{
"name": "y",
"types": [
"*"
]
},
{
"name": "scope",
"types": [
"*"
]
},
{
"name": "reverseBuffer",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
},
"ignore": true
},
{
"__docId__": 674,
"kind": "class",
"name": "UndoManager",
"memberof": "src/Util/UndoManager.js",
"static": true,
"longname": "src/Util/UndoManager.js~UndoManager",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/UndoManager.js",
"importStyle": "UndoManager",
"description": "Saves a history of locally applied operations. The UndoManager handles the\nundoing and redoing of locally created changes.",
"lineNumber": 62,
"interface": false
},
{
"__docId__": 675,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Util/UndoManager.js~UndoManager",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/UndoManager.js~UndoManager#constructor",
"access": "public",
"description": "",
"lineNumber": 67,
"params": [
{
"nullable": null,
"types": [
"YType"
],
"spread": false,
"optional": false,
"name": "scope",
"description": "The scope on which to listen for changes."
},
{
"nullable": null,
"types": [
"Object"
],
"spread": false,
"optional": false,
"name": "options",
"description": "Optionally provided configuration."
}
]
},
{
"__docId__": 676,
"kind": "member",
"name": "options",
"memberof": "src/Util/UndoManager.js~UndoManager",
"static": false,
"longname": "src/Util/UndoManager.js~UndoManager#options",
"access": "public",
"description": null,
"lineNumber": 68,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 677,
"kind": "member",
"name": "_undoBuffer",
"memberof": "src/Util/UndoManager.js~UndoManager",
"static": false,
"longname": "src/Util/UndoManager.js~UndoManager#_undoBuffer",
"access": "private",
"description": null,
"lineNumber": 70,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*[]"
]
}
},
{
"__docId__": 678,
"kind": "member",
"name": "_redoBuffer",
"memberof": "src/Util/UndoManager.js~UndoManager",
"static": false,
"longname": "src/Util/UndoManager.js~UndoManager#_redoBuffer",
"access": "private",
"description": null,
"lineNumber": 71,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*[]"
]
}
},
{
"__docId__": 679,
"kind": "member",
"name": "_scope",
"memberof": "src/Util/UndoManager.js~UndoManager",
"static": false,
"longname": "src/Util/UndoManager.js~UndoManager#_scope",
"access": "private",
"description": null,
"lineNumber": 72,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 680,
"kind": "member",
"name": "_undoing",
"memberof": "src/Util/UndoManager.js~UndoManager",
"static": false,
"longname": "src/Util/UndoManager.js~UndoManager#_undoing",
"access": "private",
"description": null,
"lineNumber": 73,
"undocument": true,
"ignore": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 681,
"kind": "member",
"name": "_redoing",
"memberof": "src/Util/UndoManager.js~UndoManager",
"static": false,
"longname": "src/Util/UndoManager.js~UndoManager#_redoing",
"access": "private",
"description": null,
"lineNumber": 74,
"undocument": true,
"ignore": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 682,
"kind": "member",
"name": "_lastTransactionWasUndo",
"memberof": "src/Util/UndoManager.js~UndoManager",
"static": false,
"longname": "src/Util/UndoManager.js~UndoManager#_lastTransactionWasUndo",
"access": "private",
"description": null,
"lineNumber": 75,
"undocument": true,
"ignore": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 683,
"kind": "member",
"name": "y",
"memberof": "src/Util/UndoManager.js~UndoManager",
"static": false,
"longname": "src/Util/UndoManager.js~UndoManager#y",
"access": "public",
"description": null,
"lineNumber": 77,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 687,
"kind": "method",
"name": "undo",
"memberof": "src/Util/UndoManager.js~UndoManager",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/UndoManager.js~UndoManager#undo",
"access": "public",
"description": "Undo the last locally created change.",
"lineNumber": 116,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 690,
"kind": "method",
"name": "redo",
"memberof": "src/Util/UndoManager.js~UndoManager",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/UndoManager.js~UndoManager#redo",
"access": "public",
"description": "Redo the last locally created change.",
"lineNumber": 126,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 693,
"kind": "file",
"name": "src/Util/YEvent.js",
"content": "\n/**\n * YEvent describes the changes on a YType.\n */\nexport default class YEvent {\n /**\n * @param {YType} target The changed type.\n */\n constructor (target) {\n /**\n * The type on which this event was created on.\n * @type {YType}\n */\n this.target = target\n /**\n * The current target on which the observe callback is called.\n * @type {YType}\n */\n this.currentTarget = target\n }\n\n /**\n * Computes the path from `y` to the changed type.\n *\n * The following property holds:\n * @example\n * let type = y\n * event.path.forEach(function (dir) {\n * type = type.get(dir)\n * })\n * type === event.target // => true\n */\n get path () {\n return this.currentTarget.getPathTo(this.target)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/YEvent.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 694,
"kind": "class",
"name": "YEvent",
"memberof": "src/Util/YEvent.js",
"static": true,
"longname": "src/Util/YEvent.js~YEvent",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/YEvent.js",
"importStyle": "YEvent",
"description": "YEvent describes the changes on a YType.",
"lineNumber": 5,
"interface": false
},
{
"__docId__": 695,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Util/YEvent.js~YEvent",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/YEvent.js~YEvent#constructor",
"access": "public",
"description": "",
"lineNumber": 9,
"params": [
{
"nullable": null,
"types": [
"YType"
],
"spread": false,
"optional": false,
"name": "target",
"description": "The changed type."
}
]
},
{
"__docId__": 696,
"kind": "member",
"name": "target",
"memberof": "src/Util/YEvent.js~YEvent",
"static": false,
"longname": "src/Util/YEvent.js~YEvent#target",
"access": "public",
"description": "The type on which this event was created on.",
"lineNumber": 14,
"type": {
"nullable": null,
"types": [
"YType"
],
"spread": false,
"description": null
}
},
{
"__docId__": 697,
"kind": "member",
"name": "currentTarget",
"memberof": "src/Util/YEvent.js~YEvent",
"static": false,
"longname": "src/Util/YEvent.js~YEvent#currentTarget",
"access": "public",
"description": "The current target on which the observe callback is called.",
"lineNumber": 19,
"type": {
"nullable": null,
"types": [
"YType"
],
"spread": false,
"description": null
}
},
{
"__docId__": 698,
"kind": "get",
"name": "path",
"memberof": "src/Util/YEvent.js~YEvent",
"generator": false,
"async": false,
"static": false,
"longname": "src/Util/YEvent.js~YEvent#path",
"access": "public",
"description": "Computes the path from `y` to the changed type.\n\nThe following property holds:",
"examples": [
" let type = y\n event.path.forEach(function (dir) {\n type = type.get(dir)\n })\n type === event.target // => true"
],
"lineNumber": 33,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 699,
"kind": "file",
"name": "src/Util/defragmentItemContent.js",
"content": "\nimport ID from '../Util/ID/ID.js'\nimport ItemJSON from '../Struct/ItemJSON.js'\nimport ItemString from '../Struct/ItemString.js'\n\n/**\n * Try to merge all items in os with their successors.\n *\n * Some transformations (like delete) fragment items.\n * Item(c: 'ab') + Delete(1,1) + Delete(0, 1) -> Item(c: 'a',deleted);Item(c: 'b',deleted)\n *\n * This functions merges the fragmented nodes together:\n * Item(c: 'a',deleted);Item(c: 'b',deleted) -> Item(c: 'ab', deleted)\n *\n * TODO: The Tree implementation does not support deletions in-spot.\n * This is why all deletions must be performed after the traversal.\n *\n */\nexport function defragmentItemContent (y) {\n const os = y.os\n if (os.length < 2) {\n return\n }\n let deletes = []\n let node = os.findSmallestNode()\n let next = node.next()\n while (next !== null) {\n let a = node.val\n let b = next.val\n if (\n (a instanceof ItemJSON || a instanceof ItemString) &&\n a.constructor === b.constructor &&\n a._deleted === b._deleted &&\n a._right === b &&\n (new ID(a._id.user, a._id.clock + a._length)).equals(b._id)\n ) {\n a._right = b._right\n if (a instanceof ItemJSON) {\n a._content = a._content.concat(b._content)\n } else if (a instanceof ItemString) {\n a._content += b._content\n }\n // delete b later\n deletes.push(b._id)\n // do not iterate node!\n // !(node = next)\n } else {\n // not able to merge node, get next node\n node = next\n }\n // update next\n next = next.next()\n }\n for (let i = deletes.length - 1; i >= 0; i--) {\n os.delete(deletes[i])\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/defragmentItemContent.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 700,
"kind": "function",
"name": "defragmentItemContent",
"memberof": "src/Util/defragmentItemContent.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/defragmentItemContent.js~defragmentItemContent",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/defragmentItemContent.js",
"importStyle": "{defragmentItemContent}",
"description": "Try to merge all items in os with their successors.\n\nSome transformations (like delete) fragment items.\nItem(c: 'ab') + Delete(1,1) + Delete(0, 1) -> Item(c: 'a',deleted);Item(c: 'b',deleted)\n\nThis functions merges the fragmented nodes together:\nItem(c: 'a',deleted);Item(c: 'b',deleted) -> Item(c: 'ab', deleted)\n\nTODO: The Tree implementation does not support deletions in-spot.\n This is why all deletions must be performed after the traversal.",
"lineNumber": 19,
"params": [
{
"name": "y",
"types": [
"*"
]
}
],
"return": null
},
{
"__docId__": 701,
"kind": "file",
"name": "src/Util/generateRandomUint32.js",
"content": "/* global crypto */\n\nexport function generateRandomUint32 () {\n if (typeof crypto !== 'undefined' && crypto.getRandomValue != null) {\n // browser\n let arr = new Uint32Array(1)\n crypto.getRandomValues(arr)\n return arr[0]\n } else if (typeof crypto !== 'undefined' && crypto.randomBytes != null) {\n // node\n let buf = crypto.randomBytes(4)\n return new Uint32Array(buf.buffer)[0]\n } else {\n return Math.ceil(Math.random() * 0xFFFFFFFF)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/generateRandomUint32.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 702,
"kind": "function",
"name": "generateRandomUint32",
"memberof": "src/Util/generateRandomUint32.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/generateRandomUint32.js~generateRandomUint32",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/generateRandomUint32.js",
"importStyle": "{generateRandomUint32}",
"description": null,
"lineNumber": 3,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 703,
"kind": "file",
"name": "src/Util/isParentOf.js",
"content": "\n/**\n * Check if `parent` is a parent of `child`.\n *\n * @param {Type} parent\n * @param {Type} child\n * @return {Boolean} Whether `parent` is a parent of `child`.\n *\n * @public\n */\nexport default function isParentOf (parent, child) {\n child = child._parent\n while (child !== null) {\n if (child === parent) {\n return true\n }\n child = child._parent\n }\n return false\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/isParentOf.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 704,
"kind": "function",
"name": "isParentOf",
"memberof": "src/Util/isParentOf.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/isParentOf.js~isParentOf",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/isParentOf.js",
"importStyle": "isParentOf",
"description": "Check if `parent` is a parent of `child`.",
"lineNumber": 11,
"params": [
{
"nullable": null,
"types": [
"Type"
],
"spread": false,
"optional": false,
"name": "parent",
"description": ""
},
{
"nullable": null,
"types": [
"Type"
],
"spread": false,
"optional": false,
"name": "child",
"description": ""
}
],
"return": {
"nullable": null,
"types": [
"Boolean"
],
"spread": false,
"description": "Whether `parent` is a parent of `child`."
}
},
{
"__docId__": 705,
"kind": "file",
"name": "src/Util/mutualExclude.js",
"content": "\n// TODO: rename mutex\n\n/**\n * Creates a mutual exclude function with the following property:\n *\n * @example\n * const mutualExclude = createMutualExclude()\n * mutualExclude(function () {\n * // This function is immediately executed\n * mutualExclude(function () {\n * // This function is never executed, as it is called with the same\n * // mutualExclude\n * })\n * })\n *\n * @return {Function} A mutual exclude function\n * @public\n */\nexport function createMutualExclude () {\n var token = true\n return function mutualExclude (f) {\n if (token) {\n token = false\n try {\n f()\n } catch (e) {\n console.error(e)\n }\n token = true\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/mutualExclude.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 706,
"kind": "function",
"name": "createMutualExclude",
"memberof": "src/Util/mutualExclude.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/mutualExclude.js~createMutualExclude",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/mutualExclude.js",
"importStyle": "{createMutualExclude}",
"description": "Creates a mutual exclude function with the following property:",
"examples": [
"const mutualExclude = createMutualExclude()\nmutualExclude(function () {\n // This function is immediately executed\n mutualExclude(function () {\n // This function is never executed, as it is called with the same\n // mutualExclude\n })\n})"
],
"lineNumber": 20,
"return": {
"nullable": null,
"types": [
"Function"
],
"spread": false,
"description": "A mutual exclude function"
},
"params": []
},
{
"__docId__": 707,
"kind": "file",
"name": "src/Util/relativePosition.js",
"content": "import ID from './ID/ID.js'\nimport RootID from './ID/RootID.js'\nimport GC from '../Struct/GC.js'\n\n// TODO: Implement function to describe ranges\n\n/**\n * A relative position that is based on the Yjs model. In contrast to an\n * absolute position (position by index), the relative position can be\n * recomputed when remote changes are received. For example:\n *\n * ```Insert(0, 'x')('a|bc') = 'xa|bc'``` Where | is the cursor position.\n *\n * A relative cursor position can be obtained with the function\n * {@link getRelativePosition} and it can be transformed to an absolute position\n * with {@link fromRelativePosition}.\n *\n * Pro tip: Use this to implement shared cursor locations in YText or YXml!\n * The relative position is {@link encodable}, so you can send it to other\n * clients.\n *\n * @example\n * // Current cursor position is at position 10\n * let relativePosition = getRelativePosition(yText, 10)\n * // modify yText\n * yText.insert(0, 'abc')\n * yText.delete(3, 10)\n * // Compute the cursor position\n * let absolutePosition = fromRelativePosition(y, relativePosition)\n * absolutePosition.type // => yText\n * console.log('cursor location is ' + absolutePosition.offset) // => cursor location is 3\n *\n * @typedef {encodable} RelativePosition\n */\n\n/**\n * Create a relativePosition based on a absolute position.\n *\n * @param {YType} type The base type (e.g. YText or YArray).\n * @param {Integer} offset The absolute position.\n */\nexport function getRelativePosition (type, offset) {\n // TODO: rename to createRelativePosition\n let t = type._start\n while (t !== null) {\n if (t._deleted === false) {\n if (t._length > offset) {\n return [t._id.user, t._id.clock + offset]\n }\n offset -= t._length\n }\n t = t._right\n }\n return ['endof', type._id.user, type._id.clock || null, type._id.name || null, type._id.type || null]\n}\n\n/**\n * @typedef {Object} AbsolutePosition The result of {@link fromRelativePosition}\n * @property {YType} type The type on which to apply the absolute position.\n * @property {Integer} offset The absolute offset.r\n */\n\n/**\n * Transforms a relative position back to a relative position.\n *\n * @param {Y} y The Yjs instance in which to query for the absolute position.\n * @param {RelativePosition} rpos The relative position.\n * @return {AbsolutePosition} The absolute position in the Yjs model\n * (type + offset).\n */\nexport function fromRelativePosition (y, rpos) {\n if (rpos[0] === 'endof') {\n let id\n if (rpos[3] === null) {\n id = new ID(rpos[1], rpos[2])\n } else {\n id = new RootID(rpos[3], rpos[4])\n }\n const type = y.os.get(id)\n if (type === null || type.constructor === GC) {\n return null\n }\n return {\n type,\n offset: type.length\n }\n } else {\n let offset = 0\n let struct = y.os.findNodeWithUpperBound(new ID(rpos[0], rpos[1])).val\n const parent = struct._parent\n if (struct.constructor === GC || parent._deleted) {\n return null\n }\n if (!struct._deleted) {\n offset = rpos[1] - struct._id.clock\n }\n struct = struct._left\n while (struct !== null) {\n if (!struct._deleted) {\n offset += struct._length\n }\n struct = struct._left\n }\n return {\n type: parent,\n offset: offset\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/relativePosition.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 708,
"kind": "typedef",
"name": "RelativePosition",
"memberof": "src/Util/relativePosition.js",
"static": true,
"longname": "src/Util/relativePosition.js~RelativePosition",
"access": "public",
"description": "A relative position that is based on the Yjs model. In contrast to an\nabsolute position (position by index), the relative position can be\nrecomputed when remote changes are received. For example:\n\n```Insert(0, 'x')('a|bc') = 'xa|bc'``` Where | is the cursor position.\n\nA relative cursor position can be obtained with the function\n{@link getRelativePosition} and it can be transformed to an absolute position\nwith {@link fromRelativePosition}.\n\nPro tip: Use this to implement shared cursor locations in YText or YXml!\nThe relative position is {@link encodable}, so you can send it to other\nclients.",
"examples": [
"// Current cursor position is at position 10\nlet relativePosition = getRelativePosition(yText, 10)\n// modify yText\nyText.insert(0, 'abc')\nyText.delete(3, 10)\n// Compute the cursor position\nlet absolutePosition = fromRelativePosition(y, relativePosition)\nabsolutePosition.type // => yText\nconsole.log('cursor location is ' + absolutePosition.offset) // => cursor location is 3"
],
"type": {
"types": [
"encodable"
],
"optional": false,
"name": "RelativePosition"
}
},
{
"__docId__": 709,
"kind": "function",
"name": "getRelativePosition",
"memberof": "src/Util/relativePosition.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/relativePosition.js~getRelativePosition",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/relativePosition.js",
"importStyle": "{getRelativePosition}",
"description": "Create a relativePosition based on a absolute position.",
"lineNumber": 42,
"params": [
{
"nullable": null,
"types": [
"YType"
],
"spread": false,
"optional": false,
"name": "type",
"description": "The base type (e.g. YText or YArray)."
},
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "offset",
"description": "The absolute position."
}
],
"return": {
"types": [
"string[]"
]
}
},
{
"__docId__": 710,
"kind": "typedef",
"name": "AbsolutePosition",
"memberof": "src/Util/relativePosition.js",
"static": true,
"longname": "src/Util/relativePosition.js~AbsolutePosition",
"access": "public",
"description": "",
"properties": [
{
"nullable": null,
"types": [
"YType"
],
"spread": false,
"optional": false,
"name": "type",
"description": "The type on which to apply the absolute position."
},
{
"nullable": null,
"types": [
"Integer"
],
"spread": false,
"optional": false,
"name": "offset",
"description": "The absolute offset.r"
}
],
"type": {
"types": [
"Object"
],
"optional": false,
"name": "AbsolutePosition"
}
},
{
"__docId__": 711,
"kind": "function",
"name": "fromRelativePosition",
"memberof": "src/Util/relativePosition.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/relativePosition.js~fromRelativePosition",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/relativePosition.js",
"importStyle": "{fromRelativePosition}",
"description": "Transforms a relative position back to a relative position.",
"lineNumber": 71,
"params": [
{
"nullable": null,
"types": [
"Y"
],
"spread": false,
"optional": false,
"name": "y",
"description": "The Yjs instance in which to query for the absolute position."
},
{
"nullable": null,
"types": [
"RelativePosition"
],
"spread": false,
"optional": false,
"name": "rpos",
"description": "The relative position."
}
],
"return": {
"nullable": null,
"types": [
"AbsolutePosition"
],
"spread": false,
"description": "The absolute position in the Yjs model\n (type + offset)."
}
},
{
"__docId__": 712,
"kind": "file",
"name": "src/Util/simpleDiff.js",
"content": "\n/**\n * A SimpleDiff describes a change on a String.\n *\n * @example\n * console.log(a) // the old value\n * console.log(b) // the updated value\n * // Apply changes of diff (pseudocode)\n * a.remove(diff.pos, diff.remove) // Remove `diff.remove` characters\n * a.insert(diff.pos, diff.insert) // Insert `diff.insert`\n * a === b // values match\n *\n * @typedef {Object} SimpleDiff\n * @property {Number} pos The index where changes were applied\n * @property {Number} delete The number of characters to delete starting\n * at `index`.\n * @property {String} insert The new text to insert at `index` after applying\n * `delete`\n */\n\n/**\n * Create a diff between two strings. This diff implementation is highly\n * efficient, but not very sophisticated.\n *\n * @public\n * @param {String} a The old version of the string\n * @param {String} b The updated version of the string\n * @return {SimpleDiff} The diff description.\n */\nexport default function simpleDiff (a, b) {\n let left = 0 // number of same characters counting from left\n let right = 0 // number of same characters counting from right\n while (left < a.length && left < b.length && a[left] === b[left]) {\n left++\n }\n if (left !== a.length || left !== b.length) {\n // Only check right if a !== b\n while (right + left < a.length && right + left < b.length && a[a.length - right - 1] === b[b.length - right - 1]) {\n right++\n }\n }\n return {\n pos: left, // TODO: rename to index (also in type above)\n remove: a.length - left - right,\n insert: b.slice(left, b.length - right)\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/simpleDiff.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 713,
"kind": "typedef",
"name": "SimpleDiff",
"memberof": "src/Util/simpleDiff.js",
"static": true,
"longname": "src/Util/simpleDiff.js~SimpleDiff",
"access": "public",
"description": "A SimpleDiff describes a change on a String.",
"examples": [
"console.log(a) // the old value\nconsole.log(b) // the updated value\n// Apply changes of diff (pseudocode)\na.remove(diff.pos, diff.remove) // Remove `diff.remove` characters\na.insert(diff.pos, diff.insert) // Insert `diff.insert`\na === b // values match"
],
"properties": [
{
"nullable": null,
"types": [
"Number"
],
"spread": false,
"optional": false,
"name": "pos",
"description": "The index where changes were applied"
},
{
"nullable": null,
"types": [
"Number"
],
"spread": false,
"optional": false,
"name": "delete",
"description": "The number of characters to delete starting\n at `index`."
},
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "insert",
"description": "The new text to insert at `index` after applying\n `delete`"
}
],
"type": {
"types": [
"Object"
],
"optional": false,
"name": "SimpleDiff"
}
},
{
"__docId__": 714,
"kind": "function",
"name": "simpleDiff",
"memberof": "src/Util/simpleDiff.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/simpleDiff.js~simpleDiff",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/simpleDiff.js",
"importStyle": "simpleDiff",
"description": "Create a diff between two strings. This diff implementation is highly\nefficient, but not very sophisticated.",
"lineNumber": 30,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "a",
"description": "The old version of the string"
},
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "b",
"description": "The updated version of the string"
}
],
"return": {
"nullable": null,
"types": [
"SimpleDiff"
],
"spread": false,
"description": "The diff description."
}
},
{
"__docId__": 715,
"kind": "file",
"name": "src/Util/structReferences.js",
"content": "import YArray from '../Types/YArray/YArray.js'\nimport YMap from '../Types/YMap/YMap.js'\nimport YText from '../Types/YText/YText.js'\nimport { YXmlFragment, YXmlElement, YXmlText, YXmlHook } from '../Types/YXml/YXml.js'\n\nimport Delete from '../Struct/Delete.js'\nimport ItemJSON from '../Struct/ItemJSON.js'\nimport ItemString from '../Struct/ItemString.js'\nimport ItemFormat from '../Struct/ItemFormat.js'\nimport ItemEmbed from '../Struct/ItemEmbed.js'\nimport GC from '../Struct/GC.js'\n\nconst structs = new Map()\nconst references = new Map()\n\n/**\n * Register a new Yjs types. The same type must be defined with the same\n * reference on all clients!\n *\n * @param {Number} reference\n * @param {class} structConstructor\n *\n * @public\n */\nexport function registerStruct (reference, structConstructor) {\n structs.set(reference, structConstructor)\n references.set(structConstructor, reference)\n}\n\n/**\n * @private\n */\nexport function getStruct (reference) {\n return structs.get(reference)\n}\n\n/**\n * @private\n */\nexport function getStructReference (typeConstructor) {\n return references.get(typeConstructor)\n}\n\n// TODO: reorder (Item* should have low numbers)\nregisterStruct(0, ItemJSON)\nregisterStruct(1, ItemString)\nregisterStruct(10, ItemFormat)\nregisterStruct(11, ItemEmbed)\nregisterStruct(2, Delete)\n\nregisterStruct(3, YArray)\nregisterStruct(4, YMap)\nregisterStruct(5, YText)\nregisterStruct(6, YXmlFragment)\nregisterStruct(7, YXmlElement)\nregisterStruct(8, YXmlText)\nregisterStruct(9, YXmlHook)\n\nregisterStruct(12, GC)\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Util/structReferences.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 716,
"kind": "variable",
"name": "structs",
"memberof": "src/Util/structReferences.js",
"static": true,
"longname": "src/Util/structReferences.js~structs",
"access": "public",
"export": false,
"importPath": "yjs/src/Util/structReferences.js",
"importStyle": null,
"description": null,
"lineNumber": 13,
"undocument": true,
"type": {
"types": [
"*"
]
},
"ignore": true
},
{
"__docId__": 717,
"kind": "variable",
"name": "references",
"memberof": "src/Util/structReferences.js",
"static": true,
"longname": "src/Util/structReferences.js~references",
"access": "public",
"export": false,
"importPath": "yjs/src/Util/structReferences.js",
"importStyle": null,
"description": null,
"lineNumber": 14,
"undocument": true,
"type": {
"types": [
"*"
]
},
"ignore": true
},
{
"__docId__": 718,
"kind": "function",
"name": "registerStruct",
"memberof": "src/Util/structReferences.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/structReferences.js~registerStruct",
"access": "public",
"export": true,
"importPath": "yjs/src/Util/structReferences.js",
"importStyle": "{registerStruct}",
"description": "Register a new Yjs types. The same type must be defined with the same\nreference on all clients!",
"lineNumber": 25,
"params": [
{
"nullable": null,
"types": [
"Number"
],
"spread": false,
"optional": false,
"name": "reference",
"description": ""
},
{
"nullable": null,
"types": [
"class"
],
"spread": false,
"optional": false,
"name": "structConstructor",
"description": ""
}
],
"return": null
},
{
"__docId__": 719,
"kind": "function",
"name": "getStruct",
"memberof": "src/Util/structReferences.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/structReferences.js~getStruct",
"access": "private",
"export": true,
"importPath": "yjs/src/Util/structReferences.js",
"importStyle": "{getStruct}",
"description": "",
"lineNumber": 33,
"ignore": true,
"params": [
{
"name": "reference",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 720,
"kind": "function",
"name": "getStructReference",
"memberof": "src/Util/structReferences.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Util/structReferences.js~getStructReference",
"access": "private",
"export": true,
"importPath": "yjs/src/Util/structReferences.js",
"importStyle": "{getStructReference}",
"description": "",
"lineNumber": 40,
"ignore": true,
"params": [
{
"name": "typeConstructor",
"types": [
"*"
]
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 721,
"kind": "file",
"name": "src/Y.dist.js",
"content": "\nimport Y from './Y.js'\nimport UndoManager from './Util/UndoManager.js'\nimport { integrateRemoteStructs } from './MessageHandler/integrateRemoteStructs.js'\n\nimport { messageToString, messageToRoomname } from './MessageHandler/messageToString.js'\n\nimport Connector from './Connector.js'\nimport Persistence from './Persistence.js'\nimport YArray from './Types/YArray/YArray.js'\nimport YMap from './Types/YMap/YMap.js'\nimport YText from './Types/YText/YText.js'\nimport { YXmlFragment, YXmlElement, YXmlText, YXmlHook } from './Types/YXml/YXml.js'\nimport BinaryDecoder from './Util/Binary/Decoder.js'\nimport { getRelativePosition, fromRelativePosition } from './Util/relativePosition.js'\nimport { registerStruct } from './Util/structReferences.js'\nimport TextareaBinding from './Bindings/TextareaBinding/TextareaBinding.js'\nimport QuillBinding from './Bindings/QuillBinding/QuillBinding.js'\nimport DomBinding from './Bindings/DomBinding/DomBinding.js'\nimport { toBinary, fromBinary } from './MessageHandler/binaryEncode.js'\n\nimport debug from 'debug'\nimport domToType from './Bindings/DomBinding/domToType.js'\nimport { domsToTypes, switchAssociation } from './Bindings/DomBinding/util.js'\n\n// TODO: The following assignments should be moved to yjs-dist\nY.AbstractConnector = Connector\nY.AbstractPersistence = Persistence\nY.Array = YArray\nY.Map = YMap\nY.Text = YText\nY.XmlElement = YXmlElement\nY.XmlFragment = YXmlFragment\nY.XmlText = YXmlText\nY.XmlHook = YXmlHook\n\nY.TextareaBinding = TextareaBinding\nY.QuillBinding = QuillBinding\nY.DomBinding = DomBinding\n\nDomBinding.domToType = domToType\nDomBinding.domsToTypes = domsToTypes\nDomBinding.switchAssociation = switchAssociation\n\nY.utils = {\n BinaryDecoder,\n UndoManager,\n getRelativePosition,\n fromRelativePosition,\n registerStruct,\n integrateRemoteStructs,\n toBinary,\n fromBinary\n}\n\nY.debug = debug\ndebug.formatters.Y = messageToString\ndebug.formatters.y = messageToRoomname\nexport default Y\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Y.dist.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 722,
"kind": "file",
"name": "src/Y.js",
"content": "import DeleteStore from './Store/DeleteStore.js'\nimport OperationStore from './Store/OperationStore.js'\nimport StateStore from './Store/StateStore.js'\nimport { generateRandomUint32 } from './Util/generateRandomUint32.js'\nimport RootID from './Util/ID/RootID.js'\nimport NamedEventHandler from './Util/NamedEventHandler.js'\nimport Transaction from './Transaction.js'\n\nexport { default as DomBinding } from './Bindings/DomBinding/DomBinding.js'\n\n/**\n * Anything that can be encoded with `JSON.stringify` and can be decoded with\n * `JSON.parse`.\n *\n * The following property should hold:\n * `JSON.parse(JSON.stringify(key))===key`\n *\n * At the moment the only safe values are number and string.\n *\n * @typedef {(number|string)} encodable\n */\n\n/**\n * A Yjs instance handles the state of shared data.\n *\n * @param {string} room Users in the same room share the same content\n * @param {Object} opts Connector definition\n * @param {AbstractPersistence} persistence Persistence adapter instance\n */\nexport default class Y extends NamedEventHandler {\n constructor (room, opts, persistence) {\n super()\n /**\n * The room name that this Yjs instance connects to.\n * @type {String}\n */\n this.room = room\n if (opts != null) {\n opts.connector.room = room\n }\n this._contentReady = false\n this._opts = opts\n if (typeof opts.userID !== 'number') {\n this.userID = generateRandomUint32()\n } else {\n this.userID = opts.userID\n }\n // TODO: This should be a Map so we can use encodables as keys\n this.share = {}\n this.ds = new DeleteStore(this)\n this.os = new OperationStore(this)\n this.ss = new StateStore(this)\n this._missingStructs = new Map()\n this._readyToIntegrate = []\n this._transaction = null\n /**\n * The {@link AbstractConnector}.that is used by this Yjs instance.\n * @type {AbstractConnector}\n */\n this.connector = null\n this.connected = false\n let initConnection = () => {\n if (opts != null) {\n this.connector = new Y[opts.connector.name](this, opts.connector)\n this.connected = true\n this.emit('connectorReady')\n }\n }\n /**\n * The {@link AbstractPersistence} that is used by this Yjs instance.\n * @type {AbstractPersistence}\n */\n this.persistence = null\n if (persistence != null) {\n this.persistence = persistence\n persistence._init(this).then(initConnection)\n } else {\n initConnection()\n }\n // for compatibility with isParentOf\n this._parent = null\n this._hasUndoManager = false\n }\n _setContentReady () {\n if (!this._contentReady) {\n this._contentReady = true\n this.emit('content')\n }\n }\n whenContentReady () {\n if (this._contentReady) {\n return Promise.resolve()\n } else {\n return new Promise(resolve => {\n this.once('content', resolve)\n })\n }\n }\n _beforeChange () {}\n /**\n * Changes that happen inside of a transaction are bundled. This means that\n * the observer fires _after_ the transaction is finished and that all changes\n * that happened inside of the transaction are sent as one message to the\n * other peers.\n *\n * @param {Function} f The function that should be executed as a transaction\n * @param {?Boolean} remote Optional. Whether this transaction is initiated by\n * a remote peer. This should not be set manually!\n * Defaults to false.\n */\n transact (f, remote = false) {\n let initialCall = this._transaction === null\n if (initialCall) {\n this._transaction = new Transaction(this)\n this.emit('beforeTransaction', this, this._transaction, remote)\n }\n try {\n f(this)\n } catch (e) {\n console.error(e)\n }\n if (initialCall) {\n this.emit('beforeObserverCalls', this, this._transaction, remote)\n const transaction = this._transaction\n this._transaction = null\n // emit change events on changed types\n transaction.changedTypes.forEach(function (subs, type) {\n if (!type._deleted) {\n type._callObserver(transaction, subs, remote)\n }\n })\n transaction.changedParentTypes.forEach(function (events, type) {\n if (!type._deleted) {\n events = events\n .filter(event =>\n !event.target._deleted\n )\n events\n .forEach(event => {\n event.currentTarget = type\n })\n // we don't have to check for events.length\n // because there is no way events is empty..\n type._deepEventHandler.callEventListeners(transaction, events)\n }\n })\n // when all changes & events are processed, emit afterTransaction event\n this.emit('afterTransaction', this, transaction, remote)\n }\n }\n\n /**\n * @private\n * Fake _start for root properties (y.set('name', type))\n */\n get _start () {\n return null\n }\n\n /**\n * @private\n * Fake _start for root properties (y.set('name', type))\n */\n set _start (start) {\n return null\n }\n\n /**\n * Define a shared data type.\n *\n * Multiple calls of `y.define(name, TypeConstructor)` yield the same result\n * and do not overwrite each other. I.e.\n * `y.define(name, type) === y.define(name, type)`\n *\n * After this method is called, the type is also available on `y.share[name]`.\n *\n * *Best Practices:*\n * Either define all types right after the Yjs instance is created or always\n * use `y.define(..)` when accessing a type.\n *\n * @example\n * // Option 1\n * const y = new Y(..)\n * y.define('myArray', YArray)\n * y.define('myMap', YMap)\n * // .. when accessing the type use y.share[name]\n * y.share.myArray.insert(..)\n * y.share.myMap.set(..)\n *\n * // Option2\n * const y = new Y(..)\n * // .. when accessing the type use `y.define(..)`\n * y.define('myArray', YArray).insert(..)\n * y.define('myMap', YMap).set(..)\n *\n * @param {String} name\n * @param {YType Constructor} TypeConstructor The constructor of the type definition\n * @returns {YType} The created type\n */\n define (name, TypeConstructor) {\n let id = new RootID(name, TypeConstructor)\n let type = this.os.get(id)\n if (this.share[name] === undefined) {\n this.share[name] = type\n } else if (this.share[name] !== type) {\n throw new Error('Type is already defined with a different constructor')\n }\n return type\n }\n\n /**\n * Get a defined type. The type must be defined locally. First define the\n * type with {@link define}.\n *\n * This returns the same value as `y.share[name]`\n *\n * @param {String} name The typename\n */\n get (name) {\n return this.share[name]\n }\n\n /**\n * Disconnect this Yjs Instance from the network. The connector will\n * unsubscribe from the room and document updates are not shared anymore.\n */\n disconnect () {\n if (this.connected) {\n this.connected = false\n return this.connector.disconnect()\n } else {\n return Promise.resolve()\n }\n }\n\n /**\n * If disconnected, tell the connector to reconnect to the room.\n */\n reconnect () {\n if (!this.connected) {\n this.connected = true\n return this.connector.reconnect()\n } else {\n return Promise.resolve()\n }\n }\n\n /**\n * Disconnect from the room, and destroy all traces of this Yjs instance.\n * Persisted data will remain until removed by the persistence adapter.\n */\n destroy () {\n super.destroy()\n this.share = null\n if (this.connector != null) {\n if (this.connector.destroy != null) {\n this.connector.destroy()\n } else {\n this.connector.disconnect()\n }\n }\n if (this.persistence !== null) {\n this.persistence.deinit(this)\n this.persistence = null\n }\n this.os = null\n this.ds = null\n this.ss = null\n }\n}\n\nY.extend = function extendYjs () {\n for (var i = 0; i < arguments.length; i++) {\n var f = arguments[i]\n if (typeof f === 'function') {\n f(Y)\n } else {\n throw new Error('Expected a function!')\n }\n }\n}\n",
"static": true,
"longname": "/Users/kjahns/git/yjs-v13/yjs/src/Y.js",
"access": "public",
"description": null,
"lineNumber": 1
},
{
"__docId__": 723,
"kind": "typedef",
"name": "encodable",
"memberof": "src/Y.js",
"static": true,
"longname": "src/Y.js~encodable",
"access": "public",
"description": "Anything that can be encoded with `JSON.stringify` and can be decoded with\n`JSON.parse`.\n\nThe following property should hold:\n`JSON.parse(JSON.stringify(key))===key`\n\nAt the moment the only safe values are number and string.",
"type": {
"types": [
"number",
"string"
],
"optional": false,
"name": "encodable"
}
},
{
"__docId__": 724,
"kind": "class",
"name": "Y",
"memberof": "src/Y.js",
"static": true,
"longname": "src/Y.js~Y",
"access": "public",
"export": true,
"importPath": "yjs/src/Y.js",
"importStyle": "Y",
"description": "A Yjs instance handles the state of shared data.",
"lineNumber": 30,
"params": [
{
"nullable": null,
"types": [
"string"
],
"spread": false,
"optional": false,
"name": "room",
"description": "Users in the same room share the same content"
},
{
"nullable": null,
"types": [
"Object"
],
"spread": false,
"optional": false,
"name": "opts",
"description": "Connector definition"
},
{
"nullable": null,
"types": [
"AbstractPersistence"
],
"spread": false,
"optional": false,
"name": "persistence",
"description": "Persistence adapter instance"
}
],
"interface": false,
"extends": [
"src/Util/NamedEventHandler.js~NamedEventHandler"
]
},
{
"__docId__": 725,
"kind": "constructor",
"name": "constructor",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#constructor",
"access": "public",
"description": null,
"lineNumber": 31,
"undocument": true
},
{
"__docId__": 726,
"kind": "member",
"name": "room",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#room",
"access": "public",
"description": "The room name that this Yjs instance connects to.",
"lineNumber": 37,
"type": {
"nullable": null,
"types": [
"String"
],
"spread": false,
"description": null
}
},
{
"__docId__": 727,
"kind": "member",
"name": "_contentReady",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#_contentReady",
"access": "private",
"description": null,
"lineNumber": 41,
"undocument": true,
"ignore": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 728,
"kind": "member",
"name": "_opts",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#_opts",
"access": "private",
"description": null,
"lineNumber": 42,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 729,
"kind": "member",
"name": "userID",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#userID",
"access": "public",
"description": null,
"lineNumber": 44,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 731,
"kind": "member",
"name": "share",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#share",
"access": "public",
"description": null,
"lineNumber": 49,
"undocument": true,
"type": {
"types": [
"{}"
]
}
},
{
"__docId__": 732,
"kind": "member",
"name": "ds",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#ds",
"access": "public",
"description": null,
"lineNumber": 50,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 733,
"kind": "member",
"name": "os",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#os",
"access": "public",
"description": null,
"lineNumber": 51,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 734,
"kind": "member",
"name": "ss",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#ss",
"access": "public",
"description": null,
"lineNumber": 52,
"undocument": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 735,
"kind": "member",
"name": "_missingStructs",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#_missingStructs",
"access": "private",
"description": null,
"lineNumber": 53,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 736,
"kind": "member",
"name": "_readyToIntegrate",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#_readyToIntegrate",
"access": "private",
"description": null,
"lineNumber": 54,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*[]"
]
}
},
{
"__docId__": 737,
"kind": "member",
"name": "_transaction",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#_transaction",
"access": "private",
"description": null,
"lineNumber": 55,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 738,
"kind": "member",
"name": "connector",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#connector",
"access": "public",
"description": "The {@link AbstractConnector}.that is used by this Yjs instance.",
"lineNumber": 60,
"type": {
"nullable": null,
"types": [
"AbstractConnector"
],
"spread": false,
"description": null
}
},
{
"__docId__": 739,
"kind": "member",
"name": "connected",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#connected",
"access": "public",
"description": null,
"lineNumber": 61,
"undocument": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 742,
"kind": "member",
"name": "persistence",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#persistence",
"access": "public",
"description": "The {@link AbstractPersistence} that is used by this Yjs instance.",
"lineNumber": 73,
"type": {
"nullable": null,
"types": [
"AbstractPersistence"
],
"spread": false,
"description": null
}
},
{
"__docId__": 744,
"kind": "member",
"name": "_parent",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#_parent",
"access": "private",
"description": null,
"lineNumber": 81,
"undocument": true,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 745,
"kind": "member",
"name": "_hasUndoManager",
"memberof": "src/Y.js~Y",
"static": false,
"longname": "src/Y.js~Y#_hasUndoManager",
"access": "private",
"description": null,
"lineNumber": 82,
"undocument": true,
"ignore": true,
"type": {
"types": [
"boolean"
]
}
},
{
"__docId__": 746,
"kind": "method",
"name": "_setContentReady",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#_setContentReady",
"access": "private",
"description": null,
"lineNumber": 84,
"undocument": true,
"ignore": true,
"params": [],
"return": null
},
{
"__docId__": 748,
"kind": "method",
"name": "whenContentReady",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#whenContentReady",
"access": "public",
"description": null,
"lineNumber": 90,
"undocument": true,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 749,
"kind": "method",
"name": "_beforeChange",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#_beforeChange",
"access": "private",
"description": null,
"lineNumber": 99,
"undocument": true,
"ignore": true,
"params": [],
"return": null
},
{
"__docId__": 750,
"kind": "method",
"name": "transact",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#transact",
"access": "public",
"description": "Changes that happen inside of a transaction are bundled. This means that\nthe observer fires _after_ the transaction is finished and that all changes\nthat happened inside of the transaction are sent as one message to the\nother peers.",
"lineNumber": 111,
"params": [
{
"nullable": null,
"types": [
"Function"
],
"spread": false,
"optional": false,
"name": "f",
"description": "The function that should be executed as a transaction"
},
{
"nullable": true,
"types": [
"Boolean"
],
"spread": false,
"optional": false,
"name": "remote",
"description": "Optional. Whether this transaction is initiated by\n a remote peer. This should not be set manually!\n Defaults to false."
}
],
"return": null
},
{
"__docId__": 753,
"kind": "get",
"name": "_start",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#_start",
"access": "private",
"description": "",
"lineNumber": 156,
"ignore": true,
"type": {
"types": [
"*"
]
}
},
{
"__docId__": 754,
"kind": "set",
"name": "_start",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#_start",
"access": "private",
"description": "",
"lineNumber": 164,
"ignore": true
},
{
"__docId__": 755,
"kind": "method",
"name": "define",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#define",
"access": "public",
"description": "Define a shared data type.\n\nMultiple calls of `y.define(name, TypeConstructor)` yield the same result\nand do not overwrite each other. I.e.\n`y.define(name, type) === y.define(name, type)`\n\nAfter this method is called, the type is also available on `y.share[name]`.\n\n*Best Practices:*\nEither define all types right after the Yjs instance is created or always\nuse `y.define(..)` when accessing a type.",
"examples": [
" // Option 1\n const y = new Y(..)\n y.define('myArray', YArray)\n y.define('myMap', YMap)\n // .. when accessing the type use y.share[name]\n y.share.myArray.insert(..)\n y.share.myMap.set(..)\n\n // Option2\n const y = new Y(..)\n // .. when accessing the type use `y.define(..)`\n y.define('myArray', YArray).insert(..)\n y.define('myMap', YMap).set(..)"
],
"lineNumber": 200,
"unknown": [
{
"tagName": "@returns",
"tagValue": "{YType} The created type"
}
],
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "name",
"description": ""
},
{
"nullable": null,
"types": [
"YType Constructor"
],
"spread": false,
"optional": false,
"name": "TypeConstructor",
"description": "The constructor of the type definition"
}
],
"return": {
"nullable": null,
"types": [
"YType"
],
"spread": false,
"description": "The created type"
}
},
{
"__docId__": 756,
"kind": "method",
"name": "get",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#get",
"access": "public",
"description": "Get a defined type. The type must be defined locally. First define the\ntype with {@link define}.\n\nThis returns the same value as `y.share[name]`",
"lineNumber": 219,
"params": [
{
"nullable": null,
"types": [
"String"
],
"spread": false,
"optional": false,
"name": "name",
"description": "The typename"
}
],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 757,
"kind": "method",
"name": "disconnect",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#disconnect",
"access": "public",
"description": "Disconnect this Yjs Instance from the network. The connector will\nunsubscribe from the room and document updates are not shared anymore.",
"lineNumber": 227,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 759,
"kind": "method",
"name": "reconnect",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#reconnect",
"access": "public",
"description": "If disconnected, tell the connector to reconnect to the room.",
"lineNumber": 239,
"params": [],
"return": {
"types": [
"*"
]
}
},
{
"__docId__": 761,
"kind": "method",
"name": "destroy",
"memberof": "src/Y.js~Y",
"generator": false,
"async": false,
"static": false,
"longname": "src/Y.js~Y#destroy",
"access": "public",
"description": "Disconnect from the room, and destroy all traces of this Yjs instance.\nPersisted data will remain until removed by the persistence adapter.",
"lineNumber": 252,
"params": [],
"return": null
},
{
"__docId__": 767,
"kind": "function",
"name": "extend",
"memberof": "src/Y.js",
"generator": false,
"async": false,
"static": true,
"longname": "src/Y.js~extend",
"access": "public",
"export": false,
"importPath": "yjs/src/Y.js",
"importStyle": null,
"description": null,
"lineNumber": 272,
"undocument": true,
"params": [],
"return": null,
"ignore": true
},
{
"kind": "index",
"content": "\n# ![Yjs](http://y-js.org/images/yjs.png)\n\nYjs is a framework for offline-first p2p shared editing on structured data like\ntext, richtext, json, or XML. It is fairly easy to get started, as Yjs hides\nmost of the complexity of concurrent editing. For additional information, demos,\nand tutorials visit [y-js.org](http://y-js.org/).\n\n### Extensions\nYjs only knows how to resolve conflicts on shared data. You have to choose a ..\n* *Connector* - a communication protocol that propagates changes to the clients\n* *Database* - a database to store your changes\n* one or more *Types* - that represent the shared data\n\nConnectors, Databases, and Types are available as modules that extend Yjs. Here\nis a list of the modules we know of:\n\n##### Connectors\n\n|Name | Description |\n|----------------|-----------------------------------|\n|[webrtc](https://github.com/y-js/y-webrtc) | Propagate updates Browser2Browser via WebRTC|\n|[websockets](https://github.com/y-js/y-websockets-client) | Set up [a central server](https://github.com/y-js/y-websockets-client), and connect to it via websockets |\n|[xmpp](https://github.com/y-js/y-xmpp) | Propagate updates in a XMPP multi-user-chat room ([XEP-0045](http://xmpp.org/extensions/xep-0045.html))|\n|[ipfs](https://github.com/ipfs-labs/y-ipfs-connector) | Connector for the [Interplanetary File System](https://ipfs.io/)!|\n|[test](https://github.com/y-js/y-test) | A Connector for testing purposes. It is designed to simulate delays that happen in worst case scenarios|\n\n##### Database adapters\n\n|Name | Description |\n|----------------|-----------------------------------|\n|[memory](https://github.com/y-js/y-memory) | In-memory storage. |\n|[indexeddb](https://github.com/y-js/y-indexeddb) | Offline storage for the browser |\n|[leveldb](https://github.com/y-js/y-leveldb) | Persistent storage for node apps |\n\n\n##### Types\n\n| Name | Description |\n|----------|-------------------|\n|[map](https://github.com/y-js/y-map) | A shared Map implementation. Maps from text to any stringify-able object |\n|[array](https://github.com/y-js/y-array) | A shared Array implementation |\n|[xml](https://github.com/y-js/y-xml) | An implementation of the DOM. You can create a two way binding to Browser DOM objects |\n|[text](https://github.com/y-js/y-text) | Collaborate on text. Supports two way binding to the [Ace Editor](https://ace.c9.io), [CodeMirror](https://codemirror.net/), [Monaco](https://github.com/Microsoft/monaco-editor), textareas, input elements, and HTML elements (e.g. <*h1*>, or <*p*>) |\n|[richtext](https://github.com/y-js/y-richtext) | Collaborate on rich text. Supports two way binding to the [Quill Rich Text Editor](http://quilljs.com/)|\n\n##### Other\n\n| Name | Description |\n|-----------|-------------------|\n|[y-element](http://y-js.org/y-element/) | Yjs Polymer Element |\n\n## Use it!\nInstall Yjs, and its modules with [bower](http://bower.io/), or\n[npm](https://www.npmjs.org/package/yjs).\n\n### Bower\n```\nbower install --save yjs y-array % add all y-* modules you want to use\n```\nYou only need to include the `y.js` file. Yjs is able to automatically require\nmissing modules. \n```\n<script src=\"./bower_components/yjs/y.js\"></script>\n```\n\n### CDN\n```\n<script src=\"https://cdn.jsdelivr.net/npm/yjs@12/src/y.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/y-array@10/dist/y-array.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/y-websockets-client@8/dist/y-websockets-client.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/y-memory@8/dist/y-memory.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/y-array@10/dist/y-array.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/y-map@10/dist/y-map.js\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/y-text@9/dist/y-text.js\"></script>\n// ..\n// do the same for all modules you want to use\n```\n\n### Npm\n```\nnpm install --save yjs % add all y-* modules you want to use\n```\n\nIf you don't include via script tag, you have to explicitly include all modules!\n(Same goes for other module systems)\n```\nvar Y = require('yjs')\nrequire('y-array')(Y) // add the y-array type to Yjs\nrequire('y-websockets-client')(Y)\nrequire('y-memory')(Y)\nrequire('y-array')(Y)\nrequire('y-map')(Y)\nrequire('y-text')(Y)\n// ..\n// do the same for all modules you want to use\n```\n\n### ES6 Syntax\n```\nimport Y from 'yjs'\nimport yArray from 'y-array'\nimport yWebsocketsClient from 'y-webrtc'\nimport yMemory from 'y-memory'\nimport yArray from 'y-array'\nimport yMap from 'y-map'\nimport yText from 'y-text'\n// ..\nY.extend(yArray, yWebsocketsClient, yMemory, yArray, yMap, yText /*, .. */)\n```\n\n# Text editing example\nInstall dependencies\n```\nbower i yjs y-memory y-webrtc y-array y-text\n```\n\nHere is a simple example of a shared textarea\n```HTML\n <!DOCTYPE html>\n <html>\n <body>\n <script src=\"./bower_components/yjs/y.js\"></script>\n <!-- Yjs automatically includes all missing dependencies (browser only) -->\n <script>\n Y({\n db: {\n name: 'memory' // use memory database adapter.\n // name: 'indexeddb' // use indexeddb database adapter instead for offline apps\n },\n connector: {\n name: 'webrtc', // use webrtc connector\n // name: 'websockets-client'\n // name: 'xmpp'\n room: 'my-room' // clients connecting to the same room share data\n },\n sourceDir: '/bower_components', // location of the y-* modules (browser only)\n share: {\n textarea: 'Text' // y.share.textarea is of type y-text\n }\n }).then(function (y) {\n // The Yjs instance `y` is available\n // y.share.* contains the shared types\n\n // Bind `y.share.textarea` to `<textarea/>`\n y.share.textarea.bind(document.querySelector('textarea'))\n })\n </script>\n <textarea></textarea>\n </body>\n </html>\n```\n\n## Get Help & Give Help\nThere are some friendly people on [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/y-js/yjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) who are eager to help, and answer questions. Please join!\n\nReport _any_ issues to the\n[Github issue page](https://github.com/y-js/yjs/issues)! I try to fix them very\nsoon, if possible.\n\n# API\n\n### Y(options)\n* Y.extend(module1, module2, ..)\n * Add extensions to Y\n * `Y.extend(require('y-webrtc'))` has the same semantics as\n `require('y-webrtc')(Y)`\n* options.db\n * Will be forwarded to the database adapter. Specify the database adaper on\n `options.db.name`.\n * Have a look at the used database adapter repository to see all available\n options.\n* options.connector\n * Will be forwarded to the connector adapter. Specify the connector adaper on\n `options.connector.name`.\n * All our connectors implement a `room` property. Clients that specify the\n same room share the same data.\n * All of our connectors specify an `url` property that defines the connection\n endpoint of the used connector.\n * All of our connectors also have a default connection endpoint that you can\n use for development.\n * Set `options.connector.generateUserId = true` in order to genenerate a\n userid, instead of receiving one from the server. This way the `Y(..)` is\n immediately going to be resolved, without waiting for any confirmation from\n the server. Use with caution.\n * Have a look at the used connector repository to see all available options.\n * *Only if you know what you are doing:* Set\n `options.connector.preferUntransformed = true` in order receive the shared\n data untransformed. This is very efficient as the database content is simply\n copied to this client. This does only work if this client receives content\n from only one client.\n* options.sourceDir (browser only)\n * Path where all y-* modules are stored\n * Defaults to `/bower_components`\n * Not required when running on `nodejs` / `iojs`\n * When using nodejs you need to manually extend Yjs:\n```\nvar Y = require('yjs')\n// you have to require a db, connector, and *all* types you use!\nrequire('y-memory')(Y)\nrequire('y-webrtc')(Y)\nrequire('y-map')(Y)\n// ..\n```\n* options.share\n * Specify on `options.share[arbitraryName]` types that are shared among all\n users.\n * E.g. Specify `options.share[arbitraryName] = 'Array'` to require y-array and\n create an y-array type on `y.share[arbitraryName]`.\n * If userA doesn't specify `options.share[arbitraryName]`, it won't be\n available for userA.\n * If userB specifies `options.share[arbitraryName]`, it still won't be\n available for userA. But all the updates are send from userB to userA.\n * In contrast to y-map, types on `y.share.*` cannot be overwritten or deleted.\n Instead, they are merged among all users. This feature is only available on\n `y.share.*`\n * Weird behavior: It is supported that two users specify different types with\n the same property name.\n E.g. userA specifies `options.share.x = 'Array'`, and userB specifies\n `options.share.x = 'Text'`. But they only share data if they specified the\n same type with the same property name\n* options.type (browser only)\n * Array of modules that Yjs needs to require, before instantiating a shared\n type.\n * By default Yjs requires the specified database adapter, the specified\n connector, and all modules that are used in `options.share.*`\n * Put all types here that you intend to use, but are not used in y.share.*\n\n### Instantiated Y object (y)\n`Y(options)` returns a promise that is fulfilled when..\n\n* All modules are loaded\n * The specified database adapter is loaded\n * The specified connector is loaded\n * All types are included\n* The connector is initialized, and a unique user id is set (received from the\n server)\n * Note: When using y-indexeddb, a retrieved user id is stored on `localStorage`\n\nThe promise returns an instance of Y. We denote it with a lower case `y`.\n\n* y.share.*\n * Instances of the types you specified on options.share.*\n * y.share.* can only be defined once when you instantiate Y!\n* y.connector is an instance of Y.AbstractConnector\n* y.connector.onUserEvent(function (event) {..})\n * Observe user events (event.action is either 'userLeft' or 'userJoined')\n* y.connector.whenSynced(listener)\n * `listener` is executed when y synced with at least one user.\n * `listener` is not called when no other user is in the same room.\n * y-websockets-client aways waits to sync with the server\n* y.connector.disconnect()\n * Force to disconnect this instance from the other instances\n* y.connector.reconnect()\n * Try to reconnect to the other instances (needs to be supported by the\n connector)\n * Not supported by y-xmpp\n* y.close()\n * Destroy this object.\n * Destroys all types (they will throw weird errors if you still use them)\n * Disconnects from the other instances (via connector)\n * Returns a promise\n* y.destroy()\n * calls y.close()\n * Removes all data from the database\n * Returns a promise\n* y.db.stopGarbageCollector()\n * Stop the garbage collector. Call y.db.garbageCollect() to continue garbage\n collection\n* y.db.gc :: Boolean\n * Whether gc is turned on\n* y.db.gcTimeout :: Number (defaults to 50000 ms)\n * Time interval between two garbage collect cycles\n * It is required that all instances exchanged all messages after two garbage\n collect cycles (after 100000 ms per default)\n* y.db.userId :: String\n * The used user id for this client. **Never overwrite this**\n\n### Logging\nYjs uses [debug](https://github.com/visionmedia/debug) for logging. The flag\n`y*` enables logging for all y-* components. You can selectively remove\ncomponents you are not interested in: E.g. The flag `y*,-y:connector-message`\nwill not log the long `y:connector-message` messages.\n\n##### Enable logging in Node.js\n```sh\nDEBUG=y* node app.js\n```\n\nRemove the colors in order to log to a file:\n```sh\nDEBUG_COLORS=0 DEBUG=y* node app.js > log\n```\n\n##### Enable logging in the browser\n```js\nlocalStorage.debug = 'y*'\n```\n\n## Contribution\nI created this framework during my bachelor thesis at the chair of computer\nscience 5 [(i5)](http://dbis.rwth-aachen.de/cms), RWTH University. Since\nDecember 2014 I'm working on Yjs as a part of my student worker job at the i5.\n\n## License\nYjs is licensed under the [MIT License](./LICENSE).\n\n<yjs@dbis.rwth-aachen.de>\n",
"longname": "/Users/kjahns/git/yjs-v13/yjs/README.md",
"name": "./README.md",
"static": true,
"access": "public"
},
{
"kind": "packageJSON",
"content": "{\n \"name\": \"yjs\",\n \"version\": \"13.0.0-54\",\n \"description\": \"A framework for real-time p2p shared editing on any data\",\n \"main\": \"./y.node.js\",\n \"browser\": \"./y.js\",\n \"module\": \"./src/y.js\",\n \"scripts\": {\n \"test\": \"npm run lint\",\n \"debug\": \"concurrently 'rollup -wc rollup.test.js' 'cutest-serve y.test.js -o'\",\n \"lint\": \"standard\",\n \"docs\": \"esdoc\",\n \"serve-docs\": \"npm run docs && serve ./docs/\",\n \"dist\": \"rollup -c rollup.browser.js; rollup -c rollup.node.js\",\n \"watch\": \"concurrently 'rollup -wc rollup.browser.js' 'rollup -wc rollup.node.js'\",\n \"postversion\": \"npm run dist\",\n \"postpublish\": \"tag-dist-files --overwrite-existing-tag\"\n },\n \"files\": [\n \"y.*\",\n \"src/*\",\n \".esdoc.json\"\n ],\n \"standard\": {\n \"ignore\": [\n \"/y.js\",\n \"/y.js.map\"\n ]\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/y-js/yjs.git\"\n },\n \"keywords\": [\n \"Yjs\",\n \"OT\",\n \"Collaboration\",\n \"Synchronization\",\n \"ShareJS\",\n \"Coweb\",\n \"Concurrency\"\n ],\n \"author\": \"Kevin Jahns\",\n \"email\": \"kevin.jahns@rwth-aachen.de\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/y-js/yjs/issues\"\n },\n \"homepage\": \"http://y-js.org\",\n \"devDependencies\": {\n \"babel-cli\": \"^6.24.1\",\n \"babel-plugin-external-helpers\": \"^6.22.0\",\n \"babel-plugin-transform-regenerator\": \"^6.24.1\",\n \"babel-plugin-transform-runtime\": \"^6.23.0\",\n \"babel-preset-latest\": \"^6.24.1\",\n \"chance\": \"^1.0.9\",\n \"concurrently\": \"^3.4.0\",\n \"cutest\": \"^0.1.9\",\n \"esdoc\": \"^1.0.4\",\n \"esdoc-standard-plugin\": \"^1.0.0\",\n \"quill\": \"^1.3.5\",\n \"quill-cursors\": \"^1.0.2\",\n \"rollup-plugin-babel\": \"^2.7.1\",\n \"rollup-plugin-commonjs\": \"^8.0.2\",\n \"rollup-plugin-inject\": \"^2.0.0\",\n \"rollup-plugin-multi-entry\": \"^2.0.1\",\n \"rollup-plugin-node-resolve\": \"^3.0.0\",\n \"rollup-plugin-uglify\": \"^1.0.2\",\n \"rollup-regenerator-runtime\": \"^6.23.1\",\n \"rollup-watch\": \"^3.2.2\",\n \"standard\": \"^10.0.2\",\n \"tag-dist-files\": \"^0.1.6\"\n },\n \"dependencies\": {\n \"debug\": \"^2.6.8\"\n }\n}\n",
"longname": "/Users/kjahns/git/yjs-v13/yjs/package.json",
"name": "package.json",
"static": true,
"access": "public"
}
]