Skip to content

Commit

Permalink
update vite 5
Browse files Browse the repository at this point in the history
  • Loading branch information
L4Ph committed Oct 1, 2024
1 parent eb851e4 commit fed0ec5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 56 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

0 comments on commit fed0ec5

Please sign in to comment.