mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-29 13:03:11 +00:00
EvenHub compatibility for iOS
This commit is contained in:
1 parent
617cdc39eb
commit
7e58c7c05f
40 files changed
+629
-176
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import { deletePathRecursively, readBinaryFile, writeBinaryFile } from '../../native/file-access';
|
||||
import { openEhpk, parseManifest, utf8Decode, type EvenHubManifest } from './ehpk';
|
||||
|
||||
/** Called on a worker on iOS. Hold only one expanded asset at a time. */
|
||||
export function extractPackage(path: string, directory: string): EvenHubManifest {
|
||||
try {
|
||||
const bytes = readBinaryFile(path);
|
||||
if (!bytes) throw new Error('Could not read the EHPK file.');
|
||||
const archive = openEhpk(bytes);
|
||||
const json = archive.files.get('app.json');
|
||||
if (!json) throw new Error('The EHPK package has no app.json.');
|
||||
const manifest = parseManifest(utf8Decode(json));
|
||||
if (!archive.files.has(`dist/${manifest.entrypoint}`)) throw new Error('The EHPK entrypoint is missing from dist/.');
|
||||
deletePathRecursively(directory);
|
||||
for (const name of archive.files.keys()) {
|
||||
if (!writeBinaryFile(`${directory}/${name}`, archive.files.get(name)!)) throw new Error(`Could not unpack ${name}.`);
|
||||
}
|
||||
return manifest;
|
||||
} catch (error) { deletePathRecursively(directory); throw error; }
|
||||
}
|
||||
Reference in new issue
Block a user