@oddsquad/vite-plugin-lit 0.4.0 → 0.6.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 (100) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +16 -5
  3. package/bin.mjs +16 -12
  4. package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-CdtPhBL-.js → browser-agent-rpc-BXhoSh1z-DXAVFObe.js} +2 -2
  5. package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-CdtPhBL-.js.map → browser-agent-rpc-BXhoSh1z-DXAVFObe.js.map} +1 -1
  6. package/dist/client/assets/{index-DVe6M4HV.js → index-DVr5EnyB.js} +1859 -751
  7. package/dist/client/assets/index-DVr5EnyB.js.map +1 -0
  8. package/dist/client/index.html +11 -1
  9. package/lib/devframe/definition.d.ts +7 -0
  10. package/lib/devframe/definition.d.ts.map +1 -1
  11. package/lib/devframe/definition.js +56 -11
  12. package/lib/devframe/definition.js.map +1 -1
  13. package/lib/devframe/launch-editor.d.ts +20 -0
  14. package/lib/devframe/launch-editor.d.ts.map +1 -0
  15. package/lib/devframe/launch-editor.js +40 -0
  16. package/lib/devframe/launch-editor.js.map +1 -0
  17. package/lib/devframe/protocol.d.ts +31 -4
  18. package/lib/devframe/protocol.d.ts.map +1 -1
  19. package/lib/devframe/protocol.js +21 -3
  20. package/lib/devframe/protocol.js.map +1 -1
  21. package/lib/devframe/rpc-source.d.ts +44 -0
  22. package/lib/devframe/rpc-source.d.ts.map +1 -0
  23. package/lib/devframe/rpc-source.js +150 -0
  24. package/lib/devframe/rpc-source.js.map +1 -0
  25. package/lib/devframe/source.d.ts +12 -0
  26. package/lib/devframe/source.d.ts.map +1 -1
  27. package/lib/devframe/source.js +12 -0
  28. package/lib/devframe/source.js.map +1 -1
  29. package/lib/devframe/vite.d.ts +2 -0
  30. package/lib/devframe/vite.d.ts.map +1 -1
  31. package/lib/devframe/vite.js +3 -9
  32. package/lib/devframe/vite.js.map +1 -1
  33. package/lib/options.d.ts +6 -1
  34. package/lib/options.d.ts.map +1 -1
  35. package/lib/options.js +65 -18
  36. package/lib/options.js.map +1 -1
  37. package/lib/override-baselines.d.ts +17 -0
  38. package/lib/override-baselines.d.ts.map +1 -0
  39. package/lib/override-baselines.js +25 -0
  40. package/lib/override-baselines.js.map +1 -0
  41. package/lib/plugin.d.ts.map +1 -1
  42. package/lib/plugin.js +8 -0
  43. package/lib/plugin.js.map +1 -1
  44. package/lib/plugins/open-in-editor.d.ts.map +1 -1
  45. package/lib/plugins/open-in-editor.js +6 -1
  46. package/lib/plugins/open-in-editor.js.map +1 -1
  47. package/lib/runtime/indicator.js.map +1 -1
  48. package/lib/runtime/inspector/install.js +4 -2
  49. package/lib/runtime/inspector/install.js.map +1 -1
  50. package/lib/runtime/inspector/serialize.d.ts.map +1 -1
  51. package/lib/runtime/inspector/serialize.js +20 -0
  52. package/lib/runtime/inspector/serialize.js.map +1 -1
  53. package/lib/runtime/overrides.d.ts +4 -10
  54. package/lib/runtime/overrides.d.ts.map +1 -1
  55. package/lib/runtime/overrides.js +5 -3
  56. package/lib/runtime/overrides.js.map +1 -1
  57. package/lib/runtime/page-channel.d.ts +52 -0
  58. package/lib/runtime/page-channel.d.ts.map +1 -0
  59. package/lib/runtime/page-channel.js +67 -0
  60. package/lib/runtime/page-channel.js.map +1 -0
  61. package/lib/runtime/patch.d.ts.map +1 -1
  62. package/lib/runtime/patch.js +2 -1
  63. package/lib/runtime/patch.js.map +1 -1
  64. package/lib/runtime/rpc-transport.d.ts +46 -0
  65. package/lib/runtime/rpc-transport.d.ts.map +1 -0
  66. package/lib/runtime/rpc-transport.js +82 -0
  67. package/lib/runtime/rpc-transport.js.map +1 -0
  68. package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -1
  69. package/lib/runtime/source-overlay/overlay-element.js +13 -3
  70. package/lib/runtime/source-overlay/overlay-element.js.map +1 -1
  71. package/lib/runtime/timeline/chrome-tracks.d.ts +22 -0
  72. package/lib/runtime/timeline/chrome-tracks.d.ts.map +1 -0
  73. package/lib/runtime/timeline/chrome-tracks.js +74 -0
  74. package/lib/runtime/timeline/chrome-tracks.js.map +1 -0
  75. package/lib/runtime/timeline/clock.d.ts +6 -0
  76. package/lib/runtime/timeline/clock.d.ts.map +1 -1
  77. package/lib/runtime/timeline/clock.js +6 -0
  78. package/lib/runtime/timeline/clock.js.map +1 -1
  79. package/lib/runtime/timeline/install.js +42 -13
  80. package/lib/runtime/timeline/install.js.map +1 -1
  81. package/lib/runtime/timeline/public-api.d.ts.map +1 -1
  82. package/lib/runtime/timeline/public-api.js +11 -3
  83. package/lib/runtime/timeline/public-api.js.map +1 -1
  84. package/lib/runtime/timeline/transport.d.ts +6 -9
  85. package/lib/runtime/timeline/transport.d.ts.map +1 -1
  86. package/lib/runtime/timeline/transport.js.map +1 -1
  87. package/lib/timeline/filter.d.ts +38 -0
  88. package/lib/timeline/filter.d.ts.map +1 -0
  89. package/lib/timeline/filter.js +44 -0
  90. package/lib/timeline/filter.js.map +1 -0
  91. package/lib/timeline/tracks.d.ts +113 -0
  92. package/lib/timeline/tracks.d.ts.map +1 -0
  93. package/lib/timeline/tracks.js +168 -0
  94. package/lib/timeline/tracks.js.map +1 -0
  95. package/package.json +6 -1
  96. package/types/timeline.d.ts +44 -0
  97. package/types/timeline.d.ts.map +1 -1
  98. package/types/timeline.js +2 -0
  99. package/types/timeline.js.map +1 -1
  100. package/dist/client/assets/index-DVe6M4HV.js.map +0 -1
package/lib/options.js CHANGED
@@ -3,6 +3,7 @@
3
3
  * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
+ import {BUILTIN_EDITORS} from './runtime/source-overlay/editors.js';
6
7
  const CSS_SHEET_BUILD_MODES = ['auto', 'url', 'inline', 'inline-raw'];
7
8
  /** Env var prefix consumed at config time. */
8
9
  export const ENV_PREFIX = 'LIT_PLUGIN';
@@ -34,6 +35,19 @@ const envEnum = (v, allowed, source) => {
34
35
  );
35
36
  return undefined;
36
37
  };
