Skip to content

Commit 85e42d1

Browse files
committed
fix(inspector) use runes and force runes mode to avoid issues in client apps that set runes mode globally
1 parent 52e4a4f commit 85e42d1

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

.changeset/cold-hats-leave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte-inspector': patch
3+
---
4+
5+
fix(inspector): migrate client component to runes and force runes mode"

packages/vite-plugin-svelte-inspector/src/runtime/Inspector.svelte

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<svelte:options runes={true} />
2+
13
<script>
24
// do not use TS here so that this component works in non-ts projects too
35
import { onMount } from 'svelte';
@@ -8,8 +10,8 @@
810
const nav_keys = Object.values(options.navKeys).map((k) => k?.toLowerCase());
911
const open_key = options.openKey?.toLowerCase();
1012
11-
let enabled = false;
12-
let has_opened = false;
13+
let enabled = $state(false);
14+
let has_opened = $state(false);
1315
1416
const icon = `data:image/svg+xml;base64,${btoa(
1517
`
@@ -24,17 +26,19 @@
2426
)}`;
2527
2628
// location of code in file
27-
let file_loc;
29+
let file_loc = $state();
2830
// cursor pos and width for file_loc overlay positioning
29-
let x, y, w;
31+
let x = $state(),
32+
y = $state(),
33+
w = $state();
3034
31-
let active_el;
35+
let active_el = $state();
3236
33-
let hold_start_ts;
37+
let hold_start_ts = $state();
3438
35-
$: show_toggle =
36-
// eslint-disable-next-line svelte/valid-compile
37-
options.showToggleButton === 'always' || (options.showToggleButton === 'active' && enabled);
39+
const show_toggle = $derived(
40+
options.showToggleButton === 'always' || (options.showToggleButton === 'active' && enabled)
41+
);
3842
3943
function mousemove(e) {
4044
x = e.x;

0 commit comments

Comments
 (0)