Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presence #31

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7235c8f
Presence changes
houshuang Apr 4, 2019
7023ee3
WIP
houshuang Apr 4, 2019
22c5bd4
WIP
houshuang Apr 4, 2019
b25c3a7
WIP
houshuang Apr 6, 2019
beb947c
WIP
houshuang Apr 11, 2019
aadf1ef
WIP
houshuang Apr 11, 2019
957924d
Remove minor formatting changes to clean up PR diff.
curran Apr 12, 2019
ca187aa
Remove minor formatting changes to clean up PR diff.
curran Apr 12, 2019
44ca0a0
Remove minor formatting changes to clean up PR diff.
curran Apr 12, 2019
1b12811
Restore original package.json
curran Apr 12, 2019
d797551
Remove yarn.lock (as this was not already there in json0)
curran Apr 12, 2019
62f6acd
Fix undefined reference
curran Apr 12, 2019
bf02b8c
Comment unused code
curran Apr 12, 2019
73adc91
Simplify comparePresence
curran Apr 12, 2019
095967e
Simplify transformPresence
curran Apr 12, 2019
6435e13
Add stub for presence tests
curran Apr 12, 2019
a249e05
Add sketch for presence structure in README
curran Apr 12, 2019
151c6ea
Add first pass implementation from earlier
curran Apr 12, 2019
1a359af
Invoke subtype transformPresence
curran Apr 12, 2019
a2ab7e7
Revise proposed structure for presence
curran Apr 12, 2019
f3eb080
Revise structure in README
curran Apr 12, 2019
db5deeb
Fix invocation of subtype .transformPresence
curran Apr 12, 2019
00ecd57
Add first substantive test case for transformPresence
curran Apr 12, 2019
78b02ba
Clean transformPresence implementation. Introduce unpackPresence.
curran Apr 12, 2019
52e0fb8
Add test case for matching presence type
curran Apr 13, 2019
1d3d6da
Add test case for non-matching path
curran Apr 13, 2019
d5b7d0b
Match style of existing code
curran Apr 13, 2019
bc3a74f
Match style of existing code - use ES5
curran Apr 13, 2019
552794c
Start working on text0 presence
curran Apr 13, 2019
bcb60c4
Add text0 transformPresence
curran Apr 13, 2019
3c9c3d0
Add tests for isOwnPosition behavior
curran Apr 13, 2019
a92c376
Clean up PR diff
curran Apr 13, 2019
072d49b
Clean up PR diff
curran Apr 13, 2019
b8ca428
Revise shape of presence data structure
curran Apr 13, 2019
424c424
Simplify implementation
curran Apr 13, 2019
d1edf5a
Add test for transformPresence by op with multiple components
curran Apr 13, 2019
e7c6f03
Finalize tests for text0-presence
curran Apr 13, 2019
19431c7
Add transformPresence tests for embedded text0 ops
curran Apr 13, 2019
0f8290e
Pass through path-only presence objects
curran Apr 13, 2019
94540e1
Remove dead code, minor cleanup
curran Apr 15, 2019
d9d32a4
Namespace package and increment minor version
curran Apr 15, 2019
95f20d8
Add link to presence demo
curran Apr 15, 2019
90a06fe
Add usage instructions and context.
curran Apr 16, 2019
a3ecc44
Merge branch 'master' into presence-attempt-4
curran Apr 16, 2019
3cd4ef6
Reset package.json for upstream PR
curran Apr 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify implementation
curran committed Apr 13, 2019
commit 424c4244d24c0fc06f422a78b6fe16036425790e
49 changes: 2 additions & 47 deletions lib/json0.js
Original file line number Diff line number Diff line change
@@ -754,52 +754,7 @@ json.comparePresence = function(pres1, pres2) {
// };
//

// Unpacks the presence array into meaningful parts.
function unpackPresence(presence) {

// Validate to help app developers find problems.
if(!presence.slice) {
console.log('Expected presence to be an array. Received:');
console.log(presence);
}

return {
presencePath: presence.slice(0, presence.length - 2),
presenceType: presence[presence.length - 2],
subPresence: presence[presence.length - 1]
};
};
json.unpackPresence = unpackPresence;

json.transformPresence = function(presence, op, isOwnOp) {
if (op.length === 0) return presence;

var presencePath = presence.p;
var presenceType = presence.t
var subPresence = presence.s;

// TODO integrate any valid ideas from here.
//for (let c of op){
// if(c.si || c.sd){
// convertFromText(c)
// }
// if(c.t === 'text0') {
// //json.canOpAffectPath = function(op, path) {
// presence = Object.assign({}, presence, {
// s: presence.s.map(selection => {
// const path = selection.slice(0, selection.length - 2);
// if(canOpAffectPath(c, path)) {
// const [start, end] = selection.slice(selection.length - 2);
// return path.concat([
// transformCursor(start, c.o),
// transformCursor(end, c.o),
// ]);
// }
// return selection;
// })
// });
// }
//}
for (var i = 0; i < op.length; i++) {
var c = op[i];

@@ -809,9 +764,9 @@ json.transformPresence = function(presence, op, isOwnOp) {
// convertFromText(c);

// Transform against subtype ops.
if (c.t && c.t === presenceType && json.pathMatches(c.p, presencePath)) {
if (c.t && c.t === presence.t && json.pathMatches(c.p, presence.p)) {
return Object.assign({}, presence, {
s: subtypes[presenceType].transformPresence(subPresence, c.o, isOwnOp)
s: subtypes[presence.t].transformPresence(presence.s, c.o, isOwnOp)
});
}