38
+ /** Keys a `LIT_PLUGIN_SOURCE_OVERLAY_EDITOR` value may name. */
39
+ const EDITOR_KEYS = Object.keys(BUILTIN_EDITORS);
40
+ /** Which layer supplied a value: the first of option, env that is defined. */
41
+ const sourceOf = (option, env) =>
42
+ option !== undefined ? 'option' : env !== undefined ? 'env' : 'default';
43
+ /**
44
+ * Take the first defined of an explicit option and an env value, else the
45
+ * default, and record which layer won.
46
+ */
47
+ const pick = (option, env, fallback) => ({
48
+ value: option ?? env ?? fallback,
49
+ source: sourceOf(option, env),
50
+ });
37
51
  /**
38
52
  * Merge explicit options over env vars over defaults (in that precedence) into
39
53
  * the flat shape the plugin hooks consume.
@@ -45,26 +59,41 @@ export const resolveOptions = (options, env) => {
45
59
  (typeof hmr === 'boolean' ? hmr : hmrObj?.enabled) ??
46
60
  envBool(env[`${ENV_PREFIX}_HMR`]) ??
47
61
  true;
48
- const reconnect =
49
- hmrObj?.reconnect ?? envBool(env[`${ENV_PREFIX}_HMR_RECONNECT`]) ?? false;
50
- const onIncompatible =
51
- hmrObj?.onIncompatible ??
62
+ const reconnect = pick(
63
+ hmrObj?.reconnect,
64
+ envBool(env[`${ENV_PREFIX}_HMR_RECONNECT`]),
65
+ false
66
+ );
67
+ const onIncompatible = pick(
68
+ hmrObj?.onIncompatible,
52
69
  envEnum(
53
70
  env[`${ENV_PREFIX}_HMR_ON_INCOMPATIBLE`],
54
71
  ON_INCOMPATIBLE_MODES,
55
72
  `${ENV_PREFIX}_HMR_ON_INCOMPATIBLE`
56
- ) ??
57
- 'reload';
73
+ ),
74
+ 'reload'
75
+ );
58
76
  const ind = hmrObj?.indicator;
59
77
  const indObj = typeof ind === 'object' ? ind : undefined;
60
- const indEnabled =
61
- (typeof ind === 'boolean' ? ind : indObj?.enabled) ??
62
- envBool(env[`${ENV_PREFIX}_HMR_INDICATOR`]) ??
63
- true;
64
- const indCount =
65
- indObj?.count ?? envBool(env[`${ENV_PREFIX}_HMR_INDICATOR_COUNT`]) ?? false;
78
+ const indEnabled = pick(
79
+ typeof ind === 'boolean' ? ind : indObj?.enabled,
80
+ envBool(env[`${ENV_PREFIX}_HMR_INDICATOR`]),
81
+ true
82
+ );
83
+ const indCount = pick(
84
+ indObj?.count,
85
+ envBool(env[`${ENV_PREFIX}_HMR_INDICATOR_COUNT`]),
86
+ false
87
+ );
66
88
  // The indicator is meaningless without HMR, so it follows the master toggle.
67
- const indicator = hmrEnabled && indEnabled ? {count: indCount} : false;
89
+ const indicator =
90
+ hmrEnabled && indEnabled.value ? {count: indCount.value} : false;
91
+ const sources = {
92
+ hmrReconnect: reconnect.source,
93
+ hmrOnIncompatible: onIncompatible.source,
94
+ hmrIndicatorVisible: indEnabled.source,
95
+ hmrIndicatorCount: indCount.source,
96
+ };
68
97
  const so = options.sourceOverlay;
69
98
  const soExplicit =
70
99
  typeof so === 'boolean' ? so : so === undefined ? undefined : true;
@@ -73,9 +102,25 @@ export const resolveOptions = (options, env) => {
73
102
  let sourceOverlay = false;
74
103
  if (soEnabled) {
75
104
  const base = typeof so === 'object' ? {...so} : {};
76
- base.key ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_KEY`] || undefined;
77
- base.editor ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_EDITOR`] || undefined;
78
- base.throttleMs ??= envNum(env[`${ENV_PREFIX}_SOURCE_OVERLAY_THROTTLE_MS`]);
105
+ // Defaults for these are applied later (toFeatureSettings / the runtime),
106
+ // so only option-vs-env is decided here; neither set means 'default'.
107
+ const envKey = env[`${ENV_PREFIX}_SOURCE_OVERLAY_KEY`] || undefined;
108
+ const envThrottle = envNum(env[`${ENV_PREFIX}_SOURCE_OVERLAY_THROTTLE_MS`]);
109
+ // Only read (and warn about) the env editor when no option supplies one.
110
+ const envEditor =
111
+ base.editor === undefined
112
+ ? envEnum(
113
+ env[`${ENV_PREFIX}_SOURCE_OVERLAY_EDITOR`],
114
+ EDITOR_KEYS,
115
+ `${ENV_PREFIX}_SOURCE_OVERLAY_EDITOR`
116
+ )
117
+ : undefined;
118
+ sources.sourceOverlayKey = sourceOf(base.key, envKey);
119
+ sources.sourceOverlayEditor = sourceOf(base.editor, envEditor);
120
+ sources.sourceOverlayThrottleMs = sourceOf(base.throttleMs, envThrottle);
121
+ base.key ??= envKey;
122
+ base.editor ??= envEditor;
123
+ base.throttleMs ??= envThrottle;
79
124
  sourceOverlay = base;
80
125
  }
81
126
  const timeline =
@@ -90,12 +135,13 @@ export const resolveOptions = (options, env) => {
90
135
  'auto';
91
136
  return {
92
137
  hmrEnabled,
93
- reconnect,
94
- onIncompatible,
138
+ reconnect: reconnect.value,
139
+ onIncompatible: onIncompatible.value,
95
140
  indicator,
96
141
  sourceOverlay,
97
142
  timeline,
98
143
  cssSheetBuild,
144
+ sources,
99
145
  };
100
146
  };
101
147
  /**
@@ -123,6 +169,7 @@ export const toFeatureSettings = (r) => {
123
169
  throttleMs: (so === false ? undefined : so.throttleMs) ?? 50,
124
170
  },
125
171
  timeline: r.timeline,
172
+ sources: {...r.sources},
126
173
  };
127
174
  };
128
175
  //# sourceMappingURL=options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/lib/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgEH,MAAM,qBAAqB,GAA6B;IACtD,MAAM;IACN,KAAK;IACL,QAAQ;IACR,YAAY;CACb,CAAC;AA8DF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AAEvC,MAAM,qBAAqB,GAAmC;IAC5D,QAAQ;IACR,MAAM;CACP,CAAC;AAEF,2EAA2E;AAC3E,MAAM,OAAO,GAAG,CAAC,CAAqB,EAAuB,EAAE,CAC7D,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,GAAG;IACvB,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,GAAG;QAC1B,CAAC,CAAC,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C,MAAM,CAAC;IACpD,OAAO;QACL,GAAG,EAAE;YACH,OAAO,EAAE,CAAC,CAAC,UAAU;YACrB,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,cAAc,EAAE,CAAC,CAAC,cAAc;YAChC,gBAAgB,EAAE,CAAC,CAAC,SAAS,KAAK,KAAK;YACvC,cAAc,EAAE,CAAC,CAAC,SAAS,KAAK,KAAK,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK;SAC3D;QACD,aAAa,EAAE;YACb,OAAO,EAAE,EAAE,KAAK,KAAK;YACrB,GAAG,EAAE,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG;YAC/C,MAAM,EACJ,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;YACpE,UAAU,EAAE,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE;SAC7D;QACD,QAAQ,EAAE,CAAC,CAAC,QAAQ;KACrB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type {SourceOverlayOptions} from './types.js';\nimport type {FeatureSettings} from '../types/timeline.js';\n\n/**\n * On-page HMR feedback: a small pulsing indicator in the corner of the host\n * page that briefly animates on each HMR update, for at-a-glance feedback\n * without watching the console.\n */\nexport interface HmrIndicatorOptions {\n /** Inject the indicator element. Defaults to `true` (when HMR is enabled). */\n enabled?: boolean;\n\n /**\n * Show a cumulative update count next to the dot (idle opacity 0.5 instead\n * of fully transparent). Defaults to `false`.\n */\n count?: boolean;\n}\n\n/**\n * HMR for Lit component classes and its on-page feedback.\n */\nexport interface HmrOptions {\n /**\n * Enable in-place HMR for Lit component classes. When `false`, the plugin\n * skips all HMR transforms and runtime injection. Defaults to `true`.\n */\n enabled?: boolean;\n\n /**\n * Cycle `disconnectedCallback()`/`connectedCallback()` on live instances\n * after a hot patch. Interning makes this mostly unnecessary, so it's\n * opt-in. 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 * The on-page update indicator. `true` enables it without a count; an\n * object configures it. Forced off when HMR itself is disabled. Defaults\n * to enabled (without a count).\n */\n indicator?: boolean | HmrIndicatorOptions;\n}\n\n/**\n * What a `?css-sheet` import compiles to under `vite build`.\n *\n * - `'url'`: fetch-backed sheet over the emitted `.css` asset.\n * - `'inline'`: css text embedded in the JS chunk, processed by the css\n * pipeline (`?inline`).\n * - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline\n * (`?raw`).\n * - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise.\n */\nexport type CssSheetBuild = 'auto' | 'url' | 'inline' | 'inline-raw';\n\nconst CSS_SHEET_BUILD_MODES: readonly CssSheetBuild[] = [\n 'auto',\n 'url',\n 'inline',\n 'inline-raw',\n];\n\n/**\n * Options for the Lit Vite plugin.\n *\n * Every option also resolves from environment variables (and `.env` files)\n * with the `LIT_PLUGIN` prefix — e.g. `LIT_PLUGIN_HMR_INDICATOR=true`. Options\n * passed here take precedence over env vars, which take precedence over the\n * built-in defaults.\n */\nexport interface LitPluginOptions {\n /**\n * HMR for Lit components and its on-page feedback. `true`/`false` toggles\n * the whole feature (patching and indicator); an object configures it.\n * Defaults to enabled.\n */\n hmr?: boolean | HmrOptions;\n\n /**\n * Dev-only click-to-open-in-IDE inspector for Lit custom elements.\n * Toggle with Ctrl+Shift+S (configurable via `key`). Defaults to `false`.\n */\n sourceOverlay?: boolean | SourceOverlayOptions;\n\n /**\n * Vite DevTools Timeline panel — a Vue DevTools–style layered event stream\n * for Lit lifecycle, render, mouse, and keyboard events.\n *\n * Requires `@vitejs/devtools` in the Vite config and the `@vitejs/devtools`\n * Vite plugin (`DevTools()`) to be active. Defaults to `false` while\n * experimental.\n *\n * `true` enables all built-in layers with defaults.\n */\n timeline?: boolean;\n\n /**\n * What a `?css-sheet` import compiles to under `vite build`.\n * - `'url'`: fetch-backed sheet over the emitted `.css` asset\n * - `'inline'`: css text embedded in the JS chunk, processed by the css\n * pipeline (`?inline`)\n * - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline\n * (`?raw`)\n * - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise\n *\n * Dev is always the fetch-backed HMR form regardless of this setting.\n * Defaults to `'auto'`.\n */\n cssSheetBuild?: CssSheetBuild;\n}\n\n/** Plugin options after merging explicit options, env vars, and defaults. */\nexport interface ResolvedOptions {\n hmrEnabled: boolean;\n reconnect: boolean;\n onIncompatible: 'reload' | 'warn';\n indicator: false | {count: boolean};\n sourceOverlay: false | SourceOverlayOptions;\n timeline: boolean;\n cssSheetBuild: CssSheetBuild;\n}\n\n/** Env var prefix consumed at config time. */\nexport const ENV_PREFIX = 'LIT_PLUGIN';\n\nconst ON_INCOMPATIBLE_MODES: readonly ('reload' | 'warn')[] = [\n 'reload',\n 'warn',\n];\n\n/** Parse a boolean-ish env string; `undefined` when unset/unrecognized. */\nconst envBool = (v: string | undefined): boolean | undefined =>\n v === 'true' || v === '1'\n ? true\n : v === 'false' || v === '0'\n ? false\n : undefined;\n\n/** Parse a numeric env string; `undefined` when unset/non-numeric. */\nconst envNum = (v: string | undefined): number | undefined => {\n if (v === undefined || v === '') return undefined;\n const n = Number(v);\n return Number.isNaN(n) ? undefined : n;\n};\n\n/**\n * Parse a string against a closed set of values; `undefined` (with a warning)\n * when set to something outside it, so a typo falls back to the default\n * instead of silently disabling a feature.\n */\nconst envEnum = <T extends string>(\n v: string | undefined,\n allowed: readonly T[],\n source: string\n): T | undefined => {\n if (v === undefined || v === '') return undefined;\n if ((allowed as readonly string[]).includes(v)) return v as T;\n console.warn(\n `[lit-plugin] ignoring ${source}=${JSON.stringify(v)}; expected one of ` +\n allowed.map((a) => JSON.stringify(a)).join(', ')\n );\n return undefined;\n};\n\n/**\n * Merge explicit options over env vars over defaults (in that precedence) into\n * the flat shape the plugin hooks consume.\n */\nexport const resolveOptions = (\n options: LitPluginOptions,\n env: Record<string, string>\n): ResolvedOptions => {\n const hmr = options.hmr;\n const hmrObj = typeof hmr === 'object' ? hmr : undefined;\n const hmrEnabled =\n (typeof hmr === 'boolean' ? hmr : hmrObj?.enabled) ??\n envBool(env[`${ENV_PREFIX}_HMR`]) ??\n true;\n const reconnect =\n hmrObj?.reconnect ?? envBool(env[`${ENV_PREFIX}_HMR_RECONNECT`]) ?? false;\n const onIncompatible =\n hmrObj?.onIncompatible ??\n envEnum(\n env[`${ENV_PREFIX}_HMR_ON_INCOMPATIBLE`],\n ON_INCOMPATIBLE_MODES,\n `${ENV_PREFIX}_HMR_ON_INCOMPATIBLE`\n ) ??\n 'reload';\n\n const ind = hmrObj?.indicator;\n const indObj = typeof ind === 'object' ? ind : undefined;\n const indEnabled =\n (typeof ind === 'boolean' ? ind : indObj?.enabled) ??\n envBool(env[`${ENV_PREFIX}_HMR_INDICATOR`]) ??\n true;\n const indCount =\n indObj?.count ?? envBool(env[`${ENV_PREFIX}_HMR_INDICATOR_COUNT`]) ?? false;\n // The indicator is meaningless without HMR, so it follows the master toggle.\n const indicator = hmrEnabled && indEnabled ? {count: indCount} : false;\n\n const so = options.sourceOverlay;\n const soExplicit =\n typeof so === 'boolean' ? so : so === undefined ? undefined : true;\n const soEnabled =\n soExplicit ?? envBool(env[`${ENV_PREFIX}_SOURCE_OVERLAY`]) ?? false;\n let sourceOverlay: false | SourceOverlayOptions = false;\n if (soEnabled) {\n const base: SourceOverlayOptions = typeof so === 'object' ? {...so} : {};\n base.key ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_KEY`] || undefined;\n base.editor ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_EDITOR`] || undefined;\n base.throttleMs ??= envNum(env[`${ENV_PREFIX}_SOURCE_OVERLAY_THROTTLE_MS`]);\n sourceOverlay = base;\n }\n\n const timeline =\n options.timeline ?? envBool(env[`${ENV_PREFIX}_TIMELINE`]) ?? false;\n\n const cssSheetBuild =\n envEnum(options.cssSheetBuild, CSS_SHEET_BUILD_MODES, 'cssSheetBuild') ??\n envEnum(\n env[`${ENV_PREFIX}_CSS_SHEET_BUILD`],\n CSS_SHEET_BUILD_MODES,\n `${ENV_PREFIX}_CSS_SHEET_BUILD`\n ) ??\n 'auto';\n\n return {\n hmrEnabled,\n reconnect,\n onIncompatible,\n indicator,\n sourceOverlay,\n timeline,\n cssSheetBuild,\n };\n};\n\n/**\n * Flattens resolved options into the JSON-serializable shape the panel's\n * Settings tab consumes (callback options like `exclude`/`onSelect` dropped;\n * a custom editor object reported as `\"custom\"`). Default key/editor/throttle\n * are applied here so the panel shows the effective values the runtime uses.\n */\nexport const toFeatureSettings = (r: ResolvedOptions): FeatureSettings => {\n const so = r.sourceOverlay;\n const editor = so === false ? undefined : so.editor;\n return {\n hmr: {\n enabled: r.hmrEnabled,\n reconnect: r.reconnect,\n onIncompatible: r.onIncompatible,\n indicatorEnabled: r.indicator !== false,\n indicatorCount: r.indicator !== false && r.indicator.count,\n },\n sourceOverlay: {\n enabled: so !== false,\n key: (so === false ? undefined : so.key) ?? 's',\n editor:\n typeof editor === 'string' ? editor : editor ? 'custom' : 'vscode',\n throttleMs: (so === false ? undefined : so.throttleMs) ?? 50,\n },\n timeline: r.timeline,\n };\n};\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/lib/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AA6DpE,MAAM,qBAAqB,GAA6B;IACtD,MAAM;IACN,KAAK;IACL,QAAQ;IACR,YAAY;CACb,CAAC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SAC7D;QACD,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,OAAO,EAAE,EAAC,GAAG,CAAC,CAAC,OAAO,EAAC;KACxB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type {SourceOverlayOptions} from './types.js';\nimport type {\n FeatureSettings,\n SettingSource,\n SettingSources,\n} from '../types/timeline.js';\nimport {BUILTIN_EDITORS} from './runtime/source-overlay/editors.js';\n\n/**\n * On-page HMR feedback: a small pulsing indicator in the corner of the host\n * page that briefly animates on each HMR update, for at-a-glance feedback\n * without watching the console.\n */\nexport interface HmrIndicatorOptions {\n /** Inject the indicator element. Defaults to `true` (when HMR is enabled). */\n enabled?: boolean;\n\n /**\n * Show a cumulative update count next to the dot (idle opacity 0.5 instead\n * of fully transparent). Defaults to `false`.\n */\n count?: boolean;\n}\n\n/**\n * HMR for Lit component classes and its on-page feedback.\n */\nexport interface HmrOptions {\n /**\n * Enable in-place HMR for Lit component classes. When `false`, the plugin\n * skips all HMR transforms and runtime injection. Defaults to `true`.\n */\n enabled?: boolean;\n\n /**\n * Cycle `disconnectedCallback()`/`connectedCallback()` on live instances\n * after a hot patch. Interning makes this mostly unnecessary, so it's\n * opt-in. 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 * The on-page update indicator. `true` enables it without a count; an\n * object configures it. Forced off when HMR itself is disabled. Defaults\n * to enabled (without a count).\n */\n indicator?: boolean | HmrIndicatorOptions;\n}\n\n/**\n * What a `?css-sheet` import compiles to under `vite build`.\n *\n * - `'url'`: fetch-backed sheet over the emitted `.css` asset.\n * - `'inline'`: css text embedded in the JS chunk, processed by the css\n * pipeline (`?inline`).\n * - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline\n * (`?raw`).\n * - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise.\n */\nexport type CssSheetBuild = 'auto' | 'url' | 'inline' | 'inline-raw';\n\nconst CSS_SHEET_BUILD_MODES: readonly CssSheetBuild[] = [\n 'auto',\n 'url',\n 'inline',\n 'inline-raw',\n];\n\n/**\n * Options for the Lit Vite plugin.\n *\n * Every option also resolves from environment variables (and `.env` files)\n * with the `LIT_PLUGIN` prefix — e.g. `LIT_PLUGIN_HMR_INDICATOR=true`. Options\n * passed here take precedence over env vars, which take precedence over the\n * built-in defaults.\n */\nexport interface LitPluginOptions {\n /**\n * HMR for Lit components and its on-page feedback. `true`/`false` toggles\n * the whole feature (patching and indicator); an object configures it.\n * Defaults to enabled.\n */\n hmr?: boolean | HmrOptions;\n\n /**\n * Dev-only click-to-open-in-IDE inspector for Lit custom elements.\n * Toggle with Ctrl+Shift+S (configurable via `key`). Defaults to `false`.\n */\n sourceOverlay?: boolean | SourceOverlayOptions;\n\n /**\n * Vite DevTools Timeline panel — a Vue DevTools–style layered event stream\n * for Lit lifecycle, render, mouse, and keyboard events.\n *\n * Requires `@vitejs/devtools` in the Vite config and the `@vitejs/devtools`\n * Vite plugin (`DevTools()`) to be active. Defaults to `false` while\n * experimental.\n *\n * `true` enables all built-in layers with defaults.\n */\n timeline?: boolean;\n\n /**\n * What a `?css-sheet` import compiles to under `vite build`.\n * - `'url'`: fetch-backed sheet over the emitted `.css` asset\n * - `'inline'`: css text embedded in the JS chunk, processed by the css\n * pipeline (`?inline`)\n * - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline\n * (`?raw`)\n * - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise\n *\n * Dev is always the fetch-backed HMR form regardless of this setting.\n * Defaults to `'auto'`.\n */\n cssSheetBuild?: CssSheetBuild;\n}\n\n/** Plugin options after merging explicit options, env vars, and defaults. */\nexport interface ResolvedOptions {\n hmrEnabled: boolean;\n reconnect: boolean;\n onIncompatible: 'reload' | 'warn';\n indicator: false | {count: boolean};\n sourceOverlay: false | SourceOverlayOptions;\n timeline: boolean;\n cssSheetBuild: CssSheetBuild;\n /**\n * Which layer each panel-visible setting came from. Source-overlay keys are\n * present only when the overlay is enabled.\n */\n sources: SettingSources;\n}\n\n/** Env var prefix consumed at config time. */\nexport const ENV_PREFIX = 'LIT_PLUGIN';\n\nconst ON_INCOMPATIBLE_MODES: readonly ('reload' | 'warn')[] = [\n 'reload',\n 'warn',\n];\n\n/** Parse a boolean-ish env string; `undefined` when unset/unrecognized. */\nconst envBool = (v: string | undefined): boolean | undefined =>\n v === 'true' || v === '1'\n ? true\n : v === 'false' || v === '0'\n ? false\n : undefined;\n\n/** Parse a numeric env string; `undefined` when unset/non-numeric. */\nconst envNum = (v: string | undefined): number | undefined => {\n if (v === undefined || v === '') return undefined;\n const n = Number(v);\n return Number.isNaN(n) ? undefined : n;\n};\n\n/**\n * Parse a string against a closed set of values; `undefined` (with a warning)\n * when set to something outside it, so a typo falls back to the default\n * instead of silently disabling a feature.\n */\nconst envEnum = <T extends string>(\n v: string | undefined,\n allowed: readonly T[],\n source: string\n): T | undefined => {\n if (v === undefined || v === '') return undefined;\n if ((allowed as readonly string[]).includes(v)) return v as T;\n console.warn(\n `[lit-plugin] ignoring ${source}=${JSON.stringify(v)}; expected one of ` +\n allowed.map((a) => JSON.stringify(a)).join(', ')\n );\n return undefined;\n};\n\n/** Keys a `LIT_PLUGIN_SOURCE_OVERLAY_EDITOR` value may name. */\nconst EDITOR_KEYS: readonly string[] = Object.keys(BUILTIN_EDITORS);\n\n/** Which layer supplied a value: the first of option, env that is defined. */\nconst sourceOf = (option: unknown, env: unknown): SettingSource =>\n option !== undefined ? 'option' : env !== undefined ? 'env' : 'default';\n\n/**\n * Take the first defined of an explicit option and an env value, else the\n * default, and record which layer won.\n */\nconst pick = <T>(\n option: T | undefined,\n env: T | undefined,\n fallback: T\n): {value: T; source: SettingSource} => ({\n value: option ?? env ?? fallback,\n source: sourceOf(option, env),\n});\n\n/**\n * Merge explicit options over env vars over defaults (in that precedence) into\n * the flat shape the plugin hooks consume.\n */\nexport const resolveOptions = (\n options: LitPluginOptions,\n env: Record<string, string>\n): ResolvedOptions => {\n const hmr = options.hmr;\n const hmrObj = typeof hmr === 'object' ? hmr : undefined;\n const hmrEnabled =\n (typeof hmr === 'boolean' ? hmr : hmrObj?.enabled) ??\n envBool(env[`${ENV_PREFIX}_HMR`]) ??\n true;\n const reconnect = pick(\n hmrObj?.reconnect,\n envBool(env[`${ENV_PREFIX}_HMR_RECONNECT`]),\n false\n );\n const onIncompatible = pick<'reload' | 'warn'>(\n hmrObj?.onIncompatible,\n envEnum(\n env[`${ENV_PREFIX}_HMR_ON_INCOMPATIBLE`],\n ON_INCOMPATIBLE_MODES,\n `${ENV_PREFIX}_HMR_ON_INCOMPATIBLE`\n ),\n 'reload'\n );\n\n const ind = hmrObj?.indicator;\n const indObj = typeof ind === 'object' ? ind : undefined;\n const indEnabled = pick(\n typeof ind === 'boolean' ? ind : indObj?.enabled,\n envBool(env[`${ENV_PREFIX}_HMR_INDICATOR`]),\n true\n );\n const indCount = pick(\n indObj?.count,\n envBool(env[`${ENV_PREFIX}_HMR_INDICATOR_COUNT`]),\n false\n );\n // The indicator is meaningless without HMR, so it follows the master toggle.\n const indicator =\n hmrEnabled && indEnabled.value ? {count: indCount.value} : false;\n\n const sources: SettingSources = {\n hmrReconnect: reconnect.source,\n hmrOnIncompatible: onIncompatible.source,\n hmrIndicatorVisible: indEnabled.source,\n hmrIndicatorCount: indCount.source,\n };\n\n const so = options.sourceOverlay;\n const soExplicit =\n typeof so === 'boolean' ? so : so === undefined ? undefined : true;\n const soEnabled =\n soExplicit ?? envBool(env[`${ENV_PREFIX}_SOURCE_OVERLAY`]) ?? false;\n let sourceOverlay: false | SourceOverlayOptions = false;\n if (soEnabled) {\n const base: SourceOverlayOptions = typeof so === 'object' ? {...so} : {};\n // Defaults for these are applied later (toFeatureSettings / the runtime),\n // so only option-vs-env is decided here; neither set means 'default'.\n const envKey = env[`${ENV_PREFIX}_SOURCE_OVERLAY_KEY`] || undefined;\n const envThrottle = envNum(env[`${ENV_PREFIX}_SOURCE_OVERLAY_THROTTLE_MS`]);\n // Only read (and warn about) the env editor when no option supplies one.\n const envEditor =\n base.editor === undefined\n ? envEnum(\n env[`${ENV_PREFIX}_SOURCE_OVERLAY_EDITOR`],\n EDITOR_KEYS,\n `${ENV_PREFIX}_SOURCE_OVERLAY_EDITOR`\n )\n : undefined;\n sources.sourceOverlayKey = sourceOf(base.key, envKey);\n sources.sourceOverlayEditor = sourceOf(base.editor, envEditor);\n sources.sourceOverlayThrottleMs = sourceOf(base.throttleMs, envThrottle);\n base.key ??= envKey;\n base.editor ??= envEditor;\n base.throttleMs ??= envThrottle;\n sourceOverlay = base;\n }\n\n const timeline =\n options.timeline ?? envBool(env[`${ENV_PREFIX}_TIMELINE`]) ?? false;\n\n const cssSheetBuild =\n envEnum(options.cssSheetBuild, CSS_SHEET_BUILD_MODES, 'cssSheetBuild') ??\n envEnum(\n env[`${ENV_PREFIX}_CSS_SHEET_BUILD`],\n CSS_SHEET_BUILD_MODES,\n `${ENV_PREFIX}_CSS_SHEET_BUILD`\n ) ??\n 'auto';\n\n return {\n hmrEnabled,\n reconnect: reconnect.value,\n onIncompatible: onIncompatible.value,\n indicator,\n sourceOverlay,\n timeline,\n cssSheetBuild,\n sources,\n };\n};\n\n/**\n * Flattens resolved options into the JSON-serializable shape the panel's\n * Settings tab consumes (callback options like `exclude`/`onSelect` dropped;\n * a custom editor object reported as `\"custom\"`). Default key/editor/throttle\n * are applied here so the panel shows the effective values the runtime uses.\n */\nexport const toFeatureSettings = (r: ResolvedOptions): FeatureSettings => {\n const so = r.sourceOverlay;\n const editor = so === false ? undefined : so.editor;\n return {\n hmr: {\n enabled: r.hmrEnabled,\n reconnect: r.reconnect,\n onIncompatible: r.onIncompatible,\n indicatorEnabled: r.indicator !== false,\n indicatorCount: r.indicator !== false && r.indicator.count,\n },\n sourceOverlay: {\n enabled: so !== false,\n key: (so === false ? undefined : so.key) ?? 's',\n editor:\n typeof editor === 'string' ? editor : editor ? 'custom' : 'vscode',\n throttleMs: (so === false ? undefined : so.throttleMs) ?? 50,\n },\n timeline: r.timeline,\n sources: {...r.sources},\n };\n};\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import type { OverrideBaselines } from '../types/timeline.js';
7
+ /**
8
+ * Whether the config value an override was made against has since changed.
9
+ *
10
+ * `recorded` is `undefined` for a legacy override that predates baseline
11
+ * tracking, which never counts as a change (no false positives). Values are
12
+ * compared structurally. The source-overlay editor reports `'custom'` for an
13
+ * `EditorConfig` object, which can't be compared meaningfully, so any side
14
+ * being `'custom'` skips the check.
15
+ */
16
+ export declare const baselineChanged: (key: keyof OverrideBaselines, recorded: unknown, current: unknown) => boolean;
17
+ //# sourceMappingURL=override-baselines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"override-baselines.d.ts","sourceRoot":"","sources":["../src/lib/override-baselines.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAE5D;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,QACrB,MAAM,iBAAiB,YAClB,OAAO,WACR,OAAO,KACf,OASF,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * Whether the config value an override was made against has since changed.
8
+ *
9
+ * `recorded` is `undefined` for a legacy override that predates baseline
10
+ * tracking, which never counts as a change (no false positives). Values are
11
+ * compared structurally. The source-overlay editor reports `'custom'` for an
12
+ * `EditorConfig` object, which can't be compared meaningfully, so any side
13
+ * being `'custom'` skips the check.
14
+ */
15
+ export const baselineChanged = (key, recorded, current) => {
16
+ if (recorded === undefined || current === undefined) return false;
17
+ if (
18
+ key === 'sourceOverlayEditor' &&
19
+ (recorded === 'custom' || current === 'custom')
20
+ ) {
21
+ return false;
22
+ }
23
+ return JSON.stringify(recorded) !== JSON.stringify(current);
24
+ };
25
+ //# sourceMappingURL=override-baselines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"override-baselines.js","sourceRoot":"","sources":["../src/lib/override-baselines.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,GAA4B,EAC5B,QAAiB,EACjB,OAAgB,EACP,EAAE;IACX,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAClE,IACE,GAAG,KAAK,qBAAqB;QAC7B,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,KAAK,QAAQ,CAAC,EAC/C,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC9D,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type {OverrideBaselines} from '../types/timeline.js';\n\n/**\n * Whether the config value an override was made against has since changed.\n *\n * `recorded` is `undefined` for a legacy override that predates baseline\n * tracking, which never counts as a change (no false positives). Values are\n * compared structurally. The source-overlay editor reports `'custom'` for an\n * `EditorConfig` object, which can't be compared meaningfully, so any side\n * being `'custom'` skips the check.\n */\nexport const baselineChanged = (\n key: keyof OverrideBaselines,\n recorded: unknown,\n current: unknown\n): boolean => {\n if (recorded === undefined || current === undefined) return false;\n if (\n key === 'sourceOverlayEditor' &&\n (recorded === 'custom' || current === 'custom')\n ) {\n return false;\n }\n return JSON.stringify(recorded) !== JSON.stringify(current);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/lib/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAU,KAAK,MAAM,EAAC,MAAM,MAAM,CAAC;AAO1C,OAAO,EAEL,KAAK,gBAAgB,EAItB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAC,4BAA4B,EAAC,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAC;AACjE,YAAY,EACV,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,SAAS,aAAa,gBAAgB,KAAQ,MAAM,EA+QhE,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/lib/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAU,KAAK,MAAM,EAAC,MAAM,MAAM,CAAC;AAO1C,OAAO,EAEL,KAAK,gBAAgB,EAItB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAC,4BAA4B,EAAC,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAC;AACjE,YAAY,EACV,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,SAAS,aAAa,gBAAgB,KAAQ,MAAM,EAuRhE,CAAC"}
package/lib/plugin.js CHANGED
@@ -285,6 +285,14 @@ export const litPlugin = (options = {}) => {
285
285
  createLitDevframePlugin({
286
286
  version: PACKAGE_VERSION,
287
287
  features: () => toFeatureSettings(resolved),
288
+ // Only a named editor counts: `toFeatureSettings` reports `vscode`
289
+ // for "never chose", which must not turn into a forced `code`.
290
+ configuredEditor: () => {
291
+ const so = resolved.sourceOverlay;
292
+ return so !== false && typeof so.editor === 'string'
293
+ ? so.editor
294
+ : undefined;
295
+ },
288
296
  })
289
297
  );
290
298
  }
