@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
|
@@ -11,219 +11,194 @@
|
|
|
11
11
|
* Vite HMR channel, keeps a watched element's details fresh as it updates, and
|
|
12
12
|
* outlines elements the panel hovers in its tree.
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import {createPageScriptChannel} from 'devframe/in-page-channel';
|
|
15
|
+
import {elementById} from '../timeline/identity.js';
|
|
16
|
+
import {buildTree, collectDetails} from './collect.js';
|
|
17
|
+
import {clearHighlight, highlightById} from './highlight.js';
|
|
18
|
+
import {LIT_IN_PAGE_CHANNEL} from '../../../types/in-page.js';
|
|
19
|
+
import {
|
|
20
|
+
INSPECT_CMD_CHANNEL,
|
|
21
|
+
INSPECT_DATA_CHANNEL,
|
|
22
|
+
} from '../../../types/inspector.js';
|
|
17
23
|
const hot = import.meta.hot;
|
|
24
|
+
// The direct panel channel, outside the `hot` gate on purpose: it is the one
|
|
25
|
+
// part of the inspector that does not need a dev server, which is what lets
|
|
26
|
+
// the hover outline keep working in a static snapshot of the panel. Answering
|
|
27
|
+
// handshakes costs nothing until a panel actually sends one.
|
|
28
|
+
if (typeof window !== 'undefined') {
|
|
29
|
+
const channel = createPageScriptChannel({
|
|
30
|
+
name: LIT_IN_PAGE_CHANNEL,
|
|
31
|
+
functions: {},
|
|
32
|
+
events: {
|
|
33
|
+
highlight: {handler: (id) => highlightById(id)},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
// A panel that goes away mid-hover never gets to send its `highlight(null)`,
|
|
37
|
+
// and an outline left painted over the app is worse than a missing one.
|
|
38
|
+
channel.events.on('panel:disconnected', () => clearHighlight());
|
|
39
|
+
}
|
|
18
40
|
if (hot !== undefined && typeof window !== 'undefined') {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
const send = (msg) => {
|
|
42
|
+
try {
|
|
43
|
+
hot.send(INSPECT_DATA_CHANNEL, msg);
|
|
44
|
+
} catch {
|
|
45
|
+
// HMR channel temporarily unavailable; the panel can re-request.
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
// Hold the watched element via a WeakRef so an active watch doesn't keep a
|
|
49
|
+
// removed element alive: the override and `restore` only reach `el` through
|
|
50
|
+
// the ref, leaving the DOM as its sole strong root.
|
|
51
|
+
let watched = null;
|
|
52
|
+
const unwatch = () => {
|
|
53
|
+
watched?.restore();
|
|
54
|
+
watched = null;
|
|
55
|
+
};
|
|
56
|
+
const watch = (id) => {
|
|
57
|
+
unwatch();
|
|
58
|
+
const el = elementById(id);
|
|
59
|
+
if (el === undefined) {
|
|
60
|
+
send({type: 'gone', id});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const hadOwn = Object.prototype.hasOwnProperty.call(el, 'updated');
|
|
64
|
+
// Only an *own* `updated` is stable across an HMR hot patch. A prototype
|
|
65
|
+
// implementation is replaced in place on every patch (`syncOwnMembers` in
|
|
66
|
+
// ../patch.ts), so caching it here would pin the watched instance to the
|
|
67
|
+
// pre-edit code for the life of the watch — resolve it through the
|
|
68
|
+
// prototype chain on each call instead. Our wrapper is an own property, so
|
|
69
|
+
// the lookup skips it and cannot recurse.
|
|
70
|
+
const ownPrev = hadOwn ? el.updated : undefined;
|
|
71
|
+
const ref = new WeakRef(el);
|
|
72
|
+
el.updated = function (changed) {
|
|
73
|
+
const current = ownPrev ?? Object.getPrototypeOf(this)?.updated;
|
|
74
|
+
current?.call(this, changed);
|
|
75
|
+
const cur = ref.deref();
|
|
76
|
+
if (cur !== undefined) {
|
|
77
|
+
send({type: 'details', details: collectDetails(cur)});
|
|
78
|
+
}
|
|
34
79
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const prev = el.updated;
|
|
44
|
-
const ref = new WeakRef(el);
|
|
45
|
-
el.updated = function (changed) {
|
|
46
|
-
prev?.call(this, changed);
|
|
47
|
-
const cur = ref.deref();
|
|
48
|
-
if (cur !== undefined) {
|
|
49
|
-
send({ type: 'details', details: collectDetails(cur) });
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
watched = {
|
|
53
|
-
ref,
|
|
54
|
-
restore: () => {
|
|
55
|
-
const cur = ref.deref();
|
|
56
|
-
if (cur === undefined)
|
|
57
|
-
return;
|
|
58
|
-
if (hadOwn)
|
|
59
|
-
cur.updated = prev;
|
|
60
|
-
else
|
|
61
|
-
delete cur.updated;
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
// Push an immediate snapshot so the panel doesn't wait for the next update.
|
|
65
|
-
send({ type: 'details', details: collectDetails(el) });
|
|
80
|
+
watched = {
|
|
81
|
+
ref,
|
|
82
|
+
restore: () => {
|
|
83
|
+
const cur = ref.deref();
|
|
84
|
+
if (cur === undefined) return;
|
|
85
|
+
if (hadOwn) cur.updated = ownPrev;
|
|
86
|
+
else delete cur.updated;
|
|
87
|
+
},
|
|
66
88
|
};
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
// Push an immediate snapshot so the panel doesn't wait for the next update.
|
|
90
|
+
send({type: 'details', details: collectDetails(el)});
|
|
91
|
+
};
|
|
92
|
+
// -------------------------------------------------------------------------
|
|
93
|
+
// Opt-in live tree: watch the DOM (light + every shadow root) and push a
|
|
94
|
+
// fresh tree when the component hierarchy actually changes. Off by default.
|
|
95
|
+
// childList-only (no attributes), so cosmetic changes — including our own
|
|
96
|
+
// highlight box toggling — don't churn; identical rebuilds are also deduped.
|
|
97
|
+
// -------------------------------------------------------------------------
|
|
98
|
+
let observer = null;
|
|
99
|
+
let observeTimer;
|
|
100
|
+
let lastTreeJson = '';
|
|
101
|
+
/** Re-attach the observer to the body and every shadow root in the page. */
|
|
102
|
+
const syncObserverTargets = (obs) => {
|
|
103
|
+
obs.disconnect();
|
|
104
|
+
obs.observe(document.body, {childList: true, subtree: true});
|
|
105
|
+
const walk = (root) => {
|
|
106
|
+
for (const el of root.querySelectorAll('*')) {
|
|
107
|
+
if (el.shadowRoot !== null) {
|
|
108
|
+
obs.observe(el.shadowRoot, {childList: true, subtree: true});
|
|
109
|
+
walk(el.shadowRoot);
|
|
87
110
|
}
|
|
88
|
-
|
|
89
|
-
Object.assign(highlightBox.style, {
|
|
90
|
-
display: 'block',
|
|
91
|
-
left: `${r.left}px`,
|
|
92
|
-
top: `${r.top}px`,
|
|
93
|
-
width: `${r.width}px`,
|
|
94
|
-
height: `${r.height}px`,
|
|
95
|
-
});
|
|
111
|
+
}
|
|
96
112
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
walk(document);
|
|
114
|
+
};
|
|
115
|
+
const pushTreeIfChanged = () => {
|
|
116
|
+
const roots = buildTree();
|
|
117
|
+
const json = JSON.stringify(roots);
|
|
118
|
+
if (json === lastTreeJson) return;
|
|
119
|
+
lastTreeJson = json;
|
|
120
|
+
send({type: 'tree', roots});
|
|
121
|
+
};
|
|
122
|
+
const onMutation = () => {
|
|
123
|
+
if (observeTimer !== undefined) clearTimeout(observeTimer);
|
|
124
|
+
observeTimer = setTimeout(() => {
|
|
125
|
+
observeTimer = undefined;
|
|
126
|
+
if (observer !== null) syncObserverTargets(observer);
|
|
127
|
+
pushTreeIfChanged();
|
|
128
|
+
}, 100);
|
|
129
|
+
};
|
|
130
|
+
const setObserving = (enabled) => {
|
|
131
|
+
if (enabled) {
|
|
132
|
+
if (observer === null) observer = new MutationObserver(onMutation);
|
|
133
|
+
lastTreeJson = '';
|
|
134
|
+
syncObserverTargets(observer);
|
|
135
|
+
pushTreeIfChanged();
|
|
136
|
+
} else if (observer !== null) {
|
|
137
|
+
observer.disconnect();
|
|
138
|
+
observer = null;
|
|
139
|
+
if (observeTimer !== undefined) {
|
|
140
|
+
clearTimeout(observeTimer);
|
|
141
|
+
observeTimer = undefined;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
// -------------------------------------------------------------------------
|
|
146
|
+
// SPA navigation: a route change swaps the component tree without any HMR
|
|
147
|
+
// or panel event, so the snapshot went stale until a manual refresh. Push a
|
|
148
|
+
// deduped tree after each navigation — twice, since routes typically
|
|
149
|
+
// lazy-load and render async. Redundant while the live observer watches.
|
|
150
|
+
// -------------------------------------------------------------------------
|
|
151
|
+
const onNavigation = () => {
|
|
152
|
+
if (observer !== null) return;
|
|
153
|
+
for (const delay of [150, 1000]) {
|
|
154
|
+
setTimeout(pushTreeIfChanged, delay);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
window.addEventListener('popstate', onNavigation);
|
|
158
|
+
window.addEventListener('hashchange', onNavigation);
|
|
159
|
+
for (const method of ['pushState', 'replaceState']) {
|
|
160
|
+
const original = history[method].bind(history);
|
|
161
|
+
history[method] = (...args) => {
|
|
162
|
+
original(...args);
|
|
163
|
+
onNavigation();
|
|
123
164
|
};
|
|
124
|
-
|
|
165
|
+
}
|
|
166
|
+
// -------------------------------------------------------------------------
|
|
167
|
+
// Command dispatch
|
|
168
|
+
// -------------------------------------------------------------------------
|
|
169
|
+
hot.on(INSPECT_CMD_CHANNEL, (data) => {
|
|
170
|
+
const cmd = data;
|
|
171
|
+
switch (cmd.type) {
|
|
172
|
+
case 'tree': {
|
|
125
173
|
const roots = buildTree();
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
observeTimer = undefined;
|
|
137
|
-
if (observer !== null)
|
|
138
|
-
syncObserverTargets(observer);
|
|
139
|
-
pushTreeIfChanged();
|
|
140
|
-
}, 100);
|
|
141
|
-
};
|
|
142
|
-
const setObserving = (enabled) => {
|
|
143
|
-
if (enabled) {
|
|
144
|
-
if (observer === null)
|
|
145
|
-
observer = new MutationObserver(onMutation);
|
|
146
|
-
lastTreeJson = '';
|
|
147
|
-
syncObserverTargets(observer);
|
|
148
|
-
pushTreeIfChanged();
|
|
149
|
-
}
|
|
150
|
-
else if (observer !== null) {
|
|
151
|
-
observer.disconnect();
|
|
152
|
-
observer = null;
|
|
153
|
-
if (observeTimer !== undefined) {
|
|
154
|
-
clearTimeout(observeTimer);
|
|
155
|
-
observeTimer = undefined;
|
|
156
|
-
}
|
|
174
|
+
lastTreeJson = JSON.stringify(roots);
|
|
175
|
+
send({type: 'tree', roots});
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
case 'details': {
|
|
179
|
+
const el = elementById(cmd.id);
|
|
180
|
+
if (el !== undefined) {
|
|
181
|
+
send({type: 'details', details: collectDetails(el)});
|
|
182
|
+
} else {
|
|
183
|
+
send({type: 'gone', id: cmd.id});
|
|
157
184
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
window.addEventListener('popstate', onNavigation);
|
|
173
|
-
window.addEventListener('hashchange', onNavigation);
|
|
174
|
-
for (const method of ['pushState', 'replaceState']) {
|
|
175
|
-
const original = history[method].bind(history);
|
|
176
|
-
history[method] = (...args) => {
|
|
177
|
-
original(...args);
|
|
178
|
-
onNavigation();
|
|
179
|
-
};
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case 'watch':
|
|
188
|
+
if (cmd.id === null) unwatch();
|
|
189
|
+
else watch(cmd.id);
|
|
190
|
+
break;
|
|
191
|
+
case 'highlight':
|
|
192
|
+
// Fallback path. A panel that handshaked over the in-page channel
|
|
193
|
+
// emits there instead and never reaches this.
|
|
194
|
+
highlightById(cmd.id);
|
|
195
|
+
break;
|
|
196
|
+
case 'observe':
|
|
197
|
+
setObserving(cmd.enabled);
|
|
198
|
+
break;
|
|
180
199
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
hot.on(INSPECT_CMD_CHANNEL, (data) => {
|
|
185
|
-
const cmd = data;
|
|
186
|
-
switch (cmd.type) {
|
|
187
|
-
case 'tree': {
|
|
188
|
-
const roots = buildTree();
|
|
189
|
-
lastTreeJson = JSON.stringify(roots);
|
|
190
|
-
send({ type: 'tree', roots });
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
case 'details': {
|
|
194
|
-
const el = elementById(cmd.id);
|
|
195
|
-
if (el !== undefined) {
|
|
196
|
-
send({ type: 'details', details: collectDetails(el) });
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
send({ type: 'gone', id: cmd.id });
|
|
200
|
-
}
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
case 'watch':
|
|
204
|
-
if (cmd.id === null)
|
|
205
|
-
unwatch();
|
|
206
|
-
else
|
|
207
|
-
watch(cmd.id);
|
|
208
|
-
break;
|
|
209
|
-
case 'highlight': {
|
|
210
|
-
if (cmd.id === null) {
|
|
211
|
-
clearHighlight();
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
const el = elementById(cmd.id);
|
|
215
|
-
if (el !== undefined)
|
|
216
|
-
showHighlight(el);
|
|
217
|
-
else
|
|
218
|
-
clearHighlight();
|
|
219
|
-
break;
|
|
220
|
-
}
|
|
221
|
-
case 'observe':
|
|
222
|
-
setObserving(cmd.enabled);
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
// Announce readiness so a panel that loaded first re-requests the tree.
|
|
227
|
-
send({ type: 'ready' });
|
|
200
|
+
});
|
|
201
|
+
// Announce readiness so a panel that loaded first re-requests the tree.
|
|
202
|
+
send({type: 'ready'});
|
|
228
203
|
}
|
|
229
|
-
//# sourceMappingURL=install.js.map
|
|
204
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/inspector/install.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,SAAS,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GAGrB,MAAM,6BAA6B,CAAC;AAOrC,MAAM,GAAG,GAAI,MAAM,CAAC,IAAwB,CAAC,GAAG,CAAC;AAEjD,IAAI,GAAG,KAAK,SAAS,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IACvD,MAAM,IAAI,GAAG,CAAC,GAAqB,EAAQ,EAAE;QAC3C,IAAI,CAAC;YACH,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC;QAAC,MAAM,CAAC;YACP,iEAAiE;QACnE,CAAC;IACH,CAAC,CAAC;IAYF,2EAA2E;IAC3E,4EAA4E;IAC5E,oDAAoD;IACpD,IAAI,OAAO,GAA0D,IAAI,CAAC;IAE1E,MAAM,OAAO,GAAG,GAAS,EAAE;QACzB,OAAO,EAAE,OAAO,EAAE,CAAC;QACnB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC,CAAC;IAEF,MAAM,KAAK,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AAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACnB,MAAM;YACR,KAAK,WAAW,CAAC,CAAC,CAAC;gBACjB,IAAI,GAAG,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;oBACpB,cAAc,EAAE,CAAC;oBACjB,MAAM;gBACR,CAAC;gBACD,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC/B,IAAI,EAAE,KAAK,SAAS;oBAAE,aAAa,CAAC,EAAE,CAAC,CAAC;;oBACnC,cAAc,EAAE,CAAC;gBACtB,MAAM;YACR,CAAC;YACD,KAAK,SAAS;gBACZ,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC1B,MAAM;QACV,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,wEAAwE;IACxE,IAAI,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC,CAAC;AACxB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Components inspector runtime.\n *\n * Injected into the host page (alongside the timeline runtime) when the\n * DevTools panel is enabled. Answers the panel's tree/details requests over the\n * Vite HMR channel, keeps a watched element's details fresh as it updates, and\n * outlines elements the panel hovers in its tree.\n */\n\nimport {elementById} from '../timeline/identity.js';\nimport {buildTree, collectDetails} from './collect.js';\nimport {\n INSPECT_CMD_CHANNEL,\n INSPECT_DATA_CHANNEL,\n type InspectorCommand,\n type InspectorMessage,\n} from '../../../types/inspector.js';\n\ntype ViteHot = {\n send: (event: string, data: unknown) => void;\n on: (event: string, handler: (data: unknown) => void) => void;\n};\n\nconst hot = (import.meta as {hot?: ViteHot}).hot;\n\nif (hot !== undefined && typeof window !== 'undefined') {\n const send = (msg: InspectorMessage): void => {\n try {\n hot.send(INSPECT_DATA_CHANNEL, msg);\n } catch {\n // HMR channel temporarily unavailable; the panel can re-request.\n }\n };\n\n // -------------------------------------------------------------------------\n // Live-watch: re-push details whenever the watched element finishes updating.\n // We wrap the instance's `updated` (not the prototype) so the hook is scoped\n // to one element and trivially removable, and it works without the timeline's\n // recording gate.\n // -------------------------------------------------------------------------\n\n type Updatable = Element & {\n updated?: (changed: unknown) => void;\n };\n // Hold the watched element via a WeakRef so an active watch doesn't keep a\n // removed element alive: the override and `restore` only reach `el` through\n // the ref, leaving the DOM as its sole strong root.\n let watched: {ref: WeakRef<Updatable>; restore: () => void} | null = null;\n\n const unwatch = (): void => {\n watched?.restore();\n watched = null;\n };\n\n const watch = (id: number): void => {\n unwatch();\n const el = elementById(id) as Updatable | undefined;\n if (el === undefined) {\n send({type: 'gone', id});\n return;\n }\n const hadOwn = Object.prototype.hasOwnProperty.call(el, 'updated');\n const prev = el.updated;\n const ref = new WeakRef(el);\n el.updated = function (changed: unknown) {\n prev?.call(this, changed);\n const cur = ref.deref();\n if (cur !== undefined) {\n send({type: 'details', details: collectDetails(cur)});\n }\n };\n watched = {\n ref,\n restore: () => {\n const cur = ref.deref();\n if (cur === undefined) return;\n if (hadOwn) cur.updated = prev;\n else delete cur.updated;\n },\n };\n // Push an immediate snapshot so the panel doesn't wait for the next update.\n send({type: 'details', details: collectDetails(el)});\n };\n\n // -------------------------------------------------------------------------\n // Highlight box: a lightweight fixed-position outline drawn over an element\n // the panel hovers in its tree. Independent of the source overlay so it works\n // whether or not that feature is enabled.\n // -------------------------------------------------------------------------\n\n let highlightBox: HTMLElement | null = null;\n\n const showHighlight = (el: Element): void => {\n if (highlightBox === null) {\n highlightBox = document.createElement('div');\n highlightBox.setAttribute('data-lit-devtools-highlight', '');\n Object.assign(highlightBox.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(highlightBox);\n }\n const r = el.getBoundingClientRect();\n Object.assign(highlightBox.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 const clearHighlight = (): void => {\n if (highlightBox !== null) highlightBox.style.display = 'none';\n };\n\n // -------------------------------------------------------------------------\n // Opt-in live tree: watch the DOM (light + every shadow root) and push a\n // fresh tree when the component hierarchy actually changes. Off by default.\n // childList-only (no attributes), so cosmetic changes — including our own\n // highlight box toggling — don't churn; identical rebuilds are also deduped.\n // -------------------------------------------------------------------------\n\n let observer: MutationObserver | null = null;\n let observeTimer: ReturnType<typeof setTimeout> | undefined;\n let lastTreeJson = '';\n\n /** Re-attach the observer to the body and every shadow root in the page. */\n const syncObserverTargets = (obs: MutationObserver): void => {\n obs.disconnect();\n obs.observe(document.body, {childList: true, subtree: true});\n const walk = (root: ParentNode): void => {\n for (const el of root.querySelectorAll('*')) {\n if (el.shadowRoot !== null) {\n obs.observe(el.shadowRoot, {childList: true, subtree: true});\n walk(el.shadowRoot);\n }\n }\n };\n walk(document);\n };\n\n const pushTreeIfChanged = (): void => {\n const roots = buildTree();\n const json = JSON.stringify(roots);\n if (json === lastTreeJson) return;\n lastTreeJson = json;\n send({type: 'tree', roots});\n };\n\n const onMutation = (): void => {\n if (observeTimer !== undefined) clearTimeout(observeTimer);\n observeTimer = setTimeout(() => {\n observeTimer = undefined;\n if (observer !== null) syncObserverTargets(observer);\n pushTreeIfChanged();\n }, 100);\n };\n\n const setObserving = (enabled: boolean): void => {\n if (enabled) {\n if (observer === null) observer = new MutationObserver(onMutation);\n lastTreeJson = '';\n syncObserverTargets(observer);\n pushTreeIfChanged();\n } else if (observer !== null) {\n observer.disconnect();\n observer = null;\n if (observeTimer !== undefined) {\n clearTimeout(observeTimer);\n observeTimer = undefined;\n }\n }\n };\n\n // -------------------------------------------------------------------------\n // SPA navigation: a route change swaps the component tree without any HMR\n // or panel event, so the snapshot went stale until a manual refresh. Push a\n // deduped tree after each navigation — twice, since routes typically\n // lazy-load and render async. Redundant while the live observer watches.\n // -------------------------------------------------------------------------\n\n const onNavigation = (): void => {\n if (observer !== null) return;\n for (const delay of [150, 1000]) {\n setTimeout(pushTreeIfChanged, delay);\n }\n };\n window.addEventListener('popstate', onNavigation);\n window.addEventListener('hashchange', onNavigation);\n for (const method of ['pushState', 'replaceState'] as const) {\n const original = history[method].bind(history);\n history[method] = (...args: Parameters<History['pushState']>) => {\n original(...args);\n onNavigation();\n };\n }\n\n // -------------------------------------------------------------------------\n // Command dispatch\n // -------------------------------------------------------------------------\n\n hot.on(INSPECT_CMD_CHANNEL, (data) => {\n const cmd = data as InspectorCommand;\n switch (cmd.type) {\n case 'tree': {\n const roots = buildTree();\n lastTreeJson = JSON.stringify(roots);\n send({type: 'tree', roots});\n break;\n }\n case 'details': {\n const el = elementById(cmd.id);\n if (el !== undefined) {\n send({type: 'details', details: collectDetails(el)});\n } else {\n send({type: 'gone', id: cmd.id});\n }\n break;\n }\n case 'watch':\n if (cmd.id === null) unwatch();\n else watch(cmd.id);\n break;\n case 'highlight': {\n if (cmd.id === null) {\n clearHighlight();\n break;\n }\n const el = elementById(cmd.id);\n if (el !== undefined) showHighlight(el);\n else clearHighlight();\n break;\n }\n case 'observe':\n setObserving(cmd.enabled);\n break;\n }\n });\n\n // Announce readiness so a panel that loaded first re-requests the tree.\n send({type: 'ready'});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/lib/runtime/inspector/install.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAC,uBAAuB,EAAC,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,SAAS,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AACvD,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EACL,mBAAmB,GAEpB,MAAM,2BAA2B,CAAC;AACnC,OA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,CAAC;gBACnC,CAAC;gBACD,MAAM;YACR,CAAC;YACD,KAAK,OAAO;gBACV,IAAI,GAAG,CAAC,EAAE,KAAK,IAAI;oBAAE,OAAO,EAAE,CAAC;;oBAC1B,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACnB,MAAM;YACR,KAAK,WAAW;gBACd,kEAAkE;gBAClE,8CAA8C;gBAC9C,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACtB,MAAM;YACR,KAAK,SAAS;gBACZ,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC1B,MAAM;QACV,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,wEAAwE;IACxE,IAAI,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC,CAAC;AACxB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Components inspector runtime.\n *\n * Injected into the host page (alongside the timeline runtime) when the\n * DevTools panel is enabled. Answers the panel's tree/details requests over the\n * Vite HMR channel, keeps a watched element's details fresh as it updates, and\n * outlines elements the panel hovers in its tree.\n */\n\nimport {createPageScriptChannel} from 'devframe/in-page-channel';\nimport {elementById} from '../timeline/identity.js';\nimport {buildTree, collectDetails} from './collect.js';\nimport {clearHighlight, highlightById} from './highlight.js';\nimport {\n LIT_IN_PAGE_CHANNEL,\n type LitInPageProtocol,\n} from '../../../types/in-page.js';\nimport {\n INSPECT_CMD_CHANNEL,\n INSPECT_DATA_CHANNEL,\n type InspectorCommand,\n type InspectorMessage,\n} from '../../../types/inspector.js';\n\ntype ViteHot = {\n send: (event: string, data: unknown) => void;\n on: (event: string, handler: (data: unknown) => void) => void;\n};\n\nconst hot = (import.meta as {hot?: ViteHot}).hot;\n\n// The direct panel channel, outside the `hot` gate on purpose: it is the one\n// part of the inspector that does not need a dev server, which is what lets\n// the hover outline keep working in a static snapshot of the panel. Answering\n// handshakes costs nothing until a panel actually sends one.\nif (typeof window !== 'undefined') {\n const channel = createPageScriptChannel<LitInPageProtocol>({\n name: LIT_IN_PAGE_CHANNEL,\n functions: {},\n events: {\n highlight: {handler: (id) => highlightById(id)},\n },\n });\n // A panel that goes away mid-hover never gets to send its `highlight(null)`,\n // and an outline left painted over the app is worse than a missing one.\n channel.events.on('panel:disconnected', () => clearHighlight());\n}\n\nif (hot !== undefined && typeof window !== 'undefined') {\n const send = (msg: InspectorMessage): void => {\n try {\n hot.send(INSPECT_DATA_CHANNEL, msg);\n } catch {\n // HMR channel temporarily unavailable; the panel can re-request.\n }\n };\n\n // -------------------------------------------------------------------------\n // Live-watch: re-push details whenever the watched element finishes updating.\n // We wrap the instance's `updated` (not the prototype) so the hook is scoped\n // to one element and trivially removable, and it works without the timeline's\n // recording gate.\n // -------------------------------------------------------------------------\n\n type Updatable = Element & {\n updated?: (changed: unknown) => void;\n };\n // Hold the watched element via a WeakRef so an active watch doesn't keep a\n // removed element alive: the override and `restore` only reach `el` through\n // the ref, leaving the DOM as its sole strong root.\n let watched: {ref: WeakRef<Updatable>; restore: () => void} | null = null;\n\n const unwatch = (): void => {\n watched?.restore();\n watched = null;\n };\n\n const watch = (id: number): void => {\n unwatch();\n const el = elementById(id) as Updatable | undefined;\n if (el === undefined) {\n send({type: 'gone', id});\n return;\n }\n const hadOwn = Object.prototype.hasOwnProperty.call(el, 'updated');\n // Only an *own* `updated` is stable across an HMR hot patch. A prototype\n // implementation is replaced in place on every patch (`syncOwnMembers` in\n // ../patch.ts), so caching it here would pin the watched instance to the\n // pre-edit code for the life of the watch — resolve it through the\n // prototype chain on each call instead. Our wrapper is an own property, so\n // the lookup skips it and cannot recurse.\n const ownPrev = hadOwn ? el.updated : undefined;\n const ref = new WeakRef(el);\n el.updated = function (this: Updatable, changed: unknown) {\n const current =\n ownPrev ?? (Object.getPrototypeOf(this) as Updatable | null)?.updated;\n current?.call(this, changed);\n const cur = ref.deref();\n if (cur !== undefined) {\n send({type: 'details', details: collectDetails(cur)});\n }\n };\n watched = {\n ref,\n restore: () => {\n const cur = ref.deref();\n if (cur === undefined) return;\n if (hadOwn) cur.updated = ownPrev;\n else delete cur.updated;\n },\n };\n // Push an immediate snapshot so the panel doesn't wait for the next update.\n send({type: 'details', details: collectDetails(el)});\n };\n\n // -------------------------------------------------------------------------\n // Opt-in live tree: watch the DOM (light + every shadow root) and push a\n // fresh tree when the component hierarchy actually changes. Off by default.\n // childList-only (no attributes), so cosmetic changes — including our own\n // highlight box toggling — don't churn; identical rebuilds are also deduped.\n // -------------------------------------------------------------------------\n\n let observer: MutationObserver | null = null;\n let observeTimer: ReturnType<typeof setTimeout> | undefined;\n let lastTreeJson = '';\n\n /** Re-attach the observer to the body and every shadow root in the page. */\n const syncObserverTargets = (obs: MutationObserver): void => {\n obs.disconnect();\n obs.observe(document.body, {childList: true, subtree: true});\n const walk = (root: ParentNode): void => {\n for (const el of root.querySelectorAll('*')) {\n if (el.shadowRoot !== null) {\n obs.observe(el.shadowRoot, {childList: true, subtree: true});\n walk(el.shadowRoot);\n }\n }\n };\n walk(document);\n };\n\n const pushTreeIfChanged = (): void => {\n const roots = buildTree();\n const json = JSON.stringify(roots);\n if (json === lastTreeJson) return;\n lastTreeJson = json;\n send({type: 'tree', roots});\n };\n\n const onMutation = (): void => {\n if (observeTimer !== undefined) clearTimeout(observeTimer);\n observeTimer = setTimeout(() => {\n observeTimer = undefined;\n if (observer !== null) syncObserverTargets(observer);\n pushTreeIfChanged();\n }, 100);\n };\n\n const setObserving = (enabled: boolean): void => {\n if (enabled) {\n if (observer === null) observer = new MutationObserver(onMutation);\n lastTreeJson = '';\n syncObserverTargets(observer);\n pushTreeIfChanged();\n } else if (observer !== null) {\n observer.disconnect();\n observer = null;\n if (observeTimer !== undefined) {\n clearTimeout(observeTimer);\n observeTimer = undefined;\n }\n }\n };\n\n // -------------------------------------------------------------------------\n // SPA navigation: a route change swaps the component tree without any HMR\n // or panel event, so the snapshot went stale until a manual refresh. Push a\n // deduped tree after each navigation — twice, since routes typically\n // lazy-load and render async. Redundant while the live observer watches.\n // -------------------------------------------------------------------------\n\n const onNavigation = (): void => {\n if (observer !== null) return;\n for (const delay of [150, 1000]) {\n setTimeout(pushTreeIfChanged, delay);\n }\n };\n window.addEventListener('popstate', onNavigation);\n window.addEventListener('hashchange', onNavigation);\n for (const method of ['pushState', 'replaceState'] as const) {\n const original = history[method].bind(history);\n history[method] = (...args: Parameters<History['pushState']>) => {\n original(...args);\n onNavigation();\n };\n }\n\n // -------------------------------------------------------------------------\n // Command dispatch\n // -------------------------------------------------------------------------\n\n hot.on(INSPECT_CMD_CHANNEL, (data) => {\n const cmd = data as InspectorCommand;\n switch (cmd.type) {\n case 'tree': {\n const roots = buildTree();\n lastTreeJson = JSON.stringify(roots);\n send({type: 'tree', roots});\n break;\n }\n case 'details': {\n const el = elementById(cmd.id);\n if (el !== undefined) {\n send({type: 'details', details: collectDetails(el)});\n } else {\n send({type: 'gone', id: cmd.id});\n }\n break;\n }\n case 'watch':\n if (cmd.id === null) unwatch();\n else watch(cmd.id);\n break;\n case 'highlight':\n // Fallback path. A panel that handshaked over the in-page channel\n // emits there instead and never reaches this.\n highlightById(cmd.id);\n break;\n case 'observe':\n setObserving(cmd.enabled);\n break;\n }\n });\n\n // Announce readiness so a panel that loaded first re-requests the tree.\n send({type: 'ready'});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/inspector/serialize.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,gEAAgE;AAChE,eAAO,MAAM,OAAO,UAAW,OAAO,KAAG,MAWxC,CAAC;AA2FF,oEAAoE;AACpE,eAAO,MAAM,SAAS,UAAW,OAAO,KAAG,MAM1C,CAAC"}
|