This project aims to make minified GAPI (https://apis.google.com/js/api.js) source code readable and understandable.
- To create accurate type definitions for TypeScript (examples: @types/gapi.client, @types/gapi)
- To create better optimized clone that will be distributed via NPM
api.js
only defines one public method:gapi.load
gapi.load
acceptslibraries
andcallbackOrConfig
arguments, as documented, butcallbackOrConfig
also has undocumented property:config
gapi.client
methods are defined in theclient
library that is being loaded bygapi.load
- Beautify code
- Go line-by-line
- Make that line more readable and easier to understand
- Leave original line commented out for future references
- Rename all minified variables (one letter, etc.)
- When renaming variables, do that in
ALL_CAPS
prefixed with__UM__
, likegapi.__UM__SOME_UNIX_TIME_NUMBER
- Try to rewrite this script and make sure that it works
- Probably add unit tests to make sure that we have a good understanding of how all parts work
- Try adding TypeScript, it may make rewriting easier since we don't have to keep in mind what that variable does/contains
Measured by appending api.js
script, loading client
lib and returning gapi
to the main testing script.
jsdom
- fast (1 second), minor differences from Chromepuppeteer
- fast (1 second), uses Chromeselenium
with headless Chrome - slowest (4 seconds), uses Chromegjstest
- can't build
Conclusion: Use puppeteer
because it's fast and uses Chrome.