@oddsquad/vite-plugin-lit 0.2.2 → 0.3.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 (210) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/LICENSE +28 -0
  3. package/README.md +153 -0
  4. package/bin.mjs +154 -0
  5. package/client.d.ts +61 -0
  6. package/dist/client/assets/browser-agent-rpc-BXhoSh1z-BvWe4sTJ.js +69 -0
  7. package/dist/client/assets/browser-agent-rpc-BXhoSh1z-BvWe4sTJ.js.map +1 -0
  8. package/dist/client/assets/index-CFrVgNfS.js +9740 -0
  9. package/dist/client/assets/index-CFrVgNfS.js.map +1 -0
  10. package/{panel → dist/client}/index.html +1 -0
  11. package/index.d.ts.map +1 -1
  12. package/index.js +2 -2
  13. package/index.js.map +1 -1
  14. package/lib/color-scheme.d.ts.map +1 -1
  15. package/lib/color-scheme.js +17 -21
  16. package/lib/color-scheme.js.map +1 -1
  17. package/lib/devframe/definition.d.ts +45 -0
  18. package/lib/devframe/definition.d.ts.map +1 -0
  19. package/lib/devframe/definition.js +547 -0
  20. package/lib/devframe/definition.js.map +1 -0
  21. package/lib/devframe/icon.d.ts +8 -0
  22. package/lib/devframe/icon.d.ts.map +1 -0
  23. package/lib/devframe/icon.js +21 -0
  24. package/lib/devframe/icon.js.map +1 -0
  25. package/lib/devframe/paths.d.ts +12 -0
  26. package/lib/devframe/paths.d.ts.map +1 -0
  27. package/lib/devframe/paths.js +38 -0
  28. package/lib/devframe/paths.js.map +1 -0
  29. package/lib/devframe/protocol.d.ts +218 -0
  30. package/lib/devframe/protocol.d.ts.map +1 -0
  31. package/lib/devframe/protocol.js +76 -0
  32. package/lib/devframe/protocol.js.map +1 -0
  33. package/lib/devframe/source.d.ts +49 -0
  34. package/lib/devframe/source.d.ts.map +1 -0
  35. package/lib/devframe/source.js +23 -0
  36. package/lib/devframe/source.js.map +1 -0
  37. package/lib/devframe/vite.d.ts +116 -0
  38. package/lib/devframe/vite.d.ts.map +1 -0
  39. package/lib/devframe/vite.js +291 -0
  40. package/lib/devframe/vite.js.map +1 -0
  41. package/lib/http.d.ts +29 -0
  42. package/lib/http.d.ts.map +1 -0
  43. package/lib/http.js +35 -0
  44. package/lib/http.js.map +1 -0
  45. package/lib/icons.d.ts +2 -0
  46. package/lib/icons.d.ts.map +1 -1
  47. package/lib/icons.js +10 -4
  48. package/lib/icons.js.map +1 -1
  49. package/lib/plugin.d.ts +15 -4
  50. package/lib/plugin.d.ts.map +1 -1
  51. package/lib/plugin.js +640 -574
  52. package/lib/plugin.js.map +1 -1
  53. package/lib/runtime/css.d.ts +2 -16
  54. package/lib/runtime/css.d.ts.map +1 -1
  55. package/lib/runtime/css.js +43 -36
  56. package/lib/runtime/css.js.map +1 -1
  57. package/lib/runtime/edge-panel.d.ts.map +1 -1
  58. package/lib/runtime/edge-panel.js +82 -91
  59. package/lib/runtime/edge-panel.js.map +1 -1
  60. package/lib/runtime/fonts.d.ts.map +1 -1
  61. package/lib/runtime/fonts.js +1 -1
  62. package/lib/runtime/fonts.js.map +1 -1
  63. package/lib/runtime/indicator.d.ts.map +1 -1
  64. package/lib/runtime/indicator.js +71 -74
  65. package/lib/runtime/indicator.js.map +1 -1
  66. package/lib/runtime/inspector/collect.d.ts.map +1 -1
  67. package/lib/runtime/inspector/collect.js +83 -90
  68. package/lib/runtime/inspector/collect.js.map +1 -1
  69. package/lib/runtime/inspector/highlight.d.ts +16 -0
  70. package/lib/runtime/inspector/highlight.d.ts.map +1 -0
  71. package/lib/runtime/inspector/highlight.js +66 -0
  72. package/lib/runtime/inspector/highlight.js.map +1 -0
  73. package/lib/runtime/inspector/install.d.ts.map +1 -1
  74. package/lib/runtime/inspector/install.js +180 -205
  75. package/lib/runtime/inspector/install.js.map +1 -1
  76. package/lib/runtime/inspector/serialize.d.ts.map +1 -1
  77. package/lib/runtime/inspector/serialize.js +86 -107
  78. package/lib/runtime/inspector/serialize.js.map +1 -1
  79. package/lib/runtime/intern.d.ts.map +1 -1
  80. package/lib/runtime/intern.js +31 -29
  81. package/lib/runtime/intern.js.map +1 -1
  82. package/lib/runtime/overrides.d.ts.map +1 -1
  83. package/lib/runtime/overrides.js +14 -13
  84. package/lib/runtime/overrides.js.map +1 -1
  85. package/lib/runtime/patch.d.ts +8 -0
  86. package/lib/runtime/patch.d.ts.map +1 -1
  87. package/lib/runtime/patch.js +321 -282
  88. package/lib/runtime/patch.js.map +1 -1
  89. package/lib/runtime/source-meta.d.ts.map +1 -1
  90. package/lib/runtime/source-meta.js +1 -1
  91. package/lib/runtime/source-meta.js.map +1 -1
  92. package/lib/runtime/source-overlay/editors.d.ts.map +1 -1
  93. package/lib/runtime/source-overlay/editors.js +27 -27
  94. package/lib/runtime/source-overlay/editors.js.map +1 -1
  95. package/lib/runtime/source-overlay/mask-path.d.ts.map +1 -1
  96. package/lib/runtime/source-overlay/mask-path.js +15 -15
  97. package/lib/runtime/source-overlay/mask-path.js.map +1 -1
  98. package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -1
  99. package/lib/runtime/source-overlay/overlay-element.js +347 -356
  100. package/lib/runtime/source-overlay/overlay-element.js.map +1 -1
  101. package/lib/runtime/source-overlay/source-host.d.ts.map +1 -1
  102. package/lib/runtime/source-overlay/source-host.js +64 -71
  103. package/lib/runtime/source-overlay/source-host.js.map +1 -1
  104. package/lib/runtime/source-overlay/template.d.ts.map +1 -1
  105. package/lib/runtime/source-overlay/template.js +3 -3
  106. package/lib/runtime/source-overlay/template.js.map +1 -1
  107. package/lib/runtime/source-overlay.d.ts.map +1 -1
  108. package/lib/runtime/source-overlay.js +5 -2
  109. package/lib/runtime/source-overlay.js.map +1 -1
  110. package/lib/runtime/timeline/clock.d.ts.map +1 -1
  111. package/lib/runtime/timeline/clock.js +2 -2
  112. package/lib/runtime/timeline/clock.js.map +1 -1
  113. package/lib/runtime/timeline/flash.d.ts +39 -0
  114. package/lib/runtime/timeline/flash.d.ts.map +1 -0
  115. package/lib/runtime/timeline/flash.js +169 -0
  116. package/lib/runtime/timeline/flash.js.map +1 -0
  117. package/lib/runtime/timeline/identity.d.ts.map +1 -1
  118. package/lib/runtime/timeline/identity.js +27 -27
  119. package/lib/runtime/timeline/identity.js.map +1 -1
  120. package/lib/runtime/timeline/input.d.ts.map +1 -1
  121. package/lib/runtime/timeline/input.js +54 -67
  122. package/lib/runtime/timeline/input.js.map +1 -1
  123. package/lib/runtime/timeline/install.d.ts.map +1 -1
  124. package/lib/runtime/timeline/install.js +38 -29
  125. package/lib/runtime/timeline/install.js.map +1 -1
  126. package/lib/runtime/timeline/lifecycle.d.ts +8 -0
  127. package/lib/runtime/timeline/lifecycle.d.ts.map +1 -1
  128. package/lib/runtime/timeline/lifecycle.js +149 -133
  129. package/lib/runtime/timeline/lifecycle.js.map +1 -1
  130. package/lib/runtime/timeline/public-api.d.ts.map +1 -1
  131. package/lib/runtime/timeline/public-api.js +9 -9
  132. package/lib/runtime/timeline/public-api.js.map +1 -1
  133. package/lib/runtime/timeline/render.d.ts.map +1 -1
  134. package/lib/runtime/timeline/render.js +70 -75
  135. package/lib/runtime/timeline/render.js.map +1 -1
  136. package/lib/runtime/timeline/transport.d.ts.map +1 -1
  137. package/lib/runtime/timeline/transport.js +39 -43
  138. package/lib/runtime/timeline/transport.js.map +1 -1
  139. package/lib/segmented-tabs.d.ts +3 -1
  140. package/lib/segmented-tabs.d.ts.map +1 -1
  141. package/lib/segmented-tabs.js +136 -107
  142. package/lib/segmented-tabs.js.map +1 -1
  143. package/lib/snapshot.d.ts +28 -0
  144. package/lib/snapshot.d.ts.map +1 -0
  145. package/lib/snapshot.js +57 -0
  146. package/lib/snapshot.js.map +1 -0
  147. package/lib/source-meta.d.ts.map +1 -1
  148. package/lib/source-meta.js +176 -162
  149. package/lib/source-meta.js.map +1 -1
  150. package/lib/timeline/derive.d.ts +152 -0
  151. package/lib/timeline/derive.d.ts.map +1 -0
  152. package/lib/timeline/derive.js +242 -0
  153. package/lib/timeline/derive.js.map +1 -0
  154. package/lib/timeline-plugin.d.ts.map +1 -1
  155. package/lib/timeline-plugin.js +304 -321
  156. package/lib/timeline-plugin.js.map +1 -1
  157. package/lib/tokens.d.ts.map +1 -1
  158. package/lib/tokens.js +17 -18
  159. package/lib/tokens.js.map +1 -1
  160. package/lib/transform.d.ts.map +1 -1
  161. package/lib/transform.js +62 -57
  162. package/lib/transform.js.map +1 -1
  163. package/lib/types.d.ts.map +1 -1
  164. package/lib/types.js +1 -1
  165. package/lib/types.js.map +1 -1
  166. package/lib/wrap-table.d.ts.map +1 -1
  167. package/lib/wrap-table.js +19 -17
  168. package/lib/wrap-table.js.map +1 -1
  169. package/package.json +77 -13
  170. package/types/hmr-incompatibility.d.ts +59 -0
  171. package/types/hmr-incompatibility.d.ts.map +1 -0
  172. package/types/hmr-incompatibility.js +30 -0
  173. package/types/hmr-incompatibility.js.map +1 -0
  174. package/types/in-page.d.ts +49 -0
  175. package/types/in-page.d.ts.map +1 -0
  176. package/types/in-page.js +33 -0
  177. package/types/in-page.js.map +1 -0
  178. package/types/inspector.d.ts.map +1 -1
  179. package/types/inspector.js.map +1 -1
  180. package/types/snapshot.d.ts +44 -0
  181. package/types/snapshot.d.ts.map +1 -0
  182. package/types/snapshot.js +7 -0
  183. package/types/snapshot.js.map +1 -0
  184. package/types/timeline.d.ts +11 -0
  185. package/types/timeline.d.ts.map +1 -1
  186. package/types/timeline.js.map +1 -1
  187. package/panel/components-view.d.ts +0 -60
  188. package/panel/components-view.d.ts.map +0 -1
  189. package/panel/components-view.js +0 -587
  190. package/panel/components-view.js.map +0 -1
  191. package/panel/devtools-settings.d.ts +0 -41
  192. package/panel/devtools-settings.d.ts.map +0 -1
  193. package/panel/devtools-settings.js +0 -463
  194. package/panel/devtools-settings.js.map +0 -1
  195. package/panel/lit-devtools-panel.d.ts +0 -37
  196. package/panel/lit-devtools-panel.d.ts.map +0 -1
  197. package/panel/lit-devtools-panel.js +0 -185
  198. package/panel/lit-devtools-panel.js.map +0 -1
  199. package/panel/timeline-event-list.d.ts +0 -43
  200. package/panel/timeline-event-list.d.ts.map +0 -1
  201. package/panel/timeline-event-list.js +0 -416
  202. package/panel/timeline-event-list.js.map +0 -1
  203. package/panel/timeline-layers.d.ts +0 -25
  204. package/panel/timeline-layers.d.ts.map +0 -1
  205. package/panel/timeline-layers.js +0 -96
  206. package/panel/timeline-layers.js.map +0 -1
  207. package/panel/timeline-view.d.ts +0 -38
  208. package/panel/timeline-view.d.ts.map +0 -1
  209. package/panel/timeline-view.js +0 -234
  210. package/panel/timeline-view.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/timeline/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoBH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAE9D,KAAK,MAAM,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAC7C,KAAK,WAAW,GAAG,MAAM,OAAO,CAAC;AACjC,KAAK,cAAc,GAAG,MAAM,OAAO,CAAC;AA4KpC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,GAChC,MAAM,MAAM,EACZ,WAAW,WAAW,EACtB,SAAS,cAAc,KACtB,IAyBF,CAAC"}
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoBH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAE9D,KAAK,MAAM,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAC7C,KAAK,WAAW,GAAG,MAAM,OAAO,CAAC;AACjC,KAAK,cAAc,GAAG,MAAM,OAAO,CAAC;AAEpC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAI/D,yEAAyE;AACzE,eAAO,MAAM,aAAa,SAAU,UAAU,GAAG,IAAI,KAAG,IAEvD,CAAC;AAmMF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,SAC1B,MAAM,aACD,WAAW,WACb,cAAc,KACtB,IAyBF,CAAC"}
@@ -18,15 +18,31 @@
18
18
  *
