@oddsquad/vite-plugin-lit 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/index.d.ts +3 -2
  2. package/index.d.ts.map +1 -1
  3. package/index.js +1 -1
  4. package/index.js.map +1 -1
  5. package/lib/color-scheme.d.ts +30 -0
  6. package/lib/color-scheme.d.ts.map +1 -0
  7. package/lib/color-scheme.js +41 -0
  8. package/lib/color-scheme.js.map +1 -0
  9. package/lib/icons.d.ts +18 -0
  10. package/lib/icons.d.ts.map +1 -0
  11. package/lib/icons.js +23 -0
  12. package/lib/icons.js.map +1 -0
  13. package/lib/plugin.d.ts +71 -6
  14. package/lib/plugin.d.ts.map +1 -1
  15. package/lib/plugin.js +522 -21
  16. package/lib/plugin.js.map +1 -1
  17. package/lib/runtime/css.d.ts +94 -0
  18. package/lib/runtime/css.d.ts.map +1 -0
  19. package/lib/runtime/css.js +112 -0
  20. package/lib/runtime/css.js.map +1 -0
  21. package/lib/runtime/edge-panel.d.ts +18 -0
  22. package/lib/runtime/edge-panel.d.ts.map +1 -0
  23. package/lib/runtime/edge-panel.js +130 -0
  24. package/lib/runtime/edge-panel.js.map +1 -0
  25. package/lib/runtime/fonts.d.ts +18 -0
  26. package/lib/runtime/fonts.d.ts.map +1 -0
  27. package/lib/runtime/fonts.js +18 -0
  28. package/lib/runtime/fonts.js.map +1 -0
  29. package/lib/runtime/indicator.d.ts +7 -0
  30. package/lib/runtime/indicator.d.ts.map +1 -0
  31. package/lib/runtime/indicator.js +141 -0
  32. package/lib/runtime/indicator.js.map +1 -0
  33. package/lib/runtime/inspector/collect.d.ts +17 -0
  34. package/lib/runtime/inspector/collect.d.ts.map +1 -0
  35. package/lib/runtime/inspector/collect.js +132 -0
  36. package/lib/runtime/inspector/collect.js.map +1 -0
  37. package/lib/runtime/inspector/install.d.ts +7 -0
  38. package/lib/runtime/inspector/install.d.ts.map +1 -0
  39. package/lib/runtime/inspector/install.js +204 -0
  40. package/lib/runtime/inspector/install.js.map +1 -0
  41. package/lib/runtime/inspector/serialize.d.ts +10 -0
  42. package/lib/runtime/inspector/serialize.d.ts.map +1 -0
  43. package/lib/runtime/inspector/serialize.js +133 -0
  44. package/lib/runtime/inspector/serialize.js.map +1 -0
  45. package/lib/runtime/intern.d.ts.map +1 -1
  46. package/lib/runtime/intern.js +1 -1
  47. package/lib/runtime/intern.js.map +1 -1
  48. package/lib/runtime/overrides.d.ts +25 -0
  49. package/lib/runtime/overrides.d.ts.map +1 -0
  50. package/lib/runtime/overrides.js +33 -0
  51. package/lib/runtime/overrides.js.map +1 -0
  52. package/lib/runtime/patch.d.ts +6 -15
  53. package/lib/runtime/patch.d.ts.map +1 -1
  54. package/lib/runtime/patch.js +81 -28
  55. package/lib/runtime/patch.js.map +1 -1
  56. package/lib/runtime/source-meta.d.ts +16 -0
  57. package/lib/runtime/source-meta.d.ts.map +1 -0
  58. package/lib/runtime/source-meta.js +8 -0
  59. package/lib/runtime/source-meta.js.map +1 -0
  60. package/lib/runtime/source-overlay/editors.d.ts +9 -0
  61. package/lib/runtime/source-overlay/editors.d.ts.map +1 -0
  62. package/lib/runtime/source-overlay/editors.js +40 -0
  63. package/lib/runtime/source-overlay/editors.js.map +1 -0
  64. package/lib/runtime/source-overlay/mask-path.d.ts +7 -0
  65. package/lib/runtime/source-overlay/mask-path.d.ts.map +1 -0
  66. package/lib/runtime/source-overlay/mask-path.js +26 -0
  67. package/lib/runtime/source-overlay/mask-path.js.map +1 -0
  68. package/lib/runtime/source-overlay/overlay-element.d.ts +18 -0
  69. package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -0
  70. package/lib/runtime/source-overlay/overlay-element.js +381 -0
  71. package/lib/runtime/source-overlay/overlay-element.js.map +1 -0
  72. package/lib/runtime/source-overlay/source-host.d.ts +14 -0
  73. package/lib/runtime/source-overlay/source-host.d.ts.map +1 -0
  74. package/lib/runtime/source-overlay/source-host.js +94 -0
  75. package/lib/runtime/source-overlay/source-host.js.map +1 -0
  76. package/lib/runtime/source-overlay/template.d.ts +7 -0
  77. package/lib/runtime/source-overlay/template.d.ts.map +1 -0
  78. package/lib/runtime/source-overlay/template.js +125 -0
  79. package/lib/runtime/source-overlay/template.js.map +1 -0
  80. package/lib/runtime/source-overlay.d.ts +7 -0
  81. package/lib/runtime/source-overlay.d.ts.map +1 -0
  82. package/lib/runtime/source-overlay.js +11 -0
  83. package/lib/runtime/source-overlay.js.map +1 -0
  84. package/lib/runtime/timeline/clock.d.ts +10 -0
  85. package/lib/runtime/timeline/clock.d.ts.map +1 -0
  86. package/lib/runtime/timeline/clock.js +22 -0
  87. package/lib/runtime/timeline/clock.js.map +1 -0
  88. package/lib/runtime/timeline/identity.d.ts +37 -0
  89. package/lib/runtime/timeline/identity.d.ts.map +1 -0
  90. package/lib/runtime/timeline/identity.js +73 -0
  91. package/lib/runtime/timeline/identity.js.map +1 -0
  92. package/lib/runtime/timeline/input.d.ts +16 -0
  93. package/lib/runtime/timeline/input.d.ts.map +1 -0
  94. package/lib/runtime/timeline/input.js +87 -0
  95. package/lib/runtime/timeline/input.js.map +1 -0
  96. package/lib/runtime/timeline/install.d.ts +7 -0
  97. package/lib/runtime/timeline/install.d.ts.map +1 -0
  98. package/lib/runtime/timeline/install.js +69 -0
  99. package/lib/runtime/timeline/install.js.map +1 -0
  100. package/lib/runtime/timeline/lifecycle.d.ts +27 -0
  101. package/lib/runtime/timeline/lifecycle.d.ts.map +1 -0
  102. package/lib/runtime/timeline/lifecycle.js +225 -0
  103. package/lib/runtime/timeline/lifecycle.js.map +1 -0
  104. package/lib/runtime/timeline/public-api.d.ts +28 -0
  105. package/lib/runtime/timeline/public-api.d.ts.map +1 -0
  106. package/lib/runtime/timeline/public-api.js +44 -0
  107. package/lib/runtime/timeline/public-api.js.map +1 -0
  108. package/lib/runtime/timeline/render.d.ts +39 -0
  109. package/lib/runtime/timeline/render.d.ts.map +1 -0
  110. package/lib/runtime/timeline/render.js +109 -0
  111. package/lib/runtime/timeline/render.js.map +1 -0
  112. package/lib/runtime/timeline/transport.d.ts +42 -0
  113. package/lib/runtime/timeline/transport.d.ts.map +1 -0
  114. package/lib/runtime/timeline/transport.js +86 -0
  115. package/lib/runtime/timeline/transport.js.map +1 -0
  116. package/lib/segmented-tabs.d.ts +33 -0
  117. package/lib/segmented-tabs.d.ts.map +1 -0
  118. package/lib/segmented-tabs.js +129 -0
  119. package/lib/segmented-tabs.js.map +1 -0
  120. package/lib/source-meta.d.ts +26 -0
  121. package/lib/source-meta.d.ts.map +1 -0
  122. package/lib/source-meta.js +129 -0
  123. package/lib/source-meta.js.map +1 -0
  124. package/lib/timeline-plugin.d.ts +72 -0
  125. package/lib/timeline-plugin.d.ts.map +1 -0
  126. package/lib/timeline-plugin.js +376 -0
  127. package/lib/timeline-plugin.js.map +1 -0
  128. package/lib/tokens.d.ts +38 -0
  129. package/lib/tokens.d.ts.map +1 -0
  130. package/lib/tokens.js +263 -0
  131. package/lib/tokens.js.map +1 -0
  132. package/lib/transform.d.ts +5 -5
  133. package/lib/transform.d.ts.map +1 -1
  134. package/lib/transform.js +3 -3
  135. package/lib/transform.js.map +1 -1
  136. package/lib/types.d.ts +34 -0
  137. package/lib/types.d.ts.map +1 -0
  138. package/lib/types.js +7 -0
  139. package/lib/types.js.map +1 -0
  140. package/lib/wrap-table.d.ts.map +1 -1
  141. package/lib/wrap-table.js.map +1 -1
  142. package/package.json +18 -4
  143. package/panel/components-view.d.ts +60 -0
  144. package/panel/components-view.d.ts.map +1 -0
  145. package/panel/components-view.js +581 -0
  146. package/panel/components-view.js.map +1 -0
  147. package/panel/devtools-settings.d.ts +41 -0
  148. package/panel/devtools-settings.d.ts.map +1 -0
  149. package/panel/devtools-settings.js +463 -0
  150. package/panel/devtools-settings.js.map +1 -0
  151. package/panel/index.html +29 -0
  152. package/panel/lit-devtools-panel.d.ts +37 -0
  153. package/panel/lit-devtools-panel.d.ts.map +1 -0
  154. package/panel/lit-devtools-panel.js +183 -0
  155. package/panel/lit-devtools-panel.js.map +1 -0
  156. package/panel/timeline-event-list.d.ts +43 -0
  157. package/panel/timeline-event-list.d.ts.map +1 -0
  158. package/panel/timeline-event-list.js +416 -0
  159. package/panel/timeline-event-list.js.map +1 -0
  160. package/panel/timeline-layers.d.ts +25 -0
  161. package/panel/timeline-layers.d.ts.map +1 -0
  162. package/panel/timeline-layers.js +96 -0
  163. package/panel/timeline-layers.js.map +1 -0
  164. package/panel/timeline-view.d.ts +38 -0
  165. package/panel/timeline-view.d.ts.map +1 -0
  166. package/panel/timeline-view.js +234 -0
  167. package/panel/timeline-view.js.map +1 -0
  168. package/types/inspector.d.ts +130 -0
  169. package/types/inspector.d.ts.map +1 -0
  170. package/types/inspector.js +16 -0
  171. package/types/inspector.js.map +1 -0
  172. package/types/timeline.d.ts +98 -0
  173. package/types/timeline.d.ts.map +1 -0
  174. package/types/timeline.js +39 -0
  175. package/types/timeline.js.map +1 -0
