@cocreate/elements 1.34.4 → 1.35.0
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 +15 -0
- package/package.json +1 -1
- package/src/fetchSrc.js +0 -26
- package/src/form.js +14 -3
- package/src/index.js +13 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [1.35.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.34.5...v1.35.0) (2024-03-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* observe form for new inputs and setAttribute ([527d1bd](https://github.com/CoCreate-app/CoCreate-elements/commit/527d1bd490ae28655006918fe8d8a99fb210cbde))
|
|
7
|
+
|
|
8
|
+
## [1.34.5](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.34.4...v1.34.5) (2024-02-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* data.object conditions ([d7f1431](https://github.com/CoCreate-app/CoCreate-elements/commit/d7f1431a70e48cf70dac8d219ab9f1c26df91a42))
|
|
14
|
+
* processing object.$update ([157f094](https://github.com/CoCreate-app/CoCreate-elements/commit/157f094d50bed51b94af9be272fdfc733b9f1cc6))
|
|
15
|
+
|
|
1
16
|
## [1.34.4](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.34.3...v1.34.4) (2024-02-19)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"description": "Fetch content into any html element by using html5 attributes to query data stored in CoCreate headless CMS. If data is changed it will instantly reflect in html tags as changes are broadcasted in realtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"elements",
|
package/src/fetchSrc.js
CHANGED
|
@@ -178,32 +178,6 @@ function base64ToArrayBuffer(base64) {
|
|
|
178
178
|
return bytes.buffer; // Return ArrayBuffer
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
const videoStreamConfig = {
|
|
182
|
-
title: "Video Title",
|
|
183
|
-
totalDuration: 3600, // Total duration of the video in seconds
|
|
184
|
-
'content-type': "video/mp4",
|
|
185
|
-
segments: [
|
|
186
|
-
{
|
|
187
|
-
_id: 1,
|
|
188
|
-
src: "http://example.com/video/chunk1.mp4", // src stored using file path
|
|
189
|
-
storage: '', // src stored using crud path
|
|
190
|
-
array: '', // src stored using crud path
|
|
191
|
-
object: '', // src stored using crud path
|
|
192
|
-
key: '', // src stored using crud path
|
|
193
|
-
start: 0, // Start time of this chunk in seconds
|
|
194
|
-
end: 10, // End time of this chunk in seconds
|
|
195
|
-
duration: 10,
|
|
196
|
-
codec: "h.264",
|
|
197
|
-
resolution: {
|
|
198
|
-
width: 1920,
|
|
199
|
-
height: 1080
|
|
200
|
-
},
|
|
201
|
-
bitrate: "5000kbps",
|
|
202
|
-
},
|
|
203
|
-
// Repeat for each chunk
|
|
204
|
-
]
|
|
205
|
-
}
|
|
206
|
-
|
|
207
181
|
observer.init({
|
|
208
182
|
name: 'CoCreateSrc',
|
|
209
183
|
observe: ['addedNodes'],
|
package/src/form.js
CHANGED
|
@@ -18,7 +18,18 @@ function init(elements) {
|
|
|
18
18
|
elements = document.querySelectorAll('form');
|
|
19
19
|
else if (!Array.isArray(elements))
|
|
20
20
|
elements = [elements]
|
|
21
|
+
|
|
21
22
|
for (let element of elements) {
|
|
23
|
+
Observer.init({
|
|
24
|
+
name: 'CoCreateFormElements',
|
|
25
|
+
observe: ['addedNodes'],
|
|
26
|
+
target: '[storage], [database], [array], [index], [object], [key]',
|
|
27
|
+
callback: function (mutation) {
|
|
28
|
+
if (element == mutation.target.form)
|
|
29
|
+
setAttribute(element, [mutation.target])
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
22
33
|
runObjectId(element);
|
|
23
34
|
setAttribute(element);
|
|
24
35
|
disableAutoFill(element);
|
|
@@ -43,7 +54,6 @@ function runObjectId(form) {
|
|
|
43
54
|
// Add a array to the array list.
|
|
44
55
|
if (array && !arrays.includes(array))
|
|
45
56
|
arrays.push(array)
|
|
46
|
-
|
|
47
57
|
}
|
|
48
58
|
// Sets the object id for each array in the array.
|
|
49
59
|
for (let i = 0; i < arrays.length; i++) {
|
|
@@ -55,8 +65,9 @@ function runObjectId(form) {
|
|
|
55
65
|
/**
|
|
56
66
|
* @param form
|
|
57
67
|
*/
|
|
58
|
-
function setAttribute(form) {
|
|
59
|
-
|
|
68
|
+
function setAttribute(form, elements) {
|
|
69
|
+
if (!elements)
|
|
70
|
+
elements = form.querySelectorAll('[storage], [database], [array], [index], [object], [key]');
|
|
60
71
|
|
|
61
72
|
for (let attribute of form.attributes) {
|
|
62
73
|
let variable = window.CoCreateConfig.attributes[attribute.name]
|
package/src/index.js
CHANGED
|
@@ -85,7 +85,7 @@ async function initElement(el) {
|
|
|
85
85
|
|
|
86
86
|
let data = getObject(el);
|
|
87
87
|
if (!data || !data.type) return
|
|
88
|
-
if (data.object
|
|
88
|
+
if (data.object && data.object !== 'pending' && !(/^[0-9a-fA-F]{24}$/.test(data.object)))
|
|
89
89
|
return
|
|
90
90
|
|
|
91
91
|
if (!elements.has(el)) {
|
|
@@ -360,6 +360,11 @@ async function setData(element, data) {
|
|
|
360
360
|
else
|
|
361
361
|
value = 0
|
|
362
362
|
} else {
|
|
363
|
+
let $update = data[type][0].$update
|
|
364
|
+
if ($update) {
|
|
365
|
+
delete data[type][0].$update
|
|
366
|
+
data[type][0] = { ...data[type][0], ...$update }
|
|
367
|
+
}
|
|
363
368
|
value = CRUD.getValueFromObject(data[type][0], key)
|
|
364
369
|
}
|
|
365
370
|
|
|
@@ -395,6 +400,12 @@ async function filterData(element, data, type, key) {
|
|
|
395
400
|
let _id = element.getAttribute('object')
|
|
396
401
|
if (_id && doc._id !== _id)
|
|
397
402
|
return
|
|
403
|
+
let $update = doc.$update
|
|
404
|
+
if ($update) {
|
|
405
|
+
delete doc.$update
|
|
406
|
+
doc = { ...doc, ...$update }
|
|
407
|
+
}
|
|
408
|
+
|
|
398
409
|
}
|
|
399
410
|
if (doc[property]) {
|
|
400
411
|
if (Array.isArray(doc[property]))
|
|
@@ -472,6 +483,7 @@ async function checkFilters(element, data, type) {
|
|
|
472
483
|
if (!isMatch)
|
|
473
484
|
newData.slice(i, 1)
|
|
474
485
|
}
|
|
486
|
+
|
|
475
487
|
}
|
|
476
488
|
|
|
477
489
|
if (!newData || !newData.length)
|