Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(inspector): use runes and force runes mode #1004

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-hats-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte-inspector': patch
---

fix(inspector): migrate client component to runes and force runes mode
3 changes: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export default [
},

rules: {
'n/no-missing-import': 'off' // n doesn't know some vite specifics or monorepo imports.
'n/no-missing-import': 'off', // n doesn't know some vite specifics or monorepo imports.
'prefer-const': 'off' // this turns let foo = $derived into a const otherwise
}
},
{
Expand Down
22 changes: 13 additions & 9 deletions packages/vite-plugin-svelte-inspector/src/runtime/Inspector.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options runes={true} />

<script>
// do not use TS here so that this component works in non-ts projects too
import { onMount } from 'svelte';
Expand All @@ -8,8 +10,8 @@
const nav_keys = Object.values(options.navKeys).map((k) => k?.toLowerCase());
const open_key = options.openKey?.toLowerCase();

let enabled = false;
let has_opened = false;
let enabled = $state(false);
let has_opened = $state(false);

const icon = `data:image/svg+xml;base64,${btoa(
`
Expand All @@ -24,17 +26,19 @@
)}`;

// location of code in file
let file_loc;
let file_loc = $state();
// cursor pos and width for file_loc overlay positioning
let x, y, w;
let x = $state(),
y = $state(),
w = $state();

let active_el;
let active_el = $state();

let hold_start_ts;
let hold_start_ts = $state();

$: show_toggle =
// eslint-disable-next-line svelte/valid-compile
options.showToggleButton === 'always' || (options.showToggleButton === 'active' && enabled);
let show_toggle = $derived(
options.showToggleButton === 'always' || (options.showToggleButton === 'active' && enabled)
);

function mousemove(e) {
x = e.x;
Expand Down