@oddsquad/vite-plugin-lit 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/index.d.ts +3 -2
  2. package/index.d.ts.map +1 -1
  3. package/index.js +1 -1
  4. package/index.js.map +1 -1
  5. package/lib/color-scheme.d.ts +30 -0
  6. package/lib/color-scheme.d.ts.map +1 -0
  7. package/lib/color-scheme.js +41 -0
  8. package/lib/color-scheme.js.map +1 -0
  9. package/lib/icons.d.ts +18 -0
  10. package/lib/icons.d.ts.map +1 -0
  11. package/lib/icons.js +23 -0
  12. package/lib/icons.js.map +1 -0
  13. package/lib/plugin.d.ts +117 -6
  14. package/lib/plugin.d.ts.map +1 -1
  15. package/lib/plugin.js +596 -20
  16. package/lib/plugin.js.map +1 -1
  17. package/lib/runtime/css.d.ts +94 -0
  18. package/lib/runtime/css.d.ts.map +1 -0
  19. package/lib/runtime/css.js +112 -0
  20. package/lib/runtime/css.js.map +1 -0
  21. package/lib/runtime/edge-panel.d.ts +18 -0
  22. package/lib/runtime/edge-panel.d.ts.map +1 -0
  23. package/lib/runtime/edge-panel.js +130 -0
  24. package/lib/runtime/edge-panel.js.map +1 -0
  25. package/lib/runtime/fonts.d.ts +18 -0
  26. package/lib/runtime/fonts.d.ts.map +1 -0
  27. package/lib/runtime/fonts.js +18 -0
  28. package/lib/runtime/fonts.js.map +1 -0
  29. package/lib/runtime/indicator.d.ts +7 -0
  30. package/lib/runtime/indicator.d.ts.map +1 -0
  31. package/lib/runtime/indicator.js +141 -0
  32. package/lib/runtime/indicator.js.map +1 -0
  33. package/lib/runtime/inspector/collect.d.ts +17 -0
  34. package/lib/runtime/inspector/collect.d.ts.map +1 -0
  35. package/lib/runtime/inspector/collect.js +132 -0
  36. package/lib/runtime/inspector/collect.js.map +1 -0
  37. package/lib/runtime/inspector/install.d.ts +7 -0
  38. package/lib/runtime/inspector/install.d.ts.map +1 -0
  39. package/lib/runtime/inspector/install.js +204 -0
  40. package/lib/runtime/inspector/install.js.map +1 -0
  41. package/lib/runtime/inspector/serialize.d.ts +10 -0
  42. package/lib/runtime/inspector/serialize.d.ts.map +1 -0
  43. package/lib/runtime/inspector/serialize.js +133 -0
  44. package/lib/runtime/inspector/serialize.js.map +1 -0
  45. package/lib/runtime/intern.d.ts.map +1 -1
  46. package/lib/runtime/intern.js +1 -1
  47. package/lib/runtime/intern.js.map +1 -1
  48. package/lib/runtime/overrides.d.ts +25 -0
  49. package/lib/runtime/overrides.d.ts.map +1 -0
  50. package/lib/runtime/overrides.js +33 -0
  51. package/lib/runtime/overrides.js.map +1 -0
  52. package/lib/runtime/patch.d.ts +6 -15
  53. package/lib/runtime/patch.d.ts.map +1 -1
  54. package/lib/runtime/patch.js +81 -28
  55. package/lib/runtime/patch.js.map +1 -1
  56. package/lib/runtime/source-meta.d.ts +16 -0
  57. package/lib/runtime/source-meta.d.ts.map +1 -0
  58. package/lib/runtime/source-meta.js +8 -0
  59. package/lib/runtime/source-meta.js.map +1 -0
  60. package/lib/runtime/source-overlay/editors.d.ts +9 -0
  61. package/lib/runtime/source-overlay/editors.d.ts.map +1 -0
  62. package/lib/runtime/source-overlay/editors.js +40 -0
  63. package/lib/runtime/source-overlay/editors.js.map +1 -0
  64. package/lib/runtime/source-overlay/mask-path.d.ts +7 -0
  65. package/lib/runtime/source-overlay/mask-path.d.ts.map +1 -0
  66. package/lib/runtime/source-overlay/mask-path.js +26 -0
  67. package/lib/runtime/source-overlay/mask-path.js.map +1 -0
  68. package/lib/runtime/source-overlay/overlay-element.d.ts +18 -0
  69. package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -0
  70. package/lib/runtime/source-overlay/overlay-element.js +381 -0
  71. package/lib/runtime/source-overlay/overlay-element.js.map +1 -0
  72. package/lib/runtime/source-overlay/source-host.d.ts +14 -0
  73. package/lib/runtime/source-overlay/source-host.d.ts.map +1 -0
  74. package/lib/runtime/source-overlay/source-host.js +94 -0
  75. package/lib/runtime/source-overlay/source-host.js.map +1 -0
  76. package/lib/runtime/source-overlay/template.d.ts +7 -0
  77. package/lib/runtime/source-overlay/template.d.ts.map +1 -0
  78. package/lib/runtime/source-overlay/template.js +125 -0
  79. package/lib/runtime/source-overlay/template.js.map +1 -0
  80. package/lib/runtime/source-overlay.d.ts +7 -0
  81. package/lib/runtime/source-overlay.d.ts.map +1 -0
  82. package/lib/runtime/source-overlay.js +11 -0
  83. package/lib/runtime/source-overlay.js.map +1 -0
  84. package/lib/runtime/timeline/clock.d.ts +10 -0
  85. package/lib/runtime/timeline/clock.d.ts.map +1 -0
  86. package/lib/runtime/timeline/clock.js +22 -0
  87. package/lib/runtime/timeline/clock.js.map +1 -0
  88. package/lib/runtime/timeline/identity.d.ts +37 -0
  89. package/lib/runtime/timeline/identity.d.ts.map +1 -0
  90. package/lib/runtime/timeline/identity.js +73 -0
  91. package/lib/runtime/timeline/identity.js.map +1 -0
  92. package/lib/runtime/timeline/input.d.ts +16 -0
  93. package/lib/runtime/timeline/input.d.ts.map +1 -0
  94. package/lib/runtime/timeline/input.js +87 -0
  95. package/lib/runtime/timeline/input.js.map +1 -0
  96. package/lib/runtime/timeline/install.d.ts +7 -0
  97. package/lib/runtime/timeline/install.d.ts.map +1 -0
  98. package/lib/runtime/timeline/install.js +69 -0
  99. package/lib/runtime/timeline/install.js.map +1 -0
  100. package/lib/runtime/timeline/lifecycle.d.ts +27 -0
  101. package/lib/runtime/timeline/lifecycle.d.ts.map +1 -0
  102. package/lib/runtime/timeline/lifecycle.js +225 -0
  103. package/lib/runtime/timeline/lifecycle.js.map +1 -0
  104. package/lib/runtime/timeline/public-api.d.ts +28 -0
  105. package/lib/runtime/timeline/public-api.d.ts.map +1 -0
  106. package/lib/runtime/timeline/public-api.js +44 -0
  107. package/lib/runtime/timeline/public-api.js.map +1 -0
  108. package/lib/runtime/timeline/render.d.ts +39 -0
  109. package/lib/runtime/timeline/render.d.ts.map +1 -0
  110. package/lib/runtime/timeline/render.js +109 -0
  111. package/lib/runtime/timeline/render.js.map +1 -0
  112. package/lib/runtime/timeline/transport.d.ts +42 -0
  113. package/lib/runtime/timeline/transport.d.ts.map +1 -0
  114. package/lib/runtime/timeline/transport.js +86 -0
  115. package/lib/runtime/timeline/transport.js.map +1 -0
  116. package/lib/segmented-tabs.d.ts +33 -0
  117. package/lib/segmented-tabs.d.ts.map +1 -0
  118. package/lib/segmented-tabs.js +129 -0
  119. package/lib/segmented-tabs.js.map +1 -0
  120. package/lib/source-meta.d.ts +26 -0
  121. package/lib/source-meta.d.ts.map +1 -0
  122. package/lib/source-meta.js +129 -0
  123. package/lib/source-meta.js.map +1 -0
  124. package/lib/timeline-plugin.d.ts +72 -0
  125. package/lib/timeline-plugin.d.ts.map +1 -0
  126. package/lib/timeline-plugin.js +376 -0
  127. package/lib/timeline-plugin.js.map +1 -0
  128. package/lib/tokens.d.ts +38 -0
  129. package/lib/tokens.d.ts.map +1 -0
  130. package/lib/tokens.js +263 -0
  131. package/lib/tokens.js.map +1 -0
  132. package/lib/transform.d.ts +5 -5
  133. package/lib/transform.d.ts.map +1 -1
  134. package/lib/transform.js +3 -3
  135. package/lib/transform.js.map +1 -1
  136. package/lib/types.d.ts +34 -0
  137. package/lib/types.d.ts.map +1 -0
  138. package/lib/types.js +7 -0
  139. package/lib/types.js.map +1 -0
  140. package/lib/wrap-table.d.ts.map +1 -1
  141. package/lib/wrap-table.js.map +1 -1
  142. package/package.json +18 -4
  143. package/panel/components-view.d.ts +60 -0
  144. package/panel/components-view.d.ts.map +1 -0
  145. package/panel/components-view.js +581 -0
  146. package/panel/components-view.js.map +1 -0
  147. package/panel/devtools-settings.d.ts +41 -0
  148. package/panel/devtools-settings.d.ts.map +1 -0
  149. package/panel/devtools-settings.js +463 -0
  150. package/panel/devtools-settings.js.map +1 -0
  151. package/panel/index.html +29 -0
  152. package/panel/lit-devtools-panel.d.ts +37 -0
  153. package/panel/lit-devtools-panel.d.ts.map +1 -0
  154. package/panel/lit-devtools-panel.js +183 -0
  155. package/panel/lit-devtools-panel.js.map +1 -0
  156. package/panel/timeline-event-list.d.ts +43 -0
  157. package/panel/timeline-event-list.d.ts.map +1 -0
  158. package/panel/timeline-event-list.js +416 -0
  159. package/panel/timeline-event-list.js.map +1 -0
  160. package/panel/timeline-layers.d.ts +25 -0
  161. package/panel/timeline-layers.d.ts.map +1 -0
  162. package/panel/timeline-layers.js +96 -0
  163. package/panel/timeline-layers.js.map +1 -0
  164. package/panel/timeline-view.d.ts +38 -0
  165. package/panel/timeline-view.d.ts.map +1 -0
  166. package/panel/timeline-view.js +234 -0
  167. package/panel/timeline-view.js.map +1 -0
  168. package/types/inspector.d.ts +130 -0
  169. package/types/inspector.d.ts.map +1 -0
  170. package/types/inspector.js +16 -0
  171. package/types/inspector.js.map +1 -0
  172. package/types/timeline.d.ts +98 -0
  173. package/types/timeline.d.ts.map +1 -0
  174. package/types/timeline.js +39 -0
  175. package/types/timeline.js.map +1 -0
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * Buffered transport for timeline events.
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).
15
+ *
16
+ * Batching: we coalesce events with `queueMicrotask` so a burst of
17
+ * commit/set-part events from a single render doesn't hammer the channel
18
+ * with one message per event.
19
+ */
20
+ import type { TimelineEvent } from '../../../types/timeline.js';
21
+ type HotClient = {
22
+ send: (event: string, data: unknown) => void;
23
+ };
24
+ /**
25
+ * Register the HMR hot client.
26
+ * Called by install.ts after import.meta.hot check.
27
+ * Flushes any queued events and fires pending one-shot callbacks.
28
+ */
29
+ export declare const setHotClient: (hot: HotClient) => void;
30
+ /**
31
+ * Register a callback to be invoked once the HMR client is available.
32
+ * If the client is already set the callback is fired on the next microtask.
33
+ */
34
+ export declare const setHotClientCallback: (cb: () => void) => void;
35
+ /**
36
+ * Enqueue a timeline event for forwarding to the Vite server.
37
+ * Batches via microtask so a single synchronous render burst
38
+ * doesn't send dozens of individual messages.
39
+ */
40
+ export declare const emit: (event: TimelineEvent) => void;
41
+ export {};
42
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/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,GAAI,KAAK,SAAS,KAAG,IAe7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,IAAI,MAAM,IAAI,KAAG,IAMrD,CAAC;AAaF;;;;GAIG;AACH,eAAO,MAAM,IAAI,GAAI,OAAO,aAAa,KAAG,IAc3C,CAAC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ const queue = [];
7
+ let flushScheduled = false;
8
+ let hotClient = null;
9
+ /**
10
+ * Cap on events retained while no hot client is connected. Without a client
11
+ * `flush()` cannot drain the queue, so an uncapped buffer would grow for the
12
+ * whole session (in production, or before `install.ts` wires the client).
13
+ * We keep only the most recent events; the retained tail flushes if a client
14
+ * later connects.
15
+ */
16
+ const MAX_PENDING = 1000;
17
+ // Callbacks registered before the hot client was available (e.g. addTimelineLayer
18
+ // called at module init time before install.ts has set the client).
19
+ const pendingCallbacks = [];
20
+ /**
21
+ * Register the HMR hot client.
22
+ * Called by install.ts after import.meta.hot check.
23
+ * Flushes any queued events and fires pending one-shot callbacks.
24
+ */
25
+ export const setHotClient = (hot) => {
26
+ hotClient = hot;
27
+ // Drain any events that arrived before the client was wired.
28
+ if (queue.length > 0 && !flushScheduled) {
29
+ flushScheduled = true;
30
+ queueMicrotask(flush);
31
+ }
32
+ // Fire one-shot callbacks (e.g. addTimelineLayer announcements).
33
+ for (const cb of pendingCallbacks.splice(0)) {
34
+ try {
35
+ cb();
36
+ }
37
+ catch {
38
+ // ignore
39
+ }
40
+ }
41
+ };
42
+ /**
43
+ * Register a callback to be invoked once the HMR client is available.
44
+ * If the client is already set the callback is fired on the next microtask.
45
+ */
46
+ export const setHotClientCallback = (cb) => {
47
+ if (hotClient !== null) {
48
+ queueMicrotask(cb);
49
+ }
50
+ else {
51
+ pendingCallbacks.push(cb);
52
+ }
53
+ };
54
+ const flush = () => {
55
+ flushScheduled = false;
56
+ if (queue.length === 0 || hotClient === null)
57
+ return;
58
+ const batch = queue.splice(0);
59
+ try {
60
+ hotClient.send('lit:timeline:push-event', { events: batch });
61
+ }
62
+ catch {
63
+ // HMR channel may be temporarily unavailable; events are dropped.
64
+ }
65
+ };
66
+ /**
67
+ * Enqueue a timeline event for forwarding to the Vite server.
68
+ * Batches via microtask so a single synchronous render burst
69
+ * doesn't send dozens of individual messages.
70
+ */
71
+ export const emit = (event) => {
72
+ queue.push(event);
73
+ if (hotClient === null) {
74
+ // No consumer yet: bound the buffer instead of scheduling a flush that
75
+ // would only no-op. `setHotClient` drains the retained tail on connect.
76
+ if (queue.length > MAX_PENDING) {
77
+ queue.splice(0, queue.length - MAX_PENDING);
78
+ }
79
+ return;
80
+ }
81
+ if (!flushScheduled) {
82
+ flushScheduled = true;
83
+ queueMicrotask(flush);
84
+ }
85
+ };
86
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/timeline/transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuBH,MAAM,KAAK,GAAoB,EAAE,CAAC;AAClC,IAAI,cAAc,GAAG,KAAK,CAAC;AAC3B,IAAI,SAAS,GAAqB,IAAI,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,kFAAkF;AAClF,oEAAoE;AACpE,MAAM,gBAAgB,GAAsB,EAAE,CAAC;AAE/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAc,EAAQ,EAAE;IACnD,SAAS,GAAG,GAAG,CAAC;IAChB,6DAA6D;IAC7D,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QACxC,cAAc,GAAG,IAAI,CAAC;QACtB,cAAc,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IACD,iEAAiE;IACjE,KAAK,MAAM,EAAE,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,EAAE,EAAE,CAAC;QACP,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAc,EAAQ,EAAE;IAC3D,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,cAAc,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,GAAS,EAAE;IACvB,cAAc,GAAG,KAAK,CAAC;IACvB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO;IACrD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,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"]}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import { LitElement } from 'lit';
7
+ export interface TabItem {
8
+ id: string;
9
+ label: string;
10
+ icon?: string;
11
+ }
12
+ export type SegTabSize = 'sm' | 'md';
13
+ /**
14
+ * Inline segmented tab control. Renders a horizontal row of text-only tabs
15
+ * with the active one highlighted by the accent color.
16
+ *
17
+ * Matches the SegmentedTabs spec from the Lit Design System devtools kit.
18
+ */
19
+ export declare class SegmentedTabs extends LitElement {
20
+ static styles: import("lit").CSSResult[];
21
+ items: TabItem[];
22
+ value: string;
23
+ size: SegTabSize;
24
+ constructor();
25
+ private _select;
26
+ render(): import("lit-html").TemplateResult<1>;
27
+ }
28
+ declare global {
29
+ interface HTMLElementTagNameMap {
30
+ 'segmented-tabs': SegmentedTabs;
31
+ }
32
+ }
33
+ //# sourceMappingURL=segmented-tabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segmented-tabs.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/segmented-tabs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAqB,MAAM,KAAK,CAAC;AAInD,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;AAErC;;;;;GAKG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C,OAAgB,MAAM,4BAuDpB;IAE+B,KAAK,EAAE,OAAO,EAAE,CAAC;IAE9B,KAAK,EAAE,MAAM,CAAC;IAEd,IAAI,EAAE,UAAU,CAAC;;IASrC,OAAO,CAAC,OAAO;IAWN,MAAM;CAyBhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
7
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11
+ };
12
+ import { LitElement, html, css, nothing } from 'lit';
13
+ import { customElement, property } from 'lit/decorators.js';
14
+ import { tokens } from './tokens.js';
15
+ /**
16
+ * Inline segmented tab control. Renders a horizontal row of text-only tabs
17
+ * with the active one highlighted by the accent color.
18
+ *
19
+ * Matches the SegmentedTabs spec from the Lit Design System devtools kit.
20
+ */
21
+ let SegmentedTabs = class SegmentedTabs extends LitElement {
22
+ static { this.styles = [
23
+ tokens,
24
+ css `
25
+ :host {
26
+ display: flex;
27
+ gap: var(--lit-devtools-space-1);
28
+ align-self: stretch;
29
+ }
30
+ button {
31
+ appearance: none;
32
+ display: flex;
33
+ align-items: center;
34
+ gap: var(--lit-devtools-space-2);
35
+ border: 0;
36
+ background: none;
37
+ font: inherit;
38
+ color: var(--lit-devtools-text-muted);
39
+ padding: 0 var(--lit-devtools-space-5);
40
+ cursor: pointer;
41
+ border-bottom: 2px solid transparent;
42
+ white-space: nowrap;
43
+ transition:
44
+ color var(--lit-devtools-dur-fast) var(--lit-devtools-ease-standard),
45
+ border-color var(--lit-devtools-dur-fast)
46
+ var(--lit-devtools-ease-standard),
47
+ background var(--lit-devtools-dur-fast)
48
+ var(--lit-devtools-ease-standard);
49
+ }
50
+ button:hover {
51
+ color: var(--lit-devtools-text);
52
+ background: var(--lit-devtools-surface-hover);
53
+ }
54
+ button.active {
55
+ color: var(--lit-devtools-accent);
56
+ border-bottom-color: var(--lit-devtools-accent);
57
+ }
58
+ button:focus-visible {
59
+ outline: 2px solid var(--lit-devtools-accent-ring);
60
+ outline-offset: -2px;
61
+ }
62
+ button svg {
63
+ width: 18px;
64
+ height: 18px;
65
+ flex-shrink: 0;
66
+ }
67
+ :host([size='sm']) button {
68
+ font-size: var(--lit-devtools-text-xs);
69
+ padding: 0 var(--lit-devtools-space-4);
70
+ }
71
+ :host([size='md']) button,
72
+ :host(:not([size])) button {
73
+ font-size: var(--lit-devtools-text-sm);
74
+ padding: 0 var(--lit-devtools-space-5);
75
+ }
76
+ `,
77
+ ]; }
78
+ constructor() {
79
+ super();
80
+ this.items = [];
81
+ this.value = '';
82
+ this.size = 'md';
83
+ }
84
+ _select(id) {
85
+ this.value = id;
86
+ this.dispatchEvent(new CustomEvent('change', {
87
+ detail: { value: id },
88
+ bubbles: true,
89
+ composed: true,
90
+ }));
91
+ }
92
+ render() {
93
+ return html `
94
+ ${this.items.map((item) => html `
95
+ <button
96
+ role="tab"
97
+ aria-selected=${item.id === this.value}
98
+ class=${item.id === this.value ? 'active' : ''}
99
+ @click=${() => this._select(item.id)}
100
+ >
101
+ ${item.icon
102
+ ? html `<svg
103
+ viewBox="0 0 256 256"
104
+ fill="currentColor"
105
+ aria-hidden="true"
106
+ >
107
+ <path d=${item.icon} />
108
+ </svg>`
109
+ : nothing}
110
+ ${item.label}
111
+ </button>
112
+ `)}
113
+ `;
114
+ }
115
+ };
116
+ __decorate([
117
+ property({ type: Array })
118
+ ], SegmentedTabs.prototype, "items", void 0);
119
+ __decorate([
120
+ property()
121
+ ], SegmentedTabs.prototype, "value", void 0);
122
+ __decorate([
123
+ property()
124
+ ], SegmentedTabs.prototype, "size", void 0);
125
+ SegmentedTabs = __decorate([
126
+ customElement('segmented-tabs')
127
+ ], SegmentedTabs);
128
+ export { SegmentedTabs };
129
+ //# sourceMappingURL=segmented-tabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segmented-tabs.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/segmented-tabs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;AAEH,OAAO,EAAC,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AACnD,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAUnC;;;;;GAKG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;aAC3B,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoDF;KACF,AAvDqB,CAuDpB;IAQF;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEO,OAAO,CAAC,EAAU;QACxB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;YACxB,MAAM,EAAE,EAAC,KAAK,EAAE,EAAE,EAAC;YACnB,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;IACJ,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,KAAK,CAAC,GAAG,CACd,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAA;;;4BAGM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,KAAK;oBAC9B,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;qBACrC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;;cAElC,IAAI,CAAC,IAAI;YACT,CAAC,CAAC,IAAI,CAAA;;;;;4BAKQ,IAAI,CAAC,IAAI;uBACd;YACT,CAAC,CAAC,OAAO;cACT,IAAI,CAAC,KAAK;;SAEf,CACF;KACF,CAAC;IACJ,CAAC;;AAhDgC;IAAhC,QAAQ,CAAC,EAAC,IAAI,EAAE,KAAK,EAAC,CAAC;4CAA0B;AAE9B;IAAnB,QAAQ,EAAE;4CAAuB;AAEd;IAAnB,QAAQ,EAAE;2CAA0B;AA9D1B,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CA2GzB","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {LitElement, html, css, nothing} from 'lit';\nimport {customElement, property} from 'lit/decorators.js';\nimport {tokens} from './tokens.js';\n\nexport interface TabItem {\n id: string;\n label: string;\n icon?: string;\n}\n\nexport type SegTabSize = 'sm' | 'md';\n\n/**\n * Inline segmented tab control. Renders a horizontal row of text-only tabs\n * with the active one highlighted by the accent color.\n *\n * Matches the SegmentedTabs spec from the Lit Design System devtools kit.\n */\n@customElement('segmented-tabs')\nexport class SegmentedTabs extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: flex;\n gap: var(--lit-devtools-space-1);\n align-self: stretch;\n }\n button {\n appearance: none;\n display: flex;\n align-items: center;\n gap: var(--lit-devtools-space-2);\n border: 0;\n background: none;\n font: inherit;\n color: var(--lit-devtools-text-muted);\n padding: 0 var(--lit-devtools-space-5);\n cursor: pointer;\n border-bottom: 2px solid transparent;\n white-space: nowrap;\n transition:\n color var(--lit-devtools-dur-fast) var(--lit-devtools-ease-standard),\n border-color var(--lit-devtools-dur-fast)\n var(--lit-devtools-ease-standard),\n background var(--lit-devtools-dur-fast)\n var(--lit-devtools-ease-standard);\n }\n button:hover {\n color: var(--lit-devtools-text);\n background: var(--lit-devtools-surface-hover);\n }\n button.active {\n color: var(--lit-devtools-accent);\n border-bottom-color: var(--lit-devtools-accent);\n }\n button:focus-visible {\n outline: 2px solid var(--lit-devtools-accent-ring);\n outline-offset: -2px;\n }\n button svg {\n width: 18px;\n height: 18px;\n flex-shrink: 0;\n }\n :host([size='sm']) button {\n font-size: var(--lit-devtools-text-xs);\n padding: 0 var(--lit-devtools-space-4);\n }\n :host([size='md']) button,\n :host(:not([size])) button {\n font-size: var(--lit-devtools-text-sm);\n padding: 0 var(--lit-devtools-space-5);\n }\n `,\n ];\n\n @property({type: Array}) declare items: TabItem[];\n\n @property() declare value: string;\n\n @property() declare size: SegTabSize;\n\n constructor() {\n super();\n this.items = [];\n this.value = '';\n this.size = 'md';\n }\n\n private _select(id: string): void {\n this.value = id;\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: {value: id},\n bubbles: true,\n composed: true,\n })\n );\n }\n\n override render() {\n return html`\n ${this.items.map(\n (item) => html`\n <button\n role=\"tab\"\n aria-selected=${item.id === this.value}\n class=${item.id === this.value ? 'active' : ''}\n @click=${() => this._select(item.id)}\n >\n ${item.icon\n ? html`<svg\n viewBox=\"0 0 256 256\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path d=${item.icon} />\n </svg>`\n : nothing}\n ${item.label}\n </button>\n `\n )}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'segmented-tabs': SegmentedTabs;\n }\n}\n"]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import type MagicString from 'magic-string';
7
+ /** Stable key shared between transform output and runtime resolution. */
8
+ export declare const SOURCE_META_KEY = "@lit-labs/vite-plugin-lit#source";
9
+ /**
10
+ * The expression string used in generated code to reference the shared
11
+ * symbol at runtime.
12
+ */
13
+ export declare const SOURCE_META_SYM = "Symbol.for('@lit-labs/vite-plugin-lit#source')";
14
+ export interface InjectedSourceMeta {
15
+ filePath: string;
16
+ lineNumber: number;
17
+ componentName?: string;
18
+ }
19
+ /** 1-based line number for an index in source text. */
20
+ export declare const lineNumberAt: (code: string, index: number) => number;
21
+ /**
22
+ * Injects component source metadata onto custom element class constructors.
23
+ * Returns whether any injection was made.
24
+ */
25
+ export declare const injectSourceMeta: (code: string, filePath: string, ms: MagicString) => boolean;
26
+ //# sourceMappingURL=source-meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-meta.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/source-meta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C,yEAAyE;AACzE,eAAO,MAAM,eAAe,qCAAqC,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,eAAe,mDAAqC,CAAC;AAElE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,uDAAuD;AACvD,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,MAClB,CAAC;AAkE1C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,IAAI,WAAW,KACd,OA8DF,CAAC"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /** Stable key shared between transform output and runtime resolution. */
7
+ export const SOURCE_META_KEY = '@lit-labs/vite-plugin-lit#source';
8
+ /**
9
+ * The expression string used in generated code to reference the shared
10
+ * symbol at runtime.
11
+ */
12
+ export const SOURCE_META_SYM = `Symbol.for('${SOURCE_META_KEY}')`;
13
+ /** 1-based line number for an index in source text. */
14
+ export const lineNumberAt = (code, index) => code.slice(0, index).split('\n').length;
15
+ /**
16
+ * Finds the index after the closing `}` of a class body starting at
17
+ * `classStart`. Skips braces inside strings, template literals, and regex
18
+ * literals so those don't throw off the count.
19
+ */
20
+ const findClassBodyEnd = (code, classStart) => {
21
+ const open = code.indexOf('{', classStart);
22
+ if (open === -1)
23
+ return -1;
24
+ let depth = 1;
25
+ let i = open + 1;
26
+ while (i < code.length && depth > 0) {
27
+ const ch = code[i];
28
+ if (ch === '"' || ch === "'") {
29
+ const quote = ch;
30
+ i++;
31
+ while (i < code.length && code[i] !== quote) {
32
+ if (code[i] === '\\')
33
+ i++;
34
+ i++;
35
+ }
36
+ i++;
37
+ continue;
38
+ }
39
+ if (ch === '`') {
40
+ i++;
41
+ while (i < code.length && code[i] !== '`') {
42
+ if (code[i] === '\\')
43
+ i++;
44
+ i++;
45
+ }
46
+ i++;
47
+ continue;
48
+ }
49
+ if (ch === '/') {
50
+ const prev = i > 0 ? code[i - 1] : '';
51
+ if (/[=:(,+\-!&|?{}[; ]/.test(prev)) {
52
+ i++;
53
+ while (i < code.length && code[i] !== '/') {
54
+ if (code[i] === '\\')
55
+ i++;
56
+ i++;
57
+ }
58
+ i++;
59
+ continue;
60
+ }
61
+ }
62
+ if (ch === '{')
63
+ depth++;
64
+ else if (ch === '}')
65
+ depth--;
66
+ i++;
67
+ }
68
+ return depth === 0 ? i : -1;
69
+ };
70
+ const makeAssignment = (className, filePath, lineNumber) => `${className}[${SOURCE_META_SYM}]={filePath:${JSON.stringify(filePath)},lineNumber:${lineNumber},componentName:${JSON.stringify(className)}};`;
71
+ /** True when `className` is declared as a class/let/const in module code. */
72
+ const isClassDeclaredInModule = (code, className) => new RegExp(`^\\s*(?:export\\s+)?(?:class|let|const|var)\\s+${className}\\b`, 'm').test(code);
73
+ /**
74
+ * Injects component source metadata onto custom element class constructors.
75
+ * Returns whether any injection was made.
76
+ */
77
+ export const injectSourceMeta = (code, filePath, ms) => {
78
+ if (code.includes(SOURCE_META_SYM)) {
79
+ return false;
80
+ }
81
+ let changed = false;
82
+ const injected = new Set();
83
+ const injectAtClassEnd = (className, matchIndex, match) => {
84
+ if (injected.has(className))
85
+ return;
86
+ const classOffset = match.indexOf('class');
87
+ if (classOffset === -1)
88
+ return;
89
+ const classStart = matchIndex + classOffset;
90
+ const end = findClassBodyEnd(code, classStart);
91
+ if (end === -1)
92
+ return;
93
+ // Report the match start (the `@customElement` decorator) rather than the
94
+ // `class` keyword, so the overlay points at the top of the component.
95
+ const line = lineNumberAt(code, matchIndex);
96
+ ms.append('\n' + makeAssignment(className, filePath, line));
97
+ injected.add(className);
98
+ changed = true;
99
+ };
100
+ // @customElement(...) class Foo (any whitespace between them)
101
+ for (const m of code.matchAll(/@customElement\s*\([^)]*\)\s+(?:export\s+)?class\s+(\w+)/g)) {
102
+ injectAtClassEnd(m[1], m.index, m[0]);
103
+ }
104
+ // customElements.define('tag', ClassName)
105
+ for (const m of code.matchAll(/customElements\.define\s*\(\s*['"][^'"]+['"]\s*,\s*(\w+)/g)) {
106
+ const className = m[1];
107
+ if (injected.has(className) || !isClassDeclaredInModule(code, className)) {
108
+ continue;
109
+ }
110
+ const line = lineNumberAt(code, m.index);
111
+ ms.append('\n' + makeAssignment(className, filePath, line));
112
+ injected.add(className);
113
+ changed = true;
114
+ }
115
+ // TypeScript experimental-decorators / esbuild output
116
+ // e.g. `Foo = __decorateClass([customElement(...)], Foo)`
117
+ // `Foo = _decorate([customElement(...)], Foo)`
118
+ for (const m of code.matchAll(/(\w+)\s*=\s*__decorate\w*\(\s*\[[\s\S]*?customElement\s*\([^)]*\)[\s\S]*?\],\s*\1\)/g)) {
119
+ const className = m[1];
120
+ if (injected.has(className))
121
+ continue;
122
+ const line = lineNumberAt(code, m.index);
123
+ ms.append('\n' + makeAssignment(className, filePath, line));
124
+ injected.add(className);
125
+ changed = true;
126
+ }
127
+ return changed;
128
+ };
129
+ //# sourceMappingURL=source-meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-meta.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/source-meta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,kCAAkC,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,eAAe,IAAI,CAAC;AAQlE,uDAAuD;AACvD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,KAAa,EAAU,EAAE,CAClE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AAE1C;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,UAAkB,EAAU,EAAE;IACpE,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC3C,IAAI,IAAI,KAAK,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;IACjB,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YAC7B,MAAM,KAAK,GAAG,EAAE,CAAC;YACjB,CAAC,EAAE,CAAC;YACJ,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC;gBAC5C,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI;oBAAE,CAAC,EAAE,CAAC;gBAC1B,C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IAAI,GAAG,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;QAC5D,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type MagicString from 'magic-string';\n\n/** Stable key shared between transform output and runtime resolution. */\nexport const SOURCE_META_KEY = '@lit-labs/vite-plugin-lit#source';\n\n/**\n * The expression string used in generated code to reference the shared\n * symbol at runtime.\n */\nexport const SOURCE_META_SYM = `Symbol.for('${SOURCE_META_KEY}')`;\n\nexport interface InjectedSourceMeta {\n filePath: string;\n lineNumber: number;\n componentName?: string;\n}\n\n/** 1-based line number for an index in source text. */\nexport const lineNumberAt = (code: string, index: number): number =>\n code.slice(0, index).split('\\n').length;\n\n/**\n * Finds the index after the closing `}` of a class body starting at\n * `classStart`. Skips braces inside strings, template literals, and regex\n * literals so those don't throw off the count.\n */\nconst findClassBodyEnd = (code: string, classStart: number): number => {\n const open = code.indexOf('{', classStart);\n if (open === -1) return -1;\n let depth = 1;\n let i = open + 1;\n while (i < code.length && depth > 0) {\n const ch = code[i];\n if (ch === '\"' || ch === \"'\") {\n const quote = ch;\n i++;\n while (i < code.length && code[i] !== quote) {\n if (code[i] === '\\\\') i++;\n i++;\n }\n i++;\n continue;\n }\n if (ch === '`') {\n i++;\n while (i < code.length && code[i] !== '`') {\n if (code[i] === '\\\\') i++;\n i++;\n }\n i++;\n continue;\n }\n if (ch === '/') {\n const prev = i > 0 ? code[i - 1] : '';\n if (/[=:(,+\\-!&|?{}[; ]/.test(prev)) {\n i++;\n while (i < code.length && code[i] !== '/') {\n if (code[i] === '\\\\') i++;\n i++;\n }\n i++;\n continue;\n }\n }\n if (ch === '{') depth++;\n else if (ch === '}') depth--;\n i++;\n }\n return depth === 0 ? i : -1;\n};\n\nconst makeAssignment = (\n className: string,\n filePath: string,\n lineNumber: number\n) =>\n `${className}[${SOURCE_META_SYM}]={filePath:${JSON.stringify(filePath)},lineNumber:${lineNumber},componentName:${JSON.stringify(className)}};`;\n\n/** True when `className` is declared as a class/let/const in module code. */\nconst isClassDeclaredInModule = (code: string, className: string): boolean =>\n new RegExp(\n `^\\\\s*(?:export\\\\s+)?(?:class|let|const|var)\\\\s+${className}\\\\b`,\n 'm'\n ).test(code);\n\n/**\n * Injects component source metadata onto custom element class constructors.\n * Returns whether any injection was made.\n */\nexport const injectSourceMeta = (\n code: string,\n filePath: string,\n ms: MagicString\n): boolean => {\n if (code.includes(SOURCE_META_SYM)) {\n return false;\n }\n let changed = false;\n const injected = new Set<string>();\n\n const injectAtClassEnd = (\n className: string,\n matchIndex: number,\n match: string\n ) => {\n if (injected.has(className)) return;\n const classOffset = match.indexOf('class');\n if (classOffset === -1) return;\n const classStart = matchIndex + classOffset;\n const end = findClassBodyEnd(code, classStart);\n if (end === -1) return;\n // Report the match start (the `@customElement` decorator) rather than the\n // `class` keyword, so the overlay points at the top of the component.\n const line = lineNumberAt(code, matchIndex);\n ms.append('\\n' + makeAssignment(className, filePath, line));\n injected.add(className);\n changed = true;\n };\n\n // @customElement(...) class Foo (any whitespace between them)\n for (const m of code.matchAll(\n /@customElement\\s*\\([^)]*\\)\\s+(?:export\\s+)?class\\s+(\\w+)/g\n )) {\n injectAtClassEnd(m[1], m.index, m[0]);\n }\n\n // customElements.define('tag', ClassName)\n for (const m of code.matchAll(\n /customElements\\.define\\s*\\(\\s*['\"][^'\"]+['\"]\\s*,\\s*(\\w+)/g\n )) {\n const className = m[1];\n if (injected.has(className) || !isClassDeclaredInModule(code, className)) {\n continue;\n }\n const line = lineNumberAt(code, m.index);\n ms.append('\\n' + makeAssignment(className, filePath, line));\n injected.add(className);\n changed = true;\n }\n\n // TypeScript experimental-decorators / esbuild output\n // e.g. `Foo = __decorateClass([customElement(...)], Foo)`\n // `Foo = _decorate([customElement(...)], Foo)`\n for (const m of code.matchAll(\n /(\\w+)\\s*=\\s*__decorate\\w*\\(\\s*\\[[\\s\\S]*?customElement\\s*\\([^)]*\\)[\\s\\S]*?\\],\\s*\\1\\)/g\n )) {\n const className = m[1];\n if (injected.has(className)) continue;\n const line = lineNumberAt(code, m.index);\n ms.append('\\n' + makeAssignment(className, filePath, line));\n injected.add(className);\n changed = true;\n }\n\n return changed;\n};\n"]}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import type { Plugin } from 'vite';
7
+ import { type FeatureSettings } from '../types/timeline.js';
8
+ interface DockEntry {
9
+ id: string;
10
+ type: 'iframe';
11
+ title: string;
12
+ icon: string;
13
+ url: string;
14
+ category?: string;
15
+ }
16
+ interface RpcFn {
17
+ name: string;
18
+ type?: string;
19
+ handler?: (...args: unknown[]) => unknown;
20
+ }
21
+ /** Subset of @devframes/hub's command-input we register. */
22
+ interface CommandInput {
23
+ id: string;
24
+ title: string;
25
+ description?: string;
26
+ icon?: string;
27
+ category?: string;
28
+ keybindings?: Array<{
29
+ key: string;
30
+ }>;
31
+ handler?: (...args: unknown[]) => unknown;
32
+ }
33
+ interface TimelineCtx {
34
+ docks: {
35
+ register: (entry: DockEntry) => unknown;
36
+ };
37
+ commands?: {
38
+ register: (command: CommandInput) => unknown;
39
+ };
40
+ rpc: {
41
+ register: (fn: RpcFn) => void;
42
+ functions?: Record<string, (...args: unknown[]) => unknown>;
43
+ };
44
+ views: {
45
+ hostStatic: (baseUrl: string, distDir: string) => void;
46
+ };
47
+ viteServer?: {
48
+ middlewares: {
49
+ use: (path: string, handler: (req: {
50
+ url?: string;
51
+ }, res: {
52
+ statusCode: number;
53
+ setHeader: (k: string, v: string) => void;
54
+ end: (body: string) => void;
55
+ }, next: () => void) => void) => void;
56
+ };
57
+ };
58
+ viteConfig?: {
59
+ root: string;
60
+ };
61
+ }
62
+ declare module 'vite' {
63
+ interface Plugin {
64
+ devtools?: {
65
+ capabilities?: unknown;
66
+ setup: (ctx: TimelineCtx) => void | Promise<void>;
67
+ };
68
+ }
69
+ }
70
+ export declare const litTimelinePlugin: (getSettings?: () => FeatureSettings | undefined) => Plugin;
71
+ export {};
72
+ //# sourceMappingURL=timeline-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeline-plugin.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/timeline-plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAC,MAAM,EAAgB,MAAM,MAAM,CAAC;AAChD,OAAO,EAEL,KAAK,eAAe,EAIrB,MAAM,sBAAsB,CAAC;AAkB9B,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;CAC3C;AAED,4DAA4D;AAC5D,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;CAC3C;AA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