Fix some build warnings

This commit is contained in:
Jon Staab 2026-09-01 15:12:21 -07:00
parent 2d20985c62
commit f83019a401
3 changed files with 27 additions and 18 deletions

View file

@ -4,15 +4,15 @@
*/
import {
DisconnectReason,
LocalParticipant,
LocalTrackPublication,
Participant,
Room as LiveKitRoom,
RoomEvent,
Track,
TrackPublication,
supportsAudioOutputSelection,
type AudioCaptureOptions,
type LocalParticipant,
type LocalTrackPublication,
type Participant,
type TrackPublication,
} from "livekit-client"
import {App} from "@capacitor/app"
import {derived, get, writable} from "svelte/store"

View file

@ -1,5 +1,4 @@
<script lang="ts">
import QRCode from "qrcode"
import Button from "@lib/components/Button.svelte"
import {clip} from "@app/toast"
@ -12,22 +11,20 @@
const copy = () => clip(code)
$effect(() => {
if (canvas && wrapper && code) {
QRCode.toCanvas(canvas, code)
}
})
// qrcode is imported here rather than at the top of the module because svelte strips effect
// bodies when compiling for SSR, which would leave the import with no remaining use.
const draw = async (canvas: HTMLCanvasElement, wrapper: Element, code: string) => {
const QRCode = await import("qrcode")
await QRCode.toCanvas(canvas, code)
scale = wrapper.getBoundingClientRect().width / canvas.width
height = canvas.height * scale
}
$effect(() => {
// Draw first so canvas.width/height reflect the current code, then fit the
// intrinsic canvas size to the wrapper. Measure the intrinsic size (not
// getBoundingClientRect, which includes the transform below) so this stays
// idempotent — otherwise scale feeds back into its own measurement and loops.
if (canvas && wrapper && code) {
const wrapperRect = wrapper.getBoundingClientRect()
scale = wrapperRect.width / canvas.width
height = canvas.height * scale
draw(canvas, wrapper, code)
}
})
</script>

View file

@ -47,8 +47,20 @@ export default defineConfig({
SvelteKitPWA({
registerType: "autoUpdate",
injectRegister: "auto",
// adapter-static writes the fallback shell after the service worker is generated, so the
// plugin can't glob it — this precaches "/" explicitly, giving workbox's navigation
// fallback something to bind to.
kit: {
spa: true,
adapterFallback: "/",
},
workbox: {
maximumFileSizeToCacheInBytes: 5 * 1024 ** 2, // 5 MB or set to something else
// The service worker is generated before SvelteKit prerenders anything, so the
// "prerendered/**" glob @vite-pwa/sveltekit forces in never matches. It only forces it
// when modifyURLPrefix is unset, and an empty one is a no-op.
modifyURLPrefix: {},
globPatterns: ["client/**/*.{js,css,ico,png,svg,webp,webmanifest}"],
},
manifest: {
name: process.env.VITE_PLATFORM_NAME,