@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
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import type { WsOriginRegistry } from 'devframe/rpc/transports/ws-server';
7
+ /**
8
+ * `allowedOrigins` for `createDevServer`, from the `--allow-origin` values:
9
+ * `undefined` for none, the entries as given when all are exact, or a registry
10
+ * that also matches the wildcard ones. Throws on a malformed wildcard entry.
11
+ */
12
+ export declare const resolveAllowedOrigins: (entries: readonly string[]) => readonly string[] | WsOriginRegistry | undefined;
13
+ //# sourceMappingURL=allowed-origins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allowed-origins.d.ts","sourceRoot":"","sources":["../../src/lib/devframe/allowed-origins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AAsBxE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,YACvB,SAAS,MAAM,EAAE,KACzB,SAAS,MAAM,EAAE,GAAG,gBAAgB,GAAG,SAkBzC,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * The origin allowlist behind `lit-devtools dev --allow-origin`.
8
+ *
9
+ * devframe compares `allowedOrigins` entries exactly, which cannot admit a
10
+ * page whose origin is only known once it boots: StackBlitz gives every port
11
+ * of a project its own `https://<slug>--<port>--<hash>.<zone>.webcontainer-api.io`.
12
+ * An entry may therefore put `*` in its host (`https://*.webcontainer-api.io`),
13
+ * standing for one or more DNS labels. Scheme and port still have to match.
14
+ *
15
+ * With a wildcard among the entries the list is handed to devframe as an
16
+ * origin registry, the one shape it accepts that decides per origin; its
17
+ * WebSocket and SSE gates both ask it. Without one it stays a plain array.
18
+ */
19
+ import {isAllowedOrigin} from 'devframe/rpc/transports/ws-server';
20
+ /** An entry with `*` in the host, compiled to a matcher. */
21
+ const compilePattern = (entry) => {
22
+ const match = /^(https?):\/\/([^/:]+)(?::(\d+))?\/?$/.exec(entry);
23
+ const host = match?.[2] ?? '';
24
+ // `*` alone, or `*.com`, would admit most of the web.
25
+ if (match === null || !/^(?:[^*]*\*)*[^*]*\.[^*.]+\.[^*.]+$/.test(host)) {
26
+ throw new Error(
27
+ `--allow-origin ${entry}: a wildcard needs the shape ` +
28
+ `https://*.example.com, with at least two literal labels after it`
29
+ );
30
+ }
31
+ const [, scheme, , port] = match;
32
+ const hostSource = host
33
+ .split('*')
34
+ .map((part) => part.replace(/[.\\+?^$()[\]{}|-]/g, '\\$&'))
35
+ .join('[a-z0-9-]+(?:\\.[a-z0-9-]+)*');
36
+ const portSource = port === undefined ? '' : `:${port}`;
37
+ return new RegExp(`^${scheme}://${hostSource}${portSource}$`, 'i');
38
+ };
39
+ /**
40
+ * `allowedOrigins` for `createDevServer`, from the `--allow-origin` values:
41
+ * `undefined` for none, the entries as given when all are exact, or a registry
42
+ * that also matches the wildcard ones. Throws on a malformed wildcard entry.
43
+ */
44
+ export const resolveAllowedOrigins = (entries) => {
45
+ if (entries.length === 0) return undefined;
46
+ const exact = entries
47
+ .filter((entry) => !entry.includes('*'))
48
+ .map((entry) => entry.replace(/\/$/, ''));
49
+ const patterns = entries
50
+ .filter((entry) => entry.includes('*'))
51
+ .map(compilePattern);
52
+ if (patterns.length === 0) return exact;
53
+ return {
54
+ // No viewer registers itself through this list, so the token guards
55
+ // nothing; it is random only so it is never a guessable constant.
56
+ token: crypto.randomUUID(),
57
+ registerFromUrl: () => undefined,
58
+ isAllowed: (origin) =>
59
+ isAllowedOrigin(origin, exact) ||
60
+ (origin !== undefined && patterns.some((re) => re.test(origin))),
61
+ };
62
+ };
63
+ //# sourceMappingURL=allowed-origins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allowed-origins.js","sourceRoot":"","sources":["../../src/lib/devframe/allowed-origins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAC,eAAe,EAAC,MAAM,mCAAmC,CAAC;AAGlE,4DAA4D;AAC5D,MAAM,cAAc,GAAG,CAAC,KAAa,EAAU,EAAE;IAC/C,MAAM,KAAK,GAAG,uCAAuC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClE,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9B,sDAAsD;IACtD,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,qCAAqC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,kBAAkB,KAAK,+BAA+B;YACpD,kEAAkE,CACrE,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,EAAE,MA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AC,MAAM,EAAE,EAAE,CACpB,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC;YAC9B,CAAC,MAAM,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;KACnE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * The origin allowlist behind `lit-devtools dev --allow-origin`.\n *\n * devframe compares `allowedOrigins` entries exactly, which cannot admit a\n * page whose origin is only known once it boots: StackBlitz gives every port\n * of a project its own `https://<slug>--<port>--<hash>.<zone>.webcontainer-api.io`.\n * An entry may therefore put `*` in its host (`https://*.webcontainer-api.io`),\n * standing for one or more DNS labels. Scheme and port still have to match.\n *\n * With a wildcard among the entries the list is handed to devframe as an\n * origin registry, the one shape it accepts that decides per origin; its\n * WebSocket and SSE gates both ask it. Without one it stays a plain array.\n */\n\nimport {isAllowedOrigin} from 'devframe/rpc/transports/ws-server';\nimport type {WsOriginRegistry} from 'devframe/rpc/transports/ws-server';\n\n/** An entry with `*` in the host, compiled to a matcher. */\nconst compilePattern = (entry: string): RegExp => {\n const match = /^(https?):\\/\\/([^/:]+)(?::(\\d+))?\\/?$/.exec(entry);\n const host = match?.[2] ?? '';\n // `*` alone, or `*.com`, would admit most of the web.\n if (match === null || !/^(?:[^*]*\\*)*[^*]*\\.[^*.]+\\.[^*.]+$/.test(host)) {\n throw new Error(\n `--allow-origin ${entry}: a wildcard needs the shape ` +\n `https://*.example.com, with at least two literal labels after it`\n );\n }\n const [, scheme, , port] = match;\n const hostSource = host\n .split('*')\n .map((part) => part.replace(/[.\\\\+?^$()[\\]{}|-]/g, '\\\\$&'))\n .join('[a-z0-9-]+(?:\\\\.[a-z0-9-]+)*');\n const portSource = port === undefined ? '' : `:${port}`;\n return new RegExp(`^${scheme}://${hostSource}${portSource}$`, 'i');\n};\n\n/**\n * `allowedOrigins` for `createDevServer`, from the `--allow-origin` values:\n * `undefined` for none, the entries as given when all are exact, or a registry\n * that also matches the wildcard ones. Throws on a malformed wildcard entry.\n */\nexport const resolveAllowedOrigins = (\n entries: readonly string[]\n): readonly string[] | WsOriginRegistry | undefined => {\n if (entries.length === 0) return undefined;\n const exact = entries\n .filter((entry) => !entry.includes('*'))\n .map((entry) => entry.replace(/\\/$/, ''));\n const patterns = entries\n .filter((entry) => entry.includes('*'))\n .map(compilePattern);\n if (patterns.length === 0) return exact;\n return {\n // No viewer registers itself through this list, so the token guards\n // nothing; it is random only so it is never a guessable constant.\n token: crypto.randomUUID(),\n registerFromUrl: () => undefined,\n isAllowed: (origin) =>\n isAllowedOrigin(origin, exact) ||\n (origin !== undefined && patterns.some((re) => re.test(origin))),\n };\n};\n"]}
package/lib/options.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { SourceOverlayOptions } from './types.js';
7
7
  import type { FeatureSettings, SettingSources } from '../types/timeline.js';
