@oddsquad/vite-plugin-lit 0.4.0 → 0.5.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +16 -5
  3. package/bin.mjs +16 -12
  4. package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-CdtPhBL-.js → browser-agent-rpc-BXhoSh1z-CRHFLjFo.js} +2 -2
  5. package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-CdtPhBL-.js.map → browser-agent-rpc-BXhoSh1z-CRHFLjFo.js.map} +1 -1
  6. package/dist/client/assets/{index-DVe6M4HV.js → index-Gn4Hk_9s.js} +1840 -758
  7. package/dist/client/assets/index-Gn4Hk_9s.js.map +1 -0
  8. package/dist/client/index.html +11 -1
  9. package/lib/devframe/definition.d.ts +7 -0
  10. package/lib/devframe/definition.d.ts.map +1 -1
  11. package/lib/devframe/definition.js +56 -11
  12. package/lib/devframe/definition.js.map +1 -1
  13. package/lib/devframe/launch-editor.d.ts +20 -0
  14. package/lib/devframe/launch-editor.d.ts.map +1 -0
  15. package/lib/devframe/launch-editor.js +40 -0
  16. package/lib/devframe/launch-editor.js.map +1 -0
  17. package/lib/devframe/protocol.d.ts +31 -4
  18. package/lib/devframe/protocol.d.ts.map +1 -1
  19. package/lib/devframe/protocol.js +21 -3
  20. package/lib/devframe/protocol.js.map +1 -1
  21. package/lib/devframe/rpc-source.d.ts +44 -0
  22. package/lib/devframe/rpc-source.d.ts.map +1 -0
  23. package/lib/devframe/rpc-source.js +150 -0
  24. package/lib/devframe/rpc-source.js.map +1 -0
  25. package/lib/devframe/source.d.ts +12 -0
  26. package/lib/devframe/source.d.ts.map +1 -1
  27. package/lib/devframe/source.js +12 -0
  28. package/lib/devframe/source.js.map +1 -1
  29. package/lib/devframe/vite.d.ts +2 -0
  30. package/lib/devframe/vite.d.ts.map +1 -1
  31. package/lib/devframe/vite.js +3 -9
  32. package/lib/devframe/vite.js.map +1 -1
  33. package/lib/options.d.ts +6 -1
  34. package/lib/options.d.ts.map +1 -1
  35. package/lib/options.js +65 -18
  36. package/lib/options.js.map +1 -1
  37. package/lib/override-baselines.d.ts +17 -0
  38. package/lib/override-baselines.d.ts.map +1 -0
  39. package/lib/override-baselines.js +25 -0
  40. package/lib/override-baselines.js.map +1 -0
  41. package/lib/plugin.d.ts.map +1 -1
  42. package/lib/plugin.js +8 -0
  43. package/lib/plugin.js.map +1 -1
  44. package/lib/plugins/open-in-editor.d.ts.map +1 -1
  45. package/lib/plugins/open-in-editor.js +6 -1
  46. package/lib/plugins/open-in-editor.js.map +1 -1
  47. package/lib/runtime/indicator.js.map +1 -1
  48. package/lib/runtime/inspector/install.js +4 -2
  49. package/lib/runtime/inspector/install.js.map +1 -1
  50. package/lib/runtime/inspector/serialize.d.ts.map +1 -1
  51. package/lib/runtime/inspector/serialize.js +20 -0
  52. package/lib/runtime/inspector/serialize.js.map +1 -1
  53. package/lib/runtime/overrides.d.ts +4 -10
  54. package/lib/runtime/overrides.d.ts.map +1 -1
  55. package/lib/runtime/overrides.js +5 -3
  56. package/lib/runtime/overrides.js.map +1 -1
  57. package/lib/runtime/page-channel.d.ts +52 -0
  58. package/lib/runtime/page-channel.d.ts.map +1 -0
  59. package/lib/runtime/page-channel.js +67 -0
  60. package/lib/runtime/page-channel.js.map +1 -0
  61. package/lib/runtime/patch.d.ts.map +1 -1
  62. package/lib/runtime/patch.js +2 -1
  63. package/lib/runtime/patch.js.map +1 -1
  64. package/lib/runtime/rpc-transport.d.ts +46 -0
  65. package/lib/runtime/rpc-transport.d.ts.map +1 -0
  66. package/lib/runtime/rpc-transport.js +82 -0
  67. package/lib/runtime/rpc-transport.js.map +1 -0
  68. package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -1
  69. package/lib/runtime/source-overlay/overlay-element.js +13 -3
  70. package/lib/runtime/source-overlay/overlay-element.js.map +1 -1
  71. package/lib/runtime/timeline/install.js +15 -4
  72. package/lib/runtime/timeline/install.js.map +1 -1
  73. package/lib/runtime/timeline/public-api.d.ts.map +1 -1
  74. package/lib/runtime/timeline/public-api.js +11 -3
  75. package/lib/runtime/timeline/public-api.js.map +1 -1
  76. package/lib/runtime/timeline/transport.d.ts +6 -9
  77. package/lib/runtime/timeline/transport.d.ts.map +1 -1
  78. package/lib/runtime/timeline/transport.js.map +1 -1
  79. package/lib/timeline/filter.d.ts +38 -0
  80. package/lib/timeline/filter.d.ts.map +1 -0
  81. package/lib/timeline/filter.js +44 -0
  82. package/lib/timeline/filter.js.map +1 -0
  83. package/lib/timeline/tracks.d.ts +113 -0
  84. package/lib/timeline/tracks.d.ts.map +1 -0
  85. package/lib/timeline/tracks.js +168 -0
  86. package/lib/timeline/tracks.js.map +1 -0
  87. package/package.json +6 -1
  88. package/types/timeline.d.ts +38 -0
  89. package/types/timeline.d.ts.map +1 -1
  90. package/types/timeline.js +2 -0
  91. package/types/timeline.js.map +1 -1
  92. package/dist/client/assets/index-DVe6M4HV.js.map +0 -1
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import type { PageTransport } from './page-channel.js';
7
+ /** The slice of a scoped devframe client the transport uses. */
8
+ export interface PageRpc {
9
+ callEvent(method: string, ...args: unknown[]): void;
10
+ register(fn: {
11
+ name: string;
12
+ type: 'event';
13
+ handler: (...args: any[]) => void;
14
+ }): void;
15
+ }
16
+ /**
17
+ * A {@link PageTransport} over a devframe RPC client: `send` becomes a
18
+ * `page-send` event, and `page-receive` events fan out to the listeners
19
+ * registered with `on`.
20
+ */
21
+ export declare const createRpcTransport: (rpc: PageRpc) => PageTransport;
22
+ export interface ConnectOptions {
23
+ /**
24
+ * A bearer token the server already trusts. Without one the client falls
25
+ * back to devframe's own flow (a stored token, a magic-link code in the URL,
26
+ * or a prompt for the one-time code the server prints) unless the server was
27
+ * started with `--no-auth`.
28
+ */
29
+ authToken?: string;
30
+ }
31
+ /**
32
+ * Point this page's runtime at a standalone `lit-devtools dev` server.
33
+ *
34
+ * Resolves once the connection is trusted, after which the tree, inspector
35
+ * and timeline traffic that used to go to this page's own Vite server goes to
36
+ * `url` instead (the runtime announces itself again so the server can replay
37
+ * recording state). Returns a function that disconnects and hands the channel
38
+ * back to the carrier it replaced.
39
+ *
40
+ * The page's origin must be allowed to reach `url`; this does not set up
41
+ * cross-origin access.
42
+ *
43
+ * @param url Origin of the dev server, e.g. `http://localhost:5180/`.
44
+ */
45
+ export declare const connectToDevServer: (url: string, options?: ConnectOptions) => Promise<() => void>;
46
+ //# sourceMappingURL=rpc-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-transport.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/rpc-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmBH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAErD,gEAAgE;AAChE,MAAM,WAAW,OAAO;IACtB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACpD,QAAQ,CAAC,EAAE,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,OAAO,CAAC;QACd,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;KACnC,GAAG,IAAI,CAAC;CACV;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAS,OAAO,KAAG,aA4BjD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,QACxB,MAAM,YACF,cAAc,KACtB,OAAO,CAAC,MAAM,IAAI,CAepB,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * Carries the page channel over devframe RPC to a standalone
8
+ * `lit-devtools dev` server, so a page that is not served by a DevTools-enabled
9
+ * Vite dev server can still feed the panel. The server half is
10
+ * `devframe/rpc-source.ts`.
11
+ *
12
+ * Opt-in and explicit: nothing connects until {@link connectToDevServer} is
13
+ * called, and `devframe/client` is only imported then, so a page that never
14
+ * asks pays nothing.
15
+ */
16
+ import {
17
+ LIT_DEVFRAME_ID,
18
+ RPC_PAGE_RECEIVE,
19
+ RPC_PAGE_SEND,
20
+ } from '../devframe/protocol.js';
21
+ import {pageChannel} from './page-channel.js';
22
+ /**
23
+ * A {@link PageTransport} over a devframe RPC client: `send` becomes a
24
+ * `page-send` event, and `page-receive` events fan out to the listeners
25
+ * registered with `on`.
26
+ */
27
+ export const createRpcTransport = (rpc) => {
28
+ const listeners = new Map();
29
+ rpc.register({
30
+ name: RPC_PAGE_RECEIVE,
31
+ type: 'event',
32
+ handler: (channel, data) => {
33
+ for (const listener of listeners.get(channel) ?? []) {
34
+ try {
35
+ listener(data);
36
+ } catch (error) {
37
+ console.error(`[lit-devtools] listener for ${channel} threw`, error);
38
+ }
39
+ }
40
+ },
41
+ });
42
+ return {
43
+ send(channel, data) {
44
+ rpc.callEvent(RPC_PAGE_SEND, channel, data);
45
+ },
46
+ on(channel, handler) {
47
+ let set = listeners.get(channel);
48
+ if (set === undefined) listeners.set(channel, (set = new Set()));
49
+ set.add(handler);
50
+ return () => void set.delete(handler);
51
+ },
52
+ };
53
+ };
54
+ /**
55
+ * Point this page's runtime at a standalone `lit-devtools dev` server.
56
+ *
57
+ * Resolves once the connection is trusted, after which the tree, inspector
58
+ * and timeline traffic that used to go to this page's own Vite server goes to
59
+ * `url` instead (the runtime announces itself again so the server can replay
60
+ * recording state). Returns a function that disconnects and hands the channel
61
+ * back to the carrier it replaced.
62
+ *
63
+ * The page's origin must be allowed to reach `url`; this does not set up
64
+ * cross-origin access.
65
+ *
66
+ * @param url Origin of the dev server, e.g. `http://localhost:5180/`.
67
+ */
68
+ export const connectToDevServer = async (url, options = {}) => {
69
+ const {getDevframeRpcClient} = await import('devframe/client');
70
+ const client = await getDevframeRpcClient({
71
+ baseURL: url,
72
+ authToken: options.authToken,
73
+ });
74
+ await client.ensureTrusted();
75
+ const previous = pageChannel.transport;
76
+ pageChannel.attach(createRpcTransport(client.scope(LIT_DEVFRAME_ID).rpc));
77
+ return () => {
78
+ client.close?.();
79
+ if (previous !== undefined) pageChannel.attach(previous);
80
+ };
81
+ };
82
+ //# sourceMappingURL=rpc-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-transport.js","sourceRoot":"","sources":["../../src/lib/runtime/rpc-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAa9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAY,EAAiB,EAAE;IAChE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAwC,CAAC;IAElE,GAAG,CAAC,QAAQ,CAAC;QACX,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,CAAC,OAAe,EAAE,IAAc,EAAE,EAAE;YAC3C,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;gBACpD,IAAI,CAAC;oBACH,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACjB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,OAAO,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACvE,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC,C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CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Carries the page channel over devframe RPC to a standalone\n * `lit-devtools dev` server, so a page that is not served by a DevTools-enabled\n * Vite dev server can still feed the panel. The server half is\n * `devframe/rpc-source.ts`.\n *\n * Opt-in and explicit: nothing connects until {@link connectToDevServer} is\n * called, and `devframe/client` is only imported then, so a page that never\n * asks pays nothing.\n */\n\nimport {\n LIT_DEVFRAME_ID,\n RPC_PAGE_RECEIVE,\n RPC_PAGE_SEND,\n} from '../devframe/protocol.js';\nimport {pageChannel} from './page-channel.js';\nimport type {PageTransport} from './page-channel.js';\n\n/** The slice of a scoped devframe client the transport uses. */\nexport interface PageRpc {\n callEvent(method: string, ...args: unknown[]): void;\n register(fn: {\n name: string;\n type: 'event';\n handler: (...args: any[]) => void;\n }): void;\n}\n\n/**\n * A {@link PageTransport} over a devframe RPC client: `send` becomes a\n * `page-send` event, and `page-receive` events fan out to the listeners\n * registered with `on`.\n */\nexport const createRpcTransport = (rpc: PageRpc): PageTransport => {\n const listeners = new Map<string, Set<(data: unknown) => void>>();\n\n rpc.register({\n name: RPC_PAGE_RECEIVE,\n type: 'event',\n handler: (channel: string, data?: unknown) => {\n for (const listener of listeners.get(channel) ?? []) {\n try {\n listener(data);\n } catch (error) {\n console.error(`[lit-devtools] listener for ${channel} threw`, error);\n }\n }\n },\n });\n\n return {\n send(channel, data) {\n rpc.callEvent(RPC_PAGE_SEND, channel, data);\n },\n on(channel, handler) {\n let set = listeners.get(channel);\n if (set === undefined) listeners.set(channel, (set = new Set()));\n set.add(handler);\n return () => void set.delete(handler);\n },\n };\n};\n\nexport interface ConnectOptions {\n /**\n * A bearer token the server already trusts. Without one the client falls\n * back to devframe's own flow (a stored token, a magic-link code in the URL,\n * or a prompt for the one-time code the server prints) unless the server was\n * started with `--no-auth`.\n */\n authToken?: string;\n}\n\n/**\n * Point this page's runtime at a standalone `lit-devtools dev` server.\n *\n * Resolves once the connection is trusted, after which the tree, inspector\n * and timeline traffic that used to go to this page's own Vite server goes to\n * `url` instead (the runtime announces itself again so the server can replay\n * recording state). Returns a function that disconnects and hands the channel\n * back to the carrier it replaced.\n *\n * The page's origin must be allowed to reach `url`; this does not set up\n * cross-origin access.\n *\n * @param url Origin of the dev server, e.g. `http://localhost:5180/`.\n */\nexport const connectToDevServer = async (\n url: string,\n options: ConnectOptions = {}\n): Promise<() => void> => {\n const {getDevframeRpcClient} = await import('devframe/client');\n const client = await getDevframeRpcClient({\n baseURL: url,\n authToken: options.authToken,\n });\n await client.ensureTrusted();\n\n const previous = pageChannel.transport;\n pageChannel.attach(createRpcTransport(client.scope(LIT_DEVFRAME_ID).rpc));\n\n return () => {\n client.close?.();\n if (previous !== undefined) pageChannel.attach(previous);\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"overlay-element.d.ts","sourceRoot":"","sources":["../../../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;AA4YD,eAAO,MAAM,iBAAiB,iBACf,wBAAwB,SAMtC,CAAC;AAEF,eAAO,MAAM,mBAAmB,YAK/B,CAAC"}
1
+ {"version":3,"file":"overlay-element.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/source-overlay/overlay-element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,WAAW,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAoB9D,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;AAqZD,eAAO,MAAM,iBAAiB,iBACf,wBAAwB,SAMtC,CAAC;AAEF,eAAO,MAAM,mBAAmB,YAK/B,CAAC"}
@@ -13,6 +13,7 @@ import {buildSpotlightClipPath} from './mask-path.js';
13
13
  import {OVERLAY_HTML} from './template.js';
