kunkun/apps/desktop/setup.ts
Huakun Shen ad83e89e52
feat: implement pixel dance animation component, page and command (#8)
* feat: implement pixel dance animation component, page and command

* feat: make entire dance page draggable

* feat: add dance transition for ui-iframe extension loading
2024-11-03 19:34:07 -05:00

28 lines
1.1 KiB
TypeScript

import assert from "assert"
import { compressString, decompressString } from "@kksh/utils"
import { $ } from "bun"
/* -------------------------------------------------------------------------- */
/* Download Dance JSON */
/* -------------------------------------------------------------------------- */
console.log("Downloading Dance Data...")
const rawData = await fetch("https://dance.kunkun.sh/api/data").then((res) => res.text())
function formatFileSize(size: number) {
return `${(size / 1024).toFixed(2)} KB`
}
Bun.write("./src/data/dance.json", rawData)
console.log(`Raw Data Size: ${formatFileSize(rawData.length)}`)
const compressedDance = compressString(rawData)
const decompressedDance = decompressString(compressedDance)
assert(decompressedDance === rawData)
const filePath = "./src/data/dance.bin"
Bun.write(
filePath, // has to be .txt in order to be imported as text
compressedDance
)
// get file size
const fileSize = Bun.file(filePath).size
console.log(`Dance Data Compressed File Size: ${formatFileSize(fileSize)}`)