19
19
  * Gated by the recording flag so overhead is near-zero when idle.
20
20
  */
21
- import { idOf, sourceOf, changedKeys } from './identity.js';
22
- import { now } from './clock.js';
21
+ import {idOf, sourceOf, changedKeys} from './identity.js';
22
+ import {now} from './clock.js';
23
+ let updateHook = null;
24
+ /** Install (or clear, with `null`) the per-update hook. One consumer. */
25
+ export const setUpdateHook = (hook) => {
26
+ updateHook = hook;
27
+ };
28
+ /** Runs the update hook, never letting a consumer's throw reach the app. */
29
+ const notifyUpdated = (el, first) => {
30
+ if (updateHook === null) return;
31
+ try {
32
+ updateHook(el, first);
33
+ } catch {
34
+ // dev tool — an overlay bug must not break the app's update cycle
35
+ }
36
+ };
37
+ /** `ReactiveElement.hasUpdated`, read before the update flips it. */
38
+ const isFirstUpdate = (el) => el.hasUpdated !== true;
23
39
  /** Phases to instrument with start/end pairs. */
24
40
  const UPDATE_PHASES = [
25
- 'performUpdate',
26
- 'willUpdate',
27
- 'update',
28
- 'updated',
29
- 'firstUpdated',
41
+ 'performUpdate',
42
+ 'willUpdate',
43
+ 'update',
44
+ 'updated',
45
+ 'firstUpdated',
30
46
  ];
