@oddsquad/vite-plugin-lit 0.0.5 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/plugin.d.ts +47 -1
- package/lib/plugin.d.ts.map +1 -1
- package/lib/plugin.js +142 -67
- package/lib/plugin.js.map +1 -1
- package/package.json +1 -1
package/lib/plugin.d.ts
CHANGED
|
@@ -46,6 +46,17 @@ export interface HmrOptions {
|
|
|
46
46
|
*/
|
|
47
47
|
indicator?: boolean | HmrIndicatorOptions;
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* What a `?css-sheet` import compiles to under `vite build`.
|
|
51
|
+
*
|
|
52
|
+
* - `'url'`: fetch-backed sheet over the emitted `.css` asset.
|
|
53
|
+
* - `'inline'`: css text embedded in the JS chunk, processed by the css
|
|
54
|
+
* pipeline (`?inline`).
|
|
55
|
+
* - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline
|
|
56
|
+
* (`?raw`).
|
|
57
|
+
* - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise.
|
|
58
|
+
*/
|
|
59
|
+
export type CssSheetBuild = 'auto' | 'url' | 'inline' | 'inline-raw';
|
|
49
60
|
/**
|
|
50
61
|
* Options for the Lit Vite plugin.
|
|
51
62
|
*
|
|
@@ -77,14 +88,49 @@ export interface LitPluginOptions {
|
|
|
77
88
|
* `true` enables all built-in layers with defaults.
|
|
78
89
|
*/
|
|
79
90
|
timeline?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* What a `?css-sheet` import compiles to under `vite build`.
|
|
93
|
+
* - `'url'`: fetch-backed sheet over the emitted `.css` asset
|
|
94
|
+
* - `'inline'`: css text embedded in the JS chunk, processed by the css
|
|
95
|
+
* pipeline (`?inline`)
|
|
96
|
+
* - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline
|
|
97
|
+
* (`?raw`)
|
|
98
|
+
* - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise
|
|
99
|
+
*
|
|
100
|
+
* Dev is always the fetch-backed HMR form regardless of this setting.
|
|
101
|
+
* Defaults to `'auto'`.
|
|
102
|
+
*/
|
|
103
|
+
cssSheetBuild?: CssSheetBuild;
|
|
104
|
+
}
|
|
105
|
+
/** Plugin options after merging explicit options, env vars, and defaults. */
|
|
106
|
+
export interface ResolvedOptions {
|
|
107
|
+
hmrEnabled: boolean;
|
|
108
|
+
reconnect: boolean;
|
|
109
|
+
onIncompatible: 'reload' | 'warn';
|
|
110
|
+
indicator: false | {
|
|
111
|
+
count: boolean;
|
|
112
|
+
};
|
|
113
|
+
sourceOverlay: false | SourceOverlayOptions;
|
|
114
|
+
timeline: boolean;
|
|
115
|
+
cssSheetBuild: CssSheetBuild;
|
|
80
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Merge explicit options over env vars over defaults (in that precedence) into
|
|
119
|
+
* the flat shape the plugin hooks consume.
|
|
120
|
+
*/
|
|
121
|
+
export declare const resolveOptions: (options: LitPluginOptions, env: Record<string, string>) => ResolvedOptions;
|
|
81
122
|
/**
|
|
82
123
|
* Import-query support, served in dev and build alike (source code using
|
|
83
124
|
* `?hmr-url`/`?css-sheet` must keep working under `vite build`, where the HMR
|
|
84
125
|
* plugin doesn't apply). Exported for the baseline e2e run, which needs the
|
|
85
126
|
* queries working without the HMR plugin.
|
|
127
|
+
*
|
|
128
|
+
* `getCssSheetBuild` is a getter, not a value: `litPlugin()` re-resolves its
|
|
129
|
+
* options against the loaded env in a `config` hook, which runs after the
|
|
130
|
+
* plugin array is built. Standalone (no getter) it behaves like the `'auto'`
|
|
131
|
+
* default.
|
|
86
132
|
*/
|
|
87
|
-
export declare const litCssQueries: () => Plugin;
|
|
133
|
+
export declare const litCssQueries: (getCssSheetBuild?: () => CssSheetBuild) => Plugin;
|
|
88
134
|
/**
|
|
89
135
|
* Vite plugin set providing HMR, CSS helpers, and Lightning CSS processing
|
|
90
136
|
* for Lit projects.
|
package/lib/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAA2B,KAAK,MAAM,EAAC,MAAM,MAAM,CAAC;AAI3D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAKrD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAEnC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC;CAC3C;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAE3B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,oBAAoB,CAAC;IAE/C;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAA2B,KAAK,MAAM,EAAC,MAAM,MAAM,CAAC;AAI3D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAKrD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IA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BAAkB,MAAM,aAA4B,KACnD,MAwFF,CAAC;AAuFF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,UAAS,gBAAqB,KAAG,MAAM,EAqRhE,CAAC"}
|
package/lib/plugin.js
CHANGED
|
@@ -12,6 +12,12 @@ import { injectSourceMeta } from './source-meta.js';
|
|
|
12
12
|
import { INSTALL_ID, VIRTUAL_PREFIX, transformLitModule } from './transform.js';
|
|
13
13
|
import { WRAP_TABLE } from './wrap-table.js';
|
|
14
14
|
import { litTimelinePlugin } from './timeline-plugin.js';
|
|
15
|
+
const CSS_SHEET_BUILD_MODES = [
|
|
16
|
+
'auto',
|
|
17
|
+
'url',
|
|
18
|
+
'inline',
|
|
19
|
+
'inline-raw',
|
|
20
|
+
];
|
|
15
21
|
/** Env var prefix consumed at config time. */
|
|
16
22
|
const ENV_PREFIX = 'LIT_PLUGIN';
|
|
17
23
|
/** Parse a boolean-ish env string; `undefined` when unset/unrecognized. */
|
|
@@ -27,11 +33,25 @@ const envNum = (v) => {
|
|
|
27
33
|
const n = Number(v);
|
|
28
34
|
return Number.isNaN(n) ? undefined : n;
|
|
29
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Parse a string against a closed set of values; `undefined` (with a warning)
|
|
38
|
+
* when set to something outside it, so a typo falls back to the default
|
|
39
|
+
* instead of silently disabling a feature.
|
|
40
|
+
*/
|
|
41
|
+
const envEnum = (v, allowed, source) => {
|
|
42
|
+
if (v === undefined || v === '')
|
|
43
|
+
return undefined;
|
|
44
|
+
if (allowed.includes(v))
|
|
45
|
+
return v;
|
|
46
|
+
console.warn(`[lit-plugin] ignoring ${source}=${JSON.stringify(v)}; expected one of ` +
|
|
47
|
+
allowed.map((a) => JSON.stringify(a)).join(', '));
|
|
48
|
+
return undefined;
|
|
49
|
+
};
|
|
30
50
|
/**
|
|
31
51
|
* Merge explicit options over env vars over defaults (in that precedence) into
|
|
32
52
|
* the flat shape the plugin hooks consume.
|
|
33
53
|
*/
|
|
34
|
-
const resolveOptions = (options, env) => {
|
|
54
|
+
export const resolveOptions = (options, env) => {
|
|
35
55
|
const hmr = options.hmr;
|
|
36
56
|
const hmrObj = typeof hmr === 'object' ? hmr : undefined;
|
|
37
57
|
const hmrEnabled = (typeof hmr === 'boolean' ? hmr : hmrObj?.enabled) ??
|
|
@@ -61,6 +81,9 @@ const resolveOptions = (options, env) => {
|
|
|
61
81
|
sourceOverlay = base;
|
|
62
82
|
}
|
|
63
83
|
const timeline = options.timeline ?? envBool(env[`${ENV_PREFIX}_TIMELINE`]) ?? false;
|
|
84
|
+
const cssSheetBuild = envEnum(options.cssSheetBuild, CSS_SHEET_BUILD_MODES, 'cssSheetBuild') ??
|
|
85
|
+
envEnum(env[`${ENV_PREFIX}_CSS_SHEET_BUILD`], CSS_SHEET_BUILD_MODES, `${ENV_PREFIX}_CSS_SHEET_BUILD`) ??
|
|
86
|
+
'auto';
|
|
64
87
|
return {
|
|
65
88
|
hmrEnabled,
|
|
66
89
|
reconnect,
|
|
@@ -68,6 +91,7 @@ const resolveOptions = (options, env) => {
|
|
|
68
91
|
indicator,
|
|
69
92
|
sourceOverlay,
|
|
70
93
|
timeline,
|
|
94
|
+
cssSheetBuild,
|
|
71
95
|
};
|
|
72
96
|
};
|
|
73
97
|
/**
|
|
@@ -203,6 +227,11 @@ const CSS_URL_VIRTUAL_PREFIX = '\0lit-plugin:hmr-url:';
|
|
|
203
227
|
* a plugin-generated module: the `import.meta.hot.accept` lives here (where
|
|
204
228
|
* Vite's static analysis sees the literal specifier), so callers write a bare
|
|
205
229
|
* import and never touch `import.meta.hot` themselves.
|
|
230
|
+
*
|
|
231
|
+
* Under `vite build` the generated module can instead inline the css text (see
|
|
232
|
+
* `cssSheetBuild`) — a library's consumers bundle its JS only, so a
|
|
233
|
+
* fetch-backed sheet would 404 on the `.css` asset that never reached their
|
|
234
|
+
* build.
|
|
206
235
|
*/
|
|
207
236
|
const CSS_SHEET_QUERY_RE = /^([^?]+\.css)\?(?:[^&]*&)*css-sheet(?:&.*)?$/;
|
|
208
237
|
const CSS_SHEET_VIRTUAL_PREFIX = '\0lit-plugin:css-sheet:';
|
|
@@ -214,60 +243,91 @@ const CSS_VIRTUAL_SUFFIX = '.js';
|
|
|
214
243
|
* `?hmr-url`/`?css-sheet` must keep working under `vite build`, where the HMR
|
|
215
244
|
* plugin doesn't apply). Exported for the baseline e2e run, which needs the
|
|
216
245
|
* queries working without the HMR plugin.
|
|
246
|
+
*
|
|
247
|
+
* `getCssSheetBuild` is a getter, not a value: `litPlugin()` re-resolves its
|
|
248
|
+
* options against the loaded env in a `config` hook, which runs after the
|
|
249
|
+
* plugin array is built. Standalone (no getter) it behaves like the `'auto'`
|
|
250
|
+
* default.
|
|
217
251
|
*/
|
|
218
|
-
export const litCssQueries = () =>
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
252
|
+
export const litCssQueries = (getCssSheetBuild = () => 'auto') => {
|
|
253
|
+
let isBuild = false;
|
|
254
|
+
let isLib = false;
|
|
255
|
+
return {
|
|
256
|
+
name: 'lit-css-query',
|
|
257
|
+
// Vite's core resolver claims `./x.css?hmr-url` for the CSS pipeline
|
|
258
|
+
// before normal plugins get a look, so resolve ahead of it.
|
|
259
|
+
enforce: 'pre',
|
|
260
|
+
configResolved(config) {
|
|
261
|
+
isBuild = config.command === 'build';
|
|
262
|
+
isLib = config.build.lib !== false && config.build.lib !== undefined;
|
|
263
|
+
},
|
|
264
|
+
async resolveId(id, importer) {
|
|
265
|
+
const prefix = CSS_URL_QUERY_RE.test(id)
|
|
266
|
+
? CSS_URL_VIRTUAL_PREFIX
|
|
267
|
+
: CSS_SHEET_QUERY_RE.test(id)
|
|
268
|
+
? CSS_SHEET_VIRTUAL_PREFIX
|
|
269
|
+
: null;
|
|
270
|
+
if (prefix === null) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
const file = id.slice(0, id.indexOf('?'));
|
|
274
|
+
const resolved = await this.resolve(file, importer);
|
|
275
|
+
if (resolved === null) {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
return prefix + resolved.id + CSS_VIRTUAL_SUFFIX;
|
|
279
|
+
},
|
|
280
|
+
load(id) {
|
|
281
|
+
const helperPath = resolveRuntimeModule('css');
|
|
282
|
+
if (id.startsWith(CSS_URL_VIRTUAL_PREFIX)) {
|
|
283
|
+
const file = id.slice(CSS_URL_VIRTUAL_PREFIX.length, -CSS_VIRTUAL_SUFFIX.length);
|
|
284
|
+
return {
|
|
285
|
+
code: `import url from ${JSON.stringify(`${file}?url`)};\n` +
|
|
286
|
+
`import {devCacheBust} from ${JSON.stringify(helperPath)};\n` +
|
|
287
|
+
`export default devCacheBust(url);\n`,
|
|
288
|
+
moduleType: 'js',
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
if (id.startsWith(CSS_SHEET_VIRTUAL_PREFIX)) {
|
|
292
|
+
const file = id.slice(CSS_SHEET_VIRTUAL_PREFIX.length, -CSS_VIRTUAL_SUFFIX.length);
|
|
293
|
+
const mode = getCssSheetBuild();
|
|
294
|
+
const inlineQuery = !isBuild || mode === 'url' || (mode === 'auto' && !isLib)
|
|
295
|
+
? null
|
|
296
|
+
: mode === 'inline-raw'
|
|
297
|
+
? '?raw'
|
|
298
|
+
: '?inline';
|
|
299
|
+
if (inlineQuery !== null) {
|
|
300
|
+
// Build only, so no `import.meta.hot` block. The sheet is still
|
|
301
|
+
// constructed once per virtual module, so adopters share it exactly
|
|
302
|
+
// as they do in the fetch-backed form.
|
|
303
|
+
return {
|
|
304
|
+
code: `import css from ${JSON.stringify(`${file}${inlineQuery}`)};\n` +
|
|
305
|
+
`const sheet = new CSSStyleSheet();\n` +
|
|
306
|
+
`sheet.replaceSync(css);\n` +
|
|
307
|
+
`export default sheet;\n`,
|
|
308
|
+
moduleType: 'js',
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
// The accept specifier must be byte-identical to the import above —
|
|
312
|
+
// Vite resolves accepted HMR deps by static analysis. Generating both
|
|
313
|
+
// here is exactly what frees the caller from writing it. The swap is
|
|
314
|
+
// self-accepted at this boundary, so it never propagates to adopters.
|
|
315
|
+
const urlSpecifier = JSON.stringify(`${file}?url`);
|
|
316
|
+
return {
|
|
317
|
+
code: `import url from ${urlSpecifier};\n` +
|
|
318
|
+
`import {urlSheet} from ${JSON.stringify(helperPath)};\n` +
|
|
319
|
+
`const {sheet, onHotUpdate} = urlSheet(url);\n` +
|
|
320
|
+
`export default sheet;\n` +
|
|
321
|
+
`if (import.meta.hot) {\n` +
|
|
322
|
+
` import.meta.hot.accept(${urlSpecifier}, onHotUpdate);\n` +
|
|
323
|
+
`}\n`,
|
|
324
|
+
moduleType: 'js',
|
|
325
|
+
};
|
|
326
|
+
}
|
|
235
327
|
return null;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
load(id) {
|
|
240
|
-
const helperPath = resolveRuntimeModule('css');
|
|
241
|
-
if (id.startsWith(CSS_URL_VIRTUAL_PREFIX)) {
|
|
242
|
-
const file = id.slice(CSS_URL_VIRTUAL_PREFIX.length, -CSS_VIRTUAL_SUFFIX.length);
|
|
243
|
-
return {
|
|
244
|
-
code: `import url from ${JSON.stringify(`${file}?url`)};\n` +
|
|
245
|
-
`import {devCacheBust} from ${JSON.stringify(helperPath)};\n` +
|
|
246
|
-
`export default devCacheBust(url);\n`,
|
|
247
|
-
moduleType: 'js',
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
if (id.startsWith(CSS_SHEET_VIRTUAL_PREFIX)) {
|
|
251
|
-
const file = id.slice(CSS_SHEET_VIRTUAL_PREFIX.length, -CSS_VIRTUAL_SUFFIX.length);
|
|
252
|
-
// The accept specifier must be byte-identical to the import above —
|
|
253
|
-
// Vite resolves accepted HMR deps by static analysis. Generating both
|
|
254
|
-
// here is exactly what frees the caller from writing it. The swap is
|
|
255
|
-
// self-accepted at this boundary, so it never propagates to adopters.
|
|
256
|
-
const urlSpecifier = JSON.stringify(`${file}?url`);
|
|
257
|
-
return {
|
|
258
|
-
code: `import url from ${urlSpecifier};\n` +
|
|
259
|
-
`import {urlSheet} from ${JSON.stringify(helperPath)};\n` +
|
|
260
|
-
`const {sheet, onHotUpdate} = urlSheet(url);\n` +
|
|
261
|
-
`export default sheet;\n` +
|
|
262
|
-
`if (import.meta.hot) {\n` +
|
|
263
|
-
` import.meta.hot.accept(${urlSpecifier}, onHotUpdate);\n` +
|
|
264
|
-
`}\n`,
|
|
265
|
-
moduleType: 'js',
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
return null;
|
|
269
|
-
},
|
|
270
|
-
});
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
};
|
|
271
331
|
/**
|
|
272
332
|
* A `css` tagged template literal with no interpolations and no escape
|
|
273
333
|
* sequences — the only kind we can hand to a CSS parser as-is. Literals
|
|
@@ -354,10 +414,30 @@ const litCssLiterals = () => {
|
|
|
354
414
|
*/
|
|
355
415
|
export const litPlugin = (options = {}) => {
|
|
356
416
|
// Resolved from explicit options first, env vars second, defaults last. The
|
|
357
|
-
// `config` hook re-resolves with the loaded env
|
|
358
|
-
// this initial pass covers code paths that run
|
|
417
|
+
// `lit-plugin-options` `config` hook below re-resolves with the loaded env
|
|
418
|
+
// once Vite hands us the mode; this initial pass covers code paths that run
|
|
419
|
+
// before (or without) it.
|
|
359
420
|
let resolved = resolveOptions(options, {});
|
|
360
421
|
let root = '';
|
|
422
|
+
// Env resolution lives in its own always-applied plugin: `?css-sheet` is a
|
|
423
|
+
// build-time feature too, and the HMR plugin (`apply: 'serve'`) never gets a
|
|
424
|
+
// `config` hook under `vite build`. `enforce: 'pre'` and first position put
|
|
425
|
+
// it ahead of every other hook that reads `resolved`.
|
|
426
|
+
const optionsPlugin = {
|
|
427
|
+
name: 'lit-plugin-options',
|
|
428
|
+
enforce: 'pre',
|
|
429
|
+
config(viteConfig, { mode }) {
|
|
430
|
+
// `loadEnv` reads `.env*` files from the env dir (root by default) and
|
|
431
|
+
// merges in matching `process.env` keys, filtered to the `LIT_PLUGIN`
|
|
432
|
+
// prefix. Explicit options still win (handled in resolveOptions).
|
|
433
|
+
const envDir = viteConfig.envDir
|
|
434
|
+
? resolvePath(viteConfig.envDir)
|
|
435
|
+
: viteConfig.root
|
|
436
|
+
? resolvePath(viteConfig.root)
|
|
437
|
+
: process.cwd();
|
|
438
|
+
resolved = resolveOptions(options, loadEnv(mode, envDir, ENV_PREFIX));
|
|
439
|
+
},
|
|
440
|
+
};
|
|
361
441
|
const sourceOverlayPlugin = {
|
|
362
442
|
name: 'lit-source-overlay',
|
|
363
443
|
apply: 'serve',
|
|
@@ -428,17 +508,9 @@ export const litPlugin = (options = {}) => {
|
|
|
428
508
|
const hmr = {
|
|
429
509
|
name: 'lit-plugin',
|
|
430
510
|
apply: 'serve',
|
|
431
|
-
config: (
|
|
432
|
-
//
|
|
433
|
-
// `
|
|
434
|
-
// merges in matching `process.env` keys, filtered to the `LIT_PLUGIN`
|
|
435
|
-
// prefix. Explicit options still win (handled in resolveOptions).
|
|
436
|
-
const envDir = viteConfig.envDir
|
|
437
|
-
? resolvePath(viteConfig.envDir)
|
|
438
|
-
: viteConfig.root
|
|
439
|
-
? resolvePath(viteConfig.root)
|
|
440
|
-
: process.cwd();
|
|
441
|
-
resolved = resolveOptions(options, loadEnv(mode, envDir, ENV_PREFIX));
|
|
511
|
+
config: () => {
|
|
512
|
+
// Options are already resolved against the loaded env by
|
|
513
|
+
// `lit-plugin-options`, which runs first.
|
|
442
514
|
if (!resolved.hmrEnabled) {
|
|
443
515
|
return;
|
|
444
516
|
}
|
|
@@ -578,7 +650,10 @@ export const litPlugin = (options = {}) => {
|
|
|
578
650
|
// feature is disabled (which env may decide), so inclusion can't be gated
|
|
579
651
|
// on the synchronously-known options here.
|
|
580
652
|
const plugins = [
|
|
581
|
-
|
|
653
|
+
optionsPlugin,
|
|
654
|
+
// Getter, not a snapshot: `resolved` is re-resolved against the loaded env
|
|
655
|
+
// in `optionsPlugin`'s `config` hook, which runs after this array is built.
|
|
656
|
+
litCssQueries(() => resolved.cssSheetBuild),
|
|
582
657
|
litCssLiterals(),
|
|
583
658
|
sourceOverlayPlugin,
|
|
584
659
|
hmr,
|
package/lib/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACnC,OAAO,EAAC,OAAO,IAAI,WAAW,EAAE,GAAG,EAAC,MAAM,WAAW,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,EAAC,OAAO,EAA+B,MAAM,MAAM,CAAC;AAC3D,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAG9E,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AA8FvD,8CAA8C;AAC9C,MAAM,UAAU,GAAG,YAAY,CAAC;AAEhC,2EAA2E;AAC3E,MAAM,OAAO,GAAG,CAAC,CAAqB,EAAuB,EAAE,CAC7D,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,GAAG;IACvB,CAAC,CAAC,IAAI;IACN,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,GAAG;QAC1B,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,SAAS,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AAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5C,CAAC;KACF,CAAC;IACF,wEAAwE;IACxE,0EAA0E;IAC1E,2CAA2C;IAC3C,MAAM,OAAO,GAAa;QACxB,aAAa,EAAE;QACf,cAAc,EAAE;QAChB,mBAAmB;QACnB,GAAG;KACJ,CAAC;IACF,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACtB,uEAAuE;QACvE,yEAAyE;QACzE,2EAA2E;QAC3E,WAAW;QACX,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {existsSync} from 'node:fs';\nimport {resolve as resolvePath, sep} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {loadEnv, type CSSOptions, type Plugin} from 'vite';\nimport MagicString from 'magic-string';\nimport {injectSourceMeta} from './source-meta.js';\nimport {INSTALL_ID, VIRTUAL_PREFIX, transformLitModule} from './transform.js';\nimport type {SourceOverlayOptions} from './types.js';\nimport type {FeatureSettings} from '../types/timeline.js';\nimport {WRAP_TABLE} from './wrap-table.js';\nimport {litTimelinePlugin} from './timeline-plugin.js';\n\n/**\n * On-page HMR feedback: a small pulsing indicator in the corner of the host\n * page that briefly animates on each HMR update, for at-a-glance feedback\n * without watching the console.\n */\nexport interface HmrIndicatorOptions {\n /** Inject the indicator element. Defaults to `true` (when HMR is enabled). */\n enabled?: boolean;\n\n /**\n * Show a cumulative update count next to the dot (idle opacity 0.5 instead\n * of fully transparent). Defaults to `false`.\n */\n count?: boolean;\n}\n\n/**\n * HMR for Lit component classes and its on-page feedback.\n */\nexport interface HmrOptions {\n /**\n * Enable in-place HMR for Lit component classes. When `false`, the plugin\n * skips all HMR transforms and runtime injection. Defaults to `true`.\n */\n enabled?: boolean;\n\n /**\n * Cycle `disconnectedCallback()`/`connectedCallback()` on live instances\n * after a hot patch. Interning makes this mostly unnecessary, so it's\n * opt-in. Defaults to `false`.\n */\n reconnect?: boolean;\n\n /**\n * What to do when a component can't be hot-patched in place (e.g.\n * standard `accessor` decorators). Defaults to `'reload'`.\n */\n onIncompatible?: 'reload' | 'warn';\n\n /**\n * The on-page update indicator. `true` enables it without a count; an\n * object configures it. Forced off when HMR itself is disabled. Defaults\n * to enabled (without a count).\n */\n indicator?: boolean | HmrIndicatorOptions;\n}\n\n/**\n * Options for the Lit Vite plugin.\n *\n * Every option also resolves from environment variables (and `.env` files)\n * with the `LIT_PLUGIN` prefix — e.g. `LIT_PLUGIN_HMR_INDICATOR=true`. Options\n * passed here take precedence over env vars, which take precedence over the\n * built-in defaults.\n */\nexport interface LitPluginOptions {\n /**\n * HMR for Lit components and its on-page feedback. `true`/`false` toggles\n * the whole feature (patching and indicator); an object configures it.\n * Defaults to enabled.\n */\n hmr?: boolean | HmrOptions;\n\n /**\n * Dev-only click-to-open-in-IDE inspector for Lit custom elements.\n * Toggle with Ctrl+Shift+S (configurable via `key`). Defaults to `false`.\n */\n sourceOverlay?: boolean | SourceOverlayOptions;\n\n /**\n * Vite DevTools Timeline panel — a Vue DevTools–style layered event stream\n * for Lit lifecycle, render, mouse, and keyboard events.\n *\n * Requires `@vitejs/devtools` in the Vite config and the `@vitejs/devtools`\n * Vite plugin (`DevTools()`) to be active. Defaults to `false` while\n * experimental.\n *\n * `true` enables all built-in layers with defaults.\n */\n timeline?: boolean;\n}\n\n/** Plugin options after merging explicit options, env vars, and defaults. */\ninterface ResolvedOptions {\n hmrEnabled: boolean;\n reconnect: boolean;\n onIncompatible: 'reload' | 'warn';\n indicator: false | {count: boolean};\n sourceOverlay: false | SourceOverlayOptions;\n timeline: boolean;\n}\n\n/** Env var prefix consumed at config time. */\nconst ENV_PREFIX = 'LIT_PLUGIN';\n\n/** Parse a boolean-ish env string; `undefined` when unset/unrecognized. */\nconst envBool = (v: string | undefined): boolean | undefined =>\n v === 'true' || v === '1'\n ? true\n : v === 'false' || v === '0'\n ? false\n : undefined;\n\n/** Parse a numeric env string; `undefined` when unset/non-numeric. */\nconst envNum = (v: string | undefined): number | undefined => {\n if (v === undefined || v === '') return undefined;\n const n = Number(v);\n return Number.isNaN(n) ? undefined : n;\n};\n\n/**\n * Merge explicit options over env vars over defaults (in that precedence) into\n * the flat shape the plugin hooks consume.\n */\nconst resolveOptions = (\n options: LitPluginOptions,\n env: Record<string, string>\n): ResolvedOptions => {\n const hmr = options.hmr;\n const hmrObj = typeof hmr === 'object' ? hmr : undefined;\n const hmrEnabled =\n (typeof hmr === 'boolean' ? hmr : hmrObj?.enabled) ??\n envBool(env[`${ENV_PREFIX}_HMR`]) ??\n true;\n const reconnect =\n hmrObj?.reconnect ?? envBool(env[`${ENV_PREFIX}_HMR_RECONNECT`]) ?? false;\n const onIncompatible =\n hmrObj?.onIncompatible ??\n (env[`${ENV_PREFIX}_HMR_ON_INCOMPATIBLE`] as 'reload' | 'warn') ??\n 'reload';\n\n const ind = hmrObj?.indicator;\n const indObj = typeof ind === 'object' ? ind : undefined;\n const indEnabled =\n (typeof ind === 'boolean' ? ind : indObj?.enabled) ??\n envBool(env[`${ENV_PREFIX}_HMR_INDICATOR`]) ??\n true;\n const indCount =\n indObj?.count ?? envBool(env[`${ENV_PREFIX}_HMR_INDICATOR_COUNT`]) ?? false;\n // The indicator is meaningless without HMR, so it follows the master toggle.\n const indicator = hmrEnabled && indEnabled ? {count: indCount} : false;\n\n const so = options.sourceOverlay;\n const soExplicit =\n typeof so === 'boolean' ? so : so === undefined ? undefined : true;\n const soEnabled =\n soExplicit ?? envBool(env[`${ENV_PREFIX}_SOURCE_OVERLAY`]) ?? false;\n let sourceOverlay: false | SourceOverlayOptions = false;\n if (soEnabled) {\n const base: SourceOverlayOptions = typeof so === 'object' ? {...so} : {};\n base.key ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_KEY`] || undefined;\n base.editor ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_EDITOR`] || undefined;\n base.throttleMs ??= envNum(env[`${ENV_PREFIX}_SOURCE_OVERLAY_THROTTLE_MS`]);\n sourceOverlay = base;\n }\n\n const timeline =\n options.timeline ?? envBool(env[`${ENV_PREFIX}_TIMELINE`]) ?? false;\n\n return {\n hmrEnabled,\n reconnect,\n onIncompatible,\n indicator,\n sourceOverlay,\n timeline,\n };\n};\n\n/**\n * Flattens resolved options into the JSON-serializable shape the panel's\n * Settings tab consumes (callback options like `exclude`/`onSelect` dropped;\n * a custom editor object reported as `\"custom\"`). Default key/editor/throttle\n * are applied here so the panel shows the effective values the runtime uses.\n */\nconst toFeatureSettings = (r: ResolvedOptions): FeatureSettings => {\n const so = r.sourceOverlay;\n const editor = so === false ? undefined : so.editor;\n return {\n hmr: {\n enabled: r.hmrEnabled,\n reconnect: r.reconnect,\n onIncompatible: r.onIncompatible,\n indicatorEnabled: r.indicator !== false,\n indicatorCount: r.indicator !== false && r.indicator.count,\n },\n sourceOverlay: {\n enabled: so !== false,\n key: (so === false ? undefined : so.key) ?? 's',\n editor:\n typeof editor === 'string' ? editor : editor ? 'custom' : 'vscode',\n throttleMs: (so === false ? undefined : so.throttleMs) ?? 50,\n },\n timeline: r.timeline,\n };\n};\n\n/**\n * Resolves a runtime module to an absolute fs path (served via `/@fs/`), so\n * the plugin works from any served root. Falls back from the built `.js` to\n * the `.ts` source when running un-built (e.g. under vitest).\n */\nconst resolveRuntimeModule = (name: string): string => {\n for (const ext of ['js', 'ts'] as const) {\n const url = new URL(`./runtime/${name}.${ext}`, import.meta.url);\n if (existsSync(url)) {\n return fileURLToPath(url).replace(/\\\\/g, '/');\n }\n }\n throw new Error(`[lit-plugin] runtime module not found: ${name}`);\n};\n\nconst JS_FILE_RE = /\\.[cm]?[jt]sx?$/;\n\nconst OPEN_IN_EDITOR_PATH = '/__lit-open-in-editor';\n\n/** Reject requests whose `Origin` is a different host than the dev server, so\n * a page the developer happens to visit can't drive these local-only\n * endpoints. Same-origin requests (no `Origin`, or matching `Host`) pass. */\nconst isSameOrigin = (headers: {origin?: string; host?: string}): boolean => {\n const {origin, host} = headers;\n if (origin === undefined || origin === 'null') return true;\n try {\n return new URL(origin).host === host;\n } catch {\n return false;\n }\n};\n\nconst createOpenInEditorMiddleware = (root: string) => {\n return (\n req: {url?: string; headers?: {origin?: string; host?: string}},\n res: {statusCode: number; end: (msg: string) => void},\n next: (err?: unknown) => void\n ) => {\n if (req.url === undefined) {\n next();\n return;\n }\n if (!isSameOrigin(req.headers ?? {})) {\n res.statusCode = 403;\n res.end('forbidden');\n return;\n }\n const query = req.url.includes('?')\n ? req.url.slice(req.url.indexOf('?') + 1)\n : '';\n const params = new URLSearchParams(query);\n const file = params.get('file');\n if (file === null) {\n res.statusCode = 400;\n res.end('missing file parameter');\n return;\n }\n // Confine the open to the project root: resolve the requested path and\n // reject anything that escapes `root` (path traversal, absolute paths to\n // arbitrary files). `launch-editor` spawns the user's editor on this path,\n // so an unvalidated `file` is a local-file-open / arg-injection vector.\n const resolved = resolvePath(root, file);\n if (resolved !== root && !resolved.startsWith(root + sep)) {\n res.statusCode = 403;\n res.end('file outside project root');\n return;\n }\n if (!existsSync(resolved)) {\n res.statusCode = 404;\n res.end('file not found');\n return;\n }\n // Coerce to integers so a crafted `line`/`column` can't smuggle extra\n // shell-visible content through the `file:line:column` ref.\n const line = String(\n Math.max(1, Number.parseInt(params.get('line') ?? '1', 10) || 1)\n );\n const column = String(\n Math.max(1, Number.parseInt(params.get('column') ?? '1', 10) || 1)\n );\n const fileRef = `${resolved}:${line}:${column}`;\n import('launch-editor')\n .then(\n (mod: {\n default?: (\n file: string,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n }) => {\n const launch = (mod.default ?? mod) as (\n file: string,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n launch(fileRef, (_fileName: string, errorMessage: string | null) => {\n if (errorMessage !== null) {\n res.statusCode = 500;\n res.end(errorMessage);\n return;\n }\n res.end('ok');\n });\n }\n )\n .catch(next);\n };\n};\n\n/**\n * `import href from './x.css?hmr-url'` — `?url` semantics with working HMR.\n * The string is a real stylesheet URL (dev-served CSS file; hashed `.css`\n * asset on build) for shadow-root `<link>` hrefs and `@import url()`s. In\n * dev, each HMR re-execution yields a freshly cache-busted href, so the\n * browser refetches the changed stylesheet; in build the `?url` asset URL\n * passes through unchanged.\n */\nconst CSS_URL_QUERY_RE = /^([^?]+\\.css)\\?(?:[^&]*&)*hmr-url(?:&.*)?$/;\nconst CSS_URL_VIRTUAL_PREFIX = '\\0lit-plugin:hmr-url:';\n\n/**\n * `import sheet from './x.css?css-sheet'` — a constructed, shareable\n * `CSSStyleSheet` backed by the `.css` asset that hot-swaps in place. Adopt it\n * from any number of components (`static styles = [sheet]`); a source edit\n * re-fetches and `replaceSync()`s it, updating every shadow root that adopted\n * it without re-rendering a component or reloading the page.\n *\n * This is the `urlSheet()` helper plus its irreducible HMR wiring, lifted into\n * a plugin-generated module: the `import.meta.hot.accept` lives here (where\n * Vite's static analysis sees the literal specifier), so callers write a bare\n * import and never touch `import.meta.hot` themselves.\n */\nconst CSS_SHEET_QUERY_RE = /^([^?]+\\.css)\\?(?:[^&]*&)*css-sheet(?:&.*)?$/;\nconst CSS_SHEET_VIRTUAL_PREFIX = '\\0lit-plugin:css-sheet:';\n// The virtual id must not end in `.css`, or Vite's CSS plugins (which match\n// the id's extension regardless of `\\0`) would compile the wrapper as CSS.\nconst CSS_VIRTUAL_SUFFIX = '.js';\n\n/**\n * Import-query support, served in dev and build alike (source code using\n * `?hmr-url`/`?css-sheet` must keep working under `vite build`, where the HMR\n * plugin doesn't apply). Exported for the baseline e2e run, which needs the\n * queries working without the HMR plugin.\n */\nexport const litCssQueries = (): Plugin => ({\n name: 'lit-css-query',\n // Vite's core resolver claims `./x.css?hmr-url` for the CSS pipeline\n // before normal plugins get a look, so resolve ahead of it.\n enforce: 'pre',\n async resolveId(id, importer) {\n const prefix = CSS_URL_QUERY_RE.test(id)\n ? CSS_URL_VIRTUAL_PREFIX\n : CSS_SHEET_QUERY_RE.test(id)\n ? CSS_SHEET_VIRTUAL_PREFIX\n : null;\n if (prefix === null) {\n return null;\n }\n const file = id.slice(0, id.indexOf('?'));\n const resolved = await this.resolve(file, importer);\n if (resolved === null) {\n return null;\n }\n return prefix + resolved.id + CSS_VIRTUAL_SUFFIX;\n },\n load(id) {\n const helperPath = resolveRuntimeModule('css');\n if (id.startsWith(CSS_URL_VIRTUAL_PREFIX)) {\n const file = id.slice(\n CSS_URL_VIRTUAL_PREFIX.length,\n -CSS_VIRTUAL_SUFFIX.length\n );\n return {\n code:\n `import url from ${JSON.stringify(`${file}?url`)};\\n` +\n `import {devCacheBust} from ${JSON.stringify(helperPath)};\\n` +\n `export default devCacheBust(url);\\n`,\n moduleType: 'js',\n };\n }\n if (id.startsWith(CSS_SHEET_VIRTUAL_PREFIX)) {\n const file = id.slice(\n CSS_SHEET_VIRTUAL_PREFIX.length,\n -CSS_VIRTUAL_SUFFIX.length\n );\n // The accept specifier must be byte-identical to the import above —\n // Vite resolves accepted HMR deps by static analysis. Generating both\n // here is exactly what frees the caller from writing it. The swap is\n // self-accepted at this boundary, so it never propagates to adopters.\n const urlSpecifier = JSON.stringify(`${file}?url`);\n return {\n code:\n `import url from ${urlSpecifier};\\n` +\n `import {urlSheet} from ${JSON.stringify(helperPath)};\\n` +\n `const {sheet, onHotUpdate} = urlSheet(url);\\n` +\n `export default sheet;\\n` +\n `if (import.meta.hot) {\\n` +\n ` import.meta.hot.accept(${urlSpecifier}, onHotUpdate);\\n` +\n `}\\n`,\n moduleType: 'js',\n };\n }\n return null;\n },\n});\n\n/**\n * A `css` tagged template literal with no interpolations and no escape\n * sequences — the only kind we can hand to a CSS parser as-is. Literals\n * with `${…}` holes or backslashes simply don't match and stay untouched.\n * The lookbehind keeps `unsafeCSS`/`myCss`-style tags from matching.\n */\nconst CSS_LITERAL_RE = /(?<![\\w$.])css`((?:[^`\\\\$]|\\$(?!\\{))*)`/g;\n\n/**\n * Runs Vite's configured Lightning CSS over `css` tagged template literals\n * in user modules, which the CSS pipeline itself never sees (they're plain\n * JS strings to it). Inert unless `css.transformer` is `'lightningcss'`;\n * options come from `css.lightningcss`, so component styles get the same\n * treatment (targets, drafts, …) as `.css` files. Applies in dev and build.\n */\nconst litCssLiterals = (): Plugin => {\n let lightningcss: typeof import('lightningcss') | null = null;\n let options: CSSOptions['lightningcss'];\n let minify = false;\n return {\n name: 'lit-css-literals',\n async configResolved(config) {\n if (config.css.transformer !== 'lightningcss') {\n return;\n }\n // The transformer setting guarantees the dependency: Vite itself\n // can't process .css files without it.\n lightningcss = await import('lightningcss');\n // cssModules makes no sense for a literal; everything else carries\n // over.\n const {cssModules: _cssModules, ...rest} = config.css.lightningcss ?? {};\n options = rest;\n minify = config.command === 'build';\n },\n transform(code, id) {\n if (lightningcss === null) {\n return null;\n }\n if (id.startsWith('\\0') || id.includes('/node_modules/')) {\n return null;\n }\n const [file] = id.split('?', 2);\n if (!JS_FILE_RE.test(file) || !code.includes('css`')) {\n return null;\n }\n const ms = new MagicString(code);\n let changed = false;\n for (const m of code.matchAll(CSS_LITERAL_RE)) {\n const literal = m[1];\n if (literal.trim() === '') {\n continue;\n }\n let out: string;\n try {\n const result = lightningcss.transform({\n ...options,\n filename: file,\n code: Buffer.from(literal),\n minify,\n });\n out = Buffer.from(result.code).toString();\n } catch (e) {\n this.warn(\n `[lit-plugin] skipping css literal Lightning CSS couldn't parse: ${\n (e as Error).message\n }`\n );\n continue;\n }\n // Re-escape for the template literal the output goes back into.\n out = out.replace(/[\\\\`$]/g, '\\\\$&');\n if (out !== literal) {\n const start = m.index + 'css`'.length;\n ms.overwrite(start, start + literal.length, out);\n changed = true;\n }\n }\n if (!changed) {\n return null;\n }\n return {code: ms.toString(), map: ms.generateMap({hires: true})};\n },\n };\n};\n\n/**\n * Vite plugin set providing HMR, CSS helpers, and Lightning CSS processing\n * for Lit projects.\n */\nexport const litPlugin = (options: LitPluginOptions = {}): Plugin[] => {\n // Resolved from explicit options first, env vars second, defaults last. The\n // `config` hook re-resolves with the loaded env once Vite hands us the mode;\n // this initial pass covers code paths that run before (or without) it.\n let resolved: ResolvedOptions = resolveOptions(options, {});\n let root = '';\n const sourceOverlayPlugin: Plugin = {\n name: 'lit-source-overlay',\n apply: 'serve',\n // Run before Vite's esbuild TS transform so source-meta line numbers are\n // measured against the author's raw source (and the `@customElement … class`\n // forms are still intact), not against transpiled output.\n enforce: 'pre',\n configResolved(config) {\n root = config.root;\n },\n resolveId(id) {\n if (id === '@lit-labs/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n return null;\n },\n configureServer(server) {\n if (!resolved.sourceOverlay) return;\n server.middlewares.use(\n OPEN_IN_EDITOR_PATH,\n createOpenInEditorMiddleware(root)\n );\n },\n transform(code, id, transformOptions) {\n if (!resolved.sourceOverlay) return null;\n if (transformOptions?.ssr) return null;\n if (\n id.startsWith('\\0') ||\n id.includes('__x00__') ||\n id.includes('lit-plugin:') ||\n id.includes('/node_modules/')\n ) {\n return null;\n }\n const [file] = id.split('?', 2);\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n if (!code.includes('customElement') && !code.includes('customElements')) {\n return null;\n }\n const ms = new MagicString(code);\n const relativeFile = file.startsWith(root + '/')\n ? file.slice(root.length + 1)\n : file;\n if (!injectSourceMeta(code, relativeFile, ms)) {\n return null;\n }\n return {code: ms.toString(), map: ms.generateMap({hires: true})};\n },\n transformIndexHtml() {\n if (!resolved.sourceOverlay) return;\n const overlayUrl = `/@fs/${resolveRuntimeModule('source-overlay')}`;\n const {\n exclude: _exclude,\n onSelect: _onSelect,\n ...overlayInit\n } = resolved.sourceOverlay;\n const initConfig = {\n ...overlayInit,\n openInEditorPath: OPEN_IN_EDITOR_PATH,\n };\n return [\n {\n tag: 'script',\n attrs: {type: 'module'},\n children: `import {initSourceOverlay} from ${JSON.stringify(overlayUrl)};\\ninitSourceOverlay(${JSON.stringify(initConfig)});\\n`,\n injectTo: 'body',\n },\n ];\n },\n };\n const hmr: Plugin = {\n name: 'lit-plugin',\n apply: 'serve',\n config: (viteConfig, {mode}) => {\n // Resolve options against the loaded env now that Vite hands us the mode.\n // `loadEnv` reads `.env*` files from the env dir (root by default) and\n // merges in matching `process.env` keys, filtered to the `LIT_PLUGIN`\n // prefix. Explicit options still win (handled in resolveOptions).\n const envDir = viteConfig.envDir\n ? resolvePath(viteConfig.envDir)\n : viteConfig.root\n ? resolvePath(viteConfig.root)\n : process.cwd();\n resolved = resolveOptions(options, loadEnv(mode, envDir, ENV_PREFIX));\n if (!resolved.hmrEnabled) {\n return;\n }\n // The injected runtime imports are invisible to the dep scanner. The\n // lit family stays prebundle-eligible on purpose: the wrapper modules'\n // bare imports then resolve to the same URL every other importer gets —\n // single lit instance, single template cache.\n return {optimizeDeps: {exclude: ['@lit-labs/vite-plugin-lit']}};\n },\n resolveId(id) {\n // Public timeline API virtual module.\n if (id === 'virtual:lit-plugin/timeline') {\n return '\\0virtual:lit-plugin/timeline';\n }\n // Resolve the browser CSS helpers and indicator runtime to the copy\n // shipped next to this plugin, so they work even when the package\n // isn't reachable through node resolution from the served root (and\n // stay out of prebundling).\n if (id === '@lit-labs/vite-plugin-lit/css.js') {\n return resolveRuntimeModule('css');\n }\n if (id === '@lit-labs/vite-plugin-lit/indicator.js') {\n return resolveRuntimeModule('indicator');\n }\n if (id === '@lit-labs/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n if (resolved.hmrEnabled && id.startsWith(VIRTUAL_PREFIX)) {\n return id;\n }\n return null;\n },\n load(id) {\n // Public timeline API — re-export the runtime module when timeline is\n // enabled, otherwise a no-op stub so imports don't throw in prod builds.\n if (id === '\\0virtual:lit-plugin/timeline') {\n if (!resolved.timeline) {\n return {\n code:\n 'export const addTimelineEvent = () => {};\\n' +\n 'export const addTimelineLayer = () => {};\\n',\n moduleType: 'js',\n };\n }\n const apiPath = resolveRuntimeModule('timeline/public-api');\n return {\n code: `export * from ${JSON.stringify(apiPath)};\\n`,\n moduleType: 'js',\n };\n }\n if (!resolved.hmrEnabled || !id.startsWith(VIRTUAL_PREFIX)) {\n return null;\n }\n if (id === INSTALL_ID) {\n const patchPath = resolveRuntimeModule('patch');\n const runtimeOptions = {\n reconnect: resolved.reconnect,\n onIncompatible: resolved.onIncompatible,\n };\n return {\n code:\n `import {install} from ${JSON.stringify(patchPath)};\\n` +\n `install(${JSON.stringify(runtimeOptions)});\\n`,\n moduleType: 'js',\n };\n }\n const spec = id.slice(VIRTUAL_PREFIX.length);\n const wrappedTags = WRAP_TABLE.get(spec);\n if (wrappedTags === undefined) {\n return null;\n }\n const internPath = resolveRuntimeModule('intern');\n // Browser-native ESM: explicit local exports shadow `export *` names\n // (spec-guaranteed), so everything except the wrapped tags passes\n // through unchanged.\n const lines = [\n `import * as __lit from ${JSON.stringify(spec)};`,\n `import {wrapTag} from ${JSON.stringify(internPath)};`,\n `export * from ${JSON.stringify(spec)};`,\n ];\n for (const {exportName, ns} of wrappedTags) {\n lines.push(\n `export const ${exportName} = wrapTag(__lit.${exportName}, ${JSON.stringify(\n ns\n )});`\n );\n }\n return {code: lines.join('\\n') + '\\n', moduleType: 'js'};\n },\n async transform(code, id, transformOptions) {\n if (!resolved.hmrEnabled) {\n return null;\n }\n if (transformOptions?.ssr) {\n return null;\n }\n if (id.startsWith('\\0') || id.includes('/node_modules/')) {\n return null;\n }\n const [file] = id.split('?', 2);\n // Allow inline scripts extracted from HTML (`?html-proxy`).\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n return transformLitModule(code);\n },\n transformIndexHtml() {\n const tags: {\n tag: string;\n attrs?: Record<string, string | undefined | boolean>;\n children?: string;\n injectTo: 'body';\n }[] = [];\n\n const indicator = resolved.indicator;\n if (indicator) {\n const indicatorUrl = `/@fs/` + resolveRuntimeModule('indicator');\n tags.push(\n {\n tag: 'script',\n attrs: {type: 'module', src: indicatorUrl},\n injectTo: 'body',\n },\n {\n tag: 'lit-devtools-hmr-indicator',\n attrs: indicator.count ? {count: ''} : undefined,\n children: '',\n injectTo: 'body',\n }\n );\n }\n\n if (resolved.timeline) {\n const installUrl = `/@fs/` + resolveRuntimeModule('timeline/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: installUrl},\n injectTo: 'body',\n });\n // Components inspector runtime — answers the panel's tree/details\n // requests. Paired with the timeline panel, which hosts its tab.\n const inspectorUrl =\n `/@fs/` + resolveRuntimeModule('inspector/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: inspectorUrl},\n injectTo: 'body',\n });\n }\n\n return tags.length > 0 ? tags : undefined;\n },\n };\n // The source-overlay plugin is always present; its hooks no-op when the\n // feature is disabled (which env may decide), so inclusion can't be gated\n // on the synchronously-known options here.\n const plugins: Plugin[] = [\n litCssQueries(),\n litCssLiterals(),\n sourceOverlayPlugin,\n hmr,\n ];\n if (resolved.timeline) {\n // Pass a getter, not a snapshot: `resolved` is re-resolved against the\n // loaded env in the `config` hook, which runs after this plugin array is\n // built. The settings endpoint reads it per-request, by which point env is\n // applied.\n plugins.push(litTimelinePlugin(() => toFeatureSettings(resolved)));\n }\n return plugins;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../packages/labs/vite-plugin-lit/src/lib/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACnC,OAAO,EAAC,OAAO,IAAI,WAAW,EAAE,GAAG,EAAC,MAAM,WAAW,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,EAAC,OAAO,EAA+B,MAAM,MAAM,CAAC;AAC3D,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CA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AC,CAAC,SAAS,CAAC;QAC5C,CAAC;KACF,CAAC;IACF,wEAAwE;IACxE,0EAA0E;IAC1E,2CAA2C;IAC3C,MAAM,OAAO,GAAa;QACxB,aAAa;QACb,2EAA2E;QAC3E,4EAA4E;QAC5E,aAAa,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC3C,cAAc,EAAE;QAChB,mBAAmB;QACnB,GAAG;KACJ,CAAC;IACF,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACtB,uEAAuE;QACvE,yEAAyE;QACzE,2EAA2E;QAC3E,WAAW;QACX,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {existsSync} from 'node:fs';\nimport {resolve as resolvePath, sep} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {loadEnv, type CSSOptions, type Plugin} from 'vite';\nimport MagicString from 'magic-string';\nimport {injectSourceMeta} from './source-meta.js';\nimport {INSTALL_ID, VIRTUAL_PREFIX, transformLitModule} from './transform.js';\nimport type {SourceOverlayOptions} from './types.js';\nimport type {FeatureSettings} from '../types/timeline.js';\nimport {WRAP_TABLE} from './wrap-table.js';\nimport {litTimelinePlugin} from './timeline-plugin.js';\n\n/**\n * On-page HMR feedback: a small pulsing indicator in the corner of the host\n * page that briefly animates on each HMR update, for at-a-glance feedback\n * without watching the console.\n */\nexport interface HmrIndicatorOptions {\n /** Inject the indicator element. Defaults to `true` (when HMR is enabled). */\n enabled?: boolean;\n\n /**\n * Show a cumulative update count next to the dot (idle opacity 0.5 instead\n * of fully transparent). Defaults to `false`.\n */\n count?: boolean;\n}\n\n/**\n * HMR for Lit component classes and its on-page feedback.\n */\nexport interface HmrOptions {\n /**\n * Enable in-place HMR for Lit component classes. When `false`, the plugin\n * skips all HMR transforms and runtime injection. Defaults to `true`.\n */\n enabled?: boolean;\n\n /**\n * Cycle `disconnectedCallback()`/`connectedCallback()` on live instances\n * after a hot patch. Interning makes this mostly unnecessary, so it's\n * opt-in. Defaults to `false`.\n */\n reconnect?: boolean;\n\n /**\n * What to do when a component can't be hot-patched in place (e.g.\n * standard `accessor` decorators). Defaults to `'reload'`.\n */\n onIncompatible?: 'reload' | 'warn';\n\n /**\n * The on-page update indicator. `true` enables it without a count; an\n * object configures it. Forced off when HMR itself is disabled. Defaults\n * to enabled (without a count).\n */\n indicator?: boolean | HmrIndicatorOptions;\n}\n\n/**\n * What a `?css-sheet` import compiles to under `vite build`.\n *\n * - `'url'`: fetch-backed sheet over the emitted `.css` asset.\n * - `'inline'`: css text embedded in the JS chunk, processed by the css\n * pipeline (`?inline`).\n * - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline\n * (`?raw`).\n * - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise.\n */\nexport type CssSheetBuild = 'auto' | 'url' | 'inline' | 'inline-raw';\n\nconst CSS_SHEET_BUILD_MODES: readonly CssSheetBuild[] = [\n 'auto',\n 'url',\n 'inline',\n 'inline-raw',\n];\n\n/**\n * Options for the Lit Vite plugin.\n *\n * Every option also resolves from environment variables (and `.env` files)\n * with the `LIT_PLUGIN` prefix — e.g. `LIT_PLUGIN_HMR_INDICATOR=true`. Options\n * passed here take precedence over env vars, which take precedence over the\n * built-in defaults.\n */\nexport interface LitPluginOptions {\n /**\n * HMR for Lit components and its on-page feedback. `true`/`false` toggles\n * the whole feature (patching and indicator); an object configures it.\n * Defaults to enabled.\n */\n hmr?: boolean | HmrOptions;\n\n /**\n * Dev-only click-to-open-in-IDE inspector for Lit custom elements.\n * Toggle with Ctrl+Shift+S (configurable via `key`). Defaults to `false`.\n */\n sourceOverlay?: boolean | SourceOverlayOptions;\n\n /**\n * Vite DevTools Timeline panel — a Vue DevTools–style layered event stream\n * for Lit lifecycle, render, mouse, and keyboard events.\n *\n * Requires `@vitejs/devtools` in the Vite config and the `@vitejs/devtools`\n * Vite plugin (`DevTools()`) to be active. Defaults to `false` while\n * experimental.\n *\n * `true` enables all built-in layers with defaults.\n */\n timeline?: boolean;\n\n /**\n * What a `?css-sheet` import compiles to under `vite build`.\n * - `'url'`: fetch-backed sheet over the emitted `.css` asset\n * - `'inline'`: css text embedded in the JS chunk, processed by the css\n * pipeline (`?inline`)\n * - `'inline-raw'`: css text embedded verbatim, skipping the css pipeline\n * (`?raw`)\n * - `'auto'`: `'inline'` when `build.lib` is set, `'url'` otherwise\n *\n * Dev is always the fetch-backed HMR form regardless of this setting.\n * Defaults to `'auto'`.\n */\n cssSheetBuild?: CssSheetBuild;\n}\n\n/** Plugin options after merging explicit options, env vars, and defaults. */\nexport interface ResolvedOptions {\n hmrEnabled: boolean;\n reconnect: boolean;\n onIncompatible: 'reload' | 'warn';\n indicator: false | {count: boolean};\n sourceOverlay: false | SourceOverlayOptions;\n timeline: boolean;\n cssSheetBuild: CssSheetBuild;\n}\n\n/** Env var prefix consumed at config time. */\nconst ENV_PREFIX = 'LIT_PLUGIN';\n\n/** Parse a boolean-ish env string; `undefined` when unset/unrecognized. */\nconst envBool = (v: string | undefined): boolean | undefined =>\n v === 'true' || v === '1'\n ? true\n : v === 'false' || v === '0'\n ? false\n : undefined;\n\n/** Parse a numeric env string; `undefined` when unset/non-numeric. */\nconst envNum = (v: string | undefined): number | undefined => {\n if (v === undefined || v === '') return undefined;\n const n = Number(v);\n return Number.isNaN(n) ? undefined : n;\n};\n\n/**\n * Parse a string against a closed set of values; `undefined` (with a warning)\n * when set to something outside it, so a typo falls back to the default\n * instead of silently disabling a feature.\n */\nconst envEnum = <T extends string>(\n v: string | undefined,\n allowed: readonly T[],\n source: string\n): T | undefined => {\n if (v === undefined || v === '') return undefined;\n if ((allowed as readonly string[]).includes(v)) return v as T;\n console.warn(\n `[lit-plugin] ignoring ${source}=${JSON.stringify(v)}; expected one of ` +\n allowed.map((a) => JSON.stringify(a)).join(', ')\n );\n return undefined;\n};\n\n/**\n * Merge explicit options over env vars over defaults (in that precedence) into\n * the flat shape the plugin hooks consume.\n */\nexport const resolveOptions = (\n options: LitPluginOptions,\n env: Record<string, string>\n): ResolvedOptions => {\n const hmr = options.hmr;\n const hmrObj = typeof hmr === 'object' ? hmr : undefined;\n const hmrEnabled =\n (typeof hmr === 'boolean' ? hmr : hmrObj?.enabled) ??\n envBool(env[`${ENV_PREFIX}_HMR`]) ??\n true;\n const reconnect =\n hmrObj?.reconnect ?? envBool(env[`${ENV_PREFIX}_HMR_RECONNECT`]) ?? false;\n const onIncompatible =\n hmrObj?.onIncompatible ??\n (env[`${ENV_PREFIX}_HMR_ON_INCOMPATIBLE`] as 'reload' | 'warn') ??\n 'reload';\n\n const ind = hmrObj?.indicator;\n const indObj = typeof ind === 'object' ? ind : undefined;\n const indEnabled =\n (typeof ind === 'boolean' ? ind : indObj?.enabled) ??\n envBool(env[`${ENV_PREFIX}_HMR_INDICATOR`]) ??\n true;\n const indCount =\n indObj?.count ?? envBool(env[`${ENV_PREFIX}_HMR_INDICATOR_COUNT`]) ?? false;\n // The indicator is meaningless without HMR, so it follows the master toggle.\n const indicator = hmrEnabled && indEnabled ? {count: indCount} : false;\n\n const so = options.sourceOverlay;\n const soExplicit =\n typeof so === 'boolean' ? so : so === undefined ? undefined : true;\n const soEnabled =\n soExplicit ?? envBool(env[`${ENV_PREFIX}_SOURCE_OVERLAY`]) ?? false;\n let sourceOverlay: false | SourceOverlayOptions = false;\n if (soEnabled) {\n const base: SourceOverlayOptions = typeof so === 'object' ? {...so} : {};\n base.key ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_KEY`] || undefined;\n base.editor ??= env[`${ENV_PREFIX}_SOURCE_OVERLAY_EDITOR`] || undefined;\n base.throttleMs ??= envNum(env[`${ENV_PREFIX}_SOURCE_OVERLAY_THROTTLE_MS`]);\n sourceOverlay = base;\n }\n\n const timeline =\n options.timeline ?? envBool(env[`${ENV_PREFIX}_TIMELINE`]) ?? false;\n\n const cssSheetBuild =\n envEnum(options.cssSheetBuild, CSS_SHEET_BUILD_MODES, 'cssSheetBuild') ??\n envEnum(\n env[`${ENV_PREFIX}_CSS_SHEET_BUILD`],\n CSS_SHEET_BUILD_MODES,\n `${ENV_PREFIX}_CSS_SHEET_BUILD`\n ) ??\n 'auto';\n\n return {\n hmrEnabled,\n reconnect,\n onIncompatible,\n indicator,\n sourceOverlay,\n timeline,\n cssSheetBuild,\n };\n};\n\n/**\n * Flattens resolved options into the JSON-serializable shape the panel's\n * Settings tab consumes (callback options like `exclude`/`onSelect` dropped;\n * a custom editor object reported as `\"custom\"`). Default key/editor/throttle\n * are applied here so the panel shows the effective values the runtime uses.\n */\nconst toFeatureSettings = (r: ResolvedOptions): FeatureSettings => {\n const so = r.sourceOverlay;\n const editor = so === false ? undefined : so.editor;\n return {\n hmr: {\n enabled: r.hmrEnabled,\n reconnect: r.reconnect,\n onIncompatible: r.onIncompatible,\n indicatorEnabled: r.indicator !== false,\n indicatorCount: r.indicator !== false && r.indicator.count,\n },\n sourceOverlay: {\n enabled: so !== false,\n key: (so === false ? undefined : so.key) ?? 's',\n editor:\n typeof editor === 'string' ? editor : editor ? 'custom' : 'vscode',\n throttleMs: (so === false ? undefined : so.throttleMs) ?? 50,\n },\n timeline: r.timeline,\n };\n};\n\n/**\n * Resolves a runtime module to an absolute fs path (served via `/@fs/`), so\n * the plugin works from any served root. Falls back from the built `.js` to\n * the `.ts` source when running un-built (e.g. under vitest).\n */\nconst resolveRuntimeModule = (name: string): string => {\n for (const ext of ['js', 'ts'] as const) {\n const url = new URL(`./runtime/${name}.${ext}`, import.meta.url);\n if (existsSync(url)) {\n return fileURLToPath(url).replace(/\\\\/g, '/');\n }\n }\n throw new Error(`[lit-plugin] runtime module not found: ${name}`);\n};\n\nconst JS_FILE_RE = /\\.[cm]?[jt]sx?$/;\n\nconst OPEN_IN_EDITOR_PATH = '/__lit-open-in-editor';\n\n/** Reject requests whose `Origin` is a different host than the dev server, so\n * a page the developer happens to visit can't drive these local-only\n * endpoints. Same-origin requests (no `Origin`, or matching `Host`) pass. */\nconst isSameOrigin = (headers: {origin?: string; host?: string}): boolean => {\n const {origin, host} = headers;\n if (origin === undefined || origin === 'null') return true;\n try {\n return new URL(origin).host === host;\n } catch {\n return false;\n }\n};\n\nconst createOpenInEditorMiddleware = (root: string) => {\n return (\n req: {url?: string; headers?: {origin?: string; host?: string}},\n res: {statusCode: number; end: (msg: string) => void},\n next: (err?: unknown) => void\n ) => {\n if (req.url === undefined) {\n next();\n return;\n }\n if (!isSameOrigin(req.headers ?? {})) {\n res.statusCode = 403;\n res.end('forbidden');\n return;\n }\n const query = req.url.includes('?')\n ? req.url.slice(req.url.indexOf('?') + 1)\n : '';\n const params = new URLSearchParams(query);\n const file = params.get('file');\n if (file === null) {\n res.statusCode = 400;\n res.end('missing file parameter');\n return;\n }\n // Confine the open to the project root: resolve the requested path and\n // reject anything that escapes `root` (path traversal, absolute paths to\n // arbitrary files). `launch-editor` spawns the user's editor on this path,\n // so an unvalidated `file` is a local-file-open / arg-injection vector.\n const resolved = resolvePath(root, file);\n if (resolved !== root && !resolved.startsWith(root + sep)) {\n res.statusCode = 403;\n res.end('file outside project root');\n return;\n }\n if (!existsSync(resolved)) {\n res.statusCode = 404;\n res.end('file not found');\n return;\n }\n // Coerce to integers so a crafted `line`/`column` can't smuggle extra\n // shell-visible content through the `file:line:column` ref.\n const line = String(\n Math.max(1, Number.parseInt(params.get('line') ?? '1', 10) || 1)\n );\n const column = String(\n Math.max(1, Number.parseInt(params.get('column') ?? '1', 10) || 1)\n );\n const fileRef = `${resolved}:${line}:${column}`;\n import('launch-editor')\n .then(\n (mod: {\n default?: (\n file: string,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n }) => {\n const launch = (mod.default ?? mod) as (\n file: string,\n cb: (fileName: string, errorMessage: string | null) => void\n ) => void;\n launch(fileRef, (_fileName: string, errorMessage: string | null) => {\n if (errorMessage !== null) {\n res.statusCode = 500;\n res.end(errorMessage);\n return;\n }\n res.end('ok');\n });\n }\n )\n .catch(next);\n };\n};\n\n/**\n * `import href from './x.css?hmr-url'` — `?url` semantics with working HMR.\n * The string is a real stylesheet URL (dev-served CSS file; hashed `.css`\n * asset on build) for shadow-root `<link>` hrefs and `@import url()`s. In\n * dev, each HMR re-execution yields a freshly cache-busted href, so the\n * browser refetches the changed stylesheet; in build the `?url` asset URL\n * passes through unchanged.\n */\nconst CSS_URL_QUERY_RE = /^([^?]+\\.css)\\?(?:[^&]*&)*hmr-url(?:&.*)?$/;\nconst CSS_URL_VIRTUAL_PREFIX = '\\0lit-plugin:hmr-url:';\n\n/**\n * `import sheet from './x.css?css-sheet'` — a constructed, shareable\n * `CSSStyleSheet` backed by the `.css` asset that hot-swaps in place. Adopt it\n * from any number of components (`static styles = [sheet]`); a source edit\n * re-fetches and `replaceSync()`s it, updating every shadow root that adopted\n * it without re-rendering a component or reloading the page.\n *\n * This is the `urlSheet()` helper plus its irreducible HMR wiring, lifted into\n * a plugin-generated module: the `import.meta.hot.accept` lives here (where\n * Vite's static analysis sees the literal specifier), so callers write a bare\n * import and never touch `import.meta.hot` themselves.\n *\n * Under `vite build` the generated module can instead inline the css text (see\n * `cssSheetBuild`) — a library's consumers bundle its JS only, so a\n * fetch-backed sheet would 404 on the `.css` asset that never reached their\n * build.\n */\nconst CSS_SHEET_QUERY_RE = /^([^?]+\\.css)\\?(?:[^&]*&)*css-sheet(?:&.*)?$/;\nconst CSS_SHEET_VIRTUAL_PREFIX = '\\0lit-plugin:css-sheet:';\n// The virtual id must not end in `.css`, or Vite's CSS plugins (which match\n// the id's extension regardless of `\\0`) would compile the wrapper as CSS.\nconst CSS_VIRTUAL_SUFFIX = '.js';\n\n/**\n * Import-query support, served in dev and build alike (source code using\n * `?hmr-url`/`?css-sheet` must keep working under `vite build`, where the HMR\n * plugin doesn't apply). Exported for the baseline e2e run, which needs the\n * queries working without the HMR plugin.\n *\n * `getCssSheetBuild` is a getter, not a value: `litPlugin()` re-resolves its\n * options against the loaded env in a `config` hook, which runs after the\n * plugin array is built. Standalone (no getter) it behaves like the `'auto'`\n * default.\n */\nexport const litCssQueries = (\n getCssSheetBuild: () => CssSheetBuild = () => 'auto'\n): Plugin => {\n let isBuild = false;\n let isLib = false;\n return {\n name: 'lit-css-query',\n // Vite's core resolver claims `./x.css?hmr-url` for the CSS pipeline\n // before normal plugins get a look, so resolve ahead of it.\n enforce: 'pre',\n configResolved(config) {\n isBuild = config.command === 'build';\n isLib = config.build.lib !== false && config.build.lib !== undefined;\n },\n async resolveId(id, importer) {\n const prefix = CSS_URL_QUERY_RE.test(id)\n ? CSS_URL_VIRTUAL_PREFIX\n : CSS_SHEET_QUERY_RE.test(id)\n ? CSS_SHEET_VIRTUAL_PREFIX\n : null;\n if (prefix === null) {\n return null;\n }\n const file = id.slice(0, id.indexOf('?'));\n const resolved = await this.resolve(file, importer);\n if (resolved === null) {\n return null;\n }\n return prefix + resolved.id + CSS_VIRTUAL_SUFFIX;\n },\n load(id) {\n const helperPath = resolveRuntimeModule('css');\n if (id.startsWith(CSS_URL_VIRTUAL_PREFIX)) {\n const file = id.slice(\n CSS_URL_VIRTUAL_PREFIX.length,\n -CSS_VIRTUAL_SUFFIX.length\n );\n return {\n code:\n `import url from ${JSON.stringify(`${file}?url`)};\\n` +\n `import {devCacheBust} from ${JSON.stringify(helperPath)};\\n` +\n `export default devCacheBust(url);\\n`,\n moduleType: 'js',\n };\n }\n if (id.startsWith(CSS_SHEET_VIRTUAL_PREFIX)) {\n const file = id.slice(\n CSS_SHEET_VIRTUAL_PREFIX.length,\n -CSS_VIRTUAL_SUFFIX.length\n );\n const mode = getCssSheetBuild();\n const inlineQuery =\n !isBuild || mode === 'url' || (mode === 'auto' && !isLib)\n ? null\n : mode === 'inline-raw'\n ? '?raw'\n : '?inline';\n if (inlineQuery !== null) {\n // Build only, so no `import.meta.hot` block. The sheet is still\n // constructed once per virtual module, so adopters share it exactly\n // as they do in the fetch-backed form.\n return {\n code:\n `import css from ${JSON.stringify(`${file}${inlineQuery}`)};\\n` +\n `const sheet = new CSSStyleSheet();\\n` +\n `sheet.replaceSync(css);\\n` +\n `export default sheet;\\n`,\n moduleType: 'js',\n };\n }\n // The accept specifier must be byte-identical to the import above —\n // Vite resolves accepted HMR deps by static analysis. Generating both\n // here is exactly what frees the caller from writing it. The swap is\n // self-accepted at this boundary, so it never propagates to adopters.\n const urlSpecifier = JSON.stringify(`${file}?url`);\n return {\n code:\n `import url from ${urlSpecifier};\\n` +\n `import {urlSheet} from ${JSON.stringify(helperPath)};\\n` +\n `const {sheet, onHotUpdate} = urlSheet(url);\\n` +\n `export default sheet;\\n` +\n `if (import.meta.hot) {\\n` +\n ` import.meta.hot.accept(${urlSpecifier}, onHotUpdate);\\n` +\n `}\\n`,\n moduleType: 'js',\n };\n }\n return null;\n },\n };\n};\n\n/**\n * A `css` tagged template literal with no interpolations and no escape\n * sequences — the only kind we can hand to a CSS parser as-is. Literals\n * with `${…}` holes or backslashes simply don't match and stay untouched.\n * The lookbehind keeps `unsafeCSS`/`myCss`-style tags from matching.\n */\nconst CSS_LITERAL_RE = /(?<![\\w$.])css`((?:[^`\\\\$]|\\$(?!\\{))*)`/g;\n\n/**\n * Runs Vite's configured Lightning CSS over `css` tagged template literals\n * in user modules, which the CSS pipeline itself never sees (they're plain\n * JS strings to it). Inert unless `css.transformer` is `'lightningcss'`;\n * options come from `css.lightningcss`, so component styles get the same\n * treatment (targets, drafts, …) as `.css` files. Applies in dev and build.\n */\nconst litCssLiterals = (): Plugin => {\n let lightningcss: typeof import('lightningcss') | null = null;\n let options: CSSOptions['lightningcss'];\n let minify = false;\n return {\n name: 'lit-css-literals',\n async configResolved(config) {\n if (config.css.transformer !== 'lightningcss') {\n return;\n }\n // The transformer setting guarantees the dependency: Vite itself\n // can't process .css files without it.\n lightningcss = await import('lightningcss');\n // cssModules makes no sense for a literal; everything else carries\n // over.\n const {cssModules: _cssModules, ...rest} = config.css.lightningcss ?? {};\n options = rest;\n minify = config.command === 'build';\n },\n transform(code, id) {\n if (lightningcss === null) {\n return null;\n }\n if (id.startsWith('\\0') || id.includes('/node_modules/')) {\n return null;\n }\n const [file] = id.split('?', 2);\n if (!JS_FILE_RE.test(file) || !code.includes('css`')) {\n return null;\n }\n const ms = new MagicString(code);\n let changed = false;\n for (const m of code.matchAll(CSS_LITERAL_RE)) {\n const literal = m[1];\n if (literal.trim() === '') {\n continue;\n }\n let out: string;\n try {\n const result = lightningcss.transform({\n ...options,\n filename: file,\n code: Buffer.from(literal),\n minify,\n });\n out = Buffer.from(result.code).toString();\n } catch (e) {\n this.warn(\n `[lit-plugin] skipping css literal Lightning CSS couldn't parse: ${\n (e as Error).message\n }`\n );\n continue;\n }\n // Re-escape for the template literal the output goes back into.\n out = out.replace(/[\\\\`$]/g, '\\\\$&');\n if (out !== literal) {\n const start = m.index + 'css`'.length;\n ms.overwrite(start, start + literal.length, out);\n changed = true;\n }\n }\n if (!changed) {\n return null;\n }\n return {code: ms.toString(), map: ms.generateMap({hires: true})};\n },\n };\n};\n\n/**\n * Vite plugin set providing HMR, CSS helpers, and Lightning CSS processing\n * for Lit projects.\n */\nexport const litPlugin = (options: LitPluginOptions = {}): Plugin[] => {\n // Resolved from explicit options first, env vars second, defaults last. The\n // `lit-plugin-options` `config` hook below re-resolves with the loaded env\n // once Vite hands us the mode; this initial pass covers code paths that run\n // before (or without) it.\n let resolved: ResolvedOptions = resolveOptions(options, {});\n let root = '';\n // Env resolution lives in its own always-applied plugin: `?css-sheet` is a\n // build-time feature too, and the HMR plugin (`apply: 'serve'`) never gets a\n // `config` hook under `vite build`. `enforce: 'pre'` and first position put\n // it ahead of every other hook that reads `resolved`.\n const optionsPlugin: Plugin = {\n name: 'lit-plugin-options',\n enforce: 'pre',\n config(viteConfig, {mode}) {\n // `loadEnv` reads `.env*` files from the env dir (root by default) and\n // merges in matching `process.env` keys, filtered to the `LIT_PLUGIN`\n // prefix. Explicit options still win (handled in resolveOptions).\n const envDir = viteConfig.envDir\n ? resolvePath(viteConfig.envDir)\n : viteConfig.root\n ? resolvePath(viteConfig.root)\n : process.cwd();\n resolved = resolveOptions(options, loadEnv(mode, envDir, ENV_PREFIX));\n },\n };\n const sourceOverlayPlugin: Plugin = {\n name: 'lit-source-overlay',\n apply: 'serve',\n // Run before Vite's esbuild TS transform so source-meta line numbers are\n // measured against the author's raw source (and the `@customElement … class`\n // forms are still intact), not against transpiled output.\n enforce: 'pre',\n configResolved(config) {\n root = config.root;\n },\n resolveId(id) {\n if (id === '@lit-labs/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n return null;\n },\n configureServer(server) {\n if (!resolved.sourceOverlay) return;\n server.middlewares.use(\n OPEN_IN_EDITOR_PATH,\n createOpenInEditorMiddleware(root)\n );\n },\n transform(code, id, transformOptions) {\n if (!resolved.sourceOverlay) return null;\n if (transformOptions?.ssr) return null;\n if (\n id.startsWith('\\0') ||\n id.includes('__x00__') ||\n id.includes('lit-plugin:') ||\n id.includes('/node_modules/')\n ) {\n return null;\n }\n const [file] = id.split('?', 2);\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n if (!code.includes('customElement') && !code.includes('customElements')) {\n return null;\n }\n const ms = new MagicString(code);\n const relativeFile = file.startsWith(root + '/')\n ? file.slice(root.length + 1)\n : file;\n if (!injectSourceMeta(code, relativeFile, ms)) {\n return null;\n }\n return {code: ms.toString(), map: ms.generateMap({hires: true})};\n },\n transformIndexHtml() {\n if (!resolved.sourceOverlay) return;\n const overlayUrl = `/@fs/${resolveRuntimeModule('source-overlay')}`;\n const {\n exclude: _exclude,\n onSelect: _onSelect,\n ...overlayInit\n } = resolved.sourceOverlay;\n const initConfig = {\n ...overlayInit,\n openInEditorPath: OPEN_IN_EDITOR_PATH,\n };\n return [\n {\n tag: 'script',\n attrs: {type: 'module'},\n children: `import {initSourceOverlay} from ${JSON.stringify(overlayUrl)};\\ninitSourceOverlay(${JSON.stringify(initConfig)});\\n`,\n injectTo: 'body',\n },\n ];\n },\n };\n const hmr: Plugin = {\n name: 'lit-plugin',\n apply: 'serve',\n config: () => {\n // Options are already resolved against the loaded env by\n // `lit-plugin-options`, which runs first.\n if (!resolved.hmrEnabled) {\n return;\n }\n // The injected runtime imports are invisible to the dep scanner. The\n // lit family stays prebundle-eligible on purpose: the wrapper modules'\n // bare imports then resolve to the same URL every other importer gets —\n // single lit instance, single template cache.\n return {optimizeDeps: {exclude: ['@lit-labs/vite-plugin-lit']}};\n },\n resolveId(id) {\n // Public timeline API virtual module.\n if (id === 'virtual:lit-plugin/timeline') {\n return '\\0virtual:lit-plugin/timeline';\n }\n // Resolve the browser CSS helpers and indicator runtime to the copy\n // shipped next to this plugin, so they work even when the package\n // isn't reachable through node resolution from the served root (and\n // stay out of prebundling).\n if (id === '@lit-labs/vite-plugin-lit/css.js') {\n return resolveRuntimeModule('css');\n }\n if (id === '@lit-labs/vite-plugin-lit/indicator.js') {\n return resolveRuntimeModule('indicator');\n }\n if (id === '@lit-labs/vite-plugin-lit/source-overlay.js') {\n return resolveRuntimeModule('source-overlay');\n }\n if (resolved.hmrEnabled && id.startsWith(VIRTUAL_PREFIX)) {\n return id;\n }\n return null;\n },\n load(id) {\n // Public timeline API — re-export the runtime module when timeline is\n // enabled, otherwise a no-op stub so imports don't throw in prod builds.\n if (id === '\\0virtual:lit-plugin/timeline') {\n if (!resolved.timeline) {\n return {\n code:\n 'export const addTimelineEvent = () => {};\\n' +\n 'export const addTimelineLayer = () => {};\\n',\n moduleType: 'js',\n };\n }\n const apiPath = resolveRuntimeModule('timeline/public-api');\n return {\n code: `export * from ${JSON.stringify(apiPath)};\\n`,\n moduleType: 'js',\n };\n }\n if (!resolved.hmrEnabled || !id.startsWith(VIRTUAL_PREFIX)) {\n return null;\n }\n if (id === INSTALL_ID) {\n const patchPath = resolveRuntimeModule('patch');\n const runtimeOptions = {\n reconnect: resolved.reconnect,\n onIncompatible: resolved.onIncompatible,\n };\n return {\n code:\n `import {install} from ${JSON.stringify(patchPath)};\\n` +\n `install(${JSON.stringify(runtimeOptions)});\\n`,\n moduleType: 'js',\n };\n }\n const spec = id.slice(VIRTUAL_PREFIX.length);\n const wrappedTags = WRAP_TABLE.get(spec);\n if (wrappedTags === undefined) {\n return null;\n }\n const internPath = resolveRuntimeModule('intern');\n // Browser-native ESM: explicit local exports shadow `export *` names\n // (spec-guaranteed), so everything except the wrapped tags passes\n // through unchanged.\n const lines = [\n `import * as __lit from ${JSON.stringify(spec)};`,\n `import {wrapTag} from ${JSON.stringify(internPath)};`,\n `export * from ${JSON.stringify(spec)};`,\n ];\n for (const {exportName, ns} of wrappedTags) {\n lines.push(\n `export const ${exportName} = wrapTag(__lit.${exportName}, ${JSON.stringify(\n ns\n )});`\n );\n }\n return {code: lines.join('\\n') + '\\n', moduleType: 'js'};\n },\n async transform(code, id, transformOptions) {\n if (!resolved.hmrEnabled) {\n return null;\n }\n if (transformOptions?.ssr) {\n return null;\n }\n if (id.startsWith('\\0') || id.includes('/node_modules/')) {\n return null;\n }\n const [file] = id.split('?', 2);\n // Allow inline scripts extracted from HTML (`?html-proxy`).\n if (!JS_FILE_RE.test(file) && !id.includes('?html-proxy')) {\n return null;\n }\n return transformLitModule(code);\n },\n transformIndexHtml() {\n const tags: {\n tag: string;\n attrs?: Record<string, string | undefined | boolean>;\n children?: string;\n injectTo: 'body';\n }[] = [];\n\n const indicator = resolved.indicator;\n if (indicator) {\n const indicatorUrl = `/@fs/` + resolveRuntimeModule('indicator');\n tags.push(\n {\n tag: 'script',\n attrs: {type: 'module', src: indicatorUrl},\n injectTo: 'body',\n },\n {\n tag: 'lit-devtools-hmr-indicator',\n attrs: indicator.count ? {count: ''} : undefined,\n children: '',\n injectTo: 'body',\n }\n );\n }\n\n if (resolved.timeline) {\n const installUrl = `/@fs/` + resolveRuntimeModule('timeline/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: installUrl},\n injectTo: 'body',\n });\n // Components inspector runtime — answers the panel's tree/details\n // requests. Paired with the timeline panel, which hosts its tab.\n const inspectorUrl =\n `/@fs/` + resolveRuntimeModule('inspector/install');\n tags.push({\n tag: 'script',\n attrs: {type: 'module', src: inspectorUrl},\n injectTo: 'body',\n });\n }\n\n return tags.length > 0 ? tags : undefined;\n },\n };\n // The source-overlay plugin is always present; its hooks no-op when the\n // feature is disabled (which env may decide), so inclusion can't be gated\n // on the synchronously-known options here.\n const plugins: Plugin[] = [\n optionsPlugin,\n // Getter, not a snapshot: `resolved` is re-resolved against the loaded env\n // in `optionsPlugin`'s `config` hook, which runs after this array is built.\n litCssQueries(() => resolved.cssSheetBuild),\n litCssLiterals(),\n sourceOverlayPlugin,\n hmr,\n ];\n if (resolved.timeline) {\n // Pass a getter, not a snapshot: `resolved` is re-resolved against the\n // loaded env in the `config` hook, which runs after this plugin array is\n // built. The settings endpoint reads it per-request, by which point env is\n // applied.\n plugins.push(litTimelinePlugin(() => toFeatureSettings(resolved)));\n }\n return plugins;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oddsquad/vite-plugin-lit",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Vite plugin providing true HMR for Lit components, plus CSS helpers and a DevTools panel",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"author": "Oddsquad (based on @lit-labs/vite-hmr by Google LLC)",
|