@oddsquad/vite-plugin-lit 0.0.3 → 0.1.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/index.d.ts +3 -2
- package/index.d.ts.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/color-scheme.d.ts +30 -0
- package/lib/color-scheme.d.ts.map +1 -0
- package/lib/color-scheme.js +41 -0
- package/lib/color-scheme.js.map +1 -0
- package/lib/icons.d.ts +18 -0
- package/lib/icons.d.ts.map +1 -0
- package/lib/icons.js +23 -0
- package/lib/icons.js.map +1 -0
- package/lib/plugin.d.ts +117 -6
- package/lib/plugin.d.ts.map +1 -1
- package/lib/plugin.js +596 -20
- package/lib/plugin.js.map +1 -1
- package/lib/runtime/css.d.ts +94 -0
- package/lib/runtime/css.d.ts.map +1 -0
- package/lib/runtime/css.js +112 -0
- package/lib/runtime/css.js.map +1 -0
- package/lib/runtime/edge-panel.d.ts +18 -0
- package/lib/runtime/edge-panel.d.ts.map +1 -0
- package/lib/runtime/edge-panel.js +130 -0
- package/lib/runtime/edge-panel.js.map +1 -0
- package/lib/runtime/fonts.d.ts +18 -0
- package/lib/runtime/fonts.d.ts.map +1 -0
- package/lib/runtime/fonts.js +18 -0
- package/lib/runtime/fonts.js.map +1 -0
- package/lib/runtime/indicator.d.ts +7 -0
- package/lib/runtime/indicator.d.ts.map +1 -0
- package/lib/runtime/indicator.js +141 -0
- package/lib/runtime/indicator.js.map +1 -0
- package/lib/runtime/inspector/collect.d.ts +17 -0
- package/lib/runtime/inspector/collect.d.ts.map +1 -0
- package/lib/runtime/inspector/collect.js +132 -0
- package/lib/runtime/inspector/collect.js.map +1 -0
- package/lib/runtime/inspector/install.d.ts +7 -0
- package/lib/runtime/inspector/install.d.ts.map +1 -0
- package/lib/runtime/inspector/install.js +204 -0
- package/lib/runtime/inspector/install.js.map +1 -0
- package/lib/runtime/inspector/serialize.d.ts +10 -0
- package/lib/runtime/inspector/serialize.d.ts.map +1 -0
- package/lib/runtime/inspector/serialize.js +133 -0
- package/lib/runtime/inspector/serialize.js.map +1 -0
- package/lib/runtime/intern.d.ts.map +1 -1
- package/lib/runtime/intern.js +1 -1
- package/lib/runtime/intern.js.map +1 -1
- package/lib/runtime/overrides.d.ts +25 -0
- package/lib/runtime/overrides.d.ts.map +1 -0
- package/lib/runtime/overrides.js +33 -0
- package/lib/runtime/overrides.js.map +1 -0
- package/lib/runtime/patch.d.ts +6 -15
- package/lib/runtime/patch.d.ts.map +1 -1
- package/lib/runtime/patch.js +81 -28
- package/lib/runtime/patch.js.map +1 -1
- package/lib/runtime/source-meta.d.ts +16 -0
- package/lib/runtime/source-meta.d.ts.map +1 -0
- package/lib/runtime/source-meta.js +8 -0
- package/lib/runtime/source-meta.js.map +1 -0
- package/lib/runtime/source-overlay/editors.d.ts +9 -0
- package/lib/runtime/source-overlay/editors.d.ts.map +1 -0
- package/lib/runtime/source-overlay/editors.js +40 -0
- package/lib/runtime/source-overlay/editors.js.map +1 -0
- package/lib/runtime/source-overlay/mask-path.d.ts +7 -0
- package/lib/runtime/source-overlay/mask-path.d.ts.map +1 -0
- package/lib/runtime/source-overlay/mask-path.js +26 -0
- package/lib/runtime/source-overlay/mask-path.js.map +1 -0
- package/lib/runtime/source-overlay/overlay-element.d.ts +18 -0
- package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -0
- package/lib/runtime/source-overlay/overlay-element.js +381 -0
- package/lib/runtime/source-overlay/overlay-element.js.map +1 -0
- package/lib/runtime/source-overlay/source-host.d.ts +14 -0
- package/lib/runtime/source-overlay/source-host.d.ts.map +1 -0
- package/lib/runtime/source-overlay/source-host.js +94 -0
- package/lib/runtime/source-overlay/source-host.js.map +1 -0
- package/lib/runtime/source-overlay/template.d.ts +7 -0
- package/lib/runtime/source-overlay/template.d.ts.map +1 -0
- package/lib/runtime/source-overlay/template.js +125 -0
- package/lib/runtime/source-overlay/template.js.map +1 -0
- package/lib/runtime/source-overlay.d.ts +7 -0
- package/lib/runtime/source-overlay.d.ts.map +1 -0
- package/lib/runtime/source-overlay.js +11 -0
- package/lib/runtime/source-overlay.js.map +1 -0
- package/lib/runtime/timeline/clock.d.ts +10 -0
- package/lib/runtime/timeline/clock.d.ts.map +1 -0
- package/lib/runtime/timeline/clock.js +22 -0
- package/lib/runtime/timeline/clock.js.map +1 -0
- package/lib/runtime/timeline/identity.d.ts +37 -0
- package/lib/runtime/timeline/identity.d.ts.map +1 -0
- package/lib/runtime/timeline/identity.js +73 -0
- package/lib/runtime/timeline/identity.js.map +1 -0
- package/lib/runtime/timeline/input.d.ts +16 -0
- package/lib/runtime/timeline/input.d.ts.map +1 -0
- package/lib/runtime/timeline/input.js +87 -0
- package/lib/runtime/timeline/input.js.map +1 -0
- package/lib/runtime/timeline/install.d.ts +7 -0
- package/lib/runtime/timeline/install.d.ts.map +1 -0
- package/lib/runtime/timeline/install.js +69 -0
- package/lib/runtime/timeline/install.js.map +1 -0
- package/lib/runtime/timeline/lifecycle.d.ts +27 -0
- package/lib/runtime/timeline/lifecycle.d.ts.map +1 -0
- package/lib/runtime/timeline/lifecycle.js +225 -0
- package/lib/runtime/timeline/lifecycle.js.map +1 -0
- package/lib/runtime/timeline/public-api.d.ts +28 -0
- package/lib/runtime/timeline/public-api.d.ts.map +1 -0
- package/lib/runtime/timeline/public-api.js +44 -0
- package/lib/runtime/timeline/public-api.js.map +1 -0
- package/lib/runtime/timeline/render.d.ts +39 -0
- package/lib/runtime/timeline/render.d.ts.map +1 -0
- package/lib/runtime/timeline/render.js +109 -0
- package/lib/runtime/timeline/render.js.map +1 -0
- package/lib/runtime/timeline/transport.d.ts +42 -0
- package/lib/runtime/timeline/transport.d.ts.map +1 -0
- package/lib/runtime/timeline/transport.js +86 -0
- package/lib/runtime/timeline/transport.js.map +1 -0
- package/lib/segmented-tabs.d.ts +33 -0
- package/lib/segmented-tabs.d.ts.map +1 -0
- package/lib/segmented-tabs.js +129 -0
- package/lib/segmented-tabs.js.map +1 -0
- package/lib/source-meta.d.ts +26 -0
- package/lib/source-meta.d.ts.map +1 -0
- package/lib/source-meta.js +129 -0
- package/lib/source-meta.js.map +1 -0
- package/lib/timeline-plugin.d.ts +72 -0
- package/lib/timeline-plugin.d.ts.map +1 -0
- package/lib/timeline-plugin.js +376 -0
- package/lib/timeline-plugin.js.map +1 -0
- package/lib/tokens.d.ts +38 -0
- package/lib/tokens.d.ts.map +1 -0
- package/lib/tokens.js +263 -0
- package/lib/tokens.js.map +1 -0
- package/lib/transform.d.ts +5 -5
- package/lib/transform.d.ts.map +1 -1
- package/lib/transform.js +3 -3
- package/lib/transform.js.map +1 -1
- package/lib/types.d.ts +34 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +7 -0
- package/lib/types.js.map +1 -0
- package/lib/wrap-table.d.ts.map +1 -1
- package/lib/wrap-table.js.map +1 -1
- package/package.json +18 -4
- package/panel/components-view.d.ts +60 -0
- package/panel/components-view.d.ts.map +1 -0
- package/panel/components-view.js +581 -0
- package/panel/components-view.js.map +1 -0
- package/panel/devtools-settings.d.ts +41 -0
- package/panel/devtools-settings.d.ts.map +1 -0
- package/panel/devtools-settings.js +463 -0
- package/panel/devtools-settings.js.map +1 -0
- package/panel/index.html +29 -0
- package/panel/lit-devtools-panel.d.ts +37 -0
- package/panel/lit-devtools-panel.d.ts.map +1 -0
- package/panel/lit-devtools-panel.js +183 -0
- package/panel/lit-devtools-panel.js.map +1 -0
- package/panel/timeline-event-list.d.ts +43 -0
- package/panel/timeline-event-list.d.ts.map +1 -0
- package/panel/timeline-event-list.js +416 -0
- package/panel/timeline-event-list.js.map +1 -0
- package/panel/timeline-layers.d.ts +25 -0
- package/panel/timeline-layers.d.ts.map +1 -0
- package/panel/timeline-layers.js +96 -0
- package/panel/timeline-layers.js.map +1 -0
- package/panel/timeline-view.d.ts +38 -0
- package/panel/timeline-view.d.ts.map +1 -0
- package/panel/timeline-view.js +234 -0
- package/panel/timeline-view.js.map +1 -0
- package/types/inspector.d.ts +130 -0
- package/types/inspector.d.ts.map +1 -0
- package/types/inspector.js +16 -0
- package/types/inspector.js.map +1 -0
- package/types/timeline.d.ts +98 -0
- package/types/timeline.d.ts.map +1 -0
- package/types/timeline.js +39 -0
- package/types/timeline.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-meta.d.ts","sourceRoot":"","sources":["../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-meta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+DAA+D;AAC/D,eAAO,MAAM,eAAe,eAAiD,CAAC;AAE9E,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,gCAAgC,GAAG,wBAAwB,GAAG;IACxE,CAAC,eAAe,CAAC,CAAC,EAAE,aAAa,CAAC;CACnC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
/** Runtime accessor for injected component source metadata. */
|
|
7
|
+
export const SOURCE_META_KEY = Symbol.for('@lit-labs/vite-plugin-lit#source');
|
|
8
|
+
//# sourceMappingURL=source-meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-meta.js","sourceRoot":"","sources":["../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-meta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+DAA+D;AAC/D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/** Runtime accessor for injected component source metadata. */\nexport const SOURCE_META_KEY = Symbol.for('@lit-labs/vite-plugin-lit#source');\n\nexport interface LitSourceMeta {\n filePath: string;\n lineNumber: number;\n componentName?: string;\n}\n\nexport type CustomElementConstructorWithMeta = CustomElementConstructor & {\n [SOURCE_META_KEY]?: LitSourceMeta;\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
import type { EditorConfig } from '../../types.js';
|
|
7
|
+
export declare const BUILTIN_EDITORS: Record<string, EditorConfig>;
|
|
8
|
+
export declare const resolveEditor: (editor: EditorConfig | string | undefined) => EditorConfig;
|
|
9
|
+
//# sourceMappingURL=editors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editors.d.ts","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/editors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAIjD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAsBxD,CAAC;AAIF,eAAO,MAAM,aAAa,GACxB,QAAQ,YAAY,GAAG,MAAM,GAAG,SAAS,KACxC,YAMF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
// Keep the keys/labels in sync with SOURCE_OVERLAY_EDITORS in
|
|
7
|
+
// src/types/timeline.ts (the panel's editor-selection options).
|
|
8
|
+
export const BUILTIN_EDITORS = {
|
|
9
|
+
vscode: {
|
|
10
|
+
name: 'VS Code',
|
|
11
|
+
url: (path, line) => `vscode://file/${path}:${line}`,
|
|
12
|
+
},
|
|
13
|
+
cursor: {
|
|
14
|
+
name: 'Cursor',
|
|
15
|
+
url: (path, line) => `cursor://file/${path}:${line}`,
|
|
16
|
+
},
|
|
17
|
+
zed: {
|
|
18
|
+
name: 'Zed',
|
|
19
|
+
url: (path, line) => `zed://file/${path}:${line}`,
|
|
20
|
+
},
|
|
21
|
+
idea: {
|
|
22
|
+
name: 'IntelliJ',
|
|
23
|
+
url: (path, line) => `idea://open?file=${encodeURIComponent(path)}&line=${line}`,
|
|
24
|
+
},
|
|
25
|
+
windsurf: {
|
|
26
|
+
name: 'Windsurf',
|
|
27
|
+
url: (path, line) => `windsurf://file/${path}:${line}`,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
// Resolve an editor option to a config: a builtin name, a custom config, or the
|
|
31
|
+
// VS Code default (also used as the fallback for an unknown name).
|
|
32
|
+
export const resolveEditor = (editor) => {
|
|
33
|
+
if (editor === undefined)
|
|
34
|
+
return BUILTIN_EDITORS.vscode;
|
|
35
|
+
if (typeof editor === 'string') {
|
|
36
|
+
return BUILTIN_EDITORS[editor] ?? BUILTIN_EDITORS.vscode;
|
|
37
|
+
}
|
|
38
|
+
return editor;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=editors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editors.js","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/editors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,8DAA8D;AAC9D,gEAAgE;AAChE,MAAM,CAAC,MAAM,eAAe,GAAiC;IAC3D,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,iBAAiB,IAAI,IAAI,IAAI,EAAE;KACrD;IACD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,iBAAiB,IAAI,IAAI,IAAI,EAAE;KACrD;IACD,GAAG,EAAE;QACH,IAAI,EAAE,KAAK;QACX,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,cAAc,IAAI,IAAI,IAAI,EAAE;KAClD;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAClB,oBAAoB,kBAAkB,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE;KAC9D;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,mBAAmB,IAAI,IAAI,IAAI,EAAE;KACvD;CACF,CAAC;AAEF,gFAAgF;AAChF,mEAAmE;AACnE,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,MAAyC,EAC3B,EAAE;IAChB,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,eAAe,CAAC,MAAM,CAAC;IACxD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC;IAC3D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type {EditorConfig} from '../../types.js';\n\n// Keep the keys/labels in sync with SOURCE_OVERLAY_EDITORS in\n// src/types/timeline.ts (the panel's editor-selection options).\nexport const BUILTIN_EDITORS: Record<string, EditorConfig> = {\n vscode: {\n name: 'VS Code',\n url: (path, line) => `vscode://file/${path}:${line}`,\n },\n cursor: {\n name: 'Cursor',\n url: (path, line) => `cursor://file/${path}:${line}`,\n },\n zed: {\n name: 'Zed',\n url: (path, line) => `zed://file/${path}:${line}`,\n },\n idea: {\n name: 'IntelliJ',\n url: (path, line) =>\n `idea://open?file=${encodeURIComponent(path)}&line=${line}`,\n },\n windsurf: {\n name: 'Windsurf',\n url: (path, line) => `windsurf://file/${path}:${line}`,\n },\n};\n\n// Resolve an editor option to a config: a builtin name, a custom config, or the\n// VS Code default (also used as the fallback for an unknown name).\nexport const resolveEditor = (\n editor: EditorConfig | string | undefined\n): EditorConfig => {\n if (editor === undefined) return BUILTIN_EDITORS.vscode;\n if (typeof editor === 'string') {\n return BUILTIN_EDITORS[editor] ?? BUILTIN_EDITORS.vscode;\n }\n return editor;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mask-path.d.ts","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/mask-path.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,eAAO,MAAM,sBAAsB,GACjC,GAAG,MAAM,EACT,GAAG,MAAM,EACT,GAAG,MAAM,EACT,GAAG,MAAM,EACT,GAAG,MAAM,KACR,MAeF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
// Build an SVG clip-path that fills the viewport except a rounded-rect hole at
|
|
7
|
+
// (l, t, w, h) with corner radius r — the spotlight cut-out for the highlight.
|
|
8
|
+
// Outer rect (clockwise) + inner rounded rect (counterclockwise) combine under
|
|
9
|
+
// the nonzero fill rule to punch the hole.
|
|
10
|
+
export const buildSpotlightClipPath = (l, t, w, h, r) => {
|
|
11
|
+
r = Math.min(r, w / 2, h / 2);
|
|
12
|
+
const outer = `M 0 0 H 9999 V 9999 H 0 Z`;
|
|
13
|
+
const inner = [
|
|
14
|
+
`M ${l + r} ${t}`,
|
|
15
|
+
`Q ${l} ${t} ${l} ${t + r}`,
|
|
16
|
+
`L ${l} ${t + h - r}`,
|
|
17
|
+
`Q ${l} ${t + h} ${l + r} ${t + h}`,
|
|
18
|
+
`L ${l + w - r} ${t + h}`,
|
|
19
|
+
`Q ${l + w} ${t + h} ${l + w} ${t + h - r}`,
|
|
20
|
+
`L ${l + w} ${t + r}`,
|
|
21
|
+
`Q ${l + w} ${t} ${l + w - r} ${t}`,
|
|
22
|
+
`Z`,
|
|
23
|
+
].join(' ');
|
|
24
|
+
return `path('${outer} ${inner}')`;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=mask-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mask-path.js","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/mask-path.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,2CAA2C;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,CAAS,EACT,CAAS,EACT,CAAS,EACT,CAAS,EACT,CAAS,EACD,EAAE;IACV,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,2BAA2B,CAAC;IAC1C,MAAM,KAAK,GAAG;QACZ,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACjB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC3B,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACrB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACnC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACzB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAC3C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACrB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACnC,GAAG;KACJ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACZ,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,CAAC;AACrC,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n// Build an SVG clip-path that fills the viewport except a rounded-rect hole at\n// (l, t, w, h) with corner radius r — the spotlight cut-out for the highlight.\n// Outer rect (clockwise) + inner rounded rect (counterclockwise) combine under\n// the nonzero fill rule to punch the hole.\nexport const buildSpotlightClipPath = (\n l: number,\n t: number,\n w: number,\n h: number,\n r: number\n): string => {\n r = Math.min(r, w / 2, h / 2);\n const outer = `M 0 0 H 9999 V 9999 H 0 Z`;\n const inner = [\n `M ${l + r} ${t}`,\n `Q ${l} ${t} ${l} ${t + r}`,\n `L ${l} ${t + h - r}`,\n `Q ${l} ${t + h} ${l + r} ${t + h}`,\n `L ${l + w - r} ${t + h}`,\n `Q ${l + w} ${t + h} ${l + w} ${t + h - r}`,\n `L ${l + w} ${t + r}`,\n `Q ${l + w} ${t} ${l + w - r} ${t}`,\n `Z`,\n ].join(' ');\n return `path('${outer} ${inner}')`;\n};\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
import type { ElementInfo, EditorConfig } from '../../types.js';
|
|
7
|
+
export interface SourceOverlayInitOptions {
|
|
8
|
+
key?: string;
|
|
9
|
+
editor?: EditorConfig | string;
|
|
10
|
+
workspaceRoot?: string;
|
|
11
|
+
throttleMs?: number;
|
|
12
|
+
exclude?: (el: Element) => boolean;
|
|
13
|
+
onSelect?: (info: ElementInfo) => void;
|
|
14
|
+
openInEditorPath?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const initSourceOverlay: (initOptions?: SourceOverlayInitOptions) => void;
|
|
17
|
+
export declare const toggleSourceOverlay: () => void;
|
|
18
|
+
//# sourceMappingURL=overlay-element.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
import { BUILTIN_EDITORS, resolveEditor } from './editors.js';
|
|
7
|
+
import { defaultResolver, findSourceAtPoint, findSourceHost, } from './source-host.js';
|
|
8
|
+
import { buildSpotlightClipPath } from './mask-path.js';
|
|
9
|
+
import { OVERLAY_HTML } from './template.js';
|
|
10
|
+
import { observeEdgeInsets } from '../edge-panel.js';
|
|
11
|
+
import { subscribeOverride } from '../overrides.js';
|
|
12
|
+
import { injectTokens } from '../../tokens.js';
|
|
13
|
+
import { idOf } from '../timeline/identity.js';
|
|
14
|
+
import { INSPECT_OVERLAY_TOGGLE_CHANNEL, INSPECT_DATA_CHANNEL, } from '../../../types/inspector.js';
|
|
15
|
+
class LitSourceOverlay extends HTMLElement {
|
|
16
|
+
#active = false;
|
|
17
|
+
#hot;
|
|
18
|
+
#options = {};
|
|
19
|
+
#editor = BUILTIN_EDITORS.vscode;
|
|
20
|
+
#resolver = defaultResolver;
|
|
21
|
+
#dialog;
|
|
22
|
+
#mask;
|
|
23
|
+
#highlight;
|
|
24
|
+
#tooltip;
|
|
25
|
+
#tag;
|
|
26
|
+
#path;
|
|
27
|
+
#info = null;
|
|
28
|
+
#targetEl = null;
|
|
29
|
+
#throttleTimer;
|
|
30
|
+
#scrollTimer;
|
|
31
|
+
#resizeObserver;
|
|
32
|
+
#cursorStyle = null;
|
|
33
|
+
// Whether the Vite HMR WebSocket is currently connected. Used to suppress the
|
|
34
|
+
// editor-URL-scheme fallback once the dev server is gone — otherwise a failed
|
|
35
|
+
// open-in-editor fetch would navigate the tab to `vscode://…`.
|
|
36
|
+
#connected = true;
|
|
37
|
+
#lastMouseX = 0;
|
|
38
|
+
#lastMouseY = 0;
|
|
39
|
+
#edgeDispose;
|
|
40
|
+
#overrideSubscribed = false;
|
|
41
|
+
constructor() {
|
|
42
|
+
super();
|
|
43
|
+
const root = this.attachShadow({ mode: 'closed' });
|
|
44
|
+
root.innerHTML = OVERLAY_HTML;
|
|
45
|
+
this.#dialog = root.getElementById('overlay');
|
|
46
|
+
this.#mask = root.getElementById('mask');
|
|
47
|
+
this.#highlight = root.getElementById('highlight');
|
|
48
|
+
this.#tooltip = root.getElementById('tooltip');
|
|
49
|
+
this.#tag = root.getElementById('tag');
|
|
50
|
+
this.#path = root.getElementById('path');
|
|
51
|
+
root.getElementById('open').addEventListener('click', (e) => {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
if (this.#info !== null)
|
|
54
|
+
this.#select(this.#info, true);
|
|
55
|
+
});
|
|
56
|
+
root.getElementById('copy').addEventListener('click', (e) => {
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
if (this.#info === null)
|
|
59
|
+
return;
|
|
60
|
+
const text = `${this.#normalizePath(this.#info.source.filePath)}:${this.#info.source.lineNumber}`;
|
|
61
|
+
navigator.clipboard?.writeText(text);
|
|
62
|
+
});
|
|
63
|
+
this.#dialog.addEventListener('cancel', (e) => e.preventDefault());
|
|
64
|
+
}
|
|
65
|
+
connectedCallback() {
|
|
66
|
+
injectTokens();
|
|
67
|
+
document.addEventListener('mousemove', this.#onTrackMouse, true);
|
|
68
|
+
document.addEventListener('keydown', this.#onKeyDown, true);
|
|
69
|
+
const hot = import.meta.hot;
|
|
70
|
+
this.#hot = hot;
|
|
71
|
+
hot?.on('vite:beforeFullReload', () => this.deactivate());
|
|
72
|
+
hot?.on('vite:ws:disconnect', () => (this.#connected = false));
|
|
73
|
+
hot?.on('vite:ws:connect', () => (this.#connected = true));
|
|
74
|
+
// Toggle from the Vite DevTools command/shortcut (handler runs server-side).
|
|
75
|
+
hot?.on(INSPECT_OVERLAY_TOGGLE_CHANNEL, () => this.toggle());
|
|
76
|
+
// Keep the (bottom-fixed) tooltip clear of the Vite DevTools edge panel.
|
|
77
|
+
this.#edgeDispose = observeEdgeInsets((insets) => {
|
|
78
|
+
this.style.setProperty('--edge-bottom', `${insets.bottom}px`);
|
|
79
|
+
});
|
|
80
|
+
// Apply the panel's editor override live (and on load). Merge so other
|
|
81
|
+
// configured options (key, throttle, …) survive.
|
|
82
|
+
if (!this.#overrideSubscribed) {
|
|
83
|
+
this.#overrideSubscribed = true;
|
|
84
|
+
subscribeOverride(hot, (o) => {
|
|
85
|
+
if (o.sourceOverlayEditor !== undefined) {
|
|
86
|
+
this.#options = { ...this.#options, editor: o.sourceOverlayEditor };
|
|
87
|
+
this.#editor = resolveEditor(o.sourceOverlayEditor);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
disconnectedCallback() {
|
|
93
|
+
document.removeEventListener('mousemove', this.#onTrackMouse, true);
|
|
94
|
+
document.removeEventListener('keydown', this.#onKeyDown, true);
|
|
95
|
+
this.deactivate();
|
|
96
|
+
this.#edgeDispose?.();
|
|
97
|
+
this.#edgeDispose = undefined;
|
|
98
|
+
}
|
|
99
|
+
configure(options) {
|
|
100
|
+
this.#options = options;
|
|
101
|
+
this.#editor = resolveEditor(options.editor);
|
|
102
|
+
}
|
|
103
|
+
activate() {
|
|
104
|
+
if (this.#active)
|
|
105
|
+
return;
|
|
106
|
+
this.#active = true;
|
|
107
|
+
this.#dialog.showModal();
|
|
108
|
+
this.#mask.style.background = 'rgba(0,0,0,0.35)';
|
|
109
|
+
// The overlay is pointer-events:none, so the cursor reflects the hovered
|
|
110
|
+
// page element. Force a crosshair while inspecting. The closed shadow DOM
|
|
111
|
+
// tooltip is unaffected, so its buttons keep their own pointer cursor.
|
|
112
|
+
if (this.#cursorStyle === null) {
|
|
113
|
+
this.#cursorStyle = document.createElement('style');
|
|
114
|
+
this.#cursorStyle.textContent = '*{cursor:crosshair !important}';
|
|
115
|
+
}
|
|
116
|
+
document.head.append(this.#cursorStyle);
|
|
117
|
+
document.addEventListener('mousemove', this.#onMouseMove, true);
|
|
118
|
+
document.addEventListener('click', this.#onClick, true);
|
|
119
|
+
window.addEventListener('scroll', this.#onScrollOrResize, { passive: true });
|
|
120
|
+
window.addEventListener('resize', this.#onScrollOrResize, { passive: true });
|
|
121
|
+
this.#resolveAt(this.#lastMouseX, this.#lastMouseY);
|
|
122
|
+
}
|
|
123
|
+
deactivate() {
|
|
124
|
+
if (!this.#active)
|
|
125
|
+
return;
|
|
126
|
+
this.#active = false;
|
|
127
|
+
this.#dialog.close();
|
|
128
|
+
this.#mask.style.background = 'rgba(0,0,0,0)';
|
|
129
|
+
this.#cursorStyle?.remove();
|
|
130
|
+
document.removeEventListener('mousemove', this.#onMouseMove, true);
|
|
131
|
+
document.removeEventListener('click', this.#onClick, true);
|
|
132
|
+
window.removeEventListener('scroll', this.#onScrollOrResize);
|
|
133
|
+
window.removeEventListener('resize', this.#onScrollOrResize);
|
|
134
|
+
if (this.#throttleTimer !== undefined) {
|
|
135
|
+
clearTimeout(this.#throttleTimer);
|
|
136
|
+
this.#throttleTimer = undefined;
|
|
137
|
+
}
|
|
138
|
+
if (this.#scrollTimer !== undefined) {
|
|
139
|
+
clearTimeout(this.#scrollTimer);
|
|
140
|
+
this.#scrollTimer = undefined;
|
|
141
|
+
}
|
|
142
|
+
this.#clearTarget();
|
|
143
|
+
}
|
|
144
|
+
toggle() {
|
|
145
|
+
if (this.#active)
|
|
146
|
+
this.deactivate();
|
|
147
|
+
else
|
|
148
|
+
this.activate();
|
|
149
|
+
}
|
|
150
|
+
#normalizePath(filePath) {
|
|
151
|
+
const root = this.#options.workspaceRoot;
|
|
152
|
+
if (root !== undefined && filePath.startsWith(root)) {
|
|
153
|
+
const rest = filePath.slice(root.length);
|
|
154
|
+
return rest.startsWith('/') ? rest.slice(1) : rest;
|
|
155
|
+
}
|
|
156
|
+
return filePath;
|
|
157
|
+
}
|
|
158
|
+
async #openInEditor(filePath, lineNumber) {
|
|
159
|
+
const path = this.#normalizePath(filePath);
|
|
160
|
+
const endpoint = this.#options.openInEditorPath ?? '/__lit-open-in-editor';
|
|
161
|
+
try {
|
|
162
|
+
const params = new URLSearchParams({
|
|
163
|
+
file: path,
|
|
164
|
+
line: String(lineNumber),
|
|
165
|
+
});
|
|
166
|
+
const res = await fetch(`${endpoint}?${params.toString()}`);
|
|
167
|
+
if (res.ok)
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// Fall back to editor URL schemes (e.g. StackBlitz previews).
|
|
172
|
+
}
|
|
173
|
+
// Skip the URL-scheme fallback when the dev server is gone: a fetch failure
|
|
174
|
+
// there means "server quit", not "no endpoint", and navigating the tab to
|
|
175
|
+
// `vscode://…` on shutdown is jarring and unwanted.
|
|
176
|
+
if (!this.#connected)
|
|
177
|
+
return;
|
|
178
|
+
window.open(this.#editor.url(path, lineNumber), '_self');
|
|
179
|
+
}
|
|
180
|
+
#updateHighlightRect() {
|
|
181
|
+
if (this.#targetEl === null)
|
|
182
|
+
return;
|
|
183
|
+
const rect = this.#targetEl.getBoundingClientRect();
|
|
184
|
+
const raw = getComputedStyle(this)
|
|
185
|
+
.getPropertyValue('--lit-devtools-radius')
|
|
186
|
+
.trim();
|
|
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`;
|
|
192
|
+
this.#mask.style.clipPath = buildSpotlightClipPath(rect.left - r, rect.top - r, rect.width + 2 * r, rect.height + 2 * r, r);
|
|
193
|
+
}
|
|
194
|
+
#showTooltip() {
|
|
195
|
+
if (this.#info === null)
|
|
196
|
+
return;
|
|
197
|
+
this.#tag.textContent = `<${this.#info.tagName}>`;
|
|
198
|
+
this.#path.textContent = `${this.#normalizePath(this.#info.source.filePath)}:${this.#info.source.lineNumber}`;
|
|
199
|
+
this.#tooltip.style.display = 'flex';
|
|
200
|
+
}
|
|
201
|
+
#clearTarget() {
|
|
202
|
+
this.#targetEl = null;
|
|
203
|
+
this.#info = null;
|
|
204
|
+
this.#highlight.style.left = '0';
|
|
205
|
+
this.#highlight.style.top = '0';
|
|
206
|
+
this.#highlight.style.width = '0';
|
|
207
|
+
this.#highlight.style.height = '0';
|
|
208
|
+
this.#mask.style.clipPath = 'none';
|
|
209
|
+
this.#tooltip.style.display = 'none';
|
|
210
|
+
if (this.#resizeObserver !== undefined) {
|
|
211
|
+
this.#resizeObserver.disconnect();
|
|
212
|
+
this.#resizeObserver = undefined;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
#shouldSkip(el) {
|
|
216
|
+
if (el === this.#dialog || this.#dialog.contains(el))
|
|
217
|
+
return true;
|
|
218
|
+
if (el.tagName === 'IFRAME')
|
|
219
|
+
return true;
|
|
220
|
+
// Never target devtools' own injected elements (indicator, overlay).
|
|
221
|
+
const tag = el.tagName.toLowerCase();
|
|
222
|
+
if (tag === 'lit-source-overlay' || tag.startsWith('lit-devtools-')) {
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
const exclude = this.#options.exclude;
|
|
226
|
+
return exclude !== undefined && exclude(el);
|
|
227
|
+
}
|
|
228
|
+
async #resolveAt(x, y) {
|
|
229
|
+
this.#lastMouseX = x;
|
|
230
|
+
this.#lastMouseY = y;
|
|
231
|
+
const el = findSourceAtPoint(x, y, this.#dialog);
|
|
232
|
+
if (el === null || this.#shouldSkip(el)) {
|
|
233
|
+
this.#clearTarget();
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const host = findSourceHost(el);
|
|
237
|
+
if (host === null) {
|
|
238
|
+
this.#clearTarget();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (host === this.#targetEl && this.#info !== null) {
|
|
242
|
+
this.#updateHighlightRect();
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
this.#targetEl = host;
|
|
246
|
+
if (this.#resizeObserver === undefined) {
|
|
247
|
+
this.#resizeObserver = new ResizeObserver(() => this.#updateHighlightRect());
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this.#resizeObserver.disconnect();
|
|
251
|
+
}
|
|
252
|
+
this.#resizeObserver.observe(host);
|
|
253
|
+
const resolved = await this.#resolver.resolveElementInfo(el);
|
|
254
|
+
if (resolved === null) {
|
|
255
|
+
this.#clearTarget();
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
this.#info = resolved;
|
|
259
|
+
this.#updateHighlightRect();
|
|
260
|
+
this.#showTooltip();
|
|
261
|
+
}
|
|
262
|
+
#onTrackMouse = (event) => {
|
|
263
|
+
this.#lastMouseX = event.clientX;
|
|
264
|
+
this.#lastMouseY = event.clientY;
|
|
265
|
+
};
|
|
266
|
+
#onKeyDown = (event) => {
|
|
267
|
+
if ((event.metaKey || event.ctrlKey) && event.shiftKey && !event.altKey) {
|
|
268
|
+
const pressed = event.key.toLowerCase();
|
|
269
|
+
const hotkey = (this.#options.key ?? 'e').toLowerCase();
|
|
270
|
+
if (pressed === hotkey) {
|
|
271
|
+
event.preventDefault();
|
|
272
|
+
this.toggle();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (this.#active && event.key === 'Escape') {
|
|
276
|
+
event.preventDefault();
|
|
277
|
+
event.stopPropagation();
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
#onMouseMove = (event) => {
|
|
281
|
+
if (!this.#active)
|
|
282
|
+
return;
|
|
283
|
+
// Keep the current selection while hovering the tooltip so its buttons stay
|
|
284
|
+
// clickable — the tooltip isn't a source element, so re-resolving here would
|
|
285
|
+
// clear the target and hide the panel out from under the pointer.
|
|
286
|
+
if (this.#pointInTooltip(event.clientX, event.clientY))
|
|
287
|
+
return;
|
|
288
|
+
const throttleMs = this.#options.throttleMs ?? 50;
|
|
289
|
+
if (this.#throttleTimer !== undefined)
|
|
290
|
+
return;
|
|
291
|
+
this.#throttleTimer = setTimeout(() => {
|
|
292
|
+
this.#throttleTimer = undefined;
|
|
293
|
+
// Resolve against the latest pointer position (kept current by
|
|
294
|
+
// #onTrackMouse), not the coords captured when this timer was scheduled
|
|
295
|
+
// ~throttleMs ago — otherwise the highlight lags the cursor during
|
|
296
|
+
// continuous movement.
|
|
297
|
+
const x = this.#lastMouseX;
|
|
298
|
+
const y = this.#lastMouseY;
|
|
299
|
+
if (this.#pointInTooltip(x, y))
|
|
300
|
+
return;
|
|
301
|
+
this.#resolveAt(x, y);
|
|
302
|
+
}, throttleMs);
|
|
303
|
+
};
|
|
304
|
+
#select(info, openInEditor = false) {
|
|
305
|
+
const target = this.#targetEl;
|
|
306
|
+
// Cancel the whole selection mode on any deliberate pick, before acting —
|
|
307
|
+
// the editor may open via a URL scheme that doesn't navigate this tab away,
|
|
308
|
+
// so we can't rely on the open outcome to dismiss the inspector.
|
|
309
|
+
this.deactivate();
|
|
310
|
+
this.#options.onSelect?.(info);
|
|
311
|
+
if (openInEditor) {
|
|
312
|
+
this.#openInEditor(info.source.filePath, info.source.lineNumber);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
// Report the picked element to the DevTools panel, which selects it in the
|
|
316
|
+
// Components tree. Identity matches the inspector runtime via idOf().
|
|
317
|
+
if (target !== null) {
|
|
318
|
+
this.#hot?.send(INSPECT_DATA_CHANNEL, { type: 'pick', id: idOf(target) });
|
|
319
|
+
this.#openDevtoolsPanel();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Bring the Lit DevTools dock entry to the front so a pick is visible even
|
|
324
|
+
* when the panel was closed. The panel mirrors this from its own
|
|
325
|
+
* `inspector-activate` handler, but only once its iframe is mounted — and the
|
|
326
|
+
* @vitejs/devtools shell does not mount that iframe until the entry has been
|
|
327
|
+
* opened at least once. This overlay always runs on the page, so calling
|
|
328
|
+
* `switchEntry` here covers the cold-start case where no panel exists yet to
|
|
329
|
+
* receive the `pick` message.
|
|
330
|
+
*/
|
|
331
|
+
#openDevtoolsPanel() {
|
|
332
|
+
try {
|
|
333
|
+
const ctx = window.__VITE_DEVTOOLS_CLIENT_CONTEXT__;
|
|
334
|
+
ctx?.docks?.switchEntry?.('lit-devtools');
|
|
335
|
+
}
|
|
336
|
+
catch {
|
|
337
|
+
// Not running inside the DevTools shell — ignore.
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
#pointInTooltip(x, y) {
|
|
341
|
+
if (this.#tooltip.style.display === 'none')
|
|
342
|
+
return false;
|
|
343
|
+
const r = this.#tooltip.getBoundingClientRect();
|
|
344
|
+
return x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;
|
|
345
|
+
}
|
|
346
|
+
#onClick = (event) => {
|
|
347
|
+
if (!this.#active || this.#info === null)
|
|
348
|
+
return;
|
|
349
|
+
// Clicks on the tooltip panel are handled by its own buttons (open/copy).
|
|
350
|
+
// The overlay's shadow root is closed, so we detect this by hit-rect rather
|
|
351
|
+
// than inspecting the event path, and let the event reach those buttons.
|
|
352
|
+
if (this.#pointInTooltip(event.clientX, event.clientY))
|
|
353
|
+
return;
|
|
354
|
+
event.preventDefault();
|
|
355
|
+
event.stopPropagation();
|
|
356
|
+
this.#select(this.#info, event.metaKey || event.ctrlKey);
|
|
357
|
+
};
|
|
358
|
+
#onScrollOrResize = () => {
|
|
359
|
+
if (this.#scrollTimer !== undefined)
|
|
360
|
+
clearTimeout(this.#scrollTimer);
|
|
361
|
+
this.#scrollTimer = setTimeout(() => {
|
|
362
|
+
this.#scrollTimer = undefined;
|
|
363
|
+
if (this.#targetEl !== null) {
|
|
364
|
+
this.#updateHighlightRect();
|
|
365
|
+
}
|
|
366
|
+
}, 50);
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
customElements.define('lit-source-overlay', LitSourceOverlay);
|
|
370
|
+
export const initSourceOverlay = (initOptions = {}) => {
|
|
371
|
+
if (typeof window === 'undefined')
|
|
372
|
+
return;
|
|
373
|
+
const el = document.createElement('lit-source-overlay');
|
|
374
|
+
el.configure(initOptions);
|
|
375
|
+
document.body.append(el);
|
|
376
|
+
};
|
|
377
|
+
export const toggleSourceOverlay = () => {
|
|
378
|
+
const el = document.querySelector('lit-source-overlay');
|
|
379
|
+
el?.toggle();
|
|
380
|
+
};
|
|
381
|
+
//# sourceMappingURL=overlay-element.js.map
|
|
@@ -0,0 +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,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,KAAK,CAAc;IACnB,UAAU,CAAc;IACxB,QAAQ,CAAc;IACtB,IAAI,CAAc;IAClB,KAAK,CAAc;IACnB,KAAK,GAAuB,IAAI,CAAC;IACjC,SAAS,GAAmB,IAAI,CAAC;IACjC,cAAc,CAA4C;IAC1D,YAAY,CAA4C;IACxD,eAAe,CAA6B;IAC5C,YAAY,GAA4B,IAAI,CAAC;IAC7C,8EAA8E;IAC9E,8EAA8E;IAC9E,+DAA+D;IAC/D,UAAU,GAAG,IAAI,CAAC;IAClB,WAAW,GAAG,CAAC,CAAC;IAChB,WAAW,GAAG,CAAC,CAAC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E,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"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
import type { ElementInfo } from '../../types.js';
|
|
7
|
+
export interface ElementResolver {
|
|
8
|
+
resolveElementInfo(el: Element): Promise<ElementInfo | null>;
|
|
9
|
+
}
|
|
10
|
+
export declare const findSourceHost: (el: Element) => Element | null;
|
|
11
|
+
export declare const deepElementFromPoint: (x: number, y: number) => Element | null;
|
|
12
|
+
export declare const findSourceAtPoint: (x: number, y: number, dialog?: HTMLDialogElement | null) => Element | null;
|
|
13
|
+
export declare const defaultResolver: ElementResolver;
|
|
14
|
+
//# sourceMappingURL=source-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-host.d.ts","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/source-overlay/source-host.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,kBAAkB,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CAC9D;AAID,eAAO,MAAM,cAAc,GAAI,IAAI,OAAO,KAAG,OAAO,GAAG,IAiBtD,CAAC;AAKF,eAAO,MAAM,oBAAoB,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,OAAO,GAAG,IAUrE,CAAC;AAIF,eAAO,MAAM,iBAAiB,GAC5B,GAAG,MAAM,EACT,GAAG,MAAM,EACT,SAAQ,iBAAiB,GAAG,IAAW,KACtC,OAAO,GAAG,IA+BZ,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,eAkB7B,CAAC"}
|