@oddsquad/vite-plugin-lit 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/README.md +28 -12
- package/bin.mjs +87 -5
- package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-F2EfZsFX.js → browser-agent-rpc-BXhoSh1z-BuCvPGjS.js} +2 -2
- package/dist/client/assets/{browser-agent-rpc-BXhoSh1z-F2EfZsFX.js.map → browser-agent-rpc-BXhoSh1z-BuCvPGjS.js.map} +1 -1
- package/dist/client/assets/{index-B2HYO7lk.js → index-D632jo79.js} +22 -3
- package/dist/client/assets/index-D632jo79.js.map +1 -0
- package/dist/client/index.html +1 -1
- package/dist/standalone/lit-devtools.js +6820 -0
- package/lib/devframe/allowed-origins.d.ts +13 -0
- package/lib/devframe/allowed-origins.d.ts.map +1 -0
- package/lib/devframe/allowed-origins.js +63 -0
- package/lib/devframe/allowed-origins.js.map +1 -0
- package/lib/options.d.ts +26 -0
- package/lib/options.d.ts.map +1 -1
- package/lib/options.js +19 -0
- package/lib/options.js.map +1 -1
- package/lib/plugin.d.ts.map +1 -1
- package/lib/plugin.js +3 -0
- package/lib/plugin.js.map +1 -1
- package/lib/plugins/private-fields.d.ts +27 -0
- package/lib/plugins/private-fields.d.ts.map +1 -0
- package/lib/plugins/private-fields.js +259 -0
- package/lib/plugins/private-fields.js.map +1 -0
- package/lib/runtime/child-state.d.ts +100 -0
- package/lib/runtime/child-state.d.ts.map +1 -0
- package/lib/runtime/child-state.js +446 -0
- package/lib/runtime/child-state.js.map +1 -0
- package/lib/runtime/inspector/install.js +4 -1
- package/lib/runtime/inspector/install.js.map +1 -1
- package/lib/runtime/patch.d.ts +24 -0
- package/lib/runtime/patch.d.ts.map +1 -1
- package/lib/runtime/patch.js +22 -1
- package/lib/runtime/patch.js.map +1 -1
- package/lib/runtime/rpc-transport.d.ts +8 -0
- package/lib/runtime/rpc-transport.d.ts.map +1 -1
- package/lib/runtime/rpc-transport.js +1 -0
- package/lib/runtime/rpc-transport.js.map +1 -1
- package/lib/runtime/source-overlay/editors.d.ts.map +1 -1
- package/lib/runtime/source-overlay/editors.js +9 -4
- package/lib/runtime/source-overlay/editors.js.map +1 -1
- package/lib/runtime/standalone.d.ts +27 -0
- package/lib/runtime/standalone.d.ts.map +1 -0
- package/lib/runtime/standalone.js +50 -0
- package/lib/runtime/standalone.js.map +1 -0
- package/lib/runtime/timeline/install.js +4 -2
- package/lib/runtime/timeline/install.js.map +1 -1
- package/lib/runtime/timeline/lifecycle.d.ts.map +1 -1
- package/lib/runtime/timeline/lifecycle.js +5 -1
- package/lib/runtime/timeline/lifecycle.js.map +1 -1
- package/package.json +13 -9
- package/types/timeline.d.ts +4 -1
- package/types/timeline.d.ts.map +1 -1
- package/types/timeline.js.map +1 -1
- package/dist/client/assets/index-B2HYO7lk.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC9B,MAAM,oCAAoC,CAAC;AAK5C,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAEnC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAwDD;;;;GAIG;AAEH,eAAO,MAAM,cAAc,WACjB,MAAM,UACN,MAAM,QACR,aAAa,CAAC,WAAW,CAAC,SA4BjC,CAAC;AA+IF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,YAC3B,MAAM,UACP,wBAAwB,UACxB,uBAAuB,CAAC,QAAQ,CAAC,KACxC,uBAAwE,CAAC;AA8K5E;;;GAGG;AACH,eAAO,MAAM,OAAO,aAAa,YAAY,KAAQ,IAuFpD,CAAC"}
|
package/lib/runtime/patch.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* it never imports lit (keeps it version-agnostic and safe for non-Lit
|
|
19
19
|
* custom elements, which get prototype/static patching only).
|
|
20
20
|
*/
|
|
21
|
+
import {createChildState} from './child-state.js';
|
|
21
22
|
import {subscribeOverride} from './overrides.js';
|
|
22
23
|
import {pageChannel} from './page-channel.js';
|
|
23
24
|
import {
|
|
@@ -86,6 +87,9 @@ const instrument = (state, proto, record) => {
|
|
|
86
87
|
const wrapper =
|
|
87
88
|
name === 'connectedCallback'
|
|
88
89
|
? function () {
|
|
90
|
+
// Before the original runs, so a transfer lands ahead of the
|
|
91
|
+
// element's first update.
|
|
92
|
+
state.childState?.connected(this, !state.generationOf.has(this));
|
|
89
93
|
record.instances.add(this);
|
|
90
94
|
const stamp = state.generationOf.get(this);
|
|
91
95
|
if (stamp !== undefined && stamp !== record.generation) {
|
|
@@ -97,6 +101,7 @@ const instrument = (state, proto, record) => {
|
|
|
97
101
|
}
|
|
98
102
|
: function () {
|
|
99
103
|
record.instances.delete(this);
|
|
104
|
+
state.childState?.disconnected(this);
|
|
100
105
|
original?.call(this);
|
|
101
106
|
};
|
|
102
107
|
wrapper[RECORD_BRAND] = record;
|
|
@@ -293,7 +298,9 @@ const hotPatch = (state, record, NewClass) => {
|
|
|
293
298
|
)
|
|
294
299
|
);
|
|
295
300
|
}
|
|
296
|
-
// 7. Update live instances.
|
|
301
|
+
// 7. Update live instances. Re-renders may re-create child elements
|
|
302
|
+
// (edited templates clone fresh DOM); the window pairs them up.
|
|
303
|
+
state.childState?.open();
|
|
297
304
|
const newPropertyKeys = NewClass.elementProperties?.keys() ?? [];
|
|
298
305
|
// After the static sync this is the NEW class's initializer list.
|
|
299
306
|
const initializers = OldClass._initializers;
|
|
@@ -332,6 +339,8 @@ const hotPatch = (state, record, NewClass) => {
|
|
|
332
339
|
state.generationOf.set(el, record.generation);
|
|
333
340
|
el.requestUpdate?.();
|
|
334
341
|
}
|
|
342
|
+
// Read after requestUpdate() so each promise covers the new update.
|
|
343
|
+
state.childState?.watch(record.instances);
|
|
335
344
|
} catch (e) {
|
|
336
345
|
incompatible(state, record.tagName, {
|
|
337
346
|
code: 'patch-failed',
|
|
@@ -357,6 +366,9 @@ export const install = (options = {}) => {
|
|
|
357
366
|
if (options.onIncompatible !== undefined) {
|
|
358
367
|
existing.options.onIncompatible = options.onIncompatible;
|
|
359
368
|
}
|
|
369
|
+
if (options.childState !== undefined) {
|
|
370
|
+
existing.options.childState = options.childState;
|
|
371
|
+
}
|
|
360
372
|
return;
|
|
361
373
|
}
|
|
362
374
|
const hot = import.meta.hot;
|
|
@@ -366,9 +378,13 @@ export const install = (options = {}) => {
|
|
|
366
378
|
options: {
|
|
367
379
|
reconnect: options.reconnect ?? false,
|
|
368
380
|
onIncompatible: options.onIncompatible ?? 'reload',
|
|
381
|
+
childState: options.childState ?? 'transfer',
|
|
369
382
|
},
|
|
370
383
|
hot: hot === undefined ? undefined : pageChannel,
|
|
371
384
|
};
|
|
385
|
+
state.childState = createChildState({
|
|
386
|
+
mode: () => state.options.childState,
|
|
387
|
+
});
|
|
372
388
|
g[STATE_KEY] = state;
|
|
373
389
|
// Let the DevTools panel override these behaviours live (and persist across
|
|
374
390
|
// reloads) on top of the config-time defaults above.
|
|
@@ -377,6 +393,11 @@ export const install = (options = {}) => {
|
|
|
377
393
|
if (o.hmrOnIncompatible !== undefined) {
|
|
378
394
|
state.options.onIncompatible = o.hmrOnIncompatible;
|
|
379
395
|
}
|
|
396
|
+
// Read on every patch (see createChildState's `mode`), so it applies from
|
|
397
|
+
// the next edit on.
|
|
398
|
+
if (o.hmrChildState !== undefined) {
|
|
399
|
+
state.options.childState = o.hmrChildState;
|
|
400
|
+
}
|
|
380
401
|
});
|
|
381
402
|
// Captured to re-invoke below as nativeDefine.call(this, ...).
|
|
382
403
|
// oxlint-disable-next-line typescript/unbound-method
|
package/lib/runtime/patch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAGlB,MAAM,oCAAoC,CAAC;AA0D5C,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,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAChC,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC;CACnC,CAAC;AAEF;;;;GAIG;AACH,wDAAwD;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,MAAc,EACd,MAAc,EACd,IAAgC,EAChC,EAAE;IACF,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAA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wC;QAExC,IAAI,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACzD,oEAAoE;YACpE,sEAAsE;YACtE,MAAM,GAAG;gBACP,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAE;gBAC1B,SAAS,EAAE,IAAI,GAAG,EAAE;gBACpB,UAAU,EAAE,CAAC;aACd,CAAC;YACF,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,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\nimport {subscribeOverride} from './overrides.js';\nimport {pageChannel} from './page-channel.js';\nimport type {PageTransport, ViteHotLike} from './page-channel.js';\nimport {\n HMR_INCOMPATIBLE_CHANNEL,\n describeHmrReason,\n type HmrIncompatibilityEvent,\n type HmrIncompatibilityReason,\n} from '../../types/hmr-incompatibility.js';\n\n/** What the patcher needs of the page channel: reporting incompatibilities. */\ntype HotChannel = Pick<PageTransport, 'send'>;\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 /** Set in `install()`; reports HMR-incompatibility events when present. */\n hot?: HotChannel;\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\n/**\n * Builds the structured event reported over {@link HMR_INCOMPATIBLE_CHANNEL}.\n * Exported for unit testing; otherwise module-internal. Whether the send\n * survives the `location.reload()` that may follow it can only be checked by\n * hand against a real dev server.\n */\nexport const buildHmrIncompatibleEvent = (\n tagName: string,\n reason: HmrIncompatibilityReason,\n action: HmrIncompatibilityEvent['action']\n): HmrIncompatibilityEvent => ({tagName, time: Date.now(), reason, action});\n\nconst incompatible = (\n state: PatchState,\n tagName: string,\n reason: HmrIncompatibilityReason\n): void => {\n const message = describeHmrReason(reason);\n const action = state.options.onIncompatible === 'warn' ? 'warn' : 'reload';\n state.hot?.send(\n HMR_INCOMPATIBLE_CHANNEL,\n buildHmrIncompatibleEvent(tagName, reason, action)\n );\n if (state.options.onIncompatible === 'warn') {\n console.warn(\n `[lit-plugin] <${tagName}> can't be hot-patched (${message}). ` +\n `Reload the page to pick up the change.`\n );\n } else {\n console.info(\n `[lit-plugin] <${tagName}>: ${message} — 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, {code: '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 state.hot?.send(\n HMR_INCOMPATIBLE_CHANNEL,\n buildHmrIncompatibleEvent(\n record.tagName,\n {code: 'observed-attributes-changed'},\n 'none'\n )\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 // Snapshot: the reconnect below mutates record.instances mid-iteration.\n // oxlint-disable-next-line unicorn/no-useless-spread\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(state, record.tagName, {\n code: 'patch-failed',\n detail: 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 hot = (import.meta as {hot?: ViteHotLike}).hot;\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 hot: hot === undefined ? undefined : pageChannel,\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(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 // Captured to re-invoke below as nativeDefine.call(this, ...).\n // oxlint-disable-next-line typescript/unbound-method\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":["../../src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,gBAAgB,GAGjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAGlB,MAAM,oCAAoC,CAAC;AAqE5C,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,C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,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACzD,oEAAoE;YACpE,sEAAsE;YACtE,MAAM,GAAG;gBACP,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAE;gBAC1B,SAAS,EAAE,IAAI,GAAG,EAAE;gBACpB,UAAU,EAAE,CAAC;aACd,CAAC;YACF,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,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\nimport {\n createChildState,\n type ChildState,\n type ChildStateMode,\n} from './child-state.js';\nimport {subscribeOverride} from './overrides.js';\nimport {pageChannel} from './page-channel.js';\nimport type {PageTransport, ViteHotLike} from './page-channel.js';\nimport {\n HMR_INCOMPATIBLE_CHANNEL,\n describeHmrReason,\n type HmrIncompatibilityEvent,\n type HmrIncompatibilityReason,\n} from '../../types/hmr-incompatibility.js';\n\n/** What the patcher needs of the page channel: reporting incompatibilities. */\ntype HotChannel = Pick<PageTransport, 'send'>;\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 /**\n * What happens to custom elements a hot patch re-creates (an edited\n * template clones fresh DOM): `'reset'` leaves them at their defaults,\n * `'transfer'` copies the old element's state onto the new one, `'reuse'`\n * puts the old element back where the new one carries no bindings (and\n * transfers otherwise). Defaults to `'transfer'`.\n */\n childState?: ChildStateMode;\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 /** Set in `install()`; reports HMR-incompatibility events when present. */\n hot?: HotChannel;\n /** Pairs re-created child elements with the ones they replace. */\n childState?: ChildState;\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 // Before the original runs, so a transfer lands ahead of the\n // element's first update.\n state.childState?.connected(this, !state.generationOf.has(this));\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 state.childState?.disconnected(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\n/**\n * Builds the structured event reported over {@link HMR_INCOMPATIBLE_CHANNEL}.\n * Exported for unit testing; otherwise module-internal. Whether the send\n * survives the `location.reload()` that may follow it can only be checked by\n * hand against a real dev server.\n */\nexport const buildHmrIncompatibleEvent = (\n tagName: string,\n reason: HmrIncompatibilityReason,\n action: HmrIncompatibilityEvent['action']\n): HmrIncompatibilityEvent => ({tagName, time: Date.now(), reason, action});\n\nconst incompatible = (\n state: PatchState,\n tagName: string,\n reason: HmrIncompatibilityReason\n): void => {\n const message = describeHmrReason(reason);\n const action = state.options.onIncompatible === 'warn' ? 'warn' : 'reload';\n state.hot?.send(\n HMR_INCOMPATIBLE_CHANNEL,\n buildHmrIncompatibleEvent(tagName, reason, action)\n );\n if (state.options.onIncompatible === 'warn') {\n console.warn(\n `[lit-plugin] <${tagName}> can't be hot-patched (${message}). ` +\n `Reload the page to pick up the change.`\n );\n } else {\n console.info(\n `[lit-plugin] <${tagName}>: ${message} — 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, {code: '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 state.hot?.send(\n HMR_INCOMPATIBLE_CHANNEL,\n buildHmrIncompatibleEvent(\n record.tagName,\n {code: 'observed-attributes-changed'},\n 'none'\n )\n );\n }\n\n // 7. Update live instances. Re-renders may re-create child elements\n // (edited templates clone fresh DOM); the window pairs them up.\n state.childState?.open();\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 // Snapshot: the reconnect below mutates record.instances mid-iteration.\n // oxlint-disable-next-line unicorn/no-useless-spread\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 // Read after requestUpdate() so each promise covers the new update.\n state.childState?.watch(record.instances);\n } catch (e) {\n incompatible(state, record.tagName, {\n code: 'patch-failed',\n detail: 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 if (options.childState !== undefined) {\n existing.options.childState = options.childState;\n }\n return;\n }\n const hot = (import.meta as {hot?: ViteHotLike}).hot;\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 childState: options.childState ?? 'transfer',\n },\n hot: hot === undefined ? undefined : pageChannel,\n };\n state.childState = createChildState({\n mode: () => state.options.childState,\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(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 // Read on every patch (see createChildState's `mode`), so it applies from\n // the next edit on.\n if (o.hmrChildState !== undefined) {\n state.options.childState = o.hmrChildState;\n }\n });\n\n // Captured to re-invoke below as nativeDefine.call(this, ...).\n // oxlint-disable-next-line typescript/unbound-method\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"]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
5
|
*/
|
|
6
|
+
import type { ConnectionMeta } from 'devframe';
|
|
6
7
|
import type { PageTransport } from './page-channel.js';
|
|
7
8
|
/** The slice of a scoped devframe client the transport uses. */
|
|
8
9
|
export interface PageRpc {
|
|
@@ -27,6 +28,13 @@ export interface ConnectOptions {
|
|
|
27
28
|
* started with `--no-auth`.
|
|
28
29
|
*/
|
|
29
30
|
authToken?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The server's connection descriptor (what it serves at
|
|
33
|
+
* `<url>/__connection.json`). Passing it skips that fetch, which is the
|
|
34
|
+
* step a cross-origin page cannot make: the server sends no CORS headers,
|
|
35
|
+
* and a classic script tag is exempt from them where `fetch` is not.
|
|
36
|
+
*/
|
|
37
|
+
connectionMeta?: ConnectionMeta;
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* Point this page's runtime at a standalone `lit-devtools dev` server.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-transport.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/rpc-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"rpc-transport.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/rpc-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAE7C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAErD,gEAAgE;AAChE,MAAM,WAAW,OAAO;IACtB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACpD,QAAQ,CAAC,EAAE,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,OAAO,CAAC;QACd,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;KACnC,GAAG,IAAI,CAAC;CACV;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAS,OAAO,KAAG,aA4BjD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,QACxB,MAAM,YACF,cAAc,KACtB,OAAO,CAAC,MAAM,IAAI,CAgBpB,CAAC"}
|
|
@@ -70,6 +70,7 @@ export const connectToDevServer = async (url, options = {}) => {
|
|
|
70
70
|
const client = await getDevframeRpcClient({
|
|
71
71
|
baseURL: url,
|
|
72
72
|
authToken: options.authToken,
|
|
73
|
+
connectionMeta: options.connectionMeta,
|
|
73
74
|
});
|
|
74
75
|
await client.ensureTrusted();
|
|
75
76
|
const previous = pageChannel.transport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-transport.js","sourceRoot":"","sources":["../../src/lib/runtime/rpc-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc-transport.js","sourceRoot":"","sources":["../../src/lib/runtime/rpc-transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAa9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAY,EAAiB,EAAE;IAChE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAwC,CAAC;IAElE,GAAG,CAAC,QAAQ,CAAC;QACX,IAAI,EAAE,gBAAgB;QACtB,IAAI,E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,OAAO,CAAC,cAAc;KACvC,CAAC,CAAC;IACH,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;IAE7B,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC;IACvC,WAAW,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAE1E,OAAO,GAAG,EAAE;QACV,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QACjB,IAAI,QAAQ,KAAK,SAAS;YAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Carries the page channel over devframe RPC to a standalone\n * `lit-devtools dev` server, so a page that is not served by a DevTools-enabled\n * Vite dev server can still feed the panel. The server half is\n * `devframe/rpc-source.ts`.\n *\n * Opt-in and explicit: nothing connects until {@link connectToDevServer} is\n * called, and `devframe/client` is only imported then, so a page that never\n * asks pays nothing.\n */\n\nimport {\n LIT_DEVFRAME_ID,\n RPC_PAGE_RECEIVE,\n RPC_PAGE_SEND,\n} from '../devframe/protocol.js';\nimport type {ConnectionMeta} from 'devframe';\nimport {pageChannel} from './page-channel.js';\nimport type {PageTransport} from './page-channel.js';\n\n/** The slice of a scoped devframe client the transport uses. */\nexport interface PageRpc {\n callEvent(method: string, ...args: unknown[]): void;\n register(fn: {\n name: string;\n type: 'event';\n handler: (...args: any[]) => void;\n }): void;\n}\n\n/**\n * A {@link PageTransport} over a devframe RPC client: `send` becomes a\n * `page-send` event, and `page-receive` events fan out to the listeners\n * registered with `on`.\n */\nexport const createRpcTransport = (rpc: PageRpc): PageTransport => {\n const listeners = new Map<string, Set<(data: unknown) => void>>();\n\n rpc.register({\n name: RPC_PAGE_RECEIVE,\n type: 'event',\n handler: (channel: string, data?: unknown) => {\n for (const listener of listeners.get(channel) ?? []) {\n try {\n listener(data);\n } catch (error) {\n console.error(`[lit-devtools] listener for ${channel} threw`, error);\n }\n }\n },\n });\n\n return {\n send(channel, data) {\n rpc.callEvent(RPC_PAGE_SEND, channel, data);\n },\n on(channel, handler) {\n let set = listeners.get(channel);\n if (set === undefined) listeners.set(channel, (set = new Set()));\n set.add(handler);\n return () => void set.delete(handler);\n },\n };\n};\n\nexport interface ConnectOptions {\n /**\n * A bearer token the server already trusts. Without one the client falls\n * back to devframe's own flow (a stored token, a magic-link code in the URL,\n * or a prompt for the one-time code the server prints) unless the server was\n * started with `--no-auth`.\n */\n authToken?: string;\n /**\n * The server's connection descriptor (what it serves at\n * `<url>/__connection.json`). Passing it skips that fetch, which is the\n * step a cross-origin page cannot make: the server sends no CORS headers,\n * and a classic script tag is exempt from them where `fetch` is not.\n */\n connectionMeta?: ConnectionMeta;\n}\n\n/**\n * Point this page's runtime at a standalone `lit-devtools dev` server.\n *\n * Resolves once the connection is trusted, after which the tree, inspector\n * and timeline traffic that used to go to this page's own Vite server goes to\n * `url` instead (the runtime announces itself again so the server can replay\n * recording state). Returns a function that disconnects and hands the channel\n * back to the carrier it replaced.\n *\n * The page's origin must be allowed to reach `url`; this does not set up\n * cross-origin access.\n *\n * @param url Origin of the dev server, e.g. `http://localhost:5180/`.\n */\nexport const connectToDevServer = async (\n url: string,\n options: ConnectOptions = {}\n): Promise<() => void> => {\n const {getDevframeRpcClient} = await import('devframe/client');\n const client = await getDevframeRpcClient({\n baseURL: url,\n authToken: options.authToken,\n connectionMeta: options.connectionMeta,\n });\n await client.ensureTrusted();\n\n const previous = pageChannel.transport;\n pageChannel.attach(createRpcTransport(client.scope(LIT_DEVFRAME_ID).rpc));\n\n return () => {\n client.close?.();\n if (previous !== undefined) pageChannel.attach(previous);\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editors.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/source-overlay/editors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"editors.d.ts","sourceRoot":"","sources":["../../../src/lib/runtime/source-overlay/editors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAWjD,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAsBxD,CAAC;AAIF,eAAO,MAAM,aAAa,WAChB,YAAY,GAAG,MAAM,GAAG,SAAS,KACxC,YAMF,CAAC"}
|
|
@@ -3,20 +3,25 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
5
|
*/
|
|
6
|
+
// `<scheme>://file/` already ends in the slash that starts a POSIX path, so a
|
|
7
|
+
// second one would put `//Users/...` in the URL path, which VS Code-family
|
|
8
|
+
// editors only resolve by accident. Drop exactly one: Windows drive paths have
|
|
9
|
+
// none to drop, and a UNC `//server/share` keeps the double slash it needs.
|
|
10
|
+
const filePath = (path) => (path.startsWith('/') ? path.slice(1) : path);
|
|
6
11
|
// Keep the keys/labels in sync with SOURCE_OVERLAY_EDITORS in
|
|
7
12
|
// src/types/timeline.ts (the panel's editor-selection options).
|
|
8
13
|
export const BUILTIN_EDITORS = {
|
|
9
14
|
vscode: {
|
|
10
15
|
name: 'VS Code',
|
|
11
|
-
url: (path, line) => `vscode://file/${path}:${line}`,
|
|
16
|
+
url: (path, line) => `vscode://file/${filePath(path)}:${line}`,
|
|
12
17
|
},
|
|
13
18
|
cursor: {
|
|
14
19
|
name: 'Cursor',
|
|
15
|
-
url: (path, line) => `cursor://file/${path}:${line}`,
|
|
20
|
+
url: (path, line) => `cursor://file/${filePath(path)}:${line}`,
|
|
16
21
|
},
|
|
17
22
|
zed: {
|
|
18
23
|
name: 'Zed',
|
|
19
|
-
url: (path, line) => `zed://file/${path}:${line}`,
|
|
24
|
+
url: (path, line) => `zed://file/${filePath(path)}:${line}`,
|
|
20
25
|
},
|
|
21
26
|
idea: {
|
|
22
27
|
name: 'IntelliJ',
|
|
@@ -25,7 +30,7 @@ export const BUILTIN_EDITORS = {
|
|
|
25
30
|
},
|
|
26
31
|
windsurf: {
|
|
27
32
|
name: 'Windsurf',
|
|
28
|
-
url: (path, line) => `windsurf://file/${path}:${line}`,
|
|
33
|
+
url: (path, line) => `windsurf://file/${filePath(path)}:${line}`,
|
|
29
34
|
},
|
|
30
35
|
};
|
|
31
36
|
// Resolve an editor option to a config: a builtin name, a custom config, or the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editors.js","sourceRoot":"","sources":["../../../src/lib/runtime/source-overlay/editors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,8DAA8D;AAC9D,gEAAgE;AAChE,MAAM,CAAC,MAAM,eAAe,GAAiC;IAC3D,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,iBAAiB,IAAI,IAAI,IAAI,EAAE;
|
|
1
|
+
{"version":3,"file":"editors.js","sourceRoot":"","sources":["../../../src/lib/runtime/source-overlay/editors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,8EAA8E;AAC9E,2EAA2E;AAC3E,+EAA+E;AAC/E,4EAA4E;AAC5E,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAChC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE9C,8DAA8D;AAC9D,gEAAgE;AAChE,MAAM,CAAC,MAAM,eAAe,GAAiC;IAC3D,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,iBAAiB,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE;KAC/D;IACD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,iBAAiB,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE;KAC/D;IACD,GAAG,EAAE;QACH,IAAI,EAAE,KAAK;QACX,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,cAAc,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE;KAC5D;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAClB,oBAAoB,kBAAkB,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE;KAC9D;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,mBAAmB,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE;KACjE;CACF,CAAC;AAEF,gFAAgF;AAChF,mEAAmE;AACnE,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,MAAyC,EAC3B,EAAE;IAChB,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,eAAe,CAAC,MAAM,CAAC;IACxD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC;IAC3D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport type {EditorConfig} from '../../types.js';\n\n// `<scheme>://file/` already ends in the slash that starts a POSIX path, so a\n// second one would put `//Users/...` in the URL path, which VS Code-family\n// editors only resolve by accident. Drop exactly one: Windows drive paths have\n// none to drop, and a UNC `//server/share` keeps the double slash it needs.\nconst filePath = (path: string) =>\n path.startsWith('/') ? path.slice(1) : path;\n\n// Keep the keys/labels in sync with SOURCE_OVERLAY_EDITORS in\n// src/types/timeline.ts (the panel's editor-selection options).\nexport const BUILTIN_EDITORS: Record<string, EditorConfig> = {\n vscode: {\n name: 'VS Code',\n url: (path, line) => `vscode://file/${filePath(path)}:${line}`,\n },\n cursor: {\n name: 'Cursor',\n url: (path, line) => `cursor://file/${filePath(path)}:${line}`,\n },\n zed: {\n name: 'Zed',\n url: (path, line) => `zed://file/${filePath(path)}:${line}`,\n },\n idea: {\n name: 'IntelliJ',\n url: (path, line) =>\n `idea://open?file=${encodeURIComponent(path)}&line=${line}`,\n },\n windsurf: {\n name: 'Windsurf',\n url: (path, line) => `windsurf://file/${filePath(path)}:${line}`,\n },\n};\n\n// Resolve an editor option to a config: a builtin name, a custom config, or the\n// VS Code default (also used as the fallback for an unknown name).\nexport const resolveEditor = (\n editor: EditorConfig | string | undefined\n): EditorConfig => {\n if (editor === undefined) return BUILTIN_EDITORS.vscode;\n if (typeof editor === 'string') {\n return BUILTIN_EDITORS[editor] ?? BUILTIN_EDITORS.vscode;\n }\n return editor;\n};\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Entry of the script `lit-devtools dev` serves at `/lit-devtools.js`.
|
|
8
|
+
*
|
|
9
|
+
* Bundled as a classic IIFE (see `src/standalone/vite.config.ts`) so a page
|
|
10
|
+
* that is not served by Vite, and may be on another origin, can load it with a
|
|
11
|
+
* plain `<script src>`: classic scripts load cross-origin without CORS.
|
|
12
|
+
* Importing the install modules starts the capture layers and the inspector;
|
|
13
|
+
* {@link connectToDevServer} then attaches the RPC carrier they announce
|
|
14
|
+
* themselves through.
|
|
15
|
+
*
|
|
16
|
+
* The server is wherever this script came from: behind a proxy or tunnel
|
|
17
|
+
* (StackBlitz, Codespaces, ngrok) that is the public address the browser used,
|
|
18
|
+
* not the one the server sees itself on. `globalThis.__LIT_DEVTOOLS_CONNECT__`,
|
|
19
|
+
* which the server prepends to the script, carries its connection descriptor,
|
|
20
|
+
* so this page never has to `fetch` `__connection.json` (a cross-origin fetch
|
|
21
|
+
* the server does not answer with CORS headers). The descriptor holds paths
|
|
22
|
+
* only, so it resolves against either address. Its `url` is the fallback for
|
|
23
|
+
* when the script's own address is unknown.
|
|
24
|
+
*/
|
|
25
|
+
import './timeline/install.js';
|
|
26
|
+
import './inspector/install.js';
|
|
27
|
+
//# sourceMappingURL=standalone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/standalone.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Entry of the script `lit-devtools dev` serves at `/lit-devtools.js`.
|
|
8
|
+
*
|
|
9
|
+
* Bundled as a classic IIFE (see `src/standalone/vite.config.ts`) so a page
|
|
10
|
+
* that is not served by Vite, and may be on another origin, can load it with a
|
|
11
|
+
* plain `<script src>`: classic scripts load cross-origin without CORS.
|
|
12
|
+
* Importing the install modules starts the capture layers and the inspector;
|
|
13
|
+
* {@link connectToDevServer} then attaches the RPC carrier they announce
|
|
14
|
+
* themselves through.
|
|
15
|
+
*
|
|
16
|
+
* The server is wherever this script came from: behind a proxy or tunnel
|
|
17
|
+
* (StackBlitz, Codespaces, ngrok) that is the public address the browser used,
|
|
18
|
+
* not the one the server sees itself on. `globalThis.__LIT_DEVTOOLS_CONNECT__`,
|
|
19
|
+
* which the server prepends to the script, carries its connection descriptor,
|
|
20
|
+
* so this page never has to `fetch` `__connection.json` (a cross-origin fetch
|
|
21
|
+
* the server does not answer with CORS headers). The descriptor holds paths
|
|
22
|
+
* only, so it resolves against either address. Its `url` is the fallback for
|
|
23
|
+
* when the script's own address is unknown.
|
|
24
|
+
*/
|
|
25
|
+
import './timeline/install.js';
|
|
26
|
+
import './inspector/install.js';
|
|
27
|
+
import {connectToDevServer} from './rpc-transport.js';
|
|
28
|
+
const config = globalThis.__LIT_DEVTOOLS_CONNECT__ ?? {};
|
|
29
|
+
const script = document.currentScript;
|
|
30
|
+
const url =
|
|
31
|
+
script instanceof HTMLScriptElement && script.src !== ''
|
|
32
|
+
? new URL('.', script.src).href
|
|
33
|
+
: config.url;
|
|
34
|
+
if (url === undefined) {
|
|
35
|
+
console.error(
|
|
36
|
+
'[lit-devtools] cannot tell which dev server to connect to: load this ' +
|
|
37
|
+
'script from the server with <script src="http://localhost:5180/lit-devtools.js">.'
|
|
38
|
+
);
|
|
39
|
+
} else {
|
|
40
|
+
connectToDevServer(url, {connectionMeta: config.connectionMeta}).then(
|
|
41
|
+
() => console.info(`[lit-devtools] connected to ${url}`),
|
|
42
|
+
(error) =>
|
|
43
|
+
console.error(
|
|
44
|
+
`[lit-devtools] could not connect to ${url}. Is \`lit-devtools dev\` ` +
|
|
45
|
+
`running, and does it allow this page's origin (--allow-origin)?`,
|
|
46
|
+
error
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=standalone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standalone.js","sourceRoot":"","sources":["../../src/lib/runtime/standalone.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,wBAAwB,CAAC;AAChC,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAQtD,MAAM,MAAM,GACT,UAA4D;KAC1D,wBAAwB,IAAI,EAAE,CAAC;AAEpC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC;AACtC,MAAM,GAAG,GACP,MAAM,YAAY,iBAAiB,IAAI,MAAM,CAAC,GAAG,KAAK,EAAE;IACtD,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI;IAC/B,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;AAEjB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;IACtB,OAAO,CAAC,KAAK,CACX,uEAAuE;QACrE,mFAAmF,CACtF,CAAC;AACJ,CAAC;KAAM,CAAC;IACN,kBAAkB,CAAC,GAAG,EAAE,EAAC,cAAc,EAAE,MAAM,CAAC,cAAc,EAAC,CAAC,CAAC,IAAI,CACnE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,+BAA+B,GAAG,EAAE,CAAC,EACxD,CAAC,KAAK,EAAE,EAAE,CACR,OAAO,CAAC,KAAK,CACX,uCAAuC,GAAG,4BAA4B;QACpE,iEAAiE,EACnE,KAAK,CACN,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Entry of the script `lit-devtools dev` serves at `/lit-devtools.js`.\n *\n * Bundled as a classic IIFE (see `src/standalone/vite.config.ts`) so a page\n * that is not served by Vite, and may be on another origin, can load it with a\n * plain `<script src>`: classic scripts load cross-origin without CORS.\n * Importing the install modules starts the capture layers and the inspector;\n * {@link connectToDevServer} then attaches the RPC carrier they announce\n * themselves through.\n *\n * The server is wherever this script came from: behind a proxy or tunnel\n * (StackBlitz, Codespaces, ngrok) that is the public address the browser used,\n * not the one the server sees itself on. `globalThis.__LIT_DEVTOOLS_CONNECT__`,\n * which the server prepends to the script, carries its connection descriptor,\n * so this page never has to `fetch` `__connection.json` (a cross-origin fetch\n * the server does not answer with CORS headers). The descriptor holds paths\n * only, so it resolves against either address. Its `url` is the fallback for\n * when the script's own address is unknown.\n */\n\nimport './timeline/install.js';\nimport './inspector/install.js';\nimport {connectToDevServer} from './rpc-transport.js';\nimport type {ConnectOptions} from './rpc-transport.js';\n\ninterface StandaloneConfig {\n url?: string;\n connectionMeta?: ConnectOptions['connectionMeta'];\n}\n\nconst config =\n (globalThis as {__LIT_DEVTOOLS_CONNECT__?: StandaloneConfig})\n .__LIT_DEVTOOLS_CONNECT__ ?? {};\n\nconst script = document.currentScript;\nconst url =\n script instanceof HTMLScriptElement && script.src !== ''\n ? new URL('.', script.src).href\n : config.url;\n\nif (url === undefined) {\n console.error(\n '[lit-devtools] cannot tell which dev server to connect to: load this ' +\n 'script from the server with <script src=\"http://localhost:5180/lit-devtools.js\">.'\n );\n} else {\n connectToDevServer(url, {connectionMeta: config.connectionMeta}).then(\n () => console.info(`[lit-devtools] connected to ${url}`),\n (error) =>\n console.error(\n `[lit-devtools] could not connect to ${url}. Is \\`lit-devtools dev\\` ` +\n `running, and does it allow this page's origin (--allow-origin)?`,\n error\n )\n );\n}\n"]}
|
|
@@ -86,8 +86,10 @@ subscribeOverride(hot, (o) => {
|
|
|
86
86
|
syncRenderDebug();
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
|
-
if (hot !== undefined)
|
|
90
|
-
|
|
89
|
+
if (hot !== undefined) pageChannel.useViteHot(hot);
|
|
90
|
+
// Wired whether or not Vite is present: a page outside Vite gets its carrier
|
|
91
|
+
// later from `connectToDevServer()`, and these listeners move onto it then.
|
|
92
|
+
{
|
|
91
93
|
setHotClient(pageChannel);
|
|
92
94
|
// Panel → app: toggle recording and per-layer flags.
|
|
93
95
|
pageChannel.on('lit:timeline:recording-changed', (data) => {
|
|
@@ -1 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EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,WAAW,CAAC,EAAE,CAAC,6BAA6B,EAAE,CAAC,IAAI,EAAE,EAAE;QACrD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAoC,CAAC,CAAC;QAC3D,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,0DAA0D;IAC1D,WAAW,CAAC,IAAI,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAC;IACnD,iEAAiE;IACjE,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,CACxB,WAAW,CAAC,IAAI,CAAC,4BAA4B,EAAE,EAAE,CAAC,CACnD,CAAC;AACJ,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Timeline runtime install entry point.\n *\n * Injected by the plugin into the host page via `transformIndexHtml` when\n * `timeline: true` is set. Sets up all capture layers and wires them to the\n * transport.\n *\n * Recording starts off; the panel iframe toggles it via the Vite HMR channel\n * (Phase 0/1) or devframe shared state (Phase 2+). Layers capture while the\n * panel is recording OR the \"chrome performance tracks\" preference is on; the\n * panel transport only receives events while recording, the Chrome tracks sink\n * only while the preference is on.\n */\n\nimport {emit, setHotClient} from './transport.js';\nimport {resetClock} from './clock.js';\nimport {createChromeTracksSink} from './chrome-tracks.js';\nimport {installLifecycleLayer, setUpdateHook} from './lifecycle.js';\nimport {installRenderLayer, setRenderDebugEnabled} from './render.js';\nimport {installMouseLayer, installKeyboardLayer} from './input.js';\nimport {flashUpdate, setFlashEnabled, setFlashRamp} from './flash.js';\nimport {subscribeOverride} from '../overrides.js';\nimport {pageChannel} from '../page-channel.js';\nimport type {ViteHotLike} from '../page-channel.js';\nimport type {\n TimelineEvent,\n TimelineLayersState,\n} from '../../../types/timeline.js';\n\n// ---------------------------------------------------------------------------\n// Recording state — written by the panel toggle, read by all capture layers.\n// ---------------------------------------------------------------------------\n\nconst state: TimelineLayersState = {\n recordingState: false,\n litLifecycleEnabled: true,\n litRenderEnabled: true,\n litRenderVerboseEnabled: false,\n mouseEventEnabled: false,\n keyboardEventEnabled: false,\n};\n\n// Mirror to Chrome DevTools' Performance panel; a page-side preference driven\n// by the settings override, independent of panel recording.\nlet chromeTracks = false;\nconst sink = createChromeTracksSink();\n\n// Layers run when either consumer wants events.\nconst capturing = (): boolean => state.recordingState || chromeTracks;\nconst out = (e: TimelineEvent): void => {\n if (state.recordingState) emit(e);\n if (chromeTracks) sink.push(e);\n};\nconst lifecycleEnabled = (): boolean => state.litLifecycleEnabled;\nconst renderEnabled = (): boolean => state.litRenderEnabled;\nconst renderVerboseEnabled = (): boolean => state.litRenderVerboseEnabled;\nconst mouseEnabled = (): boolean => state.mouseEventEnabled;\nconst keyboardEnabled = (): boolean => state.keyboardEventEnabled;\n\n// Drive Lit's debug event flag from capturing × (render-layer-enabled OR\n// verbose-layer-enabled) so lit-html only pays the per-render CustomEvent\n// dispatch cost while we're actually capturing one of the two render layers.\nconst syncRenderDebug = (): void => {\n setRenderDebugEnabled(\n capturing() && (state.litRenderEnabled || state.litRenderVerboseEnabled)\n );\n};\n\n// ---------------------------------------------------------------------------\n// Capture layer installation\n// ---------------------------------------------------------------------------\n\ninstallLifecycleLayer(out, capturing, lifecycleEnabled);\ninstallRenderLayer(out, capturing, renderEnabled, renderVerboseEnabled);\ninstallMouseLayer(out, capturing, mouseEnabled);\ninstallKeyboardLayer(out, capturing, keyboardEnabled);\n\n// Flash-on-update rides the lifecycle wrappers but not the recording gate:\n// it's a page-side visual the panel toggles as a preference, so it follows the\n// settings override (read at boot, pushed live) rather than the layer state.\nsetUpdateHook(flashUpdate);\n\n// ---------------------------------------------------------------------------\n// Page channel wiring\n// ---------------------------------------------------------------------------\n\n// `import.meta.hot` exists in Vite dev builds; the tsconfig lib set doesn't\n// include it, so we access it through the un-typed global shape.\nconst hot = (import.meta as {hot?: ViteHotLike}).hot;\n\nsubscribeOverride(hot, (o) => {\n setFlashEnabled(o.flashUpdates ?? false);\n setFlashRamp(o.flashUpdatesRamp ?? false);\n const next = o.chromeTracks ?? false;\n if (next !== chromeTracks) {\n chromeTracks = next;\n if (!next) sink.reset();\n syncRenderDebug();\n }\n});\n\nif (hot !== undefined) pageChannel.useViteHot(hot);\n\n// Wired whether or not Vite is present: a page outside Vite gets its carrier\n// later from `connectToDevServer()`, and these listeners move onto it then.\n{\n setHotClient(pageChannel);\n\n // Panel → app: toggle recording and per-layer flags.\n pageChannel.on('lit:timeline:recording-changed', (data) => {\n const next = (data as {recording: boolean}).recording;\n // Re-zero the timeline clock on the rising edge so event times read as\n // \"ms since recording started\" rather than since page load.\n if (next && !state.recordingState) resetClock();\n state.recordingState = next;\n syncRenderDebug();\n });\n\n pageChannel.on('lit:timeline:layers-changed', (data) => {\n Object.assign(state, data as Partial<TimelineLayersState>);\n syncRenderDebug();\n });\n\n // Announce readiness so the panel can detect the runtime.\n pageChannel.send('lit:timeline:runtime-ready', {});\n // A carrier attached later starts with no idea a runtime exists.\n pageChannel.onAttach(() =>\n pageChannel.send('lit:timeline:runtime-ready', {})\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,IA6BF,CAAC"}
|
|
@@ -211,12 +211,16 @@ export const installLifecycleLayer = (emit, recording, enabled) => {
|
|
|
211
211
|
// per prototype+method), so re-running once the shared bases are wrapped is a
|
|
212
212
|
// cheap no-op.
|
|
213
213
|
const origDefine = customElements.define.bind(customElements);
|
|
214
|
+
// Patch before defining: the platform reads connectedCallback and
|
|
215
|
+
// disconnectedCallback off the prototype at define() time, so wrapping them
|
|
216
|
+
// afterwards would miss the first component defined on a page with no Lit
|
|
217
|
+
// element yet.
|
|
214
218
|
customElements.define = (name, ctor, options) => {
|
|
215
|
-
origDefine(name, ctor, options);
|
|
216
219
|
const p = ctor?.prototype;
|
|
217
220
|
if (p != null && 'performUpdate' in p) {
|
|
218
221
|
patchBases(p, emit, recording, enabled);
|
|
219
222
|
}
|
|
223
|
+
origDefine(name, ctor, options);
|
|
220
224
|
};
|
|
221
225
|
};
|
|
222
226
|
/**
|