@kolbo/mcp 1.55.0 → 1.55.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/package.json +1 -1
- package/src/apps/widgets/upload.js +19 -2
package/package.json
CHANGED
|
@@ -123,7 +123,8 @@ function addFiles(list) {
|
|
|
123
123
|
if (items.length >= maxFiles) break;
|
|
124
124
|
var f = list[i];
|
|
125
125
|
var kind = classify(f.name);
|
|
126
|
-
var it = { file: f, kind: kind, status: 'queued', pct: 0, url: null, err: null, id: nextItemId
|
|
126
|
+
var it = { file: f, kind: kind, status: 'queued', pct: 0, url: null, err: null, id: nextItemId++, thumb: null };
|
|
127
|
+
if (kind === 'image') { try { it.thumb = URL.createObjectURL(f); } catch (e) {} }
|
|
127
128
|
var allowedKinds = state.kinds && state.kinds.length ? state.kinds : ['image','video','audio','document'];
|
|
128
129
|
if (!kind || allowedKinds.indexOf(kind) === -1) {
|
|
129
130
|
it.status = 'error'; it.err = 'Unsupported file type';
|
|
@@ -201,9 +202,12 @@ function rowHtml(it) {
|
|
|
201
202
|
var bar = it.status === 'uploading'
|
|
202
203
|
? '<div style="height:3px;border-radius:2px;background:var(--surface);margin-top:5px;overflow:hidden"><div id="bar-' + it.id + '" style="height:100%;width:' + it.pct + '%;background:var(--accent,#7c6cff);transition:width .2s"></div></div>'
|
|
203
204
|
: '';
|
|
205
|
+
var left = it.thumb
|
|
206
|
+
? '<img data-thumb="' + it.id + '" src="' + it.thumb + '" alt="" style="width:34px;height:34px;object-fit:cover;border-radius:7px;flex:none;border:1px solid var(--border);background:var(--surface)">'
|
|
207
|
+
: '<span>' + icon + '</span>';
|
|
204
208
|
return '<div id="row-' + it.id + '" style="padding:8px 10px;border:1px solid var(--border);border-radius:10px;margin-bottom:6px;background:var(--surface)">' +
|
|
205
209
|
'<div style="display:flex;align-items:center;gap:8px;font-size:12.5px">' +
|
|
206
|
-
|
|
210
|
+
left +
|
|
207
211
|
'<span style="flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="' + esc(it.file.name) + '">' + esc(it.file.name) + '</span>' +
|
|
208
212
|
'<span style="color:var(--text-muted);font-size:11px">' + fmtSize(it.file.size) + '</span>' +
|
|
209
213
|
'<span id="status-' + it.id + '" style="font-size:11.5px">' + right + '</span>' +
|
|
@@ -219,6 +223,19 @@ function renderRow(it) {
|
|
|
219
223
|
|
|
220
224
|
function render() {
|
|
221
225
|
el('rows').innerHTML = items.map(rowHtml).join('');
|
|
226
|
+
// Thumbnail fallback chain: local blob preview -> CDN URL (allowlisted in the
|
|
227
|
+
// host CSP) once uploaded -> plain type icon.
|
|
228
|
+
Array.prototype.forEach.call(el('rows').querySelectorAll('[data-thumb]'), function (img) {
|
|
229
|
+
img.onerror = function () {
|
|
230
|
+
var id = Number(img.getAttribute('data-thumb'));
|
|
231
|
+
for (var i = 0; i < items.length; i++) {
|
|
232
|
+
if (items[i].id !== id) continue;
|
|
233
|
+
if (items[i].url && img.src !== items[i].url) { img.src = items[i].url; return; }
|
|
234
|
+
items[i].thumb = null;
|
|
235
|
+
}
|
|
236
|
+
render();
|
|
237
|
+
};
|
|
238
|
+
});
|
|
222
239
|
Array.prototype.forEach.call(el('rows').querySelectorAll('[data-retry]'), function (a) {
|
|
223
240
|
a.onclick = function (e) {
|
|
224
241
|
e.preventDefault();
|