diff --git a/astro.config.mjs b/astro.config.mjs index e762ba5..a529435 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,5 +1,6 @@ // @ts-check -import { defineConfig } from 'astro/config'; +import { defineConfig } from "astro/config"; // https://astro.build/config -export default defineConfig({}); +export default defineConfig({ +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cd15caa..fe8e8dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: dependencies: astro: specifier: ^5.1.8 - version: 5.1.8(rollup@4.31.0)(typescript@5.7.3) + version: 5.1.8(@types/node@22.10.10)(rollup@4.31.0)(terser@5.37.0)(typescript@5.7.3) packages: @@ -306,9 +306,27 @@ packages: cpu: [x64] os: [win32] + '@jridgewell/gen-mapping@0.3.8': + resolution: {integrity: sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==} + engines: {node: '>=6.0.0'} + + '@jridgewell/resolve-uri@3.1.2': + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} + engines: {node: '>=6.0.0'} + + '@jridgewell/set-array@1.2.1': + resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==} + engines: {node: '>=6.0.0'} + + '@jridgewell/source-map@0.3.6': + resolution: {integrity: sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==} + '@jridgewell/sourcemap-codec@1.5.0': resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} + '@jridgewell/trace-mapping@0.3.25': + resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} + '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -470,6 +488,9 @@ packages: '@types/nlcst@2.0.3': resolution: {integrity: sha512-vSYNSDe6Ix3q+6Z7ri9lyWqgGhJTmzRjZRqyq15N0Z/1/UnVsno9G/N40NBijoYx2seFDIl0+B2mgAb9mezUCA==} + '@types/node@22.10.10': + resolution: {integrity: sha512-X47y/mPNzxviAGY5TcYPtYL8JsY3kAq2n8fMmKoRCxq/c4v4pyGNCzM2R6+M5/umG4ZfHuT+sgqDYqWc9rJ6ww==} + '@types/unist@3.0.3': resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==} @@ -540,6 +561,9 @@ packages: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} + buffer-from@1.1.2: + resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + camelcase@8.0.0: resolution: {integrity: sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==} engines: {node: '>=16'} @@ -593,6 +617,9 @@ packages: comma-separated-tokens@2.0.3: resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==} + commander@2.20.3: + resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} + common-ancestor-path@1.0.1: resolution: {integrity: sha512-L3sHRo1pXXEqX8VU28kfgUY+YGsk09hPqZiZmLacNib6XNTCM8ubYeT7ryXQw8asB1sKgcU5lkB7ONug08aB8w==} @@ -1216,6 +1243,13 @@ packages: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} + source-map-support@0.5.21: + resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + space-separated-tokens@2.0.2: resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} @@ -1245,6 +1279,11 @@ packages: resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} engines: {node: '>=4'} + terser@5.37.0: + resolution: {integrity: sha512-B8wRRkmre4ERucLM/uXx4MOV5cbnOlVAqUst+1+iLKPI0dOgFO28f84ptoQt9HEI537PMzfYa/d+GEPKTRXmYA==} + engines: {node: '>=10'} + hasBin: true + tinyexec@0.3.2: resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==} @@ -1289,6 +1328,9 @@ packages: uncrypto@0.1.3: resolution: {integrity: sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==} + undici-types@6.20.0: + resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} + unenv@1.10.0: resolution: {integrity: sha512-wY5bskBQFL9n3Eca5XnhH6KbUo/tfvkwm9OpcdCvLaeA7piBNbavbOKJySEwQ1V0RH6HvNlSAFRTpvTqgKRQXQ==} @@ -1707,8 +1749,33 @@ snapshots: '@img/sharp-win32-x64@0.33.5': optional: true + '@jridgewell/gen-mapping@0.3.8': + dependencies: + '@jridgewell/set-array': 1.2.1 + '@jridgewell/sourcemap-codec': 1.5.0 + '@jridgewell/trace-mapping': 0.3.25 + optional: true + + '@jridgewell/resolve-uri@3.1.2': + optional: true + + '@jridgewell/set-array@1.2.1': + optional: true + + '@jridgewell/source-map@0.3.6': + dependencies: + '@jridgewell/gen-mapping': 0.3.8 + '@jridgewell/trace-mapping': 0.3.25 + optional: true + '@jridgewell/sourcemap-codec@1.5.0': {} + '@jridgewell/trace-mapping@0.3.25': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.5.0 + optional: true + '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -1845,6 +1912,11 @@ snapshots: dependencies: '@types/unist': 3.0.3 + '@types/node@22.10.10': + dependencies: + undici-types: 6.20.0 + optional: true + '@types/unist@3.0.3': {} '@ungap/structured-clone@1.2.1': {} @@ -1876,7 +1948,7 @@ snapshots: array-iterate@2.0.1: {} - astro@5.1.8(rollup@4.31.0)(typescript@5.7.3): + astro@5.1.8(@types/node@22.10.10)(rollup@4.31.0)(terser@5.37.0)(typescript@5.7.3): dependencies: '@astrojs/compiler': 2.10.3 '@astrojs/internal-helpers': 0.4.2 @@ -1928,8 +2000,8 @@ snapshots: unist-util-visit: 5.0.0 unstorage: 1.14.4 vfile: 6.0.3 - vite: 6.0.11 - vitefu: 1.0.5(vite@6.0.11) + vite: 6.0.11(@types/node@22.10.10)(terser@5.37.0) + vitefu: 1.0.5(vite@6.0.11(@types/node@22.10.10)(terser@5.37.0)) which-pm: 3.0.0 xxhash-wasm: 1.1.0 yargs-parser: 21.1.1 @@ -1996,6 +2068,9 @@ snapshots: dependencies: fill-range: 7.1.1 + buffer-from@1.1.2: + optional: true + camelcase@8.0.0: {} ccount@2.0.1: {} @@ -2048,6 +2123,9 @@ snapshots: comma-separated-tokens@2.0.3: {} + commander@2.20.3: + optional: true + common-ancestor-path@1.0.1: {} consola@3.4.0: {} @@ -2980,6 +3058,15 @@ snapshots: source-map-js@1.2.1: {} + source-map-support@0.5.21: + dependencies: + buffer-from: 1.1.2 + source-map: 0.6.1 + optional: true + + source-map@0.6.1: + optional: true + space-separated-tokens@2.0.2: {} sprintf-js@1.0.3: {} @@ -3011,6 +3098,14 @@ snapshots: strip-bom@3.0.0: {} + terser@5.37.0: + dependencies: + '@jridgewell/source-map': 0.3.6 + acorn: 8.14.0 + commander: 2.20.3 + source-map-support: 0.5.21 + optional: true + tinyexec@0.3.2: {} to-regex-range@5.0.1: @@ -3038,6 +3133,9 @@ snapshots: uncrypto@0.1.3: {} + undici-types@6.20.0: + optional: true + unenv@1.10.0: dependencies: consola: 3.4.0 @@ -3124,17 +3222,19 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.2 - vite@6.0.11: + vite@6.0.11(@types/node@22.10.10)(terser@5.37.0): dependencies: esbuild: 0.24.2 postcss: 8.5.1 rollup: 4.31.0 optionalDependencies: + '@types/node': 22.10.10 fsevents: 2.3.3 + terser: 5.37.0 - vitefu@1.0.5(vite@6.0.11): + vitefu@1.0.5(vite@6.0.11(@types/node@22.10.10)(terser@5.37.0)): optionalDependencies: - vite: 6.0.11 + vite: 6.0.11(@types/node@22.10.10)(terser@5.37.0) web-namespaces@2.0.1: {} diff --git a/src/dong-io.ts b/src/dong-io.ts index 9ca49f0..b91ef4c 100644 --- a/src/dong-io.ts +++ b/src/dong-io.ts @@ -66,36 +66,13 @@ export const createDong = async ( ]); }; -// base 64 overload export async function readDong( dongFile: File, - opts?: { b64: true } + ): Promise< | { - image: { data: string; mime: string }; - audio: { data: string; mime: string }; - } - | string ->; -// standard overload -export async function readDong( - dongFile: File, - opts?: { b64: false } -): Promise< - | { - image: { data: Uint8Array; mime: string }; - audio: { data: Uint8Array; mime: string }; - } - | string ->; - -export async function readDong( - dongFile: File, - opts?: { b64: boolean } -): Promise< - | { - image: { data: Uint8Array | string; mime: string }; - audio: { data: Uint8Array | string; mime: string }; + image: { data: Uint8Array; b64?: string; mime: string }; + audio: { data: Uint8Array; b64?: string; mime: string }; } | string > { @@ -133,11 +110,13 @@ export async function readDong( return { image: { mime: imgMimeType, - data: opts?.b64 ? uint8array64(imageBytes) : imageBytes, + data: uint8array64(imageBytes), + b64: uint8array64(imageBytes), }, audio: { mime: audMimeType, - data: opts?.b64 ? uint8array64(audioBytes) : audioBytes, + data: uint8array64(audioBytes), + b64: uint8array64(audioBytes), }, }; } diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index 998dcaa..eb2cd79 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -79,6 +79,7 @@ const { title } = Astro.props; } } + diff --git a/src/pages/index.astro b/src/pages/index.astro index 37cf1cb..81b4874 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -131,7 +131,7 @@ import Base from "../layouts/Base.astro"; // do not append as this is only for playing audio // loaded here to prevent overlaying the sound - const audio = document.createElement("audio"); + const audio = new Audio(); dongSelect.type = "file"; dongSelect.accept = ".dong"; @@ -161,13 +161,13 @@ import Base from "../layouts/Base.astro"; // get files const dongFile = dongSelect.files[0]; - const res = await readDong(dongFile, { b64: true }); + const res = await readDong(dongFile); if (typeof res === "string") { errormsg.innerText = res; return; } - image.src = `data:${res.image.mime};base64,${res.image.data}`; + image.src = `data:${res.image.mime};base64,${res.image.b64}`; // audio play audio.src = `data:${res.audio.mime};base64,${res.audio.data}`; @@ -190,6 +190,9 @@ import Base from "../layouts/Base.astro"; button { background-color: var(--accent); + &:empty { + display: none; + } } body {