From b44627e5addca529540ab562aa2d2246d7331c30 Mon Sep 17 00:00:00 2001 From: stvncode Date: Mon, 27 Oct 2025 16:01:16 +0100 Subject: [PATCH 1/2] Fix zbt1 firmware update --- vite.config.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 6bd5a14..567c825 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -16,7 +16,7 @@ export default defineConfig({ { name: 'py-raw-loader', transform(code, id) { - if (id.endsWith('.py')) { + if (id.endsWith('.py') || id.endsWith('.txt')) { return { code: `export default ${JSON.stringify(code)};`, map: null }; } return null; @@ -53,6 +53,7 @@ export default defineConfig({ esbuildOptions: { loader: { '.py': 'text', + '.txt': 'text', }, }, }, From ddbbc8322cd4500a40111db92ca5c9b9bfa7d860 Mon Sep 17 00:00:00 2001 From: stvncode Date: Mon, 27 Oct 2025 16:19:49 +0100 Subject: [PATCH 2/2] Handle custom txt file to encode correctly --- vite.config.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 567c825..0349257 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -16,9 +16,28 @@ export default defineConfig({ { name: 'py-raw-loader', transform(code, id) { - if (id.endsWith('.py') || id.endsWith('.txt')) { + if (id.endsWith('.py')) { return { code: `export default ${JSON.stringify(code)};`, map: null }; } + + if (id.endsWith('.txt')) { + if (code.startsWith('export default "data:text/plain;base64,')) { + const match = code.match(/data:text\/plain;base64,(.+?)"$/); + if (match) { + const base64Content = match[1]; + const decodedContent = Buffer.from( + base64Content, + 'base64' + ).toString('utf-8'); + return { + code: `export default ${JSON.stringify(decodedContent)};`, + map: null, + }; + } + } + return { code: `export default ${JSON.stringify(code)};`, map: null }; + } + return null; }, },