31
47
  /** Point-in-time lifecycle events (no end bracket). */
32
48
  const POINT_PHASES = ['connectedCallback', 'disconnectedCallback'];
@@ -36,99 +52,104 @@ const ticks = new WeakMap();
36
52
  const tickOf = (el) => ticks.get(el) ?? 0;
37
53
  /** Returns true if `proto[name]` is already our wrapper (idempotent install). */
38
54
  const isWrapped = (proto, name) => {
39
- const fn = proto[name];
40
- return (typeof fn === 'function' && fn[BRAND] === true);
55
+ const fn = proto[name];
56
+ return typeof fn === 'function' && fn[BRAND] === true;
41
57
  };
42
58
  /**
43
59
  * Wrap `proto[name]` with a start/end pair emitting to `emit`.
44
60
  * `isPoint` methods only emit a single event (no end bracket).
45
61
  */
46
62
  const wrap = (proto, name, isPoint, emit, recording, enabled) => {
47
- if (isWrapped(proto, name))
48
- return;
49
- const orig = proto[name];
50
- const wrapper = function (...args) {
51
- if (!recording() || !enabled()) {
52
- return orig?.apply(this, args);
53
- }
54
- // Bump the per-instance tick at the *start* of each performUpdate, before
55
- // computing the groupId, so this whole update cycle — performUpdate and the
56
- // willUpdate/update/updated phases it nests — shares one groupId, distinct
57
- // from the previous cycle's. (Reading the tick before bumping put
58
- // performUpdate in a different group from its own phases and let adjacent
59
- // cycles collide on the same tick.)
60
- if (name === 'performUpdate') {
61
- ticks.set(this, tickOf(this) + 1);
62
- }
63
- const elementId = idOf(this);
64
- const tagName = this.localName ?? 'unknown';
65
- const source = sourceOf(this);
66
- const tick = tickOf(this);
67
- const groupId = `${elementId}:${tick}`;
68
- const time = now();
69
- const changed = changedKeys(args[0]);
70
- if (!isPoint) {
71
- emit({
72
- layerId: 'lit-lifecycle',
73
- time,
74
- groupId,
75
- title: name + ':start',
76
- subtitle: tagName,
77
- data: { phase: name, changed },
78
- meta: { elementId, tagName, source },
79
- });
80
- }
81
- let result;
82
- try {
83
- result = orig?.apply(this, args);
84
- }
85
- finally {
86
- if (!isPoint) {
87
- emit({
88
- layerId: 'lit-lifecycle',
89
- time: now(),
90
- groupId,
91
- title: name + ':end',
92
- subtitle: tagName,
93
- data: { phase: name },
94
- meta: { elementId, tagName, source },
95
- });
96
- }
97
- else {
98
- emit({
99
- layerId: 'lit-lifecycle',
100
- time,
101
- title: name,
102
- subtitle: tagName,
103
- data: { phase: name },
104
- meta: { elementId, tagName, source },
105
- });
106
- }
107
- }
108
- return result;
109
- };
110
- wrapper[BRAND] = true;
63
+ if (isWrapped(proto, name)) return;
64
+ const orig = proto[name];
65
+ const wrapper = function (...args) {
66
+ const isUpdate = name === 'performUpdate';
67
+ if (!recording() || !enabled()) {
68
+ if (!isUpdate || updateHook === null) return orig?.apply(this, args);
69
+ const first = isFirstUpdate(this);
70
+ const result = orig?.apply(this, args);
71
+ notifyUpdated(this, first);
72
+ return result;
73
+ }
74
+ const first = isUpdate && isFirstUpdate(this);
75
+ // Bump the per-instance tick at the *start* of each performUpdate, before
76
+ // computing the groupId, so this whole update cycle — performUpdate and the
77
+ // willUpdate/update/updated phases it nests — shares one groupId, distinct
78
+ // from the previous cycle's. (Reading the tick before bumping put
79
+ // performUpdate in a different group from its own phases and let adjacent
80
+ // cycles collide on the same tick.)
81
+ if (name === 'performUpdate') {
82
+ ticks.set(this, tickOf(this) + 1);
83
+ }
84
+ const elementId = idOf(this);
85
+ const tagName = this.localName ?? 'unknown';
86
+ const source = sourceOf(this);
87
+ const tick = tickOf(this);
88
+ const groupId = `${elementId}:${tick}`;
89
+ const time = now();
90
+ const changed = changedKeys(args[0]);
91
+ if (!isPoint) {
92
+ emit({
93
+ layerId: 'lit-lifecycle',
94
+ time,
95
+ groupId,
96
+ title: name + ':start',
97
+ subtitle: tagName,
98
+ data: {phase: name, changed},
99
+ meta: {elementId, tagName, source},
100
+ });
101
+ }
102
+ let result;
111
103
  try {
112
- Object.defineProperty(proto, name, {
113
- value: wrapper,
114
- writable: true,
115
- configurable: true,
104
+ result = orig?.apply(this, args);
105
+ } finally {
106
+ if (!isPoint) {
107
+ emit({
108
+ layerId: 'lit-lifecycle',
109
+ time: now(),
110
+ groupId,
111
+ title: name + ':end',
112
+ subtitle: tagName,
113
+ data: {phase: name},
114
+ meta: {elementId, tagName, source},
116
115
  });
116
+ } else {
117
+ emit({
118
+ layerId: 'lit-lifecycle',
119
+ time,
120
+ title: name,
121
+ subtitle: tagName,
122
+ data: {phase: name},
123
+ meta: {elementId, tagName, source},
124
+ });
125
+ }
117
126
  }
118
- catch {
119
- // Non-configurable slot; instrumentation degrades gracefully.
120
- }
127
+ // After the bracket, not in it: a throwing update never completed, so it
128
+ // doesn't count as one.
129
+ if (isUpdate) notifyUpdated(this, first);
130
+ return result;
131
+ };
132
+ wrapper[BRAND] = true;
133
+ try {
134
+ Object.defineProperty(proto, name, {
135
+ value: wrapper,
136
+ writable: true,
137
+ configurable: true,
138
+ });
139
+ } catch {
140
+ // Non-configurable slot; instrumentation degrades gracefully.
141
+ }
121
142
  };
122
143
  /**
123
144
  * Finds the prototype in `proto`'s chain that *owns* `name` as an own property,
124
145
  * or null if none does.
125
146
  */
126
147
  const ownerOf = (proto, name) => {
127
- let p = proto;
128
- while (p !== null && !Object.prototype.hasOwnProperty.call(p, name)) {
129
- p = Object.getPrototypeOf(p);
130
- }
131
- return p;
148
+ let p = proto;
149
+ while (p !== null && !Object.prototype.hasOwnProperty.call(p, name)) {
150
+ p = Object.getPrototypeOf(p);
151
+ }
152
+ return p;
132
153
  };
133
154
  /**
134
155
  * Returns any defined Lit element's prototype (duck-typed by `performUpdate`),
@@ -143,22 +164,20 @@ const ownerOf = (proto, name) => {
143
164
  * instrumentation at all.
144
165
  */
145
166
  const findLitElementProto = () => {
146
- const registry = customElements._registry;
147
- if (registry !== undefined) {
148
- for (const ctor of Object.values(registry)) {
149
- const proto = ctor?.prototype;
150
- if (proto != null && 'performUpdate' in proto)
151
- return proto;
152
- }
167
+ const registry = customElements._registry;
168
+ if (registry !== undefined) {
169
+ for (const ctor of Object.values(registry)) {
170
+ const proto = ctor?.prototype;
171
+ if (proto != null && 'performUpdate' in proto) return proto;
153
172
  }
154
- if (typeof document !== 'undefined') {
155
- for (const el of document.querySelectorAll('*')) {
156
- const proto = Object.getPrototypeOf(el);
157
- if (proto != null && 'performUpdate' in proto)
158
- return proto;
159
- }
173
+ }
174
+ if (typeof document !== 'undefined') {
175
+ for (const el of document.querySelectorAll('*')) {
176
+ const proto = Object.getPrototypeOf(el);
177
+ if (proto != null && 'performUpdate' in proto) return proto;
160
178
  }
161
- return null;
179
+ }
180
+ return null;
162
181
  };
163
182
  let installed = false;
164
183
  /**
@@ -177,29 +196,28 @@ let installed = false;
177
196
  * Idempotent — wrapping is brand-guarded per prototype+method.
178
197
  */
179
198
  export const installLifecycleLayer = (emit, recording, enabled) => {
180
- if (installed)
181
- return;
182
- installed = true;
183
- // Instrument from a sample already on the page (covers components defined
184
- // before the runtime installed — the common case, since the runtime is
185
- // injected after the app's modules).
186
- const proto = findLitElementProto();
187
- if (proto !== null) {
188
- patchBases(proto, emit, recording, enabled);
199
+ if (installed) return;
200
+ installed = true;
201
+ // Instrument from a sample already on the page (covers components defined
202
+ // before the runtime installed — the common case, since the runtime is
203
+ // injected after the app's modules).
204
+ const proto = findLitElementProto();
205
+ if (proto !== null) {
206
+ patchBases(proto, emit, recording, enabled);
207
+ }
208
+ // Also instrument on future defines — both for components registered later
209
+ // and for the case where none were discoverable above. Kept installed for
210
+ // the page's lifetime; `patchBases` is idempotent (wrapping is brand-guarded
211
+ // per prototype+method), so re-running once the shared bases are wrapped is a
212
+ // cheap no-op.
213
+ const origDefine = customElements.define.bind(customElements);
214
+ customElements.define = (name, ctor, options) => {
215
+ origDefine(name, ctor, options);
216
+ const p = ctor?.prototype;
217
+ if (p != null && 'performUpdate' in p) {
218
+ patchBases(p, emit, recording, enabled);
189
219
  }
190
- // Also instrument on future defines — both for components registered later
191
- // and for the case where none were discoverable above. Kept installed for
192
- // the page's lifetime; `patchBases` is idempotent (wrapping is brand-guarded
193
- // per prototype+method), so re-running once the shared bases are wrapped is a
194
- // cheap no-op.
195
- const origDefine = customElements.define.bind(customElements);
196
- customElements.define = (name, ctor, options) => {
197
- origDefine(name, ctor, options);
198
- const p = ctor?.prototype;
199
- if (p != null && 'performUpdate' in p) {
200
- patchBases(p, emit, recording, enabled);
201
- }
202
- };
220
+ };
203
221
  };
204
222
  /**
205
223
  * Wraps the lifecycle phases on the shared base prototypes reachable from
@@ -210,16 +228,14 @@ export const installLifecycleLayer = (emit, recording, enabled) => {
210
228
  * `render()`), so the timed call is the one that actually runs.
211
229
  */
212
230
  const patchBases = (sample, emit, recording, enabled) => {
213
- const reProto = ownerOf(sample, 'performUpdate');
214
- if (reProto === null)
215
- return;
216
- for (const name of UPDATE_PHASES) {
217
- const owner = name === 'update' ? ownerOf(sample, 'update') : reProto;
218
- if (owner !== null)
219
- wrap(owner, name, false, emit, recording, enabled);
220
- }
221
- for (const name of POINT_PHASES) {
222
- wrap(reProto, name, true, emit, recording, enabled);
223
- }
231
+ const reProto = ownerOf(sample, 'performUpdate');
232
+ if (reProto === null) return;
233
+ for (const name of UPDATE_PHASES) {
234
+ const owner = name === 'update' ? ownerOf(sample, 'update') : reProto;
235
+ if (owner !== null) wrap(owner, name, false, emit, recording, enabled);
236
+ }
237
+ for (const name of POINT_PHASES) {
238
+ wrap(reProto, name, true, emit, recording, enabled);
239
+ }
224
240
  };
225
- //# sourceMappingURL=lifecycle.js.map
241
+ //# sourceMappingURL=lifecycle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/timeline/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAC;AAO/B,iDAAiD;AACjD,MAAM,aAAa,GAAG;IACpB,eAAe;IACf,YAAY;IACZ,QAAQ;IACR,SAAS;IACT,cAAc;CACN,CAAC;AAEX,uDAAuD;AACvD,MAAM,YAAY,GAAG,CAAC,mBAAmB,EAAE,sBAAsB,CAAU,CAAC;AAE5E,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;AAEzE,8EAA8E;AAC9E,MAAM,KAAK,GAAG,IAAI,OAAO,EAAkB,CAAC;AAE5C,MAAM,MAAM,GAAG,CAAC,EAAU,EAAU,EAAE,CAAC,KAAK,C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CAAC,CAAC;IACjD,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO;IAC7B,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACtE,IAAI,KAAK,KAAK,IAAI;YAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;AACH,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * ReactiveElement prototype instrumentation for the lifecycle timeline layer.\n *\n * Wraps the lifecycle methods listed in PHASES on the prototype of the\n * ReactiveElement class loaded by the app — not by importing lit directly,\n * to avoid multi-copy issues. The proto is resolved from the already-defined\n * custom element registry (same mechanism as the HMR patch module).\n *\n * Each wrapped method emits a paired start/end TimelineEvent so the panel\n * can render duration bars. performUpdate brackets the whole update tick and\n * bumps a per-instance tick counter that becomes the groupId shared by all\n * phase events within that tick.\n *\n * Gated by the recording flag so overhead is near-zero when idle.\n */\n\nimport {idOf, sourceOf, changedKeys} from './identity.js';\nimport {now} from './clock.js';\nimport type {TimelineEvent} from '../../../types/timeline.js';\n\ntype EmitFn = (event: TimelineEvent) => void;\ntype RecordingFn = () => boolean;\ntype LayerEnabledFn = () => boolean;\n\n/** Phases to instrument with start/end pairs. */\nconst UPDATE_PHASES = [\n 'performUpdate',\n 'willUpdate',\n 'update',\n 'updated',\n 'firstUpdated',\n] as const;\n\n/** Point-in-time lifecycle events (no end bracket). */\nconst POINT_PHASES = ['connectedCallback', 'disconnectedCallback'] as const;\n\nconst BRAND = Symbol.for('@lit-labs/vite-plugin-lit#timeline-lifecycle');\n\n/** Per-instance update tick counter (bumped inside performUpdate wrapper). */\nconst ticks = new WeakMap<object, number>();\n\nconst tickOf = (el: object): number => ticks.get(el) ?? 0;\n\ntype AnyFn = (...args: unknown[]) => unknown;\ntype Proto = Record<string | symbol, AnyFn | undefined>;\n\n/** Returns true if `proto[name]` is already our wrapper (idempotent install). */\nconst isWrapped = (proto: Proto, name: string): boolean => {\n const fn = proto[name];\n return (\n typeof fn === 'function' && (fn as AnyFn & {[BRAND]?: true})[BRAND] === true\n );\n};\n\n/**\n * Wrap `proto[name]` with a start/end pair emitting to `emit`.\n * `isPoint` methods only emit a single event (no end bracket).\n */\nconst wrap = (\n proto: Proto,\n name: string,\n isPoint: boolean,\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n if (isWrapped(proto, name)) return;\n const orig = proto[name];\n\n const wrapper: AnyFn & {[BRAND]?: true} = function (\n this: object,\n ...args: unknown[]\n ) {\n if (!recording() || !enabled()) {\n return orig?.apply(this, args);\n }\n\n // Bump the per-instance tick at the *start* of each performUpdate, before\n // computing the groupId, so this whole update cycle — performUpdate and the\n // willUpdate/update/updated phases it nests — shares one groupId, distinct\n // from the previous cycle's. (Reading the tick before bumping put\n // performUpdate in a different group from its own phases and let adjacent\n // cycles collide on the same tick.)\n if (name === 'performUpdate') {\n ticks.set(this, tickOf(this) + 1);\n }\n\n const elementId = idOf(this);\n const tagName = (this as Element).localName ?? 'unknown';\n const source = sourceOf(this);\n const tick = tickOf(this);\n const groupId = `${elementId}:${tick}`;\n const time = now();\n const changed = changedKeys(args[0]);\n\n if (!isPoint) {\n emit({\n layerId: 'lit-lifecycle',\n time,\n groupId,\n title: name + ':start',\n subtitle: tagName,\n data: {phase: name, changed},\n meta: {elementId, tagName, source},\n });\n }\n\n let result: unknown;\n try {\n result = orig?.apply(this, args);\n } finally {\n if (!isPoint) {\n emit({\n layerId: 'lit-lifecycle',\n time: now(),\n groupId,\n title: name + ':end',\n subtitle: tagName,\n data: {phase: name},\n meta: {elementId, tagName, source},\n });\n } else {\n emit({\n layerId: 'lit-lifecycle',\n time,\n title: name,\n subtitle: tagName,\n data: {phase: name},\n meta: {elementId, tagName, source},\n });\n }\n }\n return result;\n };\n wrapper[BRAND] = true;\n\n try {\n Object.defineProperty(proto, name, {\n value: wrapper,\n writable: true,\n configurable: true,\n });\n } catch {\n // Non-configurable slot; instrumentation degrades gracefully.\n }\n};\n\n/**\n * Finds the prototype in `proto`'s chain that *owns* `name` as an own property,\n * or null if none does.\n */\nconst ownerOf = (proto: Proto, name: string): Proto | null => {\n let p: Proto | null = proto;\n while (p !== null && !Object.prototype.hasOwnProperty.call(p, name)) {\n p = Object.getPrototypeOf(p) as Proto | null;\n }\n return p;\n};\n\n/**\n * Returns any defined Lit element's prototype (duck-typed by `performUpdate`),\n * or null if none can be found yet. One sample is enough: its chain leads to\n * the shared ReactiveElement/LitElement base prototypes every component\n * inherits.\n *\n * Tries the non-standard `_registry` map first, then falls back to sampling a\n * live upgraded element from the DOM — `_registry` isn't present in every\n * engine (e.g. some Chrome builds), and without this fallback an app whose\n * components were all defined before the runtime installed gets no lifecycle\n * instrumentation at all.\n */\nconst findLitElementProto = (): Proto | null => {\n const registry = (\n customElements as unknown as {\n _registry?: Record<string, CustomElementConstructor>;\n }\n )._registry;\n if (registry !== undefined) {\n for (const ctor of Object.values(registry)) {\n const proto = ctor?.prototype;\n if (proto != null && 'performUpdate' in proto) return proto as Proto;\n }\n }\n if (typeof document !== 'undefined') {\n for (const el of document.querySelectorAll('*')) {\n const proto = Object.getPrototypeOf(el) as Proto | null;\n if (proto != null && 'performUpdate' in proto) return proto;\n }\n }\n return null;\n};\n\nlet installed = false;\n\n/**\n * Install lifecycle instrumentation for *every* Lit element on the page.\n *\n * The phases live on the shared ReactiveElement/LitElement base prototypes, so\n * wrapping them there instruments all components at once — not just the first\n * one registered (the old behavior, which also silently no-op'd when Vite\n * served the production Lit build, since that omits the `reactiveElementVersions`\n * sentinel the resolver gated on).\n *\n * A component that overrides `willUpdate`/`updated`/`firstUpdated` *without*\n * calling `super` shadows the base no-op and won't report that phase — an\n * accepted limitation; the common case and `super`-calling overrides report.\n *\n * Idempotent — wrapping is brand-guarded per prototype+method.\n */\nexport const installLifecycleLayer = (\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n if (installed) return;\n installed = true;\n\n // Instrument from a sample already on the page (covers components defined\n // before the runtime installed — the common case, since the runtime is\n // injected after the app's modules).\n const proto = findLitElementProto();\n if (proto !== null) {\n patchBases(proto, emit, recording, enabled);\n }\n\n // Also instrument on future defines — both for components registered later\n // and for the case where none were discoverable above. Kept installed for\n // the page's lifetime; `patchBases` is idempotent (wrapping is brand-guarded\n // per prototype+method), so re-running once the shared bases are wrapped is a\n // cheap no-op.\n const origDefine = customElements.define.bind(customElements);\n customElements.define = (name, ctor, options) => {\n origDefine(name, ctor, options);\n const p = ctor?.prototype as Proto | null;\n if (p != null && 'performUpdate' in p) {\n patchBases(p, emit, recording, enabled);\n }\n };\n};\n\n/**\n * Wraps the lifecycle phases on the shared base prototypes reachable from\n * `sample`. `performUpdate` is never overridden by app code, so walking up from\n * any Lit element lands on `ReactiveElement.prototype` — which owns the update/\n * connect lifecycle, shared by all components. `update` is wrapped on its\n * effective owner instead (`LitElement.prototype` overrides it to drive\n * `render()`), so the timed call is the one that actually runs.\n */\nconst patchBases = (\n sample: Proto,\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n const reProto = ownerOf(sample, 'performUpdate');\n if (reProto === null) return;\n for (const name of UPDATE_PHASES) {\n const owner = name === 'update' ? ownerOf(sample, 'update') : reProto;\n if (owner !== null) wrap(owner, name, false, emit, recording, enabled);\n }\n for (const name of POINT_PHASES) {\n wrap(reProto, name, true, emit, recording, enabled);\n }\n};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E,OAAO,CAAC,CAAC;QAChC,MAAM,CAAC,GAAG,IAAI,EAAE,SAAyB,CAAC;QAC1C,IAAI,CAAC,IAAI,IAAI,IAAI,eAAe,IAAI,CAAC,EAAE,CAAC;YACtC,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,CACjB,MAAa,EACb,IAAY,EACZ,SAAsB,EACtB,OAAuB,EACjB,EAAE;IACR,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACjD,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO;IAC7B,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACtE,IAAI,KAAK,KAAK,IAAI;YAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;AACH,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * ReactiveElement prototype instrumentation for the lifecycle timeline layer.\n *\n * Wraps the lifecycle methods listed in PHASES on the prototype of the\n * ReactiveElement class loaded by the app — not by importing lit directly,\n * to avoid multi-copy issues. The proto is resolved from the already-defined\n * custom element registry (same mechanism as the HMR patch module).\n *\n * Each wrapped method emits a paired start/end TimelineEvent so the panel\n * can render duration bars. performUpdate brackets the whole update tick and\n * bumps a per-instance tick counter that becomes the groupId shared by all\n * phase events within that tick.\n *\n * Gated by the recording flag so overhead is near-zero when idle.\n */\n\nimport {idOf, sourceOf, changedKeys} from './identity.js';\nimport {now} from './clock.js';\nimport type {TimelineEvent} from '../../../types/timeline.js';\n\ntype EmitFn = (event: TimelineEvent) => void;\ntype RecordingFn = () => boolean;\ntype LayerEnabledFn = () => boolean;\n\n/**\n * Called once per completed `performUpdate`, with the element and whether that\n * was its first update. Independent of the recording gate: the flash overlay\n * wants every update while it is on, whether or not the timeline is recording.\n */\nexport type UpdateHook = (el: Element, first: boolean) => void;\n\nlet updateHook: UpdateHook | null = null;\n\n/** Install (or clear, with `null`) the per-update hook. One consumer. */\nexport const setUpdateHook = (hook: UpdateHook | null): void => {\n updateHook = hook;\n};\n\n/** Runs the update hook, never letting a consumer's throw reach the app. */\nconst notifyUpdated = (el: object, first: boolean): void => {\n if (updateHook === null) return;\n try {\n updateHook(el as Element, first);\n } catch {\n // dev tool — an overlay bug must not break the app's update cycle\n }\n};\n\n/** `ReactiveElement.hasUpdated`, read before the update flips it. */\nconst isFirstUpdate = (el: object): boolean =>\n (el as {hasUpdated?: boolean}).hasUpdated !== true;\n\n/** Phases to instrument with start/end pairs. */\nconst UPDATE_PHASES = [\n 'performUpdate',\n 'willUpdate',\n 'update',\n 'updated',\n 'firstUpdated',\n] as const;\n\n/** Point-in-time lifecycle events (no end bracket). */\nconst POINT_PHASES = ['connectedCallback', 'disconnectedCallback'] as const;\n\nconst BRAND = Symbol.for('@lit-labs/vite-plugin-lit#timeline-lifecycle');\n\n/** Per-instance update tick counter (bumped inside performUpdate wrapper). */\nconst ticks = new WeakMap<object, number>();\n\nconst tickOf = (el: object): number => ticks.get(el) ?? 0;\n\ntype AnyFn = (...args: unknown[]) => unknown;\ntype Proto = Record<string | symbol, AnyFn | undefined>;\n\n/** Returns true if `proto[name]` is already our wrapper (idempotent install). */\nconst isWrapped = (proto: Proto, name: string): boolean => {\n const fn = proto[name];\n return (\n typeof fn === 'function' && (fn as AnyFn & {[BRAND]?: true})[BRAND] === true\n );\n};\n\n/**\n * Wrap `proto[name]` with a start/end pair emitting to `emit`.\n * `isPoint` methods only emit a single event (no end bracket).\n */\nconst wrap = (\n proto: Proto,\n name: string,\n isPoint: boolean,\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n if (isWrapped(proto, name)) return;\n const orig = proto[name];\n\n const wrapper: AnyFn & {[BRAND]?: true} = function (\n this: object,\n ...args: unknown[]\n ) {\n const isUpdate = name === 'performUpdate';\n if (!recording() || !enabled()) {\n if (!isUpdate || updateHook === null) return orig?.apply(this, args);\n const first = isFirstUpdate(this);\n const result = orig?.apply(this, args);\n notifyUpdated(this, first);\n return result;\n }\n const first = isUpdate && isFirstUpdate(this);\n\n // Bump the per-instance tick at the *start* of each performUpdate, before\n // computing the groupId, so this whole update cycle — performUpdate and the\n // willUpdate/update/updated phases it nests — shares one groupId, distinct\n // from the previous cycle's. (Reading the tick before bumping put\n // performUpdate in a different group from its own phases and let adjacent\n // cycles collide on the same tick.)\n if (name === 'performUpdate') {\n ticks.set(this, tickOf(this) + 1);\n }\n\n const elementId = idOf(this);\n const tagName = (this as Element).localName ?? 'unknown';\n const source = sourceOf(this);\n const tick = tickOf(this);\n const groupId = `${elementId}:${tick}`;\n const time = now();\n const changed = changedKeys(args[0]);\n\n if (!isPoint) {\n emit({\n layerId: 'lit-lifecycle',\n time,\n groupId,\n title: name + ':start',\n subtitle: tagName,\n data: {phase: name, changed},\n meta: {elementId, tagName, source},\n });\n }\n\n let result: unknown;\n try {\n result = orig?.apply(this, args);\n } finally {\n if (!isPoint) {\n emit({\n layerId: 'lit-lifecycle',\n time: now(),\n groupId,\n title: name + ':end',\n subtitle: tagName,\n data: {phase: name},\n meta: {elementId, tagName, source},\n });\n } else {\n emit({\n layerId: 'lit-lifecycle',\n time,\n title: name,\n subtitle: tagName,\n data: {phase: name},\n meta: {elementId, tagName, source},\n });\n }\n }\n // After the bracket, not in it: a throwing update never completed, so it\n // doesn't count as one.\n if (isUpdate) notifyUpdated(this, first);\n return result;\n };\n wrapper[BRAND] = true;\n\n try {\n Object.defineProperty(proto, name, {\n value: wrapper,\n writable: true,\n configurable: true,\n });\n } catch {\n // Non-configurable slot; instrumentation degrades gracefully.\n }\n};\n\n/**\n * Finds the prototype in `proto`'s chain that *owns* `name` as an own property,\n * or null if none does.\n */\nconst ownerOf = (proto: Proto, name: string): Proto | null => {\n let p: Proto | null = proto;\n while (p !== null && !Object.prototype.hasOwnProperty.call(p, name)) {\n p = Object.getPrototypeOf(p) as Proto | null;\n }\n return p;\n};\n\n/**\n * Returns any defined Lit element's prototype (duck-typed by `performUpdate`),\n * or null if none can be found yet. One sample is enough: its chain leads to\n * the shared ReactiveElement/LitElement base prototypes every component\n * inherits.\n *\n * Tries the non-standard `_registry` map first, then falls back to sampling a\n * live upgraded element from the DOM — `_registry` isn't present in every\n * engine (e.g. some Chrome builds), and without this fallback an app whose\n * components were all defined before the runtime installed gets no lifecycle\n * instrumentation at all.\n */\nconst findLitElementProto = (): Proto | null => {\n const registry = (\n customElements as unknown as {\n _registry?: Record<string, CustomElementConstructor>;\n }\n )._registry;\n if (registry !== undefined) {\n for (const ctor of Object.values(registry)) {\n const proto = ctor?.prototype;\n if (proto != null && 'performUpdate' in proto) return proto as Proto;\n }\n }\n if (typeof document !== 'undefined') {\n for (const el of document.querySelectorAll('*')) {\n const proto = Object.getPrototypeOf(el) as Proto | null;\n if (proto != null && 'performUpdate' in proto) return proto;\n }\n }\n return null;\n};\n\nlet installed = false;\n\n/**\n * Install lifecycle instrumentation for *every* Lit element on the page.\n *\n * The phases live on the shared ReactiveElement/LitElement base prototypes, so\n * wrapping them there instruments all components at once — not just the first\n * one registered (the old behavior, which also silently no-op'd when Vite\n * served the production Lit build, since that omits the `reactiveElementVersions`\n * sentinel the resolver gated on).\n *\n * A component that overrides `willUpdate`/`updated`/`firstUpdated` *without*\n * calling `super` shadows the base no-op and won't report that phase — an\n * accepted limitation; the common case and `super`-calling overrides report.\n *\n * Idempotent — wrapping is brand-guarded per prototype+method.\n */\nexport const installLifecycleLayer = (\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n if (installed) return;\n installed = true;\n\n // Instrument from a sample already on the page (covers components defined\n // before the runtime installed — the common case, since the runtime is\n // injected after the app's modules).\n const proto = findLitElementProto();\n if (proto !== null) {\n patchBases(proto, emit, recording, enabled);\n }\n\n // Also instrument on future defines — both for components registered later\n // and for the case where none were discoverable above. Kept installed for\n // the page's lifetime; `patchBases` is idempotent (wrapping is brand-guarded\n // per prototype+method), so re-running once the shared bases are wrapped is a\n // cheap no-op.\n const origDefine = customElements.define.bind(customElements);\n customElements.define = (name, ctor, options) => {\n origDefine(name, ctor, options);\n const p = ctor?.prototype as Proto | null;\n if (p != null && 'performUpdate' in p) {\n patchBases(p, emit, recording, enabled);\n }\n };\n};\n\n/**\n * Wraps the lifecycle phases on the shared base prototypes reachable from\n * `sample`. `performUpdate` is never overridden by app code, so walking up from\n * any Lit element lands on `ReactiveElement.prototype` — which owns the update/\n * connect lifecycle, shared by all components. `update` is wrapped on its\n * effective owner instead (`LitElement.prototype` overrides it to drive\n * `render()`), so the timed call is the one that actually runs.\n */\nconst patchBases = (\n sample: Proto,\n emit: EmitFn,\n recording: RecordingFn,\n enabled: LayerEnabledFn\n): void => {\n const reProto = ownerOf(sample, 'performUpdate');\n if (reProto === null) return;\n for (const name of UPDATE_PHASES) {\n const owner = name === 'update' ? ownerOf(sample, 'update') : reProto;\n if (owner !== null) wrap(owner, name, false, emit, recording, enabled);\n }\n for (const name of POINT_PHASES) {\n wrap(reProto, name, true, emit, recording, enabled);\n }\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/timeline/public-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAE7E,YAAY,EAAC,aAAa,EAAE,aAAa,EAAC,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,aAAa,KAAG,IAEvD,CAAC;AAIF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,aAAa,KAAG,IAOvD,CAAC"}
1
+ {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/public-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAE7E,YAAY,EAAC,aAAa,EAAE,aAAa,EAAC,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,UAAW,aAAa,KAAG,IAEvD,CAAC;AAIF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,UAAW,aAAa,KAAG,IAOvD,CAAC"}
@@ -11,7 +11,7 @@
11
11
  * This module shares the same `transport.ts` instance as `install.ts`, so
12
12
  * events emitted here flow through the same batched HMR channel to the panel.
13
13
  */
14
- import { emit, setHotClientCallback } from './transport.js';
14
+ import {emit, setHotClientCallback} from './transport.js';
15
15
  /**
16
16
  * Emit a custom timeline event from app code.
17
17
  *
@@ -24,7 +24,7 @@ import { emit, setHotClientCallback } from './transport.js';
24
24
  * transport queue).
25
25
  */
26
26
  export const addTimelineEvent = (event) => {
27
- emit(event);
27
+ emit(event);
28
28
  };
29
29
  /**
30
30
  * Register a custom timeline layer and announce it to the panel.
@@ -34,11 +34,11 @@ export const addTimelineEvent = (event) => {
34
34
  * ignored.
35
35
  */
36
36
  export const addTimelineLayer = (layer) => {
37
- const send = () => {
38
- import.meta.hot?.send('lit:timeline:custom-layer', {
39
- layer,
40
- });
41
- };
42
- setHotClientCallback(send);
37
+ const send = () => {
38
+ import.meta.hot?.send('lit:timeline:custom-layer', {
39
+ layer,
40
+ });
41
+ };
42
+ setHotClientCallback(send);
43
43
  };
44
- //# sourceMappingURL=public-api.js.map
44
+ //# sourceMappingURL=public-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/timeline/public-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAC,IAAI,EAAE,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAK1D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAoB,EAAQ,EAAE;IAC7D,IAAI,CAAC,KAAK,CAAC,CAAC;AACd,CAAC,CAAC;AAIF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAoB,EAAQ,EAAE;IAC7D,MAAM,IAAI,GAAG,GAAS,EAAE;QACrB,MAAM,CAAC,IAAwB,CAAC,GAAG,EAAE,IAAI,CAAC,2BAA2B,EAAE;YACtE,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC;IACF,oBAAoB,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Public timeline API — re-exported by the `virtual:lit-plugin/timeline`\n * virtual module so app code and other plugins can contribute events and\n * custom layers without reaching into plugin internals.\n *\n * This module shares the same `transport.ts` instance as `install.ts`, so\n * events emitted here flow through the same batched HMR channel to the panel.\n */\n\nimport {emit, setHotClientCallback} from './transport.js';\nimport type {TimelineEvent, TimelineLayer} from '../../../types/timeline.js';\n\nexport type {TimelineEvent, TimelineLayer};\n\n/**\n * Emit a custom timeline event from app code.\n *\n * The event is forwarded to the Timeline panel when recording is active.\n * Use a custom `layerId` registered with `addTimelineLayer`, or one of the\n * built-in layer ids (`'lit-lifecycle'`, `'lit-render'`, `'mouse'`,\n * `'keyboard'`).\n *\n * No-ops in production (the HMR channel is absent; events are dropped in the\n * transport queue).\n */\nexport const addTimelineEvent = (event: TimelineEvent): void => {\n emit(event);\n};\n\ntype ViteHot = {send: (event: string, data: unknown) => void};\n\n/**\n * Register a custom timeline layer and announce it to the panel.\n *\n * The panel adds the layer to its toggle strip after the built-in layers.\n * The registration message is sent once on first call; duplicate ids are\n * ignored.\n */\nexport const addTimelineLayer = (layer: TimelineLayer): void => {\n const send = (): void => {\n (import.meta as {hot?: ViteHot}).hot?.send('lit:timeline:custom-layer', {\n layer,\n });\n };\n setHotClientCallback(send);\n};\n"]}
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/public-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAC,IAAI,EAAE,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAK1D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAoB,EAAQ,EAAE;IAC7D,IAAI,CAAC,KAAK,CAAC,CAAC;AACd,CAAC,CAAC;AAIF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAoB,EAAQ,EAAE;IAC7D,MAAM,IAAI,GAAG,GAAS,EAAE;QACrB,OAAO,IAAwB,CAAC,GAAG,EAAE,IAAI,CAAC,2BAA2B,EAAE;YACtE,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC;IACF,oBAAoB,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Public timeline API — re-exported by the `virtual:lit-plugin/timeline`\n * virtual module so app code and other plugins can contribute events and\n * custom layers without reaching into plugin internals.\n *\n * This module shares the same `transport.ts` instance as `install.ts`, so\n * events emitted here flow through the same batched HMR channel to the panel.\n */\n\nimport {emit, setHotClientCallback} from './transport.js';\nimport type {TimelineEvent, TimelineLayer} from '../../../types/timeline.js';\n\nexport type {TimelineEvent, TimelineLayer};\n\n/**\n * Emit a custom timeline event from app code.\n *\n * The event is forwarded to the Timeline panel when recording is active.\n * Use a custom `layerId` registered with `addTimelineLayer`, or one of the\n * built-in layer ids (`'lit-lifecycle'`, `'lit-render'`, `'mouse'`,\n * `'keyboard'`).\n *\n * No-ops in production (the HMR channel is absent; events are dropped in the\n * transport queue).\n */\nexport const addTimelineEvent = (event: TimelineEvent): void => {\n emit(event);\n};\n\ntype ViteHot = {send: (event: string, data: unknown) => void};\n\n/**\n * Register a custom timeline layer and announce it to the panel.\n *\n * The panel adds the layer to its toggle strip after the built-in layers.\n * The registration message is sent once on first call; duplicate ids are\n * ignored.\n */\nexport const addTimelineLayer = (layer: TimelineLayer): void => {\n const send = (): void => {\n (import.meta as {hot?: ViteHot}).hot?.send('lit:timeline:custom-layer', {\n layer,\n });\n };\n setHotClientCallback(send);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../../packages/labs/vite-plugin-lit/src/lib/runtime/timeline/render.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAI9D,KAAK,MAAM,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAC7C,KAAK,WAAW,GAAG,MAAM,OAAO,CAAC;AACjC,KAAK,cAAc,GAAG,MAAM,OAAO,CAAC;AAmGpC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,MAAM,EACZ,WAAW,WAAW,EACtB,cAAc,cAAc,KAC3B,IASF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,OAAO,KAAG,IAGxD,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,oBAAoB,QAAO,IAIvC,CAAC"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/timeline/render.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAI9D,KAAK,MAAM,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAC7C,KAAK,WAAW,GAAG,MAAM,OAAO,CAAC;AACjC,KAAK,cAAc,GAAG,MAAM,OAAO,CAAC;AAmGpC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,SACvB,MAAM,aACD,WAAW,gBACR,cAAc,KAC3B,IASF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,YAAa,OAAO,KAAG,IAGxD,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,oBAAoB,QAAO,IAIvC,CAAC"}