package/lib/plugin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/lib/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,WAAW,CAAC;AACjD,OAAO,EAAC,OAAO,EAAc,MAAM,MAAM,CAAC;AAC1C,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,UAAU,EAGV,cAAc,EACd,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAC,oBAAoB,EAAE,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAC,4BAA4B,EAAC,MAAM,6BAA6B,CAAC;AACz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C","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {resolve as resolvePath} from 'node:path';\nimport {loadEnv, type Plugin} from 'vite';\nimport MagicString from 'magic-string';\nimport {injectSourceMeta} from './source-meta.js';\nimport {INSTALL_ID, VIRTUAL_PREFIX, transformLitModule} from './transform.js';\nimport {WRAP_TABLE} from './wrap-table.js';\nimport {createLitDevframePlugin} from './devframe/vite.js';\nimport {PACKAGE_VERSION} from './devframe/paths.js';\nimport {\n ENV_PREFIX,\n type LitPluginOptions,\n type ResolvedOptions,\n resolveOptions,\n toFeatureSettings,\n} from './options.js';\nimport {\n OPEN_IN_EDITOR_PATH,\n createOpenInEditorMiddleware,\n} from './plugins/open-in-editor.js';\nimport {litCssQueries} from './plugins/css-queries.js';\nimport {litTimelineVirtual} from './plugins/timeline-virtual.js';\nimport {litCssLiterals} from './plugins/css-literals.js';\nimport {resolveRuntimeModule, JS_FILE_RE} from './plugins/shared.js';\n\nexport {createOpenInEditorMiddleware} from './plugins/open-in-editor.js';\nexport {litCssQueries} from './plugins/css-queries.js';\nexport {litTimelineVirtual} from './plugins/timeline-virtual.js';\nexport type {\n HmrIndicatorOptions,\n HmrOptions,\n CssSheetBuild,\n LitPluginOptions,\n ResolvedOptions,\n} from './options.js';\nexport {resolveOptions} from './options.js';\n\n/**\n * Vite plugin set providing HMR, CSS helpers, and Lightning CSS processing\n * for Lit projects.\n */\nexport const litPlugin = (options: LitPluginOptions = {}): Plugin[] => {\n // Resolved from explicit options first, env vars second, defaults last. The\n // `lit-plugin-options` `config` hook below re-resolves with the loaded env\n // once Vite hands us the mode; this initial pass covers code paths that run\n // before (or without) it.\n let resolved: ResolvedOptions = resolveOptions(options, {});\n let root = '';\n // Env resolution lives in its own always-applied plugin: `?css-sheet` is a\n // build-time feature too, and the HMR plugin (`apply: 'serve'`) never gets a\n // `config` hook under `vite build`. `enforce: 'pre'` and first position put\n // it ahead of every other hook that reads `resolved`.\n const optionsPlugin: Plugin = {\n name: 'lit-plugin-options',\n enforce: 'pre',\n config(viteConfig, {mode}) {\n // `loadEnv` reads `.env*` files from the env dir (root by default) and\n // merges in matching `process.env` keys, filtered to the `LIT_PLUGIN`\n // prefix. Explicit options still win (handled in resolveOptions).\n const envDir = viteConfig.envDir\n ? resolvePath(viteConfig.envDir)\n : viteConfig.root\n ? resolvePath(viteConfig.root)\n : process.cwd();\n resolved = resolveOptions(options, loadEnv(mode, envDir, ENV_PREFIX));\n },\n };\n const sourceOverlayPlugin: Plugin = {\n name: 'lit-source-overlay',\n apply: 'serve',\n // Run before Vite's esbuild TS transform so source-meta line numbers are\n // measured against the author's raw source (and the `@customElement … class`\n // forms are still intact), not against transpiled output.\n enforce: 'pre',\n configResolved(config) {\n root = config.root;\n },\n resolveId(id) {\n if (id === '@oddsquad/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n return null;\n },\n configureServer(server) {\n if (!resolved.sourceOverlay) return;\n // Allow opens from everything vite itself is willing to serve\n // (`server.fs.allow` defaults to the workspace root), not just\n // `config.root` — in monorepos, component sources regularly live in\n // sibling packages outside the served app's root.\n const fsAllow = server.config.server.fs?.allow ?? [];\n server.middlewares.use(\n OPEN_IN_EDITOR_PATH,\n createOpenInEditorMiddleware([root, ...fsAllow])\n );\n },\n transform(code, id, transformOptions) {\n if (!resolved.sourceOverlay) return null;\n if (transformOptions?.ssr) return null;\n if (\n id.startsWith('\\0') ||\n id.includes('__x00__') ||\n id.includes('lit-plugin:') ||\n id.includes('/node_modules/')\n ) {\n return null;\n }\n const [file] = id.split('?', 2);\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n if (!code.includes('customElement') && !code.includes('customElements')) {\n return null;\n }\n const ms = new MagicString(code);\n const relativeFile = file.startsWith(root + '/')\n ? file.slice(root.length + 1)\n : file;\n if (!injectSourceMeta(code, relativeFile, ms)) {\n return null;\n }\n return {code: ms.toString(), map: ms.generateMap({hires: true})};\n },\n transformIndexHtml() {\n if (!resolved.sourceOverlay) return;\n const overlayUrl = `/@fs/${resolveRuntimeModule('source-overlay')}`;\n const {\n exclude: _exclude,\n onSelect: _onSelect,\n ...overlayInit\n } = resolved.sourceOverlay;\n const initConfig = {\n ...overlayInit,\n openInEditorPath: OPEN_IN_EDITOR_PATH,\n };\n return [\n {\n tag: 'script',\n attrs: {type: 'module'},\n children: `import {initSourceOverlay} from ${JSON.stringify(overlayUrl)};\\ninitSourceOverlay(${JSON.stringify(initConfig)});\\n`,\n injectTo: 'body',\n },\n ];\n },\n };\n const hmr: Plugin = {\n name: 'lit-plugin',\n apply: 'serve',\n config: () => {\n // Options are already resolved against the loaded env by\n // `lit-plugin-options`, which runs first.\n if (!resolved.hmrEnabled) {\n return;\n }\n // The injected runtime imports are invisible to the dep scanner. The\n // lit family stays prebundle-eligible on purpose: the wrapper modules'\n // bare imports then resolve to the same URL every other importer gets —\n // single lit instance, single template cache.\n return {optimizeDeps: {exclude: ['@oddsquad/vite-plugin-lit']}};\n },\n resolveId(id) {\n // Resolve the browser CSS helpers and indicator runtime to the copy\n // shipped next to this plugin, so they work even when the package\n // isn't reachable through node resolution from the served root (and\n // stay out of prebundling).\n //\n // These bare specifiers must match the package name in package.json —\n // consumers import them by name (see README \"Stylesheets\"), and Vite\n // only consults this hook for the exact string. A rename that misses\n // them turns the fallback into silently dead code.\n if (id === '@oddsquad/vite-plugin-lit/css.js') {\n return resolveRuntimeModule('css');\n }\n if (id === '@oddsquad/vite-plugin-lit/indicator.js') {\n return resolveRuntimeModule('indicator');\n }\n if (id === '@oddsquad/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n if (resolved.hmrEnabled && id.startsWith(VIRTUAL_PREFIX)) {\n return id;\n }\n return null;\n },\n load(id) {\n if (!resolved.hmrEnabled || !id.startsWith(VIRTUAL_PREFIX)) {\n return null;\n }\n if (id === INSTALL_ID) {\n const patchPath = resolveRuntimeModule('patch');\n const runtimeOptions = {\n reconnect: resolved.reconnect,\n onIncompatible: resolved.onIncompatible,\n };\n return {\n code:\n `import {install} from ${JSON.stringify(patchPath)};\\n` +\n `install(${JSON.stringify(runtimeOptions)});\\n`,\n moduleType: 'js',\n };\n }\n const spec = id.slice(VIRTUAL_PREFIX.length);\n const wrappedTags = WRAP_TABLE.get(spec);\n if (wrappedTags === undefined) {\n return null;\n }\n const internPath = resolveRuntimeModule('intern');\n // Browser-native ESM: explicit local exports shadow `export *` names\n // (spec-guaranteed), so everything except the wrapped tags passes\n // through unchanged.\n const lines = [\n `import * as __lit from ${JSON.stringify(spec)};`,\n `import {wrapTag} from ${JSON.stringify(internPath)};`,\n `export * from ${JSON.stringify(spec)};`,\n ];\n for (const {exportName, ns} of wrappedTags) {\n lines.push(\n `export const ${exportName} = wrapTag(__lit.${exportName}, ${JSON.stringify(\n ns\n )});`\n );\n }\n return {code: lines.join('\\n') + '\\n', moduleType: 'js'};\n },\n async transform(code, id, transformOptions) {\n if (!resolved.hmrEnabled) {\n return null;\n }\n if (transformOptions?.ssr) {\n return null;\n }\n if (id.startsWith('\\0') || id.includes('/node_modules/')) {\n return null;\n }\n const [file] = id.split('?', 2);\n // Allow inline scripts extracted from HTML (`?html-proxy`).\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n return transformLitModule(code);\n },\n transformIndexHtml() {\n const tags: {\n tag: string;\n attrs?: Record<string, string | undefined | boolean>;\n children?: string;\n injectTo: 'body';\n }[] = [];\n\n const indicator = resolved.indicator;\n if (indicator) {\n const indicatorUrl = `/@fs/` + resolveRuntimeModule('indicator');\n tags.push(\n {\n tag: 'script',\n attrs: {type: 'module', src: indicatorUrl},\n injectTo: 'body',\n },\n {\n tag: 'lit-devtools-hmr-indicator',\n attrs: indicator.count ? {count: ''} : undefined,\n children: '',\n injectTo: 'body',\n }\n );\n }\n\n if (resolved.timeline) {\n const installUrl = `/@fs/` + resolveRuntimeModule('timeline/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: installUrl},\n injectTo: 'body',\n });\n // Components inspector runtime — answers the panel's tree/details\n // requests. Paired with the timeline panel, which hosts its tab.\n const inspectorUrl =\n `/@fs/` + resolveRuntimeModule('inspector/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: inspectorUrl},\n injectTo: 'body',\n });\n }\n\n return tags.length > 0 ? tags : undefined;\n },\n };\n // The source-overlay plugin is always present; its hooks no-op when the\n // feature is disabled (which env may decide), so inclusion can't be gated\n // on the synchronously-known options here.\n const plugins: Plugin[] = [\n optionsPlugin,\n // Getter, not a snapshot: `resolved` is re-resolved against the loaded env\n // in `optionsPlugin`'s `config` hook, which runs after this array is built.\n litCssQueries(() => resolved.cssSheetBuild),\n litTimelineVirtual(() => resolved.timeline),\n litCssLiterals(),\n sourceOverlayPlugin,\n hmr,\n ];\n if (resolved.timeline) {\n // `features` is a getter, not a snapshot: `resolved` is re-resolved\n // against the loaded env in `optionsPlugin`'s `config` hook, which runs\n // after this array is built.\n plugins.push(\n createLitDevframePlugin({\n version: PACKAGE_VERSION,\n features: () => toFeatureSettings(resolved),\n })\n );\n }\n return plugins;\n};\n"]}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/lib/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,WAAW,CAAC;AACjD,OAAO,EAAC,OAAO,EAAc,MAAM,MAAM,CAAC;AAC1C,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,qB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a,CAAC;QAC3C,kBAAkB,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC3C,cAAc,EAAE;QAChB,mBAAmB;QACnB,GAAG;KACJ,CAAC;IACF,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACtB,oEAAoE;QACpE,wEAAwE;QACxE,6BAA6B;QAC7B,OAAO,CAAC,IAAI,CACV,uBAAuB,CAAC;YACtB,OAAO,EAAE,eAAe;YACxB,QAAQ,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC;YAC3C,mEAAmE;YACnE,+DAA+D;YAC/D,gBAAgB,EAAE,GAAG,EAAE;gBACrB,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC;gBAClC,OAAO,EAAE,KAAK,KAAK,IAAI,OAAO,EAAE,CAAC,MAAM,KAAK,QAAQ;oBAClD,CAAC,CAAC,EAAE,CAAC,MAAM;oBACX,CAAC,CAAC,SAAS,CAAC;YAChB,CAAC;SACF,CAAC,CACH,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {resolve as resolvePath} from 'node:path';\nimport {loadEnv, type Plugin} from 'vite';\nimport MagicString from 'magic-string';\nimport {injectSourceMeta} from './source-meta.js';\nimport {INSTALL_ID, VIRTUAL_PREFIX, transformLitModule} from './transform.js';\nimport {WRAP_TABLE} from './wrap-table.js';\nimport {createLitDevframePlugin} from './devframe/vite.js';\nimport {PACKAGE_VERSION} from './devframe/paths.js';\nimport {\n ENV_PREFIX,\n type LitPluginOptions,\n type ResolvedOptions,\n resolveOptions,\n toFeatureSettings,\n} from './options.js';\nimport {\n OPEN_IN_EDITOR_PATH,\n createOpenInEditorMiddleware,\n} from './plugins/open-in-editor.js';\nimport {litCssQueries} from './plugins/css-queries.js';\nimport {litTimelineVirtual} from './plugins/timeline-virtual.js';\nimport {litCssLiterals} from './plugins/css-literals.js';\nimport {resolveRuntimeModule, JS_FILE_RE} from './plugins/shared.js';\n\nexport {createOpenInEditorMiddleware} from './plugins/open-in-editor.js';\nexport {litCssQueries} from './plugins/css-queries.js';\nexport {litTimelineVirtual} from './plugins/timeline-virtual.js';\nexport type {\n HmrIndicatorOptions,\n HmrOptions,\n CssSheetBuild,\n LitPluginOptions,\n ResolvedOptions,\n} from './options.js';\nexport {resolveOptions} from './options.js';\n\n/**\n * Vite plugin set providing HMR, CSS helpers, and Lightning CSS processing\n * for Lit projects.\n */\nexport const litPlugin = (options: LitPluginOptions = {}): Plugin[] => {\n // Resolved from explicit options first, env vars second, defaults last. The\n // `lit-plugin-options` `config` hook below re-resolves with the loaded env\n // once Vite hands us the mode; this initial pass covers code paths that run\n // before (or without) it.\n let resolved: ResolvedOptions = resolveOptions(options, {});\n let root = '';\n // Env resolution lives in its own always-applied plugin: `?css-sheet` is a\n // build-time feature too, and the HMR plugin (`apply: 'serve'`) never gets a\n // `config` hook under `vite build`. `enforce: 'pre'` and first position put\n // it ahead of every other hook that reads `resolved`.\n const optionsPlugin: Plugin = {\n name: 'lit-plugin-options',\n enforce: 'pre',\n config(viteConfig, {mode}) {\n // `loadEnv` reads `.env*` files from the env dir (root by default) and\n // merges in matching `process.env` keys, filtered to the `LIT_PLUGIN`\n // prefix. Explicit options still win (handled in resolveOptions).\n const envDir = viteConfig.envDir\n ? resolvePath(viteConfig.envDir)\n : viteConfig.root\n ? resolvePath(viteConfig.root)\n : process.cwd();\n resolved = resolveOptions(options, loadEnv(mode, envDir, ENV_PREFIX));\n },\n };\n const sourceOverlayPlugin: Plugin = {\n name: 'lit-source-overlay',\n apply: 'serve',\n // Run before Vite's esbuild TS transform so source-meta line numbers are\n // measured against the author's raw source (and the `@customElement … class`\n // forms are still intact), not against transpiled output.\n enforce: 'pre',\n configResolved(config) {\n root = config.root;\n },\n resolveId(id) {\n if (id === '@oddsquad/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n return null;\n },\n configureServer(server) {\n if (!resolved.sourceOverlay) return;\n // Allow opens from everything vite itself is willing to serve\n // (`server.fs.allow` defaults to the workspace root), not just\n // `config.root` — in monorepos, component sources regularly live in\n // sibling packages outside the served app's root.\n const fsAllow = server.config.server.fs?.allow ?? [];\n server.middlewares.use(\n OPEN_IN_EDITOR_PATH,\n createOpenInEditorMiddleware([root, ...fsAllow])\n );\n },\n transform(code, id, transformOptions) {\n if (!resolved.sourceOverlay) return null;\n if (transformOptions?.ssr) return null;\n if (\n id.startsWith('\\0') ||\n id.includes('__x00__') ||\n id.includes('lit-plugin:') ||\n id.includes('/node_modules/')\n ) {\n return null;\n }\n const [file] = id.split('?', 2);\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n if (!code.includes('customElement') && !code.includes('customElements')) {\n return null;\n }\n const ms = new MagicString(code);\n const relativeFile = file.startsWith(root + '/')\n ? file.slice(root.length + 1)\n : file;\n if (!injectSourceMeta(code, relativeFile, ms)) {\n return null;\n }\n return {code: ms.toString(), map: ms.generateMap({hires: true})};\n },\n transformIndexHtml() {\n if (!resolved.sourceOverlay) return;\n const overlayUrl = `/@fs/${resolveRuntimeModule('source-overlay')}`;\n const {\n exclude: _exclude,\n onSelect: _onSelect,\n ...overlayInit\n } = resolved.sourceOverlay;\n const initConfig = {\n ...overlayInit,\n openInEditorPath: OPEN_IN_EDITOR_PATH,\n };\n return [\n {\n tag: 'script',\n attrs: {type: 'module'},\n children: `import {initSourceOverlay} from ${JSON.stringify(overlayUrl)};\\ninitSourceOverlay(${JSON.stringify(initConfig)});\\n`,\n injectTo: 'body',\n },\n ];\n },\n };\n const hmr: Plugin = {\n name: 'lit-plugin',\n apply: 'serve',\n config: () => {\n // Options are already resolved against the loaded env by\n // `lit-plugin-options`, which runs first.\n if (!resolved.hmrEnabled) {\n return;\n }\n // The injected runtime imports are invisible to the dep scanner. The\n // lit family stays prebundle-eligible on purpose: the wrapper modules'\n // bare imports then resolve to the same URL every other importer gets —\n // single lit instance, single template cache.\n return {optimizeDeps: {exclude: ['@oddsquad/vite-plugin-lit']}};\n },\n resolveId(id) {\n // Resolve the browser CSS helpers and indicator runtime to the copy\n // shipped next to this plugin, so they work even when the package\n // isn't reachable through node resolution from the served root (and\n // stay out of prebundling).\n //\n // These bare specifiers must match the package name in package.json —\n // consumers import them by name (see README \"Stylesheets\"), and Vite\n // only consults this hook for the exact string. A rename that misses\n // them turns the fallback into silently dead code.\n if (id === '@oddsquad/vite-plugin-lit/css.js') {\n return resolveRuntimeModule('css');\n }\n if (id === '@oddsquad/vite-plugin-lit/indicator.js') {\n return resolveRuntimeModule('indicator');\n }\n if (id === '@oddsquad/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n if (resolved.hmrEnabled && id.startsWith(VIRTUAL_PREFIX)) {\n return id;\n }\n return null;\n },\n load(id) {\n if (!resolved.hmrEnabled || !id.startsWith(VIRTUAL_PREFIX)) {\n return null;\n }\n if (id === INSTALL_ID) {\n const patchPath = resolveRuntimeModule('patch');\n const runtimeOptions = {\n reconnect: resolved.reconnect,\n onIncompatible: resolved.onIncompatible,\n };\n return {\n code:\n `import {install} from ${JSON.stringify(patchPath)};\\n` +\n `install(${JSON.stringify(runtimeOptions)});\\n`,\n moduleType: 'js',\n };\n }\n const spec = id.slice(VIRTUAL_PREFIX.length);\n const wrappedTags = WRAP_TABLE.get(spec);\n if (wrappedTags === undefined) {\n return null;\n }\n const internPath = resolveRuntimeModule('intern');\n // Browser-native ESM: explicit local exports shadow `export *` names\n // (spec-guaranteed), so everything except the wrapped tags passes\n // through unchanged.\n const lines = [\n `import * as __lit from ${JSON.stringify(spec)};`,\n `import {wrapTag} from ${JSON.stringify(internPath)};`,\n `export * from ${JSON.stringify(spec)};`,\n ];\n for (const {exportName, ns} of wrappedTags) {\n lines.push(\n `export const ${exportName} = wrapTag(__lit.${exportName}, ${JSON.stringify(\n ns\n )});`\n );\n }\n return {code: lines.join('\\n') + '\\n', moduleType: 'js'};\n },\n async transform(code, id, transformOptions) {\n if (!resolved.hmrEnabled) {\n return null;\n }\n if (transformOptions?.ssr) {\n return null;\n }\n if (id.startsWith('\\0') || id.includes('/node_modules/')) {\n return null;\n }\n const [file] = id.split('?', 2);\n // Allow inline scripts extracted from HTML (`?html-proxy`).\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n return transformLitModule(code);\n },\n transformIndexHtml() {\n const tags: {\n tag: string;\n attrs?: Record<string, string | undefined | boolean>;\n children?: string;\n injectTo: 'body';\n }[] = [];\n\n const indicator = resolved.indicator;\n if (indicator) {\n const indicatorUrl = `/@fs/` + resolveRuntimeModule('indicator');\n tags.push(\n {\n tag: 'script',\n attrs: {type: 'module', src: indicatorUrl},\n injectTo: 'body',\n },\n {\n tag: 'lit-devtools-hmr-indicator',\n attrs: indicator.count ? {count: ''} : undefined,\n children: '',\n injectTo: 'body',\n }\n );\n }\n\n if (resolved.timeline) {\n const installUrl = `/@fs/` + resolveRuntimeModule('timeline/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: installUrl},\n injectTo: 'body',\n });\n // Components inspector runtime — answers the panel's tree/details\n // requests. Paired with the timeline panel, which hosts its tab.\n const inspectorUrl =\n `/@fs/` + resolveRuntimeModule('inspector/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: inspectorUrl},\n injectTo: 'body',\n });\n }\n\n return tags.length > 0 ? tags : undefined;\n },\n };\n // The source-overlay plugin is always present; its hooks no-op when the\n // feature is disabled (which env may decide), so inclusion can't be gated\n // on the synchronously-known options here.\n const plugins: Plugin[] = [\n optionsPlugin,\n // Getter, not a snapshot: `resolved` is re-resolved against the loaded env\n // in `optionsPlugin`'s `config` hook, which runs after this array is built.\n litCssQueries(() => resolved.cssSheetBuild),\n litTimelineVirtual(() => resolved.timeline),\n litCssLiterals(),\n sourceOverlayPlugin,\n hmr,\n ];\n if (resolved.timeline) {\n // `features` is a getter, not a snapshot: `resolved` is re-resolved\n // against the loaded env in `optionsPlugin`'s `config` hook, which runs\n // after this array is built.\n plugins.push(\n createLitDevframePlugin({\n version: PACKAGE_VERSION,\n features: () => toFeatureSettings(resolved),\n // Only a named editor counts: `toFeatureSettings` reports `vscode`\n // for \"never chose\", which must not turn into a forced `code`.\n configuredEditor: () => {\n const so = resolved.sourceOverlay;\n return so !== false && typeof so.editor === 'string'\n ? so.editor\n : undefined;\n },\n })\n );\n }\n return plugins;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"open-in-editor.d.ts","sourceRoot":"","sources":["../../src/lib/plugins/open-in-editor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAmB,KAAK,YAAY,EAAC,MAAM,YAAY,CAAC;AAE/D,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAE3D,eAAO,MAAM,4BAA4B,iBACzB,SAAS,MAAM,EAAE,WAMxB;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,YAAY,CAAA;CAAC,OACvD;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAC,QAC/C,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,SAuFhC,CAAC"}
1
+ {"version":3,"file":"open-in-editor.d.ts","sourceRoot":"","sources":["../../src/lib/plugins/open-in-editor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAmB,KAAK,YAAY,EAAC,MAAM,YAAY,CAAC;AAE/D,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAE3D,eAAO,MAAM,4BAA4B,iBACzB,SAAS,MAAM,EAAE,WAMxB;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,YAAY,CAAA;CAAC,OACvD;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAC,QAC/C,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,SAiGhC,CAAC"}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import {existsSync} from 'node:fs';
7
7
  import {resolve as resolvePath, sep} from 'node:path';
8
+ import {toLaunchEditor} from '../devframe/launch-editor.js';
8
9
  import {isTrustedRequest} from '../http.js';
9
10
  export const OPEN_IN_EDITOR_PATH = '/__lit-open-in-editor';
10
11
  export const createOpenInEditorMiddleware = (allowedRoots) => {
@@ -63,6 +64,10 @@ export const createOpenInEditorMiddleware = (allowedRoots) => {
63
64
  const column = String(
64
65
  Math.max(1, Number.parseInt(params.get('column') ?? '1', 10) || 1)
65
66
  );
67
+ // The overlay names the editor it is using (the panel's override, else the
68
+ // configured one). Only keys `toLaunchEditor` knows become a command;
69
+ // anything else, or nothing, leaves `launch-editor` to auto-detect.
70
+ const editor = toLaunchEditor(params.get('editor') ?? undefined);
66
71
  const fileRef = `${resolved}:${line}:${column}`;
67
72
  import('launch-editor')
68
73
  .then((mod) => {
@@ -78,7 +83,7 @@ export const createOpenInEditorMiddleware = (allowedRoots) => {
78
83
  res.statusCode = statusCode;
79
84
  res.end(msg);
80
85
  };
81
- launch(fileRef, (_fileName, errorMessage) => {
86
+ launch(fileRef, editor, (_fileName, errorMessage) => {
82
87
  if (errorMessage !== null) {
83
88
  finish(500, errorMessage);
84
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"open-in-editor.js","sourceRoot":"","sources":["../../src/lib/plugins/open-in-editor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACnC,OAAO,EAAC,OAAO,IAAI,WAAW,EAAE,GAAG,EAAC,MAAM,WAAW,CAAC;AACtD,OAAO,EAA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QACF,MAAM,OAAO,GAAG,GAAG,QAAQ,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;QAChD,MAAM,CAAC,eAAe,CAAC;aACpB,IAAI,CACH,CAAC,GAKA,EAAE,EAAE;YACH,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAGzB,CAAC;YACV,uEAAuE;YACvE,uEAAuE;YACvE,oEAAoE;YACpE,8DAA8D;YAC9D,IAAI,QAAQ,GAAG,KAAK,CAAC;YACrB,MAAM,MAAM,GAAG,CAAC,UAAkB,EAAE,GAAW,EAAE,EAAE;gBACjD,IAAI,QAAQ;oBAAE,OAAO;gBACrB,QAAQ,GAAG,IAAI,CAAC;gBAChB,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;gBAC5B,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACf,CAAC,CAAC;YACF,MAAM,CAAC,OAAO,EAAE,CAAC,SAAiB,EAAE,YAA2B,EAAE,EAAE;gBACjE,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;oBAC1B,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC,CAAC,CAAC;YACH,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACpB,CAAC,CACF;aACA,KAAK,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {existsSync} from 'node:fs';\nimport {resolve as resolvePath, sep} from 'node:path';\nimport {isTrustedRequest, type TrustHeaders} from '../http.js';\n\nexport const OPEN_IN_EDITOR_PATH = '/__lit-open-in-editor';\n\nexport const createOpenInEditorMiddleware = (\n allowedRoots: readonly string[]\n) => {\n // First entry is the primary root: relative `file` params resolve against\n // it. Every entry grants open access to files beneath it.\n const roots = allowedRoots.map((r) => resolvePath(r));\n return (\n req: {url?: string; method?: string; headers?: TrustHeaders},\n res: {statusCode: number; end: (msg: string) => void},\n next: (err?: unknown) => void\n ) => {\n if (req.url === undefined) {\n next();\n return;\n }\n if (req.method !== undefined && req.method !== 'GET') {\n res.statusCode = 405;\n res.end('method not allowed');\n return;\n }\n if (!isTrustedRequest(req.headers ?? {})) {\n res.statusCode = 403;\n res.end('forbidden');\n return;\n }\n const query = req.url.includes('?')\n ? req.url.slice(req.url.indexOf('?') + 1)\n : '';\n const params = new URLSearchParams(query);\n const file = params.get('file');\n if (file === null) {\n res.statusCode = 400;\n res.end('missing file parameter');\n return;\n }\n // Confine the open to the allowed roots: resolve the requested path and\n // reject anything that escapes all of them (path traversal, absolute\n // paths to arbitrary files). `launch-editor` spawns the user's editor on\n // this path, so an unvalidated `file` is a local-file-open /\n // arg-injection vector.\n const resolved = resolvePath(roots[0] ?? process.cwd(), file);\n const allowed = roots.some(\n (root) => resolved === root || resolved.startsWith(root + sep)\n );\n if (!allowed) {\n res.statusCode = 403;\n res.end('file outside allowed roots');\n return;\n }\n if (!existsSync(resolved)) {\n res.statusCode = 404;\n res.end('file not found');\n return;\n }\n // Coerce to integers so a crafted `line`/`column` can't smuggle extra\n // shell-visible content through the `file:line:column` ref.\n const line = String(\n Math.max(1, Number.parseInt(params.get('line') ?? '1', 10) || 1)\n );\n const column = String(\n Math.max(1, Number.parseInt(params.get('column') ?? '1', 10) || 1)\n );\n const fileRef = `${resolved}:${line}:${column}`;\n import('launch-editor')\n .then(\n (mod: {\n default?: (\n file: string,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n }) => {\n const launch = (mod.default ?? mod) as (\n file: string,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n // `launch-editor` invokes the callback only on failure — synchronously\n // when it can't guess an editor, later if the spawn errors. Reply `ok`\n // right after launching; the guard keeps a sync failure's 500 first\n // and drops a late async failure (the response is long gone).\n let finished = false;\n const finish = (statusCode: number, msg: string) => {\n if (finished) return;\n finished = true;\n res.statusCode = statusCode;\n res.end(msg);\n };\n launch(fileRef, (_fileName: string, errorMessage: string | null) => {\n if (errorMessage !== null) {\n finish(500, errorMessage);\n }\n });\n finish(200, 'ok');\n }\n )\n .catch(next);\n };\n};\n"]}
1
+ {"version":3,"file":"open-in-editor.js","sourceRoot":"","sources":["../../src/lib/plugins/open-in-editor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACnC,OAAO,EAAC,OAAO,IAAI,WAAW,EAAE,GAAG,EAAC,MAAM,WAAW,CAAC;AACtD,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAoB,MAAM,YAAY,CAAC;AAE/D,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAE3D,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,YAA+B,EAC/B,EAAE;IACF,0EAA0E;IAC1E,0DAA0D;IAC1D,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,OAAO,CACL,GAA4D,EAC5D,GAAqD,EACrD,IAA6B,EAC7B,EAAE;QACF,IAAI,GAAG,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YAC1B,IAAI,EAAE,CAAC;YACP,OAAO;QACT,CAAC;QACD,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YACrD,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;YACrB,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;YAC9B,OAAO;QACT,CAAC;QACD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;YACzC,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;YACrB,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AAE,CAAC;oBAC1B,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC,CACF,CAAC;YACF,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACpB,CAAC,CACF;aACA,KAAK,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {existsSync} from 'node:fs';\nimport {resolve as resolvePath, sep} from 'node:path';\nimport {toLaunchEditor} from '../devframe/launch-editor.js';\nimport {isTrustedRequest, type TrustHeaders} from '../http.js';\n\nexport const OPEN_IN_EDITOR_PATH = '/__lit-open-in-editor';\n\nexport const createOpenInEditorMiddleware = (\n allowedRoots: readonly string[]\n) => {\n // First entry is the primary root: relative `file` params resolve against\n // it. Every entry grants open access to files beneath it.\n const roots = allowedRoots.map((r) => resolvePath(r));\n return (\n req: {url?: string; method?: string; headers?: TrustHeaders},\n res: {statusCode: number; end: (msg: string) => void},\n next: (err?: unknown) => void\n ) => {\n if (req.url === undefined) {\n next();\n return;\n }\n if (req.method !== undefined && req.method !== 'GET') {\n res.statusCode = 405;\n res.end('method not allowed');\n return;\n }\n if (!isTrustedRequest(req.headers ?? {})) {\n res.statusCode = 403;\n res.end('forbidden');\n return;\n }\n const query = req.url.includes('?')\n ? req.url.slice(req.url.indexOf('?') + 1)\n : '';\n const params = new URLSearchParams(query);\n const file = params.get('file');\n if (file === null) {\n res.statusCode = 400;\n res.end('missing file parameter');\n return;\n }\n // Confine the open to the allowed roots: resolve the requested path and\n // reject anything that escapes all of them (path traversal, absolute\n // paths to arbitrary files). `launch-editor` spawns the user's editor on\n // this path, so an unvalidated `file` is a local-file-open /\n // arg-injection vector.\n const resolved = resolvePath(roots[0] ?? process.cwd(), file);\n const allowed = roots.some(\n (root) => resolved === root || resolved.startsWith(root + sep)\n );\n if (!allowed) {\n res.statusCode = 403;\n res.end('file outside allowed roots');\n return;\n }\n if (!existsSync(resolved)) {\n res.statusCode = 404;\n res.end('file not found');\n return;\n }\n // Coerce to integers so a crafted `line`/`column` can't smuggle extra\n // shell-visible content through the `file:line:column` ref.\n const line = String(\n Math.max(1, Number.parseInt(params.get('line') ?? '1', 10) || 1)\n );\n const column = String(\n Math.max(1, Number.parseInt(params.get('column') ?? '1', 10) || 1)\n );\n // The overlay names the editor it is using (the panel's override, else the\n // configured one). Only keys `toLaunchEditor` knows become a command;\n // anything else, or nothing, leaves `launch-editor` to auto-detect.\n const editor = toLaunchEditor(params.get('editor') ?? undefined);\n const fileRef = `${resolved}:${line}:${column}`;\n import('launch-editor')\n .then(\n (mod: {\n default?: (\n file: string,\n editor: string | undefined,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n }) => {\n const launch = (mod.default ?? mod) as (\n file: string,\n editor: string | undefined,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n // `launch-editor` invokes the callback only on failure — synchronously\n // when it can't guess an editor, later if the spawn errors. Reply `ok`\n // right after launching; the guard keeps a sync failure's 500 first\n // and drops a late async failure (the response is long gone).\n let finished = false;\n const finish = (statusCode: number, msg: string) => {\n if (finished) return;\n finished = true;\n res.statusCode = statusCode;\n res.end(msg);\n };\n launch(\n fileRef,\n editor,\n (_fileName: string, errorMessage: string | null) => {\n if (errorMessage !== null) {\n finish(500, errorMessage);\n }\n }\n );\n finish(200, 'ok');\n }\n )\n .catch(next);\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"indicator.js","sourceRoot":"","sources":["../../src/lib/runtime/indicator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAC,iBAAiB,EA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AAS,EAAE,CAAC;gBACxC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YAC3D,CAAC;YACD,IAAI,CAAC,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;gBACtC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC;YACtC,CAAC;QACH,CAAC,CAAC,CAAC;QACH,8CAA8C;QAC9C,iBAAiB,CAAC,CAAC,MAAM,EAAE,EAAE;YAC3B,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;YACxD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;YAC5D,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;YAC9D,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,EAAE,GAAG,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,4BAA4B,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Custom element for the HMR update indicator.\n * Injected by the Vite plugin as an external module so that\n * `import.meta.hot` is available.\n */\n\nimport {FONT_MONO_VAR} from './fonts.js';\nimport {FLAME_ICON} from '../icons.js';\nimport {subscribeOverride} from './overrides.js';\nimport {observeEdgeInsets} from './edge-panel.js';\nimport {injectTokens} from '../tokens.js';\n\n/** One entry of a Vite `vite:afterUpdate` payload. */\ninterface ViteUpdate {\n type?: string;\n path?: string;\n acceptedPath?: string;\n}\n\n/**\n * True when an HMR batch is purely a stylesheet swap — every update is either\n * a `css-update` or a `js-update` whose accepted module is a `.css` source\n * (the shared-sheet queries `?css-sheet`/`?raw`/`?url` all accept a `.css`\n * path). Such a batch restyles adopted sheets in place with no re-render.\n *\n * Heuristic: keyed on the accepted path ending in `.css`. Robust for this\n * plugin's own queries; a user hand-wiring `import.meta.hot.accept` on a raw\n * `.css` would also read as a style swap, which is the intended grouping. An\n * empty/missing payload can't be classified, so it counts as a re-render\n * rather than being silently dropped.\n */\nfunction isStyleSwap(data: unknown): boolean {\n const updates = (data as {updates?: ViteUpdate[]} | undefined)?.updates;\n if (!Array.isArray(updates) || updates.length === 0) return false;\n return updates.every((u) => {\n if (u.type === 'css-update') return true;\n if (u.type === 'js-update') {\n return (u.acceptedPath ?? u.path ?? '').split('?')[0].endsWith('.css');\n }\n return false;\n });\n}\n\nclass LitDevtoolsIndicator extends HTMLElement {\n #initialized = false;\n #count = 0;\n #container: HTMLElement;\n #countEl: HTMLElement | null = null;\n\n constructor() {\n super();\n const root = this.attachShadow({mode: 'closed'});\n // `--idle-op` is the at-rest opacity: 0 (invisible until a pulse) without a\n // count, .5 (count stays legible) with one. The count display and idle\n // opacity are both driven by the `.with-count` class so the panel can\n // toggle the count on/off live (see #setCount).\n root.innerHTML = `\n <style>\n @keyframes pulse{0%{opacity:var(--idle-op,0)}15%{opacity:1}80%{opacity:1}100%{opacity:var(--idle-op,0)}}\n :host{\n position:fixed;inset:0;display:grid;\n z-index:2147483647;pointer-events:none;\n /* Base padding plus the inset the Vite DevTools edge panel occupies\n on each edge (set from JS), so the indicator never sits on it. */\n padding:\n calc(var(--lit-devtools-hmr-indicator-padding,16px) + var(--edge-top,0px))\n calc(var(--lit-devtools-hmr-indicator-padding,16px) + var(--edge-right,0px))\n calc(var(--lit-devtools-hmr-indicator-padding,16px) + var(--edge-bottom,0px))\n calc(var(--lit-devtools-hmr-indicator-padding,16px) + var(--edge-left,0px))\n }\n #container{\n place-self:var(--lit-devtools-hmr-indicator-align,end end);\n display:flex;align-items:stretch;\n background:var(--lit-devtools-surface-elevated);color:var(--lit-devtools-text-strong);\n backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);\n border-radius:var(--lit-devtools-radius-md);\n font:12px/1 ${FONT_MONO_VAR};font-variant-numeric:tabular-nums;\n overflow:hidden;opacity:var(--idle-op,0)\n }\n #container.with-count{--idle-op:.5}\n #container.active{animation:pulse 2.5s ease-out forwards}\n #icon{display:flex;align-items:center;justify-content:center;padding:0 10px}\n #icon svg{width:16px;height:16px;display:block;fill:currentColor}\n #indicator{\n display:flex;align-items:center;gap:6px;\n padding:7px 12px;\n border-left:1px solid var(--lit-devtools-border-subtle)\n }\n .dot{width:8px;height:8px;border-radius:50%;background:var(--lit-devtools-success);flex-shrink:0}\n /* Style-only swaps (shared adopted stylesheet hot-swap, no re-render)\n pulse in the calmer info color and don't bump the count. */\n #container.style-swap .dot{background:var(--lit-devtools-info)}\n .count{display:none}\n #container.with-count .count{display:inline}\n </style>\n <div id=\"container\"><span id=\"icon\">${FLAME_ICON}</span><span id=\"indicator\"><span class=\"dot\"></span><span class=\"count\">0</span></span></div>\n `;\n this.#container = root.getElementById('container')!;\n this.#countEl = root.querySelector('.count');\n this.#setCount(this.hasAttribute('count'));\n }\n\n /** Show/hide the cumulative update count (and the at-rest opacity). */\n #setCount(enabled: boolean) {\n this.#container.classList.toggle('with-count', enabled);\n }\n\n connectedCallback() {\n if (this.#initialized) return;\n this.#initialized = true;\n injectTokens();\n const hot = (\n import.meta as {\n hot?: {on: (event: string, cb: (data?: unknown) => void) => void};\n }\n ).hot;\n hot?.on('vite:afterUpdate', (data) => {\n // Count only updates that actually re-render/re-execute a component;\n // a pure shared-stylesheet swap (?css-sheet / ?raw / ?url adopted sheet)\n // restyles in place without re-rendering, so it pulses but doesn't count.\n const styleSwap = isStyleSwap(data);\n if (!styleSwap && this.#countEl !== null) {\n this.#countEl.textContent = String(++this.#count);\n }\n this.#container.classList.toggle('style-swap', styleSwap);\n this.#container.classList.remove('active');\n void this.#container.offsetWidth;\n this.#container.classList.add('active');\n });\n // Let the DevTools panel hide/show the indicator and its count live (and\n // across reloads).\n subscribeOverride(hot, (o) => {\n if (o.hmrIndicatorVisible !== undefined) {\n this.style.display = o.hmrIndicatorVisible ? '' : 'none';\n }\n if (o.hmrIndicatorCount !== undefined) {\n this.#setCount(o.hmrIndicatorCount);\n }\n });\n // Stay clear of the Vite DevTools edge panel.\n observeEdgeInsets((insets) => {\n this.style.setProperty('--edge-top', `${insets.top}px`);\n this.style.setProperty('--edge-right', `${insets.right}px`);\n this.style.setProperty('--edge-bottom', `${insets.bottom}px`);\n this.style.setProperty('--edge-left', `${insets.left}px`);\n });\n }\n}\n\ncustomElements.define('lit-devtools-hmr-indicator', LitDevtoolsIndicator);\n"]}
1
+ {"version":3,"file":"indicator.js","sourceRoot":"","sources":["../../src/lib/runtime/indicator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAS1C;;;;;;;;;;;GAWG;AACH,SAAS,WAAW,CAAC,IAAa;IAChC,MAAM,OAAO,GAAI,IAA6C,EAAE,OAAO,CAAC;IACxE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAClE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACzB,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY;YAAE,OAAO,IAAI,CAAC;QACzC,IAAI,CAAC,CAAC,IAAI,KA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,CAAC,CAAC;YACxD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;YAC5D,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;YAC9D,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,EAAE,GAAG,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,4BAA4B,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Custom element for the HMR update indicator.\n * Injected by the Vite plugin as an external module so that\n * `import.meta.hot` is available.\n */\n\nimport {FONT_MONO_VAR} from './fonts.js';\nimport {FLAME_ICON} from '../icons.js';\nimport {subscribeOverride} from './overrides.js';\nimport type {ViteHotLike} from './page-channel.js';\nimport {observeEdgeInsets} from './edge-panel.js';\nimport {injectTokens} from '../tokens.js';\n\n/** One entry of a Vite `vite:afterUpdate` payload. */\ninterface ViteUpdate {\n type?: string;\n path?: string;\n acceptedPath?: string;\n}\n\n/**\n * True when an HMR batch is purely a stylesheet swap — every update is either\n * a `css-update` or a `js-update` whose accepted module is a `.css` source\n * (the shared-sheet queries `?css-sheet`/`?raw`/`?url` all accept a `.css`\n * path). Such a batch restyles adopted sheets in place with no re-render.\n *\n * Heuristic: keyed on the accepted path ending in `.css`. Robust for this\n * plugin's own queries; a user hand-wiring `import.meta.hot.accept` on a raw\n * `.css` would also read as a style swap, which is the intended grouping. An\n * empty/missing payload can't be classified, so it counts as a re-render\n * rather than being silently dropped.\n */\nfunction isStyleSwap(data: unknown): boolean {\n const updates = (data as {updates?: ViteUpdate[]} | undefined)?.updates;\n if (!Array.isArray(updates) || updates.length === 0) return false;\n return updates.every((u) => {\n if (u.type === 'css-update') return true;\n if (u.type === 'js-update') {\n return (u.acceptedPath ?? u.path ?? '').split('?')[0].endsWith('.css');\n }\n return false;\n });\n}\n\nclass LitDevtoolsIndicator extends HTMLElement {\n #initialized = false;\n #count = 0;\n #container: HTMLElement;\n #countEl: HTMLElement | null = null;\n\n constructor() {\n super();\n const root = this.attachShadow({mode: 'closed'});\n // `--idle-op` is the at-rest opacity: 0 (invisible until a pulse) without a\n // count, .5 (count stays legible) with one. The count display and idle\n // opacity are both driven by the `.with-count` class so the panel can\n // toggle the count on/off live (see #setCount).\n root.innerHTML = `\n <style>\n @keyframes pulse{0%{opacity:var(--idle-op,0)}15%{opacity:1}80%{opacity:1}100%{opacity:var(--idle-op,0)}}\n :host{\n position:fixed;inset:0;display:grid;\n z-index:2147483647;pointer-events:none;\n /* Base padding plus the inset the Vite DevTools edge panel occupies\n on each edge (set from JS), so the indicator never sits on it. */\n padding:\n calc(var(--lit-devtools-hmr-indicator-padding,16px) + var(--edge-top,0px))\n calc(var(--lit-devtools-hmr-indicator-padding,16px) + var(--edge-right,0px))\n calc(var(--lit-devtools-hmr-indicator-padding,16px) + var(--edge-bottom,0px))\n calc(var(--lit-devtools-hmr-indicator-padding,16px) + var(--edge-left,0px))\n }\n #container{\n place-self:var(--lit-devtools-hmr-indicator-align,end end);\n display:flex;align-items:stretch;\n background:var(--lit-devtools-surface-elevated);color:var(--lit-devtools-text-strong);\n backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);\n border-radius:var(--lit-devtools-radius-md);\n font:12px/1 ${FONT_MONO_VAR};font-variant-numeric:tabular-nums;\n overflow:hidden;opacity:var(--idle-op,0)\n }\n #container.with-count{--idle-op:.5}\n #container.active{animation:pulse 2.5s ease-out forwards}\n #icon{display:flex;align-items:center;justify-content:center;padding:0 10px}\n #icon svg{width:16px;height:16px;display:block;fill:currentColor}\n #indicator{\n display:flex;align-items:center;gap:6px;\n padding:7px 12px;\n border-left:1px solid var(--lit-devtools-border-subtle)\n }\n .dot{width:8px;height:8px;border-radius:50%;background:var(--lit-devtools-success);flex-shrink:0}\n /* Style-only swaps (shared adopted stylesheet hot-swap, no re-render)\n pulse in the calmer info color and don't bump the count. */\n #container.style-swap .dot{background:var(--lit-devtools-info)}\n .count{display:none}\n #container.with-count .count{display:inline}\n </style>\n <div id=\"container\"><span id=\"icon\">${FLAME_ICON}</span><span id=\"indicator\"><span class=\"dot\"></span><span class=\"count\">0</span></span></div>\n `;\n this.#container = root.getElementById('container')!;\n this.#countEl = root.querySelector('.count');\n this.#setCount(this.hasAttribute('count'));\n }\n\n /** Show/hide the cumulative update count (and the at-rest opacity). */\n #setCount(enabled: boolean) {\n this.#container.classList.toggle('with-count', enabled);\n }\n\n connectedCallback() {\n if (this.#initialized) return;\n this.#initialized = true;\n injectTokens();\n const hot = (import.meta as {hot?: ViteHotLike}).hot;\n hot?.on('vite:afterUpdate', (data) => {\n // Count only updates that actually re-render/re-execute a component;\n // a pure shared-stylesheet swap (?css-sheet / ?raw / ?url adopted sheet)\n // restyles in place without re-rendering, so it pulses but doesn't count.\n const styleSwap = isStyleSwap(data);\n if (!styleSwap && this.#countEl !== null) {\n this.#countEl.textContent = String(++this.#count);\n }\n this.#container.classList.toggle('style-swap', styleSwap);\n this.#container.classList.remove('active');\n void this.#container.offsetWidth;\n this.#container.classList.add('active');\n });\n // Let the DevTools panel hide/show the indicator and its count live (and\n // across reloads).\n subscribeOverride(hot, (o) => {\n if (o.hmrIndicatorVisible !== undefined) {\n this.style.display = o.hmrIndicatorVisible ? '' : 'none';\n }\n if (o.hmrIndicatorCount !== undefined) {\n this.#setCount(o.hmrIndicatorCount);\n }\n });\n // Stay clear of the Vite DevTools edge panel.\n observeEdgeInsets((insets) => {\n this.style.setProperty('--edge-top', `${insets.top}px`);\n this.style.setProperty('--edge-right', `${insets.right}px`);\n this.style.setProperty('--edge-bottom', `${insets.bottom}px`);\n this.style.setProperty('--edge-left', `${insets.left}px`);\n });\n }\n}\n\ncustomElements.define('lit-devtools-hmr-indicator', LitDevtoolsIndicator);\n"]}
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import {createPageScriptChannel} from 'devframe/in-page-channel';
15
15
  import {elementById} from '../timeline/identity.js';
16
+ import {pageChannel} from '../page-channel.js';
16
17
  import {buildTree, collectDetails} from './collect.js';
17
18
  import {clearHighlight, highlightById} from './highlight.js';
18
19
  import {LIT_IN_PAGE_CHANNEL} from '../../../types/in-page.js';
@@ -21,6 +22,7 @@ import {
21
22
  INSPECT_DATA_CHANNEL,
22
23
  } from '../../../types/inspector.js';
23
24
  const hot = import.meta.hot;
25
+ if (hot !== undefined) pageChannel.useViteHot(hot);
24
26
  // The direct panel channel, outside the `hot` gate on purpose: it is the one
25
27
  // part of the inspector that does not need a dev server, which is what lets
26
28
  // the hover outline keep working in a static snapshot of the panel. Answering
@@ -40,7 +42,7 @@ if (typeof window !== 'undefined') {
40
42
  if (hot !== undefined && typeof window !== 'undefined') {
41
43
  const send = (msg) => {
42
44
  try {
43
- hot.send(INSPECT_DATA_CHANNEL, msg);
45
+ pageChannel.send(INSPECT_DATA_CHANNEL, msg);
44
46
  } catch {
45
47
  // HMR channel temporarily unavailable; the panel can re-request.
46
48
  }
@@ -216,7 +218,7 @@ if (hot !== undefined && typeof window !== 'undefined') {
216
218
  // -------------------------------------------------------------------------
217
219
  // Command dispatch
218
220
  // -------------------------------------------------------------------------
219
- hot.on(INSPECT_CMD_CHANNEL, (data) => {
221
+ pageChannel.on(INSPECT_CMD_CHANNEL, (data) => {
220
222
  const cmd = data;
221
223
  switch (cmd.type) {
222
224
  case 'tree': {