The map code getter utility allow you to get the compressed code in base64 of a map
In the root folder I put two files for sample, the file sample-base64.txt
and the file sample-payload.json
, you can get the code of a sample file
with mcg with this command:
NOTE: This sample command only is tested in bash
mcg "$(cat ./sample-base64.txt)" 'jsx'
Where 'jsx' is the extension of the file and the first argument is the base64 to analyze
The default extension is
txt
, it's not required, but the base64 argument is required
the common structure of a uncompressed map base64 is like in the file
sample-payload.json
:
{
"version": 3,
"mappings": ";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEO,aAAMA,gBAAgBC;AAEtB,aAAMC,wBAAwB,CAAC;AAAA,EAAEC;AAAAA,MAAe;AAAA;AACrD,QAAM;AAAA,IAAEC;AAAAA,IAAMC;AAAAA,IAAaC;AAAAA,MAAaC;AACxC,QAAM;AAAA,IAAEC;AAAAA,IAAaC;AAAAA,IAAcC;AAAAA,MAAeC;AAClD,QAAM;AAAA,IAAEC;AAAAA,MAAeC;AACvB,QAAM;AAAA,IAAEC;AAAAA,IAAaC;AAAAA,IAAcC;AAAAA,MAAeC;AAElD,SACE,wBAAC,cAAc,UAAf;AAAA,IAAwB,OAAO;AAAA,MAC7Bb;AAAAA,MACAC;AAAAA,MACAC;AAAAA,MACAE;AAAAA,MACAC;AAAAA,MACAC;AAAAA,MACAE;AAAAA,MACAE;AAAAA,MACAC;AAAAA,MACAC;AAAAA;AAAAA,IAVF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;GAPSd;UAC6BK,SACUI,eAC3BE,eAC2BI;AAAAA;KAJvCf;;;;;;;;;;;;;",
"names": [
"globalContext",
"createContext",
"GlobalContextProvider",
"children",
"todo",
"loadingTodo",
"getTodos",
"useTodo",
"createdTodo",
"creatingTodo",
"createTodo",
"useCreateTodo",
"deleteTodo",
"useDeleteTodo",
"updatedTodo",
"updatingTodo",
"updateTodo",
"useUpdateTodo"
],
"sources": [
"/home/gabriel/Code/javascript/todo-app/app/src/context/global.context.jsx"
],
"sourcesContent": [
"import React, { createContext } from 'react'\nimport { useTodo } from '../hooks/use-todo.hook'\nimport { useCreateTodo } from '../hooks/use-create-todo.hook'\nimport { useDeleteTodo } from '../hooks/use-delete-todo.hook'\nimport { useUpdateTodo } from '../hooks/use-update-todo.hook'\n\nexport const globalContext = createContext()\n\nexport const GlobalContextProvider = ({ children }) => {\n const { todo, loadingTodo, getTodos } = useTodo()\n const { createdTodo, creatingTodo, createTodo } = useCreateTodo()\n const { deleteTodo } = useDeleteTodo()\n const { updatedTodo, updatingTodo, updateTodo } = useUpdateTodo()\n\n return (\n <globalContext.Provider value={{\n todo,\n loadingTodo,\n getTodos,\n createdTodo,\n creatingTodo,\n createTodo,\n deleteTodo,\n updatedTodo,\n updatingTodo,\n updateTodo,\n }}>\n {children}\n </globalContext.Provider>\n )\n}\n"
]
}
The script get with json-parser
the sourcesContent
with the command json-parser --stdin '.sourcesContent[0]'
and then show it with batcat
The required os for the perfectly work of this script is a gnu linux based distribution, it's only tested in Arch Linux, but you can test it with Ubuntu or another linux distribution, and all will be works too, if not please open an issue.
The script is writted in bash, because it, it not works in windows.
To install mcg, the requirements are:
- json-parser
- bat: In arch linux you can install it with
pacman
: sudo pacman -S bat - base64: It's installed by default in some linux distributions
First clone the project
mkdir -p ~/repo
cd ~/repo
git clone https://github.com/AlphaTechnolog/mcg mcg
cd mcg
Then install with the install.sh
script:
sudo ./install.sh
Or with make:
sudo make install
It read the rules in the
Makefile
, inArch Linux
check ifmake
andgcc
in some cases it's not installed (like my case, I install it manuallysudo pacman -S gcc make
)
If you want to uninstall it, you can remove the binary in /usr/bin
:
sudo rm /usr/bin/mcg
Done!
If you have a base64 like this:
ewogICJ2ZXJzaW9uIjogMywKICAibWFwcGluZ3MiOiAiOzs7Ozs7Ozs7Ozs7Ozs7QUFBQTtBQUNB
O0FBQ0E7QUFDQTtBQUNBOztBQUVPLGFBQU1BLGdCQUFnQkM7QUFFdEIsYUFBTUMsd0JBQXdCLENB
QUM7QUFBQSxFQUFFQztBQUFBQSxNQUFlO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
"createContext",
"GlobalContextProvider",
"children",
"todo",
"loadingTodo",
"getTodos",
"useTodo",
"createdTodo",
"creatingTodo",
"createTodo",
"useCreateTodo",
"deleteTodo",
"useDeleteTodo",
"updatedTodo",
"updatingTodo",
"updateTodo",
"useUpdateTodo"
],
"sources": [
"/home/gabriel/Code/javascript/todo-app/app/src/context/global.context.jsx"
],
"sourcesContent": [
"import React, { createContext } from 'react'\nimport { useTodo } from '../hooks/use-todo.hook'\nimport { useCreateTodo } from '../hooks/use-create-todo.hook'\nimport { useDeleteTodo } from '../hooks/use-delete-todo.hook'\nimport { useUpdateTodo } from '../hooks/use-update-todo.hook'\n\nexport const globalContext = createContext()\n\nexport const GlobalContextProvider = ({ children }) => {\n const { todo, loadingTodo, getTodos } = useTodo()\n const { createdTodo, creatingTodo, createTodo } = useCreateTodo()\n const { deleteTodo } = useDeleteTodo()\n const { updatedTodo, updatingTodo, updateTodo } = useUpdateTodo()\n\n return (\n <globalContext.Provider value={{\n todo,\n loadingTodo,\n get