14
14
  import {observeEdgeInsets} from '../edge-panel.js';
15
15
  import {subscribeOverride} from '../overrides.js';
16
+ import {pageChannel} from '../page-channel.js';
16
17
  import {injectTokens} from '../../tokens.js';
17
18
  import {idOf} from '../timeline/identity.js';
18
19
  import {
@@ -73,7 +74,8 @@ class LitSourceOverlay extends HTMLElement {
73
74
  document.addEventListener('mousemove', this.#onTrackMouse, true);
74
75
  document.addEventListener('keydown', this.#onKeyDown, true);
75
76
  const hot = import.meta.hot;
76
- this.#hot = hot;
77
+ if (hot !== undefined) pageChannel.useViteHot(hot);
78
+ this.#hot = hot === undefined ? undefined : pageChannel;
77
79
  if (hot !== undefined && this.#hotOff === undefined) {
78
80
  // Removed again in disconnectedCallback, so a re-attached overlay
79
81
  // doesn't stack duplicates and a detached one stops reacting.
@@ -81,12 +83,15 @@ class LitSourceOverlay extends HTMLElement {
81
83
  ['vite:beforeFullReload', () => this.deactivate()],
82
84
  ['vite:ws:disconnect', () => (this.#connected = false)],
83
85
  ['vite:ws:connect', () => (this.#connected = true)],
84
- // Toggle from the Vite DevTools command/shortcut (handler runs server-side).
85
- [INSPECT_OVERLAY_TOGGLE_CHANNEL, () => this.toggle()],
86
86
  ];
87
87
  for (const [event, cb] of handlers) hot.on(event, cb);
88
+ // Toggle from the Vite DevTools command/shortcut (handler runs server-side).
89
+ const offToggle = pageChannel.on(INSPECT_OVERLAY_TOGGLE_CHANNEL, () =>
90
+ this.toggle()
91
+ );
88
92
  this.#hotOff = () => {
89
93
  for (const [event, cb] of handlers) hot.off(event, cb);
94
+ offToggle();
90
95
  };
91
96
  }
92
97
  // Keep the (bottom-fixed) tooltip clear of the Vite DevTools edge panel.
@@ -177,6 +182,11 @@ class LitSourceOverlay extends HTMLElement {
177
182
  file: path,
178
183
  line: String(lineNumber),
179
184
  });
185
+ // Name the editor the developer picked (config, env or the panel's
186
+ // override) so the server opens that one; custom editors and an unset
187
+ // choice send nothing and the server auto-detects.
188
+ const {editor} = this.#options;
189
+ if (typeof editor === 'string') params.set('editor', editor);
180
190
  const res = await fetch(`${endpoint}?${params.toString()}`);
181
191
  if (res.ok) return;
182
192
  } catch {
@@ -1 +1 @@
1
- {"version":3,"file":"overlay-element.js","sourceRoot":"","sources":["../../../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,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AW;QAAE,OAAO;IAC1C,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAqB,CAAC;IAC5E,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAC/B,oBAAoB,CACM,CAAC;IAC7B,EAAE,EAAE,MAAM,EAAE,CAAC;AACf,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type {ElementInfo, EditorConfig} from '../../types.js';\nimport {BUILTIN_EDITORS, resolveEditor} from './editors.js';\nimport {\n defaultResolver,\n findSourceAtPoint,\n findSourceHost,\n type ElementResolver,\n} from './source-host.js';\nimport {buildSpotlightClipPath} from './mask-path.js';\nimport {OVERLAY_HTML} from './template.js';\nimport {observeEdgeInsets} from '../edge-panel.js';\nimport {subscribeOverride} from '../overrides.js';\nimport {injectTokens} from '../../tokens.js';\nimport {idOf} from '../timeline/identity.js';\nimport {\n INSPECT_OVERLAY_TOGGLE_CHANNEL,\n INSPECT_DATA_CHANNEL,\n} from '../../../types/inspector.js';\n\nexport interface SourceOverlayInitOptions {\n key?: string;\n editor?: EditorConfig | string;\n workspaceRoot?: string;\n throttleMs?: number;\n exclude?: (el: Element) => boolean;\n onSelect?: (info: ElementInfo) => void;\n openInEditorPath?: string;\n}\n\nclass LitSourceOverlay extends HTMLElement {\n #active = false;\n #hot: {send: (event: string, data: unknown) => void} | undefined;\n #options: SourceOverlayInitOptions = {};\n #editor: EditorConfig = BUILTIN_EDITORS.vscode;\n #resolver: ElementResolver = defaultResolver;\n #dialog: HTMLDialogElement;\n #mask: HTMLElement;\n #highlight: HTMLElement;\n #tooltip: HTMLElement;\n #tag: HTMLElement;\n #path: HTMLElement;\n #info: ElementInfo | null = null;\n #targetEl: Element | null = null;\n #throttleTimer: ReturnType<typeof setTimeout> | undefined;\n #scrollTimer: ReturnType<typeof setTimeout> | undefined;\n #resizeObserver: ResizeObserver | undefined;\n #cursorStyle: HTMLStyleElement | null = null;\n // Whether the Vite HMR WebSocket is currently connected. Used to suppress the\n // editor-URL-scheme fallback once the dev server is gone — otherwise a failed\n // open-in-editor fetch would navigate the tab to `vscode://…`.\n #connected = true;\n #lastMouseX = 0;\n #lastMouseY = 0;\n #edgeDispose: (() => void) | undefined;\n #overrideSubscribed = false;\n #hotOff: (() => void) | undefined;\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 void 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 off: (event: string, cb: (data?: unknown) => void) => void;\n send: (event: string, data: unknown) => void;\n };\n }\n ).hot;\n this.#hot = hot;\n if (hot !== undefined && this.#hotOff === undefined) {\n // Removed again in disconnectedCallback, so a re-attached overlay\n // doesn't stack duplicates and a detached one stops reacting.\n const handlers: Array<[string, (data?: unknown) => void]> = [\n ['vite:beforeFullReload', () => this.deactivate()],\n ['vite:ws:disconnect', () => (this.#connected = false)],\n ['vite:ws:connect', () => (this.#connected = true)],\n // Toggle from the Vite DevTools command/shortcut (handler runs server-side).\n [INSPECT_OVERLAY_TOGGLE_CHANNEL, () => this.toggle()],\n ];\n for (const [event, cb] of handlers) hot.on(event, cb);\n this.#hotOff = () => {\n for (const [event, cb] of handlers) hot.off(event, cb);\n };\n }\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 this.#hotOff?.();\n this.#hotOff = 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 void this.#resolveAt(this.#lastMouseX, this.#lastMouseY);\n }\n\n deactivate() {\n if (!this.#active) return;\n this.#active = false;\n this.#dialog.close();\n this.#mask.style.background = 'rgba(0,0,0,0)';\n this.#cursorStyle?.remove();\n document.removeEventListener('mousemove', this.#onMouseMove, true);\n document.removeEventListener('click', this.#onClick, true);\n window.removeEventListener('scroll', this.#onScrollOrResize);\n window.removeEventListener('resize', this.#onScrollOrResize);\n if (this.#throttleTimer !== undefined) {\n clearTimeout(this.#throttleTimer);\n this.#throttleTimer = undefined;\n }\n if (this.#scrollTimer !== undefined) {\n clearTimeout(this.#scrollTimer);\n this.#scrollTimer = undefined;\n }\n this.#clearTarget();\n }\n\n toggle() {\n if (this.#active) this.deactivate();\n else this.activate();\n }\n\n #normalizePath(filePath: string): string {\n const root = this.#options.workspaceRoot;\n if (root !== undefined && filePath.startsWith(root)) {\n const rest = filePath.slice(root.length);\n return rest.startsWith('/') ? rest.slice(1) : rest;\n }\n return filePath;\n }\n\n async #openInEditor(filePath: string, lineNumber: number) {\n const path = this.#normalizePath(filePath);\n const endpoint = this.#options.openInEditorPath ?? '/__lit-open-in-editor';\n try {\n const params = new URLSearchParams({\n file: path,\n line: String(lineNumber),\n });\n const res = await fetch(`${endpoint}?${params.toString()}`);\n if (res.ok) return;\n } catch {\n // Fall back to editor URL schemes (e.g. StackBlitz previews).\n }\n // Skip the URL-scheme fallback when the dev server is gone: a fetch failure\n // there means \"server quit\", not \"no endpoint\", and navigating the tab to\n // `vscode://…` on shutdown is jarring and unwanted.\n if (!this.#connected) return;\n window.open(this.#editor.url(path, lineNumber), '_self');\n }\n\n #updateHighlightRect() {\n if (this.#targetEl === null) return;\n const rect = this.#targetEl.getBoundingClientRect();\n const raw = getComputedStyle(this)\n .getPropertyValue('--lit-devtools-radius')\n .trim();\n const r = parseFloat(raw) || 6;\n // The tinted box hugs the element's exact rect — that's the boundary being\n // picked; only the spotlight cutout gets the breathing room of `r`.\n this.#highlight.style.display = 'block';\n this.#highlight.style.left = `${rect.left}px`;\n this.#highlight.style.top = `${rect.top}px`;\n this.#highlight.style.width = `${rect.width}px`;\n this.#highlight.style.height = `${rect.height}px`;\n this.#mask.style.clipPath = buildSpotlightClipPath(\n rect.left - r,\n rect.top - r,\n rect.width + 2 * r,\n rect.height + 2 * r,\n r\n );\n }\n\n #showTooltip() {\n if (this.#info === null) return;\n this.#tag.textContent = `<${this.#info.tagName}>`;\n this.#path.textContent = `${this.#normalizePath(this.#info.source.filePath)}:${this.#info.source.lineNumber}`;\n this.#tooltip.style.display = 'flex';\n }\n\n #clearTarget() {\n this.#targetEl = null;\n this.#info = null;\n this.#highlight.style.display = 'none';\n this.#highlight.style.left = '0';\n this.#highlight.style.top = '0';\n this.#highlight.style.width = '0';\n this.#highlight.style.height = '0';\n this.#mask.style.clipPath = 'none';\n this.#tooltip.style.display = 'none';\n if (this.#resizeObserver !== undefined) {\n this.#resizeObserver.disconnect();\n this.#resizeObserver = undefined;\n }\n }\n\n #shouldSkip(el: Element): boolean {\n if (el === this.#dialog || this.#dialog.contains(el)) return true;\n if (el.tagName === 'IFRAME') return true;\n // Never target devtools' own injected elements (indicator, overlay).\n const tag = el.tagName.toLowerCase();\n if (tag === 'lit-source-overlay' || tag.startsWith('lit-devtools-')) {\n return true;\n }\n const exclude = this.#options.exclude;\n return exclude !== undefined && exclude(el);\n }\n\n async #resolveAt(x: number, y: number) {\n this.#lastMouseX = x;\n this.#lastMouseY = y;\n const el = findSourceAtPoint(x, y, this.#dialog);\n if (el === null || this.#shouldSkip(el)) {\n this.#clearTarget();\n return;\n }\n const host = findSourceHost(el);\n if (host === null) {\n this.#clearTarget();\n return;\n }\n if (host === this.#targetEl && this.#info !== null) {\n this.#updateHighlightRect();\n return;\n }\n this.#targetEl = host;\n if (this.#resizeObserver === undefined) {\n this.#resizeObserver = new ResizeObserver(() =>\n this.#updateHighlightRect()\n );\n } else {\n this.#resizeObserver.disconnect();\n }\n this.#resizeObserver.observe(host);\n const resolved = await this.#resolver.resolveElementInfo(el);\n if (resolved === null) {\n this.#clearTarget();\n return;\n }\n this.#info = resolved;\n this.#updateHighlightRect();\n this.#showTooltip();\n }\n\n #onTrackMouse = (event: MouseEvent) => {\n this.#lastMouseX = event.clientX;\n this.#lastMouseY = event.clientY;\n };\n\n #onKeyDown = (event: KeyboardEvent) => {\n if ((event.metaKey || event.ctrlKey) && event.shiftKey && !event.altKey) {\n const pressed = event.key.toLowerCase();\n const hotkey = (this.#options.key ?? 's').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 void 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 void 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 void ctx?.docks?.switchEntry?.('lit-devtools');\n } catch {\n // Not running inside the DevTools shell — ignore.\n }\n }\n\n #pointInTooltip(x: number, y: number): boolean {\n if (this.#tooltip.style.display === 'none') return false;\n const r = this.#tooltip.getBoundingClientRect();\n return x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;\n }\n\n #onClick = (event: MouseEvent) => {\n if (!this.#active || this.#info === null) return;\n // Clicks on the tooltip panel are handled by its own buttons (open/copy).\n // The overlay's shadow root is closed, so we detect this by hit-rect rather\n // than inspecting the event path, and let the event reach those buttons.\n if (this.#pointInTooltip(event.clientX, event.clientY)) return;\n event.preventDefault();\n event.stopPropagation();\n this.#select(this.#info, event.metaKey || event.ctrlKey);\n };\n\n #onScrollOrResize = () => {\n if (this.#scrollTimer !== undefined) clearTimeout(this.#scrollTimer);\n this.#scrollTimer = setTimeout(() => {\n this.#scrollTimer = undefined;\n if (this.#targetEl !== null) {\n this.#updateHighlightRect();\n }\n }, 50);\n };\n}\n\ncustomElements.define('lit-source-overlay', LitSourceOverlay);\n\nexport const initSourceOverlay = (\n initOptions: SourceOverlayInitOptions = {}\n) => {\n if (typeof window === 'undefined') return;\n const el = document.createElement('lit-source-overlay') as LitSourceOverlay;\n el.configure(initOptions);\n document.body.append(el);\n};\n\nexport const toggleSourceOverlay = () => {\n const el = document.querySelector(\n 'lit-source-overlay'\n ) as LitSourceOverlay | null;\n el?.toggle();\n};\n"]}
1
+ {"version":3,"file":"overlay-element.js","sourceRoot":"","sources":["../../../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,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAC/C,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,CAAiC;IACrC,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,8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,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 {pageChannel} from '../page-channel.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: typeof pageChannel | 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 #hotOff: (() => void) | undefined;\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 void 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 off: (event: string, cb: (data?: unknown) => void) => void;\n send: (event: string, data: unknown) => void;\n };\n }\n ).hot;\n if (hot !== undefined) pageChannel.useViteHot(hot);\n this.#hot = hot === undefined ? undefined : pageChannel;\n if (hot !== undefined && this.#hotOff === undefined) {\n // Removed again in disconnectedCallback, so a re-attached overlay\n // doesn't stack duplicates and a detached one stops reacting.\n const handlers: Array<[string, (data?: unknown) => void]> = [\n ['vite:beforeFullReload', () => this.deactivate()],\n ['vite:ws:disconnect', () => (this.#connected = false)],\n ['vite:ws:connect', () => (this.#connected = true)],\n ];\n for (const [event, cb] of handlers) hot.on(event, cb);\n // Toggle from the Vite DevTools command/shortcut (handler runs server-side).\n const offToggle = pageChannel.on(INSPECT_OVERLAY_TOGGLE_CHANNEL, () =>\n this.toggle()\n );\n this.#hotOff = () => {\n for (const [event, cb] of handlers) hot.off(event, cb);\n offToggle();\n };\n }\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 this.#hotOff?.();\n this.#hotOff = 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 void 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 // Name the editor the developer picked (config, env or the panel's\n // override) so the server opens that one; custom editors and an unset\n // choice send nothing and the server auto-detects.\n const {editor} = this.#options;\n if (typeof editor === 'string') params.set('editor', editor);\n const res = await fetch(`${endpoint}?${params.toString()}`);\n if (res.ok) return;\n } catch {\n // Fall back to editor URL schemes (e.g. StackBlitz previews).\n }\n // Skip the URL-scheme fallback when the dev server is gone: a fetch failure\n // there means \"server quit\", not \"no endpoint\", and navigating the tab to\n // `vscode://…` on shutdown is jarring and unwanted.\n if (!this.#connected) return;\n window.open(this.#editor.url(path, lineNumber), '_self');\n }\n\n #updateHighlightRect() {\n if (this.#targetEl === null) return;\n const rect = this.#targetEl.getBoundingClientRect();\n const raw = getComputedStyle(this)\n .getPropertyValue('--lit-devtools-radius')\n .trim();\n const r = parseFloat(raw) || 6;\n // The tinted box hugs the element's exact rect — that's the boundary being\n // picked; only the spotlight cutout gets the breathing room of `r`.\n this.#highlight.style.display = 'block';\n this.#highlight.style.left = `${rect.left}px`;\n this.#highlight.style.top = `${rect.top}px`;\n this.#highlight.style.width = `${rect.width}px`;\n this.#highlight.style.height = `${rect.height}px`;\n this.#mask.style.clipPath = buildSpotlightClipPath(\n rect.left - r,\n rect.top - r,\n rect.width + 2 * r,\n rect.height + 2 * r,\n r\n );\n }\n\n #showTooltip() {\n if (this.#info === null) return;\n this.#tag.textContent = `<${this.#info.tagName}>`;\n this.#path.textContent = `${this.#normalizePath(this.#info.source.filePath)}:${this.#info.source.lineNumber}`;\n this.#tooltip.style.display = 'flex';\n }\n\n #clearTarget() {\n this.#targetEl = null;\n this.#info = null;\n this.#highlight.style.display = 'none';\n this.#highlight.style.left = '0';\n this.#highlight.style.top = '0';\n this.#highlight.style.width = '0';\n this.#highlight.style.height = '0';\n this.#mask.style.clipPath = 'none';\n this.#tooltip.style.display = 'none';\n if (this.#resizeObserver !== undefined) {\n this.#resizeObserver.disconnect();\n this.#resizeObserver = undefined;\n }\n }\n\n #shouldSkip(el: Element): boolean {\n if (el === this.#dialog || this.#dialog.contains(el)) return true;\n if (el.tagName === 'IFRAME') return true;\n // Never target devtools' own injected elements (indicator, overlay).\n const tag = el.tagName.toLowerCase();\n if (tag === 'lit-source-overlay' || tag.startsWith('lit-devtools-')) {\n return true;\n }\n const exclude = this.#options.exclude;\n return exclude !== undefined && exclude(el);\n }\n\n async #resolveAt(x: number, y: number) {\n this.#lastMouseX = x;\n this.#lastMouseY = y;\n const el = findSourceAtPoint(x, y, this.#dialog);\n if (el === null || this.#shouldSkip(el)) {\n this.#clearTarget();\n return;\n }\n const host = findSourceHost(el);\n if (host === null) {\n this.#clearTarget();\n return;\n }\n if (host === this.#targetEl && this.#info !== null) {\n this.#updateHighlightRect();\n return;\n }\n this.#targetEl = host;\n if (this.#resizeObserver === undefined) {\n this.#resizeObserver = new ResizeObserver(() =>\n this.#updateHighlightRect()\n );\n } else {\n this.#resizeObserver.disconnect();\n }\n this.#resizeObserver.observe(host);\n const resolved = await this.#resolver.resolveElementInfo(el);\n if (resolved === null) {\n this.#clearTarget();\n return;\n }\n this.#info = resolved;\n this.#updateHighlightRect();\n this.#showTooltip();\n }\n\n #onTrackMouse = (event: MouseEvent) => {\n this.#lastMouseX = event.clientX;\n this.#lastMouseY = event.clientY;\n };\n\n #onKeyDown = (event: KeyboardEvent) => {\n if ((event.metaKey || event.ctrlKey) && event.shiftKey && !event.altKey) {\n const pressed = event.key.toLowerCase();\n const hotkey = (this.#options.key ?? 's').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 void 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 void 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 void 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"]}
@@ -20,6 +20,7 @@ import {installRenderLayer, setRenderDebugEnabled} from './render.js';
20
20
  import {installMouseLayer, installKeyboardLayer} from './input.js';
21
21
  import {flashUpdate, setFlashEnabled, setFlashRamp} from './flash.js';
22
22
  import {subscribeOverride} from '../overrides.js';
23
+ import {pageChannel} from '../page-channel.js';
23
24
  // ---------------------------------------------------------------------------
24
25
  // Recording state — written by the panel toggle, read by all capture layers.
25
26
  // ---------------------------------------------------------------------------
@@ -57,15 +58,21 @@ installKeyboardLayer(emit, recording, keyboardEnabled);
57
58
  // it's a page-side visual the panel toggles as a preference, so it follows the
58
59
  // settings override (read at boot, pushed live) rather than the layer state.
59
60
  setUpdateHook(flashUpdate);
61
+ // ---------------------------------------------------------------------------
62
+ // Page channel wiring
63
+ // ---------------------------------------------------------------------------
64
+ // `import.meta.hot` exists in Vite dev builds; the tsconfig lib set doesn't
65
+ // include it, so we access it through the un-typed global shape.
60
66
  const hot = import.meta.hot;
61
67
  subscribeOverride(hot, (o) => {
62
68
  setFlashEnabled(o.flashUpdates ?? false);
63
69
  setFlashRamp(o.flashUpdatesRamp ?? false);
64
70
  });
65
71
  if (hot !== undefined) {
66
- setHotClient(hot);
72
+ pageChannel.useViteHot(hot);
73
+ setHotClient(pageChannel);
67
74
  // Panel → app: toggle recording and per-layer flags.
68
- hot.on('lit:timeline:recording-changed', (data) => {
75
+ pageChannel.on('lit:timeline:recording-changed', (data) => {
69
76
  const next = data.recording;
70
77
  // Re-zero the timeline clock on the rising edge so event times read as
71
78
  // "ms since recording started" rather than since page load.
@@ -73,11 +80,15 @@ if (hot !== undefined) {
73
80
  state.recordingState = next;
74
81
  syncRenderDebug();
75
82
  });
76
- hot.on('lit:timeline:layers-changed', (data) => {
83
+ pageChannel.on('lit:timeline:layers-changed', (data) => {
77
84
  Object.assign(state, data);
78
85
  syncRenderDebug();
79
86
  });
80
87
  // Announce readiness so the panel can detect the runtime.
81
- hot.send('lit:timeline:runtime-ready', {});
88
+ pageChannel.send('lit:timeline:runtime-ready', {});
89
+ // A carrier attached later starts with no idea a runtime exists.
90
+ pageChannel.onAttach(() =>
91
+ pageChannel.send('lit:timeline:runtime-ready', {})
92
+ );
82
93
  }
83
94
  //# sourceMappingURL=install.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/install.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAC,IAAI,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,qBAAqB,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAC,MAAM,aAAa,CAAC;AACtE,OAAO,EAAC,iBAAiB,EAAE,oBAAoB,EAAC,MAAM,YAAY,CAAC;AACnE,OAAO,EAAC,WAAW,EAAE,eAAe,EAAE,YAAY,EAAC,MAAM,YAAY,CAAC;AACtE,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAGlD,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAE9E,MAAM,KAAK,GAAwB;IACjC,cAAc,EAAE,KAAK;IACrB,mBAAmB,EAAE,IAAI;IACzB,gBAAgB,EAAE,IAAI;IACtB,uBAAuB,EAAE,KAAK;IAC9B,iBAAiB,EAAE,KAAK;IACxB,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AAEF,MAAM,SAAS,GAAG,GAAY,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC;AACtD,MAAM,gBAAgB,GAAG,GAAY,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC;AAClE,MAAM,aAAa,GAAG,GAAY,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC;AAC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AI,EAAE,EAAE;QAChD,MAAM,IAAI,GAAI,IAA6B,CAAC,SAAS,CAAC;QACtD,uEAAuE;QACvE,4DAA4D;QAC5D,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc;YAAE,UAAU,EAAE,CAAC;QAChD,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;QAC5B,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,EAAE,CAAC,6BAA6B,EAAE,CAAC,IAAI,EAAE,EAAE;QAC7C,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAoC,CAAC,CAAC;QAC3D,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,0DAA0D;IAC1D,GAAG,CAAC,IAAI,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Timeline runtime install entry point.\n *\n * Injected by the plugin into the host page via `transformIndexHtml` when\n * `timeline: true` is set. Sets up all capture layers and wires them to the\n * transport.\n *\n * Recording starts off; the panel iframe toggles it via the Vite HMR channel\n * (Phase 0/1) or devframe shared state (Phase 2+).\n */\n\nimport {emit, setHotClient} from './transport.js';\nimport {resetClock} from './clock.js';\nimport {installLifecycleLayer, setUpdateHook} from './lifecycle.js';\nimport {installRenderLayer, setRenderDebugEnabled} from './render.js';\nimport {installMouseLayer, installKeyboardLayer} from './input.js';\nimport {flashUpdate, setFlashEnabled, setFlashRamp} from './flash.js';\nimport {subscribeOverride} from '../overrides.js';\nimport type {TimelineLayersState} from '../../../types/timeline.js';\n\n// ---------------------------------------------------------------------------\n// Recording state — written by the panel toggle, read by all capture layers.\n// ---------------------------------------------------------------------------\n\nconst state: TimelineLayersState = {\n recordingState: false,\n litLifecycleEnabled: true,\n litRenderEnabled: true,\n litRenderVerboseEnabled: false,\n mouseEventEnabled: false,\n keyboardEventEnabled: false,\n};\n\nconst recording = (): boolean => state.recordingState;\nconst lifecycleEnabled = (): boolean => state.litLifecycleEnabled;\nconst renderEnabled = (): boolean => state.litRenderEnabled;\nconst renderVerboseEnabled = (): boolean => state.litRenderVerboseEnabled;\nconst mouseEnabled = (): boolean => state.mouseEventEnabled;\nconst keyboardEnabled = (): boolean => state.keyboardEventEnabled;\n\n// Drive Lit's debug event flag from recording × (render-layer-enabled OR\n// verbose-layer-enabled) so lit-html only pays the per-render CustomEvent\n// dispatch cost while we're actually capturing one of the two render layers.\nconst syncRenderDebug = (): void => {\n setRenderDebugEnabled(\n state.recordingState &&\n (state.litRenderEnabled || state.litRenderVerboseEnabled)\n );\n};\n\n// ---------------------------------------------------------------------------\n// Capture layer installation\n// ---------------------------------------------------------------------------\n\ninstallLifecycleLayer(emit, recording, lifecycleEnabled);\ninstallRenderLayer(emit, recording, renderEnabled, renderVerboseEnabled);\ninstallMouseLayer(emit, recording, mouseEnabled);\ninstallKeyboardLayer(emit, recording, keyboardEnabled);\n\n// Flash-on-update rides the lifecycle wrappers but not the recording gate:\n// it's a page-side visual the panel toggles as a preference, so it follows the\n// settings override (read at boot, pushed live) rather than the layer state.\nsetUpdateHook(flashUpdate);\n\n// ---------------------------------------------------------------------------\n// HMR channel wiring (Phase 0/1 transport)\n// ---------------------------------------------------------------------------\n\n// `import.meta.hot` exists in Vite dev builds; the tsconfig lib set doesn't\n// include it, so we access it through the un-typed global shape.\ntype ViteHot = {\n send: (event: string, data: unknown) => void;\n on: (event: string, handler: (data: unknown) => void) => void;\n};\nconst hot = (import.meta as {hot?: ViteHot}).hot;\n\nsubscribeOverride(hot, (o) => {\n setFlashEnabled(o.flashUpdates ?? false);\n setFlashRamp(o.flashUpdatesRamp ?? false);\n});\n\nif (hot !== undefined) {\n setHotClient(hot);\n\n // Panel → app: toggle recording and per-layer flags.\n hot.on('lit:timeline:recording-changed', (data) => {\n const next = (data as {recording: boolean}).recording;\n // Re-zero the timeline clock on the rising edge so event times read as\n // \"ms since recording started\" rather than since page load.\n if (next && !state.recordingState) resetClock();\n state.recordingState = next;\n syncRenderDebug();\n });\n\n hot.on('lit:timeline:layers-changed', (data) => {\n Object.assign(state, data as Partial<TimelineLayersState>);\n syncRenderDebug();\n });\n\n // Announce readiness so the panel can detect the runtime.\n hot.send('lit:timeline:runtime-ready', {});\n}\n"]}
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/install.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAC,IAAI,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,qBAAqB,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAC,MAAM,aAAa,CAAC;AACtE,OAAO,EAAC,iBAAiB,EAAE,oBAAoB,EAAC,MAAM,YAAY,CAAC;AACnE,OAAO,EAAC,WAAW,EAAE,eAAe,EAAE,YAAY,EAAC,MAAM,YAAY,CAAC;AACtE,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAI/C,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAE9E,MAAM,KAAK,GAAwB;IACjC,cAAc,EAAE,KAAK;IACrB,mBAAmB,EAAE,IAAI;IACzB,gBAAgB,EAAE,IAAI;IACtB,uBAAuB,EAAE,KAAK;IAC9B,iBAAiB,EAAE,KAAK;IACxB,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AAEF,MAAM,SAAS,GAAG,GAAY,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC;AACtD,MAAM,gBAAgB,GAAG,GAAY,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC;AAClE,MAAM,aAAa,GAAG,GAAY,EAAE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E,CAAC;IACtB,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC5B,YAAY,CAAC,WAAW,CAAC,CAAC;IAE1B,qDAAqD;IACrD,WAAW,CAAC,EAAE,CAAC,gCAAgC,EAAE,CAAC,IAAI,EAAE,EAAE;QACxD,MAAM,IAAI,GAAI,IAA6B,CAAC,SAAS,CAAC;QACtD,uEAAuE;QACvE,4DAA4D;QAC5D,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc;YAAE,UAAU,EAAE,CAAC;QAChD,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;QAC5B,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,WAAW,CAAC,EAAE,CAAC,6BAA6B,EAAE,CAAC,IAAI,EAAE,EAAE;QACrD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAoC,CAAC,CAAC;QAC3D,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,0DAA0D;IAC1D,WAAW,CAAC,IAAI,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAC;IACnD,iEAAiE;IACjE,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,CACxB,WAAW,CAAC,IAAI,CAAC,4BAA4B,EAAE,EAAE,CAAC,CACnD,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Timeline runtime install entry point.\n *\n * Injected by the plugin into the host page via `transformIndexHtml` when\n * `timeline: true` is set. Sets up all capture layers and wires them to the\n * transport.\n *\n * Recording starts off; the panel iframe toggles it via the Vite HMR channel\n * (Phase 0/1) or devframe shared state (Phase 2+).\n */\n\nimport {emit, setHotClient} from './transport.js';\nimport {resetClock} from './clock.js';\nimport {installLifecycleLayer, setUpdateHook} from './lifecycle.js';\nimport {installRenderLayer, setRenderDebugEnabled} from './render.js';\nimport {installMouseLayer, installKeyboardLayer} from './input.js';\nimport {flashUpdate, setFlashEnabled, setFlashRamp} from './flash.js';\nimport {subscribeOverride} from '../overrides.js';\nimport {pageChannel} from '../page-channel.js';\nimport type {ViteHotLike} from '../page-channel.js';\nimport type {TimelineLayersState} from '../../../types/timeline.js';\n\n// ---------------------------------------------------------------------------\n// Recording state — written by the panel toggle, read by all capture layers.\n// ---------------------------------------------------------------------------\n\nconst state: TimelineLayersState = {\n recordingState: false,\n litLifecycleEnabled: true,\n litRenderEnabled: true,\n litRenderVerboseEnabled: false,\n mouseEventEnabled: false,\n keyboardEventEnabled: false,\n};\n\nconst recording = (): boolean => state.recordingState;\nconst lifecycleEnabled = (): boolean => state.litLifecycleEnabled;\nconst renderEnabled = (): boolean => state.litRenderEnabled;\nconst renderVerboseEnabled = (): boolean => state.litRenderVerboseEnabled;\nconst mouseEnabled = (): boolean => state.mouseEventEnabled;\nconst keyboardEnabled = (): boolean => state.keyboardEventEnabled;\n\n// Drive Lit's debug event flag from recording × (render-layer-enabled OR\n// verbose-layer-enabled) so lit-html only pays the per-render CustomEvent\n// dispatch cost while we're actually capturing one of the two render layers.\nconst syncRenderDebug = (): void => {\n setRenderDebugEnabled(\n state.recordingState &&\n (state.litRenderEnabled || state.litRenderVerboseEnabled)\n );\n};\n\n// ---------------------------------------------------------------------------\n// Capture layer installation\n// ---------------------------------------------------------------------------\n\ninstallLifecycleLayer(emit, recording, lifecycleEnabled);\ninstallRenderLayer(emit, recording, renderEnabled, renderVerboseEnabled);\ninstallMouseLayer(emit, recording, mouseEnabled);\ninstallKeyboardLayer(emit, recording, keyboardEnabled);\n\n// Flash-on-update rides the lifecycle wrappers but not the recording gate:\n// it's a page-side visual the panel toggles as a preference, so it follows the\n// settings override (read at boot, pushed live) rather than the layer state.\nsetUpdateHook(flashUpdate);\n\n// ---------------------------------------------------------------------------\n// Page channel wiring\n// ---------------------------------------------------------------------------\n\n// `import.meta.hot` exists in Vite dev builds; the tsconfig lib set doesn't\n// include it, so we access it through the un-typed global shape.\nconst hot = (import.meta as {hot?: ViteHotLike}).hot;\n\nsubscribeOverride(hot, (o) => {\n setFlashEnabled(o.flashUpdates ?? false);\n setFlashRamp(o.flashUpdatesRamp ?? false);\n});\n\nif (hot !== undefined) {\n pageChannel.useViteHot(hot);\n setHotClient(pageChannel);\n\n // Panel → app: toggle recording and per-layer flags.\n pageChannel.on('lit:timeline:recording-changed', (data) => {\n const next = (data as {recording: boolean}).recording;\n // Re-zero the timeline clock on the rising edge so event times read as\n // \"ms since recording started\" rather than since page load.\n if (next && !state.recordingState) resetClock();\n state.recordingState = next;\n syncRenderDebug();\n });\n\n pageChannel.on('lit:timeline:layers-changed', (data) => {\n Object.assign(state, data as Partial<TimelineLayersState>);\n syncRenderDebug();\n });\n\n // Announce readiness so the panel can detect the runtime.\n pageChannel.send('lit:timeline:runtime-ready', {});\n // A carrier attached later starts with no idea a runtime exists.\n pageChannel.onAttach(() =>\n pageChannel.send('lit:timeline:runtime-ready', {})\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/public-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAE7E,YAAY,EAAC,aAAa,EAAE,aAAa,EAAC,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,UAAW,aAAa,KAAG,IAEvD,CAAC;AAIF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,UAAW,aAAa,KAAG,IAOvD,CAAC"}
1
+ {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/public-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAE7E,YAAY,EAAC,aAAa,EAAE,aAAa,EAAC,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,UAAW,aAAa,KAAG,IAEvD,CAAC;AAYF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,UAAW,aAAa,KAAG,IAMvD,CAAC"}
@@ -11,6 +11,7 @@
11
11
  * This module shares the same `transport.ts` instance as `install.ts`, so
12
12
  * events emitted here flow through the same batched HMR channel to the panel.
13
13
  */
14
+ import {pageChannel} from '../page-channel.js';
14
15
  import {emit, setHotClientCallback} from './transport.js';
15
16
  /**
16
17
  * Emit a custom timeline event from app code.
@@ -26,6 +27,14 @@ import {emit, setHotClientCallback} from './transport.js';
26
27
  export const addTimelineEvent = (event) => {
27
28
  emit(event);
28
29
  };
30
+ const announcedLayers = [];
31
+ // A carrier attached later (the dev server's own RPC link, say) never saw the
32
+ // layers registered before it, so they are announced to it again.
33
+ pageChannel.onAttach(() => {
34
+ for (const layer of announcedLayers) {
35
+ pageChannel.send('lit:timeline:custom-layer', {layer});
36
+ }
37
+ });
29
38
  /**
30
39
  * Register a custom timeline layer and announce it to the panel.
31
40
  *
@@ -35,9 +44,8 @@ export const addTimelineEvent = (event) => {
35
44
  */
36
45
  export const addTimelineLayer = (layer) => {
37
46
  const send = () => {
38
- import.meta.hot?.send('lit:timeline:custom-layer', {
39
- layer,
40
- });
47
+ announcedLayers.push(layer);
48
+ pageChannel.send('lit:timeline:custom-layer', {layer});
41
49
  };
42
50
  setHotClientCallback(send);
43
51
  };
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/public-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAC,IAAI,EAAE,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAK1D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAoB,EAAQ,EAAE;IAC7D,IAAI,CAAC,KAAK,CAAC,CAAC;AACd,CAAC,CAAC;AAIF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAoB,EAAQ,EAAE;IAC7D,MAAM,IAAI,GAAG,GAAS,EAAE;QACrB,OAAO,IAAwB,CAAC,GAAG,EAAE,IAAI,CAAC,2BAA2B,EAAE;YACtE,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC;IACF,oBAAoB,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Public timeline API — re-exported by the `virtual:lit-plugin/timeline`\n * virtual module so app code and other plugins can contribute events and\n * custom layers without reaching into plugin internals.\n *\n * This module shares the same `transport.ts` instance as `install.ts`, so\n * events emitted here flow through the same batched HMR channel to the panel.\n */\n\nimport {emit, setHotClientCallback} from './transport.js';\nimport type {TimelineEvent, TimelineLayer} from '../../../types/timeline.js';\n\nexport type {TimelineEvent, TimelineLayer};\n\n/**\n * Emit a custom timeline event from app code.\n *\n * The event is forwarded to the Timeline panel when recording is active.\n * Use a custom `layerId` registered with `addTimelineLayer`, or one of the\n * built-in layer ids (`'lit-lifecycle'`, `'lit-render'`,\n * `'lit-render-verbose'`, `'mouse'`, `'keyboard'`).\n *\n * No-ops in production (the HMR channel is absent; events are dropped in the\n * transport queue).\n */\nexport const addTimelineEvent = (event: TimelineEvent): void => {\n emit(event);\n};\n\ntype ViteHot = {send: (event: string, data: unknown) => void};\n\n/**\n * Register a custom timeline layer and announce it to the panel.\n *\n * The panel adds the layer to its toggle strip after the built-in layers.\n * The registration message is sent once on first call; duplicate ids are\n * ignored.\n */\nexport const addTimelineLayer = (layer: TimelineLayer): void => {\n const send = (): void => {\n (import.meta as {hot?: ViteHot}).hot?.send('lit:timeline:custom-layer', {\n layer,\n });\n };\n setHotClientCallback(send);\n};\n"]}
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/public-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAC,IAAI,EAAE,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAK1D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAoB,EAAQ,EAAE;IAC7D,IAAI,CAAC,KAAK,CAAC,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,eAAe,GAAoB,EAAE,CAAC;AAE5C,8EAA8E;AAC9E,kEAAkE;AAClE,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE;IACxB,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;QACpC,WAAW,CAAC,IAAI,CAAC,2BAA2B,EAAE,EAAC,KAAK,EAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAoB,EAAQ,EAAE;IAC7D,MAAM,IAAI,GAAG,GAAS,EAAE;QACtB,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5B,WAAW,CAAC,IAAI,CAAC,2BAA2B,EAAE,EAAC,KAAK,EAAC,CAAC,CAAC;IACzD,CAAC,CAAC;IACF,oBAAoB,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Public timeline API — re-exported by the `virtual:lit-plugin/timeline`\n * virtual module so app code and other plugins can contribute events and\n * custom layers without reaching into plugin internals.\n *\n * This module shares the same `transport.ts` instance as `install.ts`, so\n * events emitted here flow through the same batched HMR channel to the panel.\n */\n\nimport {pageChannel} from '../page-channel.js';\nimport {emit, setHotClientCallback} from './transport.js';\nimport type {TimelineEvent, TimelineLayer} from '../../../types/timeline.js';\n\nexport type {TimelineEvent, TimelineLayer};\n\n/**\n * Emit a custom timeline event from app code.\n *\n * The event is forwarded to the Timeline panel when recording is active.\n * Use a custom `layerId` registered with `addTimelineLayer`, or one of the\n * built-in layer ids (`'lit-lifecycle'`, `'lit-render'`,\n * `'lit-render-verbose'`, `'mouse'`, `'keyboard'`).\n *\n * No-ops in production (the HMR channel is absent; events are dropped in the\n * transport queue).\n */\nexport const addTimelineEvent = (event: TimelineEvent): void => {\n emit(event);\n};\n\nconst announcedLayers: TimelineLayer[] = [];\n\n// A carrier attached later (the dev server's own RPC link, say) never saw the\n// layers registered before it, so they are announced to it again.\npageChannel.onAttach(() => {\n for (const layer of announcedLayers) {\n pageChannel.send('lit:timeline:custom-layer', {layer});\n }\n});\n\n/**\n * Register a custom timeline layer and announce it to the panel.\n *\n * The panel adds the layer to its toggle strip after the built-in layers.\n * The registration message is sent once on first call; duplicate ids are\n * ignored.\n */\nexport const addTimelineLayer = (layer: TimelineLayer): void => {\n const send = (): void => {\n announcedLayers.push(layer);\n pageChannel.send('lit:timeline:custom-layer', {layer});\n };\n setHotClientCallback(send);\n};\n"]}
@@ -6,21 +6,18 @@
6
6
  /**
7
7
  * Buffered transport for timeline events.
8
8
  *
9
- * Phase 0/1: forwards events over Vite's HMR WebSocket channel
10
- * (`import.meta.hot.send`). This avoids the need for a separate devframe
11
- * RPC connection in early phases and works with any Vite dev server.
12
- *
13
- * Phase 2 migration: replace `sendViaHmr` with `sendViaRpc` when the
14
- * devframe RPC client is available (injected by the panel's clientScript).
9
+ * Forwards events over the page channel (`../page-channel.ts`), which is
10
+ * Vite's HMR WebSocket by default and can be pointed at a standalone
11
+ * devframe server instead. Which carrier is in use is not this module's
12
+ * concern.
15
13
  *
16
14
  * Batching: we coalesce events with `queueMicrotask` so a burst of
17
15
  * commit/set-part events from a single render doesn't hammer the channel
18
16
  * with one message per event.
19
17
  */
20
18
  import type { TimelineEvent } from '../../../types/timeline.js';
21
- type HotClient = {
22
- send: (event: string, data: unknown) => void;
23
- };
19
+ import type { PageTransport } from '../page-channel.js';
20
+ type HotClient = Pick<PageTransport, 'send'>;
24
21
  /**
25
22
  * Register the HMR hot client.
26
23
  * Called by install.ts after import.meta.hot check.
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAE9D,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C,CAAC;AAmBF;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAS,SAAS,KAAG,IAe7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,OAAQ,MAAM,IAAI,KAAG,IAMrD,CAAC;AAaF;;;;GAIG;AACH,eAAO,MAAM,IAAI,UAAW,aAAa,KAAG,IAc3C,CAAC"}
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEtD,KAAK,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAmB7C;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAS,SAAS,KAAG,IAe7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,OAAQ,MAAM,IAAI,KAAG,IAMrD,CAAC;AAaF;;;;GAIG;AACH,eAAO,MAAM,IAAI,UAAW,aAAa,KAAG,IAc3C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","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CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,CAAC;QACH,SAAS,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,kEAAkE;IACpE,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAoB,EAAQ,EAAE;IACjD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,uEAAuE;QACvE,wEAAwE;QACxE,IAAI,KAAK,CAAC,MAAM,GAAG,WAAW,EAAE,CAAC;YAC/B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO;IACT,CAAC;IACD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,CAAC;QACtB,cAAc,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;AACH,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Buffered transport for timeline events.\n *\n * Phase 0/1: forwards events over Vite's HMR WebSocket channel\n * (`import.meta.hot.send`). This avoids the need for a separate devframe\n * RPC connection in early phases and works with any Vite dev server.\n *\n * Phase 2 migration: replace `sendViaHmr` with `sendViaRpc` when the\n * devframe RPC client is available (injected by the panel's clientScript).\n *\n * Batching: we coalesce events with `queueMicrotask` so a burst of\n * commit/set-part events from a single render doesn't hammer the channel\n * with one message per event.\n */\n\nimport type {TimelineEvent} from '../../../types/timeline.js';\n\ntype HotClient = {\n send: (event: string, data: unknown) => void;\n};\n\nconst queue: TimelineEvent[] = [];\nlet flushScheduled = false;\nlet hotClient: HotClient | null = null;\n\n/**\n * Cap on events retained while no hot client is connected. Without a client\n * `flush()` cannot drain the queue, so an uncapped buffer would grow for the\n * whole session (in production, or before `install.ts` wires the client).\n * We keep only the most recent events; the retained tail flushes if a client\n * later connects.\n */\nconst MAX_PENDING = 1000;\n\n// Callbacks registered before the hot client was available (e.g. addTimelineLayer\n// called at module init time before install.ts has set the client).\nconst pendingCallbacks: Array<() => void> = [];\n\n/**\n * Register the HMR hot client.\n * Called by install.ts after import.meta.hot check.\n * Flushes any queued events and fires pending one-shot callbacks.\n */\nexport const setHotClient = (hot: HotClient): void => {\n hotClient = hot;\n // Drain any events that arrived before the client was wired.\n if (queue.length > 0 && !flushScheduled) {\n flushScheduled = true;\n queueMicrotask(flush);\n }\n // Fire one-shot callbacks (e.g. addTimelineLayer announcements).\n for (const cb of pendingCallbacks.splice(0)) {\n try {\n cb();\n } catch {\n // ignore\n }\n }\n};\n\n/**\n * Register a callback to be invoked once the HMR client is available.\n * If the client is already set the callback is fired on the next microtask.\n */\nexport const setHotClientCallback = (cb: () => void): void => {\n if (hotClient !== null) {\n queueMicrotask(cb);\n } else {\n pendingCallbacks.push(cb);\n }\n};\n\nconst flush = (): void => {\n flushScheduled = false;\n if (queue.length === 0 || hotClient === null) return;\n const batch = queue.splice(0);\n try {\n hotClient.send('lit:timeline:push-event', {events: batch});\n } catch {\n // HMR channel may be temporarily unavailable; events are dropped.\n }\n};\n\n/**\n * Enqueue a timeline event for forwarding to the Vite server.\n * Batches via microtask so a single synchronous render burst\n * doesn't send dozens of individual messages.\n */\nexport const emit = (event: TimelineEvent): void => {\n queue.push(event);\n if (hotClient === null) {\n // No consumer yet: bound the buffer instead of scheduling a flush that\n // would only no-op. `setHotClient` drains the retained tail on connect.\n if (queue.length > MAX_PENDING) {\n queue.splice(0, queue.length - MAX_PENDING);\n }\n return;\n }\n if (!flushScheduled) {\n flushScheduled = true;\n queueMicrotask(flush);\n }\n};\n"]}
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/transport.ts"],"names":[],"mappings":"A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,SAAS,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,kEAAkE;IACpE,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAoB,EAAQ,EAAE;IACjD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,uEAAuE;QACvE,wEAAwE;QACxE,IAAI,KAAK,CAAC,MAAM,GAAG,WAAW,EAAE,CAAC;YAC/B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO;IACT,CAAC;IACD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,CAAC;QACtB,cAAc,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;AACH,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Buffered transport for timeline events.\n *\n * Forwards events over the page channel (`../page-channel.ts`), which is\n * Vite's HMR WebSocket by default and can be pointed at a standalone\n * devframe server instead. Which carrier is in use is not this module's\n * concern.\n *\n * Batching: we coalesce events with `queueMicrotask` so a burst of\n * commit/set-part events from a single render doesn't hammer the channel\n * with one message per event.\n */\n\nimport type {TimelineEvent} from '../../../types/timeline.js';\nimport type {PageTransport} from '../page-channel.js';\n\ntype HotClient = Pick<PageTransport, 'send'>;\n\nconst queue: TimelineEvent[] = [];\nlet flushScheduled = false;\nlet hotClient: HotClient | null = null;\n\n/**\n * Cap on events retained while no hot client is connected. Without a client\n * `flush()` cannot drain the queue, so an uncapped buffer would grow for the\n * whole session (in production, or before `install.ts` wires the client).\n * We keep only the most recent events; the retained tail flushes if a client\n * later connects.\n */\nconst MAX_PENDING = 1000;\n\n// Callbacks registered before the hot client was available (e.g. addTimelineLayer\n// called at module init time before install.ts has set the client).\nconst pendingCallbacks: Array<() => void> = [];\n\n/**\n * Register the HMR hot client.\n * Called by install.ts after import.meta.hot check.\n * Flushes any queued events and fires pending one-shot callbacks.\n */\nexport const setHotClient = (hot: HotClient): void => {\n hotClient = hot;\n // Drain any events that arrived before the client was wired.\n if (queue.length > 0 && !flushScheduled) {\n flushScheduled = true;\n queueMicrotask(flush);\n }\n // Fire one-shot callbacks (e.g. addTimelineLayer announcements).\n for (const cb of pendingCallbacks.splice(0)) {\n try {\n cb();\n } catch {\n // ignore\n }\n }\n};\n\n/**\n * Register a callback to be invoked once the HMR client is available.\n * If the client is already set the callback is fired on the next microtask.\n */\nexport const setHotClientCallback = (cb: () => void): void => {\n if (hotClient !== null) {\n queueMicrotask(cb);\n } else {\n pendingCallbacks.push(cb);\n }\n};\n\nconst flush = (): void => {\n flushScheduled = false;\n if (queue.length === 0 || hotClient === null) return;\n const batch = queue.splice(0);\n try {\n hotClient.send('lit:timeline:push-event', {events: batch});\n } catch {\n // HMR channel may be temporarily unavailable; events are dropped.\n }\n};\n\n/**\n * Enqueue a timeline event for forwarding to the Vite server.\n * Batches via microtask so a single synchronous render burst\n * doesn't send dozens of individual messages.\n */\nexport const emit = (event: TimelineEvent): void => {\n queue.push(event);\n if (hotClient === null) {\n // No consumer yet: bound the buffer instead of scheduling a flush that\n // would only no-op. `setHotClient` drains the retained tail on connect.\n if (queue.length > MAX_PENDING) {\n queue.splice(0, queue.length - MAX_PENDING);\n }\n return;\n }\n if (!flushScheduled) {\n flushScheduled = true;\n queueMicrotask(flush);\n }\n};\n"]}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * The Timeline's element and regex filters, as pure functions.
8
+ *
9
+ * Both presentations (the list and the tracks) answer "show me only this
10
+ * element" or "only things matching /update/". The filter state therefore
11
+ * lives in `timeline-view` and each presentation applies it here, so the two
12
+ * cannot drift apart on what a match means.
13
+ */
14
+ import type { TimelineEvent } from '../../types/timeline.js';
15
+ import type { TimelineSpan } from './derive.js';
16
+ /**
17
+ * Compiles the regex box. An empty box matches everything. A pattern that
18
+ * does not compile (the user is mid-typing `foo(`) disables the filter rather
19
+ * than hiding every row, and is reported as `invalid` so the input can say so.
20
+ */
21
+ export declare const compileRegex: (source: string) => {
22
+ re: RegExp | null;
23
+ invalid: boolean;
24
+ };
25
+ /** Text the regex filter searches: element tag, name, subtitle and the
26
+ * changed property keys (the reason is worth searching for by name). */
27
+ export declare const spanHaystack: (span: TimelineSpan) => string;
28
+ /**
29
+ * Applies the element and regex filters. `re` comes from {@link compileRegex}
30
+ * so a caller filtering on every keystroke compiles once, not per span.
31
+ */
32
+ export declare const filterSpans: (spans: readonly TimelineSpan[], elementId: number | null, re: RegExp | null) => TimelineSpan[];
33
+ /** Distinct elements (by stable id) seen across the recorded events. */
34
+ export declare const listElements: (events: readonly TimelineEvent[]) => Array<{
35
+ id: number;
36
+ tag: string;
37
+ }>;
38
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/lib/timeline/filter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,YAAY,WACf,MAAM,KACb;IAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAOtC,CAAC;AAEF;yEACyE;AACzE,eAAO,MAAM,YAAY,SAAU,YAAY,KAAG,MAGnC,CAAC;AAEhB;;;GAGG;AACH,eAAO,MAAM,WAAW,UACf,SAAS,YAAY,EAAE,aACnB,MAAM,GAAG,IAAI,MACpB,MAAM,GAAG,IAAI,KAChB,YAAY,EAKZ,CAAC;AAEJ,wEAAwE;AACxE,eAAO,MAAM,YAAY,WACf,SAAS,aAAa,EAAE,KAC/B,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,CASjC,CAAC"}