From 32c4c705f60e5d60e35d9918c309697b128be94f Mon Sep 17 00:00:00 2001 From: Dakedres Date: Mon, 22 Apr 2024 13:53:03 -0600 Subject: [PATCH] Fix everything up so it actually runs lol --- src/App.js | 2 -- src/EmulatedIDB.js | 22 ++++++++++++++++++++-- src/ModPackage.js | 11 +++++++---- view/init.js | 15 ++++++++------- view/main.html | 25 ------------------------- 5 files changed, 35 insertions(+), 40 deletions(-) diff --git a/src/App.js b/src/App.js index 40a5558..cc4d7ef 100755 --- a/src/App.js +++ b/src/App.js @@ -43,8 +43,6 @@ class App { const self = this, { arg, cli } = context - console.log(context) - if(arg.arguments.length > 0) { let path = $fs.utils.resolvePath(arg.arguments[0]) diff --git a/src/EmulatedIDB.js b/src/EmulatedIDB.js index accd0e7..fa5156f 100644 --- a/src/EmulatedIDB.js +++ b/src/EmulatedIDB.js @@ -1,5 +1,4 @@ -const localBasePath = '.config/xash/saves', - localExt = '.jso' +const constants = require('./util/constants.json') const callIfPresent = (func, args, fallback = false) => { if(typeof func === 'function') { @@ -9,6 +8,25 @@ const callIfPresent = (func, args, fallback = false) => { } } +// const pathToKey = (path) => { +// let key = $fs.utils.resolvePath(path) + +// if(key.startsWith('/a/')) { +// key.slice(3) +// } + +// if(key.endsWith('/')) { +// key = key.slice(0, -1) +// } + +// return key +// } + +const localBasePath = constants.storage.baseKey +const localExt = constants.storage.objectsInFilesystem.ext + +console.log('LOCAL BASE PATH', localBasePath) + class EmulatedIDB { constructor() { const self = this diff --git a/src/ModPackage.js b/src/ModPackage.js index c4424e3..c24a99d 100755 --- a/src/ModPackage.js +++ b/src/ModPackage.js @@ -22,8 +22,7 @@ const textDecoder = new TextDecoder('utf-8') class ModPackage { static async unpack(buffer, direct = false) { let asar = new Asar(buffer), - manifestString = textDecoder.decode( asar.get('manifest.json') ), - files = [ ...asar.contents ] + manifestString = textDecoder.decode( asar.get('manifest.json') ) const decompress = path => new Promise((resolve, reject) => { // gzip(asar.get(path), (error, data) => { @@ -35,13 +34,17 @@ class ModPackage { // resolve([ path, toArrayBuffer(data) ]) // }) + console.log(path) resolve([ path, asar.get(path) ]) }) - files.splice(files.indexOf('manifest.json'), 1) - files = files.map(decompress) + let files = asar.contents + .toSpliced(asar.contents.indexOf('manifest.json'), 1) + .map(decompress) files = await Promise.all(files) + + console.log(asar, files, manifestString) return direct ? { files, manifestString } : new this(new Map(files), manifestString) } diff --git a/view/init.js b/view/init.js index d69e522..a28a83c 100755 --- a/view/init.js +++ b/view/init.js @@ -220,7 +220,14 @@ function startXash() // showElement('loader1', false); // showElement('optionsTitle', false); // showElement('fSettings', false); - setupFS(); + instance.package.then(data => { + modPackage = data + script.src = modPackage.getURL(modPackage.manifest.entry) + console.log('PAYLOAD: ', script.src) + + setupFS(); + }) + Module.arguments = instance.arguments; Module.run = run = savedRun; // if( radioChecked('Zip') ) @@ -243,12 +250,6 @@ function startXash() // script.src = pkgMods.length>1?document.getElementById('selectPkg').value:pkgMods[0][0]; // } - instance.package.then(data => { - console.log('Loading package...') - modPackage = data - script.src = modPackage.getURL(modPackage.manifest.entry) - console.log('PAYLOAD: ', script.src) - }) showElement('canvas', true); diff --git a/view/main.html b/view/main.html index fb75587..0a7ac14 100755 --- a/view/main.html +++ b/view/main.html @@ -38,30 +38,6 @@ - - \ No newline at end of file