@oddsquad/vite-plugin-lit 0.6.1 → 0.7.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 (55) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +28 -12
  3. package/bin.mjs +87 -5
  4. package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-F2EfZsFX.js → browser-agent-rpc-BXhoSh1z-BuCvPGjS.js} +2 -2
  5. package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-F2EfZsFX.js.map → browser-agent-rpc-BXhoSh1z-BuCvPGjS.js.map} +1 -1
  6. package/dist/client/assets/{index-B2HYO7lk.js → index-D632jo79.js} +22 -3
  7. package/dist/client/assets/index-D632jo79.js.map +1 -0
  8. package/dist/client/index.html +1 -1
  9. package/dist/standalone/lit-devtools.js +6820 -0
  10. package/lib/devframe/allowed-origins.d.ts +13 -0
  11. package/lib/devframe/allowed-origins.d.ts.map +1 -0
  12. package/lib/devframe/allowed-origins.js +63 -0
  13. package/lib/devframe/allowed-origins.js.map +1 -0
  14. package/lib/options.d.ts +26 -0
  15. package/lib/options.d.ts.map +1 -1
  16. package/lib/options.js +19 -0
  17. package/lib/options.js.map +1 -1
  18. package/lib/plugin.d.ts.map +1 -1
  19. package/lib/plugin.js +3 -0
  20. package/lib/plugin.js.map +1 -1
  21. package/lib/plugins/private-fields.d.ts +27 -0
  22. package/lib/plugins/private-fields.d.ts.map +1 -0
  23. package/lib/plugins/private-fields.js +259 -0
  24. package/lib/plugins/private-fields.js.map +1 -0
  25. package/lib/runtime/child-state.d.ts +100 -0
  26. package/lib/runtime/child-state.d.ts.map +1 -0
  27. package/lib/runtime/child-state.js +446 -0
  28. package/lib/runtime/child-state.js.map +1 -0
  29. package/lib/runtime/inspector/install.js +4 -1
  30. package/lib/runtime/inspector/install.js.map +1 -1
  31. package/lib/runtime/patch.d.ts +24 -0
  32. package/lib/runtime/patch.d.ts.map +1 -1
  33. package/lib/runtime/patch.js +22 -1
  34. package/lib/runtime/patch.js.map +1 -1
  35. package/lib/runtime/rpc-transport.d.ts +8 -0
  36. package/lib/runtime/rpc-transport.d.ts.map +1 -1
  37. package/lib/runtime/rpc-transport.js +1 -0
  38. package/lib/runtime/rpc-transport.js.map +1 -1
  39. package/lib/runtime/source-overlay/editors.d.ts.map +1 -1
  40. package/lib/runtime/source-overlay/editors.js +9 -4
  41. package/lib/runtime/source-overlay/editors.js.map +1 -1
  42. package/lib/runtime/standalone.d.ts +27 -0
  43. package/lib/runtime/standalone.d.ts.map +1 -0
  44. package/lib/runtime/standalone.js +50 -0
  45. package/lib/runtime/standalone.js.map +1 -0
  46. package/lib/runtime/timeline/install.js +4 -2
  47. package/lib/runtime/timeline/install.js.map +1 -1
  48. package/lib/runtime/timeline/lifecycle.d.ts.map +1 -1
  49. package/lib/runtime/timeline/lifecycle.js +5 -1
  50. package/lib/runtime/timeline/lifecycle.js.map +1 -1
  51. package/package.json +13 -9
  52. package/types/timeline.d.ts +4 -1
  53. package/types/timeline.d.ts.map +1 -1
  54. package/types/timeline.js.map +1 -1
  55. package/dist/client/assets/index-B2HYO7lk.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAC;AAc/B,IAAI,UAAU,GAAsB,IAAI,CAAC;AAEzC,yEAAyE;AACzE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAuB,EAAQ,EAAE;IAC7D,UAAU,GAAG,IAAI,CAAC;AACpB,CAAC,CAAC;AAEF,4EAA4E;AAC5E,MAAM,aAAa,GAAG,CAAC,EAAU,EAAE,KAAc,EAAQ,EAAE;IAC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EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACtE,IAAI,KAAK,KAAK,IAAI;YAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;AACH,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * ReactiveElement prototype instrumentation for the lifecycle timeline layer.\n *\n * Wraps the lifecycle methods listed in PHASES on the prototype of the\n * ReactiveElement class loaded by the app — not by importing lit directly,\n * to avoid multi-copy issues. The proto is resolved from the already-defined\n * custom element registry (same mechanism as the HMR patch module).\n *\n * Each wrapped method emits a paired start/end TimelineEvent so the panel\n * can render duration bars. performUpdate brackets the whole update tick and\n * bumps a per-instance tick counter that becomes the groupId shared by all\n * phase events within that tick.\n *\n * Gated by the recording flag so overhead is near-zero when idle.\n */\n\nimport {idOf, sourceOf, changedKeys} from './identity.js';\nimport {now} from './clock.js';\nimport type {TimelineEvent} from '../../../types/timeline.js';\n\ntype EmitFn = (event: TimelineEvent) => void;\ntype RecordingFn = () => boolean;\ntype LayerEnabledFn = () => boolean;\n\n/**\n * Called once per completed `performUpdate`, with the element and whether that\n * was its first update. Independent of the recording gate: the flash overlay\n * wants every update while it is on, whether or not the timeline is recording.\n */\nexport type UpdateHook = (el: Element, first: boolean) => void;\n\nlet updateHook: UpdateHook | null = null;\n\n/** Install (or clear, with `null`) the per-update hook. One consumer. */\nexport const setUpdateHook = (hook: UpdateHook | null): void => {\n updateHook = hook;\n};\n\n/** Runs the update hook, never letting a consumer's throw reach the app. */\nconst notifyUpdated = (el: object, first: boolean): void => {\n if (updateHook === null) return;\n try {\n updateHook(el as Element, first);\n } catch {\n // dev tool — an overlay bug must not break the app's update cycle\n }\n};\n\n/** `ReactiveElement.hasUpdated`, read before the update flips it. */\nconst isFirstUpdate = (el: object): boolean =>\n (el as {hasUpdated?: boolean}).hasUpdated !== true;\n\n/** Phases to instrument with start/end pairs. */\nconst UPDATE_PHASES = [\n 'performUpdate',\n 'willUpdate',\n 'update',\n 'updated',\n 'firstUpdated',\n] as const;\n\n/** Point-in-time lifecycle events (no end bracket). */\nconst POINT_PHASES = ['connectedCallback', 'disconnectedCallback'] as const;\n\nconst BRAND = Symbol.for('@lit-labs/vite-plugin-lit#timeline-lifecycle');\n\n/** Per-instance update tick counter (bumped inside performUpdate wrapper). */\nconst ticks = new WeakMap<object, number>();\n\nconst tickOf = (el: object): number => ticks.get(el) ?? 0;\n\ntype AnyFn = (...args: unknown[]) => unknown;\ntype Proto = Record<string | symbol, AnyFn | undefined>;\n\n/** Returns true if `proto[name]` is already our wrapper (idempotent install). */\nconst isWrapped = (proto: Proto, name: string): boolean => {\n const fn = proto[name];\n return (\n typeof fn === 'function' && (fn as AnyFn & {[BRAND]?: true})[BRAND] === true\n );\n};\n\n/**\n * Wrap `proto[name]` with a start/end pair emitting to `emit`.\n * `isPoint` methods only emit a single event (no end bracket).\n */\nconst wrap = (\n proto: Proto,\n name: string,\n isPoint: boolean,\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n if (isWrapped(proto, name)) return;\n const orig = proto[name];\n\n const wrapper: AnyFn & {[BRAND]?: true} = function (\n this: object,\n ...args: unknown[]\n ) {\n const isUpdate = name === 'performUpdate';\n if (!recording() || !enabled()) {\n if (!isUpdate || updateHook === null) return orig?.apply(this, args);\n const first = isFirstUpdate(this);\n const result = orig?.apply(this, args);\n notifyUpdated(this, first);\n return result;\n }\n const first = isUpdate && isFirstUpdate(this);\n\n // Bump the per-instance tick at the *start* of each performUpdate, before\n // computing the groupId, so this whole update cycle — performUpdate and the\n // willUpdate/update/updated phases it nests — shares one groupId, distinct\n // from the previous cycle's. (Reading the tick before bumping put\n // performUpdate in a different group from its own phases and let adjacent\n // cycles collide on the same tick.)\n if (name === 'performUpdate') {\n ticks.set(this, tickOf(this) + 1);\n }\n\n const elementId = idOf(this);\n const tagName = (this as Element).localName ?? 'unknown';\n const source = sourceOf(this);\n const tick = tickOf(this);\n const groupId = `${elementId}:${tick}`;\n const time = now();\n const changed = changedKeys(args[0]);\n\n if (!isPoint) {\n emit({\n layerId: 'lit-lifecycle',\n time,\n groupId,\n title: name + ':start',\n subtitle: tagName,\n data: {phase: name, changed},\n meta: {elementId, tagName, source},\n });\n }\n\n let result: unknown;\n try {\n result = orig?.apply(this, args);\n } finally {\n if (!isPoint) {\n emit({\n layerId: 'lit-lifecycle',\n time: now(),\n groupId,\n title: name + ':end',\n subtitle: tagName,\n data: {phase: name},\n meta: {elementId, tagName, source},\n });\n } else {\n emit({\n layerId: 'lit-lifecycle',\n time,\n title: name,\n subtitle: tagName,\n data: {phase: name},\n meta: {elementId, tagName, source},\n });\n }\n }\n // After the bracket, not in it: a throwing update never completed, so it\n // doesn't count as one.\n if (isUpdate) notifyUpdated(this, first);\n return result;\n };\n wrapper[BRAND] = true;\n\n try {\n Object.defineProperty(proto, name, {\n value: wrapper,\n writable: true,\n configurable: true,\n });\n } catch {\n // Non-configurable slot; instrumentation degrades gracefully.\n }\n};\n\n/**\n * Finds the prototype in `proto`'s chain that *owns* `name` as an own property,\n * or null if none does.\n */\nconst ownerOf = (proto: Proto, name: string): Proto | null => {\n let p: Proto | null = proto;\n while (p !== null && !Object.prototype.hasOwnProperty.call(p, name)) {\n p = Object.getPrototypeOf(p) as Proto | null;\n }\n return p;\n};\n\n/**\n * Returns any defined Lit element's prototype (duck-typed by `performUpdate`),\n * or null if none can be found yet. One sample is enough: its chain leads to\n * the shared ReactiveElement/LitElement base prototypes every component\n * inherits.\n *\n * Tries the non-standard `_registry` map first, then falls back to sampling a\n * live upgraded element from the DOM — `_registry` isn't present in every\n * engine (e.g. some Chrome builds), and without this fallback an app whose\n * components were all defined before the runtime installed gets no lifecycle\n * instrumentation at all.\n */\nconst findLitElementProto = (): Proto | null => {\n const registry = (\n customElements as unknown as {\n _registry?: Record<string, CustomElementConstructor>;\n }\n )._registry;\n if (registry !== undefined) {\n for (const ctor of Object.values(registry)) {\n const proto = ctor?.prototype;\n if (proto != null && 'performUpdate' in proto) return proto as Proto;\n }\n }\n if (typeof document !== 'undefined') {\n for (const el of document.querySelectorAll('*')) {\n const proto = Object.getPrototypeOf(el) as Proto | null;\n if (proto != null && 'performUpdate' in proto) return proto;\n }\n }\n return null;\n};\n\nlet installed = false;\n\n/**\n * Install lifecycle instrumentation for *every* Lit element on the page.\n *\n * The phases live on the shared ReactiveElement/LitElement base prototypes, so\n * wrapping them there instruments all components at once — not just the first\n * one registered (the old behavior, which also silently no-op'd when Vite\n * served the production Lit build, since that omits the `reactiveElementVersions`\n * sentinel the resolver gated on).\n *\n * A component that overrides `willUpdate`/`updated`/`firstUpdated` *without*\n * calling `super` shadows the base no-op and won't report that phase — an\n * accepted limitation; the common case and `super`-calling overrides report.\n *\n * Idempotent — wrapping is brand-guarded per prototype+method.\n */\nexport const installLifecycleLayer = (\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n if (installed) return;\n installed = true;\n\n // Instrument from a sample already on the page (covers components defined\n // before the runtime installed — the common case, since the runtime is\n // injected after the app's modules).\n const proto = findLitElementProto();\n if (proto !== null) {\n patchBases(proto, emit, recording, enabled);\n }\n\n // Also instrument on future defines — both for components registered later\n // and for the case where none were discoverable above. Kept installed for\n // the page's lifetime; `patchBases` is idempotent (wrapping is brand-guarded\n // per prototype+method), so re-running once the shared bases are wrapped is a\n // cheap no-op.\n const origDefine = customElements.define.bind(customElements);\n customElements.define = (name, ctor, options) => {\n origDefine(name, ctor, options);\n const p = ctor?.prototype as Proto | null;\n if (p != null && 'performUpdate' in p) {\n patchBases(p, emit, recording, enabled);\n }\n };\n};\n\n/**\n * Wraps the lifecycle phases on the shared base prototypes reachable from\n * `sample`. `performUpdate` is never overridden by app code, so walking up from\n * any Lit element lands on `ReactiveElement.prototype` — which owns the update/\n * connect lifecycle, shared by all components. `update` is wrapped on its\n * effective owner instead (`LitElement.prototype` overrides it to drive\n * `render()`), so the timed call is the one that actually runs.\n */\nconst patchBases = (\n sample: Proto,\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n const reProto = ownerOf(sample, 'performUpdate');\n if (reProto === null) return;\n for (const name of UPDATE_PHASES) {\n const owner = name === 'update' ? ownerOf(sample, 'update') : reProto;\n if (owner !== null) wrap(owner, name, false, emit, recording, enabled);\n }\n for (const name of POINT_PHASES) {\n wrap(reProto, name, true, emit, recording, enabled);\n }\n};\n"]}
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAC;AAc/B,IAAI,UAAU,GAAsB,IAAI,CAAC;AAEzC,yEAAyE;AACzE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAuB,EAAQ,EAAE;IAC7D,UAAU,GAAG,IAAI,CAAC;AACpB,CAAC,CAAC;AAEF,4EAA4E;AAC5E,MAAM,aAAa,GAAG,CAAC,EAAU,EAAE,KAAc,EAAQ,EAAE;IACzD,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO;IAChC,IAAI,CAAC;QACH,UAAU,CAAC,EAAa,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAAC,MAA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AC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACtE,IAAI,KAAK,KAAK,IAAI;YAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;AACH,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * ReactiveElement prototype instrumentation for the lifecycle timeline layer.\n *\n * Wraps the lifecycle methods listed in PHASES on the prototype of the\n * ReactiveElement class loaded by the app — not by importing lit directly,\n * to avoid multi-copy issues. The proto is resolved from the already-defined\n * custom element registry (same mechanism as the HMR patch module).\n *\n * Each wrapped method emits a paired start/end TimelineEvent so the panel\n * can render duration bars. performUpdate brackets the whole update tick and\n * bumps a per-instance tick counter that becomes the groupId shared by all\n * phase events within that tick.\n *\n * Gated by the recording flag so overhead is near-zero when idle.\n */\n\nimport {idOf, sourceOf, changedKeys} from './identity.js';\nimport {now} from './clock.js';\nimport type {TimelineEvent} from '../../../types/timeline.js';\n\ntype EmitFn = (event: TimelineEvent) => void;\ntype RecordingFn = () => boolean;\ntype LayerEnabledFn = () => boolean;\n\n/**\n * Called once per completed `performUpdate`, with the element and whether that\n * was its first update. Independent of the recording gate: the flash overlay\n * wants every update while it is on, whether or not the timeline is recording.\n */\nexport type UpdateHook = (el: Element, first: boolean) => void;\n\nlet updateHook: UpdateHook | null = null;\n\n/** Install (or clear, with `null`) the per-update hook. One consumer. */\nexport const setUpdateHook = (hook: UpdateHook | null): void => {\n updateHook = hook;\n};\n\n/** Runs the update hook, never letting a consumer's throw reach the app. */\nconst notifyUpdated = (el: object, first: boolean): void => {\n if (updateHook === null) return;\n try {\n updateHook(el as Element, first);\n } catch {\n // dev tool — an overlay bug must not break the app's update cycle\n }\n};\n\n/** `ReactiveElement.hasUpdated`, read before the update flips it. */\nconst isFirstUpdate = (el: object): boolean =>\n (el as {hasUpdated?: boolean}).hasUpdated !== true;\n\n/** Phases to instrument with start/end pairs. */\nconst UPDATE_PHASES = [\n 'performUpdate',\n 'willUpdate',\n 'update',\n 'updated',\n 'firstUpdated',\n] as const;\n\n/** Point-in-time lifecycle events (no end bracket). */\nconst POINT_PHASES = ['connectedCallback', 'disconnectedCallback'] as const;\n\nconst BRAND = Symbol.for('@lit-labs/vite-plugin-lit#timeline-lifecycle');\n\n/** Per-instance update tick counter (bumped inside performUpdate wrapper). */\nconst ticks = new WeakMap<object, number>();\n\nconst tickOf = (el: object): number => ticks.get(el) ?? 0;\n\ntype AnyFn = (...args: unknown[]) => unknown;\ntype Proto = Record<string | symbol, AnyFn | undefined>;\n\n/** Returns true if `proto[name]` is already our wrapper (idempotent install). */\nconst isWrapped = (proto: Proto, name: string): boolean => {\n const fn = proto[name];\n return (\n typeof fn === 'function' && (fn as AnyFn & {[BRAND]?: true})[BRAND] === true\n );\n};\n\n/**\n * Wrap `proto[name]` with a start/end pair emitting to `emit`.\n * `isPoint` methods only emit a single event (no end bracket).\n */\nconst wrap = (\n proto: Proto,\n name: string,\n isPoint: boolean,\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n if (isWrapped(proto, name)) return;\n const orig = proto[name];\n\n const wrapper: AnyFn & {[BRAND]?: true} = function (\n this: object,\n ...args: unknown[]\n ) {\n const isUpdate = name === 'performUpdate';\n if (!recording() || !enabled()) {\n if (!isUpdate || updateHook === null) return orig?.apply(this, args);\n const first = isFirstUpdate(this);\n const result = orig?.apply(this, args);\n notifyUpdated(this, first);\n return result;\n }\n const first = isUpdate && isFirstUpdate(this);\n\n // Bump the per-instance tick at the *start* of each performUpdate, before\n // computing the groupId, so this whole update cycle — performUpdate and the\n // willUpdate/update/updated phases it nests — shares one groupId, distinct\n // from the previous cycle's. (Reading the tick before bumping put\n // performUpdate in a different group from its own phases and let adjacent\n // cycles collide on the same tick.)\n if (name === 'performUpdate') {\n ticks.set(this, tickOf(this) + 1);\n }\n\n const elementId = idOf(this);\n const tagName = (this as Element).localName ?? 'unknown';\n const source = sourceOf(this);\n const tick = tickOf(this);\n const groupId = `${elementId}:${tick}`;\n const time = now();\n const changed = changedKeys(args[0]);\n\n if (!isPoint) {\n emit({\n layerId: 'lit-lifecycle',\n time,\n groupId,\n title: name + ':start',\n subtitle: tagName,\n data: {phase: name, changed},\n meta: {elementId, tagName, source},\n });\n }\n\n let result: unknown;\n try {\n result = orig?.apply(this, args);\n } finally {\n if (!isPoint) {\n emit({\n layerId: 'lit-lifecycle',\n time: now(),\n groupId,\n title: name + ':end',\n subtitle: tagName,\n data: {phase: name},\n meta: {elementId, tagName, source},\n });\n } else {\n emit({\n layerId: 'lit-lifecycle',\n time,\n title: name,\n subtitle: tagName,\n data: {phase: name},\n meta: {elementId, tagName, source},\n });\n }\n }\n // After the bracket, not in it: a throwing update never completed, so it\n // doesn't count as one.\n if (isUpdate) notifyUpdated(this, first);\n return result;\n };\n wrapper[BRAND] = true;\n\n try {\n Object.defineProperty(proto, name, {\n value: wrapper,\n writable: true,\n configurable: true,\n });\n } catch {\n // Non-configurable slot; instrumentation degrades gracefully.\n }\n};\n\n/**\n * Finds the prototype in `proto`'s chain that *owns* `name` as an own property,\n * or null if none does.\n */\nconst ownerOf = (proto: Proto, name: string): Proto | null => {\n let p: Proto | null = proto;\n while (p !== null && !Object.prototype.hasOwnProperty.call(p, name)) {\n p = Object.getPrototypeOf(p) as Proto | null;\n }\n return p;\n};\n\n/**\n * Returns any defined Lit element's prototype (duck-typed by `performUpdate`),\n * or null if none can be found yet. One sample is enough: its chain leads to\n * the shared ReactiveElement/LitElement base prototypes every component\n * inherits.\n *\n * Tries the non-standard `_registry` map first, then falls back to sampling a\n * live upgraded element from the DOM — `_registry` isn't present in every\n * engine (e.g. some Chrome builds), and without this fallback an app whose\n * components were all defined before the runtime installed gets no lifecycle\n * instrumentation at all.\n */\nconst findLitElementProto = (): Proto | null => {\n const registry = (\n customElements as unknown as {\n _registry?: Record<string, CustomElementConstructor>;\n }\n )._registry;\n if (registry !== undefined) {\n for (const ctor of Object.values(registry)) {\n const proto = ctor?.prototype;\n if (proto != null && 'performUpdate' in proto) return proto as Proto;\n }\n }\n if (typeof document !== 'undefined') {\n for (const el of document.querySelectorAll('*')) {\n const proto = Object.getPrototypeOf(el) as Proto | null;\n if (proto != null && 'performUpdate' in proto) return proto;\n }\n }\n return null;\n};\n\nlet installed = false;\n\n/**\n * Install lifecycle instrumentation for *every* Lit element on the page.\n *\n * The phases live on the shared ReactiveElement/LitElement base prototypes, so\n * wrapping them there instruments all components at once — not just the first\n * one registered (the old behavior, which also silently no-op'd when Vite\n * served the production Lit build, since that omits the `reactiveElementVersions`\n * sentinel the resolver gated on).\n *\n * A component that overrides `willUpdate`/`updated`/`firstUpdated` *without*\n * calling `super` shadows the base no-op and won't report that phase — an\n * accepted limitation; the common case and `super`-calling overrides report.\n *\n * Idempotent — wrapping is brand-guarded per prototype+method.\n */\nexport const installLifecycleLayer = (\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n if (installed) return;\n installed = true;\n\n // Instrument from a sample already on the page (covers components defined\n // before the runtime installed — the common case, since the runtime is\n // injected after the app's modules).\n const proto = findLitElementProto();\n if (proto !== null) {\n patchBases(proto, emit, recording, enabled);\n }\n\n // Also instrument on future defines — both for components registered later\n // and for the case where none were discoverable above. Kept installed for\n // the page's lifetime; `patchBases` is idempotent (wrapping is brand-guarded\n // per prototype+method), so re-running once the shared bases are wrapped is a\n // cheap no-op.\n const origDefine = customElements.define.bind(customElements);\n // Patch before defining: the platform reads connectedCallback and\n // disconnectedCallback off the prototype at define() time, so wrapping them\n // afterwards would miss the first component defined on a page with no Lit\n // element yet.\n customElements.define = (name, ctor, options) => {\n const p = ctor?.prototype as Proto | null;\n if (p != null && 'performUpdate' in p) {\n patchBases(p, emit, recording, enabled);\n }\n origDefine(name, ctor, options);\n };\n};\n\n/**\n * Wraps the lifecycle phases on the shared base prototypes reachable from\n * `sample`. `performUpdate` is never overridden by app code, so walking up from\n * any Lit element lands on `ReactiveElement.prototype` — which owns the update/\n * connect lifecycle, shared by all components. `update` is wrapped on its\n * effective owner instead (`LitElement.prototype` overrides it to drive\n * `render()`), so the timed call is the one that actually runs.\n */\nconst patchBases = (\n sample: Proto,\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n const reProto = ownerOf(sample, 'performUpdate');\n if (reProto === null) return;\n for (const name of UPDATE_PHASES) {\n const owner = name === 'update' ? ownerOf(sample, 'update') : reProto;\n if (owner !== null) wrap(owner, name, false, emit, recording, enabled);\n }\n for (const name of POINT_PHASES) {\n wrap(reProto, name, true, emit, recording, enabled);\n }\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oddsquad/vite-plugin-lit",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Vite plugin providing true HMR for Lit components, plus CSS helpers and a DevTools panel",
5
5
  "license": "BSD-3-Clause",
6
6
  "author": "Oddsquad (based on @lit-labs/vite-hmr by Google LLC)",
@@ -11,6 +11,7 @@
11
11
  "/CHANGELOG.md",
12
12
  "/lib/",
13
13
  "/dist/client/",
14
+ "/dist/standalone/",
14
15
  "/types/",
15
16
  "/index.{d.ts,d.ts.map,js,js.map}",
16
17
  "/client.d.ts",
@@ -47,7 +48,7 @@
47
48
  "devframe": "^1.1.0",
48
49
  "es-module-lexer": "^3.0.2",
49
50
  "launch-editor": "^2.14.1",
50
- "magic-string": "^1.4.1"
51
+ "magic-string": "^1.4.2"
51
52
  },
52
53
  "peerDependencies": {
53
54
  "@devframes/agentic": "^1.0.0",
@@ -78,17 +79,18 @@
78
79
  "@lit-labs/virtualizer": "^2.1.1",
79
80
  "@lit/context": "^1.1.6",
80
81
  "@lit/task": "^1.0.3",
81
- "@types/node": "^26.6.1",
82
+ "@types/node": "^26.6.3",
82
83
  "@vitejs/devtools-kit": "0.7.6",
83
84
  "cac": "7.0.0",
84
- "git-cliff": "^2.13.1",
85
+ "git-cliff": "^2.14.2",
86
+ "happy-dom": "^20.14.5",
85
87
  "lightningcss": "^1.33.0",
86
88
  "lit": "^3.3.3",
87
89
  "playwright-core": "^1.63.0",
88
90
  "temporal-polyfill": "^1.0.5",
89
91
  "typescript": "^7.0.2",
90
- "vite": "npm:@voidzero-dev/vite-plus-core@0.3.2",
91
- "vite-plus": "0.3.2"
92
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.0.0",
93
+ "vite-plus": "1.0.0"
92
94
  },
93
95
  "engines": {
94
96
  "node": ">=20"
@@ -107,11 +109,11 @@
107
109
  "access": "public"
108
110
  },
109
111
  "scripts": {
110
- "build": "tsc --pretty && pnpm run build:panel && node scripts/format-build-output.mjs",
112
+ "build": "tsc --pretty && pnpm run build:panel && pnpm run build:standalone && node scripts/format-build-output.mjs",
111
113
  "build:lit-canary": "node scripts/build-lit-canary.mjs",
112
114
  "dev": "pnpm run build && vp dev playground",
113
115
  "test": "pnpm run test:unit && pnpm run test:e2e",
114
- "test:unit": "node scripts/check-client-types.mjs && vp test run --project unit",
116
+ "test:unit": "node scripts/check-client-types.mjs && vp test run --project unit --project dom",
115
117
  "test:e2e": "pnpm run build && vp test run --project e2e",
116
118
  "changelog": "git-cliff --unreleased",
117
119
  "bench": "node bench/run.mjs",
@@ -121,6 +123,8 @@
121
123
  "docs:shots": "pnpm run build && node scripts/docs-shots.mjs",
122
124
  "format": "vp fmt \"**/*.{cjs,html,js,json,md,mdx,ts,yaml}\"",
123
125
  "format:check": "vp fmt \"**/*.{cjs,html,js,json,md,mdx,ts,yaml}\" --check",
124
- "build:panel": "vp build src/panel"
126
+ "build:panel": "vp build src/panel",
127
+ "build:standalone": "vp build src/standalone",
128
+ "standalone:demo": "pnpm run build && pnpm --dir playground run standalone"
125
129
  }
126
130
  }
@@ -65,6 +65,7 @@ export interface FeatureSettings {
65
65
  enabled: boolean;
66
66
  reconnect: boolean;
67
67
  onIncompatible: 'reload' | 'warn';
68
+ childState: 'reset' | 'transfer' | 'reuse';
68
69
  indicatorEnabled: boolean;
69
70
  indicatorCount: boolean;
70
71
  };
@@ -94,6 +95,7 @@ export type SettingSource = 'option' | 'env' | 'default';
94
95
  export interface SettingSources {
95
96
  hmrReconnect?: SettingSource;
96
97
  hmrOnIncompatible?: SettingSource;
98
+ hmrChildState?: SettingSource;
97
99
  hmrIndicatorVisible?: SettingSource;
98
100
  hmrIndicatorCount?: SettingSource;
99
101
  sourceOverlayEditor?: SettingSource;
@@ -113,6 +115,7 @@ export interface SettingSources {
113
115
  export interface SettingsOverride {
114
116
  hmrReconnect?: boolean;
115
117
  hmrOnIncompatible?: 'reload' | 'warn';
118
+ hmrChildState?: 'reset' | 'transfer' | 'reuse';
116
119
  hmrIndicatorVisible?: boolean;
117
120
  hmrIndicatorCount?: boolean;
118
121
  /** Built-in editor key for the source overlay's open-in-editor target. */
@@ -151,7 +154,7 @@ export declare const SETTINGS_OVERRIDE_LS_KEY = "lit-devtools-overrides";
151
154
  * beside the {@link SettingsOverride}, never inside it: the runtime applies and
152
155
  * receives the override as-is and has no use for these.
153
156
  */
154
- export type OverrideBaselines = Partial<Record<'hmrReconnect' | 'hmrOnIncompatible' | 'hmrIndicatorVisible' | 'hmrIndicatorCount' | 'sourceOverlayEditor', unknown>>;
157
+ export type OverrideBaselines = Partial<Record<'hmrReconnect' | 'hmrOnIncompatible' | 'hmrChildState' | 'hmrIndicatorVisible' | 'hmrIndicatorCount' | 'sourceOverlayEditor', unknown>>;
155
158
  /** localStorage key holding the {@link OverrideBaselines}. */
156
159
  export declare const OVERRIDE_BASELINES_LS_KEY = "lit-devtools-override-baselines";
157
160
  /** Vite HMR channel the server uses to push overrides to the app runtime. */
@@ -1 +1 @@
1
- {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../src/types/timeline.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa,CAAC,KAAK,GAAG,OAAO;IAC5C;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IAC1C,IAAI,CAAC,EAAE;QACL,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAC,CAAC;KACvC,CAAC;CACH;AAED,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,OAAO,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,uBAAuB,EAAE,OAAO,CAAC;IACjC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,aAAa,EAMnD,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,mBAOlC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,eAA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BAAwB,GAAG,wBAAwB,CAAC;AAmBjE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,yBAAyB,GAAG,iCAAiC,CAAC;AAE3E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,yBAAyB,GAAG,gCAAgC,CAAC;AAE1E;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GACxC,oCAAoC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nexport interface TimelineLayer {\n id: string;\n label: string;\n color: number; // 0xRRGGBB\n}\n\nexport interface TimelineEvent<TData = unknown> {\n /**\n * Stable identity, stamped on the Node side (`${epoch}-${seq}`) when the\n * event is received, so it survives the stream, `recent-events` and a\n * snapshot export. Absent on events still in the page runtime.\n */\n id?: string;\n layerId: string;\n /**\n * Milliseconds since recording started, stamped in the browser page\n * (`performance.now()` re-zeroed on each recording start; see\n * `runtime/timeline/clock.ts`). Not comparable to any Node-side clock.\n */\n time: number;\n data: TData;\n title?: string;\n subtitle?: string;\n /** Pairs a start event with its matching end event in the same update group. */\n groupId?: number | string;\n logType?: 'default' | 'warning' | 'error';\n meta?: {\n elementId?: number;\n tagName?: string;\n source?: {file: string; line: number};\n };\n}\n\nexport interface TimelineLayersState {\n recordingState: boolean;\n litLifecycleEnabled: boolean;\n litRenderEnabled: boolean;\n /**\n * Per-part `lit-debug` events (`template updating`, `set part`, `commit\n * *`, …) — one per binding on *every* render, so a ticking clock or\n * animation floods the layer. Off by default; the `lit-render` layer's\n * begin/end render pair already covers the common case.\n */\n litRenderVerboseEnabled: boolean;\n mouseEventEnabled: boolean;\n keyboardEventEnabled: boolean;\n}\n\nexport const TIMELINE_LAYERS: readonly TimelineLayer[] = [\n {id: 'lit-lifecycle', label: 'Lit Lifecycle', color: 0x4d63ff},\n {id: 'lit-render', label: 'Lit Render', color: 0x325cff},\n {id: 'lit-render-verbose', label: 'Lit Render (verbose)', color: 0x99aeff},\n {id: 'mouse', label: 'Mouse', color: 0xa451af},\n {id: 'keyboard', label: 'Keyboard', color: 0x8151af},\n];\n\nexport const DEFAULT_LAYERS_STATE: TimelineLayersState = {\n recordingState: false,\n litLifecycleEnabled: true,\n litRenderEnabled: true,\n litRenderVerboseEnabled: false,\n mouseEventEnabled: false,\n keyboardEventEnabled: false,\n};\n\n/**\n * Snapshot of the plugin's resolved feature settings, surfaced in the panel's\n * Settings tab. The plugin produces this at config time (explicit options >\n * LIT_PLUGIN_* env > defaults) and serves it from the panel server. It's the\n * baseline the panel shows; some HMR settings can then be overridden live (see\n * {@link SettingsOverride}).\n */\nexport interface FeatureSettings {\n hmr: {\n enabled: boolean;\n reconnect: boolean;\n onIncompatible: 'reload' | 'warn';\n indicatorEnabled: boolean;\n indicatorCount: boolean;\n };\n sourceOverlay: {\n enabled: boolean;\n /** Hotkey letter combined with Ctrl+Shift to toggle the overlay. */\n key: string;\n editor: string;\n throttleMs: number;\n };\n timeline: boolean;\n /**\n * Which layer supplied each setting, keyed like {@link SettingsOverride}\n * (plus the read-only source-overlay rows). Lets the panel label a value\n * \"Zed (env)\" and name the baseline a panel override replaced. Optional so\n * older producers (and snapshots) without it still type-check.\n */\n sources?: SettingSources;\n}\n\n/**\n * Where a resolved setting came from, in precedence order after a panel\n * override: an explicit `litPlugin({...})` option, a `LIT_PLUGIN_*` env var,\n * or the built-in default.\n */\nexport type SettingSource = 'option' | 'env' | 'default';\n\n/** Per-setting {@link SettingSource}, as carried on {@link FeatureSettings}. */\nexport interface SettingSources {\n hmrReconnect?: SettingSource;\n hmrOnIncompatible?: SettingSource;\n hmrIndicatorVisible?: SettingSource;\n hmrIndicatorCount?: SettingSource;\n sourceOverlayEditor?: SettingSource;\n sourceOverlayKey?: SettingSource;\n sourceOverlayThrottleMs?: SettingSource;\n}\n\n/**\n * Runtime overrides the panel applies on top of the resolved env config, for\n * settings whose runtime is already injected (so they can change live). A\n * feature disabled at config time has no runtime, so it can't be enabled here\n * — only the behaviour of already-enabled features is overridable.\n *\n * Persisted under {@link SETTINGS_OVERRIDE_LS_KEY} (the panel and app share an\n * origin) so overrides survive reloads, and pushed live over\n * {@link SETTINGS_OVERRIDE_CHANNEL} via Vite HMR for immediate effect.\n */\nexport interface SettingsOverride {\n hmrReconnect?: boolean;\n hmrOnIncompatible?: 'reload' | 'warn';\n hmrIndicatorVisible?: boolean;\n hmrIndicatorCount?: boolean;\n /** Built-in editor key for the source overlay's open-in-editor target. */\n sourceOverlayEditor?: string;\n /**\n * Flash a short outline over every Lit element that completes an update.\n * Pure preference (no config-time baseline), so `undefined` reads as off.\n */\n flashUpdates?: boolean;\n /**\n * Colour the flash by how often the element updated in the last second,\n * calm to hot, instead of one flat colour. Only meaningful with\n * {@link SettingsOverride.flashUpdates}.\n */\n flashUpdatesRamp?: boolean;\n /**\n * Mirror the timeline into Chrome DevTools' Performance panel as custom\n * tracks (via `console.timeStamp`), independent of panel recording. Pure\n * preference (no config-time baseline), so `undefined` reads as off.\n */\n chromeTracks?: boolean;\n}\n\n/**\n * Built-in editors the source overlay can open files in. Keep in sync with\n * BUILTIN_EDITORS in lib/runtime/source-overlay/editors.ts.\n */\nexport const SOURCE_OVERLAY_EDITORS: ReadonlyArray<{\n value: string;\n label: string;\n}> = [\n {value: 'vscode', label: 'VS Code'},\n {value: 'cursor', label: 'Cursor'},\n {value: 'zed', label: 'Zed'},\n {value: 'idea', label: 'IntelliJ'},\n {value: 'windsurf', label: 'Windsurf'},\n];\n\n/** localStorage key holding the {@link SettingsOverride}. */\nexport const SETTINGS_OVERRIDE_LS_KEY = 'lit-devtools-overrides';\n\n/**\n * The resolved config value each overridden key was set against, recorded so\n * the Settings tab can notice when `.env` or plugin options moved on. Kept\n * beside the {@link SettingsOverride}, never inside it: the runtime applies and\n * receives the override as-is and has no use for these.\n */\nexport type OverrideBaselines = Partial<\n Record<\n | 'hmrReconnect'\n | 'hmrOnIncompatible'\n | 'hmrIndicatorVisible'\n | 'hmrIndicatorCount'\n | 'sourceOverlayEditor',\n unknown\n >\n>;\n\n/** localStorage key holding the {@link OverrideBaselines}. */\nexport const OVERRIDE_BASELINES_LS_KEY = 'lit-devtools-override-baselines';\n\n/** Vite HMR channel the server uses to push overrides to the app runtime. */\nexport const SETTINGS_OVERRIDE_CHANNEL = 'lit-devtools:settings-override';\n\n/**\n * Vite HMR channel the DevTools \"toggle source overlay\" command uses to tell\n * the app runtime to toggle the overlay (the command handler runs server-side).\n */\nexport const SOURCE_OVERLAY_TOGGLE_CHANNEL =\n 'lit-devtools:toggle-source-overlay';\n"]}
1
+ {"version":3,"file":"timeline.js","sourceRoot":"","sources":["../src/types/timeline.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkDH,MAAM,CAAC,MAAM,eAAe,GAA6B;IACvD,EAAC,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAC;IAC9D,EAAC,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAC;IACxD,EAAC,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,QAAQ,EAAC;IAC1E,EAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAC;IAC9C,EAAC,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAC;CACrD,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAwB;IACvD,cAAc,EAAE,KAAK;IACrB,mBAAmB,EAAE,IAAI;IACzB,gBAAgB,EAAE,IAAI;IACtB,uBAAuB,EAAE,KAAK;IAC9B,iBAAiB,EAAE,KAAK;IACxB,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AA2FF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAG9B;IACH,EAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAC;IACnC,EAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAC;IAClC,EAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAC;IAC5B,EAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAC;IAClC,EAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAC;CACvC,CAAC;AAEF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,wBAAwB,GAAG,wBAAwB,CAAC;AAoBjE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,yBAAyB,GAAG,iCAAiC,CAAC;AAE3E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,yBAAyB,GAAG,gCAAgC,CAAC;AAE1E;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GACxC,oCAAoC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nexport interface TimelineLayer {\n id: string;\n label: string;\n color: number; // 0xRRGGBB\n}\n\nexport interface TimelineEvent<TData = unknown> {\n /**\n * Stable identity, stamped on the Node side (`${epoch}-${seq}`) when the\n * event is received, so it survives the stream, `recent-events` and a\n * snapshot export. Absent on events still in the page runtime.\n */\n id?: string;\n layerId: string;\n /**\n * Milliseconds since recording started, stamped in the browser page\n * (`performance.now()` re-zeroed on each recording start; see\n * `runtime/timeline/clock.ts`). Not comparable to any Node-side clock.\n */\n time: number;\n data: TData;\n title?: string;\n subtitle?: string;\n /** Pairs a start event with its matching end event in the same update group. */\n groupId?: number | string;\n logType?: 'default' | 'warning' | 'error';\n meta?: {\n elementId?: number;\n tagName?: string;\n source?: {file: string; line: number};\n };\n}\n\nexport interface TimelineLayersState {\n recordingState: boolean;\n litLifecycleEnabled: boolean;\n litRenderEnabled: boolean;\n /**\n * Per-part `lit-debug` events (`template updating`, `set part`, `commit\n * *`, …) — one per binding on *every* render, so a ticking clock or\n * animation floods the layer. Off by default; the `lit-render` layer's\n * begin/end render pair already covers the common case.\n */\n litRenderVerboseEnabled: boolean;\n mouseEventEnabled: boolean;\n keyboardEventEnabled: boolean;\n}\n\nexport const TIMELINE_LAYERS: readonly TimelineLayer[] = [\n {id: 'lit-lifecycle', label: 'Lit Lifecycle', color: 0x4d63ff},\n {id: 'lit-render', label: 'Lit Render', color: 0x325cff},\n {id: 'lit-render-verbose', label: 'Lit Render (verbose)', color: 0x99aeff},\n {id: 'mouse', label: 'Mouse', color: 0xa451af},\n {id: 'keyboard', label: 'Keyboard', color: 0x8151af},\n];\n\nexport const DEFAULT_LAYERS_STATE: TimelineLayersState = {\n recordingState: false,\n litLifecycleEnabled: true,\n litRenderEnabled: true,\n litRenderVerboseEnabled: false,\n mouseEventEnabled: false,\n keyboardEventEnabled: false,\n};\n\n/**\n * Snapshot of the plugin's resolved feature settings, surfaced in the panel's\n * Settings tab. The plugin produces this at config time (explicit options >\n * LIT_PLUGIN_* env > defaults) and serves it from the panel server. It's the\n * baseline the panel shows; some HMR settings can then be overridden live (see\n * {@link SettingsOverride}).\n */\nexport interface FeatureSettings {\n hmr: {\n enabled: boolean;\n reconnect: boolean;\n onIncompatible: 'reload' | 'warn';\n childState: 'reset' | 'transfer' | 'reuse';\n indicatorEnabled: boolean;\n indicatorCount: boolean;\n };\n sourceOverlay: {\n enabled: boolean;\n /** Hotkey letter combined with Ctrl+Shift to toggle the overlay. */\n key: string;\n editor: string;\n throttleMs: number;\n };\n timeline: boolean;\n /**\n * Which layer supplied each setting, keyed like {@link SettingsOverride}\n * (plus the read-only source-overlay rows). Lets the panel label a value\n * \"Zed (env)\" and name the baseline a panel override replaced. Optional so\n * older producers (and snapshots) without it still type-check.\n */\n sources?: SettingSources;\n}\n\n/**\n * Where a resolved setting came from, in precedence order after a panel\n * override: an explicit `litPlugin({...})` option, a `LIT_PLUGIN_*` env var,\n * or the built-in default.\n */\nexport type SettingSource = 'option' | 'env' | 'default';\n\n/** Per-setting {@link SettingSource}, as carried on {@link FeatureSettings}. */\nexport interface SettingSources {\n hmrReconnect?: SettingSource;\n hmrOnIncompatible?: SettingSource;\n hmrChildState?: SettingSource;\n hmrIndicatorVisible?: SettingSource;\n hmrIndicatorCount?: SettingSource;\n sourceOverlayEditor?: SettingSource;\n sourceOverlayKey?: SettingSource;\n sourceOverlayThrottleMs?: SettingSource;\n}\n\n/**\n * Runtime overrides the panel applies on top of the resolved env config, for\n * settings whose runtime is already injected (so they can change live). A\n * feature disabled at config time has no runtime, so it can't be enabled here\n * — only the behaviour of already-enabled features is overridable.\n *\n * Persisted under {@link SETTINGS_OVERRIDE_LS_KEY} (the panel and app share an\n * origin) so overrides survive reloads, and pushed live over\n * {@link SETTINGS_OVERRIDE_CHANNEL} via Vite HMR for immediate effect.\n */\nexport interface SettingsOverride {\n hmrReconnect?: boolean;\n hmrOnIncompatible?: 'reload' | 'warn';\n hmrChildState?: 'reset' | 'transfer' | 'reuse';\n hmrIndicatorVisible?: boolean;\n hmrIndicatorCount?: boolean;\n /** Built-in editor key for the source overlay's open-in-editor target. */\n sourceOverlayEditor?: string;\n /**\n * Flash a short outline over every Lit element that completes an update.\n * Pure preference (no config-time baseline), so `undefined` reads as off.\n */\n flashUpdates?: boolean;\n /**\n * Colour the flash by how often the element updated in the last second,\n * calm to hot, instead of one flat colour. Only meaningful with\n * {@link SettingsOverride.flashUpdates}.\n */\n flashUpdatesRamp?: boolean;\n /**\n * Mirror the timeline into Chrome DevTools' Performance panel as custom\n * tracks (via `console.timeStamp`), independent of panel recording. Pure\n * preference (no config-time baseline), so `undefined` reads as off.\n */\n chromeTracks?: boolean;\n}\n\n/**\n * Built-in editors the source overlay can open files in. Keep in sync with\n * BUILTIN_EDITORS in lib/runtime/source-overlay/editors.ts.\n */\nexport const SOURCE_OVERLAY_EDITORS: ReadonlyArray<{\n value: string;\n label: string;\n}> = [\n {value: 'vscode', label: 'VS Code'},\n {value: 'cursor', label: 'Cursor'},\n {value: 'zed', label: 'Zed'},\n {value: 'idea', label: 'IntelliJ'},\n {value: 'windsurf', label: 'Windsurf'},\n];\n\n/** localStorage key holding the {@link SettingsOverride}. */\nexport const SETTINGS_OVERRIDE_LS_KEY = 'lit-devtools-overrides';\n\n/**\n * The resolved config value each overridden key was set against, recorded so\n * the Settings tab can notice when `.env` or plugin options moved on. Kept\n * beside the {@link SettingsOverride}, never inside it: the runtime applies and\n * receives the override as-is and has no use for these.\n */\nexport type OverrideBaselines = Partial<\n Record<\n | 'hmrReconnect'\n | 'hmrOnIncompatible'\n | 'hmrChildState'\n | 'hmrIndicatorVisible'\n | 'hmrIndicatorCount'\n | 'sourceOverlayEditor',\n unknown\n >\n>;\n\n/** localStorage key holding the {@link OverrideBaselines}. */\nexport const OVERRIDE_BASELINES_LS_KEY = 'lit-devtools-override-baselines';\n\n/** Vite HMR channel the server uses to push overrides to the app runtime. */\nexport const SETTINGS_OVERRIDE_CHANNEL = 'lit-devtools:settings-override';\n\n/**\n * Vite HMR channel the DevTools \"toggle source overlay\" command uses to tell\n * the app runtime to toggle the overlay (the command handler runs server-side).\n */\nexport const SOURCE_OVERLAY_TOGGLE_CHANNEL =\n 'lit-devtools:toggle-source-overlay';\n"]}