@oddsquad/vite-plugin-lit 0.6.1 → 0.8.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 (292) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/LICENSE +1 -1
  3. package/README.md +40 -17
  4. package/bin.mjs +89 -13
  5. package/client.d.ts +0 -6
  6. package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-F2EfZsFX.js → browser-agent-rpc-BXhoSh1z-ybEeG-x9.js} +2 -2
  7. package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-F2EfZsFX.js.map → browser-agent-rpc-BXhoSh1z-ybEeG-x9.js.map} +1 -1
  8. package/dist/client/assets/{index-B2HYO7lk.js → index-CgkhETVR.js} +22 -145
  9. package/dist/client/assets/index-CgkhETVR.js.map +1 -0
  10. package/dist/client/index.html +1 -1
  11. package/dist/standalone/lit-devtools.js +6717 -0
  12. package/index.d.ts +0 -5
  13. package/index.d.ts.map +1 -1
  14. package/index.js +1 -5
  15. package/index.js.map +1 -1
  16. package/lib/color-scheme.d.ts +0 -5
  17. package/lib/color-scheme.d.ts.map +1 -1
  18. package/lib/color-scheme.js +0 -5
  19. package/lib/color-scheme.js.map +1 -1
  20. package/lib/confine.d.ts +0 -5
  21. package/lib/confine.d.ts.map +1 -1
  22. package/lib/confine.js +0 -5
  23. package/lib/confine.js.map +1 -1
  24. package/lib/devframe/allowed-origins.d.ts +21 -0
  25. package/lib/devframe/allowed-origins.d.ts.map +1 -0
  26. package/lib/devframe/allowed-origins.js +58 -0
  27. package/lib/devframe/allowed-origins.js.map +1 -0
  28. package/lib/devframe/definition.d.ts +7 -3
  29. package/lib/devframe/definition.d.ts.map +1 -1
  30. package/lib/devframe/definition.js +1 -6
  31. package/lib/devframe/definition.js.map +1 -1
  32. package/lib/devframe/icon.d.ts +0 -5
  33. package/lib/devframe/icon.d.ts.map +1 -1
  34. package/lib/devframe/icon.js +0 -5
  35. package/lib/devframe/icon.js.map +1 -1
  36. package/lib/devframe/launch-editor.d.ts +0 -5
  37. package/lib/devframe/launch-editor.d.ts.map +1 -1
  38. package/lib/devframe/launch-editor.js +0 -5
  39. package/lib/devframe/launch-editor.js.map +1 -1
  40. package/lib/devframe/paths.d.ts +8 -3
  41. package/lib/devframe/paths.d.ts.map +1 -1
  42. package/lib/devframe/paths.js +0 -5
  43. package/lib/devframe/paths.js.map +1 -1
  44. package/lib/devframe/protocol.d.ts +6 -3
  45. package/lib/devframe/protocol.d.ts.map +1 -1
  46. package/lib/devframe/protocol.js +0 -5
  47. package/lib/devframe/protocol.js.map +1 -1
  48. package/lib/devframe/rpc-source.d.ts +15 -3
  49. package/lib/devframe/rpc-source.d.ts.map +1 -1
  50. package/lib/devframe/rpc-source.js +0 -5
  51. package/lib/devframe/rpc-source.js.map +1 -1
  52. package/lib/devframe/source.d.ts +0 -5
  53. package/lib/devframe/source.d.ts.map +1 -1
  54. package/lib/devframe/source.js +7 -3
  55. package/lib/devframe/source.js.map +1 -1
  56. package/lib/devframe/vite.d.ts +0 -5
  57. package/lib/devframe/vite.d.ts.map +1 -1
  58. package/lib/devframe/vite.js +16 -3
  59. package/lib/devframe/vite.js.map +1 -1
  60. package/lib/http.d.ts +0 -5
  61. package/lib/http.d.ts.map +1 -1
  62. package/lib/http.js +0 -5
  63. package/lib/http.js.map +1 -1
  64. package/lib/icons.d.ts +0 -5
  65. package/lib/icons.d.ts.map +1 -1
  66. package/lib/icons.js +0 -5
  67. package/lib/icons.js.map +1 -1
  68. package/lib/options.d.ts +26 -5
  69. package/lib/options.d.ts.map +1 -1
  70. package/lib/options.js +19 -5
  71. package/lib/options.js.map +1 -1
  72. package/lib/override-baselines.d.ts +0 -5
  73. package/lib/override-baselines.d.ts.map +1 -1
  74. package/lib/override-baselines.js +0 -5
  75. package/lib/override-baselines.js.map +1 -1
  76. package/lib/plugin.d.ts +0 -5
  77. package/lib/plugin.d.ts.map +1 -1
  78. package/lib/plugin.js +3 -5
  79. package/lib/plugin.js.map +1 -1
  80. package/lib/plugins/css-literals.d.ts +0 -5
  81. package/lib/plugins/css-literals.d.ts.map +1 -1
  82. package/lib/plugins/css-literals.js +0 -5
  83. package/lib/plugins/css-literals.js.map +1 -1
  84. package/lib/plugins/css-queries.d.ts +0 -5
  85. package/lib/plugins/css-queries.d.ts.map +1 -1
  86. package/lib/plugins/css-queries.js +0 -5
  87. package/lib/plugins/css-queries.js.map +1 -1
  88. package/lib/plugins/open-in-editor.d.ts +0 -5
  89. package/lib/plugins/open-in-editor.d.ts.map +1 -1
  90. package/lib/plugins/open-in-editor.js +0 -5
  91. package/lib/plugins/open-in-editor.js.map +1 -1
  92. package/lib/plugins/private-fields.d.ts +22 -0
  93. package/lib/plugins/private-fields.d.ts.map +1 -0
  94. package/lib/plugins/private-fields.js +254 -0
  95. package/lib/plugins/private-fields.js.map +1 -0
  96. package/lib/plugins/shared.d.ts +0 -5
  97. package/lib/plugins/shared.d.ts.map +1 -1
  98. package/lib/plugins/shared.js +0 -5
  99. package/lib/plugins/shared.js.map +1 -1
  100. package/lib/plugins/timeline-virtual.d.ts +0 -5
  101. package/lib/plugins/timeline-virtual.d.ts.map +1 -1
  102. package/lib/plugins/timeline-virtual.js +0 -5
  103. package/lib/plugins/timeline-virtual.js.map +1 -1
  104. package/lib/runtime/child-state.d.ts +95 -0
  105. package/lib/runtime/child-state.d.ts.map +1 -0
  106. package/lib/runtime/child-state.js +461 -0
  107. package/lib/runtime/child-state.js.map +1 -0
  108. package/lib/runtime/css.d.ts +14 -3
  109. package/lib/runtime/css.d.ts.map +1 -1
  110. package/lib/runtime/css.js +3 -5
  111. package/lib/runtime/css.js.map +1 -1
  112. package/lib/runtime/edge-panel.d.ts +8 -3
  113. package/lib/runtime/edge-panel.d.ts.map +1 -1
  114. package/lib/runtime/edge-panel.js +0 -5
  115. package/lib/runtime/edge-panel.js.map +1 -1
  116. package/lib/runtime/fonts.d.ts +0 -5
  117. package/lib/runtime/fonts.d.ts.map +1 -1
  118. package/lib/runtime/fonts.js +0 -5
  119. package/lib/runtime/fonts.js.map +1 -1
  120. package/lib/runtime/indicator.d.ts +3 -3
  121. package/lib/runtime/indicator.js +0 -5
  122. package/lib/runtime/indicator.js.map +1 -1
  123. package/lib/runtime/inspector/collect.d.ts +3 -3
  124. package/lib/runtime/inspector/collect.d.ts.map +1 -1
  125. package/lib/runtime/inspector/collect.js +0 -5
  126. package/lib/runtime/inspector/collect.js.map +1 -1
  127. package/lib/runtime/inspector/highlight.d.ts +10 -3
  128. package/lib/runtime/inspector/highlight.d.ts.map +1 -1
  129. package/lib/runtime/inspector/highlight.js +0 -5
  130. package/lib/runtime/inspector/highlight.js.map +1 -1
  131. package/lib/runtime/inspector/install.d.ts +6 -3
  132. package/lib/runtime/inspector/install.d.ts.map +1 -1
  133. package/lib/runtime/inspector/install.js +4 -6
  134. package/lib/runtime/inspector/install.js.map +1 -1
  135. package/lib/runtime/inspector/serialize.d.ts +4 -3
  136. package/lib/runtime/inspector/serialize.d.ts.map +1 -1
  137. package/lib/runtime/inspector/serialize.js +0 -5
  138. package/lib/runtime/inspector/serialize.js.map +1 -1
  139. package/lib/runtime/intern.d.ts +11 -3
  140. package/lib/runtime/intern.d.ts.map +1 -1
  141. package/lib/runtime/intern.js +11 -3
  142. package/lib/runtime/intern.js.map +1 -1
  143. package/lib/runtime/overrides.d.ts +3 -3
  144. package/lib/runtime/overrides.d.ts.map +1 -1
  145. package/lib/runtime/overrides.js +0 -5
  146. package/lib/runtime/overrides.js.map +1 -1
  147. package/lib/runtime/page-channel.d.ts +0 -5
  148. package/lib/runtime/page-channel.d.ts.map +1 -1
  149. package/lib/runtime/page-channel.js +13 -3
  150. package/lib/runtime/page-channel.js.map +1 -1
  151. package/lib/runtime/patch.d.ts +22 -3
  152. package/lib/runtime/patch.d.ts.map +1 -1
  153. package/lib/runtime/patch.js +22 -6
  154. package/lib/runtime/patch.js.map +1 -1
  155. package/lib/runtime/rpc-transport.d.ts +21 -3
  156. package/lib/runtime/rpc-transport.d.ts.map +1 -1
  157. package/lib/runtime/rpc-transport.js +4 -5
  158. package/lib/runtime/rpc-transport.js.map +1 -1
  159. package/lib/runtime/source-meta.d.ts +0 -5
  160. package/lib/runtime/source-meta.d.ts.map +1 -1
  161. package/lib/runtime/source-meta.js +0 -5
  162. package/lib/runtime/source-meta.js.map +1 -1
  163. package/lib/runtime/source-overlay/editors.d.ts +0 -5
  164. package/lib/runtime/source-overlay/editors.d.ts.map +1 -1
  165. package/lib/runtime/source-overlay/editors.js +9 -9
  166. package/lib/runtime/source-overlay/editors.js.map +1 -1
  167. package/lib/runtime/source-overlay/mask-path.d.ts +0 -5
  168. package/lib/runtime/source-overlay/mask-path.d.ts.map +1 -1
  169. package/lib/runtime/source-overlay/mask-path.js +0 -5
  170. package/lib/runtime/source-overlay/mask-path.js.map +1 -1
  171. package/lib/runtime/source-overlay/overlay-element.d.ts +0 -5
  172. package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -1
  173. package/lib/runtime/source-overlay/overlay-element.js +0 -5
  174. package/lib/runtime/source-overlay/overlay-element.js.map +1 -1
  175. package/lib/runtime/source-overlay/source-host.d.ts +0 -5
  176. package/lib/runtime/source-overlay/source-host.d.ts.map +1 -1
  177. package/lib/runtime/source-overlay/source-host.js +0 -5
  178. package/lib/runtime/source-overlay/source-host.js.map +1 -1
  179. package/lib/runtime/source-overlay/template.d.ts +0 -5
  180. package/lib/runtime/source-overlay/template.d.ts.map +1 -1
  181. package/lib/runtime/source-overlay/template.js +0 -5
  182. package/lib/runtime/source-overlay/template.js.map +1 -1
  183. package/lib/runtime/source-overlay.d.ts +0 -5
  184. package/lib/runtime/source-overlay.d.ts.map +1 -1
  185. package/lib/runtime/source-overlay.js +0 -5
  186. package/lib/runtime/source-overlay.js.map +1 -1
  187. package/lib/runtime/standalone.d.ts +22 -0
  188. package/lib/runtime/standalone.d.ts.map +1 -0
  189. package/lib/runtime/standalone.js +45 -0
  190. package/lib/runtime/standalone.js.map +1 -0
  191. package/lib/runtime/timeline/chrome-tracks.d.ts +0 -5
  192. package/lib/runtime/timeline/chrome-tracks.d.ts.map +1 -1
  193. package/lib/runtime/timeline/chrome-tracks.js +5 -3
  194. package/lib/runtime/timeline/chrome-tracks.js.map +1 -1
  195. package/lib/runtime/timeline/clock.d.ts +7 -3
  196. package/lib/runtime/timeline/clock.d.ts.map +1 -1
  197. package/lib/runtime/timeline/clock.js +0 -5
  198. package/lib/runtime/timeline/clock.js.map +1 -1
  199. package/lib/runtime/timeline/flash.d.ts +0 -5
  200. package/lib/runtime/timeline/flash.d.ts.map +1 -1
  201. package/lib/runtime/timeline/flash.js +15 -3
  202. package/lib/runtime/timeline/flash.js.map +1 -1
  203. package/lib/runtime/timeline/identity.d.ts +0 -5
  204. package/lib/runtime/timeline/identity.d.ts.map +1 -1
  205. package/lib/runtime/timeline/identity.js +9 -3
  206. package/lib/runtime/timeline/identity.js.map +1 -1
  207. package/lib/runtime/timeline/input.d.ts +0 -5
  208. package/lib/runtime/timeline/input.d.ts.map +1 -1
  209. package/lib/runtime/timeline/input.js +2 -3
  210. package/lib/runtime/timeline/input.js.map +1 -1
  211. package/lib/runtime/timeline/install.d.ts +11 -3
  212. package/lib/runtime/timeline/install.d.ts.map +1 -1
  213. package/lib/runtime/timeline/install.js +4 -7
  214. package/lib/runtime/timeline/install.js.map +1 -1
  215. package/lib/runtime/timeline/lifecycle.d.ts +13 -3
  216. package/lib/runtime/timeline/lifecycle.d.ts.map +1 -1
  217. package/lib/runtime/timeline/lifecycle.js +5 -6
  218. package/lib/runtime/timeline/lifecycle.js.map +1 -1
  219. package/lib/runtime/timeline/public-api.d.ts +6 -3
  220. package/lib/runtime/timeline/public-api.d.ts.map +1 -1
  221. package/lib/runtime/timeline/public-api.js +0 -5
  222. package/lib/runtime/timeline/public-api.js.map +1 -1
  223. package/lib/runtime/timeline/render.d.ts +0 -5
  224. package/lib/runtime/timeline/render.d.ts.map +1 -1
  225. package/lib/runtime/timeline/render.js +21 -3
  226. package/lib/runtime/timeline/render.js.map +1 -1
  227. package/lib/runtime/timeline/transport.d.ts +0 -5
  228. package/lib/runtime/timeline/transport.d.ts.map +1 -1
  229. package/lib/runtime/timeline/transport.js +10 -3
  230. package/lib/runtime/timeline/transport.js.map +1 -1
  231. package/lib/segmented-tabs.d.ts +0 -5
  232. package/lib/segmented-tabs.d.ts.map +1 -1
  233. package/lib/segmented-tabs.js +0 -5
  234. package/lib/segmented-tabs.js.map +1 -1
  235. package/lib/snapshot.d.ts +11 -3
  236. package/lib/snapshot.d.ts.map +1 -1
  237. package/lib/snapshot.js +0 -5
  238. package/lib/snapshot.js.map +1 -1
  239. package/lib/source-meta.d.ts +0 -5
  240. package/lib/source-meta.d.ts.map +1 -1
  241. package/lib/source-meta.js +0 -5
  242. package/lib/source-meta.js.map +1 -1
  243. package/lib/timeline/derive.d.ts +0 -5
  244. package/lib/timeline/derive.d.ts.map +1 -1
  245. package/lib/timeline/derive.js +22 -3
  246. package/lib/timeline/derive.js.map +1 -1
  247. package/lib/timeline/filter.d.ts +0 -5
  248. package/lib/timeline/filter.d.ts.map +1 -1
  249. package/lib/timeline/filter.js +6 -3
  250. package/lib/timeline/filter.js.map +1 -1
  251. package/lib/timeline/tracks.d.ts +0 -5
  252. package/lib/timeline/tracks.d.ts.map +1 -1
  253. package/lib/timeline/tracks.js +12 -3
  254. package/lib/timeline/tracks.js.map +1 -1
  255. package/lib/tokens.d.ts +0 -5
  256. package/lib/tokens.d.ts.map +1 -1
  257. package/lib/tokens.js +0 -5
  258. package/lib/tokens.js.map +1 -1
  259. package/lib/transform.d.ts +0 -5
  260. package/lib/transform.d.ts.map +1 -1
  261. package/lib/transform.js +0 -5
  262. package/lib/transform.js.map +1 -1
  263. package/lib/types.d.ts +10 -5
  264. package/lib/types.d.ts.map +1 -1
  265. package/lib/types.js +0 -5
  266. package/lib/types.js.map +1 -1
  267. package/lib/wrap-table.d.ts +0 -5
  268. package/lib/wrap-table.d.ts.map +1 -1
  269. package/lib/wrap-table.js +12 -3
  270. package/lib/wrap-table.js.map +1 -1
  271. package/package.json +14 -10
  272. package/types/hmr-incompatibility.d.ts +0 -5
  273. package/types/hmr-incompatibility.d.ts.map +1 -1
  274. package/types/hmr-incompatibility.js +13 -3
  275. package/types/hmr-incompatibility.js.map +1 -1
  276. package/types/in-page.d.ts +0 -5
  277. package/types/in-page.d.ts.map +1 -1
  278. package/types/in-page.js +0 -5
  279. package/types/in-page.js.map +1 -1
  280. package/types/inspector.d.ts +0 -5
  281. package/types/inspector.d.ts.map +1 -1
  282. package/types/inspector.js +13 -3
  283. package/types/inspector.js.map +1 -1
  284. package/types/snapshot.d.ts +0 -5
  285. package/types/snapshot.d.ts.map +1 -1
  286. package/types/snapshot.js +12 -3
  287. package/types/snapshot.js.map +1 -1
  288. package/types/timeline.d.ts +4 -6
  289. package/types/timeline.d.ts.map +1 -1
  290. package/types/timeline.js +0 -5
  291. package/types/timeline.js.map +1 -1
  292. package/dist/client/assets/index-B2HYO7lk.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/overrides.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,gEAAgE;AAChE,KAAK,GAAG,GAAG,WAAW,GAAG,SAAS,CAAC;AAEnC,mEAAmE;AACnE,eAAO,MAAM,YAAY,QAAO,gBAQ/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QACvB,GAAG,SACD,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,KAC1C,IAMF,CAAC"}
