Comparing version 0.7.0 to 0.7.1
@@ -11,5 +11,8 @@ # Changelog | ||
### Fixed | ||
- [#69]: `Automerge.load` generates random actorId if none specified ([@saranrapjs]) | ||
- [#64]: `Automerge.applyChanges()` allows changes to be applied out-of-order ([@jimpick], [@ept]) | ||
## [0.6.0] | ||
## [0.7.0] — 2018-01-15 | ||
@@ -102,2 +105,4 @@ ### Added | ||
[#69]: https://github.com/automerge/automerge/pull/69 | ||
[#64]: https://github.com/automerge/automerge/pull/64 | ||
[#62]: https://github.com/automerge/automerge/pull/62 | ||
@@ -120,4 +125,6 @@ [#60]: https://github.com/automerge/automerge/pull/60 | ||
[@jeffpeterson]: https://github.com/jeffpeterson | ||
[@jimpick]: https://github.com/jimpick | ||
[@ept]: https://github.com/ept | ||
[@mmmm1998]: https://github.com/mmmm1998 | ||
[@pvh]: https://github.com/pvh | ||
[@saranrapjs]: https://github.com/saranrapjs |
@@ -0,0 +0,0 @@ Automerge internal data structures |
@@ -0,0 +0,0 @@ module.exports = function(config) { |
{ | ||
"name": "automerge", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Data structures for building collaborative applications", | ||
@@ -5,0 +5,0 @@ "main": "src/automerge.js", |
@@ -19,5 +19,2 @@ # Automerge | ||
doc.cards[0].done = true | ||
// Save the document to disk | ||
localStorage.setItem('MyToDoList', JSON.stringify(doc)) | ||
``` | ||
@@ -208,3 +205,3 @@ | ||
`Automerge.save(doc)` serializes the state of Automerge document `doc` to a string, which you can | ||
write to disk. The string contains an encoding of all of the full change history of the document | ||
write to disk. The string contains an encoding of the full change history of the document | ||
(a bit like a git repository). | ||
@@ -211,0 +208,0 @@ |
@@ -0,0 +0,0 @@ const { List, fromJS } = require('immutable') |
@@ -165,7 +165,7 @@ const { Map, List, fromJS } = require('immutable') | ||
function load(string, actorId) { | ||
return FreezeAPI.applyChanges(FreezeAPI.init(actorId), transit.fromJSON(string), false) | ||
return FreezeAPI.applyChanges(FreezeAPI.init(actorId || uuid()), transit.fromJSON(string), false) | ||
} | ||
function loadImmutable(string, actorId) { | ||
return ImmutableAPI.applyChanges(ImmutableAPI.init(actorId), transit.fromJSON(string), false) | ||
return ImmutableAPI.applyChanges(ImmutableAPI.init(actorId || uuid()), transit.fromJSON(string), false) | ||
} | ||
@@ -172,0 +172,0 @@ |
@@ -0,0 +0,0 @@ const { Map, fromJS } = require('immutable') |
@@ -0,0 +0,0 @@ const { Map, Set } = require('immutable') |
@@ -245,2 +245,3 @@ const { Map, List, Set } = require('immutable') | ||
newRoot = Object.assign(Object.create({_conflicts: root._conflicts}), root) | ||
opSet = opSet.setIn(['cache', OpSet.ROOT_ID], newRoot) | ||
} | ||
@@ -247,0 +248,0 @@ } else { |
@@ -0,0 +0,0 @@ const { Map, List, Set } = require('immutable') |
@@ -0,0 +0,0 @@ const { Map, List, Set } = require('immutable') |
@@ -0,0 +0,0 @@ const { List, fromJS } = require('immutable') |
@@ -0,0 +0,0 @@ const { Map } = require('immutable') |
@@ -0,0 +0,0 @@ const { SkipList } = require('./skip_list') |
@@ -0,0 +0,0 @@ const { Map, Set, fromJS } = require('immutable') |
@@ -0,0 +0,0 @@ const assert = require('assert') |
@@ -0,0 +0,0 @@ const assert = require('assert') |
@@ -0,0 +0,0 @@ const assert = require('assert') |
@@ -0,0 +0,0 @@ const assert = require('assert') |
@@ -0,0 +0,0 @@ const assert = require('assert') |
@@ -0,0 +0,0 @@ const assert = require('assert') |
@@ -705,2 +705,49 @@ const assert = require('assert') | ||
describe('saving and laoding', () => { | ||
it('should save and restore an empty document', () => { | ||
let s = Automerge.load(Automerge.save(Automerge.init())) | ||
assert.deepEqual(s, {_objectId: ROOT_ID}) | ||
}) | ||
it('should generate a new random actor ID', () => { | ||
let s1 = Automerge.init() | ||
let s2 = Automerge.load(Automerge.save(s1)) | ||
assert(/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(s1._actorId)) | ||
assert(/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(s2._actorId)) | ||
assert.notEqual(s1._actorId, s2._actorId) | ||
}) | ||
it('should allow a custom actor ID to be set', () => { | ||
let s = Automerge.load(Automerge.save(Automerge.init()), 'actor3') | ||
assert.strictEqual(s._actorId, 'actor3') | ||
}) | ||
it('should reconstitute complex datatypes', () => { | ||
let s1 = Automerge.change(Automerge.init(), doc => doc.todos = [{title: 'water plants', done: false}]) | ||
let s2 = Automerge.load(Automerge.save(s1)) | ||
assert.deepEqual(s2, {_objectId: ROOT_ID, todos: [ | ||
{title: 'water plants', done: false, _objectId: s1.todos[0]._objectId} | ||
]}) | ||
}) | ||
it('should reconstitute conflicts', () => { | ||
let s1 = Automerge.change(Automerge.init('actor1'), doc => doc.x = 3) | ||
let s2 = Automerge.change(Automerge.init('actor2'), doc => doc.x = 5) | ||
s1 = Automerge.merge(s1, s2) | ||
let s3 = Automerge.load(Automerge.save(s1)) | ||
assert.strictEqual(s1.x, 5) | ||
assert.strictEqual(s3.x, 5) | ||
assert.deepEqual(s1._conflicts, {x: {actor1: 3}}) | ||
assert.deepEqual(s3._conflicts, {x: {actor1: 3}}) | ||
}) | ||
it('should allow a reloaded list to be mutated', () => { | ||
let doc = Automerge.change(Automerge.init(), doc => doc.foo = []) | ||
doc = Automerge.load(Automerge.save(doc)) | ||
doc = Automerge.change(doc, 'add', doc => doc.foo.push(1)) | ||
doc = Automerge.load(Automerge.save(doc)) | ||
assert.deepEqual(doc.foo, [1]) | ||
}) | ||
}) | ||
describe('history API', () => { | ||
@@ -851,3 +898,16 @@ it('should return an empty history for an empty document', () => { | ||
}) | ||
it('should report missing dependencies with out-of-order applyChanges', () => { | ||
let s0 = Automerge.init() | ||
let s1 = Automerge.change(s0, doc => doc.test = ['a']) | ||
let s2 = Automerge.change(s1, doc => doc.test = ['b']) | ||
let s3 = Automerge.change(s2, doc => doc.test = ['c']) | ||
let changes1to2 = Automerge.getChanges(s1, s2) | ||
let changes2to3 = Automerge.getChanges(s2, s3) | ||
let s4 = Automerge.init() | ||
let s5 = Automerge.applyChanges(s4, changes2to3) | ||
let s6 = Automerge.applyChanges(s5, changes1to2) | ||
assert.deepEqual(Automerge.getMissingDeps(s6), {[s0._actorId]: 2}) | ||
}) | ||
}) | ||
}) |
@@ -0,0 +0,0 @@ const assert = require('assert') |
@@ -0,0 +0,0 @@ const assert = require('assert') |
@@ -0,0 +0,0 @@ var path = require('path'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
408370
29
8279
503