Skip to content

Commit

Permalink
Merge pull request #8 from L4Ph/vite6-beta
Browse files Browse the repository at this point in the history
Vite6 beta
  • Loading branch information
L4Ph authored Oct 2, 2024
2 parents 0aa7345 + fed0ec5 commit 8ff5b4a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 58 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"tailwindcss": "^4.0.0-alpha.25",
"tslib": "^2.7.0",
"typescript": "^5.6.2",
"vite": "^5.4.8"
"vite": "^6.0.0-beta.2"
},
"module": "index.ts"
}
54 changes: 0 additions & 54 deletions src/routes/utils/compression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,60 +32,6 @@ export async function decompressFromBase64(input: string): Promise<string> {
return textDecoder.decode(decompressed);
}

export async function compressToUTF16(input: string): Promise<string> {
const upstream = createUpstream(textEncoder.encode(input));
const compression = new CompressionStream("deflate");
const stream = upstream.pipeThrough(compression);
const compressed = await new Response(stream).arrayBuffer();

let compressedBytes = new Uint8Array(compressed);

if (compressedBytes.length % 2 !== 0) {
const paddedBytes = new Uint8Array(compressedBytes.length + 1);
paddedBytes.set(compressedBytes);
paddedBytes[compressedBytes.length] = 0; // 奇数個配列の場合、最後のバイトに 0 をパディング
compressedBytes = paddedBytes;
}

const compressedUint16Array = new Uint16Array(compressedBytes.buffer);
return String.fromCharCode(...compressedUint16Array);
}

export async function decompressFromUTF16(input: string): Promise<string> {
const compressedUint16Array = new Uint16Array(
input.split("").map((c) => c.charCodeAt(0)),
);
let compressedBytes = new Uint8Array(compressedUint16Array.buffer);

if (compressedBytes[compressedBytes.length - 1] === 0) {
compressedBytes = compressedBytes.slice(0, compressedBytes.length - 1); // パディングされた 0 を削除
}

const upstream = createUpstream(compressedBytes);
const decompression = new DecompressionStream("deflate");
const stream = upstream.pipeThrough(decompression);
const decompressed = await new Response(stream).arrayBuffer();
return textDecoder.decode(decompressed);
}

export async function compressToUint8Array(input: string): Promise<Uint8Array> {
const upstream = createUpstream(textEncoder.encode(input));
const compression = new CompressionStream("deflate");
const stream = upstream.pipeThrough(compression);
const compressed = await new Response(stream).arrayBuffer();
return new Uint8Array(compressed);
}

export async function decompressFromUint8Array(
input: Uint8Array,
): Promise<string> {
const upstream = createUpstream(input);
const decompression = new DecompressionStream("deflate");
const stream = upstream.pipeThrough(decompression);
const decompressed = await new Response(stream).arrayBuffer();
return textDecoder.decode(decompressed);
}

export async function compressToEncodedURIComponent(
input: string,
): Promise<string> {
Expand Down
5 changes: 4 additions & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter(),
adapter: adapter({
precompress: true,
strict: true,
}),
alias: {
"@/*": "./src/lib/*",
},
Expand Down
2 changes: 0 additions & 2 deletions vite.config.js → vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { defineConfig } from "vite";
import { sveltekit } from "@sveltejs/kit/vite";
// @ts-ignore
import { fileURLToPath } from "node:url";
import tailwindcss from "@tailwindcss/vite";

const host = process.env.TAURI_DEV_HOST;
Expand Down

0 comments on commit 8ff5b4a

Please sign in to comment.