From 696576de0f261e2c844c70abc076fff09efa4b0f Mon Sep 17 00:00:00 2001
From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com>
Date: Sun, 7 Apr 2024 07:37:00 +0200
Subject: [PATCH] Pkgs + test CSP + cookies -> localStorage
---
.github/workflows/eslint.yml | 2 +
_headers | 7 +
manifest.json => assets/manifest.json | 2 +-
assets/script.js | 110 ++++++++--------
assets/style.css | 6 +-
eslint.config.js | 3 +
index.html | 20 +--
minify.js | 117 ++++++++++++-----
package-lock.json | 180 ++++++++++----------------
package.json | 10 +-
serviceworker.js | 4 +-
wrangler.toml | 13 ++
12 files changed, 248 insertions(+), 226 deletions(-)
create mode 100644 _headers
rename manifest.json => assets/manifest.json (95%)
create mode 100644 wrangler.toml
diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml
index 825ec18..8a39c62 100644
--- a/.github/workflows/eslint.yml
+++ b/.github/workflows/eslint.yml
@@ -1,6 +1,7 @@
name: ESLint
on:
+ pull_request:
push:
jobs:
@@ -15,6 +16,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 21
+ cache: "npm"
- name: "🛸 install eslint html plugins"
run: npm i --omit=optional
diff --git a/_headers b/_headers
new file mode 100644
index 0000000..5a77076
--- /dev/null
+++ b/_headers
@@ -0,0 +1,7 @@
+/*
+ Content-Security-Policy-Report-Only: default-src 'none' 'report-sample'; script-src-elem 'self'; script-src-attr 'unsafe-inline'; style-src-elem 'self'; style-src-attr 'unsafe-inline'; img-src 'self'; connect-src 'self' https://sh0rt.zip/ https://cloudflareinsights.com/cdn-cgi/rum https://static.cloudflareinsights.com; form-action 'none'; frame-ancestors 'none'; worker-src 'self'; manifest-src 'self'; report-uri https://api.tomatenkuchen.com/csp-violation
+ Report-To: {"group":"default","max_age":2592000,"endpoints":[{"url":"https://api.tomatenkuchen.com/csp-violation"}],"include_subdomains":false}
+ Cross-Origin-Opener-Policy: same-origin
+ X-Frame-Options: DENY
+ X-Content-Type-Options: nosniff
+ Referrer-Policy: strict-origin-when-cross-origin
diff --git a/manifest.json b/assets/manifest.json
similarity index 95%
rename from manifest.json
rename to assets/manifest.json
index 1388db3..f08278f 100644
--- a/manifest.json
+++ b/assets/manifest.json
@@ -51,7 +51,7 @@
"scope": "/",
"theme_color": "#216E4A",
"lang": "en",
- "description": "A tool which allows you to analyze Minecraft Java data and resource packs, and generate stats and share from them.",
+ "description": "A tool which allows you to analyze Minecraft Java data and resource packs, and generate shareable stats from them.",
"screenshots": [
{
"src": "/assets/images/showcase1.png",
diff --git a/assets/script.js b/assets/script.js
index e61a16f..922f5ed 100644
--- a/assets/script.js
+++ b/assets/script.js
@@ -1,21 +1,12 @@
-// Cookie/"load" code modified from https://github.com/DEVTomatoCake/dashboard/blob/700b21999a671f4e9c32ba4a1a35f94156db11d4/assets/js/script.js#L16-L31
-
-function setCookie(name = "", value = "", days = void 0) {
- let cookie = name + "=" + value + ";path=/;Secure;"
- if (days) cookie += "expires=" + new Date(Date.now() + 1000 * 60 * 60 * 24 * days).toUTCString() + ";"
-
- document.cookie = cookie
-}
-function getCookie(name) {
- for (const rawCookie of document.cookie.split(";")) {
- const cookie = rawCookie.trim()
- if (cookie.split("=")[0] == name) return cookie.substring(name.length + 1, cookie.length)
- }
- return void 0
-}
+// "load" code modified from https://github.com/DEVTomatoCake/dashboard/blob/700b21999a671f4e9c32ba4a1a35f94156db11d4/assets/js/script.js#L16-L31
const requestVersions = async () => {
- const res = await fetch("https://raw.githubusercontent.com/misode/mcmeta/summary/versions/data.json")
+ const res = await fetch("https://raw.githubusercontent.com/misode/mcmeta/summary/versions/data.json", {
+ headers: {
+ Accept: "application/json",
+ "User-Agent": "DEVTomatoCake/Pack-Analyzer"
+ }
+ })
const json = await res.json()
window.versions = json.map(ver => ({
name: ver.id,
@@ -91,11 +82,11 @@ let rpExclusive = {
textures: 0
}
-window.addEventListener("load", () => {
- if (getCookie("theme") == "light") document.body.classList.add("light")
+window.addEventListener("DOMContentLoaded", () => {
+ if (localStorage.getItem("theme") == "light") document.body.classList.add("light")
else if (window.matchMedia("(prefers-color-scheme: light)").matches) {
document.body.classList.add("light")
- setCookie("theme", "light", 365)
+ localStorage.setItem("theme", "light")
}
const params = new URLSearchParams(location.search)
@@ -122,6 +113,46 @@ window.addEventListener("load", () => {
mainScan(true)
}
+ document.getElementById("clear-results").addEventListener("click", () => {
+ document.getElementById("progress").innerText = ""
+ document.getElementById("result").innerHTML = ""
+ document.getElementById("resultButtons").hidden = true
+ document.getElementById("shareImage").style.display = "none"
+ if (interval) clearInterval(interval)
+ })
+ document.getElementById("toggle-theme").addEventListener("click", () => {
+ localStorage.setItem("theme", document.body.classList.toggle("light") ? "light" : "dark")
+ })
+ document.getElementById("about-button").addEventListener("click", () => openDialog(document.getElementById("aboutDialog")))
+
+ document.getElementById("select-folder").addEventListener("click", () => {
+ if (interval) clearInterval(interval)
+ selected = null
+
+ const input = document.createElement("input")
+ input.type = "file"
+ input.webkitdirectory = true
+ input.onchange = e => {
+ selected = e.target.files
+ mainScan()
+ }
+ if ("showPicker" in HTMLInputElement.prototype) input.showPicker()
+ else input.click()
+ })
+ document.getElementById("select-zip").addEventListener("click", () => {
+ if (interval) clearInterval(interval)
+
+ const input = document.createElement("input")
+ input.type = "file"
+ input.accept = ".zip"
+ input.onchange = e => handleZip(e.target.files[0])
+
+ if ("showPicker" in HTMLInputElement.prototype) input.showPicker()
+ else input.click()
+ })
+
+ for (const elem of document.getElementsByClassName("share")) elem.addEventListener("click", () => share(elem.dataset.type))
+
if (location.protocol == "https:" && "serviceWorker" in navigator) navigator.serviceWorker.register("/serviceworker.js")
})
@@ -182,18 +213,6 @@ function openDialog(dialog) {
}
}
-const toggleTheme = () => {
- setCookie("theme", document.body.classList.toggle("light") ? "light" : "dark", 365)
-}
-
-const clearResults = () => {
- document.getElementById("progress").innerText = ""
- document.getElementById("result").innerHTML = ""
- document.getElementById("resultButtons").hidden = true
- document.getElementById("shareImage").style.display = "none"
- if (interval) clearInterval(interval)
-}
-
async function share(type) {
let content = ""
if (type == "txt") content = document.getElementById("result").innerText
@@ -239,7 +258,7 @@ async function share(type) {
if (res.ok) {
document.getElementById("share-link").href = "https://sh0rt.zip/" + name
document.getElementById("share-link").innerText = "https://sh0rt.zip/" + name
- document.getElementById("share-img").src = "https://api.qrserver.com/v1/create-qr-code/?data=" + encodeURIComponent("https://sh0rt.zip/" + name) + "&size=150x150&qzone=2"
+ document.getElementById("share-img").src = "https://sh0rt.zip/qr/" + name
openDialog(document.getElementById("shareDialog"))
} else alert("Couldn't create link: " + json.error)
return
@@ -713,33 +732,6 @@ async function mainScan(hasData = false) {
}, 100)
}
-async function selectFolder() {
- if (interval) clearInterval(interval)
- selected = null
-
- const input = document.createElement("input")
- input.type = "file"
- input.webkitdirectory = true
- input.onchange = e => {
- selected = e.target.files
- mainScan()
- }
- if ("showPicker" in HTMLInputElement.prototype) input.showPicker()
- else input.click()
-}
-
-async function selectZip() {
- if (interval) clearInterval(interval)
-
- const input = document.createElement("input")
- input.type = "file"
- input.accept = ".zip"
- input.onchange = e => handleZip(e.target.files[0])
-
- if ("showPicker" in HTMLInputElement.prototype) input.showPicker()
- else input.click()
-}
-
function handleZip(file) {
selected = []
diff --git a/assets/style.css b/assets/style.css
index 92ff7d3..ea6add5 100644
--- a/assets/style.css
+++ b/assets/style.css
@@ -40,7 +40,7 @@ button {
border: none;
border-radius: 7px;
cursor: pointer;
- box-shadow: inset 0px -1px 2px rgba(17, 24, 39, .15), 0 0 0 0 transparent;
+ box-shadow: inset 0 -1px 2px rgba(17, 24, 39, .15), 0 0 0 0 transparent;
}
p {
@@ -91,11 +91,9 @@ a {
.indented {
margin-left: 25px;
}
-
.indented2 {
margin-left: 50px;
}
-
.indented3 {
margin-left: 75px;
}
@@ -134,7 +132,7 @@ summary {
height: 100%;
overflow: auto;
background-color: var(--dialog-shadow);
- transition: .3;
+ transition: .3s;
}
.dialog-content {
diff --git a/eslint.config.js b/eslint.config.js
index 0f55782..a39ad44 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -103,6 +103,7 @@ const rules = {
"prefer-const": 2,
"use-isnan": 2,
"valid-typeof": 2,
+ yoda: 2,
"@stylistic/js/array-bracket-spacing": 2,
"@stylistic/js/arrow-parens": [2, "as-needed"],
@@ -195,6 +196,8 @@ const rules = {
"unicorn/require-number-to-fixed-digits-argument": 2,
"unicorn/switch-case-braces": [2, "avoid"],
"unicorn/text-encoding-identifier-case": 2,
+ "unicorn/no-await-in-promise-methods": 2,
+ "unicorn/no-single-promise-in-promise-methods": 2,
"sonarjs/no-extra-arguments": 2,
"sonarjs/no-empty-collection": 2,
diff --git a/index.html b/index.html
index 42e25a9..e2995dd 100644
--- a/index.html
+++ b/index.html
@@ -10,7 +10,7 @@
-
+
@@ -23,17 +23,17 @@
Minecraft Java Data and Resource pack analyzer
Drop/paste a .zip or .mcfunction file, or select a folder below to analyze it!
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
+
diff --git a/minify.js b/minify.js
index a9a3320..e79c13d 100644
--- a/minify.js
+++ b/minify.js
@@ -1,5 +1,9 @@
+// Modified by TomatoCake from https://github.com/DEVTomatoCake/dashboard/blob/0a38551cd9aee972347b08e19a0c4ffaf537f8b7/minify.js
+
const fsPromises = require("node:fs").promises
+
const UglifyJS = require("uglify-js")
+const CleanCSS = require("clean-css")
const nameCache = {}
const defaultOptions = {
@@ -13,51 +17,102 @@ const defaultOptions = {
}
}
+const results = []
const minifyFile = async (path, options = {}) => {
const filename = path.split("/").pop()
- const result = UglifyJS.minify({
- [path]: await fsPromises.readFile(path, "utf8")
- }, {
- sourceMap: {
- root: "https://pack-analyzer.pages.dev/assets/",
- filename,
- url: filename + ".map"
- },
- warnings: "verbose",
- parse: {
- shebang: false
- },
- nameCache,
- mangle: true,
- ...defaultOptions,
- ...options
- })
+ const content = await fsPromises.readFile(path, "utf8")
+
+ let result = {}
+ if (filename.endsWith(".js")) {
+ result = UglifyJS.minify({
+ [path]: await fsPromises.readFile(path, "utf8")
+ }, {
+ sourceMap: {
+ root: "https://pack-analyzer.pages.dev/assets/",
+ filename,
+ url: filename + ".map"
+ },
+ warnings: "verbose",
+ parse: {
+ shebang: false
+ },
+ toplevel: true,
+ nameCache,
+ mangle: true,
+ ...defaultOptions,
+ ...options
+ })
+
+ if (result.error) throw result.error
+ if (result.warnings && result.warnings.length > defaultOptions.compress.passes) console.log(path, result.warnings)
+ } else if (filename.endsWith(".css")) {
+ const clean = new CleanCSS({
+ compatibility: {
+ colors: {
+ hexAlpha: true
+ },
+ properties: {
+ shorterLengthUnits: true,
+ urlQuotes: false
+ }
+ },
+ level: {
+ 2: {
+ mergeSemantically: true,
+ removeUnusedAtRules: true
+ }
+ },
+ inline: false,
+ sourceMap: true,
+ ...options
+ })
+
+ const output = clean.minify(content)
+ result = {
+ code: output.styles + "\n/*# sourceMappingURL=" + filename + ".map */",
+ map: output.sourceMap.toString().replace("$stdin", filename)
+ }
+
+ if (output.warnings.length > 0 || output.errors.length > 0) console.log(path, output.warnings, output.errors)
+ } else if (filename.endsWith(".json")) {
+ result = {
+ code: JSON.stringify(JSON.parse(content))
+ }
+ } else return console.error("Unknown minify file type: " + path)
- if (result.error) throw result.error
- if (result.warnings && result.warnings.length > defaultOptions.compress.passes) console.log(path, result.warnings)
+ if (result.code.length >= content.length) return console.log("No reduction for " + path + " (" + content.length + " -> " + result.code.length + ")")
if (process.env.MINIFY_ENABLED) {
await fsPromises.writeFile(path, result.code)
- await fsPromises.writeFile(path + ".map", result.map)
+ if (result.map) await fsPromises.writeFile(path + ".map", result.map)
}
+
+ results.push({
+ path: path.slice(2),
+ size: content.length,
+ compressed: result.code.length,
+ "% reduction": parseFloat((100 - (result.code.length / content.length * 100)).toFixed(1))
+ })
}
async function main() {
- await minifyFile("./assets/script.js", {
- toplevel: true,
- compress: {
- ...defaultOptions.compress,
- top_retain: ["selectFolder", "selectZip", "toggleTheme", "openDialog", "clearResults", "share"]
- },
- mangle: {
- reserved: ["selectFolder", "selectZip", "toggleTheme", "openDialog", "clearResults", "share"]
- }
- })
+ await minifyFile("./assets/script.js")
await minifyFile("./assets/jszip.js", {
- toplevel: true,
mangle: {
reserved: ["JSZip"]
}
})
+ await minifyFile("./serviceworker.js")
+
+ await minifyFile("./assets/style.css")
+ await minifyFile("./assets/manifest.json")
+
+ results.push({
+ path: "= Total",
+ size: results.reduce((acc, cur) => acc + cur.size, 0),
+ compressed: results.reduce((acc, cur) => acc + cur.compressed, 0),
+ "% reduction": parseFloat((100 - (results.reduce((acc, cur) => acc + cur.compressed, 0) / results.reduce((acc, cur) => acc + cur.size, 0) * 100)).toFixed(1))
+ })
+ console.table(results.sort((a, b) => a["% reduction"] - b["% reduction"]))
}
main()
diff --git a/package-lock.json b/package-lock.json
index 1457f61..ad953aa 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,16 +9,17 @@
"version": "2.0.0",
"license": "CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0",
"dependencies": {
+ "clean-css": "^5.3.3",
"uglify-js": "^3.17.4"
},
"devDependencies": {
- "@html-eslint/eslint-plugin": "^0.23.1",
- "@html-eslint/parser": "^0.24.0",
+ "@html-eslint/eslint-plugin": "^0.24.1",
+ "@html-eslint/parser": "^0.24.1",
"@stylistic/eslint-plugin-js": "^1.7.0",
"eslint": "^8.57.0",
"eslint-plugin-html": "^8.0.0",
- "eslint-plugin-sonarjs": "^0.24.0",
- "eslint-plugin-unicorn": "^51.0.1",
+ "eslint-plugin-sonarjs": "^0.25.1",
+ "eslint-plugin-unicorn": "^52.0.0",
"globals": "^15.0.0"
}
},
@@ -32,89 +33,18 @@
}
},
"node_modules/@babel/code-frame": {
- "version": "7.23.5",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz",
- "integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==",
+ "version": "7.24.2",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.2.tgz",
+ "integrity": "sha512-y5+tLQyV8pg3fsiln67BVLD1P13Eg4lh5RW9mF0zUuvLrv9uIQ4MCL+CRT+FTsBlBjcIan6PGsLcBN0m3ClUyQ==",
"dev": true,
"dependencies": {
- "@babel/highlight": "^7.23.4",
- "chalk": "^2.4.2"
+ "@babel/highlight": "^7.24.2",
+ "picocolors": "^1.0.0"
},
"engines": {
"node": ">=6.9.0"
}
},
- "node_modules/@babel/code-frame/node_modules/ansi-styles": {
- "version": "3.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
- "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
- "dev": true,
- "dependencies": {
- "color-convert": "^1.9.0"
- },
- "engines": {
- "node": ">=4"
- }
- },
- "node_modules/@babel/code-frame/node_modules/chalk": {
- "version": "2.4.2",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
- "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
- "dev": true,
- "dependencies": {
- "ansi-styles": "^3.2.1",
- "escape-string-regexp": "^1.0.5",
- "supports-color": "^5.3.0"
- },
- "engines": {
- "node": ">=4"
- }
- },
- "node_modules/@babel/code-frame/node_modules/color-convert": {
- "version": "1.9.3",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
- "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
- "dev": true,
- "dependencies": {
- "color-name": "1.1.3"
- }
- },
- "node_modules/@babel/code-frame/node_modules/color-name": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
- "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
- "dev": true
- },
- "node_modules/@babel/code-frame/node_modules/escape-string-regexp": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
- "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
- "dev": true,
- "engines": {
- "node": ">=0.8.0"
- }
- },
- "node_modules/@babel/code-frame/node_modules/has-flag": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
- "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
- "dev": true,
- "engines": {
- "node": ">=4"
- }
- },
- "node_modules/@babel/code-frame/node_modules/supports-color": {
- "version": "5.5.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
- "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
- "dev": true,
- "dependencies": {
- "has-flag": "^3.0.0"
- },
- "engines": {
- "node": ">=4"
- }
- },
"node_modules/@babel/helper-validator-identifier": {
"version": "7.22.20",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
@@ -125,14 +55,15 @@
}
},
"node_modules/@babel/highlight": {
- "version": "7.23.4",
- "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz",
- "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==",
+ "version": "7.24.2",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.2.tgz",
+ "integrity": "sha512-Yac1ao4flkTxTteCDZLEvdxg2fZfz1v8M4QpaGypq/WPDqg3ijHYbDfs+LG5hvzSoqaSZ9/Z9lKSP3CjZjv+pA==",
"dev": true,
"dependencies": {
"@babel/helper-validator-identifier": "^7.22.20",
"chalk": "^2.4.2",
- "js-tokens": "^4.0.0"
+ "js-tokens": "^4.0.0",
+ "picocolors": "^1.0.0"
},
"engines": {
"node": ">=6.9.0"
@@ -293,18 +224,18 @@
}
},
"node_modules/@html-eslint/eslint-plugin": {
- "version": "0.23.1",
- "resolved": "https://registry.npmjs.org/@html-eslint/eslint-plugin/-/eslint-plugin-0.23.1.tgz",
- "integrity": "sha512-2AU58FZSPPHjNJzuv08GfgU/nfrVgNI4Uj9y6KOaU5egzAf1DO5x6HeZwvS0MPBAduqoC0i1RqHNSQrzCcmB7A==",
+ "version": "0.24.1",
+ "resolved": "https://registry.npmjs.org/@html-eslint/eslint-plugin/-/eslint-plugin-0.24.1.tgz",
+ "integrity": "sha512-JwNDQBrNIWEPcxgSpla/2jaUXyQCqL7Xp8CmON4Bk5qg8MwiDLXOgjylfVC+tN52i8JeHWMca34I9DqBGRj9Qg==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
},
"node_modules/@html-eslint/parser": {
- "version": "0.24.0",
- "resolved": "https://registry.npmjs.org/@html-eslint/parser/-/parser-0.24.0.tgz",
- "integrity": "sha512-Q9mGP+g3ZmNMFMqXroIY/nhlWt5q3usfcaMlud7YRSgFnHr3EK/rzWFObHNpMmB4btDLc9FkzxsSHUgRd+qd0w==",
+ "version": "0.24.1",
+ "resolved": "https://registry.npmjs.org/@html-eslint/parser/-/parser-0.24.1.tgz",
+ "integrity": "sha512-O13xX/+Ldh0P7VZMpDDYc3XtWiE1cYm5QhVJ0VB5i7D8Q69HrrGN+5BjS17vkCoLTz+3zWWIiJv4oFmyS5LReA==",
"dev": true,
"dependencies": {
"es-html-parser": "^0.0.9"
@@ -341,9 +272,9 @@
}
},
"node_modules/@humanwhocodes/object-schema": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz",
- "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==",
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz",
+ "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==",
"dev": true
},
"node_modules/@nodelib/fs.scandir": {
@@ -401,9 +332,9 @@
}
},
"node_modules/@types/eslint": {
- "version": "8.56.5",
- "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.5.tgz",
- "integrity": "sha512-u5/YPJHo1tvkSF2CE0USEkxon82Z5DBy2xR+qfyYNszpX9qcs4sT6uq2kBbj4BXY1+DBGDPnrhMZV3pKWGNukw==",
+ "version": "8.56.7",
+ "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.7.tgz",
+ "integrity": "sha512-SjDvI/x3zsZnOkYZ3lCt9lOZWZLB2jIlNKz+LBgCtDurK0JZcwucxYHn1w2BJkD34dgX9Tjnak0txtq4WTggEA==",
"dev": true,
"dependencies": {
"@types/estree": "*",
@@ -571,9 +502,9 @@
}
},
"node_modules/caniuse-lite": {
- "version": "1.0.30001594",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001594.tgz",
- "integrity": "sha512-VblSX6nYqyJVs8DKFMldE2IVCJjZ225LW00ydtUWwh5hk9IfkTOffO6r8gJNsH0qqqeAF8KrbMYA2VEwTlGW5g==",
+ "version": "1.0.30001606",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001606.tgz",
+ "integrity": "sha512-LPbwnW4vfpJId225pwjZJOgX1m9sGfbw/RKJvw/t0QhYOOaTXHvkjVGFGPpvwEzufrjvTlsULnVTxdy4/6cqkg==",
"dev": true,
"funding": [
{
@@ -621,6 +552,17 @@
"node": ">=8"
}
},
+ "node_modules/clean-css": {
+ "version": "5.3.3",
+ "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.3.tgz",
+ "integrity": "sha512-D5J+kHaVb/wKSFcyyV75uCn8fiY4sV38XJoe4CUyGQ+mOU/fMVYUdH1hJC+CJQ5uY3EnW27SbJYS4X8BiLrAFg==",
+ "dependencies": {
+ "source-map": "~0.6.0"
+ },
+ "engines": {
+ "node": ">= 10.0"
+ }
+ },
"node_modules/clean-regexp": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz",
@@ -667,12 +609,12 @@
"dev": true
},
"node_modules/core-js-compat": {
- "version": "3.36.0",
- "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.36.0.tgz",
- "integrity": "sha512-iV9Pd/PsgjNWBXeq8XRtWVSgz2tKAfhfvBs7qxYty+RlRd+OCksaWmOnc4JKrTc1cToXL1N0s3l/vwlxPtdElw==",
+ "version": "3.36.1",
+ "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.36.1.tgz",
+ "integrity": "sha512-Dk997v9ZCt3X/npqzyGdTlq6t7lDBhZwGvV94PKzDArjp7BTRm7WlDAXYd/OWdeFHO8OChQYRJNJvUCqCbrtKA==",
"dev": true,
"dependencies": {
- "browserslist": "^4.22.3"
+ "browserslist": "^4.23.0"
},
"funding": {
"type": "opencollective",
@@ -784,9 +726,9 @@
}
},
"node_modules/electron-to-chromium": {
- "version": "1.4.692",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.692.tgz",
- "integrity": "sha512-d5rZRka9n2Y3MkWRN74IoAsxR0HK3yaAt7T50e3iT9VZmCCQDT3geXUO5ZRMhDToa1pkCeQXuNo+0g+NfDOVPA==",
+ "version": "1.4.729",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.729.tgz",
+ "integrity": "sha512-bx7+5Saea/qu14kmPTDHQxkp2UnziG3iajUQu3BxFvCOnpAJdDbMV4rSl+EqFDkkpNNVUFlR1kDfpL59xfy1HA==",
"dev": true
},
"node_modules/entities": {
@@ -905,9 +847,9 @@
}
},
"node_modules/eslint-plugin-sonarjs": {
- "version": "0.24.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.24.0.tgz",
- "integrity": "sha512-87zp50mbbNrSTuoEOebdRQBPa0mdejA5UEjyuScyIw8hEpEjfWP89Qhkq5xVZfVyVSRQKZc9alVm7yRKQvvUmg==",
+ "version": "0.25.1",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.25.1.tgz",
+ "integrity": "sha512-5IOKvj/GMBNqjxBdItfotfRHo7w48496GOu1hxdeXuD0mB1JBlDCViiLHETDTfA8pDAVSBimBEQoetRXYceQEw==",
"dev": true,
"engines": {
"node": ">=16"
@@ -917,9 +859,9 @@
}
},
"node_modules/eslint-plugin-unicorn": {
- "version": "51.0.1",
- "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-51.0.1.tgz",
- "integrity": "sha512-MuR/+9VuB0fydoI0nIn2RDA5WISRn4AsJyNSaNKLVwie9/ONvQhxOBbkfSICBPnzKrB77Fh6CZZXjgTt/4Latw==",
+ "version": "52.0.0",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-52.0.0.tgz",
+ "integrity": "sha512-1Yzm7/m+0R4djH0tjDjfVei/ju2w3AzUGjG6q8JnuNIL5xIwsflyCooW5sfBvQp2pMYQFSWWCFONsjCax1EHng==",
"dev": true,
"dependencies": {
"@babel/helper-validator-identifier": "^7.22.20",
@@ -1213,9 +1155,9 @@
}
},
"node_modules/hasown": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz",
- "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==",
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
+ "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"dev": true,
"dependencies": {
"function-bind": "^1.1.2"
@@ -1966,6 +1908,14 @@
"node": ">=8"
}
},
+ "node_modules/source-map": {
+ "version": "0.6.1",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/spdx-correct": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz",
diff --git a/package.json b/package.json
index 8822e19..6495ff7 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,6 @@
"description": "Allows you to analyze and generate stats for [Minecraft](https://minecraft.net) Java Edition data and resource packs.",
"main": "index.html",
"author": "TomatoCake",
- "license": "CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0",
"repository": {
"type": "git",
"url": "https://github.com/DEVTomatoCake/Pack-Analyzer.git"
@@ -14,16 +13,17 @@
"minify": "node minify.js"
},
"dependencies": {
+ "clean-css": "^5.3.3",
"uglify-js": "^3.17.4"
},
"devDependencies": {
- "@html-eslint/eslint-plugin": "^0.23.1",
- "@html-eslint/parser": "^0.24.0",
+ "@html-eslint/eslint-plugin": "^0.24.1",
+ "@html-eslint/parser": "^0.24.1",
"@stylistic/eslint-plugin-js": "^1.7.0",
"eslint": "^8.57.0",
"eslint-plugin-html": "^8.0.0",
- "eslint-plugin-sonarjs": "^0.24.0",
- "eslint-plugin-unicorn": "^51.0.1",
+ "eslint-plugin-sonarjs": "^0.25.1",
+ "eslint-plugin-unicorn": "^52.0.0",
"globals": "^15.0.0"
}
}
diff --git a/serviceworker.js b/serviceworker.js
index 7b278b5..9d1b5df 100644
--- a/serviceworker.js
+++ b/serviceworker.js
@@ -1,4 +1,5 @@
// Modified by TomatoCake from https://github.com/DEVTomatoCake/dashboard/blob/700b21999a671f4e9c32ba4a1a35f94156db11d4/serviceworker.js
+
const version = 1
self.addEventListener("install", event => {
@@ -11,8 +12,9 @@ self.addEventListener("install", event => {
staticCache.addAll([
"/",
"/assets/jszip.js",
+ "/assets/manifest.json",
"/assets/images/icon-128x128.png",
- "assets/images/generated_background.png"
+ "/assets/images/generated_background.png"
])
const fallbackCache = await caches.open("fallback" + version)
diff --git a/wrangler.toml b/wrangler.toml
new file mode 100644
index 0000000..f6dc782
--- /dev/null
+++ b/wrangler.toml
@@ -0,0 +1,13 @@
+# Generated by Wrangler on Sat Apr 06 2024 06:50:17 GMT+0200 (Mitteleuropäische Sommerzeit)
+name = "pack-analyzer"
+pages_build_output_dir = ""
+compatibility_date = "2024-04-03"
+
+[vars]
+MINIFY_ENABLED = "1"
+
+[env.production]
+compatibility_date = "2024-04-03"
+
+ [env.production.vars]
+ MINIFY_ENABLED = "1"