1
+ {"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/overrides.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,gEAAgE;AAChE,KAAK,GAAG,GAAG,WAAW,GAAG,SAAS,CAAC;AAEnC,mEAAmE;AACnE,eAAO,MAAM,YAAY,QAAO,gBAQ/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QACvB,GAAG,SACD,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,KAC1C,IAMF,CAAC"}
@@ -1,8 +1,3 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
1
  /**
7
2
  * Browser-runtime side of the panel's live setting overrides. Reads the
8
3
  * persisted override (written by the panel; same origin) and subscribes to the
@@ -1 +1 @@
1
- {"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../src/lib/runtime/overrides.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EACL,yBAAyB,EACzB,wBAAwB,GAEzB,MAAM,yBAAyB,CAAC;AAKjC,mEAAmE;AACnE,MAAM,CAAC,MAAM,YAAY,GAAG,GAAqB,EAAE;IACjD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;QAC3D,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,6DAA6D;IAC/D,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,GAAQ,EACR,KAA2C,EACrC,EAAE;IACR,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;IACtB,IAAI,GAAG,KAAK,SAAS;QAAE,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACnD,WAAW,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,EAAE,CACjD,KAAK,CAAC,CAAC,IAAI,IAAI,EAAE,CAAqB,CAAC,CACxC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Browser-runtime side of the panel's live setting overrides. Reads the\n * persisted override (written by the panel; same origin) and subscribes to the\n * page channel the server rebroadcasts panel changes on.\n */\n\nimport {pageChannel} from './page-channel.js';\nimport type {ViteHotLike} from './page-channel.js';\n\nimport {\n SETTINGS_OVERRIDE_CHANNEL,\n SETTINGS_OVERRIDE_LS_KEY,\n type SettingsOverride,\n} from '../../types/timeline.js';\n\n/** `import.meta.hot` of the calling module, when it has one. */\ntype Hot = ViteHotLike | undefined;\n\n/** Reads the persisted override; `{}` when unset or unparsable. */\nexport const readOverride = (): SettingsOverride => {\n try {\n const raw = localStorage.getItem(SETTINGS_OVERRIDE_LS_KEY);\n if (raw !== null) return JSON.parse(raw) as SettingsOverride;\n } catch {\n // storage unavailable / malformed — fall through to defaults\n }\n return {};\n};\n\n/**\n * Applies the persisted override immediately, then again whenever the panel\n * pushes a change over the page channel. `apply` receives the full override\n * object each time and should act only on the fields it owns.\n */\nexport const subscribeOverride = (\n hot: Hot,\n apply: (override: SettingsOverride) => void\n): void => {\n apply(readOverride());\n if (hot !== undefined) pageChannel.useViteHot(hot);\n pageChannel.on(SETTINGS_OVERRIDE_CHANNEL, (data) =>\n apply((data ?? {}) as SettingsOverride)\n );\n};\n"]}
1
+ {"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../src/lib/runtime/overrides.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EACL,yBAAyB,EACzB,wBAAwB,GAEzB,MAAM,yBAAyB,CAAC;AAKjC,mEAAmE;AACnE,MAAM,CAAC,MAAM,YAAY,GAAG,GAAqB,EAAE;IACjD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;QAC3D,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,6DAA6D;IAC/D,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,GAAQ,EACR,KAA2C,EACrC,EAAE;IACR,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;IACtB,IAAI,GAAG,KAAK,SAAS;QAAE,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACnD,WAAW,CAAC,EAAE,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,EAAE,CACjD,KAAK,CAAC,CAAC,IAAI,IAAI,EAAE,CAAqB,CAAC,CACxC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Browser-runtime side of the panel's live setting overrides. Reads the\n * persisted override (written by the panel; same origin) and subscribes to the\n * page channel the server rebroadcasts panel changes on.\n */\n\nimport {pageChannel} from './page-channel.js';\nimport type {ViteHotLike} from './page-channel.js';\n\nimport {\n SETTINGS_OVERRIDE_CHANNEL,\n SETTINGS_OVERRIDE_LS_KEY,\n type SettingsOverride,\n} from '../../types/timeline.js';\n\n/** `import.meta.hot` of the calling module, when it has one. */\ntype Hot = ViteHotLike | undefined;\n\n/** Reads the persisted override; `{}` when unset or unparsable. */\nexport const readOverride = (): SettingsOverride => {\n try {\n const raw = localStorage.getItem(SETTINGS_OVERRIDE_LS_KEY);\n if (raw !== null) return JSON.parse(raw) as SettingsOverride;\n } catch {\n // storage unavailable / malformed — fall through to defaults\n }\n return {};\n};\n\n/**\n * Applies the persisted override immediately, then again whenever the panel\n * pushes a change over the page channel. `apply` receives the full override\n * object each time and should act only on the fields it owns.\n */\nexport const subscribeOverride = (\n hot: Hot,\n apply: (override: SettingsOverride) => void\n): void => {\n apply(readOverride());\n if (hot !== undefined) pageChannel.useViteHot(hot);\n pageChannel.on(SETTINGS_OVERRIDE_CHANNEL, (data) =>\n apply((data ?? {}) as SettingsOverride)\n );\n};\n"]}
@@ -1,8 +1,3 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
1
  /**
7
2
  * The page runtime's one seam to whatever carries its traffic to the DevTools
8
3
  * server. Every `lit:*` message the runtime sends or receives (timeline
@@ -1 +1 @@
1
- {"version":3,"file":"page-channel.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/page-channel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,2EAA2E;IAC3E,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACnE;AAED,oEAAoE;AACpE,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1C,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAAC;IACtD,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAAC;CACzD;AAED,0DAA0D;AAC1D,eAAO,MAAM,W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AW,QAAS,WAAW,KAAG,aAM7C,CAAC;AAEH,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,SAAS,EAAE,aAAa,GAAG,SAAS,CAAC;IAC9C;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;IACvC,sEAAsE;IACtE,UAAU,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CACtC;AA+DD,eAAO,MAAM,WAAW,EAAE,WACJ,CAAC"}
@@ -1,7 +1,17 @@
1
1
  /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
2
+ * The page runtime's one seam to whatever carries its traffic to the DevTools
3
+ * server. Every `lit:*` message the runtime sends or receives (timeline
4
+ * events, inspector data and commands, settings overrides, HMR-incompatibility
5
+ * notices) goes through {@link pageChannel}, never through `import.meta.hot`
6
+ * directly, so the carrier can be swapped without touching a call site.
7
+ *
8
+ * The default carrier is Vite's HMR channel ({@link fromViteHot}). An
9
+ * alternative (see `rpc-transport.ts`) is attached with
10
+ * {@link PageChannel.attach}; listeners registered earlier move over to it.
11
+ *
12
+ * Vite's own lifecycle events (`vite:afterUpdate`, `vite:beforeFullReload`,
13
+ * `vite:ws:*`) are not part of this channel: they describe the HMR connection
14
+ * itself, so the sites that care still read `import.meta.hot` for those.
5
15
  */
6
16
  /** Wraps Vite's HMR client as a {@link PageTransport}. */
7
17
  export const fromViteHot = (hot) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"page-channel.js","sourceRoot":"","sources":["../../src/lib/runtime/page-channel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgCH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,WAAW,GAAG,C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,CAAC,KAAK,CAAC,CAAC;gBACvC,IAAI,KAAK,KAAK,CAAC,CAAC;oBAAE,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC/C,CAAC,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,IAAI;YACT,KAAK,MAAM,KAAK,IAAI,SAAS;gBAAE,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC;YAC7C,SAAS,GAAG,IAAI,CAAC;YACjB,KAAK,MAAM,KAAK,IAAI,SAAS;gBAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3C,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;gBACvC,IAAI,CAAC;oBACH,QAAQ,EAAE,CAAC;gBACb,CAAC;gBAAC,MAAM,CAAC;oBACP,0DAA0D;gBAC5D,CAAC;YACH,CAAC;QACH,CAAC;QACD,UAAU,CAAC,GAAG;YACZ,IAAI,SAAS,KAAK,SAAS;gBAAE,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QAChE,CAAC;QACD,QAAQ,CAAC,QAAQ;YACf,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;KACF,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,8EAA8E;AAC9E,gFAAgF;AAChF,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;AAEzE,MAAM,MAAM,GAAG,UAAgE,CAAC;AAEhF,MAAM,CAAC,MAAM,WAAW,GAAgB,CAAC,MAAM,CAAC,WAAW,CAAC;IAC1D,iBAAiB,EAAE,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * The page runtime's one seam to whatever carries its traffic to the DevTools\n * server. Every `lit:*` message the runtime sends or receives (timeline\n * events, inspector data and commands, settings overrides, HMR-incompatibility\n * notices) goes through {@link pageChannel}, never through `import.meta.hot`\n * directly, so the carrier can be swapped without touching a call site.\n *\n * The default carrier is Vite's HMR channel ({@link fromViteHot}). An\n * alternative (see `rpc-transport.ts`) is attached with\n * {@link PageChannel.attach}; listeners registered earlier move over to it.\n *\n * Vite's own lifecycle events (`vite:afterUpdate`, `vite:beforeFullReload`,\n * `vite:ws:*`) are not part of this channel: they describe the HMR connection\n * itself, so the sites that care still read `import.meta.hot` for those.\n */\n\n/** A carrier for named messages between the page runtime and the server. */\nexport interface PageTransport {\n send(channel: string, data?: unknown): void;\n /** Listen on a channel. Returns the function that removes the listener. */\n on(channel: string, handler: (data: unknown) => void): () => void;\n}\n\n/** The slice of `import.meta.hot` the default carrier relies on. */\nexport interface ViteHotLike {\n send(event: string, data?: unknown): void;\n on(event: string, handler: (data: any) => void): void;\n off?(event: string, handler: (data: any) => void): void;\n}\n\n/** Wraps Vite's HMR client as a {@link PageTransport}. */\nexport const fromViteHot = (hot: ViteHotLike): PageTransport => ({\n send: (channel, data) => hot.send(channel, data),\n on(channel, handler) {\n hot.on(channel, handler);\n return () => hot.off?.(channel, handler);\n },\n});\n\nexport interface PageChannel extends PageTransport {\n /** Whether a carrier is attached. Sends made before one is are dropped. */\n readonly attached: boolean;\n /** The carrier in use, so a replacement can hand the channel back. */\n readonly transport: PageTransport | undefined;\n /**\n * Make `transport` the carrier. Listeners already registered are moved onto\n * it and removed from the previous carrier, and `onAttach` callbacks run so\n * their owners can announce themselves to the new peer.\n */\n attach(transport: PageTransport): void;\n /** Attach Vite's HMR client, unless a carrier is already in place. */\n useViteHot(hot: ViteHotLike): void;\n /** Run `callback` on every later {@link attach}. Not run for past ones. */\n onAttach(callback: () => void): void;\n}\n\nconst createPageChannel = (): PageChannel => {\n let transport: PageTransport | undefined;\n const listeners: Array<{\n channel: string;\n handler: (data: unknown) => void;\n off?: () => void;\n }> = [];\n const attachCallbacks: Array<() => void> = [];\n\n const bind = (entry: (typeof listeners)[number]): void => {\n entry.off = transport?.on(entry.channel, entry.handler);\n };\n\n const channel: PageChannel = {\n get attached() {\n return transport !== undefined;\n },\n get transport() {\n return transport;\n },\n send(name, data) {\n transport?.send(name, data);\n },\n on(name, handler) {\n const entry: (typeof listeners)[number] = {channel: name, handler};\n listeners.push(entry);\n bind(entry);\n return () => {\n entry.off?.();\n const index = listeners.indexOf(entry);\n if (index !== -1) listeners.splice(index, 1);\n };\n },\n attach(next) {\n for (const entry of listeners) entry.off?.();\n transport = next;\n for (const entry of listeners) bind(entry);\n for (const callback of attachCallbacks) {\n try {\n callback();\n } catch {\n // One owner failing to announce must not strand the rest.\n }\n }\n },\n useViteHot(hot) {\n if (transport === undefined) channel.attach(fromViteHot(hot));\n },\n onAttach(callback) {\n attachCallbacks.push(callback);\n },\n };\n return channel;\n};\n\n// One channel per page even if this module is loaded twice (for instance once\n// through Vite's dependency optimizer and once directly), like the patch state.\nconst CHANNEL_KEY = Symbol.for('@lit-labs/vite-plugin-lit#page-channel');\n\nconst shared = globalThis as unknown as Record<symbol, PageChannel | undefined>;\n\nexport const pageChannel: PageChannel = (shared[CHANNEL_KEY] ??=\n createPageChannel());\n"]}