8
+ import type { ChildStateMode } from './runtime/child-state.js';
8
9
  /**
9
10
  * On-page HMR feedback: a small pulsing indicator in the corner of the host
10
11
  * page that briefly animates on each HMR update, for at-a-glance feedback
@@ -34,11 +35,34 @@ export interface HmrOptions {
34
35
  * opt-in. Defaults to `false`.
35
36
  */
36
37
  reconnect?: boolean;
38
+ /**
39
+ * Rewrite native `#private` class members to stable `Symbol.for` keys in
40
+ * dev so classes using them can be hot-patched in place. This trades real
41
+ * privacy and brand checks for working HMR, in dev only; builds are never
42
+ * touched. Defaults to `true`.
43
+ */
44
+ privateFields?: boolean;
37
45
  /**
38
46
  * What to do when a component can't be hot-patched in place (e.g.
39
47
  * standard `accessor` decorators). Defaults to `'reload'`.
40
48
  */
41
49
  onIncompatible?: 'reload' | 'warn';
50
+ /**
51
+ * What happens to custom elements inside a template whose text a hot patch
52
+ * changed. lit-html clones fresh DOM for the edited template, so those
53
+ * elements are re-created.
54
+ *
55
+ * - `'reset'`: they start over from their defaults.
56
+ * - `'transfer'`: each new element takes the old one's reactive properties
57
+ * and `#private` state (keys the new template binds or sets as an
58
+ * attribute keep the template's value).
59
+ * - `'reuse'`: where the new element carries no bindings, the old element
60
+ * (identity, shadow DOM, controllers) is put back in its place; elsewhere
61
+ * as `'transfer'`.
62
+ *
63
+ * Defaults to `'transfer'`.
64
+ */
65
+ childState?: ChildStateMode;
42
66
  /**
43
67
  * The on-page update indicator. `true` enables it without a count; an
44
68
  * object configures it. Forced off when HMR itself is disabled. Defaults
@@ -106,7 +130,9 @@ export interface LitPluginOptions {
106
130
  export interface ResolvedOptions {
107
131
  hmrEnabled: boolean;
108
132
  reconnect: boolean;
133
+ privateFields: boolean;
109
134
  onIncompatible: 'reload' | 'warn';
135
+ childState: ChildStateMode;
110
136
  indicator: false | {
111
137
  count: boolean;
112
138
  };
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/lib/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EACV,eAAe,EAEf,cAAc,EACf,MAAM,sBAAsB,CAAC;AAG9B;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAEnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC;CAC3C;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,MA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G,oBAAoB,CAAC;IAC5C,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,OAAO,EAAE,cAAc,CAAC;CACzB;AAED,8CAA8C;AAC9C,eAAO,MAAM,UAAU,eAAe,CAAC;AAmEvC;;;GAGG;AACH,eAAO,MAAM,cAAc,YAChB,gBAAgB,OACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC1B,eAkHF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,MAAO,eAAe,KAAG,eAsBtD,CAAC"}
package/lib/options.js CHANGED
@@ -8,6 +8,7 @@ const CSS_SHEET_BUILD_MODES = ['auto', 'url', 'inline', 'inline-raw'];
8
8
  /** Env var prefix consumed at config time. */
