@oddsquad/vite-plugin-lit 0.2.2 → 0.3.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/CHANGELOG.md +64 -0
- package/LICENSE +28 -0
- package/README.md +153 -0
- package/bin.mjs +154 -0
- package/client.d.ts +61 -0
- package/dist/client/assets/browser-agent-rpc-BXhoSh1z-BvWe4sTJ.js +69 -0
- package/dist/client/assets/browser-agent-rpc-BXhoSh1z-BvWe4sTJ.js.map +1 -0
- package/dist/client/assets/index-CFrVgNfS.js +9740 -0
- package/dist/client/assets/index-CFrVgNfS.js.map +1 -0
- package/{panel → dist/client}/index.html +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/lib/color-scheme.d.ts.map +1 -1
- package/lib/color-scheme.js +17 -21
- package/lib/color-scheme.js.map +1 -1
- package/lib/devframe/definition.d.ts +45 -0
- package/lib/devframe/definition.d.ts.map +1 -0
- package/lib/devframe/definition.js +547 -0
- package/lib/devframe/definition.js.map +1 -0
- package/lib/devframe/icon.d.ts +8 -0
- package/lib/devframe/icon.d.ts.map +1 -0
- package/lib/devframe/icon.js +21 -0
- package/lib/devframe/icon.js.map +1 -0
- package/lib/devframe/paths.d.ts +12 -0
- package/lib/devframe/paths.d.ts.map +1 -0
- package/lib/devframe/paths.js +38 -0
- package/lib/devframe/paths.js.map +1 -0
- package/lib/devframe/protocol.d.ts +218 -0
- package/lib/devframe/protocol.d.ts.map +1 -0
- package/lib/devframe/protocol.js +76 -0
- package/lib/devframe/protocol.js.map +1 -0
- package/lib/devframe/source.d.ts +49 -0
- package/lib/devframe/source.d.ts.map +1 -0
- package/lib/devframe/source.js +23 -0
- package/lib/devframe/source.js.map +1 -0
- package/lib/devframe/vite.d.ts +116 -0
- package/lib/devframe/vite.d.ts.map +1 -0
- package/lib/devframe/vite.js +291 -0
- package/lib/devframe/vite.js.map +1 -0
- package/lib/http.d.ts +29 -0
- package/lib/http.d.ts.map +1 -0
- package/lib/http.js +35 -0
- package/lib/http.js.map +1 -0
- package/lib/icons.d.ts +2 -0
- package/lib/icons.d.ts.map +1 -1
- package/lib/icons.js +10 -4
- package/lib/icons.js.map +1 -1
- package/lib/plugin.d.ts +15 -4
- package/lib/plugin.d.ts.map +1 -1
- package/lib/plugin.js +640 -574
- package/lib/plugin.js.map +1 -1
- package/lib/runtime/css.d.ts +2 -16
- package/lib/runtime/css.d.ts.map +1 -1
- package/lib/runtime/css.js +43 -36
- package/lib/runtime/css.js.map +1 -1
- package/lib/runtime/edge-panel.d.ts.map +1 -1
- package/lib/runtime/edge-panel.js +82 -91
- package/lib/runtime/edge-panel.js.map +1 -1
- package/lib/runtime/fonts.d.ts.map +1 -1
- package/lib/runtime/fonts.js +1 -1
- package/lib/runtime/fonts.js.map +1 -1
- package/lib/runtime/indicator.d.ts.map +1 -1
- package/lib/runtime/indicator.js +71 -74
- package/lib/runtime/indicator.js.map +1 -1
- package/lib/runtime/inspector/collect.d.ts.map +1 -1
- package/lib/runtime/inspector/collect.js +83 -90
- package/lib/runtime/inspector/collect.js.map +1 -1
- package/lib/runtime/inspector/highlight.d.ts +16 -0
- package/lib/runtime/inspector/highlight.d.ts.map +1 -0
- package/lib/runtime/inspector/highlight.js +66 -0
- package/lib/runtime/inspector/highlight.js.map +1 -0
- package/lib/runtime/inspector/install.d.ts.map +1 -1
- package/lib/runtime/inspector/install.js +180 -205
- package/lib/runtime/inspector/install.js.map +1 -1
- package/lib/runtime/inspector/serialize.d.ts.map +1 -1
- package/lib/runtime/inspector/serialize.js +86 -107
- package/lib/runtime/inspector/serialize.js.map +1 -1
- package/lib/runtime/intern.d.ts.map +1 -1
- package/lib/runtime/intern.js +31 -29
- package/lib/runtime/intern.js.map +1 -1
- package/lib/runtime/overrides.d.ts.map +1 -1
- package/lib/runtime/overrides.js +14 -13
- package/lib/runtime/overrides.js.map +1 -1
- package/lib/runtime/patch.d.ts +8 -0
- package/lib/runtime/patch.d.ts.map +1 -1
- package/lib/runtime/patch.js +321 -282
- package/lib/runtime/patch.js.map +1 -1
- package/lib/runtime/source-meta.d.ts.map +1 -1
- package/lib/runtime/source-meta.js +1 -1
- package/lib/runtime/source-meta.js.map +1 -1
- package/lib/runtime/source-overlay/editors.d.ts.map +1 -1
- package/lib/runtime/source-overlay/editors.js +27 -27
- package/lib/runtime/source-overlay/editors.js.map +1 -1
- package/lib/runtime/source-overlay/mask-path.d.ts.map +1 -1
- package/lib/runtime/source-overlay/mask-path.js +15 -15
- package/lib/runtime/source-overlay/mask-path.js.map +1 -1
- package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -1
- package/lib/runtime/source-overlay/overlay-element.js +347 -356
- package/lib/runtime/source-overlay/overlay-element.js.map +1 -1
- package/lib/runtime/source-overlay/source-host.d.ts.map +1 -1
- package/lib/runtime/source-overlay/source-host.js +64 -71
- package/lib/runtime/source-overlay/source-host.js.map +1 -1
- package/lib/runtime/source-overlay/template.d.ts.map +1 -1
- package/lib/runtime/source-overlay/template.js +3 -3
- package/lib/runtime/source-overlay/template.js.map +1 -1
- package/lib/runtime/source-overlay.d.ts.map +1 -1
- package/lib/runtime/source-overlay.js +5 -2
- package/lib/runtime/source-overlay.js.map +1 -1
- package/lib/runtime/timeline/clock.d.ts.map +1 -1
- package/lib/runtime/timeline/clock.js +2 -2
- package/lib/runtime/timeline/clock.js.map +1 -1
- package/lib/runtime/timeline/flash.d.ts +39 -0
- package/lib/runtime/timeline/flash.d.ts.map +1 -0
- package/lib/runtime/timeline/flash.js +169 -0
- package/lib/runtime/timeline/flash.js.map +1 -0
- package/lib/runtime/timeline/identity.d.ts.map +1 -1
- package/lib/runtime/timeline/identity.js +27 -27
- package/lib/runtime/timeline/identity.js.map +1 -1
- package/lib/runtime/timeline/input.d.ts.map +1 -1
- package/lib/runtime/timeline/input.js +54 -67
- package/lib/runtime/timeline/input.js.map +1 -1
- package/lib/runtime/timeline/install.d.ts.map +1 -1
- package/lib/runtime/timeline/install.js +38 -29
- package/lib/runtime/timeline/install.js.map +1 -1
- package/lib/runtime/timeline/lifecycle.d.ts +8 -0
- package/lib/runtime/timeline/lifecycle.d.ts.map +1 -1
- package/lib/runtime/timeline/lifecycle.js +149 -133
- package/lib/runtime/timeline/lifecycle.js.map +1 -1
- package/lib/runtime/timeline/public-api.d.ts.map +1 -1
- package/lib/runtime/timeline/public-api.js +9 -9
- package/lib/runtime/timeline/public-api.js.map +1 -1
- package/lib/runtime/timeline/render.d.ts.map +1 -1
- package/lib/runtime/timeline/render.js +70 -75
- package/lib/runtime/timeline/render.js.map +1 -1
- package/lib/runtime/timeline/transport.d.ts.map +1 -1
- package/lib/runtime/timeline/transport.js +39 -43
- package/lib/runtime/timeline/transport.js.map +1 -1
- package/lib/segmented-tabs.d.ts +3 -1
- package/lib/segmented-tabs.d.ts.map +1 -1
- package/lib/segmented-tabs.js +136 -107
- package/lib/segmented-tabs.js.map +1 -1
- package/lib/snapshot.d.ts +28 -0
- package/lib/snapshot.d.ts.map +1 -0
- package/lib/snapshot.js +57 -0
- package/lib/snapshot.js.map +1 -0
- package/lib/source-meta.d.ts.map +1 -1
- package/lib/source-meta.js +176 -162
- package/lib/source-meta.js.map +1 -1
- package/lib/timeline/derive.d.ts +152 -0
- package/lib/timeline/derive.d.ts.map +1 -0
- package/lib/timeline/derive.js +242 -0
- package/lib/timeline/derive.js.map +1 -0
- package/lib/timeline-plugin.d.ts.map +1 -1
- package/lib/timeline-plugin.js +304 -321
- package/lib/timeline-plugin.js.map +1 -1
- package/lib/tokens.d.ts.map +1 -1
- package/lib/tokens.js +17 -18
- package/lib/tokens.js.map +1 -1
- package/lib/transform.d.ts.map +1 -1
- package/lib/transform.js +62 -57
- package/lib/transform.js.map +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/wrap-table.d.ts.map +1 -1
- package/lib/wrap-table.js +19 -17
- package/lib/wrap-table.js.map +1 -1
- package/package.json +77 -13
- package/types/hmr-incompatibility.d.ts +59 -0
- package/types/hmr-incompatibility.d.ts.map +1 -0
- package/types/hmr-incompatibility.js +30 -0
- package/types/hmr-incompatibility.js.map +1 -0
- package/types/in-page.d.ts +49 -0
- package/types/in-page.d.ts.map +1 -0
- package/types/in-page.js +33 -0
- package/types/in-page.js.map +1 -0
- package/types/inspector.d.ts.map +1 -1
- package/types/inspector.js.map +1 -1
- package/types/snapshot.d.ts +44 -0
- package/types/snapshot.d.ts.map +1 -0
- package/types/snapshot.js +7 -0
- package/types/snapshot.js.map +1 -0
- package/types/timeline.d.ts +11 -0
- package/types/timeline.d.ts.map +1 -1
- package/types/timeline.js.map +1 -1
- package/panel/components-view.d.ts +0 -60
- package/panel/components-view.d.ts.map +0 -1
- package/panel/components-view.js +0 -587
- package/panel/components-view.js.map +0 -1
- package/panel/devtools-settings.d.ts +0 -41
- package/panel/devtools-settings.d.ts.map +0 -1
- package/panel/devtools-settings.js +0 -463
- package/panel/devtools-settings.js.map +0 -1
- package/panel/lit-devtools-panel.d.ts +0 -37
- package/panel/lit-devtools-panel.d.ts.map +0 -1
- package/panel/lit-devtools-panel.js +0 -185
- package/panel/lit-devtools-panel.js.map +0 -1
- package/panel/timeline-event-list.d.ts +0 -43
- package/panel/timeline-event-list.d.ts.map +0 -1
- package/panel/timeline-event-list.js +0 -416
- package/panel/timeline-event-list.js.map +0 -1
- package/panel/timeline-layers.d.ts +0 -25
- package/panel/timeline-layers.d.ts.map +0 -1
- package/panel/timeline-layers.js +0 -96
- package/panel/timeline-layers.js.map +0 -1
- package/panel/timeline-view.d.ts +0 -38
- package/panel/timeline-view.d.ts.map +0 -1
- package/panel/timeline-view.js +0 -234
- package/panel/timeline-view.js.map +0 -1
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
* element's reactive state for the inspector panel. Runs entirely in the page;
|
|
9
9
|
* the results are sent over the transport as plain JSON.
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import {idOf} from '../timeline/identity.js';
|
|
12
|
+
import {serialize, typeTag} from './serialize.js';
|
|
13
13
|
const SOURCE_META_KEY = Symbol.for('@lit-labs/vite-plugin-lit#source');
|
|
14
14
|
const metaOf = (el) => el.constructor[SOURCE_META_KEY];
|
|
15
15
|
const sourceOf = (el) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const meta = metaOf(el);
|
|
17
|
+
return meta === undefined
|
|
18
|
+
? undefined
|
|
19
|
+
: {file: meta.filePath, line: meta.lineNumber};
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
22
|
* An element worth showing in the tree: an upgraded custom element that
|
|
@@ -24,25 +24,25 @@ const sourceOf = (el) => {
|
|
|
24
24
|
* the source-meta transform touched them, while skipping devtools' own UI.
|
|
25
25
|
*/
|
|
26
26
|
export const isInspectable = (el) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return typeof el.requestUpdate === 'function';
|
|
27
|
+
const tag = el.tagName.toLowerCase();
|
|
28
|
+
if (!tag.includes('-')) return false;
|
|
29
|
+
if (tag === 'lit-source-overlay' || tag.startsWith('lit-devtools-')) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return typeof el.requestUpdate === 'function';
|
|
34
33
|
};
|
|
35
34
|
const nodeFor = (el, children) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
const meta = metaOf(el);
|
|
36
|
+
return {
|
|
37
|
+
id: idOf(el),
|
|
38
|
+
tagName: el.tagName.toLowerCase(),
|
|
39
|
+
componentName: meta?.componentName,
|
|
40
|
+
source:
|
|
41
|
+
meta === undefined
|
|
42
|
+
? undefined
|
|
43
|
+
: {file: meta.filePath, line: meta.lineNumber},
|
|
44
|
+
children,
|
|
45
|
+
};
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
48
|
* Visits `el`: if it's inspectable it becomes a node whose children are the
|
|
@@ -51,82 +51,75 @@ const nodeFor = (el, children) => {
|
|
|
51
51
|
* are flattened away).
|
|
52
52
|
*/
|
|
53
53
|
const visit = (el, sink) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
54
|
+
if (isInspectable(el)) {
|
|
55
|
+
const children = [];
|
|
56
|
+
descend(el, children);
|
|
57
|
+
sink.push(nodeFor(el, children));
|
|
58
|
+
} else {
|
|
59
|
+
descend(el, sink);
|
|
60
|
+
}
|
|
62
61
|
};
|
|
63
62
|
const descend = (el, sink) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
for (const child of el.children)
|
|
70
|
-
visit(child, sink);
|
|
63
|
+
const shadow = el.shadowRoot;
|
|
64
|
+
if (shadow !== null) {
|
|
65
|
+
for (const child of shadow.children) visit(child, sink);
|
|
66
|
+
}
|
|
67
|
+
for (const child of el.children) visit(child, sink);
|
|
71
68
|
};
|
|
72
69
|
/** Build the full component render tree rooted at the document body. */
|
|
73
70
|
export const buildTree = () => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return roots;
|
|
71
|
+
const roots = [];
|
|
72
|
+
for (const child of document.body.children) visit(child, roots);
|
|
73
|
+
return roots;
|
|
78
74
|
};
|
|
79
75
|
const attributeName = (key, decl) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return decl.attribute;
|
|
84
|
-
return String(key).toLowerCase();
|
|
76
|
+
if (decl.attribute === false) return false;
|
|
77
|
+
if (typeof decl.attribute === 'string') return decl.attribute;
|
|
78
|
+
return String(key).toLowerCase();
|
|
85
79
|
};
|
|
86
80
|
/** Snapshot one element's reactive properties, attributes, and flags. */
|
|
87
81
|
export const collectDetails = (el) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
111
|
-
}
|
|
82
|
+
const re = el;
|
|
83
|
+
const declarations = re.constructor.elementProperties;
|
|
84
|
+
const properties = [];
|
|
85
|
+
if (declarations !== undefined) {
|
|
86
|
+
for (const [key, decl] of declarations) {
|
|
87
|
+
// Reading a reactive property runs its accessor, which may throw; one bad
|
|
88
|
+
// getter must not take out the whole details snapshot.
|
|
89
|
+
let value;
|
|
90
|
+
let threw = false;
|
|
91
|
+
try {
|
|
92
|
+
value = el[key];
|
|
93
|
+
} catch {
|
|
94
|
+
threw = true;
|
|
95
|
+
}
|
|
96
|
+
properties.push({
|
|
97
|
+
name: typeof key === 'symbol' ? key.toString() : String(key),
|
|
98
|
+
value: threw ? '[getter threw]' : serialize(value),
|
|
99
|
+
type: threw ? 'error' : typeTag(value),
|
|
100
|
+
attribute: attributeName(key, decl),
|
|
101
|
+
reflects: decl.reflect === true,
|
|
102
|
+
state: decl.state === true,
|
|
103
|
+
});
|
|
112
104
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
105
|
+
}
|
|
106
|
+
const attributes = Array.from(el.attributes, (a) => ({
|
|
107
|
+
name: a.name,
|
|
108
|
+
value: a.value,
|
|
109
|
+
}));
|
|
110
|
+
const meta = metaOf(el);
|
|
111
|
+
return {
|
|
112
|
+
id: idOf(el),
|
|
113
|
+
tagName: el.tagName.toLowerCase(),
|
|
114
|
+
componentName: meta?.componentName,
|
|
115
|
+
source: sourceOf(el),
|
|
116
|
+
attributes,
|
|
117
|
+
properties,
|
|
118
|
+
flags: {
|
|
119
|
+
hasUpdated: re.hasUpdated === true,
|
|
120
|
+
isUpdatePending: re.isUpdatePending === true,
|
|
121
|
+
hasShadowRoot: el.shadowRoot !== null,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
131
124
|
};
|
|
132
|
-
//# sourceMappingURL=collect.js.map
|
|
125
|
+
//# sourceMappingURL=collect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"collect.js","sourceRoot":"","sources":["../../../src/lib/runtime/inspector/collect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,yBAAyB,CAAC;AAC7C,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAQlD,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AA0BvE,MAAM,MAAM,GAAG,CAAC,EAAW,EAA6B,EAAE,CACvD,EAA0B,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;AAE3D,MAAM,QAAQ,GAAG,CAAC,EAAW,EAA6B,EAAE;IAC1D,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IACxB,OAAO,IAAI,KAAK,SAAS;QACvB,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,EAAC,CAAC;AACnD,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG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;QACV,UAAU;QACV,KAAK,EAAE;YACL,UAAU,EAAE,EAAE,CAAC,UAAU,KAAK,IAAI;YAClC,eAAe,EAAE,EAAE,CAAC,eAAe,KAAK,IAAI;YAC5C,aAAa,EAAE,EAAE,CAAC,UAAU,KAAK,IAAI;SACtC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Walks the page to build the component render tree and to snapshot a single\n * element's reactive state for the inspector panel. Runs entirely in the page;\n * the results are sent over the transport as plain JSON.\n */\n\nimport {idOf} from '../timeline/identity.js';\nimport {serialize, typeTag} from './serialize.js';\nimport type {\n ElementSource,\n InspectorDetails,\n InspectorProp,\n InspectorTreeNode,\n} from '../../../types/inspector.js';\n\nconst SOURCE_META_KEY = Symbol.for('@lit-labs/vite-plugin-lit#source');\n\ninterface LitSourceMeta {\n filePath: string;\n lineNumber: number;\n componentName: string;\n}\n\n/** Subset of ReactiveElement's `PropertyDeclaration` we read. */\ninterface PropertyDeclaration {\n attribute?: boolean | string;\n reflect?: boolean;\n state?: boolean;\n}\n\n/** Subset of a ReactiveElement instance/constructor we duck-type against. */\ninterface ReactiveElementLike extends Element {\n requestUpdate?: unknown;\n hasUpdated?: boolean;\n isUpdatePending?: boolean;\n constructor: {\n elementProperties?: Map<PropertyKey, PropertyDeclaration>;\n [SOURCE_META_KEY]?: LitSourceMeta;\n };\n}\n\nconst metaOf = (el: Element): LitSourceMeta | undefined =>\n (el as ReactiveElementLike).constructor[SOURCE_META_KEY];\n\nconst sourceOf = (el: Element): ElementSource | undefined => {\n const meta = metaOf(el);\n return meta === undefined\n ? undefined\n : {file: meta.filePath, line: meta.lineNumber};\n};\n\n/**\n * An element worth showing in the tree: an upgraded custom element that\n * duck-types as a ReactiveElement. Catches Lit components regardless of whether\n * the source-meta transform touched them, while skipping devtools' own UI.\n */\nexport const isInspectable = (el: Element): boolean => {\n const tag = el.tagName.toLowerCase();\n if (!tag.includes('-')) return false;\n if (tag === 'lit-source-overlay' || tag.startsWith('lit-devtools-')) {\n return false;\n }\n return typeof (el as ReactiveElementLike).requestUpdate === 'function';\n};\n\nconst nodeFor = (\n el: Element,\n children: InspectorTreeNode[]\n): InspectorTreeNode => {\n const meta = metaOf(el);\n return {\n id: idOf(el),\n tagName: el.tagName.toLowerCase(),\n componentName: meta?.componentName,\n source:\n meta === undefined\n ? undefined\n : {file: meta.filePath, line: meta.lineNumber},\n children,\n };\n};\n\n/**\n * Visits `el`: if it's inspectable it becomes a node whose children are the\n * inspectables nested in its shadow + light DOM; otherwise we descend, pushing\n * any inspectables we find into the current `sink` (so non-component wrappers\n * are flattened away).\n */\nconst visit = (el: Element, sink: InspectorTreeNode[]): void => {\n if (isInspectable(el)) {\n const children: InspectorTreeNode[] = [];\n descend(el, children);\n sink.push(nodeFor(el, children));\n } else {\n descend(el, sink);\n }\n};\n\nconst descend = (el: Element, sink: InspectorTreeNode[]): void => {\n const shadow = el.shadowRoot;\n if (shadow !== null) {\n for (const child of shadow.children) visit(child, sink);\n }\n for (const child of el.children) visit(child, sink);\n};\n\n/** Build the full component render tree rooted at the document body. */\nexport const buildTree = (): InspectorTreeNode[] => {\n const roots: InspectorTreeNode[] = [];\n for (const child of document.body.children) visit(child, roots);\n return roots;\n};\n\nconst attributeName = (\n key: PropertyKey,\n decl: PropertyDeclaration\n): string | false => {\n if (decl.attribute === false) return false;\n if (typeof decl.attribute === 'string') return decl.attribute;\n return String(key).toLowerCase();\n};\n\n/** Snapshot one element's reactive properties, attributes, and flags. */\nexport const collectDetails = (el: Element): InspectorDetails => {\n const re = el as ReactiveElementLike;\n const declarations = re.constructor.elementProperties;\n const properties: InspectorProp[] = [];\n if (declarations !== undefined) {\n for (const [key, decl] of declarations) {\n // Reading a reactive property runs its accessor, which may throw; one bad\n // getter must not take out the whole details snapshot.\n let value: unknown;\n let threw = false;\n try {\n value = (el as unknown as Record<PropertyKey, unknown>)[key];\n } catch {\n threw = true;\n }\n properties.push({\n name: typeof key === 'symbol' ? key.toString() : String(key),\n value: threw ? '[getter threw]' : serialize(value),\n type: threw ? 'error' : typeTag(value),\n attribute: attributeName(key, decl),\n reflects: decl.reflect === true,\n state: decl.state === true,\n });\n }\n }\n\n const attributes = Array.from(el.attributes, (a) => ({\n name: a.name,\n value: a.value,\n }));\n\n const meta = metaOf(el);\n return {\n id: idOf(el),\n tagName: el.tagName.toLowerCase(),\n componentName: meta?.componentName,\n source: sourceOf(el),\n attributes,\n properties,\n flags: {\n hasUpdated: re.hasUpdated === true,\n isUpdatePending: re.isUpdatePending === true,\n hasShadowRoot: el.shadowRoot !== null,\n },\n };\n};\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
/** Draw the outline over `el`. */
|
|
7
|
+
export declare const showHighlight: (el: Element) => void;
|
|
8
|
+
/** Hide the outline. Cheap and safe before the box has ever been built. */
|
|
9
|
+
export declare const clearHighlight: () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Outline the element with this id, or clear it for `null` — and also when
|
|
12
|
+
* the id no longer resolves, since a stale outline over the wrong element is
|
|
13
|
+
* worse than none.
|
|
14
|
+
*/
|
|
15
|
+
export declare const highlightById: (id: number | null) => void;
|
|
16
|
+
//# sourceMappingURL=highlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/inspector/highlight.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqCH,kCAAkC;AAClC,eAAO,MAAM,aAAa,OAAQ,OAAO,KAAG,IAS3C,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,cAAc,QAAO,IAEjC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,OAAQ,MAAM,GAAG,IAAI,KAAG,IAQjD,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The hover outline the panel draws over an element in the page.
|
|
8
|
+
*
|
|
9
|
+
* Its own module because two transports drive it: the in-page channel (the
|
|
10
|
+
* fast path, no server in the loop) and the Vite HMR command channel (the
|
|
11
|
+
* fallback, for a panel with no page script to handshake with). Both end up
|
|
12
|
+
* here, so the box is created once and behaves identically either way.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately independent of the source overlay, which draws its own,
|
|
15
|
+
* richer highlight — this one has to work whether or not `sourceOverlay` is
|
|
16
|
+
* enabled.
|
|
17
|
+
*/
|
|
18
|
+
import {elementById} from '../timeline/identity.js';
|
|
19
|
+
let box = null;
|
|
20
|
+
const ensureBox = () => {
|
|
21
|
+
if (box === null) {
|
|
22
|
+
box = document.createElement('div');
|
|
23
|
+
box.setAttribute('data-lit-devtools-highlight', '');
|
|
24
|
+
Object.assign(box.style, {
|
|
25
|
+
position: 'fixed',
|
|
26
|
+
zIndex: '2147483646',
|
|
27
|
+
pointerEvents: 'none',
|
|
28
|
+
background: 'rgba(77, 99, 255, 0.25)',
|
|
29
|
+
outline: '1px solid #4d63ff',
|
|
30
|
+
borderRadius: '2px',
|
|
31
|
+
transition: 'all 80ms ease-out',
|
|
32
|
+
});
|
|
33
|
+
document.body.append(box);
|
|
34
|
+
}
|
|
35
|
+
return box;
|
|
36
|
+
};
|
|
37
|
+
/** Draw the outline over `el`. */
|
|
38
|
+
export const showHighlight = (el) => {
|
|
39
|
+
const r = el.getBoundingClientRect();
|
|
40
|
+
Object.assign(ensureBox().style, {
|
|
41
|
+
display: 'block',
|
|
42
|
+
left: `${r.left}px`,
|
|
43
|
+
top: `${r.top}px`,
|
|
44
|
+
width: `${r.width}px`,
|
|
45
|
+
height: `${r.height}px`,
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
/** Hide the outline. Cheap and safe before the box has ever been built. */
|
|
49
|
+
export const clearHighlight = () => {
|
|
50
|
+
if (box !== null) box.style.display = 'none';
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Outline the element with this id, or clear it for `null` — and also when
|
|
54
|
+
* the id no longer resolves, since a stale outline over the wrong element is
|
|
55
|
+
* worse than none.
|
|
56
|
+
*/
|
|
57
|
+
export const highlightById = (id) => {
|
|
58
|
+
if (id === null) {
|
|
59
|
+
clearHighlight();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const el = elementById(id);
|
|
63
|
+
if (el !== undefined) showHighlight(el);
|
|
64
|
+
else clearHighlight();
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=highlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.js","sourceRoot":"","sources":["../../../src/lib/runtime/inspector/highlight.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAEpD,IAAI,GAAG,GAAuB,IAAI,CAAC;AAEnC,MAAM,SAAS,GAAG,GAAgB,EAAE;IAClC,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACpC,GAAG,CAAC,YAAY,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;QACpD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE;YACvB,QAAQ,EAAE,OAAO;YACjB,MAAM,EAAE,YAAY;YACpB,aAAa,EAAE,MAAM;YACrB,UAAU,EAAE,yBAAyB;YACrC,OAAO,EAAE,mBAAmB;YAC5B,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,mBAAmB;SACO,CAAC,CAAC;QAC1C,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,kCAAkC;AAClC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAW,EAAQ,EAAE;IACjD,MAAM,CAAC,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAC;IACrC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE;QAC/B,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,IAAI;QACnB,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI;QACjB,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI;QACrB,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,IAAI;KACxB,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,cAAc,GAAG,GAAS,EAAE;IACvC,IAAI,GAAG,KAAK,IAAI;QAAE,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;AAC/C,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAiB,EAAQ,EAAE;IACvD,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;QAChB,cAAc,EAAE,CAAC;QACjB,OAAO;IACT,CAAC;IACD,MAAM,EAAE,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC;IAC3B,IAAI,EAAE,KAAK,SAAS;QAAE,aAAa,CAAC,EAAE,CAAC,CAAC;;QACnC,cAAc,EAAE,CAAC;AACxB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * The hover outline the panel draws over an element in the page.\n *\n * Its own module because two transports drive it: the in-page channel (the\n * fast path, no server in the loop) and the Vite HMR command channel (the\n * fallback, for a panel with no page script to handshake with). Both end up\n * here, so the box is created once and behaves identically either way.\n *\n * Deliberately independent of the source overlay, which draws its own,\n * richer highlight — this one has to work whether or not `sourceOverlay` is\n * enabled.\n */\n\nimport {elementById} from '../timeline/identity.js';\n\nlet box: HTMLElement | null = null;\n\nconst ensureBox = (): HTMLElement => {\n if (box === null) {\n box = document.createElement('div');\n box.setAttribute('data-lit-devtools-highlight', '');\n Object.assign(box.style, {\n position: 'fixed',\n zIndex: '2147483646',\n pointerEvents: 'none',\n background: 'rgba(77, 99, 255, 0.25)',\n outline: '1px solid #4d63ff',\n borderRadius: '2px',\n transition: 'all 80ms ease-out',\n } satisfies Partial<CSSStyleDeclaration>);\n document.body.append(box);\n }\n return box;\n};\n\n/** Draw the outline over `el`. */\nexport const showHighlight = (el: Element): void => {\n const r = el.getBoundingClientRect();\n Object.assign(ensureBox().style, {\n display: 'block',\n left: `${r.left}px`,\n top: `${r.top}px`,\n width: `${r.width}px`,\n height: `${r.height}px`,\n });\n};\n\n/** Hide the outline. Cheap and safe before the box has ever been built. */\nexport const clearHighlight = (): void => {\n if (box !== null) box.style.display = 'none';\n};\n\n/**\n * Outline the element with this id, or clear it for `null` — and also when\n * the id no longer resolves, since a stale outline over the wrong element is\n * worse than none.\n */\nexport const highlightById = (id: number | null): void => {\n if (id === null) {\n clearHighlight();\n return;\n }\n const el = elementById(id);\n if (el !== undefined) showHighlight(el);\n else clearHighlight();\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/inspector/install.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|