compress hash to get shorter url
What problem does this feature solve?
use https://github.com/rotemdan/lzutf8.js lib to compress hash, the hash will be shorter
What does the proposed API look like?
it's sfc playground's optimization, don't have an API.
if the Components are large, the base64 hash will be large too, we can use lzutf8 to compress them.
they are generated from the content:
{"App.vue":"<template>\n <div>App</div>\n <h1>{{ count }}</h1>\n <button @click=\"DoClick\">\n Add 5\n </button>\n <hr />\n\t<Comp1></Comp1>\n <hr />\n\t<Comp2></Comp2>\n</template>\n<script setup>\n import { ref } from 'vue'\n import Comp1 from './Comp1.vue'\n import Comp2 from './Comp2.vue'\n\tconst count = ref(0)\n function DoClick(){\n count.value += 5\n }\n</script>","Comp1.vue":"<template>\n <div>App</div>\n <h1>{{ count }}</h1>\n <button @click=\"DoClick\">\n Add 3\n </button>\n</template>\n<script setup>\n import { ref } from 'vue'\n\tconst count = ref(0)\n function DoClick(){\n count.value += 3\n }\n</script>","Comp2.vue":"<template>\n <div>App</div>\n <h1>{{ count }}</h1>\n <button @click=\"DoClick\">\n Add 10\n </button>\n</template>\n<script setup>\n import { ref } from 'vue'\n\tconst count = ref(0)\n function DoClick(){\n count.value += 10\n }\n</script>"}
lzutf8.decompress
can also decompress Base64 generated by btoa
, so old sfc-url works too.
lzutf8.decompress(Base64Str, { inputEncoding: 'Base64' })