@cocreate/crdt 1.15.0 → 1.15.1

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 CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.15.1](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.15.0...v1.15.1) (2023-01-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add cdn to demo ([26e4302](https://github.com/CoCreate-app/CoCreate-crdt/commit/26e43026f178a74437146087142ce7e9e5cf696e))
7
+ * string was returned as array in sttead of string ([e3314ba](https://github.com/CoCreate-app/CoCreate-crdt/commit/e3314ba703419f7a651d2572536c2891bbfac7c3))
8
+ * typo tex to text ([adb8052](https://github.com/CoCreate-app/CoCreate-crdt/commit/adb80523e2f9b5b3d3b6594af6d9435ea10b67ab))
9
+
1
10
  # [1.15.0](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.14.35...v1.15.0) (2023-01-04)
2
11
 
3
12
 
package/demo/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  CoCreate.crdt.replaceText({
13
13
  collection: "apples",
14
14
  document_id: "602c4dadb7fb6c9da35ca126",
15
- name: "html",
15
+ name: "test",
16
16
  value: 'testing new value'
17
17
  })
18
18
  <br/>
@@ -40,8 +40,8 @@
40
40
 
41
41
 
42
42
  <!--<script src="../dist/CoCreate-crdt.js"></script>-->
43
- <script src="../../../CoCreateJS/dist/CoCreate.js" ></script>
44
- <!-- <script src="https://cdn.cocreate.app/latest/CoCreate.min.js" ></script> -->
43
+ <!-- <script src="../../../CoCreateJS/dist/CoCreate.js" ></script> -->
44
+ <script src="https://cdn.cocreate.app/latest/CoCreate.min.js" ></script>
45
45
  </body>
46
46
  </html>
47
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/crdt",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "CoCreate crdt",
5
5
  "author": "CoCreate LLC",
6
6
  "license": "SEE LICENSE",
package/src/index.js CHANGED
@@ -71,7 +71,6 @@ String.prototype.customSplice = function (index, absIndex, string) {
71
71
  async function generateText(data, flag) {
72
72
  try {
73
73
  let doc = docs.get(getDocName(data))
74
- console.log('docName1', doc)
75
74
 
76
75
  let string = '';
77
76
  let changeLog = doc.get('changeLog');
@@ -204,7 +203,7 @@ function broadcastChange(data){
204
203
 
205
204
  function localChange(data, string) {
206
205
  const localChange = new CustomEvent('cocreate-crdt-update', {
207
- detail: { ...data, ...string },
206
+ detail: { ...data, string },
208
207
  });
209
208
  window.dispatchEvent(localChange);
210
209
  }
@@ -213,7 +212,7 @@ function persistChange(data) {
213
212
  let docName = getDocName(data);
214
213
  let doc = docs.get(docName);
215
214
  let changeLog = doc.get('changeLog');
216
- let text = doc.get('tex');
215
+ let text = doc.get('text');
217
216
  let Data = {
218
217
  collection: 'crdt-transactions',
219
218
  document: {
@@ -242,7 +241,6 @@ message.listen('crdt', function(response) {
242
241
  let data = response.data
243
242
  let docName = getDocName(data);
244
243
  let doc = docs.get(docName);
245
- console.log('doc2', doc)
246
244
 
247
245
  if (doc){
248
246
  if (data.clientId !== clientId){
@@ -258,11 +256,13 @@ crud.listen('sync', function(data) {
258
256
  let docName = Data.docName;
259
257
  let doc = docs.get(docName);
260
258
  if (doc && Data.crud) {
261
- Data.start = 0
262
- Data.length = doc.set('text').length
259
+ Data.crud.value = Data.text
260
+ Data.crud.start = 0
261
+ Data.crud.length = doc.get('text').length
263
262
 
264
263
  doc.set('changeLog', Data.changeLog)
265
264
  doc.set('text', Data.text)
265
+ // ToDo: compare modified dates to check if arrays need to merged and orderd by date or if we just use server
266
266
  localChange(Data.crud, Data.text)
267
267
  console.log('crdtSync')
268
268
  }