@cocreate/elements 1.35.0 → 1.35.2
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 +8 -8
- package/src/fetchSrc.js +44 -17
- package/src/index.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.35.2](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.35.1...v1.35.2) (2024-04-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump cocreate dependencies ([d8bdb33](https://github.com/CoCreate-app/CoCreate-elements/commit/d8bdb33ce67a70026d79c394fa2ef2f770a168f3))
|
|
7
|
+
|
|
8
|
+
## [1.35.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.35.0...v1.35.1) (2024-04-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* convert base64 segments to to arrayBuffer ([710c55e](https://github.com/CoCreate-app/CoCreate-elements/commit/710c55e6402fffc65cf1a633c67c7499766964e8))
|
|
14
|
+
* export setValueType ([bcc717c](https://github.com/CoCreate-app/CoCreate-elements/commit/bcc717caa541f406f1cb74fa97be6d651898f808))
|
|
15
|
+
|
|
1
16
|
# [1.35.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.34.5...v1.35.0) (2024-03-18)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.2",
|
|
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",
|
|
@@ -58,12 +58,12 @@
|
|
|
58
58
|
"webpack-log": "^3.0.1"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@cocreate/actions": "^1.
|
|
62
|
-
"@cocreate/crud-client": "^1.
|
|
63
|
-
"@cocreate/element-prototype": "^1.
|
|
64
|
-
"@cocreate/filter": "^1.
|
|
65
|
-
"@cocreate/observer": "^1.
|
|
66
|
-
"@cocreate/render": "^1.
|
|
67
|
-
"@cocreate/utils": "^1.
|
|
61
|
+
"@cocreate/actions": "^1.18.1",
|
|
62
|
+
"@cocreate/crud-client": "^1.33.8",
|
|
63
|
+
"@cocreate/element-prototype": "^1.22.2",
|
|
64
|
+
"@cocreate/filter": "^1.28.6",
|
|
65
|
+
"@cocreate/observer": "^1.16.0",
|
|
66
|
+
"@cocreate/render": "^1.40.3",
|
|
67
|
+
"@cocreate/utils": "^1.33.6"
|
|
68
68
|
}
|
|
69
69
|
}
|
package/src/fetchSrc.js
CHANGED
|
@@ -33,27 +33,44 @@ async function initElements(elements) {
|
|
|
33
33
|
let sourceBuffer;
|
|
34
34
|
|
|
35
35
|
const mediaSource = new MediaSource();
|
|
36
|
-
|
|
36
|
+
element.src = URL.createObjectURL(mediaSource);
|
|
37
37
|
mediaSource.addEventListener('sourceopen', async () => {
|
|
38
|
-
|
|
39
|
-
sourceBuffer = mediaSource.addSourceBuffer(contentType);
|
|
38
|
+
sourceBuffer = mediaSource.addSourceBuffer(`${mediaConfig['content-type']}; codecs="${mediaConfig.codecs}"`);
|
|
40
39
|
|
|
41
40
|
sourceBuffer.addEventListener('updateend', () => {
|
|
41
|
+
console.log('Update ended, buffered ranges:', sourceBuffer.buffered)
|
|
42
42
|
if (!sourceBuffer.updating && mediaSource.readyState === 'open') {
|
|
43
43
|
mediaSource.endOfStream();
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
URL.revokeObjectURL(
|
|
45
|
+
element.addEventListener('ended', () => {
|
|
46
|
+
URL.revokeObjectURL(element.src);
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
+
sourceBuffer.addEventListener('error', (e) => {
|
|
51
|
+
console.error('SourceBuffer error event:', e);
|
|
52
|
+
console.log('MediaSource readyState:', mediaSource.readyState);
|
|
53
|
+
console.log('SourceBuffer updating:', sourceBuffer.updating);
|
|
54
|
+
console.log('SourceBuffer buffered ranges:', sourceBuffer.buffered);
|
|
55
|
+
// Any other state information you can log
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
getSegment(sourceBuffer, mediaConfig.segments[0])
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
mediaSource.addEventListener('sourceended', () => {
|
|
63
|
+
console.log('MediaSource ended event fired');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
mediaSource.addEventListener('sourceclose', () => {
|
|
67
|
+
console.log('MediaSource close event fired');
|
|
50
68
|
});
|
|
51
69
|
|
|
52
70
|
// Event listener for seeking
|
|
53
71
|
element.addEventListener('seeking', () => {
|
|
54
72
|
let currentTime = element.currentTime;
|
|
55
73
|
let chunkIndex = Math.floor(currentTime / chunkDuration);
|
|
56
|
-
|
|
57
74
|
});
|
|
58
75
|
|
|
59
76
|
// Event listener for seeked
|
|
@@ -74,8 +91,8 @@ async function initElements(elements) {
|
|
|
74
91
|
});
|
|
75
92
|
|
|
76
93
|
element.addEventListener('timeupdate', function () {
|
|
77
|
-
const bufferEnd =
|
|
78
|
-
const currentTime =
|
|
94
|
+
const bufferEnd = element.buffered.end(0);
|
|
95
|
+
const currentTime = element.currentTime;
|
|
79
96
|
const threshold = 10; // seconds before buffer end to fetch the next segment
|
|
80
97
|
|
|
81
98
|
if (bufferEnd - currentTime < threshold) {
|
|
@@ -83,8 +100,9 @@ async function initElements(elements) {
|
|
|
83
100
|
getSegment(sourceBuffer, mediaConfig)
|
|
84
101
|
}
|
|
85
102
|
});
|
|
103
|
+
|
|
86
104
|
} catch (error) {
|
|
87
|
-
|
|
105
|
+
element.src = src
|
|
88
106
|
// let blob = await response.json();
|
|
89
107
|
// URL.createObjectURL(blob);
|
|
90
108
|
}
|
|
@@ -106,14 +124,14 @@ async function initElements(elements) {
|
|
|
106
124
|
}
|
|
107
125
|
};
|
|
108
126
|
|
|
109
|
-
async function getSegment(sourceBuffer,
|
|
127
|
+
async function getSegment(sourceBuffer, segment) {
|
|
110
128
|
// TODO: use socket/crud/file with room using the url to get one or more segments and append
|
|
111
129
|
let segments = []
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
|
|
130
|
+
let data
|
|
131
|
+
if (segment.array && segment.object) {
|
|
132
|
+
data = { method: 'object.read', ...segment }
|
|
115
133
|
data = await crud.send(data)
|
|
116
|
-
if (
|
|
134
|
+
if (segment.key) {
|
|
117
135
|
// TODO: utils.getValuefromObject
|
|
118
136
|
if (Array.isArray(data.object[0][key]))
|
|
119
137
|
segments.push(...data.object[0][key])
|
|
@@ -121,9 +139,15 @@ async function getSegment(sourceBuffer, segmentConfig) {
|
|
|
121
139
|
segments.push(data.object[0][key])
|
|
122
140
|
} else
|
|
123
141
|
segments.push(...data.object)
|
|
124
|
-
|
|
125
|
-
|
|
142
|
+
segment.src = segments[0]
|
|
143
|
+
segment.src = await segment.src.text();
|
|
144
|
+
// TODO: handle segment array as
|
|
145
|
+
} else if (segment.src) {
|
|
146
|
+
// TODO: handle 404, or whether src was fetched or not
|
|
147
|
+
segment.src = await fetch(segment.src);
|
|
148
|
+
segment.src = await segment.src.text();
|
|
126
149
|
}
|
|
150
|
+
|
|
127
151
|
appendSegment(sourceBuffer, segment)
|
|
128
152
|
}
|
|
129
153
|
|
|
@@ -140,13 +164,16 @@ async function appendSegment(sourceBuffer, segment) {
|
|
|
140
164
|
} else if (segment.src instanceof Blob) {
|
|
141
165
|
arrayBuffer = await segment.src.arrayBuffer();
|
|
142
166
|
} else {
|
|
143
|
-
|
|
167
|
+
arrayBuffer = base64ToArrayBuffer(segment.src);
|
|
168
|
+
|
|
169
|
+
// arrayBuffer = await segment.src.arrayBuffer();
|
|
144
170
|
}
|
|
145
171
|
|
|
146
172
|
// Wait for the source buffer to be ready for updates
|
|
147
173
|
if (sourceBuffer.updating) await new Promise(resolve => sourceBuffer.addEventListener('updateend', resolve, { once: true }));
|
|
148
174
|
|
|
149
175
|
sourceBuffer.appendBuffer(arrayBuffer);
|
|
176
|
+
console.log(sourceBuffer)
|
|
150
177
|
}
|
|
151
178
|
|
|
152
179
|
function isBuffered(element, currentTime) {
|
package/src/index.js
CHANGED
|
@@ -1295,4 +1295,4 @@ Actions.init([
|
|
|
1295
1295
|
|
|
1296
1296
|
init();
|
|
1297
1297
|
|
|
1298
|
-
export default { init, read, save, getData, getObject, reset, elements, keys, forms, debounce, getAttributes };
|
|
1298
|
+
export default { init, read, save, getData, getObject, reset, elements, keys, forms, debounce, getAttributes, setTypeValue };
|