@oddsquad/vite-plugin-lit 0.0.3 → 0.1.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 (175) hide show
  1. package/index.d.ts +3 -2
  2. package/index.d.ts.map +1 -1
  3. package/index.js +1 -1
  4. package/index.js.map +1 -1
  5. package/lib/color-scheme.d.ts +30 -0
  6. package/lib/color-scheme.d.ts.map +1 -0
  7. package/lib/color-scheme.js +41 -0
  8. package/lib/color-scheme.js.map +1 -0
  9. package/lib/icons.d.ts +18 -0
  10. package/lib/icons.d.ts.map +1 -0
  11. package/lib/icons.js +23 -0
  12. package/lib/icons.js.map +1 -0
  13. package/lib/plugin.d.ts +117 -6
  14. package/lib/plugin.d.ts.map +1 -1
  15. package/lib/plugin.js +596 -20
  16. package/lib/plugin.js.map +1 -1
  17. package/lib/runtime/css.d.ts +94 -0
  18. package/lib/runtime/css.d.ts.map +1 -0
  19. package/lib/runtime/css.js +112 -0
  20. package/lib/runtime/css.js.map +1 -0
  21. package/lib/runtime/edge-panel.d.ts +18 -0
  22. package/lib/runtime/edge-panel.d.ts.map +1 -0
  23. package/lib/runtime/edge-panel.js +130 -0
  24. package/lib/runtime/edge-panel.js.map +1 -0
  25. package/lib/runtime/fonts.d.ts +18 -0
  26. package/lib/runtime/fonts.d.ts.map +1 -0
  27. package/lib/runtime/fonts.js +18 -0
  28. package/lib/runtime/fonts.js.map +1 -0
  29. package/lib/runtime/indicator.d.ts +7 -0
  30. package/lib/runtime/indicator.d.ts.map +1 -0
  31. package/lib/runtime/indicator.js +141 -0
  32. package/lib/runtime/indicator.js.map +1 -0
  33. package/lib/runtime/inspector/collect.d.ts +17 -0
  34. package/lib/runtime/inspector/collect.d.ts.map +1 -0
  35. package/lib/runtime/inspector/collect.js +132 -0
  36. package/lib/runtime/inspector/collect.js.map +1 -0
  37. package/lib/runtime/inspector/install.d.ts +7 -0
  38. package/lib/runtime/inspector/install.d.ts.map +1 -0
  39. package/lib/runtime/inspector/install.js +204 -0
  40. package/lib/runtime/inspector/install.js.map +1 -0
  41. package/lib/runtime/inspector/serialize.d.ts +10 -0
  42. package/lib/runtime/inspector/serialize.d.ts.map +1 -0
  43. package/lib/runtime/inspector/serialize.js +133 -0
  44. package/lib/runtime/inspector/serialize.js.map +1 -0
  45. package/lib/runtime/intern.d.ts.map +1 -1
  46. package/lib/runtime/intern.js +1 -1
  47. package/lib/runtime/intern.js.map +1 -1
  48. package/lib/runtime/overrides.d.ts +25 -0
  49. package/lib/runtime/overrides.d.ts.map +1 -0
  50. package/lib/runtime/overrides.js +33 -0
  51. package/lib/runtime/overrides.js.map +1 -0
  52. package/lib/runtime/patch.d.ts +6 -15
  53. package/lib/runtime/patch.d.ts.map +1 -1
  54. package/lib/runtime/patch.js +81 -28
  55. package/lib/runtime/patch.js.map +1 -1
  56. package/lib/runtime/source-meta.d.ts +16 -0
  57. package/lib/runtime/source-meta.d.ts.map +1 -0
  58. package/lib/runtime/source-meta.js +8 -0
  59. package/lib/runtime/source-meta.js.map +1 -0
  60. package/lib/runtime/source-overlay/editors.d.ts +9 -0
  61. package/lib/runtime/source-overlay/editors.d.ts.map +1 -0
  62. package/lib/runtime/source-overlay/editors.js +40 -0
  63. package/lib/runtime/source-overlay/editors.js.map +1 -0
  64. package/lib/runtime/source-overlay/mask-path.d.ts +7 -0
  65. package/lib/runtime/source-overlay/mask-path.d.ts.map +1 -0
  66. package/lib/runtime/source-overlay/mask-path.js +26 -0
  67. package/lib/runtime/source-overlay/mask-path.js.map +1 -0
  68. package/lib/runtime/source-overlay/overlay-element.d.ts +18 -0
  69. package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -0
  70. package/lib/runtime/source-overlay/overlay-element.js +381 -0
  71. package/lib/runtime/source-overlay/overlay-element.js.map +1 -0
  72. package/lib/runtime/source-overlay/source-host.d.ts +14 -0
  73. package/lib/runtime/source-overlay/source-host.d.ts.map +1 -0
  74. package/lib/runtime/source-overlay/source-host.js +94 -0
  75. package/lib/runtime/source-overlay/source-host.js.map +1 -0
  76. package/lib/runtime/source-overlay/template.d.ts +7 -0
  77. package/lib/runtime/source-overlay/template.d.ts.map +1 -0
  78. package/lib/runtime/source-overlay/template.js +125 -0
  79. package/lib/runtime/source-overlay/template.js.map +1 -0
  80. package/lib/runtime/source-overlay.d.ts +7 -0
  81. package/lib/runtime/source-overlay.d.ts.map +1 -0
  82. package/lib/runtime/source-overlay.js +11 -0
  83. package/lib/runtime/source-overlay.js.map +1 -0
  84. package/lib/runtime/timeline/clock.d.ts +10 -0
  85. package/lib/runtime/timeline/clock.d.ts.map +1 -0
  86. package/lib/runtime/timeline/clock.js +22 -0
  87. package/lib/runtime/timeline/clock.js.map +1 -0
  88. package/lib/runtime/timeline/identity.d.ts +37 -0
  89. package/lib/runtime/timeline/identity.d.ts.map +1 -0
  90. package/lib/runtime/timeline/identity.js +73 -0
  91. package/lib/runtime/timeline/identity.js.map +1 -0
  92. package/lib/runtime/timeline/input.d.ts +16 -0
  93. package/lib/runtime/timeline/input.d.ts.map +1 -0
  94. package/lib/runtime/timeline/input.js +87 -0
  95. package/lib/runtime/timeline/input.js.map +1 -0
  96. package/lib/runtime/timeline/install.d.ts +7 -0
  97. package/lib/runtime/timeline/install.d.ts.map +1 -0
  98. package/lib/runtime/timeline/install.js +69 -0
  99. package/lib/runtime/timeline/install.js.map +1 -0
  100. package/lib/runtime/timeline/lifecycle.d.ts +27 -0
  101. package/lib/runtime/timeline/lifecycle.d.ts.map +1 -0
  102. package/lib/runtime/timeline/lifecycle.js +225 -0
  103. package/lib/runtime/timeline/lifecycle.js.map +1 -0
  104. package/lib/runtime/timeline/public-api.d.ts +28 -0
  105. package/lib/runtime/timeline/public-api.d.ts.map +1 -0
  106. package/lib/runtime/timeline/public-api.js +44 -0
  107. package/lib/runtime/timeline/public-api.js.map +1 -0
  108. package/lib/runtime/timeline/render.d.ts +39 -0
  109. package/lib/runtime/timeline/render.d.ts.map +1 -0
  110. package/lib/runtime/timeline/render.js +109 -0
  111. package/lib/runtime/timeline/render.js.map +1 -0
  112. package/lib/runtime/timeline/transport.d.ts +42 -0
  113. package/lib/runtime/timeline/transport.d.ts.map +1 -0
  114. package/lib/runtime/timeline/transport.js +86 -0
  115. package/lib/runtime/timeline/transport.js.map +1 -0
  116. package/lib/segmented-tabs.d.ts +33 -0
  117. package/lib/segmented-tabs.d.ts.map +1 -0
  118. package/lib/segmented-tabs.js +129 -0
  119. package/lib/segmented-tabs.js.map +1 -0
  120. package/lib/source-meta.d.ts +26 -0
  121. package/lib/source-meta.d.ts.map +1 -0
  122. package/lib/source-meta.js +129 -0
  123. package/lib/source-meta.js.map +1 -0
  124. package/lib/timeline-plugin.d.ts +72 -0
  125. package/lib/timeline-plugin.d.ts.map +1 -0
  126. package/lib/timeline-plugin.js +376 -0
  127. package/lib/timeline-plugin.js.map +1 -0
  128. package/lib/tokens.d.ts +38 -0
  129. package/lib/tokens.d.ts.map +1 -0
  130. package/lib/tokens.js +263 -0
  131. package/lib/tokens.js.map +1 -0
  132. package/lib/transform.d.ts +5 -5
  133. package/lib/transform.d.ts.map +1 -1
  134. package/lib/transform.js +3 -3
  135. package/lib/transform.js.map +1 -1
  136. package/lib/types.d.ts +34 -0
  137. package/lib/types.d.ts.map +1 -0
  138. package/lib/types.js +7 -0
  139. package/lib/types.js.map +1 -0
  140. package/lib/wrap-table.d.ts.map +1 -1
  141. package/lib/wrap-table.js.map +1 -1
  142. package/package.json +18 -4
  143. package/panel/components-view.d.ts +60 -0
  144. package/panel/components-view.d.ts.map +1 -0
  145. package/panel/components-view.js +581 -0
  146. package/panel/components-view.js.map +1 -0
  147. package/panel/devtools-settings.d.ts +41 -0
  148. package/panel/devtools-settings.d.ts.map +1 -0
  149. package/panel/devtools-settings.js +463 -0
  150. package/panel/devtools-settings.js.map +1 -0
  151. package/panel/index.html +29 -0
  152. package/panel/lit-devtools-panel.d.ts +37 -0
  153. package/panel/lit-devtools-panel.d.ts.map +1 -0
  154. package/panel/lit-devtools-panel.js +183 -0
  155. package/panel/lit-devtools-panel.js.map +1 -0
  156. package/panel/timeline-event-list.d.ts +43 -0
  157. package/panel/timeline-event-list.d.ts.map +1 -0
  158. package/panel/timeline-event-list.js +416 -0
  159. package/panel/timeline-event-list.js.map +1 -0
  160. package/panel/timeline-layers.d.ts +25 -0
  161. package/panel/timeline-layers.d.ts.map +1 -0
  162. package/panel/timeline-layers.js +96 -0
  163. package/panel/timeline-layers.js.map +1 -0
  164. package/panel/timeline-view.d.ts +38 -0
  165. package/panel/timeline-view.d.ts.map +1 -0
  166. package/panel/timeline-view.js +234 -0
  167. package/panel/timeline-view.js.map +1 -0
  168. package/types/inspector.d.ts +130 -0
  169. package/types/inspector.d.ts.map +1 -0
  170. package/types/inspector.js +16 -0
  171. package/types/inspector.js.map +1 -0
  172. package/types/timeline.d.ts +98 -0
  173. package/types/timeline.d.ts.map +1 -0
  174. package/types/timeline.js +39 -0
  175. package/types/timeline.js.map +1 -0
