@cocreate/crdt 1.9.1 → 1.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/docs/index.html +1 -1
- package/package.json +5 -5
- package/src/index.js +19 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [1.9.5](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.9.4...v1.9.5) (2022-02-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* value duplication resolved ([8894449](https://github.com/CoCreate-app/CoCreate-crdt/commit/8894449cda528249a3f7731490251b07db2a0a61))
|
|
7
|
+
|
|
8
|
+
## [1.9.4](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.9.3...v1.9.4) (2022-02-07)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* bump dependency versions ([502da81](https://github.com/CoCreate-app/CoCreate-crdt/commit/502da8198e52076bef6132525a17c6b42314fc0c))
|
|
14
|
+
|
|
15
|
+
## [1.9.3](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.9.2...v1.9.3) (2022-02-07)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* checkDb if condition was was true even if string was not empty. replaced == with === ([ca27e77](https://github.com/CoCreate-app/CoCreate-crdt/commit/ca27e770b2ebbabb1c2a5763e7c1205987731662))
|
|
21
|
+
|
|
22
|
+
## [1.9.2](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.9.1...v1.9.2) (2022-02-03)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* replaced show and hide class hidden with attribute hidden ([3add8ee](https://github.com/CoCreate-app/CoCreate-crdt/commit/3add8ee46e64021bf13706c935873076bdcc9927))
|
|
28
|
+
|
|
1
29
|
## [1.9.1](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.9.0...v1.9.1) (2022-02-01)
|
|
2
30
|
|
|
3
31
|
|
package/docs/index.html
CHANGED
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
<div class="container svColumn overflow:hidden card position:relative border-radius:2px width:auto height:100%" id="sandbox">
|
|
75
75
|
<div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
|
76
76
|
<a class="margin-right:10px" id="code" show="#preview" hide="#code, #view"><i class="far fa-eye"></i></a>
|
|
77
|
-
<a class="margin-right:10px
|
|
77
|
+
<a class="margin-right:10px" id="preview" show="#code, #view" hide="#preview" hidden><i class="fas fa-code"></i></a>
|
|
78
78
|
<a class="margin-right:5px" fullscreen target="#playground"><i class="fas fa-expand"></i></a>
|
|
79
79
|
</div>
|
|
80
80
|
<div class="svRow">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/crdt",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.5",
|
|
4
4
|
"description": "CoCreate crdt",
|
|
5
5
|
"author": "CoCreate LLC",
|
|
6
6
|
"license": "SEE LICENSE",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"webpack-log": "^3.0.1"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@cocreate/actions": "^1.3.
|
|
47
|
-
"@cocreate/crud-client": "^1.4.
|
|
48
|
-
"@cocreate/message-client": "^1.1.
|
|
49
|
-
"@cocreate/utils": "^1.
|
|
46
|
+
"@cocreate/actions": "^1.3.30",
|
|
47
|
+
"@cocreate/crud-client": "^1.4.45",
|
|
48
|
+
"@cocreate/message-client": "^1.1.62",
|
|
49
|
+
"@cocreate/utils": "^1.6.2"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,8 @@ import action from '@cocreate/actions';
|
|
|
6
6
|
|
|
7
7
|
const docs = new Map();
|
|
8
8
|
const clientId = config.clientId || window.CoCreateSockets.clientId || uuid.generate(12);
|
|
9
|
-
|
|
9
|
+
const checkedDb = new Map();
|
|
10
|
+
const isInit = new Map();
|
|
10
11
|
|
|
11
12
|
function init(info){
|
|
12
13
|
getText(info).then(value => {
|
|
@@ -21,20 +22,23 @@ async function getDoc(info) {
|
|
|
21
22
|
try {
|
|
22
23
|
let docName = generateDocName(info);
|
|
23
24
|
let typeName = info.name;
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
let doc = docs.get(docName);
|
|
26
|
+
|
|
27
|
+
if (!doc) {
|
|
26
28
|
let docNameMap = new Map();
|
|
27
29
|
docs.set(docName, docNameMap);
|
|
30
|
+
doc = docs.get(docName);
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
let type = doc.get(typeName)
|
|
34
|
+
if (!type) {
|
|
31
35
|
let typeNameMap = new Map();
|
|
32
|
-
|
|
36
|
+
doc.set(typeName, typeNameMap);
|
|
37
|
+
type = doc.get(typeName)
|
|
33
38
|
}
|
|
34
|
-
|
|
35
|
-
if (!docs.get(docName).get(typeName).has('changeLog')) {
|
|
39
|
+
if (!type.has('changeLog')) {
|
|
36
40
|
let changeLog = [];
|
|
37
|
-
|
|
41
|
+
|
|
38
42
|
if (info.read != 'false') {
|
|
39
43
|
let response = await crud.readDocumentList({
|
|
40
44
|
collection: "crdt-transactions",
|
|
@@ -49,11 +53,12 @@ async function getDoc(info) {
|
|
|
49
53
|
if (response.data.length && response.data[0][typeName]) {
|
|
50
54
|
changeLog = response.data[0][typeName];
|
|
51
55
|
}
|
|
52
|
-
|
|
56
|
+
type.set('changeLog', changeLog);
|
|
53
57
|
await generateText(info, true);
|
|
54
58
|
}
|
|
59
|
+
|
|
55
60
|
}
|
|
56
|
-
else if (!
|
|
61
|
+
else if (!type.has('text')){
|
|
57
62
|
await generateText(info, false);
|
|
58
63
|
}
|
|
59
64
|
return true;
|
|
@@ -75,7 +80,7 @@ async function generateText(info, flag) {
|
|
|
75
80
|
for (let change of changeLog) {
|
|
76
81
|
string = string.customSplice(change.start, change.length, change.value);
|
|
77
82
|
}
|
|
78
|
-
if (string
|
|
83
|
+
if (string === '' && info.read !== 'false'){
|
|
79
84
|
string = await checkDb(info, flag);
|
|
80
85
|
}
|
|
81
86
|
name.set('text', string);
|
|
@@ -88,7 +93,9 @@ async function generateText(info, flag) {
|
|
|
88
93
|
|
|
89
94
|
async function checkDb(info, flag) {
|
|
90
95
|
let { collection, document_id, name } = info;
|
|
91
|
-
|
|
96
|
+
if (checkedDb.get(`${collection}${document_id}${name}`)) return;
|
|
97
|
+
checkedDb.set(`${collection}${document_id}${name}`, true);
|
|
98
|
+
let response = await crud.readDocument({ collection, document_id, name });
|
|
92
99
|
let string = response.data[name];
|
|
93
100
|
if (string && flag != false) {
|
|
94
101
|
info.value = string;
|
|
@@ -233,8 +240,6 @@ async function getText(info) {
|
|
|
233
240
|
let doc = await getDoc(info);
|
|
234
241
|
if (doc) {
|
|
235
242
|
let value = docs.get(docName).get(typeName).get('text')
|
|
236
|
-
if (!value)
|
|
237
|
-
console.log(value)
|
|
238
243
|
return value;
|
|
239
244
|
}
|
|
240
245
|
else {
|