package/lib/tokens.js ADDED
@@ -0,0 +1,263 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import { css, unsafeCSS } from 'lit';
7
+ /**
8
+ * Design token CSS custom properties for the Lit DevTools.
9
+ *
10
+ * Two entry points:
11
+ * - **`tokens`** — Lit `css` template that defines the theme-agnostic base
12
+ * tokens on `:host`. Semantic color aliases (`--lit-devtools-bg`, `--lit-devtools-surface`, `--lit-devtools-text`,
13
+ * etc.) are inherited from `:root`, where {@link injectTokens} installs them.
14
+ * Use as `static styles = [tokens, css`…`]`.
15
+ * - **`injectTokens()`** — injects `:root { … }` into the page `<head>` once.
16
+ * This makes semantic aliases available to every devtools surface, both
17
+ * runtime elements (indicator, source-overlay) that build their shadow DOM
18
+ * via `innerHTML` and Lit panel components that inherit from `:root`.
19
+ * The injected stylesheet reacts to `prefers-color-scheme` and to
20
+ * `.color-scheme-light` / `.color-scheme-dark` classes on `:root`.
21
+ *
22
+ * Sourced from the lit-design skill (`tokens/colors.css`). Defaults to the
23
+ * dark DevTools theme; the light lit.dev website palette is applied when the
24
+ * OS/browser requests a light color scheme or when `:root` has the matching
25
+ * theme class.
26
+ *
27
+ * Fonts are system stacks (no webfonts). For the branded Manrope + Roboto Mono
28
+ * see the lit-design skill's `fonts/` directory.
29
+ */
30
+ const baseTokenCSS = `
31
+ /* ---- Brand · the Lit flame ---- */
32
+ --lit-devtools-lit-blue: #324fff;
33
+ --lit-devtools-lit-blue-bright: #4d63ff;
34
+ --lit-devtools-lit-indigo: #2a2c9d;
35
+ --lit-devtools-lit-dark-blue: #283198;
36
+ --lit-devtools-lit-cyan: #00ffff;
37
+ --lit-devtools-lit-dark-cyan: #00e8ff;
38
+
39
+ /* ---- Neutral ink scale (0 = near-black, 13 = white) ---- */
40
+ --lit-devtools-ink-0: hsl(0 0% 1%);
41
+ --lit-devtools-ink-1: hsl(0 0% 5%);
42
+ --lit-devtools-ink-2: hsl(0 0% 7%);
43
+ --lit-devtools-ink-3: hsl(0 0% 11%);
44
+ --lit-devtools-ink-4: hsl(0 0% 13%);
45
+ --lit-devtools-ink-5: hsl(0 0% 16%);
46
+ --lit-devtools-ink-6: hsl(0 0% 21%);
47
+ --lit-devtools-ink-7: hsl(0 0% 28%);
48
+ --lit-devtools-ink-8: hsl(0 0% 38%);
49
+ --lit-devtools-ink-9: hsl(0 0% 57%);
50
+ --lit-devtools-ink-10: hsl(0 0% 63%);
51
+ --lit-devtools-ink-11: hsl(0 0% 78%);
52
+ --lit-devtools-ink-12: hsl(0 0% 89%);
53
+ --lit-devtools-ink-13: hsl(0 0% 100%);
54
+
55
+ /* ---- Typography ---- */
56
+ --lit-devtools-font-sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
57
+ --lit-devtools-font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
58
+
59
+ --lit-devtools-weight-regular: 400;
60
+ --lit-devtools-weight-medium: 500;
61
+ --lit-devtools-weight-semibold: 600;
62
+ --lit-devtools-weight-bold: 700;
63
+ --lit-devtools-weight-extrabold: 800;
64
+
65
+ --lit-devtools-text-2xs: 11px;
66
+ --lit-devtools-text-xs: 12px;
67
+ --lit-devtools-text-sm: 13px;
68
+ --lit-devtools-text-md: 14px;
69
+ --lit-devtools-text-base:16px;
70
+
71
+ --lit-devtools-leading-tight: 1.15;
72
+ --lit-devtools-leading-snug: 1.3;
73
+ --lit-devtools-leading-normal: 1.5;
74
+
75
+ --lit-devtools-tracking-tight: -0.02em;
76
+ --lit-devtools-tracking-snug: -0.01em;
77
+ --lit-devtools-tracking-normal: 0;
78
+ --lit-devtools-tracking-wide: 0.02em;
79
+ --lit-devtools-tracking-caps: 0.06em;
80
+
81
+ /* ---- Spacing (4px base) ---- */
82
+ --lit-devtools-space-0: 0;
83
+ --lit-devtools-space-1: 2px;
84
+ --lit-devtools-space-2: 4px;
85
+ --lit-devtools-space-3: 6px;
86
+ --lit-devtools-space-4: 8px;
87
+ --lit-devtools-space-5: 12px;
88
+ --lit-devtools-space-6: 16px;
89
+ --lit-devtools-space-7: 20px;
90
+ --lit-devtools-space-8: 24px;
91
+ --lit-devtools-space-9: 32px;
92
+
93
+ /* ---- Radius ---- */
94
+ --lit-devtools-radius-xs: 3px;
95
+ --lit-devtools-radius-sm: 5px;
96
+ --lit-devtools-radius-md: 8px;
97
+ --lit-devtools-radius-lg: 12px;
98
+ --lit-devtools-radius-xl: 16px;
99
+ --lit-devtools-radius-pill: 999px;
100
+
101
+ /* ---- Elevation ---- */
102
+ --lit-devtools-shadow-xs: 0 1px 2px hsl(0 0% 0% / 0.30);
103
+ --lit-devtools-shadow-sm: 0 1px 5px hsl(0 0% 0% / 0.35);
104
+ --lit-devtools-shadow-md: 0 4px 14px hsl(0 0% 0% / 0.40);
105
+ --lit-devtools-shadow-lg: 0 12px 32px hsl(0 0% 0% / 0.50);
106
+ --lit-devtools-shadow-xl: 0 24px 64px hsl(0 0% 0% / 0.55);
107
+ --lit-devtools-shadow-window: 0 24px 80px hsl(0 0% 0% / 0.6),
108
+ 0 0 0 1px hsl(0 0% 100% / 0.06);
109
+ --lit-devtools-ring: 0 0 0 2px var(--lit-devtools-accent-ring);
110
+
111
+ /* ---- Motion ---- */
112
+ --lit-devtools-ease-standard: cubic-bezier(0.2, 0, 0, 1);
113
+ --lit-devtools-dur-fast: 140ms;
114
+ --lit-devtools-dur-normal: 220ms;
115
+ `;
116
+ const darkThemeCSS = `
117
+ /* ---- DARK · DevTools theme ---- */
118
+ --lit-devtools-accent: var(--lit-devtools-lit-blue-bright);
119
+ --lit-devtools-accent-hover: #6478ff;
120
+ --lit-devtools-accent-pressed: #3d54f0;
121
+ --lit-devtools-accent-soft: hsla(232 100% 65% / 0.16);
122
+ --lit-devtools-accent-ring: hsla(232 100% 65% / 0.45);
123
+ --lit-devtools-on-accent: #ffffff;
124
+ --lit-devtools-accent-cyan: var(--lit-devtools-lit-dark-cyan);
125
+
126
+ --lit-devtools-bg: var(--lit-devtools-ink-0);
127
+ --lit-devtools-surface: var(--lit-devtools-ink-2);
128
+ --lit-devtools-surface-low: var(--lit-devtools-ink-1);
129
+ --lit-devtools-surface-container: var(--lit-devtools-ink-4);
130
+ --lit-devtools-surface-container-high: var(--lit-devtools-ink-5);
131
+ --lit-devtools-surface-elevated: var(--lit-devtools-ink-6);
132
+ --lit-devtools-surface-hover: hsl(0 0% 100% / 0.04);
133
+ --lit-devtools-surface-active: hsl(0 0% 100% / 0.07);
134
+
135
+ --lit-devtools-text: var(--lit-devtools-ink-12);
136
+ --lit-devtools-text-strong: var(--lit-devtools-ink-13);
137
+ --lit-devtools-text-secondary: var(--lit-devtools-ink-10);
138
+ --lit-devtools-text-muted: var(--lit-devtools-ink-8);
139
+ --lit-devtools-text-link: var(--lit-devtools-lit-blue-bright);
140
+
141
+ --lit-devtools-border: var(--lit-devtools-ink-6);
142
+ --lit-devtools-border-strong: var(--lit-devtools-ink-7);
143
+ --lit-devtools-border-subtle: hsl(0 0% 100% / 0.06);
144
+
145
+ --lit-devtools-success: hsl(158 74% 53%);
146
+ --lit-devtools-success-soft: hsl(158 74% 53% / 0.15);
147
+ --lit-devtools-warning: #f4bf4f;
148
+ --lit-devtools-warning-soft: hsl(43 88% 63% / 0.15);
149
+ --lit-devtools-error: #ff6b6b;
150
+ --lit-devtools-error-soft: hsl(0 100% 71% / 0.15);
151
+ --lit-devtools-info: var(--lit-devtools-lit-dark-cyan);
152
+ --lit-devtools-info-soft: hsl(187 100% 47% / 0.15);
153
+
154
+ --lit-devtools-selection-bg: var(--lit-devtools-accent);
155
+ --lit-devtools-on-selection: #ffffff;
156
+
157
+ color-scheme: dark;
158
+ `;
159
+ const lightThemeCSS = `
160
+ /* ---- LIGHT · lit.dev website theme ---- */
161
+ --lit-devtools-accent: var(--lit-devtools-lit-blue);
162
+ --lit-devtools-accent-hover: #1f3bff;
163
+ --lit-devtools-accent-pressed: #2a2c9d;
164
+ --lit-devtools-accent-soft: hsla(232 100% 60% / 0.12);
165
+ --lit-devtools-accent-ring: hsla(232 100% 60% / 0.40);
166
+ --lit-devtools-on-accent: #ffffff;
167
+ --lit-devtools-accent-cyan: var(--lit-devtools-lit-dark-cyan);
168
+
169
+ --lit-devtools-bg: #f4f4f4;
170
+ --lit-devtools-surface: #ffffff;
171
+ --lit-devtools-surface-low: #f3f3f3;
172
+ --lit-devtools-surface-container: #ffffff;
173
+ --lit-devtools-surface-container-high: #e8e8e8;
174
+ --lit-devtools-surface-elevated: #ffffff;
175
+ --lit-devtools-surface-hover: hsl(0 0% 0% / 0.04);
176
+ --lit-devtools-surface-active: hsl(0 0% 0% / 0.07);
177
+
178
+ --lit-devtools-text: #242424;
179
+ --lit-devtools-text-strong: #000000;
180
+ --lit-devtools-text-secondary: #6e6e6e;
181
+ --lit-devtools-text-muted: #949494;
182
+ --lit-devtools-text-link: #005dc7;
183
+
184
+ --lit-devtools-border: #e2e2e2;
185
+ --lit-devtools-border-strong: #c6c6c6;
186
+ --lit-devtools-border-subtle: hsl(0 0% 0% / 0.07);
187
+
188
+ --lit-devtools-success: #00865b;
189
+ --lit-devtools-success-soft: hsl(158 100% 26% / 0.10);
190
+ --lit-devtools-warning: #b26a00;
191
+ --lit-devtools-warning-soft: hsl(40 100% 35% / 0.10);
192
+ --lit-devtools-error: #ba1a1a;
193
+ --lit-devtools-error-soft: hsl(0 75% 42% / 0.10);
194
+ --lit-devtools-info: #005dc7;
195
+ --lit-devtools-info-soft: hsl(210 100% 39% / 0.10);
196
+
197
+ --lit-devtools-selection-bg: var(--lit-devtools-accent);
198
+ --lit-devtools-on-selection: #ffffff;
199
+
200
+ color-scheme: light;
201
+ `;
202
+ /**
203
+ * Default dark theme tokens as a flat string, primarily for use by
204
+ * {@link injectTokens}. Prefer importing `tokens` for Lit components so the
205
+ * semantic aliases are inherited from `:root`.
206
+ */
207
+ export const tokenCSS = `${baseTokenCSS}\n${darkThemeCSS}`;
208
+ /**
209
+ * Lit `css` template for use in panel component shadow roots.
210
+ *
211
+ * ```ts
212
+ * import {tokens} from '../lib/tokens.js';
213
+ * // ...
214
+ * static override styles = [tokens, css`…`];
215
+ * ```
216
+ *
217
+ * This installs the theme-agnostic base tokens on `:host`. Semantic aliases
218
+ * (`--lit-devtools-bg`, `--lit-devtools-text`, etc.) are inherited from `:root`, where they are installed
219
+ * by {@link injectTokens}. The panel iframe calls `injectTokens()` from
220
+ * \`lit-devtools-panel.ts\` so all components inherit the same dark/light theme.
221
+ */
222
+ export const tokens = css `
223
+ :host {
224
+ ${unsafeCSS(baseTokenCSS)}
225
+ }
226
+ `;
227
+ let _injected = false;
228
+ /**
229
+ * Injects `:root { … }` into the page `<head>` once.
230
+ *
231
+ * CSS custom properties defined on `:root` cascade through shadow DOM
232
+ * boundaries, so this makes every `var(--lit-devtools-accent)` etc. resolve inside both
233
+ * runtime elements (indicator, source-overlay) and Lit panel components.
234
+ *
235
+ * The injected stylesheet reacts to `prefers-color-scheme` and to
236
+ * `.color-scheme-light` / `.color-scheme-dark` classes on the document root.
237
+ */
238
+ export const injectTokens = () => {
239
+ if (_injected)
240
+ return;
241
+ _injected = true;
242
+ const style = document.createElement('style');
243
+ style.setAttribute('data-lit-devtools-tokens', '');
244
+ style.textContent = `
245
+ :root {
246
+ ${baseTokenCSS}
247
+ ${darkThemeCSS}
248
+ }
249
+ @media (prefers-color-scheme: light) {
250
+ :root {
251
+ ${lightThemeCSS}
252
+ }
253
+ }
254
+ :root.color-scheme-light {
255
+ ${lightThemeCSS}
256
+ }
257
+ :root.color-scheme-dark {
258
+ ${darkThemeCSS}
259
+ }
260
+ `;
261
+ document.head.prepend(style);
262
+ };
263
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/tokens.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,GAAG,EAAE,SAAS,EAAC,MAAM,KAAK,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqFpB,CAAC;AAEF,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CpB,CAAC;AAEF,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CrB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,YAAY,KAAK,YAAY,EAAE,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;MAEnB,SAAS,CAAC,YAAY,CAAC;;CAE5B,CAAC;AAEF,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAS,EAAE;IACrC,IAAI,SAAS;QAAE,OAAO;IACtB,SAAS,GAAG,IAAI,CAAC;IACjB,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,CAAC,YAAY,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAAC;IACnD,KAAK,CAAC,WAAW,GAAG;;QAEd,YAAY;QACZ,YAAY;;;;UAIV,aAAa;;;;QAIf,aAAa;;;QAGb,YAAY;;GAEjB,CAAC;IACF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {css, unsafeCSS} from 'lit';\n\n/**\n * Design token CSS custom properties for the Lit DevTools.\n *\n * Two entry points:\n * - **`tokens`** — Lit `css` template that defines the theme-agnostic base\n * tokens on `:host`. Semantic color aliases (`--lit-devtools-bg`, `--lit-devtools-surface`, `--lit-devtools-text`,\n * etc.) are inherited from `:root`, where {@link injectTokens} installs them.\n * Use as `static styles = [tokens, css`…`]`.\n * - **`injectTokens()`** — injects `:root { … }` into the page `<head>` once.\n * This makes semantic aliases available to every devtools surface, both\n * runtime elements (indicator, source-overlay) that build their shadow DOM\n * via `innerHTML` and Lit panel components that inherit from `:root`.\n * The injected stylesheet reacts to `prefers-color-scheme` and to\n * `.color-scheme-light` / `.color-scheme-dark` classes on `:root`.\n *\n * Sourced from the lit-design skill (`tokens/colors.css`). Defaults to the\n * dark DevTools theme; the light lit.dev website palette is applied when the\n * OS/browser requests a light color scheme or when `:root` has the matching\n * theme class.\n *\n * Fonts are system stacks (no webfonts). For the branded Manrope + Roboto Mono\n * see the lit-design skill's `fonts/` directory.\n */\n\nconst baseTokenCSS = `\n /* ---- Brand · the Lit flame ---- */\n --lit-devtools-lit-blue: #324fff;\n --lit-devtools-lit-blue-bright: #4d63ff;\n --lit-devtools-lit-indigo: #2a2c9d;\n --lit-devtools-lit-dark-blue: #283198;\n --lit-devtools-lit-cyan: #00ffff;\n --lit-devtools-lit-dark-cyan: #00e8ff;\n\n /* ---- Neutral ink scale (0 = near-black, 13 = white) ---- */\n --lit-devtools-ink-0: hsl(0 0% 1%);\n --lit-devtools-ink-1: hsl(0 0% 5%);\n --lit-devtools-ink-2: hsl(0 0% 7%);\n --lit-devtools-ink-3: hsl(0 0% 11%);\n --lit-devtools-ink-4: hsl(0 0% 13%);\n --lit-devtools-ink-5: hsl(0 0% 16%);\n --lit-devtools-ink-6: hsl(0 0% 21%);\n --lit-devtools-ink-7: hsl(0 0% 28%);\n --lit-devtools-ink-8: hsl(0 0% 38%);\n --lit-devtools-ink-9: hsl(0 0% 57%);\n --lit-devtools-ink-10: hsl(0 0% 63%);\n --lit-devtools-ink-11: hsl(0 0% 78%);\n --lit-devtools-ink-12: hsl(0 0% 89%);\n --lit-devtools-ink-13: hsl(0 0% 100%);\n\n /* ---- Typography ---- */\n --lit-devtools-font-sans: system-ui, -apple-system, 'Segoe UI', sans-serif;\n --lit-devtools-font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;\n\n --lit-devtools-weight-regular: 400;\n --lit-devtools-weight-medium: 500;\n --lit-devtools-weight-semibold: 600;\n --lit-devtools-weight-bold: 700;\n --lit-devtools-weight-extrabold: 800;\n\n --lit-devtools-text-2xs: 11px;\n --lit-devtools-text-xs: 12px;\n --lit-devtools-text-sm: 13px;\n --lit-devtools-text-md: 14px;\n --lit-devtools-text-base:16px;\n\n --lit-devtools-leading-tight: 1.15;\n --lit-devtools-leading-snug: 1.3;\n --lit-devtools-leading-normal: 1.5;\n\n --lit-devtools-tracking-tight: -0.02em;\n --lit-devtools-tracking-snug: -0.01em;\n --lit-devtools-tracking-normal: 0;\n --lit-devtools-tracking-wide: 0.02em;\n --lit-devtools-tracking-caps: 0.06em;\n\n /* ---- Spacing (4px base) ---- */\n --lit-devtools-space-0: 0;\n --lit-devtools-space-1: 2px;\n --lit-devtools-space-2: 4px;\n --lit-devtools-space-3: 6px;\n --lit-devtools-space-4: 8px;\n --lit-devtools-space-5: 12px;\n --lit-devtools-space-6: 16px;\n --lit-devtools-space-7: 20px;\n --lit-devtools-space-8: 24px;\n --lit-devtools-space-9: 32px;\n\n /* ---- Radius ---- */\n --lit-devtools-radius-xs: 3px;\n --lit-devtools-radius-sm: 5px;\n --lit-devtools-radius-md: 8px;\n --lit-devtools-radius-lg: 12px;\n --lit-devtools-radius-xl: 16px;\n --lit-devtools-radius-pill: 999px;\n\n /* ---- Elevation ---- */\n --lit-devtools-shadow-xs: 0 1px 2px hsl(0 0% 0% / 0.30);\n --lit-devtools-shadow-sm: 0 1px 5px hsl(0 0% 0% / 0.35);\n --lit-devtools-shadow-md: 0 4px 14px hsl(0 0% 0% / 0.40);\n --lit-devtools-shadow-lg: 0 12px 32px hsl(0 0% 0% / 0.50);\n --lit-devtools-shadow-xl: 0 24px 64px hsl(0 0% 0% / 0.55);\n --lit-devtools-shadow-window: 0 24px 80px hsl(0 0% 0% / 0.6),\n 0 0 0 1px hsl(0 0% 100% / 0.06);\n --lit-devtools-ring: 0 0 0 2px var(--lit-devtools-accent-ring);\n\n /* ---- Motion ---- */\n --lit-devtools-ease-standard: cubic-bezier(0.2, 0, 0, 1);\n --lit-devtools-dur-fast: 140ms;\n --lit-devtools-dur-normal: 220ms;\n`;\n\nconst darkThemeCSS = `\n /* ---- DARK · DevTools theme ---- */\n --lit-devtools-accent: var(--lit-devtools-lit-blue-bright);\n --lit-devtools-accent-hover: #6478ff;\n --lit-devtools-accent-pressed: #3d54f0;\n --lit-devtools-accent-soft: hsla(232 100% 65% / 0.16);\n --lit-devtools-accent-ring: hsla(232 100% 65% / 0.45);\n --lit-devtools-on-accent: #ffffff;\n --lit-devtools-accent-cyan: var(--lit-devtools-lit-dark-cyan);\n\n --lit-devtools-bg: var(--lit-devtools-ink-0);\n --lit-devtools-surface: var(--lit-devtools-ink-2);\n --lit-devtools-surface-low: var(--lit-devtools-ink-1);\n --lit-devtools-surface-container: var(--lit-devtools-ink-4);\n --lit-devtools-surface-container-high: var(--lit-devtools-ink-5);\n --lit-devtools-surface-elevated: var(--lit-devtools-ink-6);\n --lit-devtools-surface-hover: hsl(0 0% 100% / 0.04);\n --lit-devtools-surface-active: hsl(0 0% 100% / 0.07);\n\n --lit-devtools-text: var(--lit-devtools-ink-12);\n --lit-devtools-text-strong: var(--lit-devtools-ink-13);\n --lit-devtools-text-secondary: var(--lit-devtools-ink-10);\n --lit-devtools-text-muted: var(--lit-devtools-ink-8);\n --lit-devtools-text-link: var(--lit-devtools-lit-blue-bright);\n\n --lit-devtools-border: var(--lit-devtools-ink-6);\n --lit-devtools-border-strong: var(--lit-devtools-ink-7);\n --lit-devtools-border-subtle: hsl(0 0% 100% / 0.06);\n\n --lit-devtools-success: hsl(158 74% 53%);\n --lit-devtools-success-soft: hsl(158 74% 53% / 0.15);\n --lit-devtools-warning: #f4bf4f;\n --lit-devtools-warning-soft: hsl(43 88% 63% / 0.15);\n --lit-devtools-error: #ff6b6b;\n --lit-devtools-error-soft: hsl(0 100% 71% / 0.15);\n --lit-devtools-info: var(--lit-devtools-lit-dark-cyan);\n --lit-devtools-info-soft: hsl(187 100% 47% / 0.15);\n\n --lit-devtools-selection-bg: var(--lit-devtools-accent);\n --lit-devtools-on-selection: #ffffff;\n\n color-scheme: dark;\n`;\n\nconst lightThemeCSS = `\n /* ---- LIGHT · lit.dev website theme ---- */\n --lit-devtools-accent: var(--lit-devtools-lit-blue);\n --lit-devtools-accent-hover: #1f3bff;\n --lit-devtools-accent-pressed: #2a2c9d;\n --lit-devtools-accent-soft: hsla(232 100% 60% / 0.12);\n --lit-devtools-accent-ring: hsla(232 100% 60% / 0.40);\n --lit-devtools-on-accent: #ffffff;\n --lit-devtools-accent-cyan: var(--lit-devtools-lit-dark-cyan);\n\n --lit-devtools-bg: #f4f4f4;\n --lit-devtools-surface: #ffffff;\n --lit-devtools-surface-low: #f3f3f3;\n --lit-devtools-surface-container: #ffffff;\n --lit-devtools-surface-container-high: #e8e8e8;\n --lit-devtools-surface-elevated: #ffffff;\n --lit-devtools-surface-hover: hsl(0 0% 0% / 0.04);\n --lit-devtools-surface-active: hsl(0 0% 0% / 0.07);\n\n --lit-devtools-text: #242424;\n --lit-devtools-text-strong: #000000;\n --lit-devtools-text-secondary: #6e6e6e;\n --lit-devtools-text-muted: #949494;\n --lit-devtools-text-link: #005dc7;\n\n --lit-devtools-border: #e2e2e2;\n --lit-devtools-border-strong: #c6c6c6;\n --lit-devtools-border-subtle: hsl(0 0% 0% / 0.07);\n\n --lit-devtools-success: #00865b;\n --lit-devtools-success-soft: hsl(158 100% 26% / 0.10);\n --lit-devtools-warning: #b26a00;\n --lit-devtools-warning-soft: hsl(40 100% 35% / 0.10);\n --lit-devtools-error: #ba1a1a;\n --lit-devtools-error-soft: hsl(0 75% 42% / 0.10);\n --lit-devtools-info: #005dc7;\n --lit-devtools-info-soft: hsl(210 100% 39% / 0.10);\n\n --lit-devtools-selection-bg: var(--lit-devtools-accent);\n --lit-devtools-on-selection: #ffffff;\n\n color-scheme: light;\n`;\n\n/**\n * Default dark theme tokens as a flat string, primarily for use by\n * {@link injectTokens}. Prefer importing `tokens` for Lit components so the\n * semantic aliases are inherited from `:root`.\n */\nexport const tokenCSS = `${baseTokenCSS}\\n${darkThemeCSS}`;\n\n/**\n * Lit `css` template for use in panel component shadow roots.\n *\n * ```ts\n * import {tokens} from '../lib/tokens.js';\n * // ...\n * static override styles = [tokens, css`…`];\n * ```\n *\n * This installs the theme-agnostic base tokens on `:host`. Semantic aliases\n * (`--lit-devtools-bg`, `--lit-devtools-text`, etc.) are inherited from `:root`, where they are installed\n * by {@link injectTokens}. The panel iframe calls `injectTokens()` from\n * \\`lit-devtools-panel.ts\\` so all components inherit the same dark/light theme.\n */\nexport const tokens = css`\n :host {\n ${unsafeCSS(baseTokenCSS)}\n }\n`;\n\nlet _injected = false;\n\n/**\n * Injects `:root { … }` into the page `<head>` once.\n *\n * CSS custom properties defined on `:root` cascade through shadow DOM\n * boundaries, so this makes every `var(--lit-devtools-accent)` etc. resolve inside both\n * runtime elements (indicator, source-overlay) and Lit panel components.\n *\n * The injected stylesheet reacts to `prefers-color-scheme` and to\n * `.color-scheme-light` / `.color-scheme-dark` classes on the document root.\n */\nexport const injectTokens = (): void => {\n if (_injected) return;\n _injected = true;\n const style = document.createElement('style');\n style.setAttribute('data-lit-devtools-tokens', '');\n style.textContent = `\n :root {\n ${baseTokenCSS}\n ${darkThemeCSS}\n }\n @media (prefers-color-scheme: light) {\n :root {\n ${lightThemeCSS}\n }\n }\n :root.color-scheme-light {\n ${lightThemeCSS}\n }\n :root.color-scheme-dark {\n ${darkThemeCSS}\n }\n `;\n document.head.prepend(style);\n};\n"]}
@@ -10,9 +10,9 @@ import MagicString from 'magic-string';
10
10
  * import-analysis resolves them through our `resolveId` and encodes the
11
11
  * `\0` for the browser, so it never reaches the network.
12
12
  */
13
- export declare const VIRTUAL_PREFIX = "\0lit-hmr:";
13
+ export declare const VIRTUAL_PREFIX = "\0lit-plugin:";
14
14
  /** Virtual module that installs the define interceptor. */
15
- export declare const INSTALL_ID = "\0lit-hmr:install";
15
+ export declare const INSTALL_ID = "\0lit-plugin:install";
16
16
  /**
17
17
  * A module needs the define interceptor + self-accept if it registers
18
18
  * custom elements: a textual `customElements.define(` call, or — only when
@@ -20,7 +20,7 @@ export declare const INSTALL_ID = "\0lit-hmr:install";
20
20
  * decorator runtime call stays textually present after TS transpilation).
21
21
  */
22
22
  export declare const isComponentModule: (code: string, hasLitFamilyImport: boolean) => boolean;
23
- export interface LitHmrTransformResult {
23
+ export interface LitPluginTransformResult {
24
24
  code: string;
25
25
  map: ReturnType<MagicString['generateMap']>;
26
26
  }
@@ -29,7 +29,7 @@ export interface LitHmrTransformResult {
29
29
  *
30
30
  * - Pass 1 (all user modules — shared template-partial modules must intern
31
31
  * too): rewrite import/export-from/dynamic-import specifiers found in the
32
- * wrap table to their `\0lit-hmr:` wrapper module.
32
+ * wrap table to their `\0lit-plugin:` wrapper module.
33
33
  * - Pass 2 (component modules): prepend the interceptor install import
34
34
  * (static imports hoist, so the interceptor is installed before this
35
35
  * module's defines) and append a self-accept (re-execution alone triggers
@@ -37,5 +37,5 @@ export interface LitHmrTransformResult {
37
37
  *
38
38
  * Returns `null` when the module needs no changes.
39
39
  */
40
- export declare const transformLitModule: (code: string) => Promise<LitHmrTransformResult | null>;
40
+ export declare const transformLitModule: (code: string) => Promise<LitPluginTransformResult | null>;
41
41
  //# sourceMappingURL=transform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-hmr/src/lib/transform.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,WAAW,MAAM,cAAc,CAAC;AAGvC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,eAAe,CAAC;AAE3C,2DAA2D;AAC3D,eAAO,MAAM,UAAU,sBAA6B,CAAC;AASrD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,oBAAoB,OAAO,KAC1B,OAEwD,CAAC;AAE5D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;CAC7C;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,KACX,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAqDtC,CAAC"}
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/transform.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,WAAW,MAAM,cAAc,CAAC;AAGvC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAE9C,2DAA2D;AAC3D,eAAO,MAAM,UAAU,yBAA6B,CAAC;AASrD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EACZ,oBAAoB,OAAO,KAC1B,OAIwD,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;CAC7C;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,KACX,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAqDzC,CAAC"}
package/lib/transform.js CHANGED
@@ -12,7 +12,7 @@ import { WRAP_TABLE } from './wrap-table.js';
12
12
  * import-analysis resolves them through our `resolveId` and encodes the
13
13
  * `\0` for the browser, so it never reaches the network.
14
14
  */
15
- export const VIRTUAL_PREFIX = '\0lit-hmr:';
15
+ export const VIRTUAL_PREFIX = '\0lit-plugin:';
16
16
  /** Virtual module that installs the define interceptor. */
17
17
  export const INSTALL_ID = `${VIRTUAL_PREFIX}install`;
18
18
  const LIT_FAMILY_PACKAGES = ['lit', 'lit-html', 'lit-element'];
@@ -25,14 +25,14 @@ const isLitFamilySpecifier = (spec) => LIT_FAMILY_PACKAGES.some((p) => spec ===
25
25
  * a lit-family import is present — a `customElement(` decorator call (the
26
26
  * decorator runtime call stays textually present after TS transpilation).
27
27
  */
28
- export const isComponentModule = (code, hasLitFamilyImport) => code.includes('customElements.define(') ||
28
+ export const isComponentModule = (code, hasLitFamilyImport) => /(?<![.\w$])(?:(?:window|globalThis|self)\.)?customElements\.define\s*\(/.test(code) ||
29
29
  (hasLitFamilyImport && /\bcustomElement\s*\(/.test(code));
30
30
  /**
31
31
  * The whole dev transform, as a pure function of the module source:
32
32
  *
33
33
  * - Pass 1 (all user modules — shared template-partial modules must intern
34
34
  * too): rewrite import/export-from/dynamic-import specifiers found in the
35
- * wrap table to their `\0lit-hmr:` wrapper module.
35
+ * wrap table to their `\0lit-plugin:` wrapper module.
36
36
  * - Pass 2 (component modules): prepend the interceptor install import
37
37
  * (static imports hoist, so the interceptor is installed before this
38
38
  * module's defines) and append a self-accept (re-execution alone triggers
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../packages/labs/vite-hmr/src/lib/transform.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,IAAI,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAE3C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,cAAc,SAAS,CAAC;AAErD,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;AAC/D,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AAElD,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAW,EAAE,CACrD,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvE,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAAY,EACZ,kBAA2B,EAClB,EAAE,CACX,IAAI,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IACvC,CAAC,kBAAkB,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAO5D;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,kBAA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AAC;YACN,kEAAkE;YAClE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,cAAc,GAAG,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,IAAI,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,CAAC,EAAE,CAAC;QAChD,EAAE,CAAC,OAAO,CAAC,WAAW,UAAU,MAAM,CAAC,CAAC;QACxC,EAAE,CAAC,MAAM,CAAC,gCAAgC,CAAC,CAAC;QAC5C,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,IAAI,EAAE,EAAE,CAAC,QAAQ,EAAE;QACnB,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,EAAC,KAAK,EAAE,UAAU,EAAC,CAAC;KACzC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {init, parse} from 'es-module-lexer';\nimport MagicString from 'magic-string';\nimport {WRAP_TABLE} from './wrap-table.js';\n\n/**\n * Prefix for this plugin's virtual module ids. Rewritten specifiers carry\n * the `\\0` convention directly in the transformed source; Vite's\n * import-analysis resolves them through our `resolveId` and encodes the\n * `\\0` for the browser, so it never reaches the network.\n */\nexport const VIRTUAL_PREFIX = '\\0lit-hmr:';\n\n/** Virtual module that installs the define interceptor. */\nexport const INSTALL_ID = `${VIRTUAL_PREFIX}install`;\n\nconst LIT_FAMILY_PACKAGES = ['lit', 'lit-html', 'lit-element'];\nconst LIT_FAMILY_SCOPES = ['@lit/', '@lit-labs/'];\n\nconst isLitFamilySpecifier = (spec: string): boolean =>\n LIT_FAMILY_PACKAGES.some((p) => spec === p || spec.startsWith(`${p}/`)) ||\n LIT_FAMILY_SCOPES.some((s) => spec.startsWith(s));\n\n/**\n * A module needs the define interceptor + self-accept if it registers\n * custom elements: a textual `customElements.define(` call, or — only when\n * a lit-family import is present — a `customElement(` decorator call (the\n * decorator runtime call stays textually present after TS transpilation).\n */\nexport const isComponentModule = (\n code: string,\n hasLitFamilyImport: boolean\n): boolean =>\n code.includes('customElements.define(') ||\n (hasLitFamilyImport && /\\bcustomElement\\s*\\(/.test(code));\n\nexport interface LitHmrTransformResult {\n code: string;\n map: ReturnType<MagicString['generateMap']>;\n}\n\n/**\n * The whole dev transform, as a pure function of the module source:\n *\n * - Pass 1 (all user modules — shared template-partial modules must intern\n * too): rewrite import/export-from/dynamic-import specifiers found in the\n * wrap table to their `\\0lit-hmr:` wrapper module.\n * - Pass 2 (component modules): prepend the interceptor install import\n * (static imports hoist, so the interceptor is installed before this\n * module's defines) and append a self-accept (re-execution alone triggers\n * the define interceptor — no hotUpdate hook needed).\n *\n * Returns `null` when the module needs no changes.\n */\nexport const transformLitModule = async (\n code: string\n): Promise<LitHmrTransformResult | null> => {\n // Cheap pre-filter before parsing.\n if (!code.includes('lit') && !code.includes('customElements')) {\n return null;\n }\n // Idempotency: never re-instrument our own output.\n if (code.includes(VIRTUAL_PREFIX)) {\n return null;\n }\n await init;\n let imports;\n try {\n [imports] = parse(code);\n } catch {\n // Not parseable as a module; leave it to Vite to error.\n return null;\n }\n const ms = new MagicString(code);\n let changed = false;\n let hasLitFamilyImport = false;\n for (const imp of imports) {\n const spec = imp.n;\n if (spec === undefined) {\n continue;\n }\n if (isLitFamilySpecifier(spec)) {\n hasLitFamilyImport = true;\n }\n if (!WRAP_TABLE.has(spec)) {\n continue;\n }\n if (imp.d > -1) {\n // Dynamic import: [s, e) includes the quotes (or backticks) — narrow\n // them to plain quotes around the rewritten specifier.\n ms.overwrite(imp.s, imp.e, `'${VIRTUAL_PREFIX}${spec}'`);\n } else {\n // Static import / export-from: [s, e) is the bare specifier text.\n ms.overwrite(imp.s, imp.e, `${VIRTUAL_PREFIX}${spec}`);\n }\n changed = true;\n }\n if (isComponentModule(code, hasLitFamilyImport)) {\n ms.prepend(`import '${INSTALL_ID}';\\n`);\n ms.append(`\\nimport.meta.hot?.accept();\\n`);\n changed = true;\n }\n if (!changed) {\n return null;\n }\n return {\n code: ms.toString(),\n map: ms.generateMap({hires: 'boundary'}),\n };\n};\n"]}
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/transform.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,IAAI,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAE9C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,cAAc,SAAS,CAAC;AAErD,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;AAC/D,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AAElD,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAW,EAAE,CACrD,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvE,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAAY,EACZ,kBAA2B,EAClB,EAAE,CACX,yEAAyE,CAAC,IAAI,CAC5E,IAAI,CACL;IACD,CAAC,kBAAkB,IAAI,sBAAsB,CAAC,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AAE,GAAG,CAAC,CAAC,EAAE,IAAI,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,kEAAkE;YAClE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,cAAc,GAAG,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,IAAI,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,CAAC,EAAE,CAAC;QAChD,EAAE,CAAC,OAAO,CAAC,WAAW,UAAU,MAAM,CAAC,CAAC;QACxC,EAAE,CAAC,MAAM,CAAC,gCAAgC,CAAC,CAAC;QAC5C,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO;QACL,IAAI,EAAE,EAAE,CAAC,QAAQ,EAAE;QACnB,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,EAAC,KAAK,EAAE,UAAU,EAAC,CAAC;KACzC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {init, parse} from 'es-module-lexer';\nimport MagicString from 'magic-string';\nimport {WRAP_TABLE} from './wrap-table.js';\n\n/**\n * Prefix for this plugin's virtual module ids. Rewritten specifiers carry\n * the `\\0` convention directly in the transformed source; Vite's\n * import-analysis resolves them through our `resolveId` and encodes the\n * `\\0` for the browser, so it never reaches the network.\n */\nexport const VIRTUAL_PREFIX = '\\0lit-plugin:';\n\n/** Virtual module that installs the define interceptor. */\nexport const INSTALL_ID = `${VIRTUAL_PREFIX}install`;\n\nconst LIT_FAMILY_PACKAGES = ['lit', 'lit-html', 'lit-element'];\nconst LIT_FAMILY_SCOPES = ['@lit/', '@lit-labs/'];\n\nconst isLitFamilySpecifier = (spec: string): boolean =>\n LIT_FAMILY_PACKAGES.some((p) => spec === p || spec.startsWith(`${p}/`)) ||\n LIT_FAMILY_SCOPES.some((s) => spec.startsWith(s));\n\n/**\n * A module needs the define interceptor + self-accept if it registers\n * custom elements: a textual `customElements.define(` call, or — only when\n * a lit-family import is present — a `customElement(` decorator call (the\n * decorator runtime call stays textually present after TS transpilation).\n */\nexport const isComponentModule = (\n code: string,\n hasLitFamilyImport: boolean\n): boolean =>\n /(?<![.\\w$])(?:(?:window|globalThis|self)\\.)?customElements\\.define\\s*\\(/.test(\n code\n ) ||\n (hasLitFamilyImport && /\\bcustomElement\\s*\\(/.test(code));\n\nexport interface LitPluginTransformResult {\n code: string;\n map: ReturnType<MagicString['generateMap']>;\n}\n\n/**\n * The whole dev transform, as a pure function of the module source:\n *\n * - Pass 1 (all user modules — shared template-partial modules must intern\n * too): rewrite import/export-from/dynamic-import specifiers found in the\n * wrap table to their `\\0lit-plugin:` wrapper module.\n * - Pass 2 (component modules): prepend the interceptor install import\n * (static imports hoist, so the interceptor is installed before this\n * module's defines) and append a self-accept (re-execution alone triggers\n * the define interceptor — no hotUpdate hook needed).\n *\n * Returns `null` when the module needs no changes.\n */\nexport const transformLitModule = async (\n code: string\n): Promise<LitPluginTransformResult | null> => {\n // Cheap pre-filter before parsing.\n if (!code.includes('lit') && !code.includes('customElements')) {\n return null;\n }\n // Idempotency: never re-instrument our own output.\n if (code.includes(VIRTUAL_PREFIX)) {\n return null;\n }\n await init;\n let imports;\n try {\n [imports] = parse(code);\n } catch {\n // Not parseable as a module; leave it to Vite to error.\n return null;\n }\n const ms = new MagicString(code);\n let changed = false;\n let hasLitFamilyImport = false;\n for (const imp of imports) {\n const spec = imp.n;\n if (spec === undefined) {\n continue;\n }\n if (isLitFamilySpecifier(spec)) {\n hasLitFamilyImport = true;\n }\n if (!WRAP_TABLE.has(spec)) {\n continue;\n }\n if (imp.d > -1) {\n // Dynamic import: [s, e) includes the quotes (or backticks) — narrow\n // them to plain quotes around the rewritten specifier.\n ms.overwrite(imp.s, imp.e, `'${VIRTUAL_PREFIX}${spec}'`);\n } else {\n // Static import / export-from: [s, e) is the bare specifier text.\n ms.overwrite(imp.s, imp.e, `${VIRTUAL_PREFIX}${spec}`);\n }\n changed = true;\n }\n if (isComponentModule(code, hasLitFamilyImport)) {\n ms.prepend(`import '${INSTALL_ID}';\\n`);\n ms.append(`\\nimport.meta.hot?.accept();\\n`);\n changed = true;\n }\n if (!changed) {\n return null;\n }\n return {\n code: ms.toString(),\n map: ms.generateMap({hires: 'boundary'}),\n };\n};\n"]}
package/lib/types.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ export interface ElementInfo {
7
+ tagName: string;
8
+ componentName?: string;
9
+ source: {
10
+ filePath: string;
11
+ lineNumber: number;
12
+ };
13
+ }
14
+ export interface EditorConfig {
15
+ name: string;
16
+ url: (path: string, line: number) => string;
17
+ }
18
+ export interface SourceOverlayOptions {
19
+ /**
20
+ * Hotkey letter with Ctrl+Shift (default `s` -> Ctrl+Shift+S).
21
+ */
22
+ key?: string;
23
+ /** Built-in editor key or custom `{ name, url }`. Defaults to `vscode`. */
24
+ editor?: EditorConfig | string;
25
+ /** Optional workspace root prefix for absolute file paths. */
26
+ workspaceRoot?: string;
27
+ /** Mouse move throttle in ms (default 50). */
28
+ throttleMs?: number;
29
+ /** Filter elements to skip during inspection. */
30
+ exclude?: (el: Element) => boolean;
31
+ /** Callback fired when the user clicks a component. */
32
+ onSelect?: (info: ElementInfo) => void;
33
+ }
34
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CAC7C;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,2EAA2E;IAC3E,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IAE/B,8DAA8D;IAC9D,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,iDAAiD;IACjD,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC;IAEnC,uDAAuD;IACvD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC"}
package/lib/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nexport interface ElementInfo {\n tagName: string;\n componentName?: string;\n source: {\n filePath: string;\n lineNumber: number;\n };\n}\n\nexport interface EditorConfig {\n name: string;\n url: (path: string, line: number) => string;\n}\n\nexport interface SourceOverlayOptions {\n /**\n * Hotkey letter with Ctrl+Shift (default `s` -> Ctrl+Shift+S).\n */\n key?: string;\n\n /** Built-in editor key or custom `{ name, url }`. Defaults to `vscode`. */\n editor?: EditorConfig | string;\n\n /** Optional workspace root prefix for absolute file paths. */\n workspaceRoot?: string;\n\n /** Mouse move throttle in ms (default 50). */\n throttleMs?: number;\n\n /** Filter elements to skip during inspection. */\n exclude?: (el: Element) => boolean;\n\n /** Callback fired when the user clicks a component. */\n onSelect?: (info: ElementInfo) => void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-table.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-hmr/src/lib/wrap-table.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAC;IACvD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAQD,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAehE,CAAC"}
1
+ {"version":3,"file":"wrap-table.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/wrap-table.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,CAAC;IACvD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAQD,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAehE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-table.js","sourceRoot":"","sources":["../../../packages/labs/vite-hmr/src/lib/wrap-table.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAsBH,MAAM,IAAI,GAAG,CAAC,GAAG,KAAsC,EAAgB,EAAE,CACvE,KAAK,CAAC,GAAG,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\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * The exact wrap surface: which template-tag exports of which lit-family\n * module specifiers get interned, and in which namespace.\n *\n * Namespaces are per tag *type*, not per module — `html` from `'lit'` and\n * from `'lit-html'` feed the same lit-html template cache, so they must\n * share canonical arrays. But content-equal `html` and `svg` templates must\n * never share one (a shared Template would parse SVG as HTML), and the\n * static-html tags pass zero-statics calls straight through to lit-html, so\n * they get their own namespaces too.\n *\n * Specifiers must be valid export-map subpaths (e.g. `lit/index.js` and\n * `lit-html/lit-html.js` are not, and are deliberately absent).\n */\n\nexport interface WrappedTag {\n readonly exportName: 'html' | 'svg' | 'mathml' | 'css';\n readonly ns: string;\n}\n\nconst tags = (...names: Array<WrappedTag['exportName']>): WrappedTag[] =>\n names.map((exportName) => ({exportName, ns: exportName}));\n\nconst staticTags = (...names: Array<WrappedTag['exportName']>): WrappedTag[] =>\n names.map((exportName) => ({exportName, ns: `static-${exportName}`}));\n\nexport const WRAP_TABLE: ReadonlyMap<string, readonly WrappedTag[]> = new Map([\n ['lit', tags('html', 'svg', 'mathml', 'css')],\n ['lit/html.js', tags('html', 'svg', 'mathml')],\n ['lit/static-html.js', staticTags('html', 'svg', 'mathml')],\n ['lit-html', tags('html', 'svg', 'mathml')],\n ['lit-html/static.js', staticTags('html', 'svg', 'mathml')],\n ['lit-element', tags('html', 'svg', 'mathml', 'css')],\n ['lit-element/lit-element.js', tags('html', 'svg', 'mathml', 'css')],\n ['@lit/reactive-element', tags('css')],\n ['@lit/reactive-element/css-tag.js', tags('css')],\n // The signals tags wrap the user's values but pass the strings array\n // straight through to lit-html's core tags, so they intern in the same\n // namespaces as plain html/svg (content-equal templates share a cache\n // entry either way).\n ['@lit-labs/signals', tags('html', 'svg')],\n]);\n"]}
1
+ {"version":3,"file":"wrap-table.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/wrap-table.ts"],"names":[],"mappings":"AAAA;;;;GAIG;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B,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC3C,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * The exact wrap surface: which template-tag exports of which lit-family\n * module specifiers get interned, and in which namespace.\n *\n * Namespaces are per tag *type*, not per module — `html` from `'lit'` and\n * from `'lit-html'` feed the same lit-html template cache, so they must\n * share canonical arrays. But content-equal `html` and `svg` templates must\n * never share one (a shared Template would parse SVG as HTML), and the\n * static-html tags pass zero-statics calls straight through to lit-html, so\n * they get their own namespaces too.\n *\n * Specifiers must be valid export-map subpaths (e.g. `lit/index.js` and\n * `lit-html/lit-html.js` are not, and are deliberately absent).\n */\n\nexport interface WrappedTag {\n readonly exportName: 'html' | 'svg' | 'mathml' | 'css';\n readonly ns: string;\n}\n\nconst tags = (...names: Array<WrappedTag['exportName']>): WrappedTag[] =>\n names.map((exportName) => ({exportName, ns: exportName}));\n\nconst staticTags = (...names: Array<WrappedTag['exportName']>): WrappedTag[] =>\n names.map((exportName) => ({exportName, ns: `static-${exportName}`}));\n\nexport const WRAP_TABLE: ReadonlyMap<string, readonly WrappedTag[]> = new Map([\n ['lit', tags('html', 'svg', 'mathml', 'css')],\n ['lit/html.js', tags('html', 'svg', 'mathml')],\n ['lit/static-html.js', staticTags('html', 'svg', 'mathml')],\n ['lit-html', tags('html', 'svg', 'mathml')],\n ['lit-html/static.js', staticTags('html', 'svg', 'mathml')],\n ['lit-element', tags('html', 'svg', 'mathml', 'css')],\n ['lit-element/lit-element.js', tags('html', 'svg', 'mathml', 'css')],\n ['@lit/reactive-element', tags('css')],\n ['@lit/reactive-element/css-tag.js', tags('css')],\n // The signals tags wrap the user's values but pass the strings array\n // straight through to lit-html's core tags, so they intern in the same\n // namespaces as plain html/svg (content-equal templates share a cache\n // entry either way).\n ['@lit-labs/signals', tags('html', 'svg')],\n]);\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oddsquad/vite-plugin-lit",
3
- "version": "0.0.3",
4
- "description": "Vite plugin providing true HMR for Lit components",
3
+ "version": "0.0.5",
4
+ "description": "Vite plugin providing true HMR for Lit components, plus CSS helpers and a DevTools panel",
5
5
  "license": "BSD-3-Clause",
6
6
  "author": "Oddsquad (based on @lit-labs/vite-hmr by Google LLC)",
7
7
  "type": "module",
@@ -9,24 +9,38 @@
9
9
  "module": "index.js",
10
10
  "files": [
11
11
  "/lib/",
12
+ "/types/",
13
+ "/panel/",
12
14
  "/index.{d.ts,d.ts.map,js,js.map}"
13
15
  ],
14
16
  "exports": {
15
17
  ".": {
16
18
  "types": "./index.d.ts",
17
19
  "default": "./index.js"
20
+ },
21
+ "./css.js": {
22
+ "types": "./lib/runtime/css.d.ts",
23
+ "default": "./lib/runtime/css.js"
18
24
  }
19
25
  },
20
26
  "scripts": {
21
- "build": "tsc",
27
+ "build": "tsc && node scripts/copy-panel-html.mjs",
22
28
  "prepublishOnly": "npm run build"
23
29
  },
24
30
  "dependencies": {
25
31
  "es-module-lexer": "^1.5.4",
32
+ "launch-editor": "^2.10.0",
26
33
  "magic-string": "^0.30.11"
27
34
  },
28
35
  "peerDependencies": {
29
- "vite": "^8.0.0"
36
+ "lightningcss": "^1.30.0",
37
+ "lit": "^3.0.0",
38
+ "vite": "^7.0.0 || ^8.0.0"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "lightningcss": {
42
+ "optional": true
43
+ }
30
44
  },
31
45
  "devDependencies": {
32
46
  "typescript": "^5.7.0"
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import { LitElement, type TemplateResult } from 'lit';
7
+ /**
8
+ * The Components view: a hierarchical tree of the page's Lit elements (left)
9
+ * and a details pane for the selected one (right). A tab of the DevTools panel
10
+ * shell (\`lit-devtools-panel\`).
11
+ *
12
+ * It can't touch the page DOM directly (separate iframe), so it drives the
13
+ * page's inspector runtime over the transport: it POSTs {@link InspectorCommand}s
14
+ * to {@link INSPECT_PATH} and receives {@link InspectorMessage}s on the shared
15
+ * SSE stream's `inspect` event. An overlay inspect-pick arrives as a `pick`
16
+ * message; the view selects that node and asks its host to switch to this tab.
17
+ */
18
+ export declare class ComponentsView extends LitElement {
19
+ static styles: import("lit").CSSResult[];
20
+ private _roots;
21
+ private _selectedId;
22
+ private _details;
23
+ /** True when the selected element is no longer in the page (removed / GC'd). */
24
+ private _gone;
25
+ private _expanded;
26
+ private _picking;
27
+ /** Opt-in live tree (MutationObserver in the page); persisted, default off. */
28
+ private _live;
29
+ private _es;
30
+ connectedCallback(): void;
31
+ disconnectedCallback(): void;
32
+ /** Refresh the tree (and re-arm watch / live mode) once the SSE connects. */
33
+ private _onOpen;
34
+ private _post;
35
+ private _onMessage;
36
+ /**
37
+ * Select an element by id from outside (e.g. a timeline event's "inspect"
38
+ * link). Same as a tree click; the host is responsible for switching tabs.
39
+ */
40
+ selectById(id: number): void;
41
+ private _select;
42
+ /** Expand every ancestor of `id` so the selected node is visible. */
43
+ private _revealAncestors;
44
+ private _toggleExpand;
45
+ private _refresh;
46
+ private _togglePick;
47
+ private _toggleLive;
48
+ private _highlight;
49
+ private _openSource;
50
+ private _renderNode;
51
+ private _renderPropTable;
52
+ private _renderDetails;
53
+ render(): TemplateResult<1>;
54
+ }
55
+ declare global {
56
+ interface HTMLElementTagNameMap {
57
+ 'components-view': ComponentsView;
58
+ }
59
+ }
60
+ //# sourceMappingURL=components-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components-view.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/panel/components-view.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAsB,KAAK,cAAc,EAAC,MAAM,KAAK,CAAC;AAexE;;;;;;;;;;GAUG;AACH,qBACa,cAAe,SAAQ,UAAU;IAC5C,OAAgB,MAAM,4BAoLpB;IAEO,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,QAAQ,CAAiC;IAC1D,gFAAgF;IACvE,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,QAAQ,CAAS;IAClC,+EAA+E;IACtE,OAAO,CAAC,KAAK,CAAS;IAE/B,OAAO,CAAC,GAAG,CAA4B;IAE9B,iBAAiB;IAUjB,oBAAoB;IAU7B,6EAA6E;IAC7E,OAAO,CAAC,OAAO,CAMb;IAMF,OAAO,CAAC,KAAK;IAUb,OAAO,CAAC,UAAU,CA6ChB;IAMF;;;OAGG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI5B,OAAO,CAAC,OAAO;IAcf,qEAAqE;IACrE,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,WAAW;IA8BnB,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,cAAc;IA8Db,MAAM;CAgChB;AAuBD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,cAAc,CAAC;KACnC;CACF"}