fix(frontend): resolve iOS file upload restriction

Omit `accept` attribute on iOS so payload files are not greyed out in the Files app. Also drops unused lua support.
Fixes #39
This commit is contained in:
najdek committed 2026-06-12 21:02:09 +02:00
1 parent 5d33ce1c8b
commit 21f4fded71
3 files changed
+13 -6

No files matched your search

+8 -2
View File
@@ -161,7 +161,7 @@ function App() {
}
const loadPayload = async (path) => {
const name = path.split('/').pop().replace(/\.(elf|bin|lua)$/i, '').replace(/_/g, ' ')
const name = path.split('/').pop().replace(/\.(elf|bin)$/i, '').replace(/_/g, ' ')
setLoading(true)
setActiveLoadingName(name)
try {
@@ -198,6 +198,12 @@ function App() {
input.value = ''
if (!file) return
const ext = file.name.split('.').pop().toLowerCase();
if (ext !== 'elf' && ext !== 'bin') {
addToast("Unsupported file type. Only .elf and .bin files are allowed.", "error");
return;
}
try {
const res = await fetch(`/manage:check?filename=${encodeURIComponent(file.name)}`)
const data = await res.json()
@@ -521,7 +527,7 @@ function App() {
key={p}
path={p}
onClick={() => loadPayload(p)}
isLoading={loading && activeLoadingName === p.split('/').pop().replace(/\.(elf|bin|lua)$/i, '').replace(/_/g, ' ')}
isLoading={loading && activeLoadingName === p.split('/').pop().replace(/\.(elf|bin)$/i, '').replace(/_/g, ' ')}
sourceName={config.MULTI_SOURCES_ENABLED ? (payloadMeta[p.split('/').pop()]?.source_name || null) : null}
/>
))
+3 -3
View File
@@ -1,7 +1,7 @@
import React, { useState, useEffect, useMemo } from 'react'
import { CloudDownload, Upload, Package, Database, RefreshCw, Trash2, Loader2, AlertTriangle, HardDrive, Usb, ChevronDown, Globe } from 'lucide-react'
import { QRCodeSVG } from 'qrcode.react'
import { cn, isPS5, parsePayloadName } from '../../utils/helpers'
import { cn, isPS5, isIOS, parsePayloadName } from '../../utils/helpers'
import PayloadName from '../ui/PayloadName'
const StorageHub = ({ payloads, payloadMeta, onInstall, onDelete, onUpload, onImportFromUsb, config, ip, scrollTarget, onClearScrollTarget }) => {
@@ -62,7 +62,7 @@ const StorageHub = ({ payloads, payloadMeta, onInstall, onDelete, onUpload, onIm
const getBaseName = (filename) => {
if (!filename) return '';
let clean = filename.replace(/\.(elf|bin|lua)$/i, '');
let clean = filename.replace(/\.(elf|bin)$/i, '');
const versionMatch = clean.match(/[_-]v?(\d+[\d.a-z-]+)/i);
if (versionMatch) clean = clean.replace(versionMatch[0], '');
return clean.replace(/[_-]ps[45]$/i, '');
@@ -125,7 +125,7 @@ const StorageHub = ({ payloads, payloadMeta, onInstall, onDelete, onUpload, onIm
<label className="inline-flex items-center space-x-4 px-10 py-5 bg-ps-blue hover:bg-ps-blue/80 text-white rounded-[1.25rem] font-bold tracking-tight text-xl cursor-pointer transition-all shrink-0 transform active:scale-95">
<Upload className="w-7 h-7" />
<span>Upload ELF Payload</span>
<input type="file" className="hidden" onChange={onUpload} accept=".elf,.bin,.lua" />
<input type="file" className="hidden" onChange={onUpload} accept={isIOS ? undefined : ".elf,.bin"} />
</label>
)}
</div>
+2 -1
View File
@@ -2,6 +2,7 @@ import { clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'
export const isPS5 = /PlayStation/i.test(navigator.userAgent);
export const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
export function cn(...inputs) {
return twMerge(clsx(inputs))
@@ -14,7 +15,7 @@ export const parsePayloadName = (path) => {
return { displayName: `Delay (${ms / 1000}s)`, version: null, isDelay: true };
}
let name = path.split('/').pop().replace(/\.(elf|bin|lua)$/i, '');
let name = path.split('/').pop().replace(/\.(elf|bin)$/i, '');
// Try to find version pattern like _v1.0 or -v1.0 or _1.0
const versionMatch = name.match(/[_-](v?\d+[\d.a-z-]+)/i);