Dezinater / osrscachereader

A Javascript library that allows you to read Old-School Runescape game files
https://dezinater.github.io/osrscachereader/
BSD 2-Clause "Simplified" License
6 stars 2 forks source link

Swap wasm-bz2 for compressjs #5

Closed ESchouten closed 8 months ago

ESchouten commented 8 months ago

Solves #4 Swapped wasm-bz2 for compressjs since WASM compatibility seems hard for tools like vite or esbuild

Pinned web-worker 1.2 since 1.3.0 gave me an error.

NOTE: package-lock.json not updated since prebuilt binaries for canvas are not available for ARM mac, and npm fails to build it. I succeeded with pnpm, but did not want to include that lock file, so you have to run npm i yourself after this PR

ESchouten commented 8 months ago

@Dezinater added cache loading via downloading and unzipping remote and local zip files. Solves #1

Dezinater commented 8 months ago

Nice! This looks really good. Maybe this zip loading part can be a separate pull request. I think for the bz2 stuff we should leave this pull request open and confirm it works with multiple caches. But now that you've added zip loading we can actually have it automatically check so it's even better. What do you think?

Also I have a couple of ideas for the zip loading as well so it would be nice to have all that in a separate PR

ESchouten commented 8 months ago

@Dezinater Removed the unzip part from this PR and made a new one, #6 Though this one is somewhat important to me since I'm having no success with wasm-bz2 😛

Dezinater commented 8 months ago

Since it was a bit important to you I just checked a few cache versions manually with this PR and they seem to load fine (version 210-219) I also checked the documentation for compressjs and it seems like a C port of bz2 so I'm fairly confident this should be good going forward

I will merge it now

Dezinater commented 8 months ago

@ESchouten So it seems like I made a mistake with the testing and didn't properly test it. There is a problem on this branch with webpack now lol. I'm not entirely sure what the problem is but somewhere in compressjs it calls define() which webpack doesn't seem to handle too well. Other people have already had this same issue with webpack+compressjs

https://github.com/webpack/webpack/issues/5316 https://github.com/cruise-automation/webviz/pull/316

I really would like this repo to work with webpack and vite since I know other frameworks both depend on those. I won't revert this merge tho since it's basically the same problem either way.

If you want to see this error you can just run it with npm run dev and put some sample code in index-dev.js

Uncaught TypeError: Cannot read properties of undefined (reading 'apply')
    at req (amdefine.js:145:31)
    at stringRequire (amdefine.js:221:28)
    at amdRequire (amdefine.js:114:24)
    at eval (amdefine.js:178:24)
    at Array.map (<anonymous>)
    at runFactory (amdefine.js:177:25)
    at define (amdefine.js:278:13)
    at eval (main.js:3:1)
    at ./node_modules/compressjs/main.js (osrscachereader.js:93:1)
    at __webpack_require__ (osrscachereader.js:1313:42)
ESchouten commented 8 months ago

Will look into it this week

ESchouten commented 8 months ago

PR opened with fix: #8