diff --git a/README.v13.md b/README.v13.md index d8148aba..ce462225 100644 --- a/README.v13.md +++ b/README.v13.md @@ -139,11 +139,11 @@ import * as Y from 'yjs'

const yarray = new Y.Array()
- insert(index:number, content:Array<object|string|number|Uint8Array|Y.Type>) + insert(index:number, content:Array<object|boolean|Array|string|number|Uint8Array|Y.Type>)
Insert content at index. Note that content is an array of elements. I.e. array.insert(0, [1] splices the list and inserts 1 at position 0.
- push(Array<Object|Array|string|number|Uint8Array|Y.Type>) + push(Array<Object|boolean|Array|string|number|Uint8Array|Y.Type>)
delete(index:number, length:number)
@@ -153,9 +153,9 @@ import * as Y from 'yjs'
map(function(T, number, YArray):M):Array<M>
- toArray():Array<Object|Array|string|number|Uint8Array|Y.Type> + toArray():Array<object|boolean|Array|string|number|Uint8Array|Y.Type>
Copies the content of this YArray to a new Array.
- toJSON():Array<Object|Array|string|number> + toJSON():Array<Object|boolean|Array|string|number>
Copies the content of this YArray to a new Array. It transforms all child types to JSON using their toJSON method.
[Symbol.Iterator]
@@ -188,9 +188,9 @@ import * as Y from 'yjs'

const ymap = new Y.Map()
- get(key:string):object|string|number|Uint8Array|Y.Type + get(key:string):object|boolean|string|number|Uint8Array|Y.Type
- set(key:string, value:object|string|number|Uint8Array|Y.Type) + set(key:string, value:object|boolean|string|number|Uint8Array|Y.Type)
delete(key:string)
@@ -198,7 +198,7 @@ import * as Y from 'yjs'
get(index:number)
- toJSON():Object<string, Object|Array|string|number> + toJSON():Object<string, Object|boolean|Array|string|number>
Copies the [key,value] pairs of this YMap to a new Object. It transforms all child types to JSON using their toJSON method.
[Symbol.Iterator]
diff --git a/package-lock.json b/package-lock.json index 7e0231ba..da63fe34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1779,8 +1779,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -1801,14 +1800,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1823,20 +1820,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -1953,8 +1947,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -1966,7 +1959,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -1981,7 +1973,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1989,14 +1980,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2015,7 +2004,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -2096,8 +2084,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -2109,7 +2096,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -2195,8 +2181,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -2232,7 +2217,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2252,7 +2236,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2296,14 +2279,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -5111,20 +5092,12 @@ "dev": true }, "y-protocols": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-0.0.4.tgz", - "integrity": "sha512-a7F8t16y6rVPYGvwsbfeN5EauHFBo+SIsYadvaONdp6jCyhcKokDK8u30BQOJCOxwd1FkuAhMs14m6CtJbfRqg==", + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-0.0.6.tgz", + "integrity": "sha512-XgUBKrFesfUYN3wXmVp9Exy7dOUOeX3A56gHNuI1ZNy9N7OdwoBv2TGfbvSH6+YpV1IEvEq7u5v0/je5MwXKJg==", "dev": true, "requires": { - "lib0": "0.0.4" - }, - "dependencies": { - "lib0": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.0.4.tgz", - "integrity": "sha512-osSGIxFM0mUuVAclVOQAio4lq0YYk1xFfj6J+1i3u5az8rXAQKDil2skA19aiiG0sfAdasOtr8Mk+9Mrw10cfQ==", - "dev": true - } + "lib0": "0.0.5" } }, "yallist": { diff --git a/package.json b/package.json index c15ad5a1..9ad948c9 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,6 @@ "standard": "^11.0.1", "tui-jsdoc-template": "^1.2.2", "typescript": "^3.4.5", - "y-protocols": "0.0.4" + "y-protocols": "0.0.6" } } diff --git a/rollup.config.js b/rollup.config.js index d926a781..16fdc00a 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -23,12 +23,14 @@ const debugResolve = { if (importee === 'yjs') { return `${process.cwd()}/src/index.js` } + /* if (customModules.has(importee.split('/')[0])) { return `${process.cwd()}/../${importee}/src/${importee}.js` } if (customLibModules.has(importee.split('/')[0])) { return `${process.cwd()}/../${importee}` } + */ return null } } diff --git a/src/types/AbstractType.js b/src/types/AbstractType.js index c0ad077f..c1ffc18f 100644 --- a/src/types/AbstractType.js +++ b/src/types/AbstractType.js @@ -363,7 +363,7 @@ export const typeListGet = (type, index) => { * @param {Transaction} transaction * @param {AbstractType} parent * @param {AbstractItem?} referenceItem - * @param {Array|Array|number|string|Uint8Array>} content + * @param {Array|Array|boolean|number|string|Uint8Array>} content * * @private * @function @@ -386,6 +386,7 @@ export const typeListInsertGenericsAfter = (transaction, parent, referenceItem, switch (c.constructor) { case Number: case Object: + case Boolean: case Array: case String: jsonContent.push(c) @@ -510,6 +511,7 @@ export const typeMapSet = (transaction, parent, key, value) => { switch (value.constructor) { case Number: case Object: + case Boolean: case Array: case String: new ItemJSON(nextID(transaction), left, left === null ? null : left.lastId, null, null, parent, key, [value]).integrate(transaction) diff --git a/tests/y-array.tests.js b/tests/y-array.tests.js index 0c508477..0b68532c 100644 --- a/tests/y-array.tests.js +++ b/tests/y-array.tests.js @@ -25,10 +25,10 @@ export const testDeleteInsert = tc => { */ export const testInsertThreeElementsTryRegetProperty = tc => { const { testConnector, users, array0, array1 } = init(tc, { users: 2 }) - array0.insert(0, [1, 2, 3]) - t.compare(array0.toJSON(), [1, 2, 3], '.toJSON() works') + array0.insert(0, [1, true, false]) + t.compare(array0.toJSON(), [1, true, false], '.toJSON() works') testConnector.flushAllMessages() - t.compare(array1.toJSON(), [1, 2, 3], '.toJSON() works after sync') + t.compare(array1.toJSON(), [1, true, false], '.toJSON() works after sync') compare(users) } diff --git a/tests/y-map.tests.js b/tests/y-map.tests.js index 586a5f0d..8d5bec82 100644 --- a/tests/y-map.tests.js +++ b/tests/y-map.tests.js @@ -19,6 +19,8 @@ export const testBasicMapTests = tc => { map0.set('string', 'hello Y') map0.set('object', { key: { key2: 'value' } }) map0.set('y-map', new Y.Map()) + map0.set('boolean1', true) + map0.set('boolean0', false) const map = map0.get('y-map') map.set('y-array', new Y.Array()) const array = map.get('y-array') @@ -27,6 +29,8 @@ export const testBasicMapTests = tc => { t.assert(map0.get('number') === 1, 'client 0 computed the change (number)') t.assert(map0.get('string') === 'hello Y', 'client 0 computed the change (string)') + t.assert(map0.get('boolean0') === false, 'client 0 computed the change (boolean)') + t.assert(map0.get('boolean1') === true, 'client 0 computed the change (boolean)') t.compare(map0.get('object'), { key: { key2: 'value' } }, 'client 0 computed the change (object)') t.assert(map0.get('y-map').get('y-array').get(0) === -1, 'client 0 computed the change (type)') @@ -35,12 +39,16 @@ export const testBasicMapTests = tc => { t.assert(map1.get('number') === 1, 'client 1 received the update (number)') t.assert(map1.get('string') === 'hello Y', 'client 1 received the update (string)') + t.assert(map1.get('boolean0') === false, 'client 1 computed the change (boolean)') + t.assert(map1.get('boolean1') === true, 'client 1 computed the change (boolean)') t.compare(map1.get('object'), { key: { key2: 'value' } }, 'client 1 received the update (object)') t.assert(map1.get('y-map').get('y-array').get(0) === -1, 'client 1 received the update (type)') // compare disconnected user t.assert(map2.get('number') === 1, 'client 2 received the update (number) - was disconnected') t.assert(map2.get('string') === 'hello Y', 'client 2 received the update (string) - was disconnected') + t.assert(map2.get('boolean0') === false, 'client 2 computed the change (boolean)') + t.assert(map2.get('boolean1') === true, 'client 2 computed the change (boolean)') t.compare(map2.get('object'), { key: { key2: 'value' } }, 'client 2 received the update (object) - was disconnected') t.assert(map2.get('y-map').get('y-array').get(0) === -1, 'client 2 received the update (type) - was disconnected') compare(users)