diff --git a/src/cod/App.svelte b/src/cod/App.svelte index 0af9f59..741544c 100644 --- a/src/cod/App.svelte +++ b/src/cod/App.svelte @@ -6,6 +6,7 @@ import prismIcon from '../assets/prism-launcher.svg'; import type { SpawnSession } from './spawn'; import TerminalWindow from './TerminalWindow.svelte'; + import DropFile from '../vendor/DropFile.svelte'; import { type TerminalLine, type TerminalWindow as TerminalWindowModel, @@ -1441,70 +1442,102 @@ PY`, const sendTerminalInput = (id: string, input: string) => { session?.input(id, input); }; - -
+ const onDrop = async (files: File[]) => { + let transferFiles: Record = {}; + let script = '', n = 0; + for(const file of files){ + const buf = new Uint8Array(await file.arrayBuffer()); + let str: string = 'toBase64' in buf ? buf.toBase64() : btoa(String.fromCharCode(...buf)); + while(str){ + if(JSON.stringify(transferFiles).length >= 900_000){ + await session.transfer(transferFiles); + transferFiles = {}; + n++; + } + transferFiles[`${file.name}._${n}`] = str.slice(0,100_000); + str = str.slice(100_000); + if(str){ + await session.transfer(transferFiles); + transferFiles = {}; + n++; + } + } + script = `${script};cat ${file.name}._* | base64 -d > ${file.name};rm ${file.name}._*` + } + await session.transfer(transferFiles); + await startTaskTerminal({ + id: `decode-files-${Date.now()}`, + title: 'Decode files', + command: script + }) + } + -{#if showRelativeMouseHint || relativeMouseEnabled} -
- {relativeMouseEnabled - ? 'Relative mouse active. Press Esc to release.' - : 'Game detected. Ctrl+click the desktop for relative mouse.'} -
-{/if} - - - -
- +
+ +
+ Loading Cod +
+