@oddsquad/vite-plugin-lit 0.2.3 → 0.4.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 (240) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/LICENSE +28 -0
  3. package/README.md +157 -0
  4. package/bin.mjs +154 -0
  5. package/client.d.ts +61 -0
  6. package/dist/client/assets/browser-agent-rpc-BXhoSh1z-CdtPhBL-.js +69 -0
  7. package/dist/client/assets/browser-agent-rpc-BXhoSh1z-CdtPhBL-.js.map +1 -0
  8. package/dist/client/assets/flow-DK8vmxvN.js +745 -0
  9. package/dist/client/assets/flow-DK8vmxvN.js.map +1 -0
  10. package/dist/client/assets/index-DVe6M4HV.js +10614 -0
  11. package/dist/client/assets/index-DVe6M4HV.js.map +1 -0
  12. package/{panel → dist/client}/index.html +1 -0
  13. package/index.d.ts.map +1 -1
  14. package/index.js +2 -2
  15. package/index.js.map +1 -1
  16. package/lib/color-scheme.d.ts.map +1 -1
  17. package/lib/color-scheme.js +17 -21
  18. package/lib/color-scheme.js.map +1 -1
  19. package/lib/devframe/definition.d.ts +45 -0
  20. package/lib/devframe/definition.d.ts.map +1 -0
  21. package/lib/devframe/definition.js +547 -0
  22. package/lib/devframe/definition.js.map +1 -0
  23. package/lib/devframe/icon.d.ts +8 -0
  24. package/lib/devframe/icon.d.ts.map +1 -0
  25. package/lib/devframe/icon.js +21 -0
  26. package/lib/devframe/icon.js.map +1 -0
  27. package/lib/devframe/paths.d.ts +12 -0
  28. package/lib/devframe/paths.d.ts.map +1 -0
  29. package/lib/devframe/paths.js +38 -0
  30. package/lib/devframe/paths.js.map +1 -0
  31. package/lib/devframe/protocol.d.ts +218 -0
  32. package/lib/devframe/protocol.d.ts.map +1 -0
  33. package/lib/devframe/protocol.js +77 -0
  34. package/lib/devframe/protocol.js.map +1 -0
  35. package/lib/devframe/source.d.ts +49 -0
  36. package/lib/devframe/source.d.ts.map +1 -0
  37. package/lib/devframe/source.js +23 -0
  38. package/lib/devframe/source.js.map +1 -0
  39. package/lib/devframe/vite.d.ts +116 -0
  40. package/lib/devframe/vite.d.ts.map +1 -0
  41. package/lib/devframe/vite.js +292 -0
  42. package/lib/devframe/vite.js.map +1 -0
  43. package/lib/http.d.ts +29 -0
  44. package/lib/http.d.ts.map +1 -0
  45. package/lib/http.js +35 -0
  46. package/lib/http.js.map +1 -0
  47. package/lib/icons.d.ts +2 -0
  48. package/lib/icons.d.ts.map +1 -1
  49. package/lib/icons.js +10 -4
  50. package/lib/icons.js.map +1 -1
  51. package/lib/options.d.ts +131 -0
  52. package/lib/options.d.ts.map +1 -0
  53. package/lib/options.js +128 -0
  54. package/lib/options.js.map +1 -0
  55. package/lib/plugin.d.ts +6 -137
  56. package/lib/plugin.d.ts.map +1 -1
  57. package/lib/plugin.js +280 -677
  58. package/lib/plugin.js.map +1 -1
  59. package/lib/plugins/css-literals.d.ts +15 -0
  60. package/lib/plugins/css-literals.d.ts.map +1 -0
  61. package/lib/plugins/css-literals.js +154 -0
  62. package/lib/plugins/css-literals.js.map +1 -0
  63. package/lib/plugins/css-queries.d.ts +20 -0
  64. package/lib/plugins/css-queries.d.ts.map +1 -0
  65. package/lib/plugins/css-queries.js +139 -0
  66. package/lib/plugins/css-queries.js.map +1 -0
  67. package/lib/plugins/open-in-editor.d.ts +16 -0
  68. package/lib/plugins/open-in-editor.d.ts.map +1 -0
  69. package/lib/plugins/open-in-editor.js +91 -0
  70. package/lib/plugins/open-in-editor.js.map +1 -0
  71. package/lib/plugins/shared.d.ts +13 -0
  72. package/lib/plugins/shared.d.ts.map +1 -0
  73. package/lib/plugins/shared.js +23 -0
  74. package/lib/plugins/shared.js.map +1 -0
  75. package/lib/plugins/timeline-virtual.d.ts +19 -0
  76. package/lib/plugins/timeline-virtual.d.ts.map +1 -0
  77. package/lib/plugins/timeline-virtual.js +53 -0
  78. package/lib/plugins/timeline-virtual.js.map +1 -0
  79. package/lib/runtime/css.d.ts +2 -2
  80. package/lib/runtime/css.d.ts.map +1 -1
  81. package/lib/runtime/css.js +41 -34
  82. package/lib/runtime/css.js.map +1 -1
  83. package/lib/runtime/edge-panel.d.ts.map +1 -1
  84. package/lib/runtime/edge-panel.js +82 -91
  85. package/lib/runtime/edge-panel.js.map +1 -1
  86. package/lib/runtime/fonts.d.ts.map +1 -1
  87. package/lib/runtime/fonts.js +1 -1
  88. package/lib/runtime/fonts.js.map +1 -1
  89. package/lib/runtime/indicator.d.ts.map +1 -1
  90. package/lib/runtime/indicator.js +71 -74
  91. package/lib/runtime/indicator.js.map +1 -1
  92. package/lib/runtime/inspector/collect.d.ts.map +1 -1
  93. package/lib/runtime/inspector/collect.js +83 -90
  94. package/lib/runtime/inspector/collect.js.map +1 -1
  95. package/lib/runtime/inspector/highlight.d.ts +16 -0
  96. package/lib/runtime/inspector/highlight.d.ts.map +1 -0
  97. package/lib/runtime/inspector/highlight.js +66 -0
  98. package/lib/runtime/inspector/highlight.js.map +1 -0
  99. package/lib/runtime/inspector/install.d.ts.map +1 -1
  100. package/lib/runtime/inspector/install.js +230 -205
  101. package/lib/runtime/inspector/install.js.map +1 -1
  102. package/lib/runtime/inspector/serialize.d.ts.map +1 -1
  103. package/lib/runtime/inspector/serialize.js +86 -107
  104. package/lib/runtime/inspector/serialize.js.map +1 -1
  105. package/lib/runtime/intern.d.ts.map +1 -1
  106. package/lib/runtime/intern.js +31 -29
  107. package/lib/runtime/intern.js.map +1 -1
  108. package/lib/runtime/overrides.d.ts.map +1 -1
  109. package/lib/runtime/overrides.js +14 -13
  110. package/lib/runtime/overrides.js.map +1 -1
  111. package/lib/runtime/patch.d.ts +8 -0
  112. package/lib/runtime/patch.d.ts.map +1 -1
  113. package/lib/runtime/patch.js +321 -282
  114. package/lib/runtime/patch.js.map +1 -1
  115. package/lib/runtime/source-meta.d.ts.map +1 -1
  116. package/lib/runtime/source-meta.js +1 -1
  117. package/lib/runtime/source-meta.js.map +1 -1
  118. package/lib/runtime/source-overlay/editors.d.ts.map +1 -1
  119. package/lib/runtime/source-overlay/editors.js +27 -27
  120. package/lib/runtime/source-overlay/editors.js.map +1 -1
  121. package/lib/runtime/source-overlay/mask-path.d.ts.map +1 -1
  122. package/lib/runtime/source-overlay/mask-path.js +15 -15
  123. package/lib/runtime/source-overlay/mask-path.js.map +1 -1
  124. package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -1
  125. package/lib/runtime/source-overlay/overlay-element.js +359 -355
  126. package/lib/runtime/source-overlay/overlay-element.js.map +1 -1
  127. package/lib/runtime/source-overlay/source-host.d.ts.map +1 -1
  128. package/lib/runtime/source-overlay/source-host.js +64 -71
  129. package/lib/runtime/source-overlay/source-host.js.map +1 -1
  130. package/lib/runtime/source-overlay/template.d.ts.map +1 -1
  131. package/lib/runtime/source-overlay/template.js +3 -3
  132. package/lib/runtime/source-overlay/template.js.map +1 -1
  133. package/lib/runtime/source-overlay.d.ts.map +1 -1
  134. package/lib/runtime/source-overlay.js +5 -2
  135. package/lib/runtime/source-overlay.js.map +1 -1
  136. package/lib/runtime/timeline/clock.d.ts.map +1 -1
  137. package/lib/runtime/timeline/clock.js +2 -2
  138. package/lib/runtime/timeline/clock.js.map +1 -1
  139. package/lib/runtime/timeline/flash.d.ts +39 -0
  140. package/lib/runtime/timeline/flash.d.ts.map +1 -0
  141. package/lib/runtime/timeline/flash.js +169 -0
  142. package/lib/runtime/timeline/flash.js.map +1 -0
  143. package/lib/runtime/timeline/identity.d.ts.map +1 -1
  144. package/lib/runtime/timeline/identity.js +27 -27
  145. package/lib/runtime/timeline/identity.js.map +1 -1
  146. package/lib/runtime/timeline/input.d.ts.map +1 -1
  147. package/lib/runtime/timeline/input.js +54 -67
  148. package/lib/runtime/timeline/input.js.map +1 -1
  149. package/lib/runtime/timeline/install.d.ts.map +1 -1
  150. package/lib/runtime/timeline/install.js +47 -33
  151. package/lib/runtime/timeline/install.js.map +1 -1
  152. package/lib/runtime/timeline/lifecycle.d.ts +8 -0
  153. package/lib/runtime/timeline/lifecycle.d.ts.map +1 -1
  154. package/lib/runtime/timeline/lifecycle.js +149 -133
  155. package/lib/runtime/timeline/lifecycle.js.map +1 -1
  156. package/lib/runtime/timeline/public-api.d.ts +2 -2
  157. package/lib/runtime/timeline/public-api.d.ts.map +1 -1
  158. package/lib/runtime/timeline/public-api.js +11 -11
  159. package/lib/runtime/timeline/public-api.js.map +1 -1
  160. package/lib/runtime/timeline/render.d.ts +15 -6
  161. package/lib/runtime/timeline/render.d.ts.map +1 -1
  162. package/lib/runtime/timeline/render.js +212 -78
  163. package/lib/runtime/timeline/render.js.map +1 -1
  164. package/lib/runtime/timeline/transport.d.ts.map +1 -1
  165. package/lib/runtime/timeline/transport.js +39 -43
  166. package/lib/runtime/timeline/transport.js.map +1 -1
  167. package/lib/segmented-tabs.d.ts +3 -1
  168. package/lib/segmented-tabs.d.ts.map +1 -1
  169. package/lib/segmented-tabs.js +136 -107
  170. package/lib/segmented-tabs.js.map +1 -1
  171. package/lib/snapshot.d.ts +28 -0
  172. package/lib/snapshot.d.ts.map +1 -0
  173. package/lib/snapshot.js +57 -0
  174. package/lib/snapshot.js.map +1 -0
  175. package/lib/source-meta.d.ts.map +1 -1
  176. package/lib/source-meta.js +176 -162
  177. package/lib/source-meta.js.map +1 -1
  178. package/lib/timeline/derive.d.ts +152 -0
  179. package/lib/timeline/derive.d.ts.map +1 -0
  180. package/lib/timeline/derive.js +242 -0
  181. package/lib/timeline/derive.js.map +1 -0
  182. package/lib/tokens.d.ts.map +1 -1
  183. package/lib/tokens.js +17 -18
  184. package/lib/tokens.js.map +1 -1
  185. package/lib/transform.d.ts.map +1 -1
  186. package/lib/transform.js +62 -57
  187. package/lib/transform.js.map +1 -1
  188. package/lib/types.d.ts.map +1 -1
  189. package/lib/types.js +1 -1
  190. package/lib/types.js.map +1 -1
  191. package/lib/wrap-table.d.ts.map +1 -1
  192. package/lib/wrap-table.js +19 -17
  193. package/lib/wrap-table.js.map +1 -1
  194. package/package.json +80 -13
  195. package/types/hmr-incompatibility.d.ts +59 -0
  196. package/types/hmr-incompatibility.d.ts.map +1 -0
  197. package/types/hmr-incompatibility.js +30 -0
  198. package/types/hmr-incompatibility.js.map +1 -0
  199. package/types/in-page.d.ts +49 -0
  200. package/types/in-page.d.ts.map +1 -0
  201. package/types/in-page.js +33 -0
  202. package/types/in-page.js.map +1 -0
  203. package/types/inspector.d.ts.map +1 -1
  204. package/types/inspector.js.map +1 -1
  205. package/types/snapshot.d.ts +44 -0
  206. package/types/snapshot.d.ts.map +1 -0
  207. package/types/snapshot.js +7 -0
  208. package/types/snapshot.js.map +1 -0
  209. package/types/timeline.d.ts +23 -1
  210. package/types/timeline.d.ts.map +1 -1
  211. package/types/timeline.js +2 -0
  212. package/types/timeline.js.map +1 -1
  213. package/lib/timeline-plugin.d.ts +0 -72
  214. package/lib/timeline-plugin.d.ts.map +0 -1
  215. package/lib/timeline-plugin.js +0 -376
  216. package/lib/timeline-plugin.js.map +0 -1
  217. package/panel/components-view.d.ts +0 -60
  218. package/panel/components-view.d.ts.map +0 -1
  219. package/panel/components-view.js +0 -587
  220. package/panel/components-view.js.map +0 -1
  221. package/panel/devtools-settings.d.ts +0 -41
  222. package/panel/devtools-settings.d.ts.map +0 -1
  223. package/panel/devtools-settings.js +0 -463
  224. package/panel/devtools-settings.js.map +0 -1
  225. package/panel/lit-devtools-panel.d.ts +0 -37
  226. package/panel/lit-devtools-panel.d.ts.map +0 -1
  227. package/panel/lit-devtools-panel.js +0 -185
  228. package/panel/lit-devtools-panel.js.map +0 -1
  229. package/panel/timeline-event-list.d.ts +0 -43
  230. package/panel/timeline-event-list.d.ts.map +0 -1
  231. package/panel/timeline-event-list.js +0 -416
  232. package/panel/timeline-event-list.js.map +0 -1
  233. package/panel/timeline-layers.d.ts +0 -25
  234. package/panel/timeline-layers.d.ts.map +0 -1
  235. package/panel/timeline-layers.js +0 -96
  236. package/panel/timeline-layers.js.map +0 -1
  237. package/panel/timeline-view.d.ts +0 -38
  238. package/panel/timeline-view.d.ts.map +0 -1
  239. package/panel/timeline-view.js +0 -234
  240. package/panel/timeline-view.js.map +0 -1
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ // The official Lit logo mark (Iconify `logos:lit-icon`). Its native viewBox is
7
+ // 256×320 — taller than wide — so when the DevTools dock sizes an icon to its
8
+ // width it overflowed the square slot and looked bigger than the other icons.
9
+ // We pad it to a square viewBox (-32 0 320 320, centering the 256-wide art) so
10
+ // it renders at the same box size as the built-in phosphor icons. Inlined as a
11
+ // data: URI rather than `logos:lit-icon` so it also works offline (no Iconify
12
+ // API fetch).
13
+ const LIT_LOGO_SVG =
14
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="-32 0 320 320">' +
15
+ '<path fill="#00e8ff" d="m64 192l25.926-44.727l38.233-19.114l63.974 63.974l10.833 61.754L192 320l-64-64l-38.074-25.615z"/>' +
16
+ '<path fill="#283198" d="M128 256V128l64-64v128zM0 256l64 64l9.202-60.602L64 192l-37.542 23.71z"/>' +
17
+ '<path fill="#324fff" d="M64 192V64l64-64v128zm128 128V192l64-64v128zM0 256V128l64 64z"/>' +
18
+ '<path fill="#0ff" d="M64 320V192l64 64z"/></svg>';
19
+ /** Dock icon for the Lit devframe. */
20
+ export const LIT_LOGO_ICON = `data:image/svg+xml,${encodeURIComponent(LIT_LOGO_SVG)}`;
21
+ //# sourceMappingURL=icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.js","sourceRoot":"","sources":["../../src/lib/devframe/icon.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,cAAc;AACd,MAAM,YAAY,GAChB,kEAAkE;IAClE,2HAA2H;IAC3H,mGAAmG;IACnG,0FAA0F;IAC1F,kDAAkD,CAAC;AAErD,sCAAsC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,sBAAsB,kBAAkB,CACnE,YAAY,CACb,EAAE,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n// The official Lit logo mark (Iconify `logos:lit-icon`). Its native viewBox is\n// 256×320 — taller than wide — so when the DevTools dock sizes an icon to its\n// width it overflowed the square slot and looked bigger than the other icons.\n// We pad it to a square viewBox (-32 0 320 320, centering the 256-wide art) so\n// it renders at the same box size as the built-in phosphor icons. Inlined as a\n// data: URI rather than `logos:lit-icon` so it also works offline (no Iconify\n// API fetch).\nconst LIT_LOGO_SVG =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-32 0 320 320\">' +\n '<path fill=\"#00e8ff\" d=\"m64 192l25.926-44.727l38.233-19.114l63.974 63.974l10.833 61.754L192 320l-64-64l-38.074-25.615z\"/>' +\n '<path fill=\"#283198\" d=\"M128 256V128l64-64v128zM0 256l64 64l9.202-60.602L64 192l-37.542 23.71z\"/>' +\n '<path fill=\"#324fff\" d=\"M64 192V64l64-64v128zm128 128V192l64-64v128zM0 256V128l64 64z\"/>' +\n '<path fill=\"#0ff\" d=\"M64 320V192l64 64z\"/></svg>';\n\n/** Dock icon for the Lit devframe. */\nexport const LIT_LOGO_ICON = `data:image/svg+xml,${encodeURIComponent(\n LIT_LOGO_SVG\n)}`;\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /** Absolute path of this package's root directory. */
7
+ export declare const PACKAGE_ROOT: string;
8
+ /** This package's version, as published. Surfaced by the `get-meta` query. */
9
+ export declare const PACKAGE_VERSION: string;
10
+ /** Where `vp run build:panel` writes the panel SPA the host serves. */
11
+ export declare const PANEL_DIST_DIR: string;
12
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/lib/devframe/paths.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA6BH,sDAAsD;AACtD,eAAO,MAAM,YAAY,EAAE,MAA0B,CAAC;AAEtD,8EAA8E;AAC9E,eAAO,MAAM,eAAe,EAAE,MAKR,CAAC;AAEvB,uEAAuE;AACvE,eAAO,MAAM,cAAc,EAAE,MAA6C,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * Package-root resolution for the devframe.
8
+ *
9
+ * `tsc` flattens `src/lib/devframe/*.ts` to `lib/devframe/*.js`, so a path
10
+ * relative to `import.meta.url` lands one directory apart depending on
11
+ * whether the module was loaded from source (tests, `vite dev` on this repo)
12
+ * or from the published output. Walking up to the nearest `package.json`
13
+ * instead is correct in both layouts — the same reason
14
+ * `resolveRuntimeModule()` in plugin.ts probes for both extensions.
15
+ */
16
+ import {existsSync, readFileSync} from 'node:fs';
17
+ import {dirname, join} from 'node:path';
18
+ import {fileURLToPath} from 'node:url';
19
+ const findPackageRoot = () => {
20
+ let dir = dirname(fileURLToPath(import.meta.url));
21
+ // 6 levels is more than either layout needs; the loop exits at the root.
22
+ for (let depth = 0; depth < 6; depth++) {
23
+ if (existsSync(join(dir, 'package.json'))) return dir;
24
+ const parent = dirname(dir);
25
+ if (parent === dir) break;
26
+ dir = parent;
27
+ }
28
+ throw new Error('[lit-plugin] could not locate the package root');
29
+ };
30
+ /** Absolute path of this package's root directory. */
31
+ export const PACKAGE_ROOT = findPackageRoot();
32
+ /** This package's version, as published. Surfaced by the `get-meta` query. */
33
+ export const PACKAGE_VERSION =
34
+ JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8'))
35
+ .version ?? '0.0.0';
36
+ /** Where `vp run build:panel` writes the panel SPA the host serves. */
37
+ export const PANEL_DIST_DIR = join(PACKAGE_ROOT, 'dist', 'client');
38
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/lib/devframe/paths.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;AACjD,OAAO,EAAC,OAAO,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AACxC,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAEvC,MAAM,eAAe,GAAG,GAAW,EAAE;IACnC,IAAI,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,yEAAyE;IACzE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACvC,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;YAAE,OAAO,GAAG,CAAC;QACtD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM;QAC1B,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,sDAAsD;AACtD,MAAM,CAAC,MAAM,YAAY,GAAW,eAAe,EAAE,CAAC;AAEtD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,eAAe,GAExB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAGpE,CAAC,OAAO,IAAI,OAAO,CAAC;AAEvB,uEAAuE;AACvE,MAAM,CAAC,MAAM,cAAc,GAAW,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Package-root resolution for the devframe.\n *\n * `tsc` flattens `src/lib/devframe/*.ts` to `lib/devframe/*.js`, so a path\n * relative to `import.meta.url` lands one directory apart depending on\n * whether the module was loaded from source (tests, `vite dev` on this repo)\n * or from the published output. Walking up to the nearest `package.json`\n * instead is correct in both layouts — the same reason\n * `resolveRuntimeModule()` in plugin.ts probes for both extensions.\n */\n\nimport {existsSync, readFileSync} from 'node:fs';\nimport {dirname, join} from 'node:path';\nimport {fileURLToPath} from 'node:url';\n\nconst findPackageRoot = (): string => {\n let dir = dirname(fileURLToPath(import.meta.url));\n // 6 levels is more than either layout needs; the loop exits at the root.\n for (let depth = 0; depth < 6; depth++) {\n if (existsSync(join(dir, 'package.json'))) return dir;\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n throw new Error('[lit-plugin] could not locate the package root');\n};\n\n/** Absolute path of this package's root directory. */\nexport const PACKAGE_ROOT: string = findPackageRoot();\n\n/** This package's version, as published. Surfaced by the `get-meta` query. */\nexport const PACKAGE_VERSION: string =\n (\n JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8')) as {\n version?: string;\n }\n ).version ?? '0.0.0';\n\n/** Where `vp run build:panel` writes the panel SPA the host serves. */\nexport const PANEL_DIST_DIR: string = join(PACKAGE_ROOT, 'dist', 'client');\n"]}
@@ -0,0 +1,218 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import type { FeatureSettings, SettingsOverride, TimelineEvent, TimelineLayer, TimelineLayersState } from '../../types/timeline.js';
7
+ import type { InspectorCommand, InspectorDetails, InspectorMessage, InspectorTreeNode } from '../../types/inspector.js';
8
+ import type { HmrIncompatibilityEvent } from '../../types/hmr-incompatibility.js';
9
+ import type { ComponentRollup, UpdateCycle } from '../timeline/derive.js';
10
+ /** The devframe's scope id. RPC names become `lit:*`, MCP wire names `lit_*`. */
11
+ export declare const LIT_DEVFRAME_ID = "lit";
12
+ /** Shared-state key holding the {@link SessionState} snapshot. */
13
+ export declare const SESSION_STATE_KEY = "session";
14
+ /** Streaming channel name the timeline event batches are pushed on. */
15
+ export declare const TIMELINE_STREAM_NAME = "timeline";
16
+ /**
17
+ * Id of the one long-lived timeline stream. Fixed rather than discovered:
18
+ * there is exactly one page feed per dev session, so the panel can subscribe
19
+ * without a round trip to look the id up. The node side re-`start()`s this id
20
+ * if the transport dropped the stream after the last subscriber left.
21
+ */
22
+ export declare const TIMELINE_STREAM_ID = "live";
23
+ /**
24
+ * Cap on the node-side recent-events ring buffer, matching the timeline
25
+ * stream's own `replayWindow` so an agent and a (re)connecting panel see
26
+ * comparable history.
27
+ */
28
+ export declare const RECENT_EVENTS_BUFFER_SIZE = 512;
29
+ /** Bare (unscoped) name of the `get-meta` query. */
30
+ export declare const RPC_GET_META = "get-meta";
31
+ /** Bare name of the `list-components` query. */
32
+ export declare const RPC_LIST_COMPONENTS = "list-components";
33
+ /** Bare name of the `component-details` query. */
34
+ export declare const RPC_COMPONENT_DETAILS = "component-details";
35
+ /** Bare name of the `recent-events` query. */
36
+ export declare const RPC_RECENT_EVENTS = "recent-events";
37
+ /** Bare name of the `update-summary` query. */
38
+ export declare const RPC_UPDATE_SUMMARY = "update-summary";
39
+ /** Bare name of the `inspect` action. */
40
+ export declare const RPC_INSPECT = "inspect";
41
+ /** Bare name of the `set-recording` action. */
42
+ export declare const RPC_SET_RECORDING = "set-recording";
43
+ /** Bare name of the `toggle-layer` action. */
44
+ export declare const RPC_TOGGLE_LAYER = "toggle-layer";
45
+ /** Bare name of the `set-settings-override` action. */
46
+ export declare const RPC_SET_SETTINGS_OVERRIDE = "set-settings-override";
47
+ /** Bare name of the `open-source` action. */
48
+ export declare const RPC_OPEN_SOURCE = "open-source";
49
+ /** Arguments for {@link RPC_OPEN_SOURCE}. */
50
+ export interface OpenSourceArgs {
51
+ /**
52
+ * The path as the panel has it: what the transform injected, so relative
53
+ * to the Vite root (or absolute, when the file lives outside it).
54
+ */
55
+ file: string;
56
+ line?: number;
57
+ }
58
+ /** What {@link RPC_OPEN_SOURCE} reports back. */
59
+ export interface OpenSourceResult {
60
+ /**
61
+ * False when no open service is installed on the host, which is the
62
+ * panel's cue to fall back to `/__lit-open-in-editor`.
63
+ */
64
+ opened: boolean;
65
+ }
66
+ /** Freeze the current session into a static panel directory. */
67
+ export declare const RPC_EXPORT_SNAPSHOT = "export-snapshot";
68
+ /** Arguments for {@link RPC_EXPORT_SNAPSHOT}. */
69
+ export interface ExportSnapshotArgs {
70
+ /**
71
+ * Where to write. Relative paths resolve against the dev server's cwd.
72
+ * Defaults to `lit-devtools-snapshot`.
73
+ */
74
+ outDir?: string;
75
+ }
76
+ /** What {@link RPC_EXPORT_SNAPSHOT} reports back, for the panel to display. */
77
+ export interface ExportSnapshotResult {
78
+ outDir: string;
79
+ events: number;
80
+ components: number;
81
+ details: number;
82
+ }
83
+ /** Bare name of the `inspector-message` client (node → panel) event. */
84
+ export declare const RPC_INSPECTOR_MESSAGE = "inspector-message";
85
+ /** Bare name of the `hmr-incompatibilities` query. */
86
+ export declare const RPC_HMR_INCOMPATIBILITIES = "hmr-incompatibilities";
87
+ /** Bare name of the `hmr-incompatible` client (node → panel) event. */
88
+ export declare const RPC_HMR_INCOMPATIBLE = "hmr-incompatible";
89
+ /**
90
+ * Recording/layers snapshot shared between every surface (panel, page
91
+ * runtime, MCP). Survives reconnect; mutated either by the `set-recording` /
92
+ * `toggle-layer` actions below or directly by a panel through the generic
93
+ * shared-state RPC devframe provides.
94
+ *
95
+ * `layers.recordingState` is the single authority for "is recording" — the
96
+ * runtime's own layer state carries it, so a separate flag here would be a
97
+ * second copy to keep in sync.
98
+ */
99
+ export interface SessionState {
100
+ layers: TimelineLayersState;
101
+ /** Layers announced at runtime by app code through `addTimelineLayer()`. */
102
+ customLayers: TimelineLayer[];
103
+ }
104
+ export declare const DEFAULT_SESSION_STATE: SessionState;
105
+ /** Result of the `get-meta` query. */
106
+ export interface LitGetMetaResult {
107
+ version: string;
108
+ /** Built-in layers followed by any runtime-announced custom ones. */
109
+ layers: TimelineLayer[];
110
+ features: FeatureSettings | null;
111
+ /** Channel and id to pass to `rpc.streaming.subscribe()`. */
112
+ stream: {
113
+ channel: string;
114
+ id: string;
115
+ };
116
+ }
117
+ /** Argument of the `component-details` query. */
118
+ export interface ComponentDetailsArgs {
119
+ id: number;
120
+ }
121
+ /** Argument of the `recent-events` query. */
122
+ export interface RecentEventsArgs {
123
+ layerId?: string;
124
+ elementId?: number;
125
+ /**
126
+ * Only events from the last `sinceMs` milliseconds, measured against
127
+ * the newest event currently in the buffer — not wall-clock time.
128
+ * `TimelineEvent.time` is "ms since recording started" in the page
129
+ * (see `runtime/timeline/clock.ts`), which has no fixed relationship
130
+ * to this process's clock.
131
+ */
132
+ sinceMs?: number;
133
+ /** Default 50, hard ceiling 200 regardless of what's requested. */
134
+ limit?: number;
135
+ }
136
+ /** Result of the `recent-events` query. */
137
+ export interface RecentEventsResult {
138
+ /** Whether the timeline is currently recording. */
139
+ recording: boolean;
140
+ /** Most recent events matching the filters, oldest first. */
141
+ events: TimelineEvent[];
142
+ /** Total events currently held in the ring buffer, before filtering. */
143
+ bufferSize: number;
144
+ /** True if filtering matched more events than were returned. */
145
+ truncated: boolean;
146
+ }
147
+ /** Argument of the `update-summary` query. */
148
+ export interface UpdateSummaryArgs {
149
+ /** Restrict to one component, by tag name. */
150
+ tagName?: string;
151
+ /** Same window semantics as {@link RecentEventsArgs.sinceMs}. */
152
+ sinceMs?: number;
153
+ /** Cycles returned (the component totals always cover the whole window).
154
+ * Default 50, hard ceiling 200. */
155
+ limit?: number;
156
+ }
157
+ /** Result of the `update-summary` query. */
158
+ export interface UpdateSummaryResult {
159
+ /** Whether the timeline is currently recording. */
160
+ recording: boolean;
161
+ /** Per-component totals over the window, slowest first. */
162
+ components: ComponentRollup[];
163
+ /** The most recent update cycles in the window, oldest first. */
164
+ cycles: UpdateCycle[];
165
+ /** Total events currently held in the ring buffer, before derivation. */
166
+ bufferSize: number;
167
+ /** True if more cycles were derived than were returned. */
168
+ truncated: boolean;
169
+ }
170
+ /** Argument of the `set-recording` action. */
171
+ export interface SetRecordingArgs {
172
+ recording: boolean;
173
+ }
174
+ /** Argument of the `toggle-layer` action. */
175
+ export interface ToggleLayerArgs {
176
+ layerId: string;
177
+ enabled: boolean;
178
+ }
179
+ /**
180
+ * Maps a {@link TimelineLayer.id} to the {@link TimelineLayersState} flag
181
+ * that gates it. Custom layers have no flag and are always on.
182
+ */
183
+ export declare const LAYER_FLAGS: Readonly<Record<string, keyof TimelineLayersState>>;
184
+ declare module 'devframe' {
185
+ interface DevframeRpcServerFunctions {
186
+ 'lit:get-meta': () => Promise<LitGetMetaResult>;
187
+ 'lit:list-components': () => Promise<InspectorTreeNode[]>;
188
+ 'lit:component-details': (args: ComponentDetailsArgs) => Promise<InspectorDetails | null>;
189
+ 'lit:recent-events': (args?: RecentEventsArgs) => Promise<RecentEventsResult>;
190
+ 'lit:update-summary': (args?: UpdateSummaryArgs) => Promise<UpdateSummaryResult>;
191
+ 'lit:inspect': (command: InspectorCommand) => Promise<void>;
192
+ 'lit:set-recording': (args: SetRecordingArgs) => Promise<void>;
193
+ 'lit:toggle-layer': (args: ToggleLayerArgs) => Promise<void>;
194
+ 'lit:set-settings-override': (override: SettingsOverride) => Promise<void>;
195
+ 'lit:open-source': (args: OpenSourceArgs) => Promise<OpenSourceResult>;
196
+ 'lit:export-snapshot': (args: ExportSnapshotArgs) => Promise<ExportSnapshotResult>;
197
+ 'lit:hmr-incompatibilities': () => Promise<HmrIncompatibilityEvent[]>;
198
+ }
199
+ interface DevframeRpcClientFunctions {
200
+ 'lit:inspector-message': (message: InspectorMessage) => void;
201
+ 'lit:hmr-incompatible': (event: HmrIncompatibilityEvent) => void;
202
+ }
203
+ interface DevframeSettingsRegistry {
204
+ lit: {
205
+ /** Panel chrome preference. Mirrors `COLOR_SCHEME_LS_KEY`. */
206
+ appearance?: 'auto' | 'dark' | 'light';
207
+ /**
208
+ * The Settings tab's live overrides, stored as one blob the way the
209
+ * panel already treats them. Mirrors `SETTINGS_OVERRIDE_LS_KEY`, which
210
+ * stays: the page runtime reads it synchronously at module-init time,
211
+ * long before any client exists, and every settings-store read is
212
+ * async by design.
213
+ */
214
+ override?: SettingsOverride;
215
+ };
216
+ }
217
+ }
218
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/lib/devframe/protocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAAC,eAAe,EAAE,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAExE,iFAAiF;AACjF,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,kEAAkE;AAClE,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,uEAAuE;AACvE,eAAO,MAAM,oBAAoB,aAAa,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,SAAS,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,oDAAoD;AACpD,eAAO,MAAM,YAAY,aAAa,CAAC;AAEvC,gDAAgD;AAChD,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,kDAAkD;AAClD,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD,8CAA8C;AAC9C,eAAO,MAAM,iBAAiB,k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E,qBAAqB,EAAE,CACrB,IAAI,EAAE,kBAAkB,KACrB,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACnC,2BAA2B,EAAE,MAAM,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAAC;KACvE;IAED,UAAU,0BAA0B;QAClC,uBAAuB,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;QAC7D,sBAAsB,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;KAClE;IAED,UAAU,wBAAwB;QAChC,GAAG,EAAE;YACH,8DAA8D;YAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;YACvC;;;;;;eAMG;YACH,QAAQ,CAAC,EAAE,gBAAgB,CAAC;SAC7B,CAAC;KACH;CACF"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * Shared wire contract between the Lit devframe's node-side definition
8
+ * ({@link ../definition.ts}) and its panel: shared-state / streaming /
9
+ * RPC-function names, their payload shapes, and the `devframe` registry
10
+ * augmentations that type them end to end.
11
+ *
12
+ * @see plans/devframe-foundation.md
13
+ */
14
+ import {DEFAULT_LAYERS_STATE} from '../../types/timeline.js';
15
+ /** The devframe's scope id. RPC names become `lit:*`, MCP wire names `lit_*`. */
16
+ export const LIT_DEVFRAME_ID = 'lit';
17
+ /** Shared-state key holding the {@link SessionState} snapshot. */
18
+ export const SESSION_STATE_KEY = 'session';
19
+ /** Streaming channel name the timeline event batches are pushed on. */
20
+ export const TIMELINE_STREAM_NAME = 'timeline';
21
+ /**
22
+ * Id of the one long-lived timeline stream. Fixed rather than discovered:
23
+ * there is exactly one page feed per dev session, so the panel can subscribe
24
+ * without a round trip to look the id up. The node side re-`start()`s this id
25
+ * if the transport dropped the stream after the last subscriber left.
26
+ */
27
+ export const TIMELINE_STREAM_ID = 'live';
28
+ /**
29
+ * Cap on the node-side recent-events ring buffer, matching the timeline
30
+ * stream's own `replayWindow` so an agent and a (re)connecting panel see
31
+ * comparable history.
32
+ */
33
+ export const RECENT_EVENTS_BUFFER_SIZE = 512;
34
+ /** Bare (unscoped) name of the `get-meta` query. */
35
+ export const RPC_GET_META = 'get-meta';
36
+ /** Bare name of the `list-components` query. */
37
+ export const RPC_LIST_COMPONENTS = 'list-components';
38
+ /** Bare name of the `component-details` query. */
39
+ export const RPC_COMPONENT_DETAILS = 'component-details';
40
+ /** Bare name of the `recent-events` query. */
41
+ export const RPC_RECENT_EVENTS = 'recent-events';
42
+ /** Bare name of the `update-summary` query. */
43
+ export const RPC_UPDATE_SUMMARY = 'update-summary';
44
+ /** Bare name of the `inspect` action. */
45
+ export const RPC_INSPECT = 'inspect';
46
+ /** Bare name of the `set-recording` action. */
47
+ export const RPC_SET_RECORDING = 'set-recording';
48
+ /** Bare name of the `toggle-layer` action. */
49
+ export const RPC_TOGGLE_LAYER = 'toggle-layer';
50
+ /** Bare name of the `set-settings-override` action. */
51
+ export const RPC_SET_SETTINGS_OVERRIDE = 'set-settings-override';
52
+ /** Bare name of the `open-source` action. */
53
+ export const RPC_OPEN_SOURCE = 'open-source';
54
+ /** Freeze the current session into a static panel directory. */
55
+ export const RPC_EXPORT_SNAPSHOT = 'export-snapshot';
56
+ /** Bare name of the `inspector-message` client (node → panel) event. */
57
+ export const RPC_INSPECTOR_MESSAGE = 'inspector-message';
58
+ /** Bare name of the `hmr-incompatibilities` query. */
59
+ export const RPC_HMR_INCOMPATIBILITIES = 'hmr-incompatibilities';
60
+ /** Bare name of the `hmr-incompatible` client (node → panel) event. */
61
+ export const RPC_HMR_INCOMPATIBLE = 'hmr-incompatible';
62
+ export const DEFAULT_SESSION_STATE = {
63
+ layers: DEFAULT_LAYERS_STATE,
64
+ customLayers: [],
65
+ };
66
+ /**
67
+ * Maps a {@link TimelineLayer.id} to the {@link TimelineLayersState} flag
68
+ * that gates it. Custom layers have no flag and are always on.
69
+ */
70
+ export const LAYER_FLAGS = {
71
+ 'lit-lifecycle': 'litLifecycleEnabled',
72
+ 'lit-render': 'litRenderEnabled',
73
+ 'lit-render-verbose': 'litRenderVerboseEnabled',
74
+ mouse: 'mouseEventEnabled',
75
+ keyboard: 'keyboardEventEnabled',
76
+ };
77
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/lib/devframe/protocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAC,oBAAoB,EAAC,MAAM,yBAAyB,CAAC;AAiB7D,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAErC,kEAAkE;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C,uEAAuE;AACvE,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C,oDAAoD;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AAEvC,gDAAgD;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD,kDAAkD;AAClD,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAEzD,8CAA8C;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEjD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAEnD,yCAAyC;AACzC,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AAErC,+CAA+C;AAC/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEjD,8CAA8C;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE/C,uDAAuD;AACvD,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAEjE,6CAA6C;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAqB7C,gEAAgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAmBrD,wEAAwE;AACxE,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAEzD,sDAAsD;AACtD,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAEjE,uEAAuE;AACvE,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAkBvD,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,MAAM,EAAE,oBAAoB;IAC5B,YAAY,EAAE,EAAE;CACjB,CAAC;AAiFF;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB;IACE,eAAe,EAAE,qBAAqB;IACtC,YAAY,EAAE,kBAAkB;IAChC,oBAAoB,EAAE,yBAAyB;IAC/C,KAAK,EAAE,mBAAmB;IAC1B,QAAQ,EAAE,sBAAsB;CACjC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Shared wire contract between the Lit devframe's node-side definition\n * ({@link ../definition.ts}) and its panel: shared-state / streaming /\n * RPC-function names, their payload shapes, and the `devframe` registry\n * augmentations that type them end to end.\n *\n * @see plans/devframe-foundation.md\n */\n\nimport {DEFAULT_LAYERS_STATE} from '../../types/timeline.js';\nimport type {\n FeatureSettings,\n SettingsOverride,\n TimelineEvent,\n TimelineLayer,\n TimelineLayersState,\n} from '../../types/timeline.js';\nimport type {\n InspectorCommand,\n InspectorDetails,\n InspectorMessage,\n InspectorTreeNode,\n} from '../../types/inspector.js';\nimport type {HmrIncompatibilityEvent} from '../../types/hmr-incompatibility.js';\nimport type {ComponentRollup, UpdateCycle} from '../timeline/derive.js';\n\n/** The devframe's scope id. RPC names become `lit:*`, MCP wire names `lit_*`. */\nexport const LIT_DEVFRAME_ID = 'lit';\n\n/** Shared-state key holding the {@link SessionState} snapshot. */\nexport const SESSION_STATE_KEY = 'session';\n\n/** Streaming channel name the timeline event batches are pushed on. */\nexport const TIMELINE_STREAM_NAME = 'timeline';\n\n/**\n * Id of the one long-lived timeline stream. Fixed rather than discovered:\n * there is exactly one page feed per dev session, so the panel can subscribe\n * without a round trip to look the id up. The node side re-`start()`s this id\n * if the transport dropped the stream after the last subscriber left.\n */\nexport const TIMELINE_STREAM_ID = 'live';\n\n/**\n * Cap on the node-side recent-events ring buffer, matching the timeline\n * stream's own `replayWindow` so an agent and a (re)connecting panel see\n * comparable history.\n */\nexport const RECENT_EVENTS_BUFFER_SIZE = 512;\n\n/** Bare (unscoped) name of the `get-meta` query. */\nexport const RPC_GET_META = 'get-meta';\n\n/** Bare name of the `list-components` query. */\nexport const RPC_LIST_COMPONENTS = 'list-components';\n\n/** Bare name of the `component-details` query. */\nexport const RPC_COMPONENT_DETAILS = 'component-details';\n\n/** Bare name of the `recent-events` query. */\nexport const RPC_RECENT_EVENTS = 'recent-events';\n\n/** Bare name of the `update-summary` query. */\nexport const RPC_UPDATE_SUMMARY = 'update-summary';\n\n/** Bare name of the `inspect` action. */\nexport const RPC_INSPECT = 'inspect';\n\n/** Bare name of the `set-recording` action. */\nexport const RPC_SET_RECORDING = 'set-recording';\n\n/** Bare name of the `toggle-layer` action. */\nexport const RPC_TOGGLE_LAYER = 'toggle-layer';\n\n/** Bare name of the `set-settings-override` action. */\nexport const RPC_SET_SETTINGS_OVERRIDE = 'set-settings-override';\n\n/** Bare name of the `open-source` action. */\nexport const RPC_OPEN_SOURCE = 'open-source';\n\n/** Arguments for {@link RPC_OPEN_SOURCE}. */\nexport interface OpenSourceArgs {\n /**\n * The path as the panel has it: what the transform injected, so relative\n * to the Vite root (or absolute, when the file lives outside it).\n */\n file: string;\n line?: number;\n}\n\n/** What {@link RPC_OPEN_SOURCE} reports back. */\nexport interface OpenSourceResult {\n /**\n * False when no open service is installed on the host, which is the\n * panel's cue to fall back to `/__lit-open-in-editor`.\n */\n opened: boolean;\n}\n\n/** Freeze the current session into a static panel directory. */\nexport const RPC_EXPORT_SNAPSHOT = 'export-snapshot';\n\n/** Arguments for {@link RPC_EXPORT_SNAPSHOT}. */\nexport interface ExportSnapshotArgs {\n /**\n * Where to write. Relative paths resolve against the dev server's cwd.\n * Defaults to `lit-devtools-snapshot`.\n */\n outDir?: string;\n}\n\n/** What {@link RPC_EXPORT_SNAPSHOT} reports back, for the panel to display. */\nexport interface ExportSnapshotResult {\n outDir: string;\n events: number;\n components: number;\n details: number;\n}\n\n/** Bare name of the `inspector-message` client (node → panel) event. */\nexport const RPC_INSPECTOR_MESSAGE = 'inspector-message';\n\n/** Bare name of the `hmr-incompatibilities` query. */\nexport const RPC_HMR_INCOMPATIBILITIES = 'hmr-incompatibilities';\n\n/** Bare name of the `hmr-incompatible` client (node → panel) event. */\nexport const RPC_HMR_INCOMPATIBLE = 'hmr-incompatible';\n\n/**\n * Recording/layers snapshot shared between every surface (panel, page\n * runtime, MCP). Survives reconnect; mutated either by the `set-recording` /\n * `toggle-layer` actions below or directly by a panel through the generic\n * shared-state RPC devframe provides.\n *\n * `layers.recordingState` is the single authority for \"is recording\" — the\n * runtime's own layer state carries it, so a separate flag here would be a\n * second copy to keep in sync.\n */\nexport interface SessionState {\n layers: TimelineLayersState;\n /** Layers announced at runtime by app code through `addTimelineLayer()`. */\n customLayers: TimelineLayer[];\n}\n\nexport const DEFAULT_SESSION_STATE: SessionState = {\n layers: DEFAULT_LAYERS_STATE,\n customLayers: [],\n};\n\n/** Result of the `get-meta` query. */\nexport interface LitGetMetaResult {\n version: string;\n /** Built-in layers followed by any runtime-announced custom ones. */\n layers: TimelineLayer[];\n features: FeatureSettings | null;\n /** Channel and id to pass to `rpc.streaming.subscribe()`. */\n stream: {channel: string; id: string};\n}\n\n/** Argument of the `component-details` query. */\nexport interface ComponentDetailsArgs {\n id: number;\n}\n\n/** Argument of the `recent-events` query. */\nexport interface RecentEventsArgs {\n layerId?: string;\n elementId?: number;\n /**\n * Only events from the last `sinceMs` milliseconds, measured against\n * the newest event currently in the buffer — not wall-clock time.\n * `TimelineEvent.time` is \"ms since recording started\" in the page\n * (see `runtime/timeline/clock.ts`), which has no fixed relationship\n * to this process's clock.\n */\n sinceMs?: number;\n /** Default 50, hard ceiling 200 regardless of what's requested. */\n limit?: number;\n}\n\n/** Result of the `recent-events` query. */\nexport interface RecentEventsResult {\n /** Whether the timeline is currently recording. */\n recording: boolean;\n /** Most recent events matching the filters, oldest first. */\n events: TimelineEvent[];\n /** Total events currently held in the ring buffer, before filtering. */\n bufferSize: number;\n /** True if filtering matched more events than were returned. */\n truncated: boolean;\n}\n\n/** Argument of the `update-summary` query. */\nexport interface UpdateSummaryArgs {\n /** Restrict to one component, by tag name. */\n tagName?: string;\n /** Same window semantics as {@link RecentEventsArgs.sinceMs}. */\n sinceMs?: number;\n /** Cycles returned (the component totals always cover the whole window).\n * Default 50, hard ceiling 200. */\n limit?: number;\n}\n\n/** Result of the `update-summary` query. */\nexport interface UpdateSummaryResult {\n /** Whether the timeline is currently recording. */\n recording: boolean;\n /** Per-component totals over the window, slowest first. */\n components: ComponentRollup[];\n /** The most recent update cycles in the window, oldest first. */\n cycles: UpdateCycle[];\n /** Total events currently held in the ring buffer, before derivation. */\n bufferSize: number;\n /** True if more cycles were derived than were returned. */\n truncated: boolean;\n}\n\n/** Argument of the `set-recording` action. */\nexport interface SetRecordingArgs {\n recording: boolean;\n}\n\n/** Argument of the `toggle-layer` action. */\nexport interface ToggleLayerArgs {\n layerId: string;\n enabled: boolean;\n}\n\n/**\n * Maps a {@link TimelineLayer.id} to the {@link TimelineLayersState} flag\n * that gates it. Custom layers have no flag and are always on.\n */\nexport const LAYER_FLAGS: Readonly<Record<string, keyof TimelineLayersState>> =\n {\n 'lit-lifecycle': 'litLifecycleEnabled',\n 'lit-render': 'litRenderEnabled',\n 'lit-render-verbose': 'litRenderVerboseEnabled',\n mouse: 'mouseEventEnabled',\n keyboard: 'keyboardEventEnabled',\n };\n\n// Hand-typed rather than derived through `RpcDefinitionsToFunctionsWithNamespace`\n// (also exported by `devframe/rpc`): the definitions themselves live in\n// definition.ts next to their handlers, and hand-typing here avoids a\n// value-level dependency from this shared-contract module back onto it.\ndeclare module 'devframe' {\n interface DevframeRpcServerFunctions {\n 'lit:get-meta': () => Promise<LitGetMetaResult>;\n 'lit:list-components': () => Promise<InspectorTreeNode[]>;\n 'lit:component-details': (\n args: ComponentDetailsArgs\n ) => Promise<InspectorDetails | null>;\n 'lit:recent-events': (\n args?: RecentEventsArgs\n ) => Promise<RecentEventsResult>;\n 'lit:update-summary': (\n args?: UpdateSummaryArgs\n ) => Promise<UpdateSummaryResult>;\n 'lit:inspect': (command: InspectorCommand) => Promise<void>;\n 'lit:set-recording': (args: SetRecordingArgs) => Promise<void>;\n 'lit:toggle-layer': (args: ToggleLayerArgs) => Promise<void>;\n 'lit:set-settings-override': (override: SettingsOverride) => Promise<void>;\n 'lit:open-source': (args: OpenSourceArgs) => Promise<OpenSourceResult>;\n 'lit:export-snapshot': (\n args: ExportSnapshotArgs\n ) => Promise<ExportSnapshotResult>;\n 'lit:hmr-incompatibilities': () => Promise<HmrIncompatibilityEvent[]>;\n }\n\n interface DevframeRpcClientFunctions {\n 'lit:inspector-message': (message: InspectorMessage) => void;\n 'lit:hmr-incompatible': (event: HmrIncompatibilityEvent) => void;\n }\n\n interface DevframeSettingsRegistry {\n lit: {\n /** Panel chrome preference. Mirrors `COLOR_SCHEME_LS_KEY`. */\n appearance?: 'auto' | 'dark' | 'light';\n /**\n * The Settings tab's live overrides, stored as one blob the way the\n * panel already treats them. Mirrors `SETTINGS_OVERRIDE_LS_KEY`, which\n * stays: the page runtime reads it synchronously at module-init time,\n * long before any client exists, and every settings-store read is\n * async by design.\n */\n override?: SettingsOverride;\n };\n }\n}\n"]}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * The `TimelineSource` port: the abstraction over "where page-runtime
8
+ * traffic comes from". The framework-neutral definition
9
+ * ({@link ../definition.ts}) only ever talks to this interface, so it can run
10
+ * under `createDevServer()` with no Vite installed. `vite.ts` supplies the
11
+ * real implementation (an `import.meta.hot` bridge); `createDevServer()` /
12
+ * `createBuild()` / an MCP server use {@link createNullSource} instead, since
13
+ * no page is attached.
14
+ */
15
+ import type { InspectorCommand, InspectorMessage } from '../../types/inspector.js';
16
+ import type { SettingsOverride, TimelineEvent, TimelineLayer, TimelineLayersState } from '../../types/timeline.js';
17
+ import type { HmrIncompatibilityEvent } from '../../types/hmr-incompatibility.js';
18
+ /** The definition's sink for events arriving from the page runtime. */
19
+ export interface TimelineSink {
20
+ pushEvents(events: TimelineEvent[]): void;
21
+ addLayer(layer: TimelineLayer): void;
22
+ inspectorMessage(msg: InspectorMessage): void;
23
+ hmrIncompatible(event: HmrIncompatibilityEvent): void;
24
+ /**
25
+ * A page runtime just connected (first load, reload, or HMR reconnect). It
26
+ * starts from the compiled-in defaults, so whatever recording/layer state
27
+ * this session already holds has to be replayed to it — otherwise a page
28
+ * loaded while recording is on silently captures nothing.
29
+ */
30
+ runtimeReady(): void;
31
+ }
32
+ /** Where the definition sends/receives page-runtime traffic. */
33
+ export interface TimelineSource {
34
+ /** Start forwarding page-runtime traffic to `sink`. Returns a detach function. */
35
+ attach(sink: TimelineSink): () => void;
36
+ sendInspector(cmd: InspectorCommand): void;
37
+ toggleOverlay(): void;
38
+ setRecording(r: boolean): void;
39
+ setLayers(l: TimelineLayersState): void;
40
+ /** Apply a live feature-settings override to the running page. */
41
+ setSettingsOverride(override: SettingsOverride): void;
42
+ }
43
+ /**
44
+ * No-op source used wherever no page is attached (`createDevServer()`,
45
+ * `createBuild()`, an MCP server). `attach()` never calls the sink; every
46
+ * other method is a no-op.
47
+ */
48
+ export declare function createNullSource(): TimelineSource;
49
+ //# sourceMappingURL=source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/lib/devframe/source.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,oCAAoC,CAAC;AAEhF,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC9C,eAAe,CAAC,KAAK,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACtD;;;;;OAKG;IACH,YAAY,IAAI,IAAI,CAAC;CACtB;AAED,gEAAgE;AAChE,MAAM,WAAW,cAAc;IAC7B,kFAAkF;IAClF,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,IAAI,CAAC;IACvC,aAAa,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC3C,aAAa,IAAI,IAAI,CAAC;IACtB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACxC,kEAAkE;IAClE,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,cAAc,CAWjD"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * No-op source used wherever no page is attached (`createDevServer()`,
8
+ * `createBuild()`, an MCP server). `attach()` never calls the sink; every
9
+ * other method is a no-op.
10
+ */
11
+ export function createNullSource() {
12
+ return {
13
+ attach() {
14
+ return () => {};
15
+ },
16
+ sendInspector() {},
17
+ toggleOverlay() {},
18
+ setRecording() {},
19
+ setLayers() {},
20
+ setSettingsOverride() {},
21
+ };
22
+ }
23
+ //# sourceMappingURL=source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/lib/devframe/source.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmDH;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,MAAM;YACJ,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;QAClB,CAAC;QACD,aAAa,KAAI,CAAC;QAClB,aAAa,KAAI,CAAC;QAClB,YAAY,KAAI,CAAC;QACjB,SAAS,KAAI,CAAC;QACd,mBAAmB,KAAI,CAAC;KACzB,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * The `TimelineSource` port: the abstraction over \"where page-runtime\n * traffic comes from\". The framework-neutral definition\n * ({@link ../definition.ts}) only ever talks to this interface, so it can run\n * under `createDevServer()` with no Vite installed. `vite.ts` supplies the\n * real implementation (an `import.meta.hot` bridge); `createDevServer()` /\n * `createBuild()` / an MCP server use {@link createNullSource} instead, since\n * no page is attached.\n */\n\nimport type {\n InspectorCommand,\n InspectorMessage,\n} from '../../types/inspector.js';\nimport type {\n SettingsOverride,\n TimelineEvent,\n TimelineLayer,\n TimelineLayersState,\n} from '../../types/timeline.js';\nimport type {HmrIncompatibilityEvent} from '../../types/hmr-incompatibility.js';\n\n/** The definition's sink for events arriving from the page runtime. */\nexport interface TimelineSink {\n pushEvents(events: TimelineEvent[]): void;\n addLayer(layer: TimelineLayer): void;\n inspectorMessage(msg: InspectorMessage): void;\n hmrIncompatible(event: HmrIncompatibilityEvent): void;\n /**\n * A page runtime just connected (first load, reload, or HMR reconnect). It\n * starts from the compiled-in defaults, so whatever recording/layer state\n * this session already holds has to be replayed to it — otherwise a page\n * loaded while recording is on silently captures nothing.\n */\n runtimeReady(): void;\n}\n\n/** Where the definition sends/receives page-runtime traffic. */\nexport interface TimelineSource {\n /** Start forwarding page-runtime traffic to `sink`. Returns a detach function. */\n attach(sink: TimelineSink): () => void;\n sendInspector(cmd: InspectorCommand): void;\n toggleOverlay(): void;\n setRecording(r: boolean): void;\n setLayers(l: TimelineLayersState): void;\n /** Apply a live feature-settings override to the running page. */\n setSettingsOverride(override: SettingsOverride): void;\n}\n\n/**\n * No-op source used wherever no page is attached (`createDevServer()`,\n * `createBuild()`, an MCP server). `attach()` never calls the sink; every\n * other method is a no-op.\n */\nexport function createNullSource(): TimelineSource {\n return {\n attach() {\n return () => {};\n },\n sendInspector() {},\n toggleOverlay() {},\n setRecording() {},\n setLayers() {},\n setSettingsOverride() {},\n };\n}\n"]}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * Mounts the Lit devframe ({@link createLitDevframe}) into the Vite DevTools
8
+ * hub and bridges the page runtime's `import.meta.hot` transport to the
9
+ * definition's `TimelineSource` port. Everything Vite-specific lives here:
10
+ * the definition itself must keep running under `createDevServer()` with no
11
+ * Vite installed.
12
+ *
13
+ * Vite DevTools 0.7+ is itself built on devframe, so its plugin context is a
14
+ * devframe hub context: `ctx.install(definition)` serves the panel SPA from
15
+ * the definition's `clientAssets`, registers its dock, and exposes its RPC
16
+ * over the hub's authenticated WebSocket. That is all
17
+ * `createPluginFromDevframe()` from `@vitejs/devtools-kit` does, so calling
18
+ * `install` directly keeps DevTools an optional peer we never import at
19
+ * runtime — the hook below is duck-typed, exactly as the panel's previous
20
+ * dock registration was.
21
+ *
22
+ * @see plans/devframe-foundation.md
23
+ */
24
+ import type { Plugin, ViteDevServer } from 'vite';
25
+ import type { DevframeDefinition } from 'devframe';
26
+ import type { InspectorCommand } from '../../types/inspector.js';
27
+ import type { FeatureSettings, SettingsOverride, TimelineLayersState } from '../../types/timeline.js';
28
+ import { createLitDevframe } from './definition.js';
29
+ import type { TimelineSink, TimelineSource } from './source.js';
30
+ export { createLitDevframe };
31
+ /**
32
+ * The slice of the Vite DevTools hub context this plugin uses. Structurally a
33
+ * subset of `ViteDevToolsNodeContext` from `@vitejs/devtools-kit/node`;
34
+ * declared here so the package never imports that optional peer at runtime.
35
+ * Install `@vitejs/devtools-kit` as a dev dependency to check it against the
36
+ * real declarations.
37
+ */
38
+ interface DevToolsHubContext {
39
+ readonly viteServer?: ViteDevServer;
40
+ /** Serve a devframe's SPA, register its dock, and run its `setup()`. */
41
+ install: (devframe: DevframeDefinition, options?: {
42
+ base?: string;
43
+ dock?: Record<string, unknown>;
44
+ }) => Promise<void>;
45
+ docks?: {
46
+ activate?: (dockId: string, params?: Record<string, unknown>) => void;
47
+ };
48
+ commands?: {
49
+ register?: (command: Record<string, unknown>) => unknown;
50
+ };
51
+ /**
52
+ * The hub's host runtime. Structurally the slice of devframe's
53
+ * `DevframeHost` {@link registerInstance} needs; `DevframeHubContext`
54
+ * extends `DevframeNodeContext`, which carries it.
55
+ */
56
+ host?: {
57
+ resolveOrigin?: () => string;
58
+ };
59
+ }
60
+ declare module 'vite' {
61
+ interface Plugin {
62
+ /** Vite DevTools plugin hook, contributed by `@vitejs/devtools`. */
63
+ devtools?: {
64
+ capabilities?: {
65
+ dev?: boolean;
66
+ build?: boolean;
67
+ };
68
+ setup: (ctx: DevToolsHubContext) => void | Promise<void>;
69
+ };
70
+ }
71
+ }
72
+ export interface CreateLitDevframePluginOptions {
73
+ version: string;
74
+ features?: () => FeatureSettings | null;
75
+ /** Override the built panel SPA directory. Defaults to `dist/client`. */
76
+ clientAssets?: string;
77
+ }
78
+ /**
79
+ * `TimelineSource` over a Vite dev server's `hot` channel.
80
+ *
81
+ * `install()` runs the definition's `setup()` — and therefore
82
+ * `source.attach()` — before it resolves, so this is attached before a dev
83
+ * server is necessarily in hand. Calls made before {@link bind} are dropped
84
+ * rather than buffered: nothing can emit a page-runtime event until a page
85
+ * has connected to a bound server.
86
+ */
87
+ export declare class HotTimelineSource implements TimelineSource {
88
+ #private;
89
+ /**
90
+ * Wire the source to a live dev server. Call once, from `devtools.setup()`.
91
+ * `hub` is optional: without it the bridge still carries page traffic both
92
+ * ways, it just cannot bring the dock to the front on an overlay pick.
93
+ */
94
+ bind(server: ViteDevServer, hub?: DevToolsHubContext): void;
95
+ /** Toggle the page's inspect overlay. Also used by the palette command. */
96
+ toggleOverlay(): void;
97
+ attach(sink: TimelineSink): () => void;
98
+ sendInspector(cmd: InspectorCommand): void;
99
+ setRecording(recording: boolean): void;
100
+ setLayers(layers: TimelineLayersState): void;
101
+ setSettingsOverride(override: SettingsOverride): void;
102
+ }
103
+ /**
104
+ * The Vite plugin that mounts the Lit devframe on the DevTools hub. A no-op
105
+ * when DevTools is not active: without it nothing calls `devtools.setup()`,
106
+ * so the definition is never installed and the panel simply isn't there.
107
+ */
108
+ export declare function createLitDevframePlugin(options: CreateLitDevframePluginOptions): Plugin;
109
+ /**
110
+ * The page-runtime bridge on its own, for a host that drives its own mount
111
+ * (or a test that wants to observe page traffic without a hub). Bind it to a
112
+ * dev server, then either hand it to {@link createLitDevframe} or
113
+ * {@link TimelineSource.attach} your own sink.
114
+ */
115
+ export declare const createHotTimelineSource: () => HotTimelineSource;
116
+ //# sourceMappingURL=vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/lib/devframe/vite.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;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