0.1.8 • Published 8 months ago

@llllvvuu/dl-webapp-sources v0.1.8

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

Download original source code from public sourcemaps

Get original JavaScript/TypeScript files/project layout:

dl-webapp-sources -o my-react-app \
  https://app.com/chunk1.js https://app.com/chunk2.js.map localChunk.js localMap.js.map ...
  • sanitize output paths / pad relative parents
  • .js arguments
  • .js.map arguments
  • URL arguments
  • filename arguments
  • sourceMappingURL=data:...
  • sourceMappingURL=file:...
  • sourceMappingURL=http...
  • sourceMappingURL=<relativepath>
  • guess sourceMappingURL by adding .map (find sources that Chrome misses)
  • lookup from sourcesContent
  • lookup from sources paths

Installation

npm install -g @llllvvuu/dl-webapp-sources

CLI Usage

Automated crawler may not pass auth, and it may also miss asynchronously loaded JS. But, you can get a list of loaded JS files by manually logging in.

After logging in, paste into the console:

performance
  .getEntriesByType("resource")
  .map(resource => resource.name)
  .filter(name => name.endsWith(".js"))
  .map(name => `"${name}"`)
  .join(" ")

This gives you the CLI args for:

dl-webapp-sources ${JS_URLS} -o ${OUTPUT_DIRECTORY}

If you got anything interesting, go back and click around the app to load all of the chunks (if it's a SPA), and repeat.

Now you can try to add some create-react-app or create-next-app boilerplate to try to get the app to build.

⚠️ Sometimes axios gets 403; I will try to fix this if I have time, but in the meantime you can get around this by manually downloading .js.map from the browser and passing the local filepath into the CLI.

⚠️ Some sites clear the performance timeline, so the performance API won't list all of the JS files. If this happens you can try another method to get the list of JS files.

Library Usage

See the API reference at markdown/dl-webapp-sources.md.

Motivation

I created this solution since neither denands/sourcemapper, tehryanx/sourcemapper, nor paazmaya/shuji accept a list of multiple JS files, which is quite common with chunked webapps.

jonluca/source-map-cloner is a solution for crawling an HTML page.

dl-webapp-sources leaves auth/crawling to the user. It accepts a list of .js or .js.map.

Sometimes it can find sources that Google Chrome misses.

Credits

0.1.8

8 months ago

0.1.7

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago