@oddsquad/vite-plugin-lit 0.1.0 → 0.2.0

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.
package/lib/plugin.d.ts CHANGED
@@ -119,6 +119,16 @@ export interface ResolvedOptions {
119
119
  * the flat shape the plugin hooks consume.
120
120
  */
121
121
  export declare const resolveOptions: (options: LitPluginOptions, env: Record<string, string>) => ResolvedOptions;
122
+ export declare const createOpenInEditorMiddleware: (allowedRoots: readonly string[]) => (req: {
123
+ url?: string;
124
+ headers?: {
125
+ origin?: string;
126
+ host?: string;
127
+ };
128
+ }, res: {
129
+ statusCode: number;
130
+ end: (msg: string) => void;
131
+ }, next: (err?: unknown) => void) => void;
122
132
  /**
123
133
  * Import-query support, served in dev and build alike (source code using
124
134
  * `?hmr-url`/`?css-sheet` must keep working under `vite build`, where the HMR
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAA2B,KAAK,MAAM,EAAC,MAAM,MAAM,CAAC;AAI3D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAKrD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAEnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC;CAC3C;AAED;;;;;;;;;GASG;AACH,MAAM,MA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AE,MAAM,CAAC,KAC1B,eA4DF,CAAC;AA8DF,eAAO,MAAM,4BAA4B,GACvC,cAAc,SAAS,MAAM,EAAE,MAM7B,KAAK;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,CAAA;CAAC,EAC/D,KAAK;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAC,EACrD,MAAM,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,SAkFhC,CAAC;AAoCF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GACxB,mBAAkB,MAAM,aAA4B,KACnD,MAwFF,CAAC;AAuFF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,UAAS,gBAAqB,KAAG,MAAM,EA0RhE,CAAC"}
package/lib/plugin.js CHANGED
@@ -150,7 +150,10 @@ const isSameOrigin = (headers) => {
150
150
  return false;
151
151
  }
152
152
  };
153
- const createOpenInEditorMiddleware = (root) => {
153
+ export const createOpenInEditorMiddleware = (allowedRoots) => {
154
+ // First entry is the primary root: relative `file` params resolve against
155
+ // it. Every entry grants open access to files beneath it.
156
+ const roots = allowedRoots.map((r) => resolvePath(r));
154
157
  return (req, res, next) => {
155
158
  if (req.url === undefined) {
156
159
  next();
@@ -171,14 +174,16 @@ const createOpenInEditorMiddleware = (root) => {
171
174
  res.end('missing file parameter');
172
175
  return;
173
176
  }
174
- // Confine the open to the project root: resolve the requested path and
175
- // reject anything that escapes `root` (path traversal, absolute paths to
176
- // arbitrary files). `launch-editor` spawns the user's editor on this path,
177
- // so an unvalidated `file` is a local-file-open / arg-injection vector.
178
- const resolved = resolvePath(root, file);
179
- if (resolved !== root && !resolved.startsWith(root + sep)) {
177
+ // Confine the open to the allowed roots: resolve the requested path and
178
+ // reject anything that escapes all of them (path traversal, absolute
179
+ // paths to arbitrary files). `launch-editor` spawns the user's editor on
180
+ // this path, so an unvalidated `file` is a local-file-open /
181
+ // arg-injection vector.
182
+ const resolved = resolvePath(roots[0] ?? process.cwd(), file);
183
+ const allowed = roots.some((root) => resolved === root || resolved.startsWith(root + sep));
184
+ if (!allowed) {
180
185
  res.statusCode = 403;
181
- res.end('file outside project root');
186
+ res.end('file outside allowed roots');
182
187
  return;
183
188
  }
184
189
  if (!existsSync(resolved)) {
@@ -194,14 +199,24 @@ const createOpenInEditorMiddleware = (root) => {
194
199
  import('launch-editor')
195
200
  .then((mod) => {
196
201
  const launch = (mod.default ?? mod);
202
+ // `launch-editor` invokes the callback only on failure — synchronously
203
+ // when it can't guess an editor, later if the spawn errors. Reply `ok`
204
+ // right after launching; the guard keeps a sync failure's 500 first
205
+ // and drops a late async failure (the response is long gone).
206
+ let finished = false;
207
+ const finish = (statusCode, msg) => {
208
+ if (finished)
209
+ return;
210
+ finished = true;
211
+ res.statusCode = statusCode;
212
+ res.end(msg);
213
+ };
197
214
  launch(fileRef, (_fileName, errorMessage) => {
198
215
  if (errorMessage !== null) {
199
- res.statusCode = 500;
200
- res.end(errorMessage);
201
- return;
216
+ finish(500, errorMessage);
202
217
  }
203
- res.end('ok');
204
218
  });
219
+ finish(200, 'ok');
205
220
  })
206
221
  .catch(next);
207
222
  };
@@ -457,7 +472,12 @@ export const litPlugin = (options = {}) => {
457
472
  configureServer(server) {
458
473
  if (!resolved.sourceOverlay)
459
474
  return;
460
- server.middlewares.use(OPEN_IN_EDITOR_PATH, createOpenInEditorMiddleware(root));
475
+ // Allow opens from everything vite itself is willing to serve
476
+ // (`server.fs.allow` defaults to the workspace root), not just
477
+ // `config.root` — in monorepos, component sources regularly live in
478
+ // sibling packages outside the served app's root.
479
+ const fsAllow = server.config.server.fs?.allow ?? [];
480
+ server.middlewares.use(OPEN_IN_EDITOR_PATH, createOpenInEditorMiddleware([root, ...fsAllow]));
461
481
  },
462
482
  transform(code, id, transformOptions) {
463
483
  if (!resolved.sourceOverlay)
package/lib/plugin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACnC,OAAO,EAAC,OAAO,IAAI,WAAW,EAAE,GAAG,EAAC,MAAM,WAAW,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,EAAC,OAAO,EAA+B,MAAM,MAAM,CAAC;AAC3D,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAG9E,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AA6DvD,MAAM,qBAAqB,GAA6B;IACtD,MAAM;IACN,KAAK;IACL,QAAQ;IACR,YAAY;CACb,CAAC;AA8DF,8CAA8C;AAC9C,MAAM,UAAU,GAAG,YAAY,CAAC;AAEhC,2EAA2E;AAC3E,MAAM,OAAO,GAAG,CAAC,CAAqB,EAAuB,EAAE,CAC7D,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,GAAG;IACvB,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,GAAG;QAC1B,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,SAAS,CAAC;AAElB,sEAAsE;AACtE,MAAM,MAAM,GAAG,CAAC,CAAqB,EAAsB,EAAE;IAC3D,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IAClD,MAAM,CAAC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,QAAQ;oBACb,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAC;oBACxC,QAAQ,EAAE,MAAM;iBACjB,CAAC,CAAC;gBACH,kEAAkE;gBAClE,iEAAiE;gBACjE,MAAM,YAAY,GAChB,OAAO,GAAG,oBAAoB,CAAC,mBAAmB,CAAC,CAAC;gBACtD,IAAI,CAAC,IAAI,CAAC;oBACR,GAAG,EAAE,QAAQ;oBACb,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,EAAC;oBAC1C,QAAQ,EAAE,MAAM;iBACjB,CAAC,CAAC;YACL,CAAC;YAED,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5C,CAAC;KACF,CAAC;IACF,wEAAwE;IACxE,0EAA0E;IAC1E,2CAA2C;IAC3C,MAAM,OAAO,GAAa;QACxB,aAAa;QACb,2EAA2E;QAC3E,4EAA4E;QAC5E,aAAa,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC3C,cAAc,EAAE;QAChB,mBAAmB;QACnB,GAAG;KACJ,CAAC;IACF,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACtB,uEAAuE;QACvE,yEAAyE;QACzE,2EAA2E;QAC3E,WAAW;QACX,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {existsSync} from 'node:fs';\nimport {resolve as resolvePath, sep} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {loadEnv, type CSSOptions, type Plugin} from 'vite';\nimport MagicString from 'magic-string';\nimport {injectSourceMeta} from './source-meta.js';\nimport {INSTALL_ID, VIRTUAL_PREFIX, transformLitModule} from './transform.js';\nimport type {SourceOverlayOptions} from './types.js';\nimport type {FeatureSettings} from '../types/timeline.js';\nimport {WRAP_TABLE} from './wrap-table.js';\nimport {litTimelinePlugin} from './timeline-plugin.js';\n\n/**\n * On-page HMR feedback: a small pulsing indicator in the corner of the host\n * page that briefly animates on each HMR update, for at-a-glance feedback\n * without watching the console.\n */\nexport interface HmrIndicatorOptions {\n /** Inject the indicator element. Defaults to `true` (when HMR is enabled). */\n enabled?: boolean;\n\n /**\n * Show a cumulative update count next to the dot (idle opacity 0.5 instead\n * of fully transparent). Defaults to `false`.\n */\n count?: boolean;\n}\n\n/**\n * HMR for Lit component classes and its on-page feedback.\n */\nexport interface HmrOptions {\n /**\n * Enable in-place HMR for Lit component classes. When `false`, the plugin\n * skips all HMR transforms and runtime injection. Defaults to `true`.\n */\n enabled?: boolean;\n\n /**\n * Cycle `disconnectedCallback()`/`connectedCallback()` on live instances\n * after a hot patch. Interning makes this mostly unnecessary, so it's\n * opt-in. Defaults to `false`.\n */\n reconnect?: boolean;\n\n /**\n * What to do when a component can't be hot-patched in place (e.g.\n * standard `accessor` decorators). Defaults to `'reload'`.\n */\n onIncompatible?: 'reload' | 'warn';\n\n /**\n * The on-page update indicator. `true` enables it without a count; an\n * object configures it. Forced off when HMR itself is disabled. Defaults\n * to enabled (without a count).\n */\n indicator?: boolean | HmrIndicatorOptions;\n}\n\n/**\n * What a `?css-sheet` import compiles to under `vite build`.\n *\n * - `'url'`: fetch-backed sheet over the emitted `.css` asset.\n * - `'inline'`: css text embedded in the JS chunk, processed by the css\n * pipeline (`?inline`).\n * - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline\n * (`?raw`).\n * - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise.\n */\nexport type CssSheetBuild = 'auto' | 'url' | 'inline' | 'inline-raw';\n\nconst CSS_SHEET_BUILD_MODES: readonly CssSheetBuild[] = [\n 'auto',\n 'url',\n 'inline',\n 'inline-raw',\n];\n\n/**\n * Options for the Lit Vite plugin.\n *\n * Every option also resolves from environment variables (and `.env` files)\n * with the `LIT_PLUGIN` prefix — e.g. `LIT_PLUGIN_HMR_INDICATOR=true`. Options\n * passed here take precedence over env vars, which take precedence over the\n * built-in defaults.\n */\nexport interface LitPluginOptions {\n /**\n * HMR for Lit components and its on-page feedback. `true`/`false` toggles\n * the whole feature (patching and indicator); an object configures it.\n * Defaults to enabled.\n */\n hmr?: boolean | HmrOptions;\n\n /**\n * Dev-only click-to-open-in-IDE inspector for Lit custom elements.\n * Toggle with Ctrl+Shift+S (configurable via `key`). Defaults to `false`.\n */\n sourceOverlay?: boolean | SourceOverlayOptions;\n\n /**\n * Vite DevTools Timeline panel — a Vue DevTools–style layered event stream\n * for Lit lifecycle, render, mouse, and keyboard events.\n *\n * Requires `@vitejs/devtools` in the Vite config and the `@vitejs/devtools`\n * Vite plugin (`DevTools()`) to be active. Defaults to `false` while\n * experimental.\n *\n * `true` enables all built-in layers with defaults.\n */\n timeline?: boolean;\n\n /**\n * What a `?css-sheet` import compiles to under `vite build`.\n * - `'url'`: fetch-backed sheet over the emitted `.css` asset\n * - `'inline'`: css text embedded in the JS chunk, processed by the css\n * pipeline (`?inline`)\n * - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline\n * (`?raw`)\n * - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise\n *\n * Dev is always the fetch-backed HMR form regardless of this setting.\n * Defaults to `'auto'`.\n */\n cssSheetBuild?: CssSheetBuild;\n}\n\n/** Plugin options after merging explicit options, env vars, and defaults. */\nexport interface ResolvedOptions {\n hmrEnabled: boolean;\n reconnect: boolean;\n onIncompatible: 'reload' | 'warn';\n indicator: false | {count: boolean};\n sourceOverlay: false | SourceOverlayOptions;\n timeline: boolean;\n cssSheetBuild: CssSheetBuild;\n}\n\n/** Env var prefix consumed at config time. */\nconst ENV_PREFIX = 'LIT_PLUGIN';\n\n/** Parse a boolean-ish env string; `undefined` when unset/unrecognized. */\nconst envBool = (v: string | undefined): boolean | undefined =>\n v === 'true' || v === '1'\n ? true\n : v === 'false' || v === '0'\n ? false\n : undefined;\n\n/** Parse a numeric env string; `undefined` when unset/non-numeric. */\nconst envNum = (v: string | undefined): number | undefined => {\n if (v === undefined || v === '') return undefined;\n const n = Number(v);\n return Number.isNaN(n) ? undefined : n;\n};\n\n/**\n * Parse a string against a closed set of values; `undefined` (with a warning)\n * when set to something outside it, so a typo falls back to the default\n * instead of silently disabling a feature.\n */\nconst envEnum = <T extends string>(\n v: string | undefined,\n allowed: readonly T[],\n source: string\n): T | undefined => {\n if (v === undefined || v === '') return undefined;\n if ((allowed as readonly string[]).includes(v)) return v as T;\n console.warn(\n `[lit-plugin] ignoring ${source}=${JSON.stringify(v)}; expected one of ` +\n allowed.map((a) => JSON.stringify(a)).join(', ')\n );\n return undefined;\n};\n\n/**\n * Merge explicit options over env vars over defaults (in that precedence) into\n * the flat shape the plugin hooks consume.\n */\nexport const resolveOptions = (\n options: LitPluginOptions,\n env: Record<string, string>\n): ResolvedOptions => {\n const hmr = options.hmr;\n const hmrObj = typeof hmr === 'object' ? hmr : undefined;\n const hmrEnabled =\n (typeof hmr === 'boolean' ? hmr : hmrObj?.enabled) ??\n envBool(env[`${ENV_PREFIX}_HMR`]) ??\n true;\n const reconnect =\n hmrObj?.reconnect ?? envBool(env[`${ENV_PREFIX}_HMR_RECONNECT`]) ?? false;\n const onIncompatible =\n hmrObj?.onIncompatible ??\n (env[`${ENV_PREFIX}_HMR_ON_INCOMPATIBLE`] as 'reload' | 'warn') ??\n 'reload';\n\n const ind = hmrObj?.indicator;\n const indObj = typeof ind === 'object' ? ind : undefined;\n const indEnabled =\n (typeof ind === 'boolean' ? ind : indObj?.enabled) ??\n envBool(env[`${ENV_PREFIX}_HMR_INDICATOR`]) ??\n true;\n const indCount =\n indObj?.count ?? envBool(env[`${ENV_PREFIX}_HMR_INDICATOR_COUNT`]) ?? false;\n // The indicator is meaningless without HMR, so it follows the master toggle.\n const indicator = hmrEnabled && indEnabled ? {count: indCount} : false;\n\n const so = options.sourceOverlay;\n const soExplicit =\n typeof so === 'boolean' ? so : so === undefined ? undefined : true;\n const soEnabled =\n soExplicit ?? envBool(env[`${ENV_PREFIX}_SOURCE_OVERLAY`]) ?? false;\n let sourceOverlay: false | SourceOverlayOptions = false;\n if (soEnabled) {\n const base: SourceOverlayOptions = typeof so === 'object' ? {...so} : {};\n base.key ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_KEY`] || undefined;\n base.editor ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_EDITOR`] || undefined;\n base.throttleMs ??= envNum(env[`${ENV_PREFIX}_SOURCE_OVERLAY_THROTTLE_MS`]);\n sourceOverlay = base;\n }\n\n const timeline =\n options.timeline ?? envBool(env[`${ENV_PREFIX}_TIMELINE`]) ?? false;\n\n const cssSheetBuild =\n envEnum(options.cssSheetBuild, CSS_SHEET_BUILD_MODES, 'cssSheetBuild') ??\n envEnum(\n env[`${ENV_PREFIX}_CSS_SHEET_BUILD`],\n CSS_SHEET_BUILD_MODES,\n `${ENV_PREFIX}_CSS_SHEET_BUILD`\n ) ??\n 'auto';\n\n return {\n hmrEnabled,\n reconnect,\n onIncompatible,\n indicator,\n sourceOverlay,\n timeline,\n cssSheetBuild,\n };\n};\n\n/**\n * Flattens resolved options into the JSON-serializable shape the panel's\n * Settings tab consumes (callback options like `exclude`/`onSelect` dropped;\n * a custom editor object reported as `\"custom\"`). Default key/editor/throttle\n * are applied here so the panel shows the effective values the runtime uses.\n */\nconst toFeatureSettings = (r: ResolvedOptions): FeatureSettings => {\n const so = r.sourceOverlay;\n const editor = so === false ? undefined : so.editor;\n return {\n hmr: {\n enabled: r.hmrEnabled,\n reconnect: r.reconnect,\n onIncompatible: r.onIncompatible,\n indicatorEnabled: r.indicator !== false,\n indicatorCount: r.indicator !== false && r.indicator.count,\n },\n sourceOverlay: {\n enabled: so !== false,\n key: (so === false ? undefined : so.key) ?? 's',\n editor:\n typeof editor === 'string' ? editor : editor ? 'custom' : 'vscode',\n throttleMs: (so === false ? undefined : so.throttleMs) ?? 50,\n },\n timeline: r.timeline,\n };\n};\n\n/**\n * Resolves a runtime module to an absolute fs path (served via `/@fs/`), so\n * the plugin works from any served root. Falls back from the built `.js` to\n * the `.ts` source when running un-built (e.g. under vitest).\n */\nconst resolveRuntimeModule = (name: string): string => {\n for (const ext of ['js', 'ts'] as const) {\n const url = new URL(`./runtime/${name}.${ext}`, import.meta.url);\n if (existsSync(url)) {\n return fileURLToPath(url).replace(/\\\\/g, '/');\n }\n }\n throw new Error(`[lit-plugin] runtime module not found: ${name}`);\n};\n\nconst JS_FILE_RE = /\\.[cm]?[jt]sx?$/;\n\nconst OPEN_IN_EDITOR_PATH = '/__lit-open-in-editor';\n\n/** Reject requests whose `Origin` is a different host than the dev server, so\n * a page the developer happens to visit can't drive these local-only\n * endpoints. Same-origin requests (no `Origin`, or matching `Host`) pass. */\nconst isSameOrigin = (headers: {origin?: string; host?: string}): boolean => {\n const {origin, host} = headers;\n if (origin === undefined || origin === 'null') return true;\n try {\n return new URL(origin).host === host;\n } catch {\n return false;\n }\n};\n\nconst createOpenInEditorMiddleware = (root: string) => {\n return (\n req: {url?: string; headers?: {origin?: string; host?: string}},\n res: {statusCode: number; end: (msg: string) => void},\n next: (err?: unknown) => void\n ) => {\n if (req.url === undefined) {\n next();\n return;\n }\n if (!isSameOrigin(req.headers ?? {})) {\n res.statusCode = 403;\n res.end('forbidden');\n return;\n }\n const query = req.url.includes('?')\n ? req.url.slice(req.url.indexOf('?') + 1)\n : '';\n const params = new URLSearchParams(query);\n const file = params.get('file');\n if (file === null) {\n res.statusCode = 400;\n res.end('missing file parameter');\n return;\n }\n // Confine the open to the project root: resolve the requested path and\n // reject anything that escapes `root` (path traversal, absolute paths to\n // arbitrary files). `launch-editor` spawns the user's editor on this path,\n // so an unvalidated `file` is a local-file-open / arg-injection vector.\n const resolved = resolvePath(root, file);\n if (resolved !== root && !resolved.startsWith(root + sep)) {\n res.statusCode = 403;\n res.end('file outside project root');\n return;\n }\n if (!existsSync(resolved)) {\n res.statusCode = 404;\n res.end('file not found');\n return;\n }\n // Coerce to integers so a crafted `line`/`column` can't smuggle extra\n // shell-visible content through the `file:line:column` ref.\n const line = String(\n Math.max(1, Number.parseInt(params.get('line') ?? '1', 10) || 1)\n );\n const column = String(\n Math.max(1, Number.parseInt(params.get('column') ?? '1', 10) || 1)\n );\n const fileRef = `${resolved}:${line}:${column}`;\n import('launch-editor')\n .then(\n (mod: {\n default?: (\n file: string,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n }) => {\n const launch = (mod.default ?? mod) as (\n file: string,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n launch(fileRef, (_fileName: string, errorMessage: string | null) => {\n if (errorMessage !== null) {\n res.statusCode = 500;\n res.end(errorMessage);\n return;\n }\n res.end('ok');\n });\n }\n )\n .catch(next);\n };\n};\n\n/**\n * `import href from './x.css?hmr-url'` — `?url` semantics with working HMR.\n * The string is a real stylesheet URL (dev-served CSS file; hashed `.css`\n * asset on build) for shadow-root `<link>` hrefs and `@import url()`s. In\n * dev, each HMR re-execution yields a freshly cache-busted href, so the\n * browser refetches the changed stylesheet; in build the `?url` asset URL\n * passes through unchanged.\n */\nconst CSS_URL_QUERY_RE = /^([^?]+\\.css)\\?(?:[^&]*&)*hmr-url(?:&.*)?$/;\nconst CSS_URL_VIRTUAL_PREFIX = '\\0lit-plugin:hmr-url:';\n\n/**\n * `import sheet from './x.css?css-sheet'` — a constructed, shareable\n * `CSSStyleSheet` backed by the `.css` asset that hot-swaps in place. Adopt it\n * from any number of components (`static styles = [sheet]`); a source edit\n * re-fetches and `replaceSync()`s it, updating every shadow root that adopted\n * it without re-rendering a component or reloading the page.\n *\n * This is the `urlSheet()` helper plus its irreducible HMR wiring, lifted into\n * a plugin-generated module: the `import.meta.hot.accept` lives here (where\n * Vite's static analysis sees the literal specifier), so callers write a bare\n * import and never touch `import.meta.hot` themselves.\n *\n * Under `vite build` the generated module can instead inline the css text (see\n * `cssSheetBuild`) — a library's consumers bundle its JS only, so a\n * fetch-backed sheet would 404 on the `.css` asset that never reached their\n * build.\n */\nconst CSS_SHEET_QUERY_RE = /^([^?]+\\.css)\\?(?:[^&]*&)*css-sheet(?:&.*)?$/;\nconst CSS_SHEET_VIRTUAL_PREFIX = '\\0lit-plugin:css-sheet:';\n// The virtual id must not end in `.css`, or Vite's CSS plugins (which match\n// the id's extension regardless of `\\0`) would compile the wrapper as CSS.\nconst CSS_VIRTUAL_SUFFIX = '.js';\n\n/**\n * Import-query support, served in dev and build alike (source code using\n * `?hmr-url`/`?css-sheet` must keep working under `vite build`, where the HMR\n * plugin doesn't apply). Exported for the baseline e2e run, which needs the\n * queries working without the HMR plugin.\n *\n * `getCssSheetBuild` is a getter, not a value: `litPlugin()` re-resolves its\n * options against the loaded env in a `config` hook, which runs after the\n * plugin array is built. Standalone (no getter) it behaves like the `'auto'`\n * default.\n */\nexport const litCssQueries = (\n getCssSheetBuild: () => CssSheetBuild = () => 'auto'\n): Plugin => {\n let isBuild = false;\n let isLib = false;\n return {\n name: 'lit-css-query',\n // Vite's core resolver claims `./x.css?hmr-url` for the CSS pipeline\n // before normal plugins get a look, so resolve ahead of it.\n enforce: 'pre',\n configResolved(config) {\n isBuild = config.command === 'build';\n isLib = config.build.lib !== false && config.build.lib !== undefined;\n },\n async resolveId(id, importer) {\n const prefix = CSS_URL_QUERY_RE.test(id)\n ? CSS_URL_VIRTUAL_PREFIX\n : CSS_SHEET_QUERY_RE.test(id)\n ? CSS_SHEET_VIRTUAL_PREFIX\n : null;\n if (prefix === null) {\n return null;\n }\n const file = id.slice(0, id.indexOf('?'));\n const resolved = await this.resolve(file, importer);\n if (resolved === null) {\n return null;\n }\n return prefix + resolved.id + CSS_VIRTUAL_SUFFIX;\n },\n load(id) {\n const helperPath = resolveRuntimeModule('css');\n if (id.startsWith(CSS_URL_VIRTUAL_PREFIX)) {\n const file = id.slice(\n CSS_URL_VIRTUAL_PREFIX.length,\n -CSS_VIRTUAL_SUFFIX.length\n );\n return {\n code:\n `import url from ${JSON.stringify(`${file}?url`)};\\n` +\n `import {devCacheBust} from ${JSON.stringify(helperPath)};\\n` +\n `export default devCacheBust(url);\\n`,\n moduleType: 'js',\n };\n }\n if (id.startsWith(CSS_SHEET_VIRTUAL_PREFIX)) {\n const file = id.slice(\n CSS_SHEET_VIRTUAL_PREFIX.length,\n -CSS_VIRTUAL_SUFFIX.length\n );\n const mode = getCssSheetBuild();\n const inlineQuery =\n !isBuild || mode === 'url' || (mode === 'auto' && !isLib)\n ? null\n : mode === 'inline-raw'\n ? '?raw'\n : '?inline';\n if (inlineQuery !== null) {\n // Build only, so no `import.meta.hot` block. The sheet is still\n // constructed once per virtual module, so adopters share it exactly\n // as they do in the fetch-backed form.\n return {\n code:\n `import css from ${JSON.stringify(`${file}${inlineQuery}`)};\\n` +\n `const sheet = new CSSStyleSheet();\\n` +\n `sheet.replaceSync(css);\\n` +\n `export default sheet;\\n`,\n moduleType: 'js',\n };\n }\n // The accept specifier must be byte-identical to the import above —\n // Vite resolves accepted HMR deps by static analysis. Generating both\n // here is exactly what frees the caller from writing it. The swap is\n // self-accepted at this boundary, so it never propagates to adopters.\n const urlSpecifier = JSON.stringify(`${file}?url`);\n return {\n code:\n `import url from ${urlSpecifier};\\n` +\n `import {urlSheet} from ${JSON.stringify(helperPath)};\\n` +\n `const {sheet, onHotUpdate} = urlSheet(url);\\n` +\n `export default sheet;\\n` +\n `if (import.meta.hot) {\\n` +\n ` import.meta.hot.accept(${urlSpecifier}, onHotUpdate);\\n` +\n `}\\n`,\n moduleType: 'js',\n };\n }\n return null;\n },\n };\n};\n\n/**\n * A `css` tagged template literal with no interpolations and no escape\n * sequences — the only kind we can hand to a CSS parser as-is. Literals\n * with `${…}` holes or backslashes simply don't match and stay untouched.\n * The lookbehind keeps `unsafeCSS`/`myCss`-style tags from matching.\n */\nconst CSS_LITERAL_RE = /(?<![\\w$.])css`((?:[^`\\\\$]|\\$(?!\\{))*)`/g;\n\n/**\n * Runs Vite's configured Lightning CSS over `css` tagged template literals\n * in user modules, which the CSS pipeline itself never sees (they're plain\n * JS strings to it). Inert unless `css.transformer` is `'lightningcss'`;\n * options come from `css.lightningcss`, so component styles get the same\n * treatment (targets, drafts, …) as `.css` files. Applies in dev and build.\n */\nconst litCssLiterals = (): Plugin => {\n let lightningcss: typeof import('lightningcss') | null = null;\n let options: CSSOptions['lightningcss'];\n let minify = false;\n return {\n name: 'lit-css-literals',\n async configResolved(config) {\n if (config.css.transformer !== 'lightningcss') {\n return;\n }\n // The transformer setting guarantees the dependency: Vite itself\n // can't process .css files without it.\n lightningcss = await import('lightningcss');\n // cssModules makes no sense for a literal; everything else carries\n // over.\n const {cssModules: _cssModules, ...rest} = config.css.lightningcss ?? {};\n options = rest;\n minify = config.command === 'build';\n },\n transform(code, id) {\n if (lightningcss === null) {\n return null;\n }\n if (id.startsWith('\\0') || id.includes('/node_modules/')) {\n return null;\n }\n const [file] = id.split('?', 2);\n if (!JS_FILE_RE.test(file) || !code.includes('css`')) {\n return null;\n }\n const ms = new MagicString(code);\n let changed = false;\n for (const m of code.matchAll(CSS_LITERAL_RE)) {\n const literal = m[1];\n if (literal.trim() === '') {\n continue;\n }\n let out: string;\n try {\n const result = lightningcss.transform({\n ...options,\n filename: file,\n code: Buffer.from(literal),\n minify,\n });\n out = Buffer.from(result.code).toString();\n } catch (e) {\n this.warn(\n `[lit-plugin] skipping css literal Lightning CSS couldn't parse: ${\n (e as Error).message\n }`\n );\n continue;\n }\n // Re-escape for the template literal the output goes back into.\n out = out.replace(/[\\\\`$]/g, '\\\\$&');\n if (out !== literal) {\n const start = m.index + 'css`'.length;\n ms.overwrite(start, start + literal.length, out);\n changed = true;\n }\n }\n if (!changed) {\n return null;\n }\n return {code: ms.toString(), map: ms.generateMap({hires: true})};\n },\n };\n};\n\n/**\n * Vite plugin set providing HMR, CSS helpers, and Lightning CSS processing\n * for Lit projects.\n */\nexport const litPlugin = (options: LitPluginOptions = {}): Plugin[] => {\n // Resolved from explicit options first, env vars second, defaults last. The\n // `lit-plugin-options` `config` hook below re-resolves with the loaded env\n // once Vite hands us the mode; this initial pass covers code paths that run\n // before (or without) it.\n let resolved: ResolvedOptions = resolveOptions(options, {});\n let root = '';\n // Env resolution lives in its own always-applied plugin: `?css-sheet` is a\n // build-time feature too, and the HMR plugin (`apply: 'serve'`) never gets a\n // `config` hook under `vite build`. `enforce: 'pre'` and first position put\n // it ahead of every other hook that reads `resolved`.\n const optionsPlugin: Plugin = {\n name: 'lit-plugin-options',\n enforce: 'pre',\n config(viteConfig, {mode}) {\n // `loadEnv` reads `.env*` files from the env dir (root by default) and\n // merges in matching `process.env` keys, filtered to the `LIT_PLUGIN`\n // prefix. Explicit options still win (handled in resolveOptions).\n const envDir = viteConfig.envDir\n ? resolvePath(viteConfig.envDir)\n : viteConfig.root\n ? resolvePath(viteConfig.root)\n : process.cwd();\n resolved = resolveOptions(options, loadEnv(mode, envDir, ENV_PREFIX));\n },\n };\n const sourceOverlayPlugin: Plugin = {\n name: 'lit-source-overlay',\n apply: 'serve',\n // Run before Vite's esbuild TS transform so source-meta line numbers are\n // measured against the author's raw source (and the `@customElement … class`\n // forms are still intact), not against transpiled output.\n enforce: 'pre',\n configResolved(config) {\n root = config.root;\n },\n resolveId(id) {\n if (id === '@lit-labs/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n return null;\n },\n configureServer(server) {\n if (!resolved.sourceOverlay) return;\n server.middlewares.use(\n OPEN_IN_EDITOR_PATH,\n createOpenInEditorMiddleware(root)\n );\n },\n transform(code, id, transformOptions) {\n if (!resolved.sourceOverlay) return null;\n if (transformOptions?.ssr) return null;\n if (\n id.startsWith('\\0') ||\n id.includes('__x00__') ||\n id.includes('lit-plugin:') ||\n id.includes('/node_modules/')\n ) {\n return null;\n }\n const [file] = id.split('?', 2);\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n if (!code.includes('customElement') && !code.includes('customElements')) {\n return null;\n }\n const ms = new MagicString(code);\n const relativeFile = file.startsWith(root + '/')\n ? file.slice(root.length + 1)\n : file;\n if (!injectSourceMeta(code, relativeFile, ms)) {\n return null;\n }\n return {code: ms.toString(), map: ms.generateMap({hires: true})};\n },\n transformIndexHtml() {\n if (!resolved.sourceOverlay) return;\n const overlayUrl = `/@fs/${resolveRuntimeModule('source-overlay')}`;\n const {\n exclude: _exclude,\n onSelect: _onSelect,\n ...overlayInit\n } = resolved.sourceOverlay;\n const initConfig = {\n ...overlayInit,\n openInEditorPath: OPEN_IN_EDITOR_PATH,\n };\n return [\n {\n tag: 'script',\n attrs: {type: 'module'},\n children: `import {initSourceOverlay} from ${JSON.stringify(overlayUrl)};\\ninitSourceOverlay(${JSON.stringify(initConfig)});\\n`,\n injectTo: 'body',\n },\n ];\n },\n };\n const hmr: Plugin = {\n name: 'lit-plugin',\n apply: 'serve',\n config: () => {\n // Options are already resolved against the loaded env by\n // `lit-plugin-options`, which runs first.\n if (!resolved.hmrEnabled) {\n return;\n }\n // The injected runtime imports are invisible to the dep scanner. The\n // lit family stays prebundle-eligible on purpose: the wrapper modules'\n // bare imports then resolve to the same URL every other importer gets —\n // single lit instance, single template cache.\n return {optimizeDeps: {exclude: ['@lit-labs/vite-plugin-lit']}};\n },\n resolveId(id) {\n // Public timeline API virtual module.\n if (id === 'virtual:lit-plugin/timeline') {\n return '\\0virtual:lit-plugin/timeline';\n }\n // Resolve the browser CSS helpers and indicator runtime to the copy\n // shipped next to this plugin, so they work even when the package\n // isn't reachable through node resolution from the served root (and\n // stay out of prebundling).\n if (id === '@lit-labs/vite-plugin-lit/css.js') {\n return resolveRuntimeModule('css');\n }\n if (id === '@lit-labs/vite-plugin-lit/indicator.js') {\n return resolveRuntimeModule('indicator');\n }\n if (id === '@lit-labs/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n if (resolved.hmrEnabled && id.startsWith(VIRTUAL_PREFIX)) {\n return id;\n }\n return null;\n },\n load(id) {\n // Public timeline API — re-export the runtime module when timeline is\n // enabled, otherwise a no-op stub so imports don't throw in prod builds.\n if (id === '\\0virtual:lit-plugin/timeline') {\n if (!resolved.timeline) {\n return {\n code:\n 'export const addTimelineEvent = () => {};\\n' +\n 'export const addTimelineLayer = () => {};\\n',\n moduleType: 'js',\n };\n }\n const apiPath = resolveRuntimeModule('timeline/public-api');\n return {\n code: `export * from ${JSON.stringify(apiPath)};\\n`,\n moduleType: 'js',\n };\n }\n if (!resolved.hmrEnabled || !id.startsWith(VIRTUAL_PREFIX)) {\n return null;\n }\n if (id === INSTALL_ID) {\n const patchPath = resolveRuntimeModule('patch');\n const runtimeOptions = {\n reconnect: resolved.reconnect,\n onIncompatible: resolved.onIncompatible,\n };\n return {\n code:\n `import {install} from ${JSON.stringify(patchPath)};\\n` +\n `install(${JSON.stringify(runtimeOptions)});\\n`,\n moduleType: 'js',\n };\n }\n const spec = id.slice(VIRTUAL_PREFIX.length);\n const wrappedTags = WRAP_TABLE.get(spec);\n if (wrappedTags === undefined) {\n return null;\n }\n const internPath = resolveRuntimeModule('intern');\n // Browser-native ESM: explicit local exports shadow `export *` names\n // (spec-guaranteed), so everything except the wrapped tags passes\n // through unchanged.\n const lines = [\n `import * as __lit from ${JSON.stringify(spec)};`,\n `import {wrapTag} from ${JSON.stringify(internPath)};`,\n `export * from ${JSON.stringify(spec)};`,\n ];\n for (const {exportName, ns} of wrappedTags) {\n lines.push(\n `export const ${exportName} = wrapTag(__lit.${exportName}, ${JSON.stringify(\n ns\n )});`\n );\n }\n return {code: lines.join('\\n') + '\\n', moduleType: 'js'};\n },\n async transform(code, id, transformOptions) {\n if (!resolved.hmrEnabled) {\n return null;\n }\n if (transformOptions?.ssr) {\n return null;\n }\n if (id.startsWith('\\0') || id.includes('/node_modules/')) {\n return null;\n }\n const [file] = id.split('?', 2);\n // Allow inline scripts extracted from HTML (`?html-proxy`).\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n return transformLitModule(code);\n },\n transformIndexHtml() {\n const tags: {\n tag: string;\n attrs?: Record<string, string | undefined | boolean>;\n children?: string;\n injectTo: 'body';\n }[] = [];\n\n const indicator = resolved.indicator;\n if (indicator) {\n const indicatorUrl = `/@fs/` + resolveRuntimeModule('indicator');\n tags.push(\n {\n tag: 'script',\n attrs: {type: 'module', src: indicatorUrl},\n injectTo: 'body',\n },\n {\n tag: 'lit-devtools-hmr-indicator',\n attrs: indicator.count ? {count: ''} : undefined,\n children: '',\n injectTo: 'body',\n }\n );\n }\n\n if (resolved.timeline) {\n const installUrl = `/@fs/` + resolveRuntimeModule('timeline/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: installUrl},\n injectTo: 'body',\n });\n // Components inspector runtime — answers the panel's tree/details\n // requests. Paired with the timeline panel, which hosts its tab.\n const inspectorUrl =\n `/@fs/` + resolveRuntimeModule('inspector/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: inspectorUrl},\n injectTo: 'body',\n });\n }\n\n return tags.length > 0 ? tags : undefined;\n },\n };\n // The source-overlay plugin is always present; its hooks no-op when the\n // feature is disabled (which env may decide), so inclusion can't be gated\n // on the synchronously-known options here.\n const plugins: Plugin[] = [\n optionsPlugin,\n // Getter, not a snapshot: `resolved` is re-resolved against the loaded env\n // in `optionsPlugin`'s `config` hook, which runs after this array is built.\n litCssQueries(() => resolved.cssSheetBuild),\n litCssLiterals(),\n sourceOverlayPlugin,\n hmr,\n ];\n if (resolved.timeline) {\n // Pass a getter, not a snapshot: `resolved` is re-resolved against the\n // loaded env in the `config` hook, which runs after this plugin array is\n // built. The settings endpoint reads it per-request, by which point env is\n // applied.\n plugins.push(litTimelinePlugin(() => toFeatureSettings(resolved)));\n }\n return plugins;\n};\n"]}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../packages/labs/v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AC3C,MAAM,OAAO,GAAa;QACxB,aAAa;QACb,2EAA2E;QAC3E,4EAA4E;QAC5E,aAAa,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC3C,cAAc,EAAE;QAChB,mBAAmB;QACnB,GAAG;KACJ,CAAC;IACF,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACtB,uEAAuE;QACvE,yEAAyE;QACzE,2EAA2E;QAC3E,WAAW;QACX,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {existsSync} from 'node:fs';\nimport {resolve as resolvePath, sep} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {loadEnv, type CSSOptions, type Plugin} from 'vite';\nimport MagicString from 'magic-string';\nimport {injectSourceMeta} from './source-meta.js';\nimport {INSTALL_ID, VIRTUAL_PREFIX, transformLitModule} from './transform.js';\nimport type {SourceOverlayOptions} from './types.js';\nimport type {FeatureSettings} from '../types/timeline.js';\nimport {WRAP_TABLE} from './wrap-table.js';\nimport {litTimelinePlugin} from './timeline-plugin.js';\n\n/**\n * On-page HMR feedback: a small pulsing indicator in the corner of the host\n * page that briefly animates on each HMR update, for at-a-glance feedback\n * without watching the console.\n */\nexport interface HmrIndicatorOptions {\n /** Inject the indicator element. Defaults to `true` (when HMR is enabled). */\n enabled?: boolean;\n\n /**\n * Show a cumulative update count next to the dot (idle opacity 0.5 instead\n * of fully transparent). Defaults to `false`.\n */\n count?: boolean;\n}\n\n/**\n * HMR for Lit component classes and its on-page feedback.\n */\nexport interface HmrOptions {\n /**\n * Enable in-place HMR for Lit component classes. When `false`, the plugin\n * skips all HMR transforms and runtime injection. Defaults to `true`.\n */\n enabled?: boolean;\n\n /**\n * Cycle `disconnectedCallback()`/`connectedCallback()` on live instances\n * after a hot patch. Interning makes this mostly unnecessary, so it's\n * opt-in. Defaults to `false`.\n */\n reconnect?: boolean;\n\n /**\n * What to do when a component can't be hot-patched in place (e.g.\n * standard `accessor` decorators). Defaults to `'reload'`.\n */\n onIncompatible?: 'reload' | 'warn';\n\n /**\n * The on-page update indicator. `true` enables it without a count; an\n * object configures it. Forced off when HMR itself is disabled. Defaults\n * to enabled (without a count).\n */\n indicator?: boolean | HmrIndicatorOptions;\n}\n\n/**\n * What a `?css-sheet` import compiles to under `vite build`.\n *\n * - `'url'`: fetch-backed sheet over the emitted `.css` asset.\n * - `'inline'`: css text embedded in the JS chunk, processed by the css\n * pipeline (`?inline`).\n * - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline\n * (`?raw`).\n * - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise.\n */\nexport type CssSheetBuild = 'auto' | 'url' | 'inline' | 'inline-raw';\n\nconst CSS_SHEET_BUILD_MODES: readonly CssSheetBuild[] = [\n 'auto',\n 'url',\n 'inline',\n 'inline-raw',\n];\n\n/**\n * Options for the Lit Vite plugin.\n *\n * Every option also resolves from environment variables (and `.env` files)\n * with the `LIT_PLUGIN` prefix — e.g. `LIT_PLUGIN_HMR_INDICATOR=true`. Options\n * passed here take precedence over env vars, which take precedence over the\n * built-in defaults.\n */\nexport interface LitPluginOptions {\n /**\n * HMR for Lit components and its on-page feedback. `true`/`false` toggles\n * the whole feature (patching and indicator); an object configures it.\n * Defaults to enabled.\n */\n hmr?: boolean | HmrOptions;\n\n /**\n * Dev-only click-to-open-in-IDE inspector for Lit custom elements.\n * Toggle with Ctrl+Shift+S (configurable via `key`). Defaults to `false`.\n */\n sourceOverlay?: boolean | SourceOverlayOptions;\n\n /**\n * Vite DevTools Timeline panel — a Vue DevTools–style layered event stream\n * for Lit lifecycle, render, mouse, and keyboard events.\n *\n * Requires `@vitejs/devtools` in the Vite config and the `@vitejs/devtools`\n * Vite plugin (`DevTools()`) to be active. Defaults to `false` while\n * experimental.\n *\n * `true` enables all built-in layers with defaults.\n */\n timeline?: boolean;\n\n /**\n * What a `?css-sheet` import compiles to under `vite build`.\n * - `'url'`: fetch-backed sheet over the emitted `.css` asset\n * - `'inline'`: css text embedded in the JS chunk, processed by the css\n * pipeline (`?inline`)\n * - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline\n * (`?raw`)\n * - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise\n *\n * Dev is always the fetch-backed HMR form regardless of this setting.\n * Defaults to `'auto'`.\n */\n cssSheetBuild?: CssSheetBuild;\n}\n\n/** Plugin options after merging explicit options, env vars, and defaults. */\nexport interface ResolvedOptions {\n hmrEnabled: boolean;\n reconnect: boolean;\n onIncompatible: 'reload' | 'warn';\n indicator: false | {count: boolean};\n sourceOverlay: false | SourceOverlayOptions;\n timeline: boolean;\n cssSheetBuild: CssSheetBuild;\n}\n\n/** Env var prefix consumed at config time. */\nconst ENV_PREFIX = 'LIT_PLUGIN';\n\n/** Parse a boolean-ish env string; `undefined` when unset/unrecognized. */\nconst envBool = (v: string | undefined): boolean | undefined =>\n v === 'true' || v === '1'\n ? true\n : v === 'false' || v === '0'\n ? false\n : undefined;\n\n/** Parse a numeric env string; `undefined` when unset/non-numeric. */\nconst envNum = (v: string | undefined): number | undefined => {\n if (v === undefined || v === '') return undefined;\n const n = Number(v);\n return Number.isNaN(n) ? undefined : n;\n};\n\n/**\n * Parse a string against a closed set of values; `undefined` (with a warning)\n * when set to something outside it, so a typo falls back to the default\n * instead of silently disabling a feature.\n */\nconst envEnum = <T extends string>(\n v: string | undefined,\n allowed: readonly T[],\n source: string\n): T | undefined => {\n if (v === undefined || v === '') return undefined;\n if ((allowed as readonly string[]).includes(v)) return v as T;\n console.warn(\n `[lit-plugin] ignoring ${source}=${JSON.stringify(v)}; expected one of ` +\n allowed.map((a) => JSON.stringify(a)).join(', ')\n );\n return undefined;\n};\n\n/**\n * Merge explicit options over env vars over defaults (in that precedence) into\n * the flat shape the plugin hooks consume.\n */\nexport const resolveOptions = (\n options: LitPluginOptions,\n env: Record<string, string>\n): ResolvedOptions => {\n const hmr = options.hmr;\n const hmrObj = typeof hmr === 'object' ? hmr : undefined;\n const hmrEnabled =\n (typeof hmr === 'boolean' ? hmr : hmrObj?.enabled) ??\n envBool(env[`${ENV_PREFIX}_HMR`]) ??\n true;\n const reconnect =\n hmrObj?.reconnect ?? envBool(env[`${ENV_PREFIX}_HMR_RECONNECT`]) ?? false;\n const onIncompatible =\n hmrObj?.onIncompatible ??\n (env[`${ENV_PREFIX}_HMR_ON_INCOMPATIBLE`] as 'reload' | 'warn') ??\n 'reload';\n\n const ind = hmrObj?.indicator;\n const indObj = typeof ind === 'object' ? ind : undefined;\n const indEnabled =\n (typeof ind === 'boolean' ? ind : indObj?.enabled) ??\n envBool(env[`${ENV_PREFIX}_HMR_INDICATOR`]) ??\n true;\n const indCount =\n indObj?.count ?? envBool(env[`${ENV_PREFIX}_HMR_INDICATOR_COUNT`]) ?? false;\n // The indicator is meaningless without HMR, so it follows the master toggle.\n const indicator = hmrEnabled && indEnabled ? {count: indCount} : false;\n\n const so = options.sourceOverlay;\n const soExplicit =\n typeof so === 'boolean' ? so : so === undefined ? undefined : true;\n const soEnabled =\n soExplicit ?? envBool(env[`${ENV_PREFIX}_SOURCE_OVERLAY`]) ?? false;\n let sourceOverlay: false | SourceOverlayOptions = false;\n if (soEnabled) {\n const base: SourceOverlayOptions = typeof so === 'object' ? {...so} : {};\n base.key ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_KEY`] || undefined;\n base.editor ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_EDITOR`] || undefined;\n base.throttleMs ??= envNum(env[`${ENV_PREFIX}_SOURCE_OVERLAY_THROTTLE_MS`]);\n sourceOverlay = base;\n }\n\n const timeline =\n options.timeline ?? envBool(env[`${ENV_PREFIX}_TIMELINE`]) ?? false;\n\n const cssSheetBuild =\n envEnum(options.cssSheetBuild, CSS_SHEET_BUILD_MODES, 'cssSheetBuild') ??\n envEnum(\n env[`${ENV_PREFIX}_CSS_SHEET_BUILD`],\n CSS_SHEET_BUILD_MODES,\n `${ENV_PREFIX}_CSS_SHEET_BUILD`\n ) ??\n 'auto';\n\n return {\n hmrEnabled,\n reconnect,\n onIncompatible,\n indicator,\n sourceOverlay,\n timeline,\n cssSheetBuild,\n };\n};\n\n/**\n * Flattens resolved options into the JSON-serializable shape the panel's\n * Settings tab consumes (callback options like `exclude`/`onSelect` dropped;\n * a custom editor object reported as `\"custom\"`). Default key/editor/throttle\n * are applied here so the panel shows the effective values the runtime uses.\n */\nconst toFeatureSettings = (r: ResolvedOptions): FeatureSettings => {\n const so = r.sourceOverlay;\n const editor = so === false ? undefined : so.editor;\n return {\n hmr: {\n enabled: r.hmrEnabled,\n reconnect: r.reconnect,\n onIncompatible: r.onIncompatible,\n indicatorEnabled: r.indicator !== false,\n indicatorCount: r.indicator !== false && r.indicator.count,\n },\n sourceOverlay: {\n enabled: so !== false,\n key: (so === false ? undefined : so.key) ?? 's',\n editor:\n typeof editor === 'string' ? editor : editor ? 'custom' : 'vscode',\n throttleMs: (so === false ? undefined : so.throttleMs) ?? 50,\n },\n timeline: r.timeline,\n };\n};\n\n/**\n * Resolves a runtime module to an absolute fs path (served via `/@fs/`), so\n * the plugin works from any served root. Falls back from the built `.js` to\n * the `.ts` source when running un-built (e.g. under vitest).\n */\nconst resolveRuntimeModule = (name: string): string => {\n for (const ext of ['js', 'ts'] as const) {\n const url = new URL(`./runtime/${name}.${ext}`, import.meta.url);\n if (existsSync(url)) {\n return fileURLToPath(url).replace(/\\\\/g, '/');\n }\n }\n throw new Error(`[lit-plugin] runtime module not found: ${name}`);\n};\n\nconst JS_FILE_RE = /\\.[cm]?[jt]sx?$/;\n\nconst OPEN_IN_EDITOR_PATH = '/__lit-open-in-editor';\n\n/** Reject requests whose `Origin` is a different host than the dev server, so\n * a page the developer happens to visit can't drive these local-only\n * endpoints. Same-origin requests (no `Origin`, or matching `Host`) pass. */\nconst isSameOrigin = (headers: {origin?: string; host?: string}): boolean => {\n const {origin, host} = headers;\n if (origin === undefined || origin === 'null') return true;\n try {\n return new URL(origin).host === host;\n } catch {\n return false;\n }\n};\n\nexport const createOpenInEditorMiddleware = (\n allowedRoots: readonly string[]\n) => {\n // First entry is the primary root: relative `file` params resolve against\n // it. Every entry grants open access to files beneath it.\n const roots = allowedRoots.map((r) => resolvePath(r));\n return (\n req: {url?: string; headers?: {origin?: string; host?: string}},\n res: {statusCode: number; end: (msg: string) => void},\n next: (err?: unknown) => void\n ) => {\n if (req.url === undefined) {\n next();\n return;\n }\n if (!isSameOrigin(req.headers ?? {})) {\n res.statusCode = 403;\n res.end('forbidden');\n return;\n }\n const query = req.url.includes('?')\n ? req.url.slice(req.url.indexOf('?') + 1)\n : '';\n const params = new URLSearchParams(query);\n const file = params.get('file');\n if (file === null) {\n res.statusCode = 400;\n res.end('missing file parameter');\n return;\n }\n // Confine the open to the allowed roots: resolve the requested path and\n // reject anything that escapes all of them (path traversal, absolute\n // paths to arbitrary files). `launch-editor` spawns the user's editor on\n // this path, so an unvalidated `file` is a local-file-open /\n // arg-injection vector.\n const resolved = resolvePath(roots[0] ?? process.cwd(), file);\n const allowed = roots.some(\n (root) => resolved === root || resolved.startsWith(root + sep)\n );\n if (!allowed) {\n res.statusCode = 403;\n res.end('file outside allowed roots');\n return;\n }\n if (!existsSync(resolved)) {\n res.statusCode = 404;\n res.end('file not found');\n return;\n }\n // Coerce to integers so a crafted `line`/`column` can't smuggle extra\n // shell-visible content through the `file:line:column` ref.\n const line = String(\n Math.max(1, Number.parseInt(params.get('line') ?? '1', 10) || 1)\n );\n const column = String(\n Math.max(1, Number.parseInt(params.get('column') ?? '1', 10) || 1)\n );\n const fileRef = `${resolved}:${line}:${column}`;\n import('launch-editor')\n .then(\n (mod: {\n default?: (\n file: string,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n }) => {\n const launch = (mod.default ?? mod) as (\n file: string,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n // `launch-editor` invokes the callback only on failure — synchronously\n // when it can't guess an editor, later if the spawn errors. Reply `ok`\n // right after launching; the guard keeps a sync failure's 500 first\n // and drops a late async failure (the response is long gone).\n let finished = false;\n const finish = (statusCode: number, msg: string) => {\n if (finished) return;\n finished = true;\n res.statusCode = statusCode;\n res.end(msg);\n };\n launch(fileRef, (_fileName: string, errorMessage: string | null) => {\n if (errorMessage !== null) {\n finish(500, errorMessage);\n }\n });\n finish(200, 'ok');\n }\n )\n .catch(next);\n };\n};\n\n/**\n * `import href from './x.css?hmr-url'` — `?url` semantics with working HMR.\n * The string is a real stylesheet URL (dev-served CSS file; hashed `.css`\n * asset on build) for shadow-root `<link>` hrefs and `@import url()`s. In\n * dev, each HMR re-execution yields a freshly cache-busted href, so the\n * browser refetches the changed stylesheet; in build the `?url` asset URL\n * passes through unchanged.\n */\nconst CSS_URL_QUERY_RE = /^([^?]+\\.css)\\?(?:[^&]*&)*hmr-url(?:&.*)?$/;\nconst CSS_URL_VIRTUAL_PREFIX = '\\0lit-plugin:hmr-url:';\n\n/**\n * `import sheet from './x.css?css-sheet'` — a constructed, shareable\n * `CSSStyleSheet` backed by the `.css` asset that hot-swaps in place. Adopt it\n * from any number of components (`static styles = [sheet]`); a source edit\n * re-fetches and `replaceSync()`s it, updating every shadow root that adopted\n * it without re-rendering a component or reloading the page.\n *\n * This is the `urlSheet()` helper plus its irreducible HMR wiring, lifted into\n * a plugin-generated module: the `import.meta.hot.accept` lives here (where\n * Vite's static analysis sees the literal specifier), so callers write a bare\n * import and never touch `import.meta.hot` themselves.\n *\n * Under `vite build` the generated module can instead inline the css text (see\n * `cssSheetBuild`) — a library's consumers bundle its JS only, so a\n * fetch-backed sheet would 404 on the `.css` asset that never reached their\n * build.\n */\nconst CSS_SHEET_QUERY_RE = /^([^?]+\\.css)\\?(?:[^&]*&)*css-sheet(?:&.*)?$/;\nconst CSS_SHEET_VIRTUAL_PREFIX = '\\0lit-plugin:css-sheet:';\n// The virtual id must not end in `.css`, or Vite's CSS plugins (which match\n// the id's extension regardless of `\\0`) would compile the wrapper as CSS.\nconst CSS_VIRTUAL_SUFFIX = '.js';\n\n/**\n * Import-query support, served in dev and build alike (source code using\n * `?hmr-url`/`?css-sheet` must keep working under `vite build`, where the HMR\n * plugin doesn't apply). Exported for the baseline e2e run, which needs the\n * queries working without the HMR plugin.\n *\n * `getCssSheetBuild` is a getter, not a value: `litPlugin()` re-resolves its\n * options against the loaded env in a `config` hook, which runs after the\n * plugin array is built. Standalone (no getter) it behaves like the `'auto'`\n * default.\n */\nexport const litCssQueries = (\n getCssSheetBuild: () => CssSheetBuild = () => 'auto'\n): Plugin => {\n let isBuild = false;\n let isLib = false;\n return {\n name: 'lit-css-query',\n // Vite's core resolver claims `./x.css?hmr-url` for the CSS pipeline\n // before normal plugins get a look, so resolve ahead of it.\n enforce: 'pre',\n configResolved(config) {\n isBuild = config.command === 'build';\n isLib = config.build.lib !== false && config.build.lib !== undefined;\n },\n async resolveId(id, importer) {\n const prefix = CSS_URL_QUERY_RE.test(id)\n ? CSS_URL_VIRTUAL_PREFIX\n : CSS_SHEET_QUERY_RE.test(id)\n ? CSS_SHEET_VIRTUAL_PREFIX\n : null;\n if (prefix === null) {\n return null;\n }\n const file = id.slice(0, id.indexOf('?'));\n const resolved = await this.resolve(file, importer);\n if (resolved === null) {\n return null;\n }\n return prefix + resolved.id + CSS_VIRTUAL_SUFFIX;\n },\n load(id) {\n const helperPath = resolveRuntimeModule('css');\n if (id.startsWith(CSS_URL_VIRTUAL_PREFIX)) {\n const file = id.slice(\n CSS_URL_VIRTUAL_PREFIX.length,\n -CSS_VIRTUAL_SUFFIX.length\n );\n return {\n code:\n `import url from ${JSON.stringify(`${file}?url`)};\\n` +\n `import {devCacheBust} from ${JSON.stringify(helperPath)};\\n` +\n `export default devCacheBust(url);\\n`,\n moduleType: 'js',\n };\n }\n if (id.startsWith(CSS_SHEET_VIRTUAL_PREFIX)) {\n const file = id.slice(\n CSS_SHEET_VIRTUAL_PREFIX.length,\n -CSS_VIRTUAL_SUFFIX.length\n );\n const mode = getCssSheetBuild();\n const inlineQuery =\n !isBuild || mode === 'url' || (mode === 'auto' && !isLib)\n ? null\n : mode === 'inline-raw'\n ? '?raw'\n : '?inline';\n if (inlineQuery !== null) {\n // Build only, so no `import.meta.hot` block. The sheet is still\n // constructed once per virtual module, so adopters share it exactly\n // as they do in the fetch-backed form.\n return {\n code:\n `import css from ${JSON.stringify(`${file}${inlineQuery}`)};\\n` +\n `const sheet = new CSSStyleSheet();\\n` +\n `sheet.replaceSync(css);\\n` +\n `export default sheet;\\n`,\n moduleType: 'js',\n };\n }\n // The accept specifier must be byte-identical to the import above —\n // Vite resolves accepted HMR deps by static analysis. Generating both\n // here is exactly what frees the caller from writing it. The swap is\n // self-accepted at this boundary, so it never propagates to adopters.\n const urlSpecifier = JSON.stringify(`${file}?url`);\n return {\n code:\n `import url from ${urlSpecifier};\\n` +\n `import {urlSheet} from ${JSON.stringify(helperPath)};\\n` +\n `const {sheet, onHotUpdate} = urlSheet(url);\\n` +\n `export default sheet;\\n` +\n `if (import.meta.hot) {\\n` +\n ` import.meta.hot.accept(${urlSpecifier}, onHotUpdate);\\n` +\n `}\\n`,\n moduleType: 'js',\n };\n }\n return null;\n },\n };\n};\n\n/**\n * A `css` tagged template literal with no interpolations and no escape\n * sequences — the only kind we can hand to a CSS parser as-is. Literals\n * with `${…}` holes or backslashes simply don't match and stay untouched.\n * The lookbehind keeps `unsafeCSS`/`myCss`-style tags from matching.\n */\nconst CSS_LITERAL_RE = /(?<![\\w$.])css`((?:[^`\\\\$]|\\$(?!\\{))*)`/g;\n\n/**\n * Runs Vite's configured Lightning CSS over `css` tagged template literals\n * in user modules, which the CSS pipeline itself never sees (they're plain\n * JS strings to it). Inert unless `css.transformer` is `'lightningcss'`;\n * options come from `css.lightningcss`, so component styles get the same\n * treatment (targets, drafts, …) as `.css` files. Applies in dev and build.\n */\nconst litCssLiterals = (): Plugin => {\n let lightningcss: typeof import('lightningcss') | null = null;\n let options: CSSOptions['lightningcss'];\n let minify = false;\n return {\n name: 'lit-css-literals',\n async configResolved(config) {\n if (config.css.transformer !== 'lightningcss') {\n return;\n }\n // The transformer setting guarantees the dependency: Vite itself\n // can't process .css files without it.\n lightningcss = await import('lightningcss');\n // cssModules makes no sense for a literal; everything else carries\n // over.\n const {cssModules: _cssModules, ...rest} = config.css.lightningcss ?? {};\n options = rest;\n minify = config.command === 'build';\n },\n transform(code, id) {\n if (lightningcss === null) {\n return null;\n }\n if (id.startsWith('\\0') || id.includes('/node_modules/')) {\n return null;\n }\n const [file] = id.split('?', 2);\n if (!JS_FILE_RE.test(file) || !code.includes('css`')) {\n return null;\n }\n const ms = new MagicString(code);\n let changed = false;\n for (const m of code.matchAll(CSS_LITERAL_RE)) {\n const literal = m[1];\n if (literal.trim() === '') {\n continue;\n }\n let out: string;\n try {\n const result = lightningcss.transform({\n ...options,\n filename: file,\n code: Buffer.from(literal),\n minify,\n });\n out = Buffer.from(result.code).toString();\n } catch (e) {\n this.warn(\n `[lit-plugin] skipping css literal Lightning CSS couldn't parse: ${\n (e as Error).message\n }`\n );\n continue;\n }\n // Re-escape for the template literal the output goes back into.\n out = out.replace(/[\\\\`$]/g, '\\\\$&');\n if (out !== literal) {\n const start = m.index + 'css`'.length;\n ms.overwrite(start, start + literal.length, out);\n changed = true;\n }\n }\n if (!changed) {\n return null;\n }\n return {code: ms.toString(), map: ms.generateMap({hires: true})};\n },\n };\n};\n\n/**\n * Vite plugin set providing HMR, CSS helpers, and Lightning CSS processing\n * for Lit projects.\n */\nexport const litPlugin = (options: LitPluginOptions = {}): Plugin[] => {\n // Resolved from explicit options first, env vars second, defaults last. The\n // `lit-plugin-options` `config` hook below re-resolves with the loaded env\n // once Vite hands us the mode; this initial pass covers code paths that run\n // before (or without) it.\n let resolved: ResolvedOptions = resolveOptions(options, {});\n let root = '';\n // Env resolution lives in its own always-applied plugin: `?css-sheet` is a\n // build-time feature too, and the HMR plugin (`apply: 'serve'`) never gets a\n // `config` hook under `vite build`. `enforce: 'pre'` and first position put\n // it ahead of every other hook that reads `resolved`.\n const optionsPlugin: Plugin = {\n name: 'lit-plugin-options',\n enforce: 'pre',\n config(viteConfig, {mode}) {\n // `loadEnv` reads `.env*` files from the env dir (root by default) and\n // merges in matching `process.env` keys, filtered to the `LIT_PLUGIN`\n // prefix. Explicit options still win (handled in resolveOptions).\n const envDir = viteConfig.envDir\n ? resolvePath(viteConfig.envDir)\n : viteConfig.root\n ? resolvePath(viteConfig.root)\n : process.cwd();\n resolved = resolveOptions(options, loadEnv(mode, envDir, ENV_PREFIX));\n },\n };\n const sourceOverlayPlugin: Plugin = {\n name: 'lit-source-overlay',\n apply: 'serve',\n // Run before Vite's esbuild TS transform so source-meta line numbers are\n // measured against the author's raw source (and the `@customElement … class`\n // forms are still intact), not against transpiled output.\n enforce: 'pre',\n configResolved(config) {\n root = config.root;\n },\n resolveId(id) {\n if (id === '@lit-labs/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n return null;\n },\n configureServer(server) {\n if (!resolved.sourceOverlay) return;\n // Allow opens from everything vite itself is willing to serve\n // (`server.fs.allow` defaults to the workspace root), not just\n // `config.root` — in monorepos, component sources regularly live in\n // sibling packages outside the served app's root.\n const fsAllow = server.config.server.fs?.allow ?? [];\n server.middlewares.use(\n OPEN_IN_EDITOR_PATH,\n createOpenInEditorMiddleware([root, ...fsAllow])\n );\n },\n transform(code, id, transformOptions) {\n if (!resolved.sourceOverlay) return null;\n if (transformOptions?.ssr) return null;\n if (\n id.startsWith('\\0') ||\n id.includes('__x00__') ||\n id.includes('lit-plugin:') ||\n id.includes('/node_modules/')\n ) {\n return null;\n }\n const [file] = id.split('?', 2);\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n if (!code.includes('customElement') && !code.includes('customElements')) {\n return null;\n }\n const ms = new MagicString(code);\n const relativeFile = file.startsWith(root + '/')\n ? file.slice(root.length + 1)\n : file;\n if (!injectSourceMeta(code, relativeFile, ms)) {\n return null;\n }\n return {code: ms.toString(), map: ms.generateMap({hires: true})};\n },\n transformIndexHtml() {\n if (!resolved.sourceOverlay) return;\n const overlayUrl = `/@fs/${resolveRuntimeModule('source-overlay')}`;\n const {\n exclude: _exclude,\n onSelect: _onSelect,\n ...overlayInit\n } = resolved.sourceOverlay;\n const initConfig = {\n ...overlayInit,\n openInEditorPath: OPEN_IN_EDITOR_PATH,\n };\n return [\n {\n tag: 'script',\n attrs: {type: 'module'},\n children: `import {initSourceOverlay} from ${JSON.stringify(overlayUrl)};\\ninitSourceOverlay(${JSON.stringify(initConfig)});\\n`,\n injectTo: 'body',\n },\n ];\n },\n };\n const hmr: Plugin = {\n name: 'lit-plugin',\n apply: 'serve',\n config: () => {\n // Options are already resolved against the loaded env by\n // `lit-plugin-options`, which runs first.\n if (!resolved.hmrEnabled) {\n return;\n }\n // The injected runtime imports are invisible to the dep scanner. The\n // lit family stays prebundle-eligible on purpose: the wrapper modules'\n // bare imports then resolve to the same URL every other importer gets —\n // single lit instance, single template cache.\n return {optimizeDeps: {exclude: ['@lit-labs/vite-plugin-lit']}};\n },\n resolveId(id) {\n // Public timeline API virtual module.\n if (id === 'virtual:lit-plugin/timeline') {\n return '\\0virtual:lit-plugin/timeline';\n }\n // Resolve the browser CSS helpers and indicator runtime to the copy\n // shipped next to this plugin, so they work even when the package\n // isn't reachable through node resolution from the served root (and\n // stay out of prebundling).\n if (id === '@lit-labs/vite-plugin-lit/css.js') {\n return resolveRuntimeModule('css');\n }\n if (id === '@lit-labs/vite-plugin-lit/indicator.js') {\n return resolveRuntimeModule('indicator');\n }\n if (id === '@lit-labs/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n if (resolved.hmrEnabled && id.startsWith(VIRTUAL_PREFIX)) {\n return id;\n }\n return null;\n },\n load(id) {\n // Public timeline API — re-export the runtime module when timeline is\n // enabled, otherwise a no-op stub so imports don't throw in prod builds.\n if (id === '\\0virtual:lit-plugin/timeline') {\n if (!resolved.timeline) {\n return {\n code:\n 'export const addTimelineEvent = () => {};\\n' +\n 'export const addTimelineLayer = () => {};\\n',\n moduleType: 'js',\n };\n }\n const apiPath = resolveRuntimeModule('timeline/public-api');\n return {\n code: `export * from ${JSON.stringify(apiPath)};\\n`,\n moduleType: 'js',\n };\n }\n if (!resolved.hmrEnabled || !id.startsWith(VIRTUAL_PREFIX)) {\n return null;\n }\n if (id === INSTALL_ID) {\n const patchPath = resolveRuntimeModule('patch');\n const runtimeOptions = {\n reconnect: resolved.reconnect,\n onIncompatible: resolved.onIncompatible,\n };\n return {\n code:\n `import {install} from ${JSON.stringify(patchPath)};\\n` +\n `install(${JSON.stringify(runtimeOptions)});\\n`,\n moduleType: 'js',\n };\n }\n const spec = id.slice(VIRTUAL_PREFIX.length);\n const wrappedTags = WRAP_TABLE.get(spec);\n if (wrappedTags === undefined) {\n return null;\n }\n const internPath = resolveRuntimeModule('intern');\n // Browser-native ESM: explicit local exports shadow `export *` names\n // (spec-guaranteed), so everything except the wrapped tags passes\n // through unchanged.\n const lines = [\n `import * as __lit from ${JSON.stringify(spec)};`,\n `import {wrapTag} from ${JSON.stringify(internPath)};`,\n `export * from ${JSON.stringify(spec)};`,\n ];\n for (const {exportName, ns} of wrappedTags) {\n lines.push(\n `export const ${exportName} = wrapTag(__lit.${exportName}, ${JSON.stringify(\n ns\n )});`\n );\n }\n return {code: lines.join('\\n') + '\\n', moduleType: 'js'};\n },\n async transform(code, id, transformOptions) {\n if (!resolved.hmrEnabled) {\n return null;\n }\n if (transformOptions?.ssr) {\n return null;\n }\n if (id.startsWith('\\0') || id.includes('/node_modules/')) {\n return null;\n }\n const [file] = id.split('?', 2);\n // Allow inline scripts extracted from HTML (`?html-proxy`).\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n return transformLitModule(code);\n },\n transformIndexHtml() {\n const tags: {\n tag: string;\n attrs?: Record<string, string | undefined | boolean>;\n children?: string;\n injectTo: 'body';\n }[] = [];\n\n const indicator = resolved.indicator;\n if (indicator) {\n const indicatorUrl = `/@fs/` + resolveRuntimeModule('indicator');\n tags.push(\n {\n tag: 'script',\n attrs: {type: 'module', src: indicatorUrl},\n injectTo: 'body',\n },\n {\n tag: 'lit-devtools-hmr-indicator',\n attrs: indicator.count ? {count: ''} : undefined,\n children: '',\n injectTo: 'body',\n }\n );\n }\n\n if (resolved.timeline) {\n const installUrl = `/@fs/` + resolveRuntimeModule('timeline/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: installUrl},\n injectTo: 'body',\n });\n // Components inspector runtime — answers the panel's tree/details\n // requests. Paired with the timeline panel, which hosts its tab.\n const inspectorUrl =\n `/@fs/` + resolveRuntimeModule('inspector/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: inspectorUrl},\n injectTo: 'body',\n });\n }\n\n return tags.length > 0 ? tags : undefined;\n },\n };\n // The source-overlay plugin is always present; its hooks no-op when the\n // feature is disabled (which env may decide), so inclusion can't be gated\n // on the synchronously-known options here.\n const plugins: Plugin[] = [\n optionsPlugin,\n // Getter, not a snapshot: `resolved` is re-resolved against the loaded env\n // in `optionsPlugin`'s `config` hook, which runs after this array is built.\n litCssQueries(() => resolved.cssSheetBuild),\n litCssLiterals(),\n sourceOverlayPlugin,\n hmr,\n ];\n if (resolved.timeline) {\n // Pass a getter, not a snapshot: `resolved` is re-resolved against the\n // loaded env in the `config` hook, which runs after this plugin array is\n // built. The settings endpoint reads it per-request, by which point env is\n // applied.\n plugins.push(litTimelinePlugin(() => toFeatureSettings(resolved)));\n }\n return plugins;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"overlay-element.d.ts","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/overlay-element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,WAAW,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAmB9D,MAAM,WAAW,wBAAwB;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AA0XD,eAAO,MAAM,iBAAiB,GAC5B,cAAa,wBAA6B,SAM3C,CAAC;AAEF,eAAO,MAAM,mBAAmB,YAK/B,CAAC"}
1
+ {"version":3,"file":"overlay-element.d.ts","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/overlay-element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,WAAW,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAmB9D,MAAM,WAAW,wBAAwB;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,OAAO,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AA8XD,eAAO,MAAM,iBAAiB,GAC5B,cAAa,wBAA6B,SAM3C,CAAC;AAEF,eAAO,MAAM,mBAAmB,YAK/B,CAAC"}
@@ -185,10 +185,13 @@ class LitSourceOverlay extends HTMLElement {
185
185
  .getPropertyValue('--lit-devtools-radius')
186
186
  .trim();
187
187
  const r = parseFloat(raw) || 6;
188
- this.#highlight.style.left = `${rect.left - r}px`;
189
- this.#highlight.style.top = `${rect.top - r}px`;
190
- this.#highlight.style.width = `${rect.width + 2 * r}px`;
191
- this.#highlight.style.height = `${rect.height + 2 * r}px`;
188
+ // The tinted box hugs the element's exact rect — that's the boundary being
189
+ // picked; only the spotlight cutout gets the breathing room of `r`.
190
+ this.#highlight.style.display = 'block';
191
+ this.#highlight.style.left = `${rect.left}px`;
192
+ this.#highlight.style.top = `${rect.top}px`;
193
+ this.#highlight.style.width = `${rect.width}px`;
194
+ this.#highlight.style.height = `${rect.height}px`;
192
195
  this.#mask.style.clipPath = buildSpotlightClipPath(rect.left - r, rect.top - r, rect.width + 2 * r, rect.height + 2 * r, r);
193
196
  }
194
197
  #showTooltip() {
@@ -201,6 +204,7 @@ class LitSourceOverlay extends HTMLElement {
201
204
  #clearTarget() {
202
205
  this.#targetEl = null;
203
206
  this.#info = null;
207
+ this.#highlight.style.display = 'none';
204
208
  this.#highlight.style.left = '0';
205
209
  this.#highlight.style.top = '0';
206
210
  this.#highlight.style.width = '0';
@@ -1 +1 @@
1
- {"version":3,"file":"overlay-element.js","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/overlay-element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,sBAAsB,EAAC,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,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OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC,CAAC;IAEF,iBAAiB,GAAG,GAAG,EAAE;QACvB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS;YAAE,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACrE,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,GAAG,EAAE;YAClC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;YAC9B,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;gBAC5B,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC9B,CAAC;QACH,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC,CAAC;CACH;AAED,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;AAE9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,cAAwC,EAAE,EAC1C,EAAE;IACF,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAC1C,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAqB,CAAC;IAC5E,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAC/B,oBAAoB,CACM,CAAC;IAC7B,EAAE,EAAE,MAAM,EAAE,CAAC;AACf,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type {ElementInfo, EditorConfig} from '../../types.js';\nimport {BUILTIN_EDITORS, resolveEditor} from './editors.js';\nimport {\n defaultResolver,\n findSourceAtPoint,\n findSourceHost,\n type ElementResolver,\n} from './source-host.js';\nimport {buildSpotlightClipPath} from './mask-path.js';\nimport {OVERLAY_HTML} from './template.js';\nimport {observeEdgeInsets} from '../edge-panel.js';\nimport {subscribeOverride} from '../overrides.js';\nimport {injectTokens} from '../../tokens.js';\nimport {idOf} from '../timeline/identity.js';\nimport {\n INSPECT_OVERLAY_TOGGLE_CHANNEL,\n INSPECT_DATA_CHANNEL,\n} from '../../../types/inspector.js';\n\nexport interface SourceOverlayInitOptions {\n key?: string;\n editor?: EditorConfig | string;\n workspaceRoot?: string;\n throttleMs?: number;\n exclude?: (el: Element) => boolean;\n onSelect?: (info: ElementInfo) => void;\n openInEditorPath?: string;\n}\n\nclass LitSourceOverlay extends HTMLElement {\n #active = false;\n #hot: {send: (event: string, data: unknown) => void} | undefined;\n #options: SourceOverlayInitOptions = {};\n #editor: EditorConfig = BUILTIN_EDITORS.vscode;\n #resolver: ElementResolver = defaultResolver;\n #dialog: HTMLDialogElement;\n #mask: HTMLElement;\n #highlight: HTMLElement;\n #tooltip: HTMLElement;\n #tag: HTMLElement;\n #path: HTMLElement;\n #info: ElementInfo | null = null;\n #targetEl: Element | null = null;\n #throttleTimer: ReturnType<typeof setTimeout> | undefined;\n #scrollTimer: ReturnType<typeof setTimeout> | undefined;\n #resizeObserver: ResizeObserver | undefined;\n #cursorStyle: HTMLStyleElement | null = null;\n // Whether the Vite HMR WebSocket is currently connected. Used to suppress the\n // editor-URL-scheme fallback once the dev server is gone — otherwise a failed\n // open-in-editor fetch would navigate the tab to `vscode://…`.\n #connected = true;\n #lastMouseX = 0;\n #lastMouseY = 0;\n #edgeDispose: (() => void) | undefined;\n #overrideSubscribed = false;\n\n constructor() {\n super();\n const root = this.attachShadow({mode: 'closed'});\n root.innerHTML = OVERLAY_HTML;\n this.#dialog = root.getElementById('overlay') as HTMLDialogElement;\n this.#mask = root.getElementById('mask')!;\n this.#highlight = root.getElementById('highlight')!;\n this.#tooltip = root.getElementById('tooltip')!;\n this.#tag = root.getElementById('tag')!;\n this.#path = root.getElementById('path')!;\n root.getElementById('open')!.addEventListener('click', (e) => {\n e.stopPropagation();\n if (this.#info !== null) this.#select(this.#info, true);\n });\n root.getElementById('copy')!.addEventListener('click', (e) => {\n e.stopPropagation();\n if (this.#info === null) return;\n const text = `${this.#normalizePath(this.#info.source.filePath)}:${this.#info.source.lineNumber}`;\n navigator.clipboard?.writeText(text);\n });\n this.#dialog.addEventListener('cancel', (e) => e.preventDefault());\n }\n\n connectedCallback() {\n injectTokens();\n document.addEventListener('mousemove', this.#onTrackMouse, true);\n document.addEventListener('keydown', this.#onKeyDown, true);\n const hot = (\n import.meta as {\n hot?: {\n on: (event: string, cb: (data?: unknown) => void) => void;\n send: (event: string, data: unknown) => void;\n };\n }\n ).hot;\n this.#hot = hot;\n hot?.on('vite:beforeFullReload', () => this.deactivate());\n hot?.on('vite:ws:disconnect', () => (this.#connected = false));\n hot?.on('vite:ws:connect', () => (this.#connected = true));\n // Toggle from the Vite DevTools command/shortcut (handler runs server-side).\n hot?.on(INSPECT_OVERLAY_TOGGLE_CHANNEL, () => this.toggle());\n // Keep the (bottom-fixed) tooltip clear of the Vite DevTools edge panel.\n this.#edgeDispose = observeEdgeInsets((insets) => {\n this.style.setProperty('--edge-bottom', `${insets.bottom}px`);\n });\n // Apply the panel's editor override live (and on load). Merge so other\n // configured options (key, throttle, …) survive.\n if (!this.#overrideSubscribed) {\n this.#overrideSubscribed = true;\n subscribeOverride(hot, (o) => {\n if (o.sourceOverlayEditor !== undefined) {\n this.#options = {...this.#options, editor: o.sourceOverlayEditor};\n this.#editor = resolveEditor(o.sourceOverlayEditor);\n }\n });\n }\n }\n\n disconnectedCallback() {\n document.removeEventListener('mousemove', this.#onTrackMouse, true);\n document.removeEventListener('keydown', this.#onKeyDown, true);\n this.deactivate();\n this.#edgeDispose?.();\n this.#edgeDispose = undefined;\n }\n\n configure(options: SourceOverlayInitOptions) {\n this.#options = options;\n this.#editor = resolveEditor(options.editor);\n }\n\n activate() {\n if (this.#active) return;\n this.#active = true;\n this.#dialog.showModal();\n this.#mask.style.background = 'rgba(0,0,0,0.35)';\n // The overlay is pointer-events:none, so the cursor reflects the hovered\n // page element. Force a crosshair while inspecting. The closed shadow DOM\n // tooltip is unaffected, so its buttons keep their own pointer cursor.\n if (this.#cursorStyle === null) {\n this.#cursorStyle = document.createElement('style');\n this.#cursorStyle.textContent = '*{cursor:crosshair !important}';\n }\n document.head.append(this.#cursorStyle);\n document.addEventListener('mousemove', this.#onMouseMove, true);\n document.addEventListener('click', this.#onClick, true);\n window.addEventListener('scroll', this.#onScrollOrResize, {passive: true});\n window.addEventListener('resize', this.#onScrollOrResize, {passive: true});\n this.#resolveAt(this.#lastMouseX, this.#lastMouseY);\n }\n\n deactivate() {\n if (!this.#active) return;\n this.#active = false;\n this.#dialog.close();\n this.#mask.style.background = 'rgba(0,0,0,0)';\n this.#cursorStyle?.remove();\n document.removeEventListener('mousemove', this.#onMouseMove, true);\n document.removeEventListener('click', this.#onClick, true);\n window.removeEventListener('scroll', this.#onScrollOrResize);\n window.removeEventListener('resize', this.#onScrollOrResize);\n if (this.#throttleTimer !== undefined) {\n clearTimeout(this.#throttleTimer);\n this.#throttleTimer = undefined;\n }\n if (this.#scrollTimer !== undefined) {\n clearTimeout(this.#scrollTimer);\n this.#scrollTimer = undefined;\n }\n this.#clearTarget();\n }\n\n toggle() {\n if (this.#active) this.deactivate();\n else this.activate();\n }\n\n #normalizePath(filePath: string): string {\n const root = this.#options.workspaceRoot;\n if (root !== undefined && filePath.startsWith(root)) {\n const rest = filePath.slice(root.length);\n return rest.startsWith('/') ? rest.slice(1) : rest;\n }\n return filePath;\n }\n\n async #openInEditor(filePath: string, lineNumber: number) {\n const path = this.#normalizePath(filePath);\n const endpoint = this.#options.openInEditorPath ?? '/__lit-open-in-editor';\n try {\n const params = new URLSearchParams({\n file: path,\n line: String(lineNumber),\n });\n const res = await fetch(`${endpoint}?${params.toString()}`);\n if (res.ok) return;\n } catch {\n // Fall back to editor URL schemes (e.g. StackBlitz previews).\n }\n // Skip the URL-scheme fallback when the dev server is gone: a fetch failure\n // there means \"server quit\", not \"no endpoint\", and navigating the tab to\n // `vscode://…` on shutdown is jarring and unwanted.\n if (!this.#connected) return;\n window.open(this.#editor.url(path, lineNumber), '_self');\n }\n\n #updateHighlightRect() {\n if (this.#targetEl === null) return;\n const rect = this.#targetEl.getBoundingClientRect();\n const raw = getComputedStyle(this)\n .getPropertyValue('--lit-devtools-radius')\n .trim();\n const r = parseFloat(raw) || 6;\n this.#highlight.style.left = `${rect.left - r}px`;\n this.#highlight.style.top = `${rect.top - r}px`;\n this.#highlight.style.width = `${rect.width + 2 * r}px`;\n this.#highlight.style.height = `${rect.height + 2 * r}px`;\n this.#mask.style.clipPath = buildSpotlightClipPath(\n rect.left - r,\n rect.top - r,\n rect.width + 2 * r,\n rect.height + 2 * r,\n r\n );\n }\n\n #showTooltip() {\n if (this.#info === null) return;\n this.#tag.textContent = `<${this.#info.tagName}>`;\n this.#path.textContent = `${this.#normalizePath(this.#info.source.filePath)}:${this.#info.source.lineNumber}`;\n this.#tooltip.style.display = 'flex';\n }\n\n #clearTarget() {\n this.#targetEl = null;\n this.#info = null;\n this.#highlight.style.left = '0';\n this.#highlight.style.top = '0';\n this.#highlight.style.width = '0';\n this.#highlight.style.height = '0';\n this.#mask.style.clipPath = 'none';\n this.#tooltip.style.display = 'none';\n if (this.#resizeObserver !== undefined) {\n this.#resizeObserver.disconnect();\n this.#resizeObserver = undefined;\n }\n }\n\n #shouldSkip(el: Element): boolean {\n if (el === this.#dialog || this.#dialog.contains(el)) return true;\n if (el.tagName === 'IFRAME') return true;\n // Never target devtools' own injected elements (indicator, overlay).\n const tag = el.tagName.toLowerCase();\n if (tag === 'lit-source-overlay' || tag.startsWith('lit-devtools-')) {\n return true;\n }\n const exclude = this.#options.exclude;\n return exclude !== undefined && exclude(el);\n }\n\n async #resolveAt(x: number, y: number) {\n this.#lastMouseX = x;\n this.#lastMouseY = y;\n const el = findSourceAtPoint(x, y, this.#dialog);\n if (el === null || this.#shouldSkip(el)) {\n this.#clearTarget();\n return;\n }\n const host = findSourceHost(el);\n if (host === null) {\n this.#clearTarget();\n return;\n }\n if (host === this.#targetEl && this.#info !== null) {\n this.#updateHighlightRect();\n return;\n }\n this.#targetEl = host;\n if (this.#resizeObserver === undefined) {\n this.#resizeObserver = new ResizeObserver(() =>\n this.#updateHighlightRect()\n );\n } else {\n this.#resizeObserver.disconnect();\n }\n this.#resizeObserver.observe(host);\n const resolved = await this.#resolver.resolveElementInfo(el);\n if (resolved === null) {\n this.#clearTarget();\n return;\n }\n this.#info = resolved;\n this.#updateHighlightRect();\n this.#showTooltip();\n }\n\n #onTrackMouse = (event: MouseEvent) => {\n this.#lastMouseX = event.clientX;\n this.#lastMouseY = event.clientY;\n };\n\n #onKeyDown = (event: KeyboardEvent) => {\n if ((event.metaKey || event.ctrlKey) && event.shiftKey && !event.altKey) {\n const pressed = event.key.toLowerCase();\n const hotkey = (this.#options.key ?? 'e').toLowerCase();\n if (pressed === hotkey) {\n event.preventDefault();\n this.toggle();\n }\n }\n if (this.#active && event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n\n #onMouseMove = (event: MouseEvent) => {\n if (!this.#active) return;\n // Keep the current selection while hovering the tooltip so its buttons stay\n // clickable — the tooltip isn't a source element, so re-resolving here would\n // clear the target and hide the panel out from under the pointer.\n if (this.#pointInTooltip(event.clientX, event.clientY)) return;\n const throttleMs = this.#options.throttleMs ?? 50;\n if (this.#throttleTimer !== undefined) return;\n this.#throttleTimer = setTimeout(() => {\n this.#throttleTimer = undefined;\n // Resolve against the latest pointer position (kept current by\n // #onTrackMouse), not the coords captured when this timer was scheduled\n // ~throttleMs ago — otherwise the highlight lags the cursor during\n // continuous movement.\n const x = this.#lastMouseX;\n const y = this.#lastMouseY;\n if (this.#pointInTooltip(x, y)) return;\n this.#resolveAt(x, y);\n }, throttleMs);\n };\n\n #select(info: ElementInfo, openInEditor = false) {\n const target = this.#targetEl;\n // Cancel the whole selection mode on any deliberate pick, before acting —\n // the editor may open via a URL scheme that doesn't navigate this tab away,\n // so we can't rely on the open outcome to dismiss the inspector.\n this.deactivate();\n this.#options.onSelect?.(info);\n if (openInEditor) {\n this.#openInEditor(info.source.filePath, info.source.lineNumber);\n return;\n }\n // Report the picked element to the DevTools panel, which selects it in the\n // Components tree. Identity matches the inspector runtime via idOf().\n if (target !== null) {\n this.#hot?.send(INSPECT_DATA_CHANNEL, {type: 'pick', id: idOf(target)});\n this.#openDevtoolsPanel();\n }\n }\n\n /**\n * Bring the Lit DevTools dock entry to the front so a pick is visible even\n * when the panel was closed. The panel mirrors this from its own\n * `inspector-activate` handler, but only once its iframe is mounted — and the\n * @vitejs/devtools shell does not mount that iframe until the entry has been\n * opened at least once. This overlay always runs on the page, so calling\n * `switchEntry` here covers the cold-start case where no panel exists yet to\n * receive the `pick` message.\n */\n #openDevtoolsPanel() {\n try {\n const ctx = (\n window as unknown as Record<\n string,\n undefined | {docks?: {switchEntry?: (id: string) => Promise<boolean>}}\n >\n ).__VITE_DEVTOOLS_CLIENT_CONTEXT__;\n ctx?.docks?.switchEntry?.('lit-devtools');\n } catch {\n // Not running inside the DevTools shell — ignore.\n }\n }\n\n #pointInTooltip(x: number, y: number): boolean {\n if (this.#tooltip.style.display === 'none') return false;\n const r = this.#tooltip.getBoundingClientRect();\n return x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;\n }\n\n #onClick = (event: MouseEvent) => {\n if (!this.#active || this.#info === null) return;\n // Clicks on the tooltip panel are handled by its own buttons (open/copy).\n // The overlay's shadow root is closed, so we detect this by hit-rect rather\n // than inspecting the event path, and let the event reach those buttons.\n if (this.#pointInTooltip(event.clientX, event.clientY)) return;\n event.preventDefault();\n event.stopPropagation();\n this.#select(this.#info, event.metaKey || event.ctrlKey);\n };\n\n #onScrollOrResize = () => {\n if (this.#scrollTimer !== undefined) clearTimeout(this.#scrollTimer);\n this.#scrollTimer = setTimeout(() => {\n this.#scrollTimer = undefined;\n if (this.#targetEl !== null) {\n this.#updateHighlightRect();\n }\n }, 50);\n };\n}\n\ncustomElements.define('lit-source-overlay', LitSourceOverlay);\n\nexport const initSourceOverlay = (\n initOptions: SourceOverlayInitOptions = {}\n) => {\n if (typeof window === 'undefined') return;\n const el = document.createElement('lit-source-overlay') as LitSourceOverlay;\n el.configure(initOptions);\n document.body.append(el);\n};\n\nexport const toggleSourceOverlay = () => {\n const el = document.querySelector(\n 'lit-source-overlay'\n ) as LitSourceOverlay | null;\n el?.toggle();\n};\n"]}
1
+ {"version":3,"file":"overlay-element.js","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/overlay-element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,sBAAsB,EAAC,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,IAAI,EAAC,MAAM,yBAAyB,CAAC;AAC7C,OAAO,EACL,8BAA8B,EAC9B,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAYrC,MAAM,gBAAiB,SAAQ,WAAW;IACxC,OAAO,GAAG,KAAK,CAAC;IAChB,IAAI,CAA6D;IACjE,QAAQ,GAA6B,EAAE,CAAC;IACxC,OAAO,GAAiB,eAAe,CAAC,MAAM,CAAC;IAC/C,SAAS,GAAoB,eAAe,CAAC;IAC7C,OAAO,CAAoB;IAC3B,KA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I,CAAC,YAAY,GAAG,SAAS,CAAC;YAC9B,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;gBAC5B,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC9B,CAAC;QACH,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC,CAAC;CACH;AAED,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;AAE9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,cAAwC,EAAE,EAC1C,EAAE;IACF,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAC1C,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAqB,CAAC;IAC5E,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAC/B,oBAAoB,CACM,CAAC;IAC7B,EAAE,EAAE,MAAM,EAAE,CAAC;AACf,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type {ElementInfo, EditorConfig} from '../../types.js';\nimport {BUILTIN_EDITORS, resolveEditor} from './editors.js';\nimport {\n defaultResolver,\n findSourceAtPoint,\n findSourceHost,\n type ElementResolver,\n} from './source-host.js';\nimport {buildSpotlightClipPath} from './mask-path.js';\nimport {OVERLAY_HTML} from './template.js';\nimport {observeEdgeInsets} from '../edge-panel.js';\nimport {subscribeOverride} from '../overrides.js';\nimport {injectTokens} from '../../tokens.js';\nimport {idOf} from '../timeline/identity.js';\nimport {\n INSPECT_OVERLAY_TOGGLE_CHANNEL,\n INSPECT_DATA_CHANNEL,\n} from '../../../types/inspector.js';\n\nexport interface SourceOverlayInitOptions {\n key?: string;\n editor?: EditorConfig | string;\n workspaceRoot?: string;\n throttleMs?: number;\n exclude?: (el: Element) => boolean;\n onSelect?: (info: ElementInfo) => void;\n openInEditorPath?: string;\n}\n\nclass LitSourceOverlay extends HTMLElement {\n #active = false;\n #hot: {send: (event: string, data: unknown) => void} | undefined;\n #options: SourceOverlayInitOptions = {};\n #editor: EditorConfig = BUILTIN_EDITORS.vscode;\n #resolver: ElementResolver = defaultResolver;\n #dialog: HTMLDialogElement;\n #mask: HTMLElement;\n #highlight: HTMLElement;\n #tooltip: HTMLElement;\n #tag: HTMLElement;\n #path: HTMLElement;\n #info: ElementInfo | null = null;\n #targetEl: Element | null = null;\n #throttleTimer: ReturnType<typeof setTimeout> | undefined;\n #scrollTimer: ReturnType<typeof setTimeout> | undefined;\n #resizeObserver: ResizeObserver | undefined;\n #cursorStyle: HTMLStyleElement | null = null;\n // Whether the Vite HMR WebSocket is currently connected. Used to suppress the\n // editor-URL-scheme fallback once the dev server is gone — otherwise a failed\n // open-in-editor fetch would navigate the tab to `vscode://…`.\n #connected = true;\n #lastMouseX = 0;\n #lastMouseY = 0;\n #edgeDispose: (() => void) | undefined;\n #overrideSubscribed = false;\n\n constructor() {\n super();\n const root = this.attachShadow({mode: 'closed'});\n root.innerHTML = OVERLAY_HTML;\n this.#dialog = root.getElementById('overlay') as HTMLDialogElement;\n this.#mask = root.getElementById('mask')!;\n this.#highlight = root.getElementById('highlight')!;\n this.#tooltip = root.getElementById('tooltip')!;\n this.#tag = root.getElementById('tag')!;\n this.#path = root.getElementById('path')!;\n root.getElementById('open')!.addEventListener('click', (e) => {\n e.stopPropagation();\n if (this.#info !== null) this.#select(this.#info, true);\n });\n root.getElementById('copy')!.addEventListener('click', (e) => {\n e.stopPropagation();\n if (this.#info === null) return;\n const text = `${this.#normalizePath(this.#info.source.filePath)}:${this.#info.source.lineNumber}`;\n navigator.clipboard?.writeText(text);\n });\n this.#dialog.addEventListener('cancel', (e) => e.preventDefault());\n }\n\n connectedCallback() {\n injectTokens();\n document.addEventListener('mousemove', this.#onTrackMouse, true);\n document.addEventListener('keydown', this.#onKeyDown, true);\n const hot = (\n import.meta as {\n hot?: {\n on: (event: string, cb: (data?: unknown) => void) => void;\n send: (event: string, data: unknown) => void;\n };\n }\n ).hot;\n this.#hot = hot;\n hot?.on('vite:beforeFullReload', () => this.deactivate());\n hot?.on('vite:ws:disconnect', () => (this.#connected = false));\n hot?.on('vite:ws:connect', () => (this.#connected = true));\n // Toggle from the Vite DevTools command/shortcut (handler runs server-side).\n hot?.on(INSPECT_OVERLAY_TOGGLE_CHANNEL, () => this.toggle());\n // Keep the (bottom-fixed) tooltip clear of the Vite DevTools edge panel.\n this.#edgeDispose = observeEdgeInsets((insets) => {\n this.style.setProperty('--edge-bottom', `${insets.bottom}px`);\n });\n // Apply the panel's editor override live (and on load). Merge so other\n // configured options (key, throttle, …) survive.\n if (!this.#overrideSubscribed) {\n this.#overrideSubscribed = true;\n subscribeOverride(hot, (o) => {\n if (o.sourceOverlayEditor !== undefined) {\n this.#options = {...this.#options, editor: o.sourceOverlayEditor};\n this.#editor = resolveEditor(o.sourceOverlayEditor);\n }\n });\n }\n }\n\n disconnectedCallback() {\n document.removeEventListener('mousemove', this.#onTrackMouse, true);\n document.removeEventListener('keydown', this.#onKeyDown, true);\n this.deactivate();\n this.#edgeDispose?.();\n this.#edgeDispose = undefined;\n }\n\n configure(options: SourceOverlayInitOptions) {\n this.#options = options;\n this.#editor = resolveEditor(options.editor);\n }\n\n activate() {\n if (this.#active) return;\n this.#active = true;\n this.#dialog.showModal();\n this.#mask.style.background = 'rgba(0,0,0,0.35)';\n // The overlay is pointer-events:none, so the cursor reflects the hovered\n // page element. Force a crosshair while inspecting. The closed shadow DOM\n // tooltip is unaffected, so its buttons keep their own pointer cursor.\n if (this.#cursorStyle === null) {\n this.#cursorStyle = document.createElement('style');\n this.#cursorStyle.textContent = '*{cursor:crosshair !important}';\n }\n document.head.append(this.#cursorStyle);\n document.addEventListener('mousemove', this.#onMouseMove, true);\n document.addEventListener('click', this.#onClick, true);\n window.addEventListener('scroll', this.#onScrollOrResize, {passive: true});\n window.addEventListener('resize', this.#onScrollOrResize, {passive: true});\n this.#resolveAt(this.#lastMouseX, this.#lastMouseY);\n }\n\n deactivate() {\n if (!this.#active) return;\n this.#active = false;\n this.#dialog.close();\n this.#mask.style.background = 'rgba(0,0,0,0)';\n this.#cursorStyle?.remove();\n document.removeEventListener('mousemove', this.#onMouseMove, true);\n document.removeEventListener('click', this.#onClick, true);\n window.removeEventListener('scroll', this.#onScrollOrResize);\n window.removeEventListener('resize', this.#onScrollOrResize);\n if (this.#throttleTimer !== undefined) {\n clearTimeout(this.#throttleTimer);\n this.#throttleTimer = undefined;\n }\n if (this.#scrollTimer !== undefined) {\n clearTimeout(this.#scrollTimer);\n this.#scrollTimer = undefined;\n }\n this.#clearTarget();\n }\n\n toggle() {\n if (this.#active) this.deactivate();\n else this.activate();\n }\n\n #normalizePath(filePath: string): string {\n const root = this.#options.workspaceRoot;\n if (root !== undefined && filePath.startsWith(root)) {\n const rest = filePath.slice(root.length);\n return rest.startsWith('/') ? rest.slice(1) : rest;\n }\n return filePath;\n }\n\n async #openInEditor(filePath: string, lineNumber: number) {\n const path = this.#normalizePath(filePath);\n const endpoint = this.#options.openInEditorPath ?? '/__lit-open-in-editor';\n try {\n const params = new URLSearchParams({\n file: path,\n line: String(lineNumber),\n });\n const res = await fetch(`${endpoint}?${params.toString()}`);\n if (res.ok) return;\n } catch {\n // Fall back to editor URL schemes (e.g. StackBlitz previews).\n }\n // Skip the URL-scheme fallback when the dev server is gone: a fetch failure\n // there means \"server quit\", not \"no endpoint\", and navigating the tab to\n // `vscode://…` on shutdown is jarring and unwanted.\n if (!this.#connected) return;\n window.open(this.#editor.url(path, lineNumber), '_self');\n }\n\n #updateHighlightRect() {\n if (this.#targetEl === null) return;\n const rect = this.#targetEl.getBoundingClientRect();\n const raw = getComputedStyle(this)\n .getPropertyValue('--lit-devtools-radius')\n .trim();\n const r = parseFloat(raw) || 6;\n // The tinted box hugs the element's exact rect — that's the boundary being\n // picked; only the spotlight cutout gets the breathing room of `r`.\n this.#highlight.style.display = 'block';\n this.#highlight.style.left = `${rect.left}px`;\n this.#highlight.style.top = `${rect.top}px`;\n this.#highlight.style.width = `${rect.width}px`;\n this.#highlight.style.height = `${rect.height}px`;\n this.#mask.style.clipPath = buildSpotlightClipPath(\n rect.left - r,\n rect.top - r,\n rect.width + 2 * r,\n rect.height + 2 * r,\n r\n );\n }\n\n #showTooltip() {\n if (this.#info === null) return;\n this.#tag.textContent = `<${this.#info.tagName}>`;\n this.#path.textContent = `${this.#normalizePath(this.#info.source.filePath)}:${this.#info.source.lineNumber}`;\n this.#tooltip.style.display = 'flex';\n }\n\n #clearTarget() {\n this.#targetEl = null;\n this.#info = null;\n this.#highlight.style.display = 'none';\n this.#highlight.style.left = '0';\n this.#highlight.style.top = '0';\n this.#highlight.style.width = '0';\n this.#highlight.style.height = '0';\n this.#mask.style.clipPath = 'none';\n this.#tooltip.style.display = 'none';\n if (this.#resizeObserver !== undefined) {\n this.#resizeObserver.disconnect();\n this.#resizeObserver = undefined;\n }\n }\n\n #shouldSkip(el: Element): boolean {\n if (el === this.#dialog || this.#dialog.contains(el)) return true;\n if (el.tagName === 'IFRAME') return true;\n // Never target devtools' own injected elements (indicator, overlay).\n const tag = el.tagName.toLowerCase();\n if (tag === 'lit-source-overlay' || tag.startsWith('lit-devtools-')) {\n return true;\n }\n const exclude = this.#options.exclude;\n return exclude !== undefined && exclude(el);\n }\n\n async #resolveAt(x: number, y: number) {\n this.#lastMouseX = x;\n this.#lastMouseY = y;\n const el = findSourceAtPoint(x, y, this.#dialog);\n if (el === null || this.#shouldSkip(el)) {\n this.#clearTarget();\n return;\n }\n const host = findSourceHost(el);\n if (host === null) {\n this.#clearTarget();\n return;\n }\n if (host === this.#targetEl && this.#info !== null) {\n this.#updateHighlightRect();\n return;\n }\n this.#targetEl = host;\n if (this.#resizeObserver === undefined) {\n this.#resizeObserver = new ResizeObserver(() =>\n this.#updateHighlightRect()\n );\n } else {\n this.#resizeObserver.disconnect();\n }\n this.#resizeObserver.observe(host);\n const resolved = await this.#resolver.resolveElementInfo(el);\n if (resolved === null) {\n this.#clearTarget();\n return;\n }\n this.#info = resolved;\n this.#updateHighlightRect();\n this.#showTooltip();\n }\n\n #onTrackMouse = (event: MouseEvent) => {\n this.#lastMouseX = event.clientX;\n this.#lastMouseY = event.clientY;\n };\n\n #onKeyDown = (event: KeyboardEvent) => {\n if ((event.metaKey || event.ctrlKey) && event.shiftKey && !event.altKey) {\n const pressed = event.key.toLowerCase();\n const hotkey = (this.#options.key ?? 'e').toLowerCase();\n if (pressed === hotkey) {\n event.preventDefault();\n this.toggle();\n }\n }\n if (this.#active && event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n\n #onMouseMove = (event: MouseEvent) => {\n if (!this.#active) return;\n // Keep the current selection while hovering the tooltip so its buttons stay\n // clickable — the tooltip isn't a source element, so re-resolving here would\n // clear the target and hide the panel out from under the pointer.\n if (this.#pointInTooltip(event.clientX, event.clientY)) return;\n const throttleMs = this.#options.throttleMs ?? 50;\n if (this.#throttleTimer !== undefined) return;\n this.#throttleTimer = setTimeout(() => {\n this.#throttleTimer = undefined;\n // Resolve against the latest pointer position (kept current by\n // #onTrackMouse), not the coords captured when this timer was scheduled\n // ~throttleMs ago — otherwise the highlight lags the cursor during\n // continuous movement.\n const x = this.#lastMouseX;\n const y = this.#lastMouseY;\n if (this.#pointInTooltip(x, y)) return;\n this.#resolveAt(x, y);\n }, throttleMs);\n };\n\n #select(info: ElementInfo, openInEditor = false) {\n const target = this.#targetEl;\n // Cancel the whole selection mode on any deliberate pick, before acting —\n // the editor may open via a URL scheme that doesn't navigate this tab away,\n // so we can't rely on the open outcome to dismiss the inspector.\n this.deactivate();\n this.#options.onSelect?.(info);\n if (openInEditor) {\n this.#openInEditor(info.source.filePath, info.source.lineNumber);\n return;\n }\n // Report the picked element to the DevTools panel, which selects it in the\n // Components tree. Identity matches the inspector runtime via idOf().\n if (target !== null) {\n this.#hot?.send(INSPECT_DATA_CHANNEL, {type: 'pick', id: idOf(target)});\n this.#openDevtoolsPanel();\n }\n }\n\n /**\n * Bring the Lit DevTools dock entry to the front so a pick is visible even\n * when the panel was closed. The panel mirrors this from its own\n * `inspector-activate` handler, but only once its iframe is mounted — and the\n * @vitejs/devtools shell does not mount that iframe until the entry has been\n * opened at least once. This overlay always runs on the page, so calling\n * `switchEntry` here covers the cold-start case where no panel exists yet to\n * receive the `pick` message.\n */\n #openDevtoolsPanel() {\n try {\n const ctx = (\n window as unknown as Record<\n string,\n undefined | {docks?: {switchEntry?: (id: string) => Promise<boolean>}}\n >\n ).__VITE_DEVTOOLS_CLIENT_CONTEXT__;\n ctx?.docks?.switchEntry?.('lit-devtools');\n } catch {\n // Not running inside the DevTools shell — ignore.\n }\n }\n\n #pointInTooltip(x: number, y: number): boolean {\n if (this.#tooltip.style.display === 'none') return false;\n const r = this.#tooltip.getBoundingClientRect();\n return x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;\n }\n\n #onClick = (event: MouseEvent) => {\n if (!this.#active || this.#info === null) return;\n // Clicks on the tooltip panel are handled by its own buttons (open/copy).\n // The overlay's shadow root is closed, so we detect this by hit-rect rather\n // than inspecting the event path, and let the event reach those buttons.\n if (this.#pointInTooltip(event.clientX, event.clientY)) return;\n event.preventDefault();\n event.stopPropagation();\n this.#select(this.#info, event.metaKey || event.ctrlKey);\n };\n\n #onScrollOrResize = () => {\n if (this.#scrollTimer !== undefined) clearTimeout(this.#scrollTimer);\n this.#scrollTimer = setTimeout(() => {\n this.#scrollTimer = undefined;\n if (this.#targetEl !== null) {\n this.#updateHighlightRect();\n }\n }, 50);\n };\n}\n\ncustomElements.define('lit-source-overlay', LitSourceOverlay);\n\nexport const initSourceOverlay = (\n initOptions: SourceOverlayInitOptions = {}\n) => {\n if (typeof window === 'undefined') return;\n const el = document.createElement('lit-source-overlay') as LitSourceOverlay;\n el.configure(initOptions);\n document.body.append(el);\n};\n\nexport const toggleSourceOverlay = () => {\n const el = document.querySelector(\n 'lit-source-overlay'\n ) as LitSourceOverlay | null;\n el?.toggle();\n};\n"]}
@@ -3,5 +3,5 @@
3
3
  * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- export declare const OVERLAY_HTML = "\n <style>\n dialog {\n background: transparent;\n border: none;\n padding: 0;\n margin: 0;\n max-width: none;\n max-height: none;\n pointer-events: none;\n }\n #mask {\n position: fixed;\n inset: 0;\n pointer-events: none;\n background: rgba(0,0,0,0);\n transition: background-color 0.3s cubic-bezier(0.9, 0, 0.1, 1);\n }\n #highlight {\n position: fixed;\n top: 0;\n left: 0;\n pointer-events: none;\n box-sizing: border-box;\n border-radius: var(--lit-devtools-radius-md);\n }\n #tooltip {\n position: fixed;\n /* Lift above the Vite DevTools edge panel when it's docked to the bottom\n (--edge-bottom is set from JS; 0 otherwise). */\n bottom: calc(16px + var(--edge-bottom, 0px));\n left: 50%;\n translate: -50%;\n display: none;\n align-items: stretch;\n pointer-events: auto;\n max-width: min(90vw, 480px);\n border-radius: var(--lit-devtools-radius-md);\n background: var(--lit-devtools-surface-elevated);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n color: var(--lit-devtools-text-strong);\n font: 12px/1.4 var(--lit-devtools-font-mono, ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace);\n box-shadow: var(--lit-devtools-shadow-md);\n overflow: hidden;\n }\n .icon-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n padding: 0 12px;\n border: none;\n background: transparent;\n color: inherit;\n cursor: pointer;\n }\n .icon-btn:hover { background: var(--lit-devtools-surface-hover); }\n /* No outline ring; keyboard focus reuses the subtle hover tint. */\n .icon-btn:focus { outline: none; }\n .icon-btn:focus-visible { background: var(--lit-devtools-surface-hover); }\n .icon-btn svg {\n width: 16px;\n height: 16px;\n display: block;\n fill: currentColor;\n }\n #meta {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: 1px;\n min-width: 0;\n padding: 6px 10px;\n border-left: 1px solid var(--lit-devtools-border-subtle);\n border-right: 1px solid var(--lit-devtools-border-subtle);\n }\n #tag {\n font-weight: 600;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: var(--lit-devtools-text-strong);\n }\n #path {\n color: var(--lit-devtools-text-secondary);\n font-size: 11px;\n word-break: break-all;\n }\n </style>\n <dialog id=\"overlay\">\n <div id=\"mask\"></div>\n <div id=\"highlight\"></div>\n <div id=\"tooltip\">\n <span\n id=\"open\"\n class=\"icon-btn\"\n title=\"Open in editor\"\n aria-label=\"Open in editor\"\n ><svg viewBox=\"0 0 256 256\" aria-hidden=\"true\"><path d=\"M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z\"></path></svg></span>\n <div id=\"meta\">\n <span id=\"tag\"></span>\n <span id=\"path\"></span>\n </div>\n <button\n id=\"copy\"\n class=\"icon-btn\"\n type=\"button\"\n title=\"Copy path\"\n aria-label=\"Copy path\"\n ><svg viewBox=\"0 0 256 256\" aria-hidden=\"true\"><path d=\"M184,64H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H184a8,8,0,0,0,8-8V72A8,8,0,0,0,184,64Zm-8,144H48V80H176ZM224,40V184a8,8,0,0,1-16,0V48H72a8,8,0,0,1,0-16H216A8,8,0,0,1,224,40Z\"></path></svg></button>\n </div>\n </dialog>\n";
6
+ export declare const OVERLAY_HTML = "\n <style>\n dialog {\n background: transparent;\n border: none;\n padding: 0;\n margin: 0;\n max-width: none;\n max-height: none;\n pointer-events: none;\n }\n #mask {\n position: fixed;\n inset: 0;\n pointer-events: none;\n background: rgba(0,0,0,0);\n transition: background-color 0.3s cubic-bezier(0.9, 0, 0.1, 1);\n }\n #highlight {\n position: fixed;\n top: 0;\n left: 0;\n display: none;\n pointer-events: none;\n box-sizing: border-box;\n border-radius: 2px;\n /* Same box the inspector panel draws on tree hover (inspector/install.ts),\n so picking and panel-hovering read as the same selection. */\n background: rgba(77, 99, 255, 0.25);\n outline: 1px solid #4d63ff;\n transition: all 80ms ease-out;\n }\n #tooltip {\n position: fixed;\n /* Lift above the Vite DevTools edge panel when it's docked to the bottom\n (--edge-bottom is set from JS; 0 otherwise). */\n bottom: calc(16px + var(--edge-bottom, 0px));\n left: 50%;\n translate: -50%;\n display: none;\n align-items: stretch;\n pointer-events: auto;\n max-width: min(90vw, 480px);\n border-radius: var(--lit-devtools-radius-md);\n background: var(--lit-devtools-surface-elevated);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n color: var(--lit-devtools-text-strong);\n font: 12px/1.4 var(--lit-devtools-font-mono, ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace);\n box-shadow: var(--lit-devtools-shadow-md);\n overflow: hidden;\n }\n .icon-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n padding: 0 12px;\n border: none;\n background: transparent;\n color: inherit;\n cursor: pointer;\n }\n .icon-btn:hover { background: var(--lit-devtools-surface-hover); }\n /* No outline ring; keyboard focus reuses the subtle hover tint. */\n .icon-btn:focus { outline: none; }\n .icon-btn:focus-visible { background: var(--lit-devtools-surface-hover); }\n .icon-btn svg {\n width: 16px;\n height: 16px;\n display: block;\n fill: currentColor;\n }\n #meta {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: 1px;\n min-width: 0;\n padding: 6px 10px;\n border-left: 1px solid var(--lit-devtools-border-subtle);\n border-right: 1px solid var(--lit-devtools-border-subtle);\n }\n #tag {\n font-weight: 600;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: var(--lit-devtools-text-strong);\n }\n #path {\n color: var(--lit-devtools-text-secondary);\n font-size: 11px;\n word-break: break-all;\n }\n </style>\n <dialog id=\"overlay\">\n <div id=\"mask\"></div>\n <div id=\"highlight\"></div>\n <div id=\"tooltip\">\n <span\n id=\"open\"\n class=\"icon-btn\"\n title=\"Open in editor\"\n aria-label=\"Open in editor\"\n ><svg viewBox=\"0 0 256 256\" aria-hidden=\"true\"><path d=\"M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z\"></path></svg></span>\n <div id=\"meta\">\n <span id=\"tag\"></span>\n <span id=\"path\"></span>\n </div>\n <button\n id=\"copy\"\n class=\"icon-btn\"\n type=\"button\"\n title=\"Copy path\"\n aria-label=\"Copy path\"\n ><svg viewBox=\"0 0 256 256\" aria-hidden=\"true\"><path d=\"M184,64H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H184a8,8,0,0,0,8-8V72A8,8,0,0,0,184,64Zm-8,144H48V80H176ZM224,40V184a8,8,0,0,1-16,0V48H72a8,8,0,0,1,0-16H216A8,8,0,0,1,224,40Z\"></path></svg></button>\n </div>\n </dialog>\n";
7
7
  //# sourceMappingURL=template.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,eAAO,MAAM,YAAY,u2HAiHxB,CAAC"}
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,eAAO,MAAM,YAAY,knIAuHxB,CAAC"}
@@ -30,9 +30,15 @@ export const OVERLAY_HTML = `
30
30
  position: fixed;
31
31
  top: 0;
32
32
  left: 0;
33
+ display: none;
33
34
  pointer-events: none;
34
35
  box-sizing: border-box;
35
- border-radius: var(--lit-devtools-radius-md);
36
+ border-radius: 2px;
37
+ /* Same box the inspector panel draws on tree hover (inspector/install.ts),
38
+ so picking and panel-hovering read as the same selection. */
39
+ background: rgba(77, 99, 255, 0.25);
40
+ outline: 1px solid #4d63ff;
41
+ transition: all 80ms ease-out;
36
42
  }
37
43
  #tooltip {
38
44
  position: fixed;
@@ -1 +1 @@
1
- {"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEpD,8EAA8E;AAC9E,4EAA4E;AAC5E,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA0CL,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAyD3B,SAAS;;;;;;;;;;;SAWT,SAAS;;;CAGjB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {FONT_MONO_VAR} from '../fonts.js';\nimport {CODE_ICON, COPY_ICON} from '../../icons.js';\n\n// Shadow DOM markup for the overlay: a transparent modal <dialog> hosting the\n// dimming mask, the highlight ring, and the bottom-fixed tooltip panel. The\n// panel is a three-section split: open-in-editor icon | tag + path | copy icon.\nexport const OVERLAY_HTML = `\n <style>\n dialog {\n background: transparent;\n border: none;\n padding: 0;\n margin: 0;\n max-width: none;\n max-height: none;\n pointer-events: none;\n }\n #mask {\n position: fixed;\n inset: 0;\n pointer-events: none;\n background: rgba(0,0,0,0);\n transition: background-color 0.3s cubic-bezier(0.9, 0, 0.1, 1);\n }\n #highlight {\n position: fixed;\n top: 0;\n left: 0;\n pointer-events: none;\n box-sizing: border-box;\n border-radius: var(--lit-devtools-radius-md);\n }\n #tooltip {\n position: fixed;\n /* Lift above the Vite DevTools edge panel when it's docked to the bottom\n (--edge-bottom is set from JS; 0 otherwise). */\n bottom: calc(16px + var(--edge-bottom, 0px));\n left: 50%;\n translate: -50%;\n display: none;\n align-items: stretch;\n pointer-events: auto;\n max-width: min(90vw, 480px);\n border-radius: var(--lit-devtools-radius-md);\n background: var(--lit-devtools-surface-elevated);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n color: var(--lit-devtools-text-strong);\n font: 12px/1.4 ${FONT_MONO_VAR};\n box-shadow: var(--lit-devtools-shadow-md);\n overflow: hidden;\n }\n .icon-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n padding: 0 12px;\n border: none;\n background: transparent;\n color: inherit;\n cursor: pointer;\n }\n .icon-btn:hover { background: var(--lit-devtools-surface-hover); }\n /* No outline ring; keyboard focus reuses the subtle hover tint. */\n .icon-btn:focus { outline: none; }\n .icon-btn:focus-visible { background: var(--lit-devtools-surface-hover); }\n .icon-btn svg {\n width: 16px;\n height: 16px;\n display: block;\n fill: currentColor;\n }\n #meta {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: 1px;\n min-width: 0;\n padding: 6px 10px;\n border-left: 1px solid var(--lit-devtools-border-subtle);\n border-right: 1px solid var(--lit-devtools-border-subtle);\n }\n #tag {\n font-weight: 600;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: var(--lit-devtools-text-strong);\n }\n #path {\n color: var(--lit-devtools-text-secondary);\n font-size: 11px;\n word-break: break-all;\n }\n </style>\n <dialog id=\"overlay\">\n <div id=\"mask\"></div>\n <div id=\"highlight\"></div>\n <div id=\"tooltip\">\n <span\n id=\"open\"\n class=\"icon-btn\"\n title=\"Open in editor\"\n aria-label=\"Open in editor\"\n >${CODE_ICON}</span>\n <div id=\"meta\">\n <span id=\"tag\"></span>\n <span id=\"path\"></span>\n </div>\n <button\n id=\"copy\"\n class=\"icon-btn\"\n type=\"button\"\n title=\"Copy path\"\n aria-label=\"Copy path\"\n >${COPY_ICON}</button>\n </div>\n </dialog>\n`;\n"]}
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/template.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEpD,8EAA8E;AAC9E,4EAA4E;AAC5E,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAgDL,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAyD3B,SAAS;;;;;;;;;;;SAWT,SAAS;;;CAGjB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {FONT_MONO_VAR} from '../fonts.js';\nimport {CODE_ICON, COPY_ICON} from '../../icons.js';\n\n// Shadow DOM markup for the overlay: a transparent modal <dialog> hosting the\n// dimming mask, the highlight ring, and the bottom-fixed tooltip panel. The\n// panel is a three-section split: open-in-editor icon | tag + path | copy icon.\nexport const OVERLAY_HTML = `\n <style>\n dialog {\n background: transparent;\n border: none;\n padding: 0;\n margin: 0;\n max-width: none;\n max-height: none;\n pointer-events: none;\n }\n #mask {\n position: fixed;\n inset: 0;\n pointer-events: none;\n background: rgba(0,0,0,0);\n transition: background-color 0.3s cubic-bezier(0.9, 0, 0.1, 1);\n }\n #highlight {\n position: fixed;\n top: 0;\n left: 0;\n display: none;\n pointer-events: none;\n box-sizing: border-box;\n border-radius: 2px;\n /* Same box the inspector panel draws on tree hover (inspector/install.ts),\n so picking and panel-hovering read as the same selection. */\n background: rgba(77, 99, 255, 0.25);\n outline: 1px solid #4d63ff;\n transition: all 80ms ease-out;\n }\n #tooltip {\n position: fixed;\n /* Lift above the Vite DevTools edge panel when it's docked to the bottom\n (--edge-bottom is set from JS; 0 otherwise). */\n bottom: calc(16px + var(--edge-bottom, 0px));\n left: 50%;\n translate: -50%;\n display: none;\n align-items: stretch;\n pointer-events: auto;\n max-width: min(90vw, 480px);\n border-radius: var(--lit-devtools-radius-md);\n background: var(--lit-devtools-surface-elevated);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n color: var(--lit-devtools-text-strong);\n font: 12px/1.4 ${FONT_MONO_VAR};\n box-shadow: var(--lit-devtools-shadow-md);\n overflow: hidden;\n }\n .icon-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n padding: 0 12px;\n border: none;\n background: transparent;\n color: inherit;\n cursor: pointer;\n }\n .icon-btn:hover { background: var(--lit-devtools-surface-hover); }\n /* No outline ring; keyboard focus reuses the subtle hover tint. */\n .icon-btn:focus { outline: none; }\n .icon-btn:focus-visible { background: var(--lit-devtools-surface-hover); }\n .icon-btn svg {\n width: 16px;\n height: 16px;\n display: block;\n fill: currentColor;\n }\n #meta {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: 1px;\n min-width: 0;\n padding: 6px 10px;\n border-left: 1px solid var(--lit-devtools-border-subtle);\n border-right: 1px solid var(--lit-devtools-border-subtle);\n }\n #tag {\n font-weight: 600;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: var(--lit-devtools-text-strong);\n }\n #path {\n color: var(--lit-devtools-text-secondary);\n font-size: 11px;\n word-break: break-all;\n }\n </style>\n <dialog id=\"overlay\">\n <div id=\"mask\"></div>\n <div id=\"highlight\"></div>\n <div id=\"tooltip\">\n <span\n id=\"open\"\n class=\"icon-btn\"\n title=\"Open in editor\"\n aria-label=\"Open in editor\"\n >${CODE_ICON}</span>\n <div id=\"meta\">\n <span id=\"tag\"></span>\n <span id=\"path\"></span>\n </div>\n <button\n id=\"copy\"\n class=\"icon-btn\"\n type=\"button\"\n title=\"Copy path\"\n aria-label=\"Copy path\"\n >${COPY_ICON}</button>\n </div>\n </dialog>\n`;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"source-meta.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/source-meta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C,yEAAyE;AACzE,eAAO,MAAM,eAAe,qCAAqC,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,eAAe,mDAAqC,CAAC;AAElE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,uDAAuD;AACvD,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,MAClB,CAAC;AAkE1C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,IAAI,WAAW,KACd,OA8DF,CAAC"}
1
+ {"version":3,"file":"source-meta.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/source-meta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C,yEAAyE;AACzE,eAAO,MAAM,eAAe,qCAAqC,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,eAAe,mDAAqC,CAAC;AAElE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,uDAAuD;AACvD,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,MAClB,CAAC;AAqI1C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,IAAI,WAAW,KACd,OA8DF,CAAC"}
@@ -14,17 +14,43 @@ export const SOURCE_META_SYM = `Symbol.for('${SOURCE_META_KEY}')`;
14
14
  export const lineNumberAt = (code, index) => code.slice(0, index).split('\n').length;
15
15
  /**
16
16
  * Finds the index after the closing `}` of a class body starting at
17
- * `classStart`. Skips braces inside strings, template literals, and regex
18
- * literals so those don't throw off the count.
17
+ * `classStart`. Skips braces inside strings, comments, regex literals, and
18
+ * template literals — including code in `${…}` interpolations, where nested
19
+ * templates (Lit's `html\`…\`` inside `.map()` etc.) recurse arbitrarily.
19
20
  */
20
21
  const findClassBodyEnd = (code, classStart) => {
21
22
  const open = code.indexOf('{', classStart);
22
23
  if (open === -1)
23
24
  return -1;
25
+ // Brace depth of the code scope currently being scanned. Entering a `${…}`
26
+ // interpolation pushes the enclosing scope's depth and restarts at 1 (the
27
+ // `${` counts as the open brace); balancing it pops back into the template.
24
28
  let depth = 1;
29
+ const interpolationStack = [];
30
+ let inTemplate = false;
25
31
  let i = open + 1;
26
- while (i < code.length && depth > 0) {
32
+ while (i < code.length) {
27
33
  const ch = code[i];
34
+ if (inTemplate) {
35
+ if (ch === '\\') {
36
+ i += 2;
37
+ continue;
38
+ }
39
+ if (ch === '`') {
40
+ inTemplate = false;
41
+ i++;
42
+ continue;
43
+ }
44
+ if (ch === '$' && code[i + 1] === '{') {
45
+ interpolationStack.push(depth);
46
+ depth = 1;
47
+ inTemplate = false;
48
+ i += 2;
49
+ continue;
50
+ }
51
+ i++;
52
+ continue;
53
+ }
28
54
  if (ch === '"' || ch === "'") {
29
55
  const quote = ch;
30
56
  i++;
@@ -37,35 +63,74 @@ const findClassBodyEnd = (code, classStart) => {
37
63
  continue;
38
64
  }
39
65
  if (ch === '`') {
40
- i++;
41
- while (i < code.length && code[i] !== '`') {
42
- if (code[i] === '\\')
43
- i++;
44
- i++;
45
- }
66
+ inTemplate = true;
46
67
  i++;
47
68
  continue;
48
69
  }
49
70
  if (ch === '/') {
50
- const prev = i > 0 ? code[i - 1] : '';
51
- if (/[=:(,+\-!&|?{}[; ]/.test(prev)) {
52
- i++;
53
- while (i < code.length && code[i] !== '/') {
54
- if (code[i] === '\\')
55
- i++;
56
- i++;
57
- }
58
- i++;
71
+ const next = code[i + 1];
72
+ if (next === '/') {
73
+ i = code.indexOf('\n', i);
74
+ if (i === -1)
75
+ return -1;
76
+ continue;
77
+ }
78
+ if (next === '*') {
79
+ i = code.indexOf('*/', i + 2);
80
+ if (i === -1)
81
+ return -1;
82
+ i += 2;
59
83
  continue;
60
84
  }
85
+ // Regex literal vs division: scan back over whitespace to the last
86
+ // significant char — a regex can only follow an operator, opening
87
+ // punctuation, or a keyword like `return`. `a / b` has an identifier
88
+ // there, so it's division and scans on as plain code.
89
+ let j = i - 1;
90
+ while (j >= 0 && /\s/.test(code[j]))
91
+ j--;
92
+ const prev = j >= 0 ? code[j] : '';
93
+ const regexPossible = j < 0 ||
94
+ /[=:(,+\-!&|?{}[;]/.test(prev) ||
95
+ /(?:^|[^\w$])(?:return|typeof|case|instanceof|in|of|new|delete|void|throw|do|else|yield|await)$/.test(code.slice(Math.max(0, j - 11), j + 1));
96
+ if (regexPossible) {
97
+ let k = i + 1;
98
+ let inCharClass = false;
99
+ while (k < code.length &&
100
+ code[k] !== '\n' &&
101
+ (inCharClass || code[k] !== '/')) {
102
+ if (code[k] === '\\')
103
+ k++;
104
+ else if (code[k] === '[')
105
+ inCharClass = true;
106
+ else if (code[k] === ']')
107
+ inCharClass = false;
108
+ k++;
109
+ }
110
+ if (code[k] === '/') {
111
+ i = k + 1;
112
+ continue;
113
+ }
114
+ // No closing `/` before the line ends — not a regex after all.
115
+ }
61
116
  }
62
- if (ch === '{')
117
+ if (ch === '{') {
63
118
  depth++;
64
- else if (ch === '}')
119
+ }
120
+ else if (ch === '}') {
65
121
  depth--;
122
+ if (depth === 0) {
123
+ const enclosing = interpolationStack.pop();
124
+ if (enclosing === undefined) {
125
+ return i + 1;
126
+ }
127
+ depth = enclosing;
128
+ inTemplate = true;
129
+ }
130
+ }
66
131
  i++;
67
132
  }
68
- return depth === 0 ? i : -1;
133
+ return -1;
69
134
  };
70
135
  const makeAssignment = (className, filePath, lineNumber) => `${className}[${SOURCE_META_SYM}]={filePath:${JSON.stringify(filePath)},lineNumber:${lineNumber},componentName:${JSON.stringify(className)}};`;
71
136
  /** True when `className` is declared as a class/let/const in module code. */
@@ -1 +1 @@
1
- {"version":3,"file":"source-meta.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/source-meta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,kCAAkC,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,eAAe,IAAI,CAAC;AAQlE,uDAAuD;AACvD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,KAAa,EAAU,EAAE,CAClE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,IAA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C,CAAC,CAAC,CAAC;QACvB,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,uBAAuB,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;YACzE,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACzC,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;QAC5D,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,sDAAsD;IACtD,0DAA0D;IAC1D,qDAAqD;IACrD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAC3B,sFAAsF,CACvF,EAAE,CAAC;QACF,MAAM,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,SAAS;QACtC,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACzC,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;QAC5D,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type MagicString from 'magic-string';\n\n/** Stable key shared between transform output and runtime resolution. */\nexport const SOURCE_META_KEY = '@lit-labs/vite-plugin-lit#source';\n\n/**\n * The expression string used in generated code to reference the shared\n * symbol at runtime.\n */\nexport const SOURCE_META_SYM = `Symbol.for('${SOURCE_META_KEY}')`;\n\nexport interface InjectedSourceMeta {\n filePath: string;\n lineNumber: number;\n componentName?: string;\n}\n\n/** 1-based line number for an index in source text. */\nexport const lineNumberAt = (code: string, index: number): number =>\n code.slice(0, index).split('\\n').length;\n\n/**\n * Finds the index after the closing `}` of a class body starting at\n * `classStart`. Skips braces inside strings, template literals, and regex\n * literals so those don't throw off the count.\n */\nconst findClassBodyEnd = (code: string, classStart: number): number => {\n const open = code.indexOf('{', classStart);\n if (open === -1) return -1;\n let depth = 1;\n let i = open + 1;\n while (i < code.length && depth > 0) {\n const ch = code[i];\n if (ch === '\"' || ch === \"'\") {\n const quote = ch;\n i++;\n while (i < code.length && code[i] !== quote) {\n if (code[i] === '\\\\') i++;\n i++;\n }\n i++;\n continue;\n }\n if (ch === '`') {\n i++;\n while (i < code.length && code[i] !== '`') {\n if (code[i] === '\\\\') i++;\n i++;\n }\n i++;\n continue;\n }\n if (ch === '/') {\n const prev = i > 0 ? code[i - 1] : '';\n if (/[=:(,+\\-!&|?{}[; ]/.test(prev)) {\n i++;\n while (i < code.length && code[i] !== '/') {\n if (code[i] === '\\\\') i++;\n i++;\n }\n i++;\n continue;\n }\n }\n if (ch === '{') depth++;\n else if (ch === '}') depth--;\n i++;\n }\n return depth === 0 ? i : -1;\n};\n\nconst makeAssignment = (\n className: string,\n filePath: string,\n lineNumber: number\n) =>\n `${className}[${SOURCE_META_SYM}]={filePath:${JSON.stringify(filePath)},lineNumber:${lineNumber},componentName:${JSON.stringify(className)}};`;\n\n/** True when `className` is declared as a class/let/const in module code. */\nconst isClassDeclaredInModule = (code: string, className: string): boolean =>\n new RegExp(\n `^\\\\s*(?:export\\\\s+)?(?:class|let|const|var)\\\\s+${className}\\\\b`,\n 'm'\n ).test(code);\n\n/**\n * Injects component source metadata onto custom element class constructors.\n * Returns whether any injection was made.\n */\nexport const injectSourceMeta = (\n code: string,\n filePath: string,\n ms: MagicString\n): boolean => {\n if (code.includes(SOURCE_META_SYM)) {\n return false;\n }\n let changed = false;\n const injected = new Set<string>();\n\n const injectAtClassEnd = (\n className: string,\n matchIndex: number,\n match: string\n ) => {\n if (injected.has(className)) return;\n const classOffset = match.indexOf('class');\n if (classOffset === -1) return;\n const classStart = matchIndex + classOffset;\n const end = findClassBodyEnd(code, classStart);\n if (end === -1) return;\n // Report the match start (the `@customElement` decorator) rather than the\n // `class` keyword, so the overlay points at the top of the component.\n const line = lineNumberAt(code, matchIndex);\n ms.append('\\n' + makeAssignment(className, filePath, line));\n injected.add(className);\n changed = true;\n };\n\n // @customElement(...) class Foo (any whitespace between them)\n for (const m of code.matchAll(\n /@customElement\\s*\\([^)]*\\)\\s+(?:export\\s+)?class\\s+(\\w+)/g\n )) {\n injectAtClassEnd(m[1], m.index, m[0]);\n }\n\n // customElements.define('tag', ClassName)\n for (const m of code.matchAll(\n /customElements\\.define\\s*\\(\\s*['\"][^'\"]+['\"]\\s*,\\s*(\\w+)/g\n )) {\n const className = m[1];\n if (injected.has(className) || !isClassDeclaredInModule(code, className)) {\n continue;\n }\n const line = lineNumberAt(code, m.index);\n ms.append('\\n' + makeAssignment(className, filePath, line));\n injected.add(className);\n changed = true;\n }\n\n // TypeScript experimental-decorators / esbuild output\n // e.g. `Foo = __decorateClass([customElement(...)], Foo)`\n // `Foo = _decorate([customElement(...)], Foo)`\n for (const m of code.matchAll(\n /(\\w+)\\s*=\\s*__decorate\\w*\\(\\s*\\[[\\s\\S]*?customElement\\s*\\([^)]*\\)[\\s\\S]*?\\],\\s*\\1\\)/g\n )) {\n const className = m[1];\n if (injected.has(className)) continue;\n const line = lineNumberAt(code, m.index);\n ms.append('\\n' + makeAssignment(className, filePath, line));\n injected.add(className);\n changed = true;\n }\n\n return changed;\n};\n"]}
1
+ {"version":3,"file":"source-meta.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/source-meta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,kCAA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AY,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACzC,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;QAC5D,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,sDAAsD;IACtD,0DAA0D;IAC1D,qDAAqD;IACrD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAC3B,sFAAsF,CACvF,EAAE,CAAC;QACF,MAAM,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,SAAS;QACtC,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACzC,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;QAC5D,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type MagicString from 'magic-string';\n\n/** Stable key shared between transform output and runtime resolution. */\nexport const SOURCE_META_KEY = '@lit-labs/vite-plugin-lit#source';\n\n/**\n * The expression string used in generated code to reference the shared\n * symbol at runtime.\n */\nexport const SOURCE_META_SYM = `Symbol.for('${SOURCE_META_KEY}')`;\n\nexport interface InjectedSourceMeta {\n filePath: string;\n lineNumber: number;\n componentName?: string;\n}\n\n/** 1-based line number for an index in source text. */\nexport const lineNumberAt = (code: string, index: number): number =>\n code.slice(0, index).split('\\n').length;\n\n/**\n * Finds the index after the closing `}` of a class body starting at\n * `classStart`. Skips braces inside strings, comments, regex literals, and\n * template literals — including code in `${…}` interpolations, where nested\n * templates (Lit's `html\\`…\\`` inside `.map()` etc.) recurse arbitrarily.\n */\nconst findClassBodyEnd = (code: string, classStart: number): number => {\n const open = code.indexOf('{', classStart);\n if (open === -1) return -1;\n // Brace depth of the code scope currently being scanned. Entering a `${…}`\n // interpolation pushes the enclosing scope's depth and restarts at 1 (the\n // `${` counts as the open brace); balancing it pops back into the template.\n let depth = 1;\n const interpolationStack: number[] = [];\n let inTemplate = false;\n let i = open + 1;\n while (i < code.length) {\n const ch = code[i];\n if (inTemplate) {\n if (ch === '\\\\') {\n i += 2;\n continue;\n }\n if (ch === '`') {\n inTemplate = false;\n i++;\n continue;\n }\n if (ch === '$' && code[i + 1] === '{') {\n interpolationStack.push(depth);\n depth = 1;\n inTemplate = false;\n i += 2;\n continue;\n }\n i++;\n continue;\n }\n if (ch === '\"' || ch === \"'\") {\n const quote = ch;\n i++;\n while (i < code.length && code[i] !== quote) {\n if (code[i] === '\\\\') i++;\n i++;\n }\n i++;\n continue;\n }\n if (ch === '`') {\n inTemplate = true;\n i++;\n continue;\n }\n if (ch === '/') {\n const next = code[i + 1];\n if (next === '/') {\n i = code.indexOf('\\n', i);\n if (i === -1) return -1;\n continue;\n }\n if (next === '*') {\n i = code.indexOf('*/', i + 2);\n if (i === -1) return -1;\n i += 2;\n continue;\n }\n // Regex literal vs division: scan back over whitespace to the last\n // significant char — a regex can only follow an operator, opening\n // punctuation, or a keyword like `return`. `a / b` has an identifier\n // there, so it's division and scans on as plain code.\n let j = i - 1;\n while (j >= 0 && /\\s/.test(code[j])) j--;\n const prev = j >= 0 ? code[j] : '';\n const regexPossible =\n j < 0 ||\n /[=:(,+\\-!&|?{}[;]/.test(prev) ||\n /(?:^|[^\\w$])(?:return|typeof|case|instanceof|in|of|new|delete|void|throw|do|else|yield|await)$/.test(\n code.slice(Math.max(0, j - 11), j + 1)\n );\n if (regexPossible) {\n let k = i + 1;\n let inCharClass = false;\n while (\n k < code.length &&\n code[k] !== '\\n' &&\n (inCharClass || code[k] !== '/')\n ) {\n if (code[k] === '\\\\') k++;\n else if (code[k] === '[') inCharClass = true;\n else if (code[k] === ']') inCharClass = false;\n k++;\n }\n if (code[k] === '/') {\n i = k + 1;\n continue;\n }\n // No closing `/` before the line ends — not a regex after all.\n }\n }\n if (ch === '{') {\n depth++;\n } else if (ch === '}') {\n depth--;\n if (depth === 0) {\n const enclosing = interpolationStack.pop();\n if (enclosing === undefined) {\n return i + 1;\n }\n depth = enclosing;\n inTemplate = true;\n }\n }\n i++;\n }\n return -1;\n};\n\nconst makeAssignment = (\n className: string,\n filePath: string,\n lineNumber: number\n) =>\n `${className}[${SOURCE_META_SYM}]={filePath:${JSON.stringify(filePath)},lineNumber:${lineNumber},componentName:${JSON.stringify(className)}};`;\n\n/** True when `className` is declared as a class/let/const in module code. */\nconst isClassDeclaredInModule = (code: string, className: string): boolean =>\n new RegExp(\n `^\\\\s*(?:export\\\\s+)?(?:class|let|const|var)\\\\s+${className}\\\\b`,\n 'm'\n ).test(code);\n\n/**\n * Injects component source metadata onto custom element class constructors.\n * Returns whether any injection was made.\n */\nexport const injectSourceMeta = (\n code: string,\n filePath: string,\n ms: MagicString\n): boolean => {\n if (code.includes(SOURCE_META_SYM)) {\n return false;\n }\n let changed = false;\n const injected = new Set<string>();\n\n const injectAtClassEnd = (\n className: string,\n matchIndex: number,\n match: string\n ) => {\n if (injected.has(className)) return;\n const classOffset = match.indexOf('class');\n if (classOffset === -1) return;\n const classStart = matchIndex + classOffset;\n const end = findClassBodyEnd(code, classStart);\n if (end === -1) return;\n // Report the match start (the `@customElement` decorator) rather than the\n // `class` keyword, so the overlay points at the top of the component.\n const line = lineNumberAt(code, matchIndex);\n ms.append('\\n' + makeAssignment(className, filePath, line));\n injected.add(className);\n changed = true;\n };\n\n // @customElement(...) class Foo (any whitespace between them)\n for (const m of code.matchAll(\n /@customElement\\s*\\([^)]*\\)\\s+(?:export\\s+)?class\\s+(\\w+)/g\n )) {\n injectAtClassEnd(m[1], m.index, m[0]);\n }\n\n // customElements.define('tag', ClassName)\n for (const m of code.matchAll(\n /customElements\\.define\\s*\\(\\s*['\"][^'\"]+['\"]\\s*,\\s*(\\w+)/g\n )) {\n const className = m[1];\n if (injected.has(className) || !isClassDeclaredInModule(code, className)) {\n continue;\n }\n const line = lineNumberAt(code, m.index);\n ms.append('\\n' + makeAssignment(className, filePath, line));\n injected.add(className);\n changed = true;\n }\n\n // TypeScript experimental-decorators / esbuild output\n // e.g. `Foo = __decorateClass([customElement(...)], Foo)`\n // `Foo = _decorate([customElement(...)], Foo)`\n for (const m of code.matchAll(\n /(\\w+)\\s*=\\s*__decorate\\w*\\(\\s*\\[[\\s\\S]*?customElement\\s*\\([^)]*\\)[\\s\\S]*?\\],\\s*\\1\\)/g\n )) {\n const className = m[1];\n if (injected.has(className)) continue;\n const line = lineNumberAt(code, m.index);\n ms.append('\\n' + makeAssignment(className, filePath, line));\n injected.add(className);\n changed = true;\n }\n\n return changed;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oddsquad/vite-plugin-lit",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
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)",
@@ -1 +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;IAC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;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;IAyBnB,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"}
@@ -385,7 +385,13 @@ let ComponentsView = class ComponentsView extends LitElement {
385
385
  file: src.file,
386
386
  line: String(src.line),
387
387
  });
388
- fetch(`/__lit-open-in-editor?${params.toString()}`).catch((err) => {
388
+ fetch(`/__lit-open-in-editor?${params.toString()}`)
389
+ .then(async (res) => {
390
+ if (!res.ok) {
391
+ console.warn(`[lit-devtools] open-in-editor failed (${res.status})`, await res.text());
392
+ }
393
+ })
394
+ .catch((err) => {
389
395
  console.warn('[lit-devtools] open-in-editor failed', err);
390
396
  });
391
397
  }
@@ -1 +1 @@
1
- {"version":3,"file":"components-view.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/panel/components-view.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;AAEH,OAAO,EAA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C,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {LitElement, html, css, nothing, type TemplateResult} from 'lit';\nimport {customElement, state} from 'lit/decorators.js';\nimport {tokens} from '../lib/tokens.js';\nimport {\n INSPECT_PATH,\n INSPECT_SSE_EVENT,\n type InspectorCommand,\n type InspectorDetails,\n type InspectorMessage,\n type InspectorTreeNode,\n} from '../types/inspector.js';\n\n/** localStorage key remembering the opt-in live-tree toggle. */\nconst LIVE_LS_KEY = 'lit-devtools-components-live';\n\n/**\n * The Components view: a hierarchical tree of the page's Lit elements (left)\n * and a details pane for the selected one (right). A tab of the DevTools panel\n * shell (\\`lit-devtools-panel\\`).\n *\n * It can't touch the page DOM directly (separate iframe), so it drives the\n * page's inspector runtime over the transport: it POSTs {@link InspectorCommand}s\n * to {@link INSPECT_PATH} and receives {@link InspectorMessage}s on the shared\n * SSE stream's `inspect` event. An overlay inspect-pick arrives as a `pick`\n * message; the view selects that node and asks its host to switch to this tab.\n */\n@customElement('components-view')\nexport class ComponentsView extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n }\n :host([hidden]) {\n display: none;\n }\n .toolbar {\n display: flex;\n align-items: center;\n gap: var(--lit-devtools-space-4);\n padding: var(--lit-devtools-space-3) var(--lit-devtools-space-5);\n border-bottom: 1px solid var(--lit-devtools-border);\n background: var(--lit-devtools-surface-low);\n flex-shrink: 0;\n }\n .spacer {\n flex: 1;\n }\n button {\n padding: var(--lit-devtools-space-2) var(--lit-devtools-space-5);\n border-radius: var(--lit-devtools-radius-sm);\n border: 1px solid var(--lit-devtools-border);\n background: var(--lit-devtools-surface-elevated);\n color: var(--lit-devtools-text);\n font-size: var(--lit-devtools-text-2xs);\n cursor: pointer;\n }\n button:hover {\n background: var(--lit-devtools-surface-hover);\n border-color: var(--lit-devtools-border-strong);\n }\n button.pick.active,\n button.live.active {\n border-color: var(--lit-devtools-accent);\n background: var(--lit-devtools-accent-soft);\n color: var(--lit-devtools-accent);\n }\n button:disabled {\n opacity: 0.4;\n cursor: default;\n }\n .body {\n display: flex;\n flex: 1;\n overflow: hidden;\n }\n .tree {\n flex: 1;\n overflow: auto;\n padding: var(--lit-devtools-space-2) 0;\n min-width: 0;\n }\n .empty {\n padding: var(--lit-devtools-space-6);\n color: var(--lit-devtools-text-muted);\n font-size: var(--lit-devtools-text-xs);\n }\n .row {\n display: flex;\n align-items: center;\n gap: var(--lit-devtools-space-2);\n padding: 1px var(--lit-devtools-space-5);\n white-space: nowrap;\n cursor: pointer;\n font-family: var(--lit-devtools-font-mono);\n font-size: var(--lit-devtools-text-xs);\n line-height: 18px;\n }\n .row:hover {\n background: var(--lit-devtools-surface-hover);\n }\n .row.selected {\n background: var(--lit-devtools-surface-active);\n }\n .twisty {\n width: 12px;\n text-align: center;\n color: var(--lit-devtools-text-muted);\n flex-shrink: 0;\n }\n .twisty.leaf {\n visibility: hidden;\n }\n .tag {\n color: var(--lit-devtools-accent);\n }\n .tag .punct {\n color: var(--lit-devtools-text-muted);\n }\n .details {\n width: 340px;\n flex-shrink: 0;\n border-left: 1px solid var(--lit-devtools-border);\n overflow: auto;\n padding: var(--lit-devtools-space-5) var(--lit-devtools-space-5);\n font-size: var(--lit-devtools-text-xs);\n }\n .details h2 {\n font-size: var(--lit-devtools-text-xs);\n font-family: var(--lit-devtools-font-mono);\n color: var(--lit-devtools-accent);\n margin: 0 0 var(--lit-devtools-space-1);\n }\n .src {\n background: none;\n border: 0;\n padding: 0;\n color: var(--lit-devtools-text-link);\n font-size: var(--lit-devtools-text-2xs);\n cursor: pointer;\n text-decoration: underline;\n word-break: break-all;\n text-align: left;\n }\n section {\n margin-top: var(--lit-devtools-space-5);\n }\n section > .label {\n text-transform: uppercase;\n letter-spacing: var(--lit-devtools-tracking-caps);\n font-size: var(--lit-devtools-text-2xs);\n color: var(--lit-devtools-text-muted);\n margin-bottom: var(--lit-devtools-space-2);\n }\n table {\n width: 100%;\n border-collapse: collapse;\n font-family: var(--lit-devtools-font-mono);\n }\n td {\n padding: 2px var(--lit-devtools-space-4) 2px 0;\n vertical-align: top;\n word-break: break-word;\n }\n td.name {\n color: var(--lit-devtools-text);\n white-space: nowrap;\n }\n td.val {\n color: var(--lit-devtools-warning);\n width: 100%;\n }\n .badge {\n display: inline-block;\n margin-left: var(--lit-devtools-space-2);\n padding: 0 var(--lit-devtools-space-2);\n border-radius: var(--lit-devtools-radius-xs);\n font-size: 9px;\n background: var(--lit-devtools-surface-elevated);\n color: var(--lit-devtools-text-secondary);\n vertical-align: middle;\n }\n .flags {\n display: flex;\n gap: var(--lit-devtools-space-4);\n flex-wrap: wrap;\n }\n .flag {\n padding: 1px var(--lit-devtools-space-4);\n border-radius: var(--lit-devtools-radius-xs);\n background: var(--lit-devtools-surface-elevated);\n color: var(--lit-devtools-text-secondary);\n font-size: var(--lit-devtools-text-2xs);\n }\n .flag.on {\n background: var(--lit-devtools-accent-soft);\n color: var(--lit-devtools-accent);\n }\n .placeholder {\n color: var(--lit-devtools-text-muted);\n padding: var(--lit-devtools-space-8) 0;\n text-align: center;\n }\n `,\n ];\n\n @state() private _roots: InspectorTreeNode[] = [];\n @state() private _selectedId: number | null = null;\n @state() private _details: InspectorDetails | null = null;\n /** True when the selected element is no longer in the page (removed / GC'd). */\n @state() private _gone = false;\n @state() private _expanded = new Set<number>();\n @state() private _picking = false;\n /** Opt-in live tree (MutationObserver in the page); persisted, default off. */\n @state() private _live = false;\n\n private _es: EventSource | null = null;\n\n override connectedCallback() {\n super.connectedCallback();\n this._live = localStorage.getItem(LIVE_LS_KEY) === 'true';\n this._es = new EventSource('/__lit-devtools-events');\n this._es.addEventListener(INSPECT_SSE_EVENT, this._onMessage);\n // Request only once the stream is open — a command sent before we're\n // subscribed would have its reply broadcast before we could receive it.\n this._es.addEventListener('open', this._onOpen);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this._es?.removeEventListener(INSPECT_SSE_EVENT, this._onMessage);\n this._es?.removeEventListener('open', this._onOpen);\n this._es?.close();\n this._es = null;\n this._post({type: 'watch', id: null});\n if (this._live) this._post({type: 'observe', enabled: false});\n }\n\n /** Refresh the tree (and re-arm watch / live mode) once the SSE connects. */\n private _onOpen = (): void => {\n this._post({type: 'tree'});\n if (this._selectedId !== null) {\n this._post({type: 'watch', id: this._selectedId});\n }\n if (this._live) this._post({type: 'observe', enabled: true});\n };\n\n // ---------------------------------------------------------------------------\n // Transport\n // ---------------------------------------------------------------------------\n\n private _post(cmd: InspectorCommand): void {\n fetch(INSPECT_PATH, {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify(cmd),\n }).catch((err) => {\n console.warn('[lit-devtools] inspector POST failed', err);\n });\n }\n\n private _onMessage = (e: Event): void => {\n let msg: InspectorMessage;\n try {\n msg = JSON.parse((e as MessageEvent<string>).data) as InspectorMessage;\n } catch {\n return;\n }\n switch (msg.type) {\n case 'ready':\n // Runtime (re)connected — refresh the tree and re-arm any selection.\n this._post({type: 'tree'});\n if (this._selectedId !== null) {\n this._post({type: 'watch', id: this._selectedId});\n }\n break;\n case 'tree':\n this._roots = msg.roots;\n // Re-reveal the selection against the fresh tree: a just-picked node may\n // not have existed in the previous _roots, so the reveal in _select()\n // found no ancestors to expand and the node stayed hidden.\n if (this._selectedId !== null) {\n this._revealAncestors(this._selectedId);\n }\n break;\n case 'details':\n if (msg.details.id === this._selectedId) {\n this._details = msg.details;\n this._gone = false;\n }\n break;\n case 'gone':\n if (msg.id === this._selectedId) {\n this._details = null;\n this._gone = true;\n }\n break;\n case 'pick':\n this._picking = false;\n this._select(msg.id);\n // Bring this tab to the front so the pick is visible.\n this.dispatchEvent(\n new CustomEvent('inspector-activate', {bubbles: true, composed: true})\n );\n break;\n }\n };\n\n // ---------------------------------------------------------------------------\n // Selection / expansion\n // ---------------------------------------------------------------------------\n\n /**\n * Select an element by id from outside (e.g. a timeline event's \"inspect\"\n * link). Same as a tree click; the host is responsible for switching tabs.\n */\n selectById(id: number): void {\n this._select(id);\n }\n\n private _select(id: number): void {\n if (this._selectedId === id) return;\n if (this._selectedId !== null) {\n this._post({type: 'watch', id: null});\n }\n this._selectedId = id;\n this._details = null;\n this._gone = false;\n this._revealAncestors(id);\n this._post({type: 'tree'}); // refresh in case the picked node is new\n this._post({type: 'details', id});\n this._post({type: 'watch', id});\n }\n\n /** Expand every ancestor of `id` so the selected node is visible. */\n private _revealAncestors(id: number): void {\n const path = findAncestors(this._roots, id);\n if (path === null) return;\n const next = new Set(this._expanded);\n for (const ancestorId of path) next.add(ancestorId);\n this._expanded = next;\n }\n\n private _toggleExpand(id: number): void {\n const next = new Set(this._expanded);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n this._expanded = next;\n }\n\n // ---------------------------------------------------------------------------\n // Actions\n // ---------------------------------------------------------------------------\n\n private _refresh(): void {\n this._post({type: 'tree'});\n if (this._selectedId !== null) {\n this._post({type: 'details', id: this._selectedId});\n }\n }\n\n private _togglePick(): void {\n this._picking = !this._picking;\n this._post({type: 'pick'});\n }\n\n private _toggleLive(): void {\n this._live = !this._live;\n try {\n localStorage.setItem(LIVE_LS_KEY, String(this._live));\n } catch {\n // ignore (private/storage unavailable)\n }\n this._post({type: 'observe', enabled: this._live});\n // Leaving live mode, pull one fresh tree so it doesn't go stale silently.\n if (!this._live) this._post({type: 'tree'});\n }\n\n private _highlight(id: number | null): void {\n this._post({type: 'highlight', id});\n }\n\n private _openSource(): void {\n const src = this._details?.source;\n if (src === undefined) return;\n const params = new URLSearchParams({\n file: src.file,\n line: String(src.line),\n });\n fetch(`/__lit-open-in-editor?${params.toString()}`).catch((err) => {\n console.warn('[lit-devtools] open-in-editor failed', err);\n });\n }\n\n // ---------------------------------------------------------------------------\n // Render\n // ---------------------------------------------------------------------------\n\n private _renderNode(node: InspectorTreeNode, depth: number): TemplateResult {\n const hasChildren = node.children.length > 0;\n const expanded = this._expanded.has(node.id);\n return html`\n <div\n class=\"row ${node.id === this._selectedId ? 'selected' : ''}\"\n style=\"padding-left:${8 + depth * 14}px\"\n @click=${() => this._select(node.id)}\n @mouseenter=${() => this._highlight(node.id)}\n >\n <span\n class=\"twisty ${hasChildren ? '' : 'leaf'}\"\n @click=${(e: Event) => {\n e.stopPropagation();\n this._toggleExpand(node.id);\n }}\n >${hasChildren ? (expanded ? '▾' : '▸') : '•'}</span\n >\n <span class=\"tag\"\n ><span class=\"punct\">&lt;</span>${node.tagName}<span class=\"punct\"\n >&gt;</span\n ></span\n >\n </div>\n ${hasChildren && expanded\n ? node.children.map((c) => this._renderNode(c, depth + 1))\n : nothing}\n `;\n }\n\n private _renderPropTable(\n props: InspectorDetails['properties']\n ): TemplateResult {\n return html`\n <table>\n ${props.map(\n (p) => html`\n <tr>\n <td class=\"name\">\n ${p.name}${p.reflects\n ? html`<span class=\"badge\" title=\"reflects to attribute\"\n >${typeof p.attribute === 'string'\n ? p.attribute\n : 'attr'}</span\n >`\n : nothing}\n </td>\n <td class=\"val\">${p.value}</td>\n </tr>\n `\n )}\n </table>\n `;\n }\n\n private _renderDetails(): TemplateResult {\n const d = this._details;\n if (d === null) {\n let message: string;\n if (this._gone) {\n message = 'This element is no longer in the page.';\n } else if (this._selectedId === null) {\n message = 'Select a component to inspect.';\n } else {\n message = 'Loading…';\n }\n return html`<div class=\"placeholder\">${message}</div>`;\n }\n const props = d.properties.filter((p) => !p.state);\n const stateProps = d.properties.filter((p) => p.state);\n return html`\n <h2>&lt;${d.tagName}&gt;</h2>\n ${d.source !== undefined\n ? html`<button class=\"src\" @click=${this._openSource}>\n ${d.source.file}:${d.source.line}\n </button>`\n : nothing}\n <section>\n <div class=\"flags\">\n <span class=\"flag ${d.flags.hasUpdated ? 'on' : ''}\">updated</span>\n <span class=\"flag ${d.flags.isUpdatePending ? 'on' : ''}\"\n >update pending</span\n >\n <span class=\"flag ${d.flags.hasShadowRoot ? 'on' : ''}\"\n >shadow root</span\n >\n </div>\n </section>\n ${props.length > 0\n ? html`<section>\n <div class=\"label\">Properties</div>\n ${this._renderPropTable(props)}\n </section>`\n : nothing}\n ${stateProps.length > 0\n ? html`<section>\n <div class=\"label\">State</div>\n ${this._renderPropTable(stateProps)}\n </section>`\n : nothing}\n ${d.attributes.length > 0\n ? html`<section>\n <div class=\"label\">Attributes</div>\n <table>\n ${d.attributes.map(\n (a) =>\n html`<tr>\n <td class=\"name\">${a.name}</td>\n <td class=\"val\">${a.value}</td>\n </tr>`\n )}\n </table>\n </section>`\n : nothing}\n `;\n }\n\n override render() {\n return html`\n <div class=\"toolbar\">\n <button\n class=\"pick ${this._picking ? 'active' : ''}\"\n title=\"Pick an element on the page (Meta+Shift+E)\"\n @click=${this._togglePick}\n >\n ⌖ Pick\n </button>\n <span class=\"spacer\"></span>\n <button\n class=\"live ${this._live ? 'active' : ''}\"\n title=\"Update the tree automatically as the page changes\"\n @click=${this._toggleLive}\n >\n ${this._live ? '● Live' : '○ Live'}\n </button>\n <button @click=${this._refresh} ?disabled=${this._live}>Refresh</button>\n </div>\n <div class=\"body\">\n <div class=\"tree\" @mouseleave=${() => this._highlight(null)}>\n ${this._roots.length === 0\n ? html`<div class=\"empty\">\n No Lit components found on the page.\n </div>`\n : this._roots.map((n) => this._renderNode(n, 0))}\n </div>\n <div class=\"details\">${this._renderDetails()}</div>\n </div>\n `;\n }\n}\n\n/**\n * Returns the ids of every ancestor of `id` (nearest last), or `null` if `id`\n * isn't in the tree. The target id itself is not included.\n */\nconst findAncestors = (\n nodes: InspectorTreeNode[],\n id: number\n): number[] | null => {\n const trail: number[] = [];\n const walk = (list: InspectorTreeNode[]): boolean => {\n for (const node of list) {\n if (node.id === id) return true;\n trail.push(node.id);\n if (walk(node.children)) return true;\n trail.pop();\n }\n return false;\n };\n return walk(nodes) ? [...trail] : null;\n};\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'components-view': ComponentsView;\n }\n}\n"]}
1
+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,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE;gBAAE,OAAO,IAAI,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACpB,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAAE,OAAO,IAAI,CAAC;YACrC,KAAK,CAAC,GAAG,EAAE,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IACF,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {LitElement, html, css, nothing, type TemplateResult} from 'lit';\nimport {customElement, state} from 'lit/decorators.js';\nimport {tokens} from '../lib/tokens.js';\nimport {\n INSPECT_PATH,\n INSPECT_SSE_EVENT,\n type InspectorCommand,\n type InspectorDetails,\n type InspectorMessage,\n type InspectorTreeNode,\n} from '../types/inspector.js';\n\n/** localStorage key remembering the opt-in live-tree toggle. */\nconst LIVE_LS_KEY = 'lit-devtools-components-live';\n\n/**\n * The Components view: a hierarchical tree of the page's Lit elements (left)\n * and a details pane for the selected one (right). A tab of the DevTools panel\n * shell (\\`lit-devtools-panel\\`).\n *\n * It can't touch the page DOM directly (separate iframe), so it drives the\n * page's inspector runtime over the transport: it POSTs {@link InspectorCommand}s\n * to {@link INSPECT_PATH} and receives {@link InspectorMessage}s on the shared\n * SSE stream's `inspect` event. An overlay inspect-pick arrives as a `pick`\n * message; the view selects that node and asks its host to switch to this tab.\n */\n@customElement('components-view')\nexport class ComponentsView extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n }\n :host([hidden]) {\n display: none;\n }\n .toolbar {\n display: flex;\n align-items: center;\n gap: var(--lit-devtools-space-4);\n padding: var(--lit-devtools-space-3) var(--lit-devtools-space-5);\n border-bottom: 1px solid var(--lit-devtools-border);\n background: var(--lit-devtools-surface-low);\n flex-shrink: 0;\n }\n .spacer {\n flex: 1;\n }\n button {\n padding: var(--lit-devtools-space-2) var(--lit-devtools-space-5);\n border-radius: var(--lit-devtools-radius-sm);\n border: 1px solid var(--lit-devtools-border);\n background: var(--lit-devtools-surface-elevated);\n color: var(--lit-devtools-text);\n font-size: var(--lit-devtools-text-2xs);\n cursor: pointer;\n }\n button:hover {\n background: var(--lit-devtools-surface-hover);\n border-color: var(--lit-devtools-border-strong);\n }\n button.pick.active,\n button.live.active {\n border-color: var(--lit-devtools-accent);\n background: var(--lit-devtools-accent-soft);\n color: var(--lit-devtools-accent);\n }\n button:disabled {\n opacity: 0.4;\n cursor: default;\n }\n .body {\n display: flex;\n flex: 1;\n overflow: hidden;\n }\n .tree {\n flex: 1;\n overflow: auto;\n padding: var(--lit-devtools-space-2) 0;\n min-width: 0;\n }\n .empty {\n padding: var(--lit-devtools-space-6);\n color: var(--lit-devtools-text-muted);\n font-size: var(--lit-devtools-text-xs);\n }\n .row {\n display: flex;\n align-items: center;\n gap: var(--lit-devtools-space-2);\n padding: 1px var(--lit-devtools-space-5);\n white-space: nowrap;\n cursor: pointer;\n font-family: var(--lit-devtools-font-mono);\n font-size: var(--lit-devtools-text-xs);\n line-height: 18px;\n }\n .row:hover {\n background: var(--lit-devtools-surface-hover);\n }\n .row.selected {\n background: var(--lit-devtools-surface-active);\n }\n .twisty {\n width: 12px;\n text-align: center;\n color: var(--lit-devtools-text-muted);\n flex-shrink: 0;\n }\n .twisty.leaf {\n visibility: hidden;\n }\n .tag {\n color: var(--lit-devtools-accent);\n }\n .tag .punct {\n color: var(--lit-devtools-text-muted);\n }\n .details {\n width: 340px;\n flex-shrink: 0;\n border-left: 1px solid var(--lit-devtools-border);\n overflow: auto;\n padding: var(--lit-devtools-space-5) var(--lit-devtools-space-5);\n font-size: var(--lit-devtools-text-xs);\n }\n .details h2 {\n font-size: var(--lit-devtools-text-xs);\n font-family: var(--lit-devtools-font-mono);\n color: var(--lit-devtools-accent);\n margin: 0 0 var(--lit-devtools-space-1);\n }\n .src {\n background: none;\n border: 0;\n padding: 0;\n color: var(--lit-devtools-text-link);\n font-size: var(--lit-devtools-text-2xs);\n cursor: pointer;\n text-decoration: underline;\n word-break: break-all;\n text-align: left;\n }\n section {\n margin-top: var(--lit-devtools-space-5);\n }\n section > .label {\n text-transform: uppercase;\n letter-spacing: var(--lit-devtools-tracking-caps);\n font-size: var(--lit-devtools-text-2xs);\n color: var(--lit-devtools-text-muted);\n margin-bottom: var(--lit-devtools-space-2);\n }\n table {\n width: 100%;\n border-collapse: collapse;\n font-family: var(--lit-devtools-font-mono);\n }\n td {\n padding: 2px var(--lit-devtools-space-4) 2px 0;\n vertical-align: top;\n word-break: break-word;\n }\n td.name {\n color: var(--lit-devtools-text);\n white-space: nowrap;\n }\n td.val {\n color: var(--lit-devtools-warning);\n width: 100%;\n }\n .badge {\n display: inline-block;\n margin-left: var(--lit-devtools-space-2);\n padding: 0 var(--lit-devtools-space-2);\n border-radius: var(--lit-devtools-radius-xs);\n font-size: 9px;\n background: var(--lit-devtools-surface-elevated);\n color: var(--lit-devtools-text-secondary);\n vertical-align: middle;\n }\n .flags {\n display: flex;\n gap: var(--lit-devtools-space-4);\n flex-wrap: wrap;\n }\n .flag {\n padding: 1px var(--lit-devtools-space-4);\n border-radius: var(--lit-devtools-radius-xs);\n background: var(--lit-devtools-surface-elevated);\n color: var(--lit-devtools-text-secondary);\n font-size: var(--lit-devtools-text-2xs);\n }\n .flag.on {\n background: var(--lit-devtools-accent-soft);\n color: var(--lit-devtools-accent);\n }\n .placeholder {\n color: var(--lit-devtools-text-muted);\n padding: var(--lit-devtools-space-8) 0;\n text-align: center;\n }\n `,\n ];\n\n @state() private _roots: InspectorTreeNode[] = [];\n @state() private _selectedId: number | null = null;\n @state() private _details: InspectorDetails | null = null;\n /** True when the selected element is no longer in the page (removed / GC'd). */\n @state() private _gone = false;\n @state() private _expanded = new Set<number>();\n @state() private _picking = false;\n /** Opt-in live tree (MutationObserver in the page); persisted, default off. */\n @state() private _live = false;\n\n private _es: EventSource | null = null;\n\n override connectedCallback() {\n super.connectedCallback();\n this._live = localStorage.getItem(LIVE_LS_KEY) === 'true';\n this._es = new EventSource('/__lit-devtools-events');\n this._es.addEventListener(INSPECT_SSE_EVENT, this._onMessage);\n // Request only once the stream is open — a command sent before we're\n // subscribed would have its reply broadcast before we could receive it.\n this._es.addEventListener('open', this._onOpen);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this._es?.removeEventListener(INSPECT_SSE_EVENT, this._onMessage);\n this._es?.removeEventListener('open', this._onOpen);\n this._es?.close();\n this._es = null;\n this._post({type: 'watch', id: null});\n if (this._live) this._post({type: 'observe', enabled: false});\n }\n\n /** Refresh the tree (and re-arm watch / live mode) once the SSE connects. */\n private _onOpen = (): void => {\n this._post({type: 'tree'});\n if (this._selectedId !== null) {\n this._post({type: 'watch', id: this._selectedId});\n }\n if (this._live) this._post({type: 'observe', enabled: true});\n };\n\n // ---------------------------------------------------------------------------\n // Transport\n // ---------------------------------------------------------------------------\n\n private _post(cmd: InspectorCommand): void {\n fetch(INSPECT_PATH, {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify(cmd),\n }).catch((err) => {\n console.warn('[lit-devtools] inspector POST failed', err);\n });\n }\n\n private _onMessage = (e: Event): void => {\n let msg: InspectorMessage;\n try {\n msg = JSON.parse((e as MessageEvent<string>).data) as InspectorMessage;\n } catch {\n return;\n }\n switch (msg.type) {\n case 'ready':\n // Runtime (re)connected — refresh the tree and re-arm any selection.\n this._post({type: 'tree'});\n if (this._selectedId !== null) {\n this._post({type: 'watch', id: this._selectedId});\n }\n break;\n case 'tree':\n this._roots = msg.roots;\n // Re-reveal the selection against the fresh tree: a just-picked node may\n // not have existed in the previous _roots, so the reveal in _select()\n // found no ancestors to expand and the node stayed hidden.\n if (this._selectedId !== null) {\n this._revealAncestors(this._selectedId);\n }\n break;\n case 'details':\n if (msg.details.id === this._selectedId) {\n this._details = msg.details;\n this._gone = false;\n }\n break;\n case 'gone':\n if (msg.id === this._selectedId) {\n this._details = null;\n this._gone = true;\n }\n break;\n case 'pick':\n this._picking = false;\n this._select(msg.id);\n // Bring this tab to the front so the pick is visible.\n this.dispatchEvent(\n new CustomEvent('inspector-activate', {bubbles: true, composed: true})\n );\n break;\n }\n };\n\n // ---------------------------------------------------------------------------\n // Selection / expansion\n // ---------------------------------------------------------------------------\n\n /**\n * Select an element by id from outside (e.g. a timeline event's \"inspect\"\n * link). Same as a tree click; the host is responsible for switching tabs.\n */\n selectById(id: number): void {\n this._select(id);\n }\n\n private _select(id: number): void {\n if (this._selectedId === id) return;\n if (this._selectedId !== null) {\n this._post({type: 'watch', id: null});\n }\n this._selectedId = id;\n this._details = null;\n this._gone = false;\n this._revealAncestors(id);\n this._post({type: 'tree'}); // refresh in case the picked node is new\n this._post({type: 'details', id});\n this._post({type: 'watch', id});\n }\n\n /** Expand every ancestor of `id` so the selected node is visible. */\n private _revealAncestors(id: number): void {\n const path = findAncestors(this._roots, id);\n if (path === null) return;\n const next = new Set(this._expanded);\n for (const ancestorId of path) next.add(ancestorId);\n this._expanded = next;\n }\n\n private _toggleExpand(id: number): void {\n const next = new Set(this._expanded);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n this._expanded = next;\n }\n\n // ---------------------------------------------------------------------------\n // Actions\n // ---------------------------------------------------------------------------\n\n private _refresh(): void {\n this._post({type: 'tree'});\n if (this._selectedId !== null) {\n this._post({type: 'details', id: this._selectedId});\n }\n }\n\n private _togglePick(): void {\n this._picking = !this._picking;\n this._post({type: 'pick'});\n }\n\n private _toggleLive(): void {\n this._live = !this._live;\n try {\n localStorage.setItem(LIVE_LS_KEY, String(this._live));\n } catch {\n // ignore (private/storage unavailable)\n }\n this._post({type: 'observe', enabled: this._live});\n // Leaving live mode, pull one fresh tree so it doesn't go stale silently.\n if (!this._live) this._post({type: 'tree'});\n }\n\n private _highlight(id: number | null): void {\n this._post({type: 'highlight', id});\n }\n\n private _openSource(): void {\n const src = this._details?.source;\n if (src === undefined) return;\n const params = new URLSearchParams({\n file: src.file,\n line: String(src.line),\n });\n fetch(`/__lit-open-in-editor?${params.toString()}`)\n .then(async (res) => {\n if (!res.ok) {\n console.warn(\n `[lit-devtools] open-in-editor failed (${res.status})`,\n await res.text()\n );\n }\n })\n .catch((err) => {\n console.warn('[lit-devtools] open-in-editor failed', err);\n });\n }\n\n // ---------------------------------------------------------------------------\n // Render\n // ---------------------------------------------------------------------------\n\n private _renderNode(node: InspectorTreeNode, depth: number): TemplateResult {\n const hasChildren = node.children.length > 0;\n const expanded = this._expanded.has(node.id);\n return html`\n <div\n class=\"row ${node.id === this._selectedId ? 'selected' : ''}\"\n style=\"padding-left:${8 + depth * 14}px\"\n @click=${() => this._select(node.id)}\n @mouseenter=${() => this._highlight(node.id)}\n >\n <span\n class=\"twisty ${hasChildren ? '' : 'leaf'}\"\n @click=${(e: Event) => {\n e.stopPropagation();\n this._toggleExpand(node.id);\n }}\n >${hasChildren ? (expanded ? '▾' : '▸') : '•'}</span\n >\n <span class=\"tag\"\n ><span class=\"punct\">&lt;</span>${node.tagName}<span class=\"punct\"\n >&gt;</span\n ></span\n >\n </div>\n ${hasChildren && expanded\n ? node.children.map((c) => this._renderNode(c, depth + 1))\n : nothing}\n `;\n }\n\n private _renderPropTable(\n props: InspectorDetails['properties']\n ): TemplateResult {\n return html`\n <table>\n ${props.map(\n (p) => html`\n <tr>\n <td class=\"name\">\n ${p.name}${p.reflects\n ? html`<span class=\"badge\" title=\"reflects to attribute\"\n >${typeof p.attribute === 'string'\n ? p.attribute\n : 'attr'}</span\n >`\n : nothing}\n </td>\n <td class=\"val\">${p.value}</td>\n </tr>\n `\n )}\n </table>\n `;\n }\n\n private _renderDetails(): TemplateResult {\n const d = this._details;\n if (d === null) {\n let message: string;\n if (this._gone) {\n message = 'This element is no longer in the page.';\n } else if (this._selectedId === null) {\n message = 'Select a component to inspect.';\n } else {\n message = 'Loading…';\n }\n return html`<div class=\"placeholder\">${message}</div>`;\n }\n const props = d.properties.filter((p) => !p.state);\n const stateProps = d.properties.filter((p) => p.state);\n return html`\n <h2>&lt;${d.tagName}&gt;</h2>\n ${d.source !== undefined\n ? html`<button class=\"src\" @click=${this._openSource}>\n ${d.source.file}:${d.source.line}\n </button>`\n : nothing}\n <section>\n <div class=\"flags\">\n <span class=\"flag ${d.flags.hasUpdated ? 'on' : ''}\">updated</span>\n <span class=\"flag ${d.flags.isUpdatePending ? 'on' : ''}\"\n >update pending</span\n >\n <span class=\"flag ${d.flags.hasShadowRoot ? 'on' : ''}\"\n >shadow root</span\n >\n </div>\n </section>\n ${props.length > 0\n ? html`<section>\n <div class=\"label\">Properties</div>\n ${this._renderPropTable(props)}\n </section>`\n : nothing}\n ${stateProps.length > 0\n ? html`<section>\n <div class=\"label\">State</div>\n ${this._renderPropTable(stateProps)}\n </section>`\n : nothing}\n ${d.attributes.length > 0\n ? html`<section>\n <div class=\"label\">Attributes</div>\n <table>\n ${d.attributes.map(\n (a) =>\n html`<tr>\n <td class=\"name\">${a.name}</td>\n <td class=\"val\">${a.value}</td>\n </tr>`\n )}\n </table>\n </section>`\n : nothing}\n `;\n }\n\n override render() {\n return html`\n <div class=\"toolbar\">\n <button\n class=\"pick ${this._picking ? 'active' : ''}\"\n title=\"Pick an element on the page (Meta+Shift+E)\"\n @click=${this._togglePick}\n >\n ⌖ Pick\n </button>\n <span class=\"spacer\"></span>\n <button\n class=\"live ${this._live ? 'active' : ''}\"\n title=\"Update the tree automatically as the page changes\"\n @click=${this._toggleLive}\n >\n ${this._live ? '● Live' : '○ Live'}\n </button>\n <button @click=${this._refresh} ?disabled=${this._live}>Refresh</button>\n </div>\n <div class=\"body\">\n <div class=\"tree\" @mouseleave=${() => this._highlight(null)}>\n ${this._roots.length === 0\n ? html`<div class=\"empty\">\n No Lit components found on the page.\n </div>`\n : this._roots.map((n) => this._renderNode(n, 0))}\n </div>\n <div class=\"details\">${this._renderDetails()}</div>\n </div>\n `;\n }\n}\n\n/**\n * Returns the ids of every ancestor of `id` (nearest last), or `null` if `id`\n * isn't in the tree. The target id itself is not included.\n */\nconst findAncestors = (\n nodes: InspectorTreeNode[],\n id: number\n): number[] | null => {\n const trail: number[] = [];\n const walk = (list: InspectorTreeNode[]): boolean => {\n for (const node of list) {\n if (node.id === id) return true;\n trail.push(node.id);\n if (walk(node.children)) return true;\n trail.pop();\n }\n return false;\n };\n return walk(nodes) ? [...trail] : null;\n};\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'components-view': ComponentsView;\n }\n}\n"]}