@cocreate/crdt 1.8.19 → 1.8.23
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/package.json +5 -5
- package/src/index.js +27 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [1.8.23](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.8.22...v1.8.23) (2021-11-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* getDocs will request generateText with changeLog true or false ([2309736](https://github.com/CoCreate-app/CoCreate-crdt/commit/230973632f96a8a65f1bea430e626a8a7e6223af))
|
|
7
|
+
|
|
8
|
+
## [1.8.22](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.8.21...v1.8.22) (2021-11-23)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update dependencies ([e4f1d13](https://github.com/CoCreate-app/CoCreate-crdt/commit/e4f1d136b47f11120a61ddaa91dd782cdd42ab5d))
|
|
14
|
+
|
|
15
|
+
## [1.8.21](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.8.20...v1.8.21) (2021-11-23)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* await generateText ([917dd9a](https://github.com/CoCreate-app/CoCreate-crdt/commit/917dd9acdeae8b6dc9185aa2049dd28b0337e3eb))
|
|
21
|
+
|
|
22
|
+
## [1.8.20](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.8.19...v1.8.20) (2021-11-22)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* if crud or save will not save to crud ([b8f51ac](https://github.com/CoCreate-app/CoCreate-crdt/commit/b8f51ac606fc3d1894404ef8ec82c3895b16d6cc))
|
|
28
|
+
|
|
1
29
|
## [1.8.19](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.8.18...v1.8.19) (2021-11-20)
|
|
2
30
|
|
|
3
31
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/crdt",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.23",
|
|
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/action": "^1.3.
|
|
47
|
-
"@cocreate/crud-client": "^1.4.
|
|
48
|
-
"@cocreate/message-client": "^1.1.
|
|
49
|
-
"@cocreate/utils": "^1.3.
|
|
46
|
+
"@cocreate/action": "^1.3.18",
|
|
47
|
+
"@cocreate/crud-client": "^1.4.34",
|
|
48
|
+
"@cocreate/message-client": "^1.1.52",
|
|
49
|
+
"@cocreate/utils": "^1.3.12"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/index.js
CHANGED
|
@@ -34,7 +34,6 @@ async function getDoc(info) {
|
|
|
34
34
|
|
|
35
35
|
if (!docs.get(docName).get(typeName).has('changeLog')) {
|
|
36
36
|
let changeLog = [];
|
|
37
|
-
docs.get(docName).get(typeName).set('changeLog', changeLog);
|
|
38
37
|
|
|
39
38
|
if (info.read != 'false') {
|
|
40
39
|
let response = await crud.readDocumentList({
|
|
@@ -49,10 +48,13 @@ async function getDoc(info) {
|
|
|
49
48
|
});
|
|
50
49
|
if (response.data.length && response.data[0][typeName]) {
|
|
51
50
|
changeLog = response.data[0][typeName];
|
|
52
|
-
docs.get(docName).get(typeName).set('changeLog', changeLog);
|
|
53
51
|
}
|
|
52
|
+
docs.get(docName).get(typeName).set('changeLog', changeLog);
|
|
53
|
+
await generateText(info, true);
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
}
|
|
56
|
+
else if (!docs.get(docName).get(typeName).has('text')){
|
|
57
|
+
await generateText(info, false);
|
|
56
58
|
}
|
|
57
59
|
return true;
|
|
58
60
|
}
|
|
@@ -65,7 +67,7 @@ String.prototype.customSplice = function (index, absIndex, string) {
|
|
|
65
67
|
return this.slice(0, index) + string+ this.slice(index + Math.abs(absIndex));
|
|
66
68
|
};
|
|
67
69
|
|
|
68
|
-
async function generateText(info) {
|
|
70
|
+
async function generateText(info, flag) {
|
|
69
71
|
try {
|
|
70
72
|
let name = docs.get(`${info.collection}${info.document_id}`).get(info.name);
|
|
71
73
|
let string = '';
|
|
@@ -73,26 +75,27 @@ async function generateText(info) {
|
|
|
73
75
|
for (let change of changeLog) {
|
|
74
76
|
string = string.customSplice(change.start, change.length, change.value);
|
|
75
77
|
}
|
|
78
|
+
if (string == '' && info.read != 'false'){
|
|
79
|
+
string = await checkDb(info, flag);
|
|
80
|
+
}
|
|
76
81
|
name.set('text', string);
|
|
77
|
-
|
|
78
|
-
checkDb(info);
|
|
82
|
+
return;
|
|
79
83
|
}
|
|
80
84
|
catch (e) {
|
|
81
85
|
console.error(e);
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
function checkDb(info) {
|
|
89
|
+
async function checkDb(info, flag) {
|
|
86
90
|
let { collection, document_id, name } = info;
|
|
87
|
-
crud.readDocument({ collection, document_id, name })
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
});
|
|
91
|
+
let response = await crud.readDocument({ collection, document_id, name })
|
|
92
|
+
let string = response.data[name];
|
|
93
|
+
if (string && flag != false) {
|
|
94
|
+
info.value = string;
|
|
95
|
+
info.start = 0;
|
|
96
|
+
insertChange(info);
|
|
97
|
+
}
|
|
98
|
+
return string || '';
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
function insertChange(info, broadcast, flag) {
|
|
@@ -228,7 +231,13 @@ async function getText(info) {
|
|
|
228
231
|
let typeName = info.name;
|
|
229
232
|
let doc = await getDoc(info);
|
|
230
233
|
if (doc) {
|
|
231
|
-
|
|
234
|
+
let value = docs.get(docName).get(typeName).get('text')
|
|
235
|
+
if (!value)
|
|
236
|
+
console.log(value)
|
|
237
|
+
return value;
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
console.log('undefined')
|
|
232
241
|
}
|
|
233
242
|
}
|
|
234
243
|
catch (e) {
|
|
@@ -286,7 +295,7 @@ async function updateText(info, flag) {
|
|
|
286
295
|
|
|
287
296
|
insertChange(info, broadcast, flag);
|
|
288
297
|
|
|
289
|
-
if (info.crud != 'false') {
|
|
298
|
+
if (info.crud != 'false' && info.save != 'false') {
|
|
290
299
|
let wholestring = await getText(info);
|
|
291
300
|
crud.updateDocument({
|
|
292
301
|
collection: info.collection,
|