Skip to content

Commit 1fef750

Browse files
feat: KS snapshot analyzer
A new project that should allow users to easily inspect the contents of their settings snapshots.
1 parent b3bbe97 commit 1fef750

File tree

8 files changed

+504
-9
lines changed

8 files changed

+504
-9
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"private": true,
3+
"name": "@kitten-science/snapshot-analyzer",
4+
"version": "0.0.1",
5+
"description": "Displays information about Kittten Scientists settings.",
6+
"license": "MIT",
7+
"author": "Oliver Salzburg <[email protected]>",
8+
"type": "module",
9+
"main": "index.html",
10+
"scripts": {
11+
"snapshot-analyzer:build": "vite build",
12+
"snapshot-analyzer:serve": "vite serve"
13+
},
14+
"dependencies": {
15+
"@kitten-science/kitten-scientists": "workspace:*",
16+
"@oliversalzburg/js-utils": "0.0.27",
17+
"lz-string": "1.5.0",
18+
"tslib": "2.6.2"
19+
},
20+
"devDependencies": {
21+
"typescript": "5.3.3",
22+
"vite": "5.0.10",
23+
"vite-plugin-html": "3.2.0"
24+
},
25+
"engines": {
26+
"node": "^20.0.0"
27+
}
28+
}
15 KB
Binary file not shown.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>KS Snapshot Analyzer</title>
6+
<meta property="og:title" content="Snapshot Analyzer" />
7+
<meta
8+
property="og:description"
9+
content="Displays information about Kittten Scientists settings."
10+
/>
11+
<meta property="og:url" content="https://kitten-science.com/snapshot-analyzer/" />
12+
<link rel="icon" type="image/x-icon" href="favicon.ico" />
13+
<style>
14+
html,
15+
body {
16+
padding: 0;
17+
margin: 0;
18+
width: 100%;
19+
height: 100%;
20+
}
21+
22+
body {
23+
display: flex;
24+
flex-direction: column;
25+
26+
textarea {
27+
flex: 1;
28+
}
29+
}
30+
</style>
31+
</head>
32+
33+
<body>
34+
<input id="input" type="text" placeholder="Paste KS settings export here." />
35+
<textarea id="parsed" placeholder="Parsed settings will be shown here." readonly></textarea>
36+
</body>
37+
<script src="main.ts" type="module"></script>
38+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { UserScript } from "@kitten-science/kitten-scientists";
2+
import { getDocumentElementTypeByIdStrict } from "@oliversalzburg/js-utils/dom/core.js";
3+
import { decompressFromBase64 } from "lz-string";
4+
5+
const input = getDocumentElementTypeByIdStrict(document, "input", HTMLInputElement);
6+
const parsed = getDocumentElementTypeByIdStrict(document, "parsed", HTMLTextAreaElement);
7+
8+
input.addEventListener("change", (event: Event) => {
9+
// Pre-decompress
10+
const decompressed = decompressFromBase64(input.value);
11+
parsed.value = JSON.stringify(UserScript.decodeSettings(decompressed), undefined, 2);
12+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "build",
5+
"rootDir": "source"
6+
},
7+
"include": ["../../@types", "source"],
8+
"references": []
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from "vite";
2+
import { createHtmlPlugin } from "vite-plugin-html";
3+
4+
export default defineConfig({
5+
base: "/snapshot-analyzer/",
6+
root: "source",
7+
build: {
8+
modulePreload: {
9+
polyfill: false,
10+
},
11+
},
12+
plugins: [createHtmlPlugin()],
13+
});

tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
},
1616
{
1717
"path": "packages/kitten-scientists"
18+
},
19+
{
20+
"path": "packages/snapshot-analyzer"
1821
}
1922
]
2023
}

0 commit comments

Comments
 (0)