Removed sourcemap

This commit is contained in:
SwingTheVine 2025-07-27 10:55:39 -04:00
parent f16005b10b
commit 4c21a2fb89
7 changed files with 12 additions and 100 deletions

View file

@ -7,27 +7,6 @@ on:
jobs:
# Updates the Auto branch to match Main
update-auto:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Update Auto To Main
run: |
git fetch origin
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git checkout auto || git checkout -b auto
git reset --hard origin/main
git push --force origin auto
# Builds the code
# This is bundling, obfuscating, version bumping, etc.
build:
@ -36,17 +15,9 @@ jobs:
runs-on: ubuntu-latest
needs: [update-auto] # Needs the update-auto job to finish first
outputs:
msg: ${{ steps.get-commit-message.outputs.MSG }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: auto # Checks out the auto branch
fetch-depth: 0
- name: Set up Node
uses: actions/setup-node@v4
@ -85,63 +56,14 @@ jobs:
id: get-commit-message
run: echo "MSG=$(git log -1 --pretty=%B)" >> $GITHUB_OUTPUT
# This should happen on 'auto' branch
- name: Commit and push built script
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git checkout auto || git checkout -b auto
git add dist/*
git add src/BlueMarble.meta.js
git add package.json
git add docs/README.md
git commit -m "Bumped version; ${{ steps.get-commit-message.outputs.MSG }}" || echo "No changes to commit"
git push
update-map:
permissions:
contents: write
runs-on: ubuntu-latest
needs: [update-auto, build] # Needs the update-auto and build jobs to finish first
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: auto # Checks out the auto branch
fetch-depth: 0
- name: Get SHA of origin/auto
run: |
git fetch origin auto
AUTO_SHA=$(git rev-parse origin/auto)
echo "Auto SHA: $AUTO_SHA"
echo "AUTO_SHA=$AUTO_SHA" >> $GITHUB_ENV
- name: Update Source Map URL
run: |
sed -i "s|sourceMappingURL=.*|sourceMappingURL=https://raw.githubusercontent.com/${{ github.repository }}/${AUTO_SHA}/dist/BlueMarble.user.js.map|" dist/BlueMarble.user.js
echo "Updated sourceMappingURL:"
grep 'sourceMappingURL=' dist/BlueMarble.user.js
- name: Commit New Source Map URL
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add dist/BlueMarble.user.js
git commit -m "Merge version; ${{ needs.build.outputs.MSG }}" || echo "No changes to commit"
git push
- name: Merge Auto -> Main
run: |
git fetch origin
git checkout origin/main -B main
git merge --squash origin/auto
git commit -m "Release version; ${{ needs.build.outputs.MSG }}" || echo "No changes to commit"
git push origin main

View file

@ -4,7 +4,6 @@
* 2. Bundle the JS files into one file (esbuild)
* 3. Bundle the CSS files into one file (esbuild)
* 4. Compress & obfuscate the bundled JS file (terner)
* 5. Create a sourcemap
* @since 0.0.6
*/
@ -55,23 +54,16 @@ const resultEsbuild = await esbuild.build({
platform: 'browser', // The platform the bundled code will be operating on
legalComments: 'inline', // What level of legal comments are preserved? (Hard: none, Soft: inline)
minify: false, // Should the code be minified?
write: false, // Should we write the outfile?
sourcemap: true,
write: false, // Should we write the outfile to the disk?
}).catch(() => process.exit(1));
// Retrieves the JS file and map file
const resultEsbuildJS = resultEsbuild.outputFiles.find(file => file.path.endsWith('.js'));
const resultEsbuildMap = resultEsbuild.outputFiles.find(file => file.path.endsWith('.map'));
// Obfuscates the JS file
let resultTerser = await terser.minify(resultEsbuildJS.text, {
sourceMap: {
//content: resultEsbuildMap.text, // The esbundle sourcemap
filename: 'BlueMarble.user.js', // The file to make a sourcemap for
url: ' ' // (This value is intentional) The sourcemap url to point to.
},
mangle: {
toplevel: true, // Obfuscate top-level class/function names
//toplevel: true, // Obfuscate top-level class/function names
keep_classnames: false, // Should class names be preserved?
keep_fnames: false, // Should function names be preserved?
reserved: [], // List of keywords to preserve
@ -83,11 +75,14 @@ let resultTerser = await terser.minify(resultEsbuildJS.text, {
},
format: {
comments: 'some' // Save legal comments
},
compress: {
dead_code: isGitHub, // Should unreachable code be removed?
drop_console: isGitHub, // Should console code be removed?
drop_debugger: isGitHub, // SHould debugger code be removed?
passes: 2 // How many times terser will compress the code
}
});
// Creates the sourcemap file
fs.writeFileSync('dist/BlueMarble.user.js.map', resultTerser.map.replace(`"sources":["0"]`, `"sources":["BlueMarble.user.js"]`), 'utf8');
// Adds the banner
fs.writeFileSync('dist/BlueMarble.user.js', metaContent + resultTerser.code, 'utf8');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -35,7 +35,7 @@
<a href="https://github.com/SwingTheVine/Wplace-BlueMarble/blob/main/LICENSE.txt" target="_blank"><img alt="Software License: MPL-2.0" src="https://img.shields.io/badge/Software_License-MPL--2.0-brightgreen?style=flat"></a>
<a href="https://discord.gg/tpeBPy46hf" target="_blank"><img alt="Contact Me" src="https://img.shields.io/badge/Contact_Me-gray?style=flat&logo=Discord&logoColor=white&logoSize=auto&labelColor=cornflowerblue"></a>
<a href="" target="_blank"><img alt="WakaTime" src="https://img.shields.io/badge/Coding_Time-35hrs_30mins-blue?style=flat&logo=wakatime&logoColor=black&logoSize=auto&labelColor=white"></a>
<a href="" target="_blank"><img alt="Total Patches" src="https://img.shields.io/badge/Total_Patches-197-black?style=flat"></a>
<a href="" target="_blank"><img alt="Total Patches" src="https://img.shields.io/badge/Total_Patches-200-black?style=flat"></a>
<a href="" target="_blank"><img alt="Total Lines of Code" src="https://tokei.rs/b1/github/SwingTheVine/Wplace-BlueMarble?category=code"></a>
<a href="" target="_blank"><img alt="Total Comments" src="https://tokei.rs/b1/github/SwingTheVine/Wplace-BlueMarble?category=comments"></a>
<a href="" target="_blank"><img alt="Build" src="https://github.com/SwingTheVine/Wplace-BlueMarble/actions/workflows/build.yml/badge.svg"></a>

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "wplace-bluemarble",
"version": "0.50.4",
"version": "0.50.7",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "wplace-bluemarble",
"version": "0.50.4",
"version": "0.50.7",
"devDependencies": {
"esbuild": "^0.25.0",
"terser": "^5.43.1"

View file

@ -57,10 +57,6 @@ export default class ApiHandler {
const nextLevelPixels = Math.ceil(Math.pow(Math.floor(dataJSON['level']) * Math.pow(30, 0.65), (1/0.65)) - dataJSON['pixelsPainted']); // Calculates pixels to the next level
const clog = console.log;
clog(dataJSON);
clog(dataJSON?.droplets);
overlay.updateInnerHTML('bm-user-name', `Username: <b>${Utils.escapeHTML(dataJSON['name'])}</b>`); // Updates the text content of the username field
overlay.updateInnerHTML('bm-user-droplets', `Droplets: <b>${new Intl.NumberFormat().format(dataJSON['droplets'])}</b>`); // Updates the text content of the droplets field
overlay.updateInnerHTML('bm-user-nextlevel', `Next level in <b>${new Intl.NumberFormat().format(nextLevelPixels)}</b> pixel${nextLevelPixels == 1 ? '' : 's'}`); // Updates the text content of the next level field