feat: sync and update with all changes from solar-punk-ltd fork (#730)

* fix: swap error caused by invalid id and batchcount
* fix: enhance creation messages for admin drive and user drives
* fix: identity and wallet creation
* fix: asset preview types
* fix: fm search unicode text
* fix: feed identity and stamp usage
* fix: ui display changes
* fix: stamp buy and dilute
* fix: vite polyfill warning for stream
* fix: standard mode postage stamp purchase reserves incorrect size and duration
* fix: add syncing message for Bee node and update page state handling
* refactor: stamp depth and amount validation

---------

Co-authored-by: Balint Ujvari <balint.ujvari@solarpunk.buzz>
Co-authored-by: Bálint Ujvári <58116288+bosi95@users.noreply.github.com>
Co-authored-by: rolandlor <33499567+rolandlor@users.noreply.github.com>
This commit is contained in:
Ferenc Sárai
2026-04-02 14:53:20 +02:00
committed by GitHub
parent 4848b5be97
commit cb5adfe031
41 changed files with 627 additions and 380 deletions
+116
View File
@@ -137,3 +137,119 @@ export function packageFile(file: FilePath, pathOverwrite?: string): FilePath {
bytes: file.bytes,
}
}
export function getExtensionFromName(name: string): string {
const ext = name.split('.').pop()?.toLowerCase() || ''
const hasExtension = name.includes('.') && ext && ext !== name
return hasExtension ? ext : ''
}
const EXT_TO_MIME: Record<string, string> = {
mp4: 'video/mp4',
webm: 'video/webm',
ogv: 'video/ogg',
mp3: 'audio/mpeg',
m4a: 'audio/mp4',
aac: 'audio/aac',
wav: 'audio/wav',
ogg: 'audio/ogg',
png: 'image/png',
jpg: 'image/jpeg',
jpeg: 'image/jpeg',
gif: 'image/gif',
webp: 'image/webp',
avif: 'image/avif',
svg: 'image/svg+xml',
pdf: 'application/pdf',
txt: 'text/plain',
md: 'text/markdown',
json: 'application/json',
csv: 'text/csv',
html: 'text/html',
htm: 'text/html',
ico: 'image/vnd.microsoft.icon',
}
export function guessMime(name: string, mtdt?: Record<string, string> | undefined): { mime: string; ext: string } {
const md = mtdt?.mimeType || mtdt?.mime || mtdt?.['content-type']
const ext = getExtensionFromName(name)
if (md) return { mime: md, ext }
const mime = EXT_TO_MIME[ext] || 'application/octet-stream'
return { mime, ext }
}
export type Viewer = {
name: string
test: (mime: string) => boolean
render: (win: Window, url: string, mime: string, name: string) => void
}
const VIDEO_HTML = (u: string, title: string) =>
`<html><head><meta charset="utf-8"/><title>${title}</title></head><body style="margin:0;background:#000">
<video controls autoplay style="width:100%;height:100%" src="${u}"></video>
</body></html>`
const AUDIO_HTML = (u: string, title: string) =>
`<html><head><meta charset="utf-8"/><title>${title}</title></head><body>
<audio controls autoplay style="width:100%" src="${u}"></audio>
</body></html>`
const IMAGE_HTML = (u: string, title: string) =>
`<html><head><meta charset="utf-8"/><title>${title}</title></head><body style="margin:0;background:#111;display:grid;place-items:center;min-height:100vh">
<img style="max-width:100%;max-height:100vh" src="${u}" />
</body></html>`
export const VIEWERS: Viewer[] = [
{
name: 'video',
test: m => m.startsWith('video/'),
render: (w, url, mime, name) => {
w.document.write(VIDEO_HTML(url, name))
w.document.title = name
},
},
{
name: 'audio',
test: m => m.startsWith('audio/'),
render: (w, url, mime, name) => {
w.document.write(AUDIO_HTML(url, name))
w.document.title = name
},
},
{
name: 'image',
test: m => m.startsWith('image/'),
render: (w, url, mime, name) => {
w.document.write(IMAGE_HTML(url, name))
w.document.title = name
},
},
{
name: 'pdf',
test: m => m === 'application/pdf',
render: (w, url, mime, name) => {
w.document.title = name
w.location.href = url
},
},
{
name: 'html',
test: m => m === 'text/html',
render: (w, url, mime, name) => {
w.document.title = name
w.location.href = url
},
},
{
name: 'text-like',
test: m => m.startsWith('text/') || m === 'application/json' || m === 'text/markdown',
render: (w, url, mime, name) => {
w.document.title = name
w.location.href = url
},
},
]