@@ -0,0 +1,133 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * Compact, depth- and breadth-limited previews of arbitrary property values
8
+ * for the inspector details pane. Values cross the transport as plain strings,
9
+ * so this never needs to round-trip — it only has to be readable and safe
10
+ * (circular refs, DOM nodes, functions, huge collections all handled).
11
+ */
12
+ const MAX_DEPTH = 2;
13
+ const MAX_ITEMS = 8;
14
+ const MAX_STRING = 120;
15
+ /** A short type label for the details table's "type" column. */
16
+ export const typeTag = (value) => {
17
+ if (value === null)
18
+ return 'null';
19
+ if (Array.isArray(value))
20
+ return `Array(${value.length})`;
21
+ const t = typeof value;
22
+ if (t !== 'object' && t !== 'function')
23
+ return t;
24
+ if (t === 'function')
25
+ return 'function';
26
+ if (value instanceof Map)
27
+ return `Map(${value.size})`;
28
+ if (value instanceof Set)
29
+ return `Set(${value.size})`;
30
+ if (value instanceof Node)
31
+ return 'Node';
32
+ const name = value.constructor?.name;
33
+ return name !== undefined && name !== 'Object' ? name : 'object';
34
+ };
35
+ const truncate = (s) => s.length > MAX_STRING ? s.slice(0, MAX_STRING) + '…' : s;
36
+ const previewNode = (node) => {
37
+ if (node instanceof Element) {
38
+ const id = node.id ? `#${node.id}` : '';
39
+ return `<${node.tagName.toLowerCase()}${id}>`;
40
+ }
41
+ return `#${node.nodeName.toLowerCase()}`;
42
+ };
43
+ const serializeAt = (value, depth, seen) => {
44
+ if (value === null)
45
+ return 'null';
46
+ if (value === undefined)
47
+ return 'undefined';
48
+ const t = typeof value;
49
+ if (t === 'string')
50
+ return JSON.stringify(truncate(value));
51
+ if (t === 'number' || t === 'boolean')
52
+ return String(value);
53
+ if (t === 'bigint')
54
+ return `${value}n`;
55
+ if (t === 'symbol')
56
+ return value.toString();
57
+ if (t === 'function') {
58
+ const name = value.name;
59
+ return name ? `ƒ ${name}()` : 'ƒ ()';
60
+ }
61
+ const obj = value;
62
+ if (seen.has(obj))
63
+ return '[Circular]';
64
+ if (value instanceof Node)
65
+ return previewNode(value);
66
+ if (value instanceof Date)
67
+ return value.toISOString();
68
+ if (value instanceof RegExp)
69
+ return String(value);
70
+ if (value instanceof Map)
71
+ return `Map(${value.size})`;
72
+ if (value instanceof Set)
73
+ return `Set(${value.size})`;
74
+ if (depth >= MAX_DEPTH) {
75
+ return Array.isArray(value) ? `Array(${value.length})` : typeTag(value);
76
+ }
77
+ // Typed arrays are indexable but not `Array.isArray`; routing them through
78
+ // the generic object branch would make `Object.keys` materialize every index
79
+ // (e.g. a million-element Uint8Array) before slicing. Handle them as arrays.
80
+ if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {
81
+ const arr = value;
82
+ const shown = Math.min(arr.length, MAX_ITEMS);
83
+ const items = [];
84
+ for (let i = 0; i < shown; i++)
85
+ items.push(String(arr[i]));
86
+ if (arr.length > MAX_ITEMS)
87
+ items.push(`…+${arr.length - MAX_ITEMS}`);
88
+ return `${obj.constructor?.name ?? 'TypedArray'}(${arr.length}) [${items.join(', ')}]`;
89
+ }
90
+ seen.add(obj);
91
+ try {
92
+ if (Array.isArray(value)) {
93
+ const items = value
94
+ .slice(0, MAX_ITEMS)
95
+ .map((v) => serializeAt(v, depth + 1, seen));
96
+ if (value.length > MAX_ITEMS)
97
+ items.push(`…+${value.length - MAX_ITEMS}`);
98
+ return `[${items.join(', ')}]`;
99
+ }
100
+ // Read each property individually (keys, not entries) so a single throwing
101
+ // getter degrades to a placeholder instead of aborting the whole preview.
102
+ const keys = Object.keys(value);
103
+ const parts = keys.slice(0, MAX_ITEMS).map((k) => {
104
+ let v;
105
+ try {
106
+ v = value[k];
107
+ }
108
+ catch {
109
+ return `${k}: [getter threw]`;
110
+ }
111
+ return `${k}: ${serializeAt(v, depth + 1, seen)}`;
112
+ });
113
+ if (keys.length > MAX_ITEMS) {
114
+ parts.push(`…+${keys.length - MAX_ITEMS}`);
115
+ }
116
+ const name = obj.constructor?.name;
117
+ const prefix = name !== undefined && name !== 'Object' ? `${name} ` : '';
118
+ return `${prefix}{${parts.join(', ')}}`;
119
+ }
120
+ finally {
121
+ seen.delete(obj);
122
+ }
123
+ };
124
+ /** Produce a readable one-line preview of `value`. Never throws. */
125
+ export const serialize = (value) => {
126
+ try {
127
+ return serializeAt(value, 0, new WeakSet());
128
+ }
129
+ catch {
130
+ return '[unserializable]';
131
+ }
132
+ };
133
+ //# sourceMappingURL=serialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/inspector/serialize.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,gEAAgE;AAChE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAc,EAAU,EAAE;IAChD,IAAI,KAAK,KA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CAAC,GAAG,CAAC;IAC1C,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAEF,oEAAoE;AACpE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAU,EAAE;IAClD,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,kBAAkB,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Compact, depth- and breadth-limited previews of arbitrary property values\n * for the inspector details pane. Values cross the transport as plain strings,\n * so this never needs to round-trip — it only has to be readable and safe\n * (circular refs, DOM nodes, functions, huge collections all handled).\n */\n\nconst MAX_DEPTH = 2;\nconst MAX_ITEMS = 8;\nconst MAX_STRING = 120;\n\n/** A short type label for the details table's \"type\" column. */\nexport const typeTag = (value: unknown): string => {\n if (value === null) return 'null';\n if (Array.isArray(value)) return `Array(${value.length})`;\n const t = typeof value;\n if (t !== 'object' && t !== 'function') return t;\n if (t === 'function') return 'function';\n if (value instanceof Map) return `Map(${value.size})`;\n if (value instanceof Set) return `Set(${value.size})`;\n if (value instanceof Node) return 'Node';\n const name = (value as object).constructor?.name;\n return name !== undefined && name !== 'Object' ? name : 'object';\n};\n\nconst truncate = (s: string): string =>\n s.length > MAX_STRING ? s.slice(0, MAX_STRING) + '…' : s;\n\nconst previewNode = (node: Node): string => {\n if (node instanceof Element) {\n const id = node.id ? `#${node.id}` : '';\n return `<${node.tagName.toLowerCase()}${id}>`;\n }\n return `#${node.nodeName.toLowerCase()}`;\n};\n\nconst serializeAt = (\n value: unknown,\n depth: number,\n seen: WeakSet<object>\n): string => {\n if (value === null) return 'null';\n if (value === undefined) return 'undefined';\n\n const t = typeof value;\n if (t === 'string') return JSON.stringify(truncate(value as string));\n if (t === 'number' || t === 'boolean') return String(value);\n if (t === 'bigint') return `${value}n`;\n if (t === 'symbol') return (value as symbol).toString();\n if (t === 'function') {\n const name = (value as {name?: string}).name;\n return name ? `ƒ ${name}()` : 'ƒ ()';\n }\n\n const obj = value as object;\n if (seen.has(obj)) return '[Circular]';\n\n if (value instanceof Node) return previewNode(value);\n if (value instanceof Date) return value.toISOString();\n if (value instanceof RegExp) return String(value);\n if (value instanceof Map) return `Map(${value.size})`;\n if (value instanceof Set) return `Set(${value.size})`;\n\n if (depth >= MAX_DEPTH) {\n return Array.isArray(value) ? `Array(${value.length})` : typeTag(value);\n }\n\n // Typed arrays are indexable but not `Array.isArray`; routing them through\n // the generic object branch would make `Object.keys` materialize every index\n // (e.g. a million-element Uint8Array) before slicing. Handle them as arrays.\n if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {\n const arr = value as unknown as {length: number; [i: number]: number};\n const shown = Math.min(arr.length, MAX_ITEMS);\n const items: string[] = [];\n for (let i = 0; i < shown; i++) items.push(String(arr[i]));\n if (arr.length > MAX_ITEMS) items.push(`…+${arr.length - MAX_ITEMS}`);\n return `${obj.constructor?.name ?? 'TypedArray'}(${arr.length}) [${items.join(', ')}]`;\n }\n\n seen.add(obj);\n try {\n if (Array.isArray(value)) {\n const items = value\n .slice(0, MAX_ITEMS)\n .map((v) => serializeAt(v, depth + 1, seen));\n if (value.length > MAX_ITEMS) items.push(`…+${value.length - MAX_ITEMS}`);\n return `[${items.join(', ')}]`;\n }\n // Read each property individually (keys, not entries) so a single throwing\n // getter degrades to a placeholder instead of aborting the whole preview.\n const keys = Object.keys(value as Record<string, unknown>);\n const parts = keys.slice(0, MAX_ITEMS).map((k) => {\n let v: unknown;\n try {\n v = (value as Record<string, unknown>)[k];\n } catch {\n return `${k}: [getter threw]`;\n }\n return `${k}: ${serializeAt(v, depth + 1, seen)}`;\n });\n if (keys.length > MAX_ITEMS) {\n parts.push(`…+${keys.length - MAX_ITEMS}`);\n }\n const name = obj.constructor?.name;\n const prefix = name !== undefined && name !== 'Object' ? `${name} ` : '';\n return `${prefix}{${parts.join(', ')}}`;\n } finally {\n seen.delete(obj);\n }\n};\n\n/** Produce a readable one-line preview of `value`. Never throws. */\nexport const serialize = (value: unknown): string => {\n try {\n return serializeAt(value, 0, new WeakSet());\n } catch {\n return '[unserializable]';\n }\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"intern.d.ts","sourceRoot":"","sources":["../../../../packages/labs/vite-hmr/src/lib/runtime/intern.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuDH;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GACjB,IAAI,MAAM,EACV,SAAS,oBAAoB,KAC5B,oBAoBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,GAClB,CAAC,SAAS,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,KAAK,OAAO,EAExE,KAAK,CAAC,EACN,IAAI,MAAM,KACT,CAE0C,CAAC"}
1
+ {"version":3,"file":"intern.d.ts","sourceRoot":"","sources":["../../../../packages/labs/vite-plugin-lit/src/lib/runtime/intern.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuDH;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GACjB,IAAI,MAAM,EACV,SAAS,oBAAoB,KAC5B,oBAoBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,GAClB,CAAC,SAAS,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,KAAK,OAAO,EAExE,KAAK,CAAC,EACN,IAAI,MAAM,KACT,CAE0C,CAAC"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  // Exactly one intern state per page, even if this module is loaded twice
7
7
  // (e.g. via both an optimized and a raw URL).
8
- const STATE_KEY = Symbol.for('@lit-labs/vite-hmr#intern');
8
+ const STATE_KEY = Symbol.for('@lit-labs/vite-plugin-lit#intern');
9
9
  const getState = () => {
10
10
  const g = globalThis;
11
11
  return (g[STATE_KEY] ??= {
@@ -1 +1 @@
1
- {"version":3,"file":"intern.js","sourceRoot":"","sources":["../../../../packages/labs/vite-hmr/src/lib/runtime/intern.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2BH,yEAAyE;AACzE,8CAA8C;AAC9C,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAE1D,MAAM,QAAQ,GAAG,GAAgB,EAAE;IACjC,MAAM,CAAC,GAAG,UAAgE,CAAC;IAC3E,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK;QACvB,SAAS,EAAE,IAAI,GAAG,EAAE;QACpB,WAAW,EAAE,IAAI,OAAO,EAAE;KAC3B,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,GAAsB,EAAU,EAAE;IAChE,IAAI,GAAG,GAAG,EAAE,GAAG,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IACnC,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC;QACxB,GAAG,IAAI,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;IAChD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,EAAU,EACV,OAA6B,EACP,EAAE;IACxB,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QACvB,CAAC,KAAK,CAAC,OAAO,CAAE,OAA2B,CAAC,GAAG,CAAC,EAChD,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,GAAG,GAAG,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,SAAS,GAAG,OAAO,CAAC;QACpB,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACtC,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC1C,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAGrB,GAAM,EACN,EAAU,EACP,EAAE,CACL,CAAC,CAAC,OAA6B,EAAE,GAAG,MAAe,EAAE,EAAE,CACrD,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,CAAM,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Template-strings interning.\n *\n * lit-html keys its template cache by the object identity of the\n * `TemplateStringsArray`, so when Vite HMR re-executes a module, every\n * template literal produces a fresh array and lit rebuilds the entire DOM\n * subtree. Interning canonicalizes strings arrays by content: unchanged\n * templates keep their identity across re-execution, so only the edited\n * template rebuilds its part.\n *\n * This module is dependency-free and must stay safe to load in any\n * environment (it is injected into user modules in dev).\n */\n\ninterface InternState {\n /** Content key → the canonical (first-seen) strings array. */\n byContent: Map<string, TemplateStringsArray>;\n /**\n * Fast path: per-call-site arrays recur on every render, so after the\n * first lookup we can map them to their canonical array with a single\n * WeakMap hit instead of rebuilding the content key.\n */\n canonicalOf: WeakMap<TemplateStringsArray, TemplateStringsArray>;\n}\n\n// Exactly one intern state per page, even if this module is loaded twice\n// (e.g. via both an optimized and a raw URL).\nconst STATE_KEY = Symbol.for('@lit-labs/vite-hmr#intern');\n\nconst getState = (): InternState => {\n const g = globalThis as unknown as Record<symbol, InternState | undefined>;\n return (g[STATE_KEY] ??= {\n byContent: new Map(),\n canonicalOf: new WeakMap(),\n });\n};\n\n/**\n * Builds a collision-free content key for a strings array.\n *\n * Uses the `raw` chunks (cooked strings derive from raw) with length\n * prefixes so that chunk boundaries can never collide, namespaced per tag\n * type: `html` and `svg` templates with equal content must not share a\n * canonical array, or one shared `Template` would parse SVG as HTML.\n */\nconst contentKey = (ns: string, raw: readonly string[]): string => {\n let key = ns + '\\x00' + raw.length;\n for (const chunk of raw) {\n key += '\\x01' + chunk.length + '\\x01' + chunk;\n }\n return key;\n};\n\n/**\n * Returns the canonical strings array for `strings` within namespace `ns`.\n *\n * The first genuine `TemplateStringsArray` seen for a given content becomes\n * the canonical array; later content-equal arrays map onto it. Non-template\n * input (anything without a `raw` array) passes through untouched so lit\n * can raise its own error.\n */\nexport const intern = (\n ns: string,\n strings: TemplateStringsArray\n): TemplateStringsArray => {\n if (\n !Array.isArray(strings) ||\n !Array.isArray((strings as {raw?: unknown}).raw)\n ) {\n return strings;\n }\n const state = getState();\n const fast = state.canonicalOf.get(strings);\n if (fast !== undefined) {\n return fast;\n }\n const key = contentKey(ns, strings.raw);\n let canonical = state.byContent.get(key);\n if (canonical === undefined) {\n canonical = strings;\n state.byContent.set(key, canonical);\n }\n state.canonicalOf.set(strings, canonical);\n return canonical;\n};\n\n/**\n * Wraps a template tag so its strings argument is interned in `ns`.\n */\nexport const wrapTag = <\n T extends (strings: TemplateStringsArray, ...values: never[]) => unknown,\n>(\n tag: T,\n ns: string\n): T =>\n ((strings: TemplateStringsArray, ...values: never[]) =>\n tag(intern(ns, strings), ...values)) as T;\n"]}
1
+ {"version":3,"file":"intern.js","sourceRoot":"","sources":["../../../../packages/labs/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GAAG,CAAC,CAAC;IACxC,IAAI,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,SAAS,GAAG,OAAO,CAAC;QACpB,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACtC,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC1C,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAGrB,GAAM,EACN,EAAU,EACP,EAAE,CACL,CAAC,CAAC,OAA6B,EAAE,GAAG,MAAe,EAAE,EAAE,CACrD,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,CAAM,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Template-strings interning.\n *\n * lit-html keys its template cache by the object identity of the\n * `TemplateStringsArray`, so when Vite HMR re-executes a module, every\n * template literal produces a fresh array and lit rebuilds the entire DOM\n * subtree. Interning canonicalizes strings arrays by content: unchanged\n * templates keep their identity across re-execution, so only the edited\n * template rebuilds its part.\n *\n * This module is dependency-free and must stay safe to load in any\n * environment (it is injected into user modules in dev).\n */\n\ninterface InternState {\n /** Content key → the canonical (first-seen) strings array. */\n byContent: Map<string, TemplateStringsArray>;\n /**\n * Fast path: per-call-site arrays recur on every render, so after the\n * first lookup we can map them to their canonical array with a single\n * WeakMap hit instead of rebuilding the content key.\n */\n canonicalOf: WeakMap<TemplateStringsArray, TemplateStringsArray>;\n}\n\n// Exactly one intern state per page, even if this module is loaded twice\n// (e.g. via both an optimized and a raw URL).\nconst STATE_KEY = Symbol.for('@lit-labs/vite-plugin-lit#intern');\n\nconst getState = (): InternState => {\n const g = globalThis as unknown as Record<symbol, InternState | undefined>;\n return (g[STATE_KEY] ??= {\n byContent: new Map(),\n canonicalOf: new WeakMap(),\n });\n};\n\n/**\n * Builds a collision-free content key for a strings array.\n *\n * Uses the `raw` chunks (cooked strings derive from raw) with length\n * prefixes so that chunk boundaries can never collide, namespaced per tag\n * type: `html` and `svg` templates with equal content must not share a\n * canonical array, or one shared `Template` would parse SVG as HTML.\n */\nconst contentKey = (ns: string, raw: readonly string[]): string => {\n let key = ns + '\\x00' + raw.length;\n for (const chunk of raw) {\n key += '\\x01' + chunk.length + '\\x01' + chunk;\n }\n return key;\n};\n\n/**\n * Returns the canonical strings array for `strings` within namespace `ns`.\n *\n * The first genuine `TemplateStringsArray` seen for a given content becomes\n * the canonical array; later content-equal arrays map onto it. Non-template\n * input (anything without a `raw` array) passes through untouched so lit\n * can raise its own error.\n */\nexport const intern = (\n ns: string,\n strings: TemplateStringsArray\n): TemplateStringsArray => {\n if (\n !Array.isArray(strings) ||\n !Array.isArray((strings as {raw?: unknown}).raw)\n ) {\n return strings;\n }\n const state = getState();\n const fast = state.canonicalOf.get(strings);\n if (fast !== undefined) {\n return fast;\n }\n const key = contentKey(ns, strings.raw);\n let canonical = state.byContent.get(key);\n if (canonical === undefined) {\n canonical = strings;\n state.byContent.set(key, canonical);\n }\n state.canonicalOf.set(strings, canonical);\n return canonical;\n};\n\n/**\n * Wraps a template tag so its strings argument is interned in `ns`.\n */\nexport const wrapTag = <\n T extends (strings: TemplateStringsArray, ...values: never[]) => unknown,\n>(\n tag: T,\n ns: string\n): T =>\n ((strings: TemplateStringsArray, ...values: never[]) =>\n tag(intern(ns, strings), ...values)) as T;\n"]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * Browser-runtime side of the panel's live setting overrides. Reads the
8
+ * persisted override (written by the panel; same origin) and subscribes to the
9
+ * Vite HMR channel the server rebroadcasts panel changes on.
10
+ */
11
+ import { type SettingsOverride } from '../../types/timeline.js';
12
+ /** Minimal `import.meta.hot` shape we rely on. */
13
+ type Hot = {
14
+ on: (event: string, cb: (data: unknown) => void) => void;
15
+ } | undefined;
16
+ /** Reads the persisted override; `{}` when unset or unparsable. */
17
+ export declare const readOverride: () => SettingsOverride;
18
+ /**
19
+ * Applies the persisted override immediately, then again whenever the panel
20
+ * pushes a change over the HMR channel. `apply` receives the full override
21
+ * object each time and should act only on the fields it owns.
22
+ */
23
+ export declare const subscribeOverride: (hot: Hot, apply: (override: SettingsOverride) => void) => void;
24
+ export {};
25
+ //# sourceMappingURL=overrides.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../../../packages/labs/vite-plugin-lit/src/lib/runtime/overrides.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,kDAAkD;AAClD,KAAK,GAAG,GACJ;IAAC,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAA;CAAC,GAC1D,SAAS,CAAC;AAEd,mEAAmE;AACnE,eAAO,MAAM,YAAY,QAAO,gBAQ/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,GAAG,EACR,OAAO,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,KAC1C,IAKF,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /**
7
+ * Browser-runtime side of the panel's live setting overrides. Reads the
8
+ * persisted override (written by the panel; same origin) and subscribes to the
9
+ * Vite HMR channel the server rebroadcasts panel changes on.
10
+ */
11
+ import { SETTINGS_OVERRIDE_CHANNEL, SETTINGS_OVERRIDE_LS_KEY, } from '../../types/timeline.js';
12
+ /** Reads the persisted override; `{}` when unset or unparsable. */
13
+ export const readOverride = () => {
14
+ try {
15
+ const raw = localStorage.getItem(SETTINGS_OVERRIDE_LS_KEY);
16
+ if (raw !== null)
17
+ return JSON.parse(raw);
18
+ }
19
+ catch {
20
+ // storage unavailable / malformed — fall through to defaults
21
+ }
22
+ return {};
23
+ };
24
+ /**
25
+ * Applies the persisted override immediately, then again whenever the panel
26
+ * pushes a change over the HMR channel. `apply` receives the full override
27
+ * object each time and should act only on the fields it owns.
28
+ */
29
+ export const subscribeOverride = (hot, apply) => {
30
+ apply(readOverride());
31
+ hot?.on(SETTINGS_OVERRIDE_CHANNEL, (data) => apply((data ?? {})));
32
+ };
33
+ //# sourceMappingURL=overrides.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../../../packages/labs/vite-plugin-lit/src/lib/runtime/overrides.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,OAAO,EACL,yBAAyB,EACzB,wBAAwB,GAEzB,MAAM,yBAAyB,CAAC;AAOjC,mEAAmE;AACnE,MAAM,CAAC,MAAM,YAAY,GAAG,GAAqB,EAAE;IACjD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;QAC3D,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,6DAA6D;IAC/D,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,GAAQ,EACR,KAA2C,EACrC,EAAE;IACR,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;IACtB,GAAG,EAAE,EAAE,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC1C,KAAK,CAAC,CAAC,IAAI,IAAI,EAAE,CAAqB,CAAC,CACxC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Browser-runtime side of the panel's live setting overrides. Reads the\n * persisted override (written by the panel; same origin) and subscribes to the\n * Vite HMR channel the server rebroadcasts panel changes on.\n */\n\nimport {\n SETTINGS_OVERRIDE_CHANNEL,\n SETTINGS_OVERRIDE_LS_KEY,\n type SettingsOverride,\n} from '../../types/timeline.js';\n\n/** Minimal `import.meta.hot` shape we rely on. */\ntype Hot =\n | {on: (event: string, cb: (data: unknown) => void) => void}\n | undefined;\n\n/** Reads the persisted override; `{}` when unset or unparsable. */\nexport const readOverride = (): SettingsOverride => {\n try {\n const raw = localStorage.getItem(SETTINGS_OVERRIDE_LS_KEY);\n if (raw !== null) return JSON.parse(raw) as SettingsOverride;\n } catch {\n // storage unavailable / malformed — fall through to defaults\n }\n return {};\n};\n\n/**\n * Applies the persisted override immediately, then again whenever the panel\n * pushes a change over the HMR channel. `apply` receives the full override\n * object each time and should act only on the fields it owns.\n */\nexport const subscribeOverride = (\n hot: Hot,\n apply: (override: SettingsOverride) => void\n): void => {\n apply(readOverride());\n hot?.on(SETTINGS_OVERRIDE_CHANNEL, (data) =>\n apply((data ?? {}) as SettingsOverride)\n );\n};\n"]}
@@ -3,21 +3,6 @@
3
3
  * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
- /**
7
- * In-place custom element class patching.
8
- *
9
- * Vite HMR re-executes an edited component module, which calls
10
- * `customElements.define()` again with a freshly evaluated class. The
11
- * platform registry can't re-define a tag, and live instances keep their
12
- * original prototype chain, so instead of swapping classes we intercept the
13
- * duplicate define and patch the originally-registered class in place:
14
- * copy prototype + static descriptors from the new class onto the old one
15
- * and nudge live instances to re-render.
16
- *
17
- * This module is dependency-free and duck-typed against ReactiveElement so
18
- * it never imports lit (keeps it version-agnostic and safe for non-Lit
19
- * custom elements, which get prototype/static patching only).
20
- */
21
6
  export interface PatchOptions {
22
7
  /**
23
8
  * Cycle `disconnectedCallback()`/`connectedCallback()` on live instances
@@ -30,6 +15,12 @@ export interface PatchOptions {
30
15
  */
31
16
  onIncompatible?: 'reload' | 'warn';
32
17
  }
18
+ /**
19
+ * Syncs own members `source` → `target`: deletes own keys of `target` that
20
+ * vanished from `source`, then copies every own descriptor of `source`.
21
+ * Individual copies are best-effort (non-configurable slots are skipped).
22
+ */
23
+ export declare const syncOwnMembers: (target: object, source: object, skip: ReadonlyArray<PropertyKey>) => void;
33
24
  /**
34
25
  * Installs the `customElements.define` interceptor. Idempotent (per-page
35
26
  * global guard); no-ops in environments without `customElements` (SSR).
@@ -1 +1 @@
1
- {"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../../packages/labs/vite-hmr/src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CACpC;AAuVD;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,UAAS,YAAiB,KAAG,IA8DpD,CAAC"}
1
+ {"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../../packages/labs/vite-plugin-lit/src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuBH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CACpC;AAoDD;;;;GAIG;AAEH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,MAAM,aAAa,CAAC,WAAW,CAAC,SA4BjC,CAAC;AAoSF;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,UAAS,YAAiB,KAAG,IAuEpD,CAAC"}
@@ -3,10 +3,26 @@
3
3
  * Copyright 2026 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
5
  */
6
+ /**
7
+ * In-place custom element class patching.
8
+ *
9
+ * Vite HMR re-executes an edited component module, which calls
10
+ * `customElements.define()` again with a freshly evaluated class. The
11
+ * platform registry can't re-define a tag, and live instances keep their
12
+ * original prototype chain, so instead of swapping classes we intercept the
13
+ * duplicate define and patch the originally-registered class in place:
14
+ * copy prototype + static descriptors from the new class onto the old one
15
+ * and nudge live instances to re-render.
16
+ *
17
+ * This module is dependency-free and duck-typed against ReactiveElement so
18
+ * it never imports lit (keeps it version-agnostic and safe for non-Lit
19
+ * custom elements, which get prototype/static patching only).
20
+ */
21
+ import { subscribeOverride } from './overrides.js';
6
22
  // Exactly one patch state per page, even if this module loads twice.
7
- const STATE_KEY = Symbol.for('@lit-labs/vite-hmr#patch');
23
+ const STATE_KEY = Symbol.for('@lit-labs/vite-plugin-lit#patch');
8
24
  // Brands our lifecycle wrappers so re-instrumentation is idempotent.
9
- const RECORD_BRAND = Symbol.for('@lit-labs/vite-hmr#wrapperRecord');
25
+ const RECORD_BRAND = Symbol.for('@lit-labs/vite-plugin-lit#wrapperRecord');
10
26
  const PROTO_SKIP = ['constructor'];
11
27
  const STATIC_SKIP = ['prototype', 'name', 'length'];
12
28
  const ownKeys = (o) => [
@@ -18,7 +34,8 @@ const ownKeys = (o) => [
18
34
  * vanished from `source`, then copies every own descriptor of `source`.
19
35
  * Individual copies are best-effort (non-configurable slots are skipped).
20
36
  */
21
- const syncOwnMembers = (target, source, skip) => {
37
+ // Exported for unit testing; otherwise module-internal.
38
+ export const syncOwnMembers = (target, source, skip) => {
22
39
  for (const key of ownKeys(target)) {
23
40
  if (skip.includes(key)) {
24
41
  continue;
@@ -105,47 +122,70 @@ const usesStandardDecorators = (ctor) => {
105
122
  if (metadata === undefined || metadata === null) {
106
123
  return false;
107
124
  }
108
- const litPropertyMetadata = globalThis.litPropertyMetadata;
109
- const properties = litPropertyMetadata?.get(metadata);
110
- return properties !== undefined && properties.size > 0;
125
+ // litPropertyMetadata is a Lit internal (not public API). Guard against
126
+ // rename, removal, or shape changes — a false negative here means we try
127
+ // to hot-patch and crash, which is handled by the outer catch in hotPatch.
128
+ try {
129
+ const litPropertyMetadata = globalThis.litPropertyMetadata;
130
+ const properties = litPropertyMetadata?.get(metadata);
131
+ return properties !== undefined && properties.size > 0;
132
+ }
133
+ catch {
134
+ return false;
135
+ }
136
+ };
137
+ /**
138
+ * Resolves a static `elementStyles` array to its constructed `CSSStyleSheet`s.
139
+ * Returns `null` for a non-array or any shimmed sheet (no constructible
140
+ * stylesheet support), so callers can bail rather than adopt a partial list.
141
+ */
142
+ const stylesToSheets = (styles) => {
143
+ if (!Array.isArray(styles))
144
+ return null;
145
+ const sheets = [];
146
+ for (const style of styles) {
147
+ const sheet = style instanceof CSSStyleSheet
148
+ ? style
149
+ : (style?.styleSheet ??
150
+ undefined);
151
+ if (!(sheet instanceof CSSStyleSheet))
152
+ return null;
153
+ sheets.push(sheet);
154
+ }
155
+ return sheets;
111
156
  };
112
157
  /**
113
158
  * Re-adopts constructed stylesheets on an instance's shadow root from the
114
159
  * (just-patched) static `elementStyles`. Local reimplementation — no lit
115
160
  * import. Skips cleanly for light-DOM components and shimmed sheets.
161
+ *
162
+ * `oldSheets` are the sheets the pre-patch class contributed (captured before
163
+ * the static sync). We drop exactly those and append the new set, leaving any
164
+ * sheet adopted imperatively by other code in place rather than clobbering the
165
+ * whole list.
116
166
  */
117
- const readoptStyles = (el) => {
167
+ const readoptStyles = (el, oldSheets) => {
118
168
  const root = el.renderRoot;
119
169
  if (typeof ShadowRoot === 'undefined' || !(root instanceof ShadowRoot)) {
120
170
  return;
121
171
  }
122
- const styles = el.constructor.elementStyles;
123
- if (!Array.isArray(styles)) {
172
+ const sheets = stylesToSheets(el.constructor.elementStyles);
173
+ if (sheets === null) {
124
174
  return;
125
175
  }
126
- const sheets = [];
127
- for (const style of styles) {
128
- const sheet = style instanceof CSSStyleSheet
129
- ? style
130
- : (style?.styleSheet ??
131
- undefined);
132
- if (!(sheet instanceof CSSStyleSheet)) {
133
- // Shimmed sheet (no constructible stylesheet support); bail out
134
- // rather than adopt a partial list.
135
- return;
136
- }
137
- sheets.push(sheet);
138
- }
139
- // Assign (never accumulate): replaces any previously adopted set.
140
- root.adoptedStyleSheets = sheets;
176
+ const drop = new Set(oldSheets);
177
+ const ours = new Set(sheets);
178
+ // Our styles go first, matching Lit's own order (extra sheets appended).
179
+ const preserved = [...root.adoptedStyleSheets].filter((s) => !drop.has(s) && !ours.has(s));
180
+ root.adoptedStyleSheets = [...sheets, ...preserved];
141
181
  };
142
182
  const incompatible = (state, tagName, reason) => {
143
183
  if (state.options.onIncompatible === 'warn') {
144
- console.warn(`[lit-hmr] <${tagName}> can't be hot-patched (${reason}). ` +
184
+ console.warn(`[lit-plugin] <${tagName}> can't be hot-patched (${reason}). ` +
145
185
  `Reload the page to pick up the change.`);
146
186
  }
147
187
  else {
148
- console.info(`[lit-hmr] <${tagName}>: ${reason} — performing full reload.`);
188
+ console.info(`[lit-plugin] <${tagName}>: ${reason} — performing full reload.`);
149
189
  location.reload();
150
190
  }
151
191
  };
@@ -196,6 +236,10 @@ const hotPatch = (state, record, NewClass) => {
196
236
  if (Object.getPrototypeOf(OldClass) !== newStaticParent) {
197
237
  Object.setPrototypeOf(OldClass, newStaticParent);
198
238
  }
239
+ // Capture the sheets the OLD class contributed before the static sync
240
+ // overwrites `elementStyles`, so readoptStyles can drop exactly those and
241
+ // leave imperatively-adopted sheets in place.
242
+ const oldSheets = stylesToSheets(OldClass.elementStyles) ?? [];
199
243
  // 5. Sync own members new → old on the prototype and on statics.
200
244
  syncOwnMembers(OldClass.prototype, NewClass.prototype, PROTO_SKIP);
201
245
  syncOwnMembers(OldClass, NewClass, STATIC_SKIP);
@@ -212,7 +256,7 @@ const hotPatch = (state, record, NewClass) => {
212
256
  });
213
257
  if (oldObserved.length !== newObserved.length ||
214
258
  oldObserved.some((attr, i) => attr !== newObserved[i])) {
215
- console.info(`[lit-hmr] <${record.tagName}> changed observedAttributes; the ` +
259
+ console.info(`[lit-plugin] <${record.tagName}> changed observedAttributes; the ` +
216
260
  `platform registry can't pick this up — reload recommended.`);
217
261
  }
218
262
  // 7. Update live instances.
@@ -249,7 +293,7 @@ const hotPatch = (state, record, NewClass) => {
249
293
  }
250
294
  }
251
295
  }
252
- readoptStyles(el);
296
+ readoptStyles(el, oldSheets);
253
297
  state.generationOf.set(el, record.generation);
254
298
  el.requestUpdate?.();
255
299
  }
@@ -287,6 +331,15 @@ export const install = (options = {}) => {
287
331
  },
288
332
  };
289
333
  g[STATE_KEY] = state;
334
+ // Let the DevTools panel override these behaviours live (and persist across
335
+ // reloads) on top of the config-time defaults above.
336
+ subscribeOverride(import.meta.hot, (o) => {
337
+ if (o.hmrReconnect !== undefined)
338
+ state.options.reconnect = o.hmrReconnect;
339
+ if (o.hmrOnIncompatible !== undefined) {
340
+ state.options.onIncompatible = o.hmrOnIncompatible;
341
+ }
342
+ });
290
343
  const nativeDefine = customElements.define;
291
344
  customElements.define = function (name, ctor, defineOptions) {
292
345
  let record = state.records.get(name);
@@ -1 +1 @@
1
- {"version":3,"file":"patch.js","sourceRoot":"","sources":["../../../../packages/labs/vite-hmr/src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqEH,qEAAqE;AACrE,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AACzD,qEAAqE;AACrE,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAEpE,MAAM,UAAU,GAA+B,CAAC,aAAa,CAAC,CAAC;AAC/D,MAAM,WAAW,GAA+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AI,EAAE,MAAM,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,GAAG;gBACP,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,IAAI;gBACf,SAAS,EAAE,IAAI,GAAG,EAAE;gBACpB,UAAU,EAAE,CAAC;aACd,CAAC;YACF,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAChC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC1C,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,IAAI,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;YAC9B,kDAAkD;YAClD,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAwB,CAAC,CAAC;IACpD,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * In-place custom element class patching.\n *\n * Vite HMR re-executes an edited component module, which calls\n * `customElements.define()` again with a freshly evaluated class. The\n * platform registry can't re-define a tag, and live instances keep their\n * original prototype chain, so instead of swapping classes we intercept the\n * duplicate define and patch the originally-registered class in place:\n * copy prototype + static descriptors from the new class onto the old one\n * and nudge live instances to re-render.\n *\n * This module is dependency-free and duck-typed against ReactiveElement so\n * it never imports lit (keeps it version-agnostic and safe for non-Lit\n * custom elements, which get prototype/static patching only).\n */\n\nexport interface PatchOptions {\n /**\n * Cycle `disconnectedCallback()`/`connectedCallback()` on live instances\n * after a hot patch. Defaults to `false`.\n */\n reconnect?: boolean;\n\n /**\n * What to do when a component can't be hot-patched in place (e.g.\n * standard `accessor` decorators). Defaults to `'reload'`.\n */\n onIncompatible?: 'reload' | 'warn';\n}\n\ninterface ReactiveElementLike extends HTMLElement {\n requestUpdate?: () => void;\n renderRoot?: unknown;\n connectedCallback?: () => void;\n disconnectedCallback?: () => void;\n}\n\n/** Duck-typed view of ReactiveElement constructor statics. */\ninterface ReactiveCtorLike extends CustomElementConstructor {\n finalize?: () => void;\n elementProperties?: Map<PropertyKey, unknown>;\n elementStyles?: ReadonlyArray<unknown>;\n observedAttributes?: readonly string[];\n _initializers?: Array<(element: unknown) => void>;\n}\n\ninterface TagRecord {\n tagName: string;\n canonical: CustomElementConstructor;\n instances: Set<ReactiveElementLike>;\n generation: number;\n}\n\ninterface PatchState {\n records: Map<string, TagRecord>;\n /** Generation a (possibly detached) instance last caught up to. */\n generationOf: WeakMap<ReactiveElementLike, number>;\n options: Required<PatchOptions>;\n}\n\ntype LifecycleName = 'connectedCallback' | 'disconnectedCallback';\n\ninterface BrandedWrapper {\n (this: ReactiveElementLike): void;\n [RECORD_BRAND]?: TagRecord;\n}\n\n// Exactly one patch state per page, even if this module loads twice.\nconst STATE_KEY = Symbol.for('@lit-labs/vite-hmr#patch');\n// Brands our lifecycle wrappers so re-instrumentation is idempotent.\nconst RECORD_BRAND = Symbol.for('@lit-labs/vite-hmr#wrapperRecord');\n\nconst PROTO_SKIP: ReadonlyArray<PropertyKey> = ['constructor'];\nconst STATIC_SKIP: ReadonlyArray<PropertyKey> = ['prototype', 'name', 'length'];\n\nconst ownKeys = (o: object): PropertyKey[] => [\n ...Object.getOwnPropertyNames(o),\n ...Object.getOwnPropertySymbols(o),\n];\n\n/**\n * Syncs own members `source` → `target`: deletes own keys of `target` that\n * vanished from `source`, then copies every own descriptor of `source`.\n * Individual copies are best-effort (non-configurable slots are skipped).\n */\nconst syncOwnMembers = (\n target: object,\n source: object,\n skip: ReadonlyArray<PropertyKey>\n) => {\n for (const key of ownKeys(target)) {\n if (skip.includes(key)) {\n continue;\n }\n if (Object.getOwnPropertyDescriptor(source, key) === undefined) {\n try {\n delete (target as Record<PropertyKey, unknown>)[key];\n } catch {\n // Non-configurable; leave it.\n }\n }\n }\n for (const key of ownKeys(source)) {\n if (skip.includes(key)) {\n continue;\n }\n try {\n Object.defineProperty(\n target,\n key,\n Object.getOwnPropertyDescriptor(source, key)!\n );\n } catch {\n // Non-configurable; leave it.\n }\n }\n};\n\n/**\n * Defines branded `connectedCallback`/`disconnectedCallback` wrappers on the\n * prototype to maintain the live-instance set and generation stamps. Called\n * at first define and again after every patch (descriptor sync replaces or\n * deletes the wrappers).\n */\nconst instrument = (\n state: PatchState,\n proto: object,\n record: TagRecord\n): void => {\n for (const name of [\n 'connectedCallback',\n 'disconnectedCallback',\n ] as const satisfies readonly LifecycleName[]) {\n const own = Object.getOwnPropertyDescriptor(proto, name);\n if ((own?.value as BrandedWrapper | undefined)?.[RECORD_BRAND] === record) {\n continue;\n }\n // May be an own raw function (just copied from the new class), an\n // inherited base implementation, or absent entirely.\n const original = (proto as Record<LifecycleName, (() => void) | undefined>)[\n name\n ];\n const wrapper: BrandedWrapper =\n name === 'connectedCallback'\n ? function (this: ReactiveElementLike) {\n record.instances.add(this);\n const stamp = state.generationOf.get(this);\n if (stamp !== undefined && stamp !== record.generation) {\n // Was detached during one or more patches; catch up.\n this.requestUpdate?.();\n }\n state.generationOf.set(this, record.generation);\n original?.call(this);\n }\n : function (this: ReactiveElementLike) {\n record.instances.delete(this);\n original?.call(this);\n };\n wrapper[RECORD_BRAND] = record;\n try {\n Object.defineProperty(proto, name, {\n value: wrapper,\n writable: true,\n configurable: true,\n });\n } catch {\n // Non-configurable lifecycle slot; tracking degrades gracefully.\n }\n }\n};\n\n/**\n * Detects standard-decorator (`accessor`) reactive properties on the new\n * class. Those close over per-class-evaluation private slots, so copied\n * accessors would brand-check-throw — in-place patching is impossible.\n */\nconst usesStandardDecorators = (ctor: ReactiveCtorLike): boolean => {\n const metadataSymbol = (Symbol as {metadata?: symbol}).metadata;\n if (metadataSymbol === undefined) {\n return false;\n }\n const metadata = Object.getOwnPropertyDescriptor(ctor, metadataSymbol)\n ?.value as object | undefined;\n if (metadata === undefined || metadata === null) {\n return false;\n }\n const litPropertyMetadata = (\n globalThis as {litPropertyMetadata?: WeakMap<object, Map<unknown, unknown>>}\n ).litPropertyMetadata;\n const properties = litPropertyMetadata?.get(metadata);\n return properties !== undefined && properties.size > 0;\n};\n\n/**\n * Re-adopts constructed stylesheets on an instance's shadow root from the\n * (just-patched) static `elementStyles`. Local reimplementation — no lit\n * import. Skips cleanly for light-DOM components and shimmed sheets.\n */\nconst readoptStyles = (el: ReactiveElementLike): void => {\n const root = el.renderRoot;\n if (typeof ShadowRoot === 'undefined' || !(root instanceof ShadowRoot)) {\n return;\n }\n const styles = (el.constructor as ReactiveCtorLike).elementStyles;\n if (!Array.isArray(styles)) {\n return;\n }\n const sheets: CSSStyleSheet[] = [];\n for (const style of styles) {\n const sheet =\n style instanceof CSSStyleSheet\n ? style\n : ((style as {styleSheet?: CSSStyleSheet} | null)?.styleSheet ??\n undefined);\n if (!(sheet instanceof CSSStyleSheet)) {\n // Shimmed sheet (no constructible stylesheet support); bail out\n // rather than adopt a partial list.\n return;\n }\n sheets.push(sheet);\n }\n // Assign (never accumulate): replaces any previously adopted set.\n root.adoptedStyleSheets = sheets;\n};\n\nconst incompatible = (\n state: PatchState,\n tagName: string,\n reason: string\n): void => {\n if (state.options.onIncompatible === 'warn') {\n console.warn(\n `[lit-hmr] <${tagName}> can't be hot-patched (${reason}). ` +\n `Reload the page to pick up the change.`\n );\n } else {\n console.info(`[lit-hmr] <${tagName}>: ${reason} — performing full reload.`);\n location.reload();\n }\n};\n\n/**\n * Patches the originally-registered class for `record.tagName` in place\n * from the freshly evaluated `NewClass`, then updates live instances.\n */\nconst hotPatch = (\n state: PatchState,\n record: TagRecord,\n NewClass: ReactiveCtorLike\n): void => {\n const OldClass = record.canonical as ReactiveCtorLike;\n try {\n // 1. Materialize finalized/elementProperties/elementStyles/\n // __attributeToPropertyMap on the new class before we copy statics.\n if (typeof NewClass.finalize === 'function') {\n NewClass.finalize();\n }\n\n // 2. Standard-decorator `accessor` properties can't be patched in place.\n if (usesStandardDecorators(NewClass)) {\n incompatible(state, record.tagName, 'standard accessor decorators');\n return;\n }\n\n // The platform snapshots observedAttributes at define time; new\n // attribute observations can't take effect without a reload.\n const oldObserved = [...(OldClass.observedAttributes ?? [])];\n const newObserved = [...(NewClass.observedAttributes ?? [])];\n\n // 3. Snapshot reactive property values per live instance through the\n // OLD accessors. Vite serves prod lit in dev (no `development`\n // export condition), where accessor storage keys are unique\n // Symbol()s per class evaluation — without this, state resets.\n const propertyKeys = new Set<PropertyKey>([\n ...(OldClass.elementProperties?.keys() ?? []),\n ...(NewClass.elementProperties?.keys() ?? []),\n ]);\n const snapshots = new Map<ReactiveElementLike, Map<PropertyKey, unknown>>();\n for (const el of record.instances) {\n const values = new Map<PropertyKey, unknown>();\n for (const key of propertyKeys) {\n values.set(key, (el as unknown as Record<PropertyKey, unknown>)[key]);\n }\n snapshots.set(el, values);\n }\n\n // 4. Re-parent prototype chains. Mixins regenerate intermediate classes\n // on every module evaluation, so the parents usually differ.\n const newProtoParent = Object.getPrototypeOf(NewClass.prototype) as object;\n if (Object.getPrototypeOf(OldClass.prototype) !== newProtoParent) {\n Object.setPrototypeOf(OldClass.prototype, newProtoParent);\n }\n const newStaticParent = Object.getPrototypeOf(NewClass) as object;\n if (Object.getPrototypeOf(OldClass) !== newStaticParent) {\n Object.setPrototypeOf(OldClass, newStaticParent);\n }\n\n // 5. Sync own members new → old on the prototype and on statics.\n syncOwnMembers(OldClass.prototype, NewClass.prototype, PROTO_SKIP);\n syncOwnMembers(OldClass, NewClass, STATIC_SKIP);\n\n // 6. The sync replaced/removed our lifecycle wrappers; re-instrument.\n instrument(state, OldClass.prototype, record);\n record.generation++;\n // Module-local `instanceof NewClass` checks keep working against\n // instances of the canonical class.\n Object.defineProperty(NewClass, Symbol.hasInstance, {\n value: (instance: unknown) =>\n typeof instance === 'object' &&\n instance !== null &&\n OldClass.prototype.isPrototypeOf(instance),\n configurable: true,\n });\n\n if (\n oldObserved.length !== newObserved.length ||\n oldObserved.some((attr, i) => attr !== newObserved[i])\n ) {\n console.info(\n `[lit-hmr] <${record.tagName}> changed observedAttributes; the ` +\n `platform registry can't pick this up — reload recommended.`\n );\n }\n\n // 7. Update live instances.\n const newPropertyKeys = NewClass.elementProperties?.keys() ?? [];\n // After the static sync this is the NEW class's initializer list.\n const initializers = OldClass._initializers;\n for (const el of [...record.instances]) {\n if (state.options.reconnect) {\n el.disconnectedCallback?.();\n el.connectedCallback?.();\n }\n // Decorator-created reactive controllers (e.g. @lit/context's\n // @provide/@consume) live in per-class-evaluation closures keyed by\n // instance via addInitializer. Re-running the initializers enrolls\n // live instances in the new closures — without this, the first\n // assignment through a copied accessor throws and we'd full-reload.\n // Controllers from previous evaluations stay attached but inert\n // (everything flows through the newest closures); that's bounded by\n // edit count and dev-only. Runs before the value restore so e.g. a\n // re-created ContextProvider exists when the restore pushes into it.\n if (Array.isArray(initializers)) {\n for (const initialize of initializers) {\n initialize(el);\n }\n }\n const values = snapshots.get(el);\n if (values !== undefined) {\n // Restore through the new accessors — only keys the new class\n // still declares.\n for (const key of newPropertyKeys) {\n if (values.has(key)) {\n (el as unknown as Record<PropertyKey, unknown>)[key] =\n values.get(key);\n }\n }\n }\n readoptStyles(el);\n state.generationOf.set(el, record.generation);\n el.requestUpdate?.();\n }\n } catch (e) {\n incompatible(\n state,\n record.tagName,\n `patching failed: ${e instanceof Error ? e.message : String(e)}`\n );\n }\n};\n\n/**\n * Installs the `customElements.define` interceptor. Idempotent (per-page\n * global guard); no-ops in environments without `customElements` (SSR).\n */\nexport const install = (options: PatchOptions = {}): void => {\n if (typeof customElements === 'undefined') {\n return;\n }\n const g = globalThis as unknown as Record<symbol, PatchState | undefined>;\n const existing = g[STATE_KEY];\n if (existing !== undefined) {\n // Already installed; refresh explicitly-provided options only.\n if (options.reconnect !== undefined) {\n existing.options.reconnect = options.reconnect;\n }\n if (options.onIncompatible !== undefined) {\n existing.options.onIncompatible = options.onIncompatible;\n }\n return;\n }\n const state: PatchState = {\n records: new Map(),\n generationOf: new WeakMap(),\n options: {\n reconnect: options.reconnect ?? false,\n onIncompatible: options.onIncompatible ?? 'reload',\n },\n };\n g[STATE_KEY] = state;\n\n const nativeDefine = customElements.define;\n customElements.define = function (\n this: CustomElementRegistry,\n name: string,\n ctor: CustomElementConstructor,\n defineOptions?: ElementDefinitionOptions\n ) {\n let record = state.records.get(name);\n if (record === undefined && this.get(name) !== undefined) {\n // Defined before install() ran (shouldn't happen — the installer is\n // import-hoisted — but recover gracefully without instance tracking).\n record = {\n tagName: name,\n canonical: this.get(name)!,\n instances: new Set(),\n generation: 0,\n };\n state.records.set(name, record);\n }\n if (record === undefined) {\n record = {\n tagName: name,\n canonical: ctor,\n instances: new Set(),\n generation: 0,\n };\n state.records.set(name, record);\n instrument(state, ctor.prototype, record);\n return nativeDefine.call(this, name, ctor, defineOptions);\n }\n if (ctor === record.canonical) {\n // Same class object re-defined; nothing to patch.\n return;\n }\n hotPatch(state, record, ctor as ReactiveCtorLike);\n };\n};\n"]}
1
+ {"version":3,"file":"patch.js","sourceRoot":"","sources":["../../../../packages/labs/vite-plugin-lit/src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAwDjD,qEAAqE;AACrE,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;AAChE,qEAAqE;AACrE,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;AAE3E,MAAM,UAAU,GAA+B,CAAC,aAAa,CAAC,CAAC;AAC/D,MAAM,WAAW,GAA+B,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEhF,MAAM,OAAO,GAAG,CAAC,CAAS,EAAiB,EAAE,CAAC;IAC5C,GAAG,MAA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AS,EAAE,IAAI,GAAG,EAAE;gBACpB,UAAU,EAAE,CAAC;aACd,CAAC;YACF,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAChC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC1C,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,IAAI,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;YAC9B,kDAAkD;YAClD,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAwB,CAAC,CAAC;IACpD,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * In-place custom element class patching.\n *\n * Vite HMR re-executes an edited component module, which calls\n * `customElements.define()` again with a freshly evaluated class. The\n * platform registry can't re-define a tag, and live instances keep their\n * original prototype chain, so instead of swapping classes we intercept the\n * duplicate define and patch the originally-registered class in place:\n * copy prototype + static descriptors from the new class onto the old one\n * and nudge live instances to re-render.\n *\n * This module is dependency-free and duck-typed against ReactiveElement so\n * it never imports lit (keeps it version-agnostic and safe for non-Lit\n * custom elements, which get prototype/static patching only).\n */\n\nimport {subscribeOverride} from './overrides.js';\n\n/** Minimal `import.meta.hot` shape used to receive live setting overrides. */\ntype HotChannel = {on: (event: string, cb: (data: unknown) => void) => void};\n\nexport interface PatchOptions {\n /**\n * Cycle `disconnectedCallback()`/`connectedCallback()` on live instances\n * after a hot patch. Defaults to `false`.\n */\n reconnect?: boolean;\n\n /**\n * What to do when a component can't be hot-patched in place (e.g.\n * standard `accessor` decorators). Defaults to `'reload'`.\n */\n onIncompatible?: 'reload' | 'warn';\n}\n\ninterface ReactiveElementLike extends HTMLElement {\n requestUpdate?: () => void;\n renderRoot?: unknown;\n connectedCallback?: () => void;\n disconnectedCallback?: () => void;\n}\n\n/** Duck-typed view of ReactiveElement constructor statics. */\ninterface ReactiveCtorLike extends CustomElementConstructor {\n finalize?: () => void;\n elementProperties?: Map<PropertyKey, unknown>;\n elementStyles?: ReadonlyArray<unknown>;\n observedAttributes?: readonly string[];\n _initializers?: Array<(element: unknown) => void>;\n}\n\ninterface TagRecord {\n tagName: string;\n canonical: CustomElementConstructor;\n instances: Set<ReactiveElementLike>;\n generation: number;\n}\n\ninterface PatchState {\n records: Map<string, TagRecord>;\n /** Generation a (possibly detached) instance last caught up to. */\n generationOf: WeakMap<ReactiveElementLike, number>;\n options: Required<PatchOptions>;\n}\n\ntype LifecycleName = 'connectedCallback' | 'disconnectedCallback';\n\ninterface BrandedWrapper {\n (this: ReactiveElementLike): void;\n [RECORD_BRAND]?: TagRecord;\n}\n\n// Exactly one patch state per page, even if this module loads twice.\nconst STATE_KEY = Symbol.for('@lit-labs/vite-plugin-lit#patch');\n// Brands our lifecycle wrappers so re-instrumentation is idempotent.\nconst RECORD_BRAND = Symbol.for('@lit-labs/vite-plugin-lit#wrapperRecord');\n\nconst PROTO_SKIP: ReadonlyArray<PropertyKey> = ['constructor'];\nconst STATIC_SKIP: ReadonlyArray<PropertyKey> = ['prototype', 'name', 'length'];\n\nconst ownKeys = (o: object): PropertyKey[] => [\n ...Object.getOwnPropertyNames(o),\n ...Object.getOwnPropertySymbols(o),\n];\n\n/**\n * Syncs own members `source` → `target`: deletes own keys of `target` that\n * vanished from `source`, then copies every own descriptor of `source`.\n * Individual copies are best-effort (non-configurable slots are skipped).\n */\n// Exported for unit testing; otherwise module-internal.\nexport const syncOwnMembers = (\n target: object,\n source: object,\n skip: ReadonlyArray<PropertyKey>\n) => {\n for (const key of ownKeys(target)) {\n if (skip.includes(key)) {\n continue;\n }\n if (Object.getOwnPropertyDescriptor(source, key) === undefined) {\n try {\n delete (target as Record<PropertyKey, unknown>)[key];\n } catch {\n // Non-configurable; leave it.\n }\n }\n }\n for (const key of ownKeys(source)) {\n if (skip.includes(key)) {\n continue;\n }\n try {\n Object.defineProperty(\n target,\n key,\n Object.getOwnPropertyDescriptor(source, key)!\n );\n } catch {\n // Non-configurable; leave it.\n }\n }\n};\n\n/**\n * Defines branded `connectedCallback`/`disconnectedCallback` wrappers on the\n * prototype to maintain the live-instance set and generation stamps. Called\n * at first define and again after every patch (descriptor sync replaces or\n * deletes the wrappers).\n */\nconst instrument = (\n state: PatchState,\n proto: object,\n record: TagRecord\n): void => {\n for (const name of [\n 'connectedCallback',\n 'disconnectedCallback',\n ] as const satisfies readonly LifecycleName[]) {\n const own = Object.getOwnPropertyDescriptor(proto, name);\n if ((own?.value as BrandedWrapper | undefined)?.[RECORD_BRAND] === record) {\n continue;\n }\n // May be an own raw function (just copied from the new class), an\n // inherited base implementation, or absent entirely.\n const original = (proto as Record<LifecycleName, (() => void) | undefined>)[\n name\n ];\n const wrapper: BrandedWrapper =\n name === 'connectedCallback'\n ? function (this: ReactiveElementLike) {\n record.instances.add(this);\n const stamp = state.generationOf.get(this);\n if (stamp !== undefined && stamp !== record.generation) {\n // Was detached during one or more patches; catch up.\n this.requestUpdate?.();\n }\n state.generationOf.set(this, record.generation);\n original?.call(this);\n }\n : function (this: ReactiveElementLike) {\n record.instances.delete(this);\n original?.call(this);\n };\n wrapper[RECORD_BRAND] = record;\n try {\n Object.defineProperty(proto, name, {\n value: wrapper,\n writable: true,\n configurable: true,\n });\n } catch {\n // Non-configurable lifecycle slot; tracking degrades gracefully.\n }\n }\n};\n\n/**\n * Detects standard-decorator (`accessor`) reactive properties on the new\n * class. Those close over per-class-evaluation private slots, so copied\n * accessors would brand-check-throw — in-place patching is impossible.\n */\nconst usesStandardDecorators = (ctor: ReactiveCtorLike): boolean => {\n const metadataSymbol = (Symbol as {metadata?: symbol}).metadata;\n if (metadataSymbol === undefined) {\n return false;\n }\n const metadata = Object.getOwnPropertyDescriptor(ctor, metadataSymbol)\n ?.value as object | undefined;\n if (metadata === undefined || metadata === null) {\n return false;\n }\n // litPropertyMetadata is a Lit internal (not public API). Guard against\n // rename, removal, or shape changes — a false negative here means we try\n // to hot-patch and crash, which is handled by the outer catch in hotPatch.\n try {\n const litPropertyMetadata = (\n globalThis as {\n litPropertyMetadata?: WeakMap<object, Map<unknown, unknown>>;\n }\n ).litPropertyMetadata;\n const properties = litPropertyMetadata?.get(metadata);\n return properties !== undefined && properties.size > 0;\n } catch {\n return false;\n }\n};\n\n/**\n * Resolves a static `elementStyles` array to its constructed `CSSStyleSheet`s.\n * Returns `null` for a non-array or any shimmed sheet (no constructible\n * stylesheet support), so callers can bail rather than adopt a partial list.\n */\nconst stylesToSheets = (styles: unknown): CSSStyleSheet[] | null => {\n if (!Array.isArray(styles)) return null;\n const sheets: CSSStyleSheet[] = [];\n for (const style of styles) {\n const sheet =\n style instanceof CSSStyleSheet\n ? style\n : ((style as {styleSheet?: CSSStyleSheet} | null)?.styleSheet ??\n undefined);\n if (!(sheet instanceof CSSStyleSheet)) return null;\n sheets.push(sheet);\n }\n return sheets;\n};\n\n/**\n * Re-adopts constructed stylesheets on an instance's shadow root from the\n * (just-patched) static `elementStyles`. Local reimplementation — no lit\n * import. Skips cleanly for light-DOM components and shimmed sheets.\n *\n * `oldSheets` are the sheets the pre-patch class contributed (captured before\n * the static sync). We drop exactly those and append the new set, leaving any\n * sheet adopted imperatively by other code in place rather than clobbering the\n * whole list.\n */\nconst readoptStyles = (\n el: ReactiveElementLike,\n oldSheets: CSSStyleSheet[]\n): void => {\n const root = el.renderRoot;\n if (typeof ShadowRoot === 'undefined' || !(root instanceof ShadowRoot)) {\n return;\n }\n const sheets = stylesToSheets(\n (el.constructor as ReactiveCtorLike).elementStyles\n );\n if (sheets === null) {\n return;\n }\n const drop = new Set(oldSheets);\n const ours = new Set(sheets);\n // Our styles go first, matching Lit's own order (extra sheets appended).\n const preserved = [...root.adoptedStyleSheets].filter(\n (s) => !drop.has(s) && !ours.has(s)\n );\n root.adoptedStyleSheets = [...sheets, ...preserved];\n};\n\nconst incompatible = (\n state: PatchState,\n tagName: string,\n reason: string\n): void => {\n if (state.options.onIncompatible === 'warn') {\n console.warn(\n `[lit-plugin] <${tagName}> can't be hot-patched (${reason}). ` +\n `Reload the page to pick up the change.`\n );\n } else {\n console.info(\n `[lit-plugin] <${tagName}>: ${reason} — performing full reload.`\n );\n location.reload();\n }\n};\n\n/**\n * Patches the originally-registered class for `record.tagName` in place\n * from the freshly evaluated `NewClass`, then updates live instances.\n */\nconst hotPatch = (\n state: PatchState,\n record: TagRecord,\n NewClass: ReactiveCtorLike\n): void => {\n const OldClass = record.canonical as ReactiveCtorLike;\n try {\n // 1. Materialize finalized/elementProperties/elementStyles/\n // __attributeToPropertyMap on the new class before we copy statics.\n if (typeof NewClass.finalize === 'function') {\n NewClass.finalize();\n }\n\n // 2. Standard-decorator `accessor` properties can't be patched in place.\n if (usesStandardDecorators(NewClass)) {\n incompatible(state, record.tagName, 'standard accessor decorators');\n return;\n }\n\n // The platform snapshots observedAttributes at define time; new\n // attribute observations can't take effect without a reload.\n const oldObserved = [...(OldClass.observedAttributes ?? [])];\n const newObserved = [...(NewClass.observedAttributes ?? [])];\n\n // 3. Snapshot reactive property values per live instance through the\n // OLD accessors. Vite serves prod lit in dev (no `development`\n // export condition), where accessor storage keys are unique\n // Symbol()s per class evaluation — without this, state resets.\n const propertyKeys = new Set<PropertyKey>([\n ...(OldClass.elementProperties?.keys() ?? []),\n ...(NewClass.elementProperties?.keys() ?? []),\n ]);\n const snapshots = new Map<ReactiveElementLike, Map<PropertyKey, unknown>>();\n for (const el of record.instances) {\n const values = new Map<PropertyKey, unknown>();\n for (const key of propertyKeys) {\n values.set(key, (el as unknown as Record<PropertyKey, unknown>)[key]);\n }\n snapshots.set(el, values);\n }\n\n // 4. Re-parent prototype chains. Mixins regenerate intermediate classes\n // on every module evaluation, so the parents usually differ.\n const newProtoParent = Object.getPrototypeOf(NewClass.prototype) as object;\n if (Object.getPrototypeOf(OldClass.prototype) !== newProtoParent) {\n Object.setPrototypeOf(OldClass.prototype, newProtoParent);\n }\n const newStaticParent = Object.getPrototypeOf(NewClass) as object;\n if (Object.getPrototypeOf(OldClass) !== newStaticParent) {\n Object.setPrototypeOf(OldClass, newStaticParent);\n }\n\n // Capture the sheets the OLD class contributed before the static sync\n // overwrites `elementStyles`, so readoptStyles can drop exactly those and\n // leave imperatively-adopted sheets in place.\n const oldSheets = stylesToSheets(OldClass.elementStyles) ?? [];\n\n // 5. Sync own members new → old on the prototype and on statics.\n syncOwnMembers(OldClass.prototype, NewClass.prototype, PROTO_SKIP);\n syncOwnMembers(OldClass, NewClass, STATIC_SKIP);\n\n // 6. The sync replaced/removed our lifecycle wrappers; re-instrument.\n instrument(state, OldClass.prototype, record);\n record.generation++;\n // Module-local `instanceof NewClass` checks keep working against\n // instances of the canonical class.\n Object.defineProperty(NewClass, Symbol.hasInstance, {\n value: (instance: unknown) =>\n typeof instance === 'object' &&\n instance !== null &&\n OldClass.prototype.isPrototypeOf(instance),\n configurable: true,\n });\n\n if (\n oldObserved.length !== newObserved.length ||\n oldObserved.some((attr, i) => attr !== newObserved[i])\n ) {\n console.info(\n `[lit-plugin] <${record.tagName}> changed observedAttributes; the ` +\n `platform registry can't pick this up — reload recommended.`\n );\n }\n\n // 7. Update live instances.\n const newPropertyKeys = NewClass.elementProperties?.keys() ?? [];\n // After the static sync this is the NEW class's initializer list.\n const initializers = OldClass._initializers;\n for (const el of [...record.instances]) {\n if (state.options.reconnect) {\n el.disconnectedCallback?.();\n el.connectedCallback?.();\n }\n // Decorator-created reactive controllers (e.g. @lit/context's\n // @provide/@consume) live in per-class-evaluation closures keyed by\n // instance via addInitializer. Re-running the initializers enrolls\n // live instances in the new closures — without this, the first\n // assignment through a copied accessor throws and we'd full-reload.\n // Controllers from previous evaluations stay attached but inert\n // (everything flows through the newest closures); that's bounded by\n // edit count and dev-only. Runs before the value restore so e.g. a\n // re-created ContextProvider exists when the restore pushes into it.\n if (Array.isArray(initializers)) {\n for (const initialize of initializers) {\n initialize(el);\n }\n }\n const values = snapshots.get(el);\n if (values !== undefined) {\n // Restore through the new accessors — only keys the new class\n // still declares.\n for (const key of newPropertyKeys) {\n if (values.has(key)) {\n (el as unknown as Record<PropertyKey, unknown>)[key] =\n values.get(key);\n }\n }\n }\n readoptStyles(el, oldSheets);\n state.generationOf.set(el, record.generation);\n el.requestUpdate?.();\n }\n } catch (e) {\n incompatible(\n state,\n record.tagName,\n `patching failed: ${e instanceof Error ? e.message : String(e)}`\n );\n }\n};\n\n/**\n * Installs the `customElements.define` interceptor. Idempotent (per-page\n * global guard); no-ops in environments without `customElements` (SSR).\n */\nexport const install = (options: PatchOptions = {}): void => {\n if (typeof customElements === 'undefined') {\n return;\n }\n const g = globalThis as unknown as Record<symbol, PatchState | undefined>;\n const existing = g[STATE_KEY];\n if (existing !== undefined) {\n // Already installed; refresh explicitly-provided options only.\n if (options.reconnect !== undefined) {\n existing.options.reconnect = options.reconnect;\n }\n if (options.onIncompatible !== undefined) {\n existing.options.onIncompatible = options.onIncompatible;\n }\n return;\n }\n const state: PatchState = {\n records: new Map(),\n generationOf: new WeakMap(),\n options: {\n reconnect: options.reconnect ?? false,\n onIncompatible: options.onIncompatible ?? 'reload',\n },\n };\n g[STATE_KEY] = state;\n\n // Let the DevTools panel override these behaviours live (and persist across\n // reloads) on top of the config-time defaults above.\n subscribeOverride((import.meta as {hot?: HotChannel}).hot, (o) => {\n if (o.hmrReconnect !== undefined) state.options.reconnect = o.hmrReconnect;\n if (o.hmrOnIncompatible !== undefined) {\n state.options.onIncompatible = o.hmrOnIncompatible;\n }\n });\n\n const nativeDefine = customElements.define;\n customElements.define = function (\n this: CustomElementRegistry,\n name: string,\n ctor: CustomElementConstructor,\n defineOptions?: ElementDefinitionOptions\n ) {\n let record = state.records.get(name);\n if (record === undefined && this.get(name) !== undefined) {\n // Defined before install() ran (shouldn't happen — the installer is\n // import-hoisted — but recover gracefully without instance tracking).\n record = {\n tagName: name,\n canonical: this.get(name)!,\n instances: new Set(),\n generation: 0,\n };\n state.records.set(name, record);\n }\n if (record === undefined) {\n record = {\n tagName: name,\n canonical: ctor,\n instances: new Set(),\n generation: 0,\n };\n state.records.set(name, record);\n instrument(state, ctor.prototype, record);\n return nativeDefine.call(this, name, ctor, defineOptions);\n }\n if (ctor === record.canonical) {\n // Same class object re-defined; nothing to patch.\n return;\n }\n hotPatch(state, record, ctor as ReactiveCtorLike);\n };\n};\n"]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ /** Runtime accessor for injected component source metadata. */
7
+ export declare const SOURCE_META_KEY: unique symbol;
8
+ export interface LitSourceMeta {
9
+ filePath: string;
10
+ lineNumber: number;
11
+ componentName?: string;
12
+ }
13
+ export type CustomElementConstructorWithMeta = CustomElementConstructor & {
14
+ [SOURCE_META_KEY]?: LitSourceMeta;
15
+ };
16
+ //# sourceMappingURL=source-meta.d.ts.map