1
+ {"version":3,"file":"page-channel.js","sourceRoot":"","sources":["../../src/lib/runtime/page-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAgBH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAgB,EAAiB,EAAE,CAAC,CAAC;IAC/D,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC;IAChD,EAAE,CAAC,OAAO,EAAE,OAAO;QACjB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACzB,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;CACF,CAAC,CAAC;AA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C,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;gBACvC,IAAI,CAAC;oBACH,QAAQ,EAAE,CAAC;gBACb,CAAC;gBAAC,MAAM,CAAC;oBACP,0DAA0D;gBAC5D,CAAC;YACH,CAAC;QACH,CAAC;QACD,UAAU,CAAC,GAAG;YACZ,IAAI,SAAS,KAAK,SAAS;gBAAE,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QAChE,CAAC;QACD,QAAQ,CAAC,QAAQ;YACf,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;KACF,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,8EAA8E;AAC9E,gFAAgF;AAChF,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;AAEzE,MAAM,MAAM,GAAG,UAAgE,CAAC;AAEhF,MAAM,CAAC,MAAM,WAAW,GAAgB,CAAC,MAAM,CAAC,WAAW,CAAC;IAC1D,iBAAiB,EAAE,CAAC,CAAC","sourcesContent":["/**\n * The page runtime's one seam to whatever carries its traffic to the DevTools\n * server. Every `lit:*` message the runtime sends or receives (timeline\n * events, inspector data and commands, settings overrides, HMR-incompatibility\n * notices) goes through {@link pageChannel}, never through `import.meta.hot`\n * directly, so the carrier can be swapped without touching a call site.\n *\n * The default carrier is Vite's HMR channel ({@link fromViteHot}). An\n * alternative (see `rpc-transport.ts`) is attached with\n * {@link PageChannel.attach}; listeners registered earlier move over to it.\n *\n * Vite's own lifecycle events (`vite:afterUpdate`, `vite:beforeFullReload`,\n * `vite:ws:*`) are not part of this channel: they describe the HMR connection\n * itself, so the sites that care still read `import.meta.hot` for those.\n */\n\n/** A carrier for named messages between the page runtime and the server. */\nexport interface PageTransport {\n send(channel: string, data?: unknown): void;\n /** Listen on a channel. Returns the function that removes the listener. */\n on(channel: string, handler: (data: unknown) => void): () => void;\n}\n\n/** The slice of `import.meta.hot` the default carrier relies on. */\nexport interface ViteHotLike {\n send(event: string, data?: unknown): void;\n on(event: string, handler: (data: any) => void): void;\n off?(event: string, handler: (data: any) => void): void;\n}\n\n/** Wraps Vite's HMR client as a {@link PageTransport}. */\nexport const fromViteHot = (hot: ViteHotLike): PageTransport => ({\n send: (channel, data) => hot.send(channel, data),\n on(channel, handler) {\n hot.on(channel, handler);\n return () => hot.off?.(channel, handler);\n },\n});\n\nexport interface PageChannel extends PageTransport {\n /** Whether a carrier is attached. Sends made before one is are dropped. */\n readonly attached: boolean;\n /** The carrier in use, so a replacement can hand the channel back. */\n readonly transport: PageTransport | undefined;\n /**\n * Make `transport` the carrier. Listeners already registered are moved onto\n * it and removed from the previous carrier, and `onAttach` callbacks run so\n * their owners can announce themselves to the new peer.\n */\n attach(transport: PageTransport): void;\n /** Attach Vite's HMR client, unless a carrier is already in place. */\n useViteHot(hot: ViteHotLike): void;\n /** Run `callback` on every later {@link attach}. Not run for past ones. */\n onAttach(callback: () => void): void;\n}\n\nconst createPageChannel = (): PageChannel => {\n let transport: PageTransport | undefined;\n const listeners: Array<{\n channel: string;\n handler: (data: unknown) => void;\n off?: () => void;\n }> = [];\n const attachCallbacks: Array<() => void> = [];\n\n const bind = (entry: (typeof listeners)[number]): void => {\n entry.off = transport?.on(entry.channel, entry.handler);\n };\n\n const channel: PageChannel = {\n get attached() {\n return transport !== undefined;\n },\n get transport() {\n return transport;\n },\n send(name, data) {\n transport?.send(name, data);\n },\n on(name, handler) {\n const entry: (typeof listeners)[number] = {channel: name, handler};\n listeners.push(entry);\n bind(entry);\n return () => {\n entry.off?.();\n const index = listeners.indexOf(entry);\n if (index !== -1) listeners.splice(index, 1);\n };\n },\n attach(next) {\n for (const entry of listeners) entry.off?.();\n transport = next;\n for (const entry of listeners) bind(entry);\n for (const callback of attachCallbacks) {\n try {\n callback();\n } catch {\n // One owner failing to announce must not strand the rest.\n }\n }\n },\n useViteHot(hot) {\n if (transport === undefined) channel.attach(fromViteHot(hot));\n },\n onAttach(callback) {\n attachCallbacks.push(callback);\n },\n };\n return channel;\n};\n\n// One channel per page even if this module is loaded twice (for instance once\n// through Vite's dependency optimizer and once directly), like the patch state.\nconst CHANNEL_KEY = Symbol.for('@lit-labs/vite-plugin-lit#page-channel');\n\nconst shared = globalThis as unknown as Record<symbol, PageChannel | undefined>;\n\nexport const pageChannel: PageChannel = (shared[CHANNEL_KEY] ??=\n createPageChannel());\n"]}
@@ -1,8 +1,19 @@
1
1
  /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
2
+ * In-place custom element class patching.
3
+ *
4
+ * Vite HMR re-executes an edited component module, which calls
5
+ * `customElements.define()` again with a freshly evaluated class. The
6
+ * platform registry can't re-define a tag, and live instances keep their
7
+ * original prototype chain, so instead of swapping classes we intercept the
8
+ * duplicate define and patch the originally-registered class in place:
9
+ * copy prototype + static descriptors from the new class onto the old one
10
+ * and nudge live instances to re-render.
11
+ *
12
+ * This module is dependency-free and duck-typed against ReactiveElement so
13
+ * it never imports lit (keeps it version-agnostic and safe for non-Lit
14
+ * custom elements, which get prototype/static patching only).
5
15
  */
16
+ import { type ChildStateMode } from './child-state.js';
6
17
  import { type HmrIncompatibilityEvent, type HmrIncompatibilityReason } from '../../types/hmr-incompatibility.js';
7
18
  export interface PatchOptions {
8
19
  /**
@@ -15,6 +26,14 @@ export interface PatchOptions {
15
26
  * standard `accessor` decorators). Defaults to `'reload'`.
16
27
  */
17
28
  onIncompatible?: 'reload' | 'warn';
29
+ /**
30
+ * What happens to custom elements a hot patch re-creates (an edited
31
+ * template clones fresh DOM): `'reset'` leaves them at their defaults,
32
+ * `'transfer'` copies the old element's state onto the new one, `'reuse'`
33
+ * puts the old element back where the new one carries no bindings (and
34
+ * transfers otherwise). Defaults to `'transfer'`.
35
+ */
36
+ childState?: ChildStateMode;
18
37
  }
19
38
  /**
20
39
  * Syncs own members `source` → `target`: deletes own keys of `target` that
@@ -1 +1 @@
1
- {"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqBH,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC9B,MAAM,oCAAoC,CAAC;AAK5C,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CACpC;AAsDD;;;;GAIG;AAEH,eAAO,MAAM,cAAc,WACjB,MAAM,UACN,MAAM,QACR,aAAa,CAAC,WAAW,CAAC,SA4BjC,CAAC;AA2IF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,YAC3B,MAAM,UACP,wBAAwB,UACxB,uBAAuB,CAAC,QAAQ,CAAC,KACxC,uBAAwE,CAAC;AA0K5E;;;GAGG;AACH,eAAO,MAAM,OAAO,aAAa,YAAY,KAAQ,IA2EpD,CAAC"}
1
+ {"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC9B,MAAM,oCAAoC,CAAC;AAK5C,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAEnC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAwDD;;;;GAIG;AAEH,eAAO,MAAM,cAAc,WACjB,MAAM,UACN,MAAM,QACR,aAAa,CAAC,WAAW,CAAC,SA4BjC,CAAC;AA+IF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,YAC3B,MAAM,UACP,wBAAwB,UACxB,uBAAuB,CAAC,QAAQ,CAAC,KACxC,uBAAwE,CAAC;AA8K5E;;;GAGG;AACH,eAAO,MAAM,OAAO,aAAa,YAAY,KAAQ,IAuFpD,CAAC"}
@@ -1,8 +1,3 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
1
  /**
7
2
  * In-place custom element class patching.
8
3
  *
@@ -18,6 +13,7 @@
18
13
  * it never imports lit (keeps it version-agnostic and safe for non-Lit
19
14
  * custom elements, which get prototype/static patching only).
20
15
  */
16
+ import {createChildState} from './child-state.js';
21
17
  import {subscribeOverride} from './overrides.js';
22
18
  import {pageChannel} from './page-channel.js';
23
19
  import {
@@ -86,6 +82,9 @@ const instrument = (state, proto, record) => {
86
82
  const wrapper =
87
83
  name === 'connectedCallback'
88
84
  ? function () {
85
+ // Before the original runs, so a transfer lands ahead of the
86
+ // element's first update.
87
+ state.childState?.connected(this, !state.generationOf.has(this));
89
88
  record.instances.add(this);
90
89
  const stamp = state.generationOf.get(this);
91
90
  if (stamp !== undefined && stamp !== record.generation) {
@@ -97,6 +96,7 @@ const instrument = (state, proto, record) => {
97
96
  }
98
97
  : function () {
99
98
  record.instances.delete(this);
99
+ state.childState?.disconnected(this);
100
100
  original?.call(this);
101
101
  };
102
102
  wrapper[RECORD_BRAND] = record;
@@ -293,7 +293,9 @@ const hotPatch = (state, record, NewClass) => {
293
293
  )
294
294
  );
295
295
  }
296
- // 7. Update live instances.
296
+ // 7. Update live instances. Re-renders may re-create child elements
297
+ // (edited templates clone fresh DOM); the window pairs them up.
298
+ state.childState?.open();
297
299
  const newPropertyKeys = NewClass.elementProperties?.keys() ?? [];
298
300
  // After the static sync this is the NEW class's initializer list.
299
301
  const initializers = OldClass._initializers;
@@ -332,6 +334,8 @@ const hotPatch = (state, record, NewClass) => {
332
334
  state.generationOf.set(el, record.generation);
333
335
  el.requestUpdate?.();
334
336
  }
337
+ // Read after requestUpdate() so each promise covers the new update.
338
+ state.childState?.watch(record.instances);
335
339
  } catch (e) {
336
340
  incompatible(state, record.tagName, {
337
341
  code: 'patch-failed',
@@ -357,6 +361,9 @@ export const install = (options = {}) => {
357
361
  if (options.onIncompatible !== undefined) {
358
362
  existing.options.onIncompatible = options.onIncompatible;
359
363
  }
364
+ if (options.childState !== undefined) {
365
+ existing.options.childState = options.childState;
366
+ }
360
367
  return;
361
368
  }
362
369
  const hot = import.meta.hot;
@@ -366,9 +373,13 @@ export const install = (options = {}) => {
366
373
  options: {
367
374
  reconnect: options.reconnect ?? false,
368
375
  onIncompatible: options.onIncompatible ?? 'reload',
376
+ childState: options.childState ?? 'transfer',
369
377
  },
370
378
  hot: hot === undefined ? undefined : pageChannel,
371
379
  };
380
+ state.childState = createChildState({
381
+ mode: () => state.options.childState,
382
+ });
372
383
  g[STATE_KEY] = state;
373
384
  // Let the DevTools panel override these behaviours live (and persist across
374
385
  // reloads) on top of the config-time defaults above.
@@ -377,6 +388,11 @@ export const install = (options = {}) => {
377
388
  if (o.hmrOnIncompatible !== undefined) {
378
389
  state.options.onIncompatible = o.hmrOnIncompatible;
379
390
  }
391
+ // Read on every patch (see createChildState's `mode`), so it applies from
392
+ // the next edit on.
393
+ if (o.hmrChildState !== undefined) {
394
+ state.options.childState = o.hmrChildState;
395
+ }
380
396
  });
381
397
  // Captured to re-invoke below as nativeDefine.call(this, ...).
382
398
  // oxlint-disable-next-line typescript/unbound-method
@@ -1 +1 @@
1
- {"version":3,"file":"patch.js","sourceRoot":"","sources":["../../src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAGlB,MAAM,oCAAoC,CAAC;AA0D5C,qEAAqE;AACrE,MAAM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AAI;gBACf,SAAS,EAAE,IAAI,GAAG,EAAE;gBACpB,UAAU,EAAE,CAAC;aACd,CAAC;YACF,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAChC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC1C,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,IAAI,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;YAC9B,kDAAkD;YAClD,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAwB,CAAC,CAAC;IACpD,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * In-place custom element class patching.\n *\n * Vite HMR re-executes an edited component module, which calls\n * `customElements.define()` again with a freshly evaluated class. The\n * platform registry can't re-define a tag, and live instances keep their\n * original prototype chain, so instead of swapping classes we intercept the\n * duplicate define and patch the originally-registered class in place:\n * copy prototype + static descriptors from the new class onto the old one\n * and nudge live instances to re-render.\n *\n * This module is dependency-free and duck-typed against ReactiveElement so\n * it never imports lit (keeps it version-agnostic and safe for non-Lit\n * custom elements, which get prototype/static patching only).\n */\n\nimport {subscribeOverride} from './overrides.js';\nimport {pageChannel} from './page-channel.js';\nimport type {PageTransport, ViteHotLike} from './page-channel.js';\nimport {\n HMR_INCOMPATIBLE_CHANNEL,\n describeHmrReason,\n type HmrIncompatibilityEvent,\n type HmrIncompatibilityReason,\n} from '../../types/hmr-incompatibility.js';\n\n/** What the patcher needs of the page channel: reporting incompatibilities. */\ntype HotChannel = Pick<PageTransport, 'send'>;\n\nexport interface PatchOptions {\n /**\n * Cycle `disconnectedCallback()`/`connectedCallback()` on live instances\n * after a hot patch. Defaults to `false`.\n */\n reconnect?: boolean;\n\n /**\n * What to do when a component can't be hot-patched in place (e.g.\n * standard `accessor` decorators). Defaults to `'reload'`.\n */\n onIncompatible?: 'reload' | 'warn';\n}\n\ninterface ReactiveElementLike extends HTMLElement {\n requestUpdate?: () => void;\n renderRoot?: unknown;\n connectedCallback?: () => void;\n disconnectedCallback?: () => void;\n}\n\n/** Duck-typed view of ReactiveElement constructor statics. */\ninterface ReactiveCtorLike extends CustomElementConstructor {\n finalize?: () => void;\n elementProperties?: Map<PropertyKey, unknown>;\n elementStyles?: ReadonlyArray<unknown>;\n observedAttributes?: readonly string[];\n _initializers?: Array<(element: unknown) => void>;\n}\n\ninterface TagRecord {\n tagName: string;\n canonical: CustomElementConstructor;\n instances: Set<ReactiveElementLike>;\n generation: number;\n}\n\ninterface PatchState {\n records: Map<string, TagRecord>;\n /** Generation a (possibly detached) instance last caught up to. */\n generationOf: WeakMap<ReactiveElementLike, number>;\n options: Required<PatchOptions>;\n /** Set in `install()`; reports HMR-incompatibility events when present. */\n hot?: HotChannel;\n}\n\ntype LifecycleName = 'connectedCallback' | 'disconnectedCallback';\n\ninterface BrandedWrapper {\n (this: ReactiveElementLike): void;\n [RECORD_BRAND]?: TagRecord;\n}\n\n// Exactly one patch state per page, even if this module loads twice.\nconst STATE_KEY = Symbol.for('@lit-labs/vite-plugin-lit#patch');\n// Brands our lifecycle wrappers so re-instrumentation is idempotent.\nconst RECORD_BRAND = Symbol.for('@lit-labs/vite-plugin-lit#wrapperRecord');\n\nconst PROTO_SKIP: ReadonlyArray<PropertyKey> = ['constructor'];\nconst STATIC_SKIP: ReadonlyArray<PropertyKey> = ['prototype', 'name', 'length'];\n\nconst ownKeys = (o: object): PropertyKey[] => [\n ...Object.getOwnPropertyNames(o),\n ...Object.getOwnPropertySymbols(o),\n];\n\n/**\n * Syncs own members `source` → `target`: deletes own keys of `target` that\n * vanished from `source`, then copies every own descriptor of `source`.\n * Individual copies are best-effort (non-configurable slots are skipped).\n */\n// Exported for unit testing; otherwise module-internal.\nexport const syncOwnMembers = (\n target: object,\n source: object,\n skip: ReadonlyArray<PropertyKey>\n) => {\n for (const key of ownKeys(target)) {\n if (skip.includes(key)) {\n continue;\n }\n if (Object.getOwnPropertyDescriptor(source, key) === undefined) {\n try {\n delete (target as Record<PropertyKey, unknown>)[key];\n } catch {\n // Non-configurable; leave it.\n }\n }\n }\n for (const key of ownKeys(source)) {\n if (skip.includes(key)) {\n continue;\n }\n try {\n Object.defineProperty(\n target,\n key,\n Object.getOwnPropertyDescriptor(source, key)!\n );\n } catch {\n // Non-configurable; leave it.\n }\n }\n};\n\n/**\n * Defines branded `connectedCallback`/`disconnectedCallback` wrappers on the\n * prototype to maintain the live-instance set and generation stamps. Called\n * at first define and again after every patch (descriptor sync replaces or\n * deletes the wrappers).\n */\nconst instrument = (\n state: PatchState,\n proto: object,\n record: TagRecord\n): void => {\n for (const name of [\n 'connectedCallback',\n 'disconnectedCallback',\n ] as const satisfies readonly LifecycleName[]) {\n const own = Object.getOwnPropertyDescriptor(proto, name);\n if ((own?.value as BrandedWrapper | undefined)?.[RECORD_BRAND] === record) {\n continue;\n }\n // May be an own raw function (just copied from the new class), an\n // inherited base implementation, or absent entirely.\n const original = (proto as Record<LifecycleName, (() => void) | undefined>)[\n name\n ];\n const wrapper: BrandedWrapper =\n name === 'connectedCallback'\n ? function (this: ReactiveElementLike) {\n record.instances.add(this);\n const stamp = state.generationOf.get(this);\n if (stamp !== undefined && stamp !== record.generation) {\n // Was detached during one or more patches; catch up.\n this.requestUpdate?.();\n }\n state.generationOf.set(this, record.generation);\n original?.call(this);\n }\n : function (this: ReactiveElementLike) {\n record.instances.delete(this);\n original?.call(this);\n };\n wrapper[RECORD_BRAND] = record;\n try {\n Object.defineProperty(proto, name, {\n value: wrapper,\n writable: true,\n configurable: true,\n });\n } catch {\n // Non-configurable lifecycle slot; tracking degrades gracefully.\n }\n }\n};\n\n/**\n * Detects standard-decorator (`accessor`) reactive properties on the new\n * class. Those close over per-class-evaluation private slots, so copied\n * accessors would brand-check-throw — in-place patching is impossible.\n */\nconst usesStandardDecorators = (ctor: ReactiveCtorLike): boolean => {\n const metadataSymbol = (Symbol as {metadata?: symbol}).metadata;\n if (metadataSymbol === undefined) {\n return false;\n }\n const metadata = Object.getOwnPropertyDescriptor(ctor, metadataSymbol)\n ?.value as object | undefined;\n if (metadata === undefined || metadata === null) {\n return false;\n }\n // litPropertyMetadata is a Lit internal (not public API). Guard against\n // rename, removal, or shape changes — a false negative here means we try\n // to hot-patch and crash, which is handled by the outer catch in hotPatch.\n try {\n const litPropertyMetadata = (\n globalThis as {\n litPropertyMetadata?: WeakMap<object, Map<unknown, unknown>>;\n }\n ).litPropertyMetadata;\n const properties = litPropertyMetadata?.get(metadata);\n return properties !== undefined && properties.size > 0;\n } catch {\n return false;\n }\n};\n\n/**\n * Resolves a static `elementStyles` array to its constructed `CSSStyleSheet`s.\n * Returns `null` for a non-array or any shimmed sheet (no constructible\n * stylesheet support), so callers can bail rather than adopt a partial list.\n */\nconst stylesToSheets = (styles: unknown): CSSStyleSheet[] | null => {\n if (!Array.isArray(styles)) return null;\n const sheets: CSSStyleSheet[] = [];\n for (const style of styles) {\n const sheet =\n style instanceof CSSStyleSheet\n ? style\n : ((style as {styleSheet?: CSSStyleSheet} | null)?.styleSheet ??\n undefined);\n if (!(sheet instanceof CSSStyleSheet)) return null;\n sheets.push(sheet);\n }\n return sheets;\n};\n\n/**\n * Re-adopts constructed stylesheets on an instance's shadow root from the\n * (just-patched) static `elementStyles`. Local reimplementation — no lit\n * import. Skips cleanly for light-DOM components and shimmed sheets.\n *\n * `oldSheets` are the sheets the pre-patch class contributed (captured before\n * the static sync). We drop exactly those and append the new set, leaving any\n * sheet adopted imperatively by other code in place rather than clobbering the\n * whole list.\n */\nconst readoptStyles = (\n el: ReactiveElementLike,\n oldSheets: CSSStyleSheet[]\n): void => {\n const root = el.renderRoot;\n if (typeof ShadowRoot === 'undefined' || !(root instanceof ShadowRoot)) {\n return;\n }\n const sheets = stylesToSheets(\n (el.constructor as ReactiveCtorLike).elementStyles\n );\n if (sheets === null) {\n return;\n }\n const drop = new Set(oldSheets);\n const ours = new Set(sheets);\n // Our styles go first, matching Lit's own order (extra sheets appended).\n const preserved = [...root.adoptedStyleSheets].filter(\n (s) => !drop.has(s) && !ours.has(s)\n );\n root.adoptedStyleSheets = [...sheets, ...preserved];\n};\n\n/**\n * Builds the structured event reported over {@link HMR_INCOMPATIBLE_CHANNEL}.\n * Exported for unit testing; otherwise module-internal. Whether the send\n * survives the `location.reload()` that may follow it can only be checked by\n * hand against a real dev server.\n */\nexport const buildHmrIncompatibleEvent = (\n tagName: string,\n reason: HmrIncompatibilityReason,\n action: HmrIncompatibilityEvent['action']\n): HmrIncompatibilityEvent => ({tagName, time: Date.now(), reason, action});\n\nconst incompatible = (\n state: PatchState,\n tagName: string,\n reason: HmrIncompatibilityReason\n): void => {\n const message = describeHmrReason(reason);\n const action = state.options.onIncompatible === 'warn' ? 'warn' : 'reload';\n state.hot?.send(\n HMR_INCOMPATIBLE_CHANNEL,\n buildHmrIncompatibleEvent(tagName, reason, action)\n );\n if (state.options.onIncompatible === 'warn') {\n console.warn(\n `[lit-plugin] <${tagName}> can't be hot-patched (${message}). ` +\n `Reload the page to pick up the change.`\n );\n } else {\n console.info(\n `[lit-plugin] <${tagName}>: ${message} — performing full reload.`\n );\n location.reload();\n }\n};\n\n/**\n * Patches the originally-registered class for `record.tagName` in place\n * from the freshly evaluated `NewClass`, then updates live instances.\n */\nconst hotPatch = (\n state: PatchState,\n record: TagRecord,\n NewClass: ReactiveCtorLike\n): void => {\n const OldClass = record.canonical as ReactiveCtorLike;\n try {\n // 1. Materialize finalized/elementProperties/elementStyles/\n // __attributeToPropertyMap on the new class before we copy statics.\n if (typeof NewClass.finalize === 'function') {\n NewClass.finalize();\n }\n\n // 2. Standard-decorator `accessor` properties can't be patched in place.\n if (usesStandardDecorators(NewClass)) {\n incompatible(state, record.tagName, {code: 'accessor-decorators'});\n return;\n }\n\n // The platform snapshots observedAttributes at define time; new\n // attribute observations can't take effect without a reload.\n const oldObserved = [...(OldClass.observedAttributes ?? [])];\n const newObserved = [...(NewClass.observedAttributes ?? [])];\n\n // 3. Snapshot reactive property values per live instance through the\n // OLD accessors. Vite serves prod lit in dev (no `development`\n // export condition), where accessor storage keys are unique\n // Symbol()s per class evaluation — without this, state resets.\n const propertyKeys = new Set<PropertyKey>([\n ...(OldClass.elementProperties?.keys() ?? []),\n ...(NewClass.elementProperties?.keys() ?? []),\n ]);\n const snapshots = new Map<ReactiveElementLike, Map<PropertyKey, unknown>>();\n for (const el of record.instances) {\n const values = new Map<PropertyKey, unknown>();\n for (const key of propertyKeys) {\n values.set(key, (el as unknown as Record<PropertyKey, unknown>)[key]);\n }\n snapshots.set(el, values);\n }\n\n // 4. Re-parent prototype chains. Mixins regenerate intermediate classes\n // on every module evaluation, so the parents usually differ.\n const newProtoParent = Object.getPrototypeOf(NewClass.prototype) as object;\n if (Object.getPrototypeOf(OldClass.prototype) !== newProtoParent) {\n Object.setPrototypeOf(OldClass.prototype, newProtoParent);\n }\n const newStaticParent = Object.getPrototypeOf(NewClass) as object;\n if (Object.getPrototypeOf(OldClass) !== newStaticParent) {\n Object.setPrototypeOf(OldClass, newStaticParent);\n }\n\n // Capture the sheets the OLD class contributed before the static sync\n // overwrites `elementStyles`, so readoptStyles can drop exactly those and\n // leave imperatively-adopted sheets in place.\n const oldSheets = stylesToSheets(OldClass.elementStyles) ?? [];\n\n // 5. Sync own members new → old on the prototype and on statics.\n syncOwnMembers(OldClass.prototype, NewClass.prototype, PROTO_SKIP);\n syncOwnMembers(OldClass, NewClass, STATIC_SKIP);\n\n // 6. The sync replaced/removed our lifecycle wrappers; re-instrument.\n instrument(state, OldClass.prototype, record);\n record.generation++;\n // Module-local `instanceof NewClass` checks keep working against\n // instances of the canonical class.\n Object.defineProperty(NewClass, Symbol.hasInstance, {\n value: (instance: unknown) =>\n typeof instance === 'object' &&\n instance !== null &&\n OldClass.prototype.isPrototypeOf(instance),\n configurable: true,\n });\n\n if (\n oldObserved.length !== newObserved.length ||\n oldObserved.some((attr, i) => attr !== newObserved[i])\n ) {\n console.info(\n `[lit-plugin] <${record.tagName}> changed observedAttributes; the ` +\n `platform registry can't pick this up — reload recommended.`\n );\n state.hot?.send(\n HMR_INCOMPATIBLE_CHANNEL,\n buildHmrIncompatibleEvent(\n record.tagName,\n {code: 'observed-attributes-changed'},\n 'none'\n )\n );\n }\n\n // 7. Update live instances.\n const newPropertyKeys = NewClass.elementProperties?.keys() ?? [];\n // After the static sync this is the NEW class's initializer list.\n const initializers = OldClass._initializers;\n // Snapshot: the reconnect below mutates record.instances mid-iteration.\n // oxlint-disable-next-line unicorn/no-useless-spread\n for (const el of [...record.instances]) {\n if (state.options.reconnect) {\n el.disconnectedCallback?.();\n el.connectedCallback?.();\n }\n // Decorator-created reactive controllers (e.g. @lit/context's\n // @provide/@consume) live in per-class-evaluation closures keyed by\n // instance via addInitializer. Re-running the initializers enrolls\n // live instances in the new closures — without this, the first\n // assignment through a copied accessor throws and we'd full-reload.\n // Controllers from previous evaluations stay attached but inert\n // (everything flows through the newest closures); that's bounded by\n // edit count and dev-only. Runs before the value restore so e.g. a\n // re-created ContextProvider exists when the restore pushes into it.\n if (Array.isArray(initializers)) {\n for (const initialize of initializers) {\n initialize(el);\n }\n }\n const values = snapshots.get(el);\n if (values !== undefined) {\n // Restore through the new accessors — only keys the new class\n // still declares.\n for (const key of newPropertyKeys) {\n if (values.has(key)) {\n (el as unknown as Record<PropertyKey, unknown>)[key] =\n values.get(key);\n }\n }\n }\n readoptStyles(el, oldSheets);\n state.generationOf.set(el, record.generation);\n el.requestUpdate?.();\n }\n } catch (e) {\n incompatible(state, record.tagName, {\n code: 'patch-failed',\n detail: e instanceof Error ? e.message : String(e),\n });\n }\n};\n\n/**\n * Installs the `customElements.define` interceptor. Idempotent (per-page\n * global guard); no-ops in environments without `customElements` (SSR).\n */\nexport const install = (options: PatchOptions = {}): void => {\n if (typeof customElements === 'undefined') {\n return;\n }\n const g = globalThis as unknown as Record<symbol, PatchState | undefined>;\n const existing = g[STATE_KEY];\n if (existing !== undefined) {\n // Already installed; refresh explicitly-provided options only.\n if (options.reconnect !== undefined) {\n existing.options.reconnect = options.reconnect;\n }\n if (options.onIncompatible !== undefined) {\n existing.options.onIncompatible = options.onIncompatible;\n }\n return;\n }\n const hot = (import.meta as {hot?: ViteHotLike}).hot;\n const state: PatchState = {\n records: new Map(),\n generationOf: new WeakMap(),\n options: {\n reconnect: options.reconnect ?? false,\n onIncompatible: options.onIncompatible ?? 'reload',\n },\n hot: hot === undefined ? undefined : pageChannel,\n };\n g[STATE_KEY] = state;\n\n // Let the DevTools panel override these behaviours live (and persist across\n // reloads) on top of the config-time defaults above.\n subscribeOverride(hot, (o) => {\n if (o.hmrReconnect !== undefined) state.options.reconnect = o.hmrReconnect;\n if (o.hmrOnIncompatible !== undefined) {\n state.options.onIncompatible = o.hmrOnIncompatible;\n }\n });\n\n // Captured to re-invoke below as nativeDefine.call(this, ...).\n // oxlint-disable-next-line typescript/unbound-method\n const nativeDefine = customElements.define;\n customElements.define = function (\n this: CustomElementRegistry,\n name: string,\n ctor: CustomElementConstructor,\n defineOptions?: ElementDefinitionOptions\n ) {\n let record = state.records.get(name);\n if (record === undefined && this.get(name) !== undefined) {\n // Defined before install() ran (shouldn't happen — the installer is\n // import-hoisted — but recover gracefully without instance tracking).\n record = {\n tagName: name,\n canonical: this.get(name)!,\n instances: new Set(),\n generation: 0,\n };\n state.records.set(name, record);\n }\n if (record === undefined) {\n record = {\n tagName: name,\n canonical: ctor,\n instances: new Set(),\n generation: 0,\n };\n state.records.set(name, record);\n instrument(state, ctor.prototype, record);\n return nativeDefine.call(this, name, ctor, defineOptions);\n }\n if (ctor === record.canonical) {\n // Same class object re-defined; nothing to patch.\n return;\n }\n hotPatch(state, record, ctor as ReactiveCtorLike);\n };\n};\n"]}
1
+ {"version":3,"file":"patch.js","sourceR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ACd,CAAC;YACF,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAChC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC1C,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,IAAI,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;YAC9B,kDAAkD;YAClD,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAwB,CAAC,CAAC;IACpD,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * In-place custom element class patching.\n *\n * Vite HMR re-executes an edited component module, which calls\n * `customElements.define()` again with a freshly evaluated class. The\n * platform registry can't re-define a tag, and live instances keep their\n * original prototype chain, so instead of swapping classes we intercept the\n * duplicate define and patch the originally-registered class in place:\n * copy prototype + static descriptors from the new class onto the old one\n * and nudge live instances to re-render.\n *\n * This module is dependency-free and duck-typed against ReactiveElement so\n * it never imports lit (keeps it version-agnostic and safe for non-Lit\n * custom elements, which get prototype/static patching only).\n */\n\nimport {\n createChildState,\n type ChildState,\n type ChildStateMode,\n} from './child-state.js';\nimport {subscribeOverride} from './overrides.js';\nimport {pageChannel} from './page-channel.js';\nimport type {PageTransport, ViteHotLike} from './page-channel.js';\nimport {\n HMR_INCOMPATIBLE_CHANNEL,\n describeHmrReason,\n type HmrIncompatibilityEvent,\n type HmrIncompatibilityReason,\n} from '../../types/hmr-incompatibility.js';\n\n/** What the patcher needs of the page channel: reporting incompatibilities. */\ntype HotChannel = Pick<PageTransport, 'send'>;\n\nexport interface PatchOptions {\n /**\n * Cycle `disconnectedCallback()`/`connectedCallback()` on live instances\n * after a hot patch. Defaults to `false`.\n */\n reconnect?: boolean;\n\n /**\n * What to do when a component can't be hot-patched in place (e.g.\n * standard `accessor` decorators). Defaults to `'reload'`.\n */\n onIncompatible?: 'reload' | 'warn';\n\n /**\n * What happens to custom elements a hot patch re-creates (an edited\n * template clones fresh DOM): `'reset'` leaves them at their defaults,\n * `'transfer'` copies the old element's state onto the new one, `'reuse'`\n * puts the old element back where the new one carries no bindings (and\n * transfers otherwise). Defaults to `'transfer'`.\n */\n childState?: ChildStateMode;\n}\n\ninterface ReactiveElementLike extends HTMLElement {\n requestUpdate?: () => void;\n renderRoot?: unknown;\n connectedCallback?: () => void;\n disconnectedCallback?: () => void;\n}\n\n/** Duck-typed view of ReactiveElement constructor statics. */\ninterface ReactiveCtorLike extends CustomElementConstructor {\n finalize?: () => void;\n elementProperties?: Map<PropertyKey, unknown>;\n elementStyles?: ReadonlyArray<unknown>;\n observedAttributes?: readonly string[];\n _initializers?: Array<(element: unknown) => void>;\n}\n\ninterface TagRecord {\n tagName: string;\n canonical: CustomElementConstructor;\n instances: Set<ReactiveElementLike>;\n generation: number;\n}\n\ninterface PatchState {\n records: Map<string, TagRecord>;\n /** Generation a (possibly detached) instance last caught up to. */\n generationOf: WeakMap<ReactiveElementLike, number>;\n options: Required<PatchOptions>;\n /** Set in `install()`; reports HMR-incompatibility events when present. */\n hot?: HotChannel;\n /** Pairs re-created child elements with the ones they replace. */\n childState?: ChildState;\n}\n\ntype LifecycleName = 'connectedCallback' | 'disconnectedCallback';\n\ninterface BrandedWrapper {\n (this: ReactiveElementLike): void;\n [RECORD_BRAND]?: TagRecord;\n}\n\n// Exactly one patch state per page, even if this module loads twice.\nconst STATE_KEY = Symbol.for('@lit-labs/vite-plugin-lit#patch');\n// Brands our lifecycle wrappers so re-instrumentation is idempotent.\nconst RECORD_BRAND = Symbol.for('@lit-labs/vite-plugin-lit#wrapperRecord');\n\nconst PROTO_SKIP: ReadonlyArray<PropertyKey> = ['constructor'];\nconst STATIC_SKIP: ReadonlyArray<PropertyKey> = ['prototype', 'name', 'length'];\n\nconst ownKeys = (o: object): PropertyKey[] => [\n ...Object.getOwnPropertyNames(o),\n ...Object.getOwnPropertySymbols(o),\n];\n\n/**\n * Syncs own members `source` → `target`: deletes own keys of `target` that\n * vanished from `source`, then copies every own descriptor of `source`.\n * Individual copies are best-effort (non-configurable slots are skipped).\n */\n// Exported for unit testing; otherwise module-internal.\nexport const syncOwnMembers = (\n target: object,\n source: object,\n skip: ReadonlyArray<PropertyKey>\n) => {\n for (const key of ownKeys(target)) {\n if (skip.includes(key)) {\n continue;\n }\n if (Object.getOwnPropertyDescriptor(source, key) === undefined) {\n try {\n delete (target as Record<PropertyKey, unknown>)[key];\n } catch {\n // Non-configurable; leave it.\n }\n }\n }\n for (const key of ownKeys(source)) {\n if (skip.includes(key)) {\n continue;\n }\n try {\n Object.defineProperty(\n target,\n key,\n Object.getOwnPropertyDescriptor(source, key)!\n );\n } catch {\n // Non-configurable; leave it.\n }\n }\n};\n\n/**\n * Defines branded `connectedCallback`/`disconnectedCallback` wrappers on the\n * prototype to maintain the live-instance set and generation stamps. Called\n * at first define and again after every patch (descriptor sync replaces or\n * deletes the wrappers).\n */\nconst instrument = (\n state: PatchState,\n proto: object,\n record: TagRecord\n): void => {\n for (const name of [\n 'connectedCallback',\n 'disconnectedCallback',\n ] as const satisfies readonly LifecycleName[]) {\n const own = Object.getOwnPropertyDescriptor(proto, name);\n if ((own?.value as BrandedWrapper | undefined)?.[RECORD_BRAND] === record) {\n continue;\n }\n // May be an own raw function (just copied from the new class), an\n // inherited base implementation, or absent entirely.\n const original = (proto as Record<LifecycleName, (() => void) | undefined>)[\n name\n ];\n const wrapper: BrandedWrapper =\n name === 'connectedCallback'\n ? function (this: ReactiveElementLike) {\n // Before the original runs, so a transfer lands ahead of the\n // element's first update.\n state.childState?.connected(this, !state.generationOf.has(this));\n record.instances.add(this);\n const stamp = state.generationOf.get(this);\n if (stamp !== undefined && stamp !== record.generation) {\n // Was detached during one or more patches; catch up.\n this.requestUpdate?.();\n }\n state.generationOf.set(this, record.generation);\n original?.call(this);\n }\n : function (this: ReactiveElementLike) {\n record.instances.delete(this);\n state.childState?.disconnected(this);\n original?.call(this);\n };\n wrapper[RECORD_BRAND] = record;\n try {\n Object.defineProperty(proto, name, {\n value: wrapper,\n writable: true,\n configurable: true,\n });\n } catch {\n // Non-configurable lifecycle slot; tracking degrades gracefully.\n }\n }\n};\n\n/**\n * Detects standard-decorator (`accessor`) reactive properties on the new\n * class. Those close over per-class-evaluation private slots, so copied\n * accessors would brand-check-throw — in-place patching is impossible.\n */\nconst usesStandardDecorators = (ctor: ReactiveCtorLike): boolean => {\n const metadataSymbol = (Symbol as {metadata?: symbol}).metadata;\n if (metadataSymbol === undefined) {\n return false;\n }\n const metadata = Object.getOwnPropertyDescriptor(ctor, metadataSymbol)\n ?.value as object | undefined;\n if (metadata === undefined || metadata === null) {\n return false;\n }\n // litPropertyMetadata is a Lit internal (not public API). Guard against\n // rename, removal, or shape changes — a false negative here means we try\n // to hot-patch and crash, which is handled by the outer catch in hotPatch.\n try {\n const litPropertyMetadata = (\n globalThis as {\n litPropertyMetadata?: WeakMap<object, Map<unknown, unknown>>;\n }\n ).litPropertyMetadata;\n const properties = litPropertyMetadata?.get(metadata);\n return properties !== undefined && properties.size > 0;\n } catch {\n return false;\n }\n};\n\n/**\n * Resolves a static `elementStyles` array to its constructed `CSSStyleSheet`s.\n * Returns `null` for a non-array or any shimmed sheet (no constructible\n * stylesheet support), so callers can bail rather than adopt a partial list.\n */\nconst stylesToSheets = (styles: unknown): CSSStyleSheet[] | null => {\n if (!Array.isArray(styles)) return null;\n const sheets: CSSStyleSheet[] = [];\n for (const style of styles) {\n const sheet =\n style instanceof CSSStyleSheet\n ? style\n : ((style as {styleSheet?: CSSStyleSheet} | null)?.styleSheet ??\n undefined);\n if (!(sheet instanceof CSSStyleSheet)) return null;\n sheets.push(sheet);\n }\n return sheets;\n};\n\n/**\n * Re-adopts constructed stylesheets on an instance's shadow root from the\n * (just-patched) static `elementStyles`. Local reimplementation — no lit\n * import. Skips cleanly for light-DOM components and shimmed sheets.\n *\n * `oldSheets` are the sheets the pre-patch class contributed (captured before\n * the static sync). We drop exactly those and append the new set, leaving any\n * sheet adopted imperatively by other code in place rather than clobbering the\n * whole list.\n */\nconst readoptStyles = (\n el: ReactiveElementLike,\n oldSheets: CSSStyleSheet[]\n): void => {\n const root = el.renderRoot;\n if (typeof ShadowRoot === 'undefined' || !(root instanceof ShadowRoot)) {\n return;\n }\n const sheets = stylesToSheets(\n (el.constructor as ReactiveCtorLike).elementStyles\n );\n if (sheets === null) {\n return;\n }\n const drop = new Set(oldSheets);\n const ours = new Set(sheets);\n // Our styles go first, matching Lit's own order (extra sheets appended).\n const preserved = [...root.adoptedStyleSheets].filter(\n (s) => !drop.has(s) && !ours.has(s)\n );\n root.adoptedStyleSheets = [...sheets, ...preserved];\n};\n\n/**\n * Builds the structured event reported over {@link HMR_INCOMPATIBLE_CHANNEL}.\n * Exported for unit testing; otherwise module-internal. Whether the send\n * survives the `location.reload()` that may follow it can only be checked by\n * hand against a real dev server.\n */\nexport const buildHmrIncompatibleEvent = (\n tagName: string,\n reason: HmrIncompatibilityReason,\n action: HmrIncompatibilityEvent['action']\n): HmrIncompatibilityEvent => ({tagName, time: Date.now(), reason, action});\n\nconst incompatible = (\n state: PatchState,\n tagName: string,\n reason: HmrIncompatibilityReason\n): void => {\n const message = describeHmrReason(reason);\n const action = state.options.onIncompatible === 'warn' ? 'warn' : 'reload';\n state.hot?.send(\n HMR_INCOMPATIBLE_CHANNEL,\n buildHmrIncompatibleEvent(tagName, reason, action)\n );\n if (state.options.onIncompatible === 'warn') {\n console.warn(\n `[lit-plugin] <${tagName}> can't be hot-patched (${message}). ` +\n `Reload the page to pick up the change.`\n );\n } else {\n console.info(\n `[lit-plugin] <${tagName}>: ${message} — performing full reload.`\n );\n location.reload();\n }\n};\n\n/**\n * Patches the originally-registered class for `record.tagName` in place\n * from the freshly evaluated `NewClass`, then updates live instances.\n */\nconst hotPatch = (\n state: PatchState,\n record: TagRecord,\n NewClass: ReactiveCtorLike\n): void => {\n const OldClass = record.canonical as ReactiveCtorLike;\n try {\n // 1. Materialize finalized/elementProperties/elementStyles/\n // __attributeToPropertyMap on the new class before we copy statics.\n if (typeof NewClass.finalize === 'function') {\n NewClass.finalize();\n }\n\n // 2. Standard-decorator `accessor` properties can't be patched in place.\n if (usesStandardDecorators(NewClass)) {\n incompatible(state, record.tagName, {code: 'accessor-decorators'});\n return;\n }\n\n // The platform snapshots observedAttributes at define time; new\n // attribute observations can't take effect without a reload.\n const oldObserved = [...(OldClass.observedAttributes ?? [])];\n const newObserved = [...(NewClass.observedAttributes ?? [])];\n\n // 3. Snapshot reactive property values per live instance through the\n // OLD accessors. Vite serves prod lit in dev (no `development`\n // export condition), where accessor storage keys are unique\n // Symbol()s per class evaluation — without this, state resets.\n const propertyKeys = new Set<PropertyKey>([\n ...(OldClass.elementProperties?.keys() ?? []),\n ...(NewClass.elementProperties?.keys() ?? []),\n ]);\n const snapshots = new Map<ReactiveElementLike, Map<PropertyKey, unknown>>();\n for (const el of record.instances) {\n const values = new Map<PropertyKey, unknown>();\n for (const key of propertyKeys) {\n values.set(key, (el as unknown as Record<PropertyKey, unknown>)[key]);\n }\n snapshots.set(el, values);\n }\n\n // 4. Re-parent prototype chains. Mixins regenerate intermediate classes\n // on every module evaluation, so the parents usually differ.\n const newProtoParent = Object.getPrototypeOf(NewClass.prototype) as object;\n if (Object.getPrototypeOf(OldClass.prototype) !== newProtoParent) {\n Object.setPrototypeOf(OldClass.prototype, newProtoParent);\n }\n const newStaticParent = Object.getPrototypeOf(NewClass) as object;\n if (Object.getPrototypeOf(OldClass) !== newStaticParent) {\n Object.setPrototypeOf(OldClass, newStaticParent);\n }\n\n // Capture the sheets the OLD class contributed before the static sync\n // overwrites `elementStyles`, so readoptStyles can drop exactly those and\n // leave imperatively-adopted sheets in place.\n const oldSheets = stylesToSheets(OldClass.elementStyles) ?? [];\n\n // 5. Sync own members new → old on the prototype and on statics.\n syncOwnMembers(OldClass.prototype, NewClass.prototype, PROTO_SKIP);\n syncOwnMembers(OldClass, NewClass, STATIC_SKIP);\n\n // 6. The sync replaced/removed our lifecycle wrappers; re-instrument.\n instrument(state, OldClass.prototype, record);\n record.generation++;\n // Module-local `instanceof NewClass` checks keep working against\n // instances of the canonical class.\n Object.defineProperty(NewClass, Symbol.hasInstance, {\n value: (instance: unknown) =>\n typeof instance === 'object' &&\n instance !== null &&\n OldClass.prototype.isPrototypeOf(instance),\n configurable: true,\n });\n\n if (\n oldObserved.length !== newObserved.length ||\n oldObserved.some((attr, i) => attr !== newObserved[i])\n ) {\n console.info(\n `[lit-plugin] <${record.tagName}> changed observedAttributes; the ` +\n `platform registry can't pick this up — reload recommended.`\n );\n state.hot?.send(\n HMR_INCOMPATIBLE_CHANNEL,\n buildHmrIncompatibleEvent(\n record.tagName,\n {code: 'observed-attributes-changed'},\n 'none'\n )\n );\n }\n\n // 7. Update live instances. Re-renders may re-create child elements\n // (edited templates clone fresh DOM); the window pairs them up.\n state.childState?.open();\n const newPropertyKeys = NewClass.elementProperties?.keys() ?? [];\n // After the static sync this is the NEW class's initializer list.\n const initializers = OldClass._initializers;\n // Snapshot: the reconnect below mutates record.instances mid-iteration.\n // oxlint-disable-next-line unicorn/no-useless-spread\n for (const el of [...record.instances]) {\n if (state.options.reconnect) {\n el.disconnectedCallback?.();\n el.connectedCallback?.();\n }\n // Decorator-created reactive controllers (e.g. @lit/context's\n // @provide/@consume) live in per-class-evaluation closures keyed by\n // instance via addInitializer. Re-running the initializers enrolls\n // live instances in the new closures — without this, the first\n // assignment through a copied accessor throws and we'd full-reload.\n // Controllers from previous evaluations stay attached but inert\n // (everything flows through the newest closures); that's bounded by\n // edit count and dev-only. Runs before the value restore so e.g. a\n // re-created ContextProvider exists when the restore pushes into it.\n if (Array.isArray(initializers)) {\n for (const initialize of initializers) {\n initialize(el);\n }\n }\n const values = snapshots.get(el);\n if (values !== undefined) {\n // Restore through the new accessors — only keys the new class\n // still declares.\n for (const key of newPropertyKeys) {\n if (values.has(key)) {\n (el as unknown as Record<PropertyKey, unknown>)[key] =\n values.get(key);\n }\n }\n }\n readoptStyles(el, oldSheets);\n state.generationOf.set(el, record.generation);\n el.requestUpdate?.();\n }\n // Read after requestUpdate() so each promise covers the new update.\n state.childState?.watch(record.instances);\n } catch (e) {\n incompatible(state, record.tagName, {\n code: 'patch-failed',\n detail: e instanceof Error ? e.message : String(e),\n });\n }\n};\n\n/**\n * Installs the `customElements.define` interceptor. Idempotent (per-page\n * global guard); no-ops in environments without `customElements` (SSR).\n */\nexport const install = (options: PatchOptions = {}): void => {\n if (typeof customElements === 'undefined') {\n return;\n }\n const g = globalThis as unknown as Record<symbol, PatchState | undefined>;\n const existing = g[STATE_KEY];\n if (existing !== undefined) {\n // Already installed; refresh explicitly-provided options only.\n if (options.reconnect !== undefined) {\n existing.options.reconnect = options.reconnect;\n }\n if (options.onIncompatible !== undefined) {\n existing.options.onIncompatible = options.onIncompatible;\n }\n if (options.childState !== undefined) {\n existing.options.childState = options.childState;\n }\n return;\n }\n const hot = (import.meta as {hot?: ViteHotLike}).hot;\n const state: PatchState = {\n records: new Map(),\n generationOf: new WeakMap(),\n options: {\n reconnect: options.reconnect ?? false,\n onIncompatible: options.onIncompatible ?? 'reload',\n childState: options.childState ?? 'transfer',\n },\n hot: hot === undefined ? undefined : pageChannel,\n };\n state.childState = createChildState({\n mode: () => state.options.childState,\n });\n g[STATE_KEY] = state;\n\n // Let the DevTools panel override these behaviours live (and persist across\n // reloads) on top of the config-time defaults above.\n subscribeOverride(hot, (o) => {\n if (o.hmrReconnect !== undefined) state.options.reconnect = o.hmrReconnect;\n if (o.hmrOnIncompatible !== undefined) {\n state.options.onIncompatible = o.hmrOnIncompatible;\n }\n // Read on every patch (see createChildState's `mode`), so it applies from\n // the next edit on.\n if (o.hmrChildState !== undefined) {\n state.options.childState = o.hmrChildState;\n }\n });\n\n // Captured to re-invoke below as nativeDefine.call(this, ...).\n // oxlint-disable-next-line typescript/unbound-method\n const nativeDefine = customElements.define;\n customElements.define = function (\n this: CustomElementRegistry,\n name: string,\n ctor: CustomElementConstructor,\n defineOptions?: ElementDefinitionOptions\n ) {\n let record = state.records.get(name);\n if (record === undefined && this.get(name) !== undefined) {\n // Defined before install() ran (shouldn't happen — the installer is\n // import-hoisted — but recover gracefully without instance tracking).\n record = {\n tagName: name,\n canonical: this.get(name)!,\n instances: new Set(),\n generation: 0,\n };\n state.records.set(name, record);\n }\n if (record === undefined) {\n record = {\n tagName: name,\n canonical: ctor,\n instances: new Set(),\n generation: 0,\n };\n state.records.set(name, record);\n instrument(state, ctor.prototype, record);\n return nativeDefine.call(this, name, ctor, defineOptions);\n }\n if (ctor === record.canonical) {\n // Same class object re-defined; nothing to patch.\n return;\n }\n hotPatch(state, record, ctor as ReactiveCtorLike);\n };\n};\n"]}
@@ -1,12 +1,22 @@
1
1
  /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
2
+ * Carries the page channel over devframe RPC to a standalone
3
+ * `lit-devtools dev` server, so a page that is not served by a DevTools-enabled
4
+ * Vite dev server can still feed the panel. The server half is
5
+ * `devframe/rpc-source.ts`.
6
+ *
7
+ * Opt-in and explicit: nothing connects until {@link connectToDevServer} is
8
+ * called, and `devframe/client` is only imported then, so a page that never
9
+ * asks pays nothing.
10
+ *
11
+ * @module
5
12
  */
13
+ import type { ConnectionMeta } from 'devframe';
6
14
  import type { PageTransport } from './page-channel.js';
7
15
  /** The slice of a scoped devframe client the transport uses. */
8
16
  export interface PageRpc {
17
+ /** Fires a devframe event on the server, without waiting for a reply. */
9
18
  callEvent(method: string, ...args: unknown[]): void;
19
+ /** Registers a handler for an event the server sends to this page. */
10
20
  register(fn: {
11
21
  name: string;
12
22
  type: 'event';
@@ -19,6 +29,7 @@ export interface PageRpc {
19
29
  * registered with `on`.
20
30
  */
21
31
  export declare const createRpcTransport: (rpc: PageRpc) => PageTransport;
32
+ /** Options for {@link connectToDevServer}. */
22
33
  export interface ConnectOptions {
23
34
  /**
24
35
  * A bearer token the server already trusts. Without one the client falls
@@ -27,6 +38,13 @@ export interface ConnectOptions {
27
38
  * started with `--no-auth`.
28
39
  */
29
40
  authToken?: string;
41
+ /**
42
+ * The server's connection descriptor (what it serves at
43
+ * `<url>/__connection.json`). Passing it skips that fetch, which is the
44
+ * step a cross-origin page cannot make: the server sends no CORS headers,
45
+ * and a classic script tag is exempt from them where `fetch` is not.
46
+ */
47
+ connectionMeta?: ConnectionMeta;
30
48
  }
31
49
  /**
32
50
  * Point this page's runtime at a standalone `lit-devtools dev` server.
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-transport.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/rpc-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmBH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAErD,gEAAgE;AAChE,MAAM,WAAW,OAAO;IACtB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACpD,QAAQ,CAAC,EAAE,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,OAAO,CAAC;QACd,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;KACnC,GAAG,IAAI,CAAC;CACV;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAS,OAAO,KAAG,aA4BjD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,QACxB,MAAM,YACF,cAAc,KACtB,OAAO,CAAC,MAAM,IAAI,CAepB,CAAC"}
1
+ {"version":3,"file":"rpc-transport.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/rpc-transport.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAE7C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAErD,gEAAgE;AAChE,MAAM,WAAW,OAAO;IACtB,yEAAyE;IACzE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACpD,sEAAsE;IACtE,QAAQ,CAAC,EAAE,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,OAAO,CAAC;QACd,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;KACnC,GAAG,IAAI,CAAC;CACV;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAS,OAAO,KAAG,aA4BjD,CAAC;AAEF,8CAA8C;AAC9C,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,QACxB,MAAM,YACF,cAAc,KACtB,OAAO,CAAC,MAAM,IAAI,CAgBpB,CAAC"}
@@ -1,8 +1,4 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
1
+ /* @ts-self-types="./rpc-transport.d.ts" */
6
2
  /**
7
3
  * Carries the page channel over devframe RPC to a standalone
8
4
  * `lit-devtools dev` server, so a page that is not served by a DevTools-enabled
@@ -12,6 +8,8 @@
12
8
  * Opt-in and explicit: nothing connects until {@link connectToDevServer} is
13
9
  * called, and `devframe/client` is only imported then, so a page that never
14
10
  * asks pays nothing.
11
+ *
12
+ * @module
15
13
  */
16
14
  import {
17
15
  LIT_DEVFRAME_ID,
@@ -70,6 +68,7 @@ export const connectToDevServer = async (url, options = {}) => {
70
68
  const client = await getDevframeRpcClient({
71
69
  baseURL: url,
72
70
  authToken: options.authToken,
71
+ connectionMeta: options.connectionMeta,
73
72
  });
74
73
  await client.ensureTrusted();
75
74
  const previous = pageChannel.transport;
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-transport.js","sourceRoot":"","sources":["../../src/lib/runtime/rpc-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAa9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAY,EAAiB,EAAE;IAChE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAwC,CAAC;IAElE,GAAG,CAAC,QAAQ,CAAC;QACX,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,CAAC,OAAe,EAAE,IAAc,EAAE,EAAE;YAC3C,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;gBACpD,IAAI,CAAC;oBACH,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACjB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,OAAO,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACvE,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,CAAC,OAAO,EAAE,IAAI;YAChB,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC;QACD,EAAE,CAAC,OAAO,EAAE,OAAO;YACjB,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACjC,IAAI,GAAG,KAAK,SAAS;gBAAE,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;YACjE,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACjB,OAAO,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAYF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,GAAW,EACX,OAAO,GAAmB,EAAE,EACP,EAAE;IACvB,MAAM,EAAC,oBAAoB,EAAC,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC;QACxC,OAAO,EAAE,GAAG;QACZ,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC;IACH,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;IAE7B,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC;IACvC,WAAW,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAE1E,OAAO,GAAG,EAAE;QACV,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QACjB,IAAI,QAAQ,KAAK,SAAS;YAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Carries the page channel over devframe RPC to a standalone\n * `lit-devtools dev` server, so a page that is not served by a DevTools-enabled\n * Vite dev server can still feed the panel. The server half is\n * `devframe/rpc-source.ts`.\n *\n * Opt-in and explicit: nothing connects until {@link connectToDevServer} is\n * called, and `devframe/client` is only imported then, so a page that never\n * asks pays nothing.\n */\n\nimport {\n LIT_DEVFRAME_ID,\n RPC_PAGE_RECEIVE,\n RPC_PAGE_SEND,\n} from '../devframe/protocol.js';\nimport {pageChannel} from './page-channel.js';\nimport type {PageTransport} from './page-channel.js';\n\n/** The slice of a scoped devframe client the transport uses. */\nexport interface PageRpc {\n callEvent(method: string, ...args: unknown[]): void;\n register(fn: {\n name: string;\n type: 'event';\n handler: (...args: any[]) => void;\n }): void;\n}\n\n/**\n * A {@link PageTransport} over a devframe RPC client: `send` becomes a\n * `page-send` event, and `page-receive` events fan out to the listeners\n * registered with `on`.\n */\nexport const createRpcTransport = (rpc: PageRpc): PageTransport => {\n const listeners = new Map<string, Set<(data: unknown) => void>>();\n\n rpc.register({\n name: RPC_PAGE_RECEIVE,\n type: 'event',\n handler: (channel: string, data?: unknown) => {\n for (const listener of listeners.get(channel) ?? []) {\n try {\n listener(data);\n } catch (error) {\n console.error(`[lit-devtools] listener for ${channel} threw`, error);\n }\n }\n },\n });\n\n return {\n send(channel, data) {\n rpc.callEvent(RPC_PAGE_SEND, channel, data);\n },\n on(channel, handler) {\n let set = listeners.get(channel);\n if (set === undefined) listeners.set(channel, (set = new Set()));\n set.add(handler);\n return () => void set.delete(handler);\n },\n };\n};\n\nexport interface ConnectOptions {\n /**\n * A bearer token the server already trusts. Without one the client falls\n * back to devframe's own flow (a stored token, a magic-link code in the URL,\n * or a prompt for the one-time code the server prints) unless the server was\n * started with `--no-auth`.\n */\n authToken?: string;\n}\n\n/**\n * Point this page's runtime at a standalone `lit-devtools dev` server.\n *\n * Resolves once the connection is trusted, after which the tree, inspector\n * and timeline traffic that used to go to this page's own Vite server goes to\n * `url` instead (the runtime announces itself again so the server can replay\n * recording state). Returns a function that disconnects and hands the channel\n * back to the carrier it replaced.\n *\n * The page's origin must be allowed to reach `url`; this does not set up\n * cross-origin access.\n *\n * @param url Origin of the dev server, e.g. `http://localhost:5180/`.\n */\nexport const connectToDevServer = async (\n url: string,\n options: ConnectOptions = {}\n): Promise<() => void> => {\n const {getDevframeRpcClient} = await import('devframe/client');\n const client = await getDevframeRpcClient({\n baseURL: url,\n authToken: options.authToken,\n });\n await client.ensureTrusted();\n\n const previous = pageChannel.transport;\n pageChannel.attach(createRpcTransport(client.scope(LIT_DEVFRAME_ID).rpc));\n\n return () => {\n client.close?.();\n if (previous !== undefined) pageChannel.attach(previous);\n };\n};\n"]}
1
+ {"version":3,"file":"rpc-transport.js","sourceRoot":"","sources":["../../src/lib/runtime/rpc-transport.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAe9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAY,EAAiB,EAAE;IAChE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAwC,CAAC;IAElE,GAAG,CAAC,QAAQ,CAAC;QACX,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,CAAC,OAAe,EAAE,IAAc,EAAE,EAAE;YAC3C,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;gBACpD,IAAI,CAAC;oBACH,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACjB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,OAAO,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACvE,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,CAAC,OAAO,EAAE,IAAI;YAChB,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC;QACD,EAAE,CAAC,OAAO,EAAE,OAAO;YACjB,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACjC,IAAI,GAAG,KAAK,SAAS;gBAAE,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;YACjE,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACjB,OAAO,GAAG,EAAE,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAoBF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,GAAW,EACX,OAAO,GAAmB,EAAE,EACP,EAAE;IACvB,MAAM,EAAC,oBAAoB,EAAC,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC;QACxC,OAAO,EAAE,GAAG;QACZ,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,cAAc,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC,CAAC;IACH,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;IAE7B,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC;IACvC,WAAW,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAE1E,OAAO,GAAG,EAAE;QACV,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QACjB,IAAI,QAAQ,KAAK,SAAS;YAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* @ts-self-types=\"./rpc-transport.d.ts\" */\n/**\n * Carries the page channel over devframe RPC to a standalone\n * `lit-devtools dev` server, so a page that is not served by a DevTools-enabled\n * Vite dev server can still feed the panel. The server half is\n * `devframe/rpc-source.ts`.\n *\n * Opt-in and explicit: nothing connects until {@link connectToDevServer} is\n * called, and `devframe/client` is only imported then, so a page that never\n * asks pays nothing.\n *\n * @module\n */\n\nimport {\n LIT_DEVFRAME_ID,\n RPC_PAGE_RECEIVE,\n RPC_PAGE_SEND,\n} from '../devframe/protocol.js';\nimport type {ConnectionMeta} from 'devframe';\nimport {pageChannel} from './page-channel.js';\nimport type {PageTransport} from './page-channel.js';\n\n/** The slice of a scoped devframe client the transport uses. */\nexport interface PageRpc {\n /** Fires a devframe event on the server, without waiting for a reply. */\n callEvent(method: string, ...args: unknown[]): void;\n /** Registers a handler for an event the server sends to this page. */\n register(fn: {\n name: string;\n type: 'event';\n handler: (...args: any[]) => void;\n }): void;\n}\n\n/**\n * A {@link PageTransport} over a devframe RPC client: `send` becomes a\n * `page-send` event, and `page-receive` events fan out to the listeners\n * registered with `on`.\n */\nexport const createRpcTransport = (rpc: PageRpc): PageTransport => {\n const listeners = new Map<string, Set<(data: unknown) => void>>();\n\n rpc.register({\n name: RPC_PAGE_RECEIVE,\n type: 'event',\n handler: (channel: string, data?: unknown) => {\n for (const listener of listeners.get(channel) ?? []) {\n try {\n listener(data);\n } catch (error) {\n console.error(`[lit-devtools] listener for ${channel} threw`, error);\n }\n }\n },\n });\n\n return {\n send(channel, data) {\n rpc.callEvent(RPC_PAGE_SEND, channel, data);\n },\n on(channel, handler) {\n let set = listeners.get(channel);\n if (set === undefined) listeners.set(channel, (set = new Set()));\n set.add(handler);\n return () => void set.delete(handler);\n },\n };\n};\n\n/** Options for {@link connectToDevServer}. */\nexport interface ConnectOptions {\n /**\n * A bearer token the server already trusts. Without one the client falls\n * back to devframe's own flow (a stored token, a magic-link code in the URL,\n * or a prompt for the one-time code the server prints) unless the server was\n * started with `--no-auth`.\n */\n authToken?: string;\n /**\n * The server's connection descriptor (what it serves at\n * `<url>/__connection.json`). Passing it skips that fetch, which is the\n * step a cross-origin page cannot make: the server sends no CORS headers,\n * and a classic script tag is exempt from them where `fetch` is not.\n */\n connectionMeta?: ConnectionMeta;\n}\n\n/**\n * Point this page's runtime at a standalone `lit-devtools dev` server.\n *\n * Resolves once the connection is trusted, after which the tree, inspector\n * and timeline traffic that used to go to this page's own Vite server goes to\n * `url` instead (the runtime announces itself again so the server can replay\n * recording state). Returns a function that disconnects and hands the channel\n * back to the carrier it replaced.\n *\n * The page's origin must be allowed to reach `url`; this does not set up\n * cross-origin access.\n *\n * @param url Origin of the dev server, e.g. `http://localhost:5180/`.\n */\nexport const connectToDevServer = async (\n url: string,\n options: ConnectOptions = {}\n): Promise<() => void> => {\n const {getDevframeRpcClient} = await import('devframe/client');\n const client = await getDevframeRpcClient({\n baseURL: url,\n authToken: options.authToken,\n connectionMeta: options.connectionMeta,\n });\n await client.ensureTrusted();\n\n const previous = pageChannel.transport;\n pageChannel.attach(createRpcTransport(client.scope(LIT_DEVFRAME_ID).rpc));\n\n return () => {\n client.close?.();\n if (previous !== undefined) pageChannel.attach(previous);\n };\n};\n"]}
@@ -1,8 +1,3 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
1
  /** Runtime accessor for injected component source metadata. */
7
2
  export declare const SOURCE_META_KEY: unique symbol;
8
3
  export interface LitSourceMeta {
@@ -1 +1 @@
1
- {"version":3,"file":"source-meta.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/source-meta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+DAA+D;AAC/D,eAAO,MAAM,eAAe,eAAiD,CAAC;AAE9E,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,gCAAgC,GAAG,wBAAwB,GAAG;IACxE,CAAC,eAAe,CAAC,CAAC,EAAE,aAAa,CAAC;CACnC,CAAC"}
1
+ {"version":3,"file":"source-meta.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/source-meta.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,eAAO,MAAM,eAAe,eAAiD,CAAC;AAE9E,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,gCAAgC,GAAG,wBAAwB,GAAG;IACxE,CAAC,eAAe,CAAC,CAAC,EAAE,aAAa,CAAC;CACnC,CAAC"}
@@ -1,8 +1,3 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
1
  /** Runtime accessor for injected component source metadata. */
7
2
  export const SOURCE_META_KEY = Symbol.for('@lit-labs/vite-plugin-lit#source');
8
3
  //# sourceMappingURL=source-meta.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-meta.js","sourceRoot":"","sources":["../../src/lib/runtime/source-meta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+DAA+D;AAC/D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/** Runtime accessor for injected component source metadata. */\nexport const SOURCE_META_KEY = Symbol.for('@lit-labs/vite-plugin-lit#source');\n\nexport interface LitSourceMeta {\n filePath: string;\n lineNumber: number;\n componentName?: string;\n}\n\nexport type CustomElementConstructorWithMeta = CustomElementConstructor & {\n [SOURCE_META_KEY]?: LitSourceMeta;\n};\n"]}
1
+ {"version":3,"file":"source-meta.js","sourceRoot":"","sources":["../../src/lib/runtime/source-meta.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["/** Runtime accessor for injected component source metadata. */\nexport const SOURCE_META_KEY = Symbol.for('@lit-labs/vite-plugin-lit#source');\n\nexport interface LitSourceMeta {\n filePath: string;\n lineNumber: number;\n componentName?: string;\n}\n\nexport type CustomElementConstructorWithMeta = CustomElementConstructor & {\n [SOURCE_META_KEY]?: LitSourceMeta;\n};\n"]}
@@ -1,8 +1,3 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
1
  import type { EditorConfig } from '../../types.js';
7
2
  export declare const BUILTIN_EDITORS: Record<string, EditorConfig>;
8
3
  export declare const resolveEditor: (editor: EditorConfig | string | undefined) => EditorConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"editors.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/source-overlay/editors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAIjD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAsBxD,CAAC;AAIF,eAAO,MAAM,aAAa,WAChB,YAAY,GAAG,MAAM,GAAG,SAAS,KACxC,YAMF,CAAC"}
1
+ {"version":3,"file":"editors.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/source-overlay/editors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAWjD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAsBxD,CAAC;AAIF,eAAO,MAAM,aAAa,WAChB,YAAY,GAAG,MAAM,GAAG,SAAS,KACxC,YAMF,CAAC"}
@@ -1,22 +1,22 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
1
+ // `<scheme>://file/` already ends in the slash that starts a POSIX path, so a
2
+ // second one would put `//Users/...` in the URL path, which VS Code-family
3
+ // editors only resolve by accident. Drop exactly one: Windows drive paths have
4
+ // none to drop, and a UNC `//server/share` keeps the double slash it needs.
5
+ const filePath = (path) => (path.startsWith('/') ? path.slice(1) : path);
6
6
  // Keep the keys/labels in sync with SOURCE_OVERLAY_EDITORS in
7
7
  // src/types/timeline.ts (the panel's editor-selection options).
8
8
  export const BUILTIN_EDITORS = {
9
9
  vscode: {
10
10
  name: 'VS Code',
11
- url: (path, line) => `vscode://file/${path}:${line}`,
11
+ url: (path, line) => `vscode://file/${filePath(path)}:${line}`,
12
12
  },
13
13
  cursor: {
14
14
  name: 'Cursor',
15
- url: (path, line) => `cursor://file/${path}:${line}`,
15
+ url: (path, line) => `cursor://file/${filePath(path)}:${line}`,
16
16
  },
17
17
  zed: {
18
18
  name: 'Zed',
19
- url: (path, line) => `zed://file/${path}:${line}`,
19
+ url: (path, line) => `zed://file/${filePath(path)}:${line}`,
20
20
  },
21
21
  idea: {
22
22
  name: 'IntelliJ',
@@ -25,7 +25,7 @@ export const BUILTIN_EDITORS = {
25
25
  },
26
26
  windsurf: {
27
27
  name: 'Windsurf',
28
- url: (path, line) => `windsurf://file/${path}:${line}`,
28
+ url: (path, line) => `windsurf://file/${filePath(path)}:${line}`,
29
29
  },
30
30
  };
31
31
  // Resolve an editor option to a config: a builtin name, a custom config, or the