@anglefeint/astro-theme 0.1.20 → 0.1.21
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/package.json
CHANGED
|
@@ -124,67 +124,40 @@ export function initRedQueenTv(prefersReducedMotion) {
|
|
|
124
124
|
preloadRetryTimers.add(id);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
function
|
|
127
|
+
function preloadDecoderData(item, token, attempt, done) {
|
|
128
128
|
if (token !== playToken || !isPlaying) return;
|
|
129
129
|
var tryCount = typeof attempt === 'number' ? attempt : 0;
|
|
130
130
|
var cachedData = mediaDataCache[item.url];
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
done(true);
|
|
131
|
+
function retryOrFail() {
|
|
132
|
+
if (tryCount >= PRELOAD_RETRY_MAX) {
|
|
133
|
+
done(false);
|
|
135
134
|
return;
|
|
136
135
|
}
|
|
137
|
-
var
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
var retryDelay = Math.min(1800, RETRY_BASE_MS * (tryCount + 1));
|
|
137
|
+
schedulePreloadRetry(function() {
|
|
138
|
+
preloadDecoderData(item, token, tryCount + 1, done);
|
|
139
|
+
}, retryDelay);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function verifyBuffer(buffer) {
|
|
143
|
+
mediaDataCache[item.url] = buffer;
|
|
144
|
+
var decoder = new ImageDecoder({ data: buffer, type: item.type });
|
|
145
|
+
decoder.tracks.ready.then(async function() {
|
|
146
|
+
var result = await decoder.decode({ frameIndex: 0 });
|
|
140
147
|
if (result && result.image && result.image.close) result.image.close();
|
|
141
148
|
done(true);
|
|
142
|
-
}).catch(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
var retryDelay = Math.min(1800, RETRY_BASE_MS * (tryCount + 1));
|
|
148
|
-
schedulePreloadRetry(function() {
|
|
149
|
-
preloadGif(item, token, tryCount + 1, done);
|
|
150
|
-
}, retryDelay);
|
|
151
|
-
});
|
|
149
|
+
}).catch(retryOrFail);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (cachedData instanceof ArrayBuffer) {
|
|
153
|
+
verifyBuffer(cachedData);
|
|
152
154
|
return;
|
|
153
155
|
}
|
|
154
156
|
|
|
155
157
|
fetch(resolveItemUrl(item))
|
|
156
158
|
.then(function(response) { return response.arrayBuffer(); })
|
|
157
|
-
.then(
|
|
158
|
-
|
|
159
|
-
if (typeof ImageDecoder === 'undefined') {
|
|
160
|
-
done(true);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
var decoder = new ImageDecoder({ data: buffer, type: item.type });
|
|
164
|
-
decoder.tracks.ready.then(async function() {
|
|
165
|
-
var result = await decoder.decode({ frameIndex: 0 });
|
|
166
|
-
if (result && result.image && result.image.close) result.image.close();
|
|
167
|
-
done(true);
|
|
168
|
-
}).catch(function() {
|
|
169
|
-
if (tryCount >= PRELOAD_RETRY_MAX) {
|
|
170
|
-
done(false);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
var retryDelay = Math.min(1800, RETRY_BASE_MS * (tryCount + 1));
|
|
174
|
-
schedulePreloadRetry(function() {
|
|
175
|
-
preloadGif(item, token, tryCount + 1, done);
|
|
176
|
-
}, retryDelay);
|
|
177
|
-
});
|
|
178
|
-
}).catch(function() {
|
|
179
|
-
if (tryCount >= PRELOAD_RETRY_MAX) {
|
|
180
|
-
done(false);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
var retryDelay = Math.min(1800, RETRY_BASE_MS * (tryCount + 1));
|
|
184
|
-
schedulePreloadRetry(function() {
|
|
185
|
-
preloadGif(item, token, tryCount + 1, done);
|
|
186
|
-
}, retryDelay);
|
|
187
|
-
});
|
|
159
|
+
.then(verifyBuffer)
|
|
160
|
+
.catch(retryOrFail);
|
|
188
161
|
}
|
|
189
162
|
|
|
190
163
|
function preloadImage(item, token, attempt, done) {
|
|
@@ -235,8 +208,9 @@ export function initRedQueenTv(prefersReducedMotion) {
|
|
|
235
208
|
if (left <= 0) finish(!failed);
|
|
236
209
|
}
|
|
237
210
|
|
|
211
|
+
var hasImageDecoder = typeof ImageDecoder !== 'undefined';
|
|
238
212
|
playlist.forEach(function(item) {
|
|
239
|
-
if (
|
|
213
|
+
if (hasImageDecoder) preloadDecoderData(item, token, 0, markDone);
|
|
240
214
|
else preloadImage(item, token, 0, markDone);
|
|
241
215
|
});
|
|
242
216
|
}
|