9
9
  export const ENV_PREFIX = 'LIT_PLUGIN';
10
10
  const ON_INCOMPATIBLE_MODES = ['reload', 'warn'];
11
+ const CHILD_STATE_MODES = ['reset', 'transfer', 'reuse'];
11
12
  /** Parse a boolean-ish env string; `undefined` when unset/unrecognized. */
12
13
  const envBool = (v) =>
13
14
  v === 'true' || v === '1'
@@ -64,6 +65,11 @@ export const resolveOptions = (options, env) => {
64
65
  envBool(env[`${ENV_PREFIX}_HMR_RECONNECT`]),
65
66
  false
66
67
  );
68
+ const privateFields = pick(
69
+ hmrObj?.privateFields,
70
+ envBool(env[`${ENV_PREFIX}_HMR_PRIVATE_FIELDS`]),
71
+ true
72
+ );
67
73
  const onIncompatible = pick(
68
74
  hmrObj?.onIncompatible,
69
75
  envEnum(
@@ -73,6 +79,15 @@ export const resolveOptions = (options, env) => {
73
79
  ),
74
80
  'reload'
75
81
  );
82
+ const childState = pick(
83
+ hmrObj?.childState,
84
+ envEnum(
85
+ env[`${ENV_PREFIX}_HMR_CHILD_STATE`],
86
+ CHILD_STATE_MODES,
87
+ `${ENV_PREFIX}_HMR_CHILD_STATE`
88
+ ),
89
+ 'transfer'
90
+ );
76
91
  const ind = hmrObj?.indicator;
77
92
  const indObj = typeof ind === 'object' ? ind : undefined;
78
93
  const indEnabled = pick(
@@ -91,6 +106,7 @@ export const resolveOptions = (options, env) => {
91
106
  const sources = {
92
107
  hmrReconnect: reconnect.source,
93
108
  hmrOnIncompatible: onIncompatible.source,
109
+ hmrChildState: childState.source,
94
110
  hmrIndicatorVisible: indEnabled.source,
95
111
  hmrIndicatorCount: indCount.source,
96
112
  };
@@ -136,7 +152,9 @@ export const resolveOptions = (options, env) => {
136
152
  return {
137
153
  hmrEnabled,
138
154
  reconnect: reconnect.value,
155
+ privateFields: privateFields.value,
139
156
  onIncompatible: onIncompatible.value,
157
+ childState: childState.value,
140
158
  indicator,
141
159
  sourceOverlay,
142
160
  timeline,
@@ -158,6 +176,7 @@ export const toFeatureSettings = (r) => {
158
176
  enabled: r.hmrEnabled,
159
177
  reconnect: r.reconnect,
160
178
  onIncompatible: r.onIncompatible,
179
+ childState: r.childState,
161
180
  indicatorEnabled: r.indicator !== false,
162
181
  indicatorCount: r.indicator !== false && r.indicator.count,
163
182
  },
@@ -1 +1 @@
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;AAmEF,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,KAAK;QACP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E;IACvE,MAAM,EAAE,GAAG,CAAC,CAAC,aAAa,CAAC;IAC3B,MAAM,MAAM,GAAG,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,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;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"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/lib/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAC;AAuFpE,MAAM,qBAAqB,GAA6B;IACtD,MAAM;IACN,KAAK;IACL,QAAQ;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C,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;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';\nimport type {ChildStateMode} from './runtime/child-state.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 * Rewrite native `#private` class members to stable `Symbol.for` keys in\n * dev so classes using them can be hot-patched in place. This trades real\n * privacy and brand checks for working HMR, in dev only; builds are never\n * touched. Defaults to `true`.\n */\n privateFields?: boolean;\n\n /**\n * What to do when a component can't be hot-patched in place (e.g.\n * standard `accessor` decorators). Defaults to `'reload'`.\n */\n onIncompatible?: 'reload' | 'warn';\n\n /**\n * What happens to custom elements inside a template whose text a hot patch\n * changed. lit-html clones fresh DOM for the edited template, so those\n * elements are re-created.\n *\n * - `'reset'`: they start over from their defaults.\n * - `'transfer'`: each new element takes the old one's reactive properties\n * and `#private` state (keys the new template binds or sets as an\n * attribute keep the template's value).\n * - `'reuse'`: where the new element carries no bindings, the old element\n * (identity, shadow DOM, controllers) is put back in its place; elsewhere\n * as `'transfer'`.\n *\n * Defaults to `'transfer'`.\n */\n childState?: ChildStateMode;\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 privateFields: boolean;\n onIncompatible: 'reload' | 'warn';\n childState: ChildStateMode;\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\nconst CHILD_STATE_MODES: readonly ChildStateMode[] = [\n 'reset',\n 'transfer',\n 'reuse',\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 privateFields = pick(\n hmrObj?.privateFields,\n envBool(env[`${ENV_PREFIX}_HMR_PRIVATE_FIELDS`]),\n true\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 const childState = pick<ChildStateMode>(\n hmrObj?.childState,\n envEnum(\n env[`${ENV_PREFIX}_HMR_CHILD_STATE`],\n CHILD_STATE_MODES,\n `${ENV_PREFIX}_HMR_CHILD_STATE`\n ),\n 'transfer'\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 hmrChildState: childState.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 privateFields: privateFields.value,\n onIncompatible: onIncompatible.value,\n childState: childState.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 childState: r.childState,\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"]}
@@ -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,EAuRhE,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;AAWtB,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,EAyRhE,CAAC"}
package/lib/plugin.js CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  import {litCssQueries} from './plugins/css-queries.js';
20
20
  import {litTimelineVirtual} from './plugins/timeline-virtual.js';
21
21
  import {litCssLiterals} from './plugins/css-literals.js';
22
+ import {litPrivateFields} from './plugins/private-fields.js';
22
23
  import {resolveRuntimeModule, JS_FILE_RE} from './plugins/shared.js';
23
24
  export {createOpenInEditorMiddleware} from './plugins/open-in-editor.js';
24
25
  export {litCssQueries} from './plugins/css-queries.js';
@@ -179,6 +180,7 @@ export const litPlugin = (options = {}) => {
179
180
  const runtimeOptions = {
180
181
  reconnect: resolved.reconnect,
181
182
  onIncompatible: resolved.onIncompatible,
183
+ childState: resolved.childState,
182
184
  };
183
185
  return {
184
186
  code:
@@ -274,6 +276,7 @@ export const litPlugin = (options = {}) => {
274
276
  litCssQueries(() => resolved.cssSheetBuild),
275
277
  litTimelineVirtual(() => resolved.timeline),
276
278
  litCssLiterals(),
279
+ litPrivateFields(() => resolved.hmrEnabled && resolved.privateFields),
277
280
  sourceOverlayPlugin,
278
281
  hmr,
279
282
  ];
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,WAA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C;YACL,CAAC;YAED,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5C,CAAC;KACF,CAAC;IACF,wEAAwE;IACxE,0EAA0E;IAC1E,2CAA2C;IAC3C,MAAM,OAAO,GAAa;QACxB,aAAa;QACb,2EAA2E;QAC3E,4EAA4E;QAC5E,aAAa,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,aAAa,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
+ {"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,EAC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C;QAC3C,kBAAkB,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC3C,cAAc,EAAE;QAChB,gBAAgB,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,IAAI,QAAQ,CAAC,aAAa,CAAC;QACrE,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 {litPrivateFields} from './plugins/private-fields.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 childState: resolved.childState,\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 litPrivateFields(() => resolved.hmrEnabled && resolved.privateFields),\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"]}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ import type { Plugin } from 'vite';
7
+ import MagicString from 'magic-string';
8
+ /**
9
+ * Rewrites native `#private` class members into computed keys backed by
10
+ * `Symbol.for(...)`. The key is stable across re-evaluations of the module,
11
+ * so instances built by an earlier evaluation of a class and methods copied
12
+ * from a later one agree on where private state lives. That is what lets HMR
13
+ * patch a class in place. Returns `null` when there is nothing to rewrite or
14
+ * the module can't be handled safely.
15
+ */
16
+ export declare const rewritePrivateNames: (code: string, id: string) => {
17
+ code: string;
18
+ map: ReturnType<MagicString['generateMap']>;
19
+ } | null;
20
+ /**
21
+ * Dev-only transform that swaps native `#private` class members for stable
22
+ * symbol keys so HMR's in-place class patching keeps working. See
23
+ * {@link rewritePrivateNames}. `enabled` is read lazily because options are
24
+ * re-resolved against the loaded env after the plugin array is built.
25
+ */
26
+ export declare const litPrivateFields: (enabled: () => boolean) => Plugin;
27
+ //# sourceMappingURL=private-fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-fields.d.ts","sourceRoot":"","sources":["../../src/lib/plugins/private-fields.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAEjC,OAAO,WAAW,MAAM,cAAc,CAAC;AAwCvC;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,MACR,MAAM,KACT;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAA;CAAC,GAAG,IA4NhE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,YAAa,MAAM,OAAO,KAAG,MAgBxD,CAAC"}