@navecss/core 0.4.0 → 0.5.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/dist/vite.js CHANGED
@@ -1,17 +1,18 @@
1
- import { findingsInText, formatFinding } from './chunk-UANF3FGO.js';
2
- import { assertOptions, resolveUsedOptions, keptAtoms, atomsWrittenIn, applyEdits, compareText, withoutRemoved, CX_SOURCE, toSourceMap, isSecondHop, buildReport, moduleReport, isListableReexport, readModule, combinedMapOf, placerFor, cxModulesArray, nodeAt, staticStringOf, pushAll, childrenOf, nodesAt, LINE_UNKNOWN_WITHOUT_MAP, LINE_UNKNOWN_UNMAPPED, exportNameOf, atomOfClass, analyze, memberReadOf, patternDestructuring, stringAt, propertyNameOf } from './chunk-E5F6YF7A.js';
3
- import { validateExtendAtomsHostFree } from './chunk-LQSGQ2OA.js';
1
+ import { formatFinding, findingsInText } from './chunk-ZNTNLGEC.js';
2
+ import { assertOptions, resolveUsedOptions, keptAtoms, withRestorers, pruneAtomicLayer, atomsWrittenIn, applyEdits, compareText, inspectAtomicLayer, withoutRemoved, CX_SOURCE, toSourceMap, unprunedAtoms, isSecondHop, buildReport, atomOfClass, moduleReport, isListableReexport, CLASS_MAP_NOT_PARSED, isNode, readModule, combinedMapOf, placerFor, cxModulesArray, nodeAt, staticStringOf, pushAll, childrenOf, nodesAt, LINE_UNKNOWN_WITHOUT_MAP, LINE_UNKNOWN_UNMAPPED, exportNameOf, analyze, memberReadOf, patternDestructuring, stringAt, propertyNameOf } from './chunk-BCUK4M4P.js';
3
+ import { validateExtendAtomsHostFree } from './chunk-63H2FLGU.js';
4
4
  import { resolveExtendSpecifier, applyExtendModule } from './chunk-NKUZNRF4.js';
5
- import { snapshotExtendMap, expandText, foldLocated } from './chunk-LADFXRWQ.js';
6
- import { tokenize } from './chunk-NFS2REPQ.js';
5
+ import { snapshotExtendMap, expandText, foldLocated } from './chunk-MWHZ26S4.js';
6
+ import './chunk-UVHGEVMV.js';
7
7
  import { decodeIncomingMap, formatDiagnostic } from './chunk-SYNQJNVB.js';
8
8
  import './chunk-CUL5PLPI.js';
9
+ import './chunk-2K5EBBF2.js';
9
10
  import { atomClassMap } from './chunk-GZL2VW7C.js';
11
+ import { mkdirSync, writeFileSync, readFileSync, existsSync, realpathSync, statSync } from 'fs';
10
12
  import { readFile } from 'fs/promises';
11
- import path2 from 'path';
13
+ import path from 'path';
12
14
  import { fileURLToPath } from 'url';
13
15
  import { randomUUID } from 'crypto';
14
- import { mkdirSync, writeFileSync, readFileSync, existsSync, realpathSync, statSync } from 'fs';
15
16
 
16
17
  // src/vite-builds.ts
17
18
  function htmlPageOf(id) {
@@ -92,6 +93,14 @@ function secondHalf(pickers) {
92
93
  },
93
94
  buildEnd(error) {
94
95
  return pickers.forHook(this).collect.buildEnd.call(this, error);
96
+ },
97
+ // The same step as the first half's, ahead of every other plugin's: a plugin that inlines or
98
+ // renames a stylesheet in its own `generateBundle` has not yet done so.
99
+ generateBundle: {
100
+ order: "pre",
101
+ handler(options, bundle) {
102
+ pickers.forHook(this).collect.generateBundle.handler.call(this, options, bundle);
103
+ }
95
104
  }
96
105
  };
97
106
  }
@@ -142,26 +151,838 @@ function registry(assemble2) {
142
151
  };
143
152
  return { pickers, configure };
144
153
  }
145
- function shareAcrossBuilds(assemble2) {
146
- const { pickers, configure } = registry(assemble2);
147
- return [firstHalf(pickers, configure), secondHalf(pickers)];
154
+ function shareAcrossBuilds(assemble2) {
155
+ const { pickers, configure } = registry(assemble2);
156
+ return [firstHalf(pickers, configure), secondHalf(pickers)];
157
+ }
158
+
159
+ // src/vite-dev-reloads.ts
160
+ function freshReloads() {
161
+ return {
162
+ stale: /* @__PURE__ */ new Set(),
163
+ reloading: /* @__PURE__ */ new Map(),
164
+ listening: 0,
165
+ unheard: /* @__PURE__ */ new Set(),
166
+ reloadTimer: void 0,
167
+ readAhead: 0
168
+ };
169
+ }
170
+ function noteReloadSent(state, id) {
171
+ state.reloading.set(id, Date.now());
172
+ if (state.listening === 0) state.unheard.add(id);
173
+ }
174
+
175
+ // src/vite-report.ts
176
+ function withSourceRoot(source, sourceRoot) {
177
+ if (!sourceRoot || /^(?:[a-z][a-z\d+.-]*:|\/)/i.test(source)) return source;
178
+ return `${sourceRoot.replace(/\/$/, "")}/${source}`;
179
+ }
180
+ function locateAt(position, text, input) {
181
+ const origin = input.incoming?.originalPositionFor({
182
+ line: position.line,
183
+ column: position.column - 1
184
+ });
185
+ if (origin === void 0) {
186
+ return {
187
+ text,
188
+ file: input.file,
189
+ isProcessed: true,
190
+ line: position.line,
191
+ column: position.column
192
+ };
193
+ }
194
+ return {
195
+ text,
196
+ file: withSourceRoot(origin.source, input.incoming?.sourceRoot),
197
+ isProcessed: false,
198
+ line: origin.line,
199
+ column: origin.column + 1
200
+ };
201
+ }
202
+ function locate(diagnostic, input) {
203
+ return locateAt(diagnostic, formatDiagnostic(diagnostic, { extend: input.extend }), input);
204
+ }
205
+ function withNoMapNote(body, input, at) {
206
+ if (!at.isProcessed) return body;
207
+ const reason = input.incoming === void 0 ? "no source map" : "the source map does not cover it";
208
+ const note = `(position in ${input.file} as processed; ${reason})`;
209
+ const lines = body.split("\n");
210
+ const hasAvailable = lines.at(-1)?.startsWith("Available: ") === true;
211
+ lines.splice(hasAvailable ? -1 : lines.length, 0, note);
212
+ return lines.join("\n");
213
+ }
214
+ function logFor(message, input, at) {
215
+ return {
216
+ message,
217
+ id: input.id,
218
+ loc: { file: at.file, line: at.line, column: at.column - 1 }
219
+ };
220
+ }
221
+ function frame(at) {
222
+ return `${at.file}:${at.line}:${at.column}: `;
223
+ }
224
+ function reportDiagnostics(input) {
225
+ if (input.onUnknown === "ignore" || input.diagnostics.length === 0) return;
226
+ const inSourceOrder = input.diagnostics.toSorted((a, b) => a.offset - b.offset);
227
+ const located = inSourceOrder.map((diagnostic) => locate(diagnostic, input));
228
+ if (input.onUnknown === "warn") {
229
+ for (const at of located) {
230
+ const message2 = withNoMapNote(`${frame(at)}${at.text}`, input, at);
231
+ input.ctx.warn(logFor(message2, input, at));
232
+ }
233
+ return;
234
+ }
235
+ const first = located[0];
236
+ const message = withNoMapNote(`${frame(first)}${foldLocated(located)}`, input, first);
237
+ input.ctx.error(logFor(message, input, first));
238
+ }
239
+ function placeOrderWarnings(input) {
240
+ return input.warnings.map((warning) => {
241
+ const at = locateAt(warning, warning.text, input);
242
+ const message = withNoMapNote(`${frame(at)}${at.text}`, input, at);
243
+ return {
244
+ key: `${at.file}\0${at.line}\0${at.column}\0${at.text}`,
245
+ print: () => {
246
+ input.ctx.warn(logFor(message, input, at));
247
+ }
248
+ };
249
+ });
250
+ }
251
+
252
+ // src/vite-order-warnings.ts
253
+ function freshWarningMemory() {
254
+ return { printed: /* @__PURE__ */ new Set(), lastSets: /* @__PURE__ */ new Map() };
255
+ }
256
+ function noteNoDirective(memory, id) {
257
+ memory.lastSets.delete(id);
258
+ }
259
+ function reportOrderWarnings(input, memory, command) {
260
+ const placed = placeOrderWarnings(input);
261
+ if (command === "serve") {
262
+ const set = placed.map((warning) => warning.key).join("\n");
263
+ if (memory.lastSets.get(input.id) === set) return;
264
+ memory.lastSets.set(input.id, set);
265
+ for (const warning of placed) warning.print();
266
+ return;
267
+ }
268
+ for (const warning of placed) {
269
+ if (memory.printed.has(warning.key)) continue;
270
+ memory.printed.add(warning.key);
271
+ warning.print();
272
+ }
273
+ }
274
+
275
+ // src/vite-writers.ts
276
+ function freshWriters() {
277
+ return {
278
+ emittedBy: void 0,
279
+ firstWriter: void 0,
280
+ fixed: /* @__PURE__ */ new Map(),
281
+ writers: /* @__PURE__ */ new Map(),
282
+ whole: /* @__PURE__ */ new Set(),
283
+ wholeAssets: /* @__PURE__ */ new Set()
284
+ };
285
+ }
286
+ function hasStylesheet(state, name) {
287
+ const prefix = `${name}\0`;
288
+ return state.sheets.keys().some((key) => key.startsWith(prefix));
289
+ }
290
+ function forgetWriters(state) {
291
+ state.emitted = void 0;
292
+ state.emittedBy = void 0;
293
+ state.firstWriter = void 0;
294
+ state.fixed.clear();
295
+ state.writers.clear();
296
+ state.whole.clear();
297
+ state.wholeAssets.clear();
298
+ }
299
+
300
+ // src/vite-state.ts
301
+ var byConfig = /* @__PURE__ */ new WeakMap();
302
+ var byBuild = /* @__PURE__ */ new WeakMap();
303
+ function buildOf(config) {
304
+ return config.command === "build" ? config.inlineConfig : void 0;
305
+ }
306
+ function mapOf(registry2, owner) {
307
+ const found = registry2.get(owner) ?? /* @__PURE__ */ new Map();
308
+ registry2.set(owner, found);
309
+ return found;
310
+ }
311
+ function freshState() {
312
+ return {
313
+ started: false,
314
+ modules: /* @__PURE__ */ new Map(),
315
+ exposures: /* @__PURE__ */ new Map(),
316
+ templateLinks: /* @__PURE__ */ new Map(),
317
+ packages: /* @__PURE__ */ new Set(),
318
+ declared: /* @__PURE__ */ new Map(),
319
+ recognised: /* @__PURE__ */ new Map(),
320
+ sheets: /* @__PURE__ */ new Map(),
321
+ pages: /* @__PURE__ */ new Map(),
322
+ emitted: void 0,
323
+ ...freshWriters(),
324
+ externals: /* @__PURE__ */ new Set(),
325
+ clientEnded: false,
326
+ serverImports: [],
327
+ client: void 0,
328
+ expectedEnvironments: void 0,
329
+ builtEnvironments: /* @__PURE__ */ new Set(),
330
+ warned: /* @__PURE__ */ new Set(),
331
+ served: /* @__PURE__ */ new Map(),
332
+ ...freshReloads(),
333
+ htmlRead: false,
334
+ serverTransformed: false,
335
+ directiveExpanded: false,
336
+ markupJudged: false,
337
+ warmedUp: false,
338
+ requested: /* @__PURE__ */ new Set(),
339
+ orderWarnings: freshWarningMemory()
340
+ };
341
+ }
342
+ function stateFor(root, config) {
343
+ const known = byConfig.get(config)?.get(root);
344
+ if (known) return known;
345
+ const build = buildOf(config);
346
+ const shared = build && byBuild.get(build)?.get(root);
347
+ const state = shared && !shared.started ? shared : freshState();
348
+ mapOf(byConfig, config).set(root, state);
349
+ if (build) mapOf(byBuild, build).set(root, state);
350
+ return state;
351
+ }
352
+ function moduleKey(environment, id) {
353
+ return `${environment}\0${id}`;
354
+ }
355
+ function collectedAtoms(state, kept) {
356
+ const atoms = new Set(kept);
357
+ for (const record of state.modules.values()) for (const atom of record.atoms) atoms.add(atom);
358
+ for (const page of state.pages.values()) for (const atom of page) atoms.add(atom);
359
+ return atoms;
360
+ }
361
+ function servedAtoms(state, kept) {
362
+ return withRestorers(collectedAtoms(state, kept));
363
+ }
364
+ function recordsOf(state, environment) {
365
+ const prefix = `${environment}\0`;
366
+ return [...state.modules].filter(([key]) => key.startsWith(prefix)).map(([, record]) => record);
367
+ }
368
+
369
+ // src/vite-css-capture.ts
370
+ var originals = /* @__PURE__ */ new WeakMap();
371
+ function transformHandler(plugin) {
372
+ const { transform } = plugin;
373
+ if (typeof transform === "function") return transform;
374
+ const handler = transform?.handler;
375
+ return typeof handler === "function" ? handler : void 0;
376
+ }
377
+ function unwrapped(handler) {
378
+ let current = handler;
379
+ for (let next = originals.get(current); next; next = originals.get(current)) current = next;
380
+ return current;
381
+ }
382
+ function remember(context, environment, id, css) {
383
+ const key = moduleKey(environment, id);
384
+ const isPossible = css.includes("\\") || /layer/i.test(css);
385
+ if (isPossible && inspectAtomicLayer(css).hasLayer) context.state.sheets.set(key, css);
386
+ else context.state.sheets.delete(key);
387
+ }
388
+ function captureStylesheets(context, plugins) {
389
+ const plugin = plugins?.find((candidate) => candidate.name === "vite:css-post");
390
+ const original = plugin && transformHandler(plugin);
391
+ if (!plugin || !original) return;
392
+ const wrapped = function(css, id) {
393
+ const environment = this.environment?.name ?? "client";
394
+ remember(context, environment, id, css);
395
+ return original.call(this, css, id);
396
+ };
397
+ originals.set(wrapped, original);
398
+ const { transform } = plugin;
399
+ plugin.transform = typeof transform === "function" ? wrapped : { ...transform, handler: wrapped };
400
+ }
401
+
402
+ // src/vite-css-id.ts
403
+ var STYLESHEET = /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
404
+ var SPECIAL_QUERY = /[?&](?:worker|sharedworker|raw|url)\b/;
405
+ var CSS_MODULE = /\.module\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
406
+ var TEXT_QUERY = /[?&](?:inline|direct|transform-only)\b/;
407
+ function isStylesheetPath(id) {
408
+ return STYLESHEET.test(id);
409
+ }
410
+ function isStylesheetId(id) {
411
+ return STYLESHEET.test(id) && !SPECIAL_QUERY.test(id);
412
+ }
413
+ function isCssModuleId(id) {
414
+ return isStylesheetId(id) && CSS_MODULE.test(id) && !TEXT_QUERY.test(id);
415
+ }
416
+ function isUnreadStylesheet(id) {
417
+ return isStylesheetId(id) && !isCssModuleId(id);
418
+ }
419
+ function canHoldDirective(code) {
420
+ return /@[n\\]/i.test(code);
421
+ }
422
+ function filePathOf(id) {
423
+ const query = id.indexOf("?");
424
+ return query === -1 ? id : id.slice(0, query);
425
+ }
426
+ var NAVE_MODULE_DIRS = ["src", "dist"].map(
427
+ (name) => `${path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", name).replaceAll("\\", "/")}/`
428
+ );
429
+ function pathOfId(id) {
430
+ return filePathOf(id).replaceAll("\\", "/");
431
+ }
432
+ function isNaveOwn(id) {
433
+ const file = pathOfId(id);
434
+ return NAVE_MODULE_DIRS.some((directory) => file.startsWith(directory));
435
+ }
436
+ function isDependencyId(id) {
437
+ return pathOfId(id).includes("/node_modules/");
438
+ }
439
+ async function packageNameOf(file, cache) {
440
+ const directory = path.dirname(file);
441
+ const cached = cache.get(directory);
442
+ if (cached) return cached;
443
+ const found = nameAbove(directory, cache);
444
+ cache.set(directory, found);
445
+ return found;
446
+ }
447
+ async function nameAbove(directory, cache) {
448
+ const name = await readName(directory);
449
+ const parent = path.dirname(directory);
450
+ if (name !== void 0 || parent === directory) return name;
451
+ return packageNameOf(directory, cache);
452
+ }
453
+ async function readName(directory) {
454
+ try {
455
+ const manifest = JSON.parse(await readFile(path.join(directory, "package.json"), "utf8"));
456
+ return typeof manifest.name === "string" ? manifest.name : void 0;
457
+ } catch {
458
+ return void 0;
459
+ }
460
+ }
461
+ function moduleLabel(root, id) {
462
+ const file = filePathOf(id);
463
+ if (file.startsWith("\0")) return String.raw`\0${file.slice(1)}`;
464
+ if (!path.isAbsolute(file)) return file;
465
+ return path.relative(root, file).replaceAll("\\", "/");
466
+ }
467
+
468
+ // src/vite-emit.ts
469
+ var decoder = new TextDecoder();
470
+ async function refeed(ctx, css, id) {
471
+ const plugin = ctx.environment.plugins.find((candidate) => candidate.name === "vite:css-post");
472
+ const handler = plugin && transformHandler(plugin);
473
+ if (!handler) {
474
+ ctx.error(
475
+ "nave: this version of Vite has no CSS step the plugin knows how to hand a stylesheet back to, so it cannot remove the unused atoms. Ship every atom with atomic: 'all' in navePlugin() until the plugin supports this version of Vite."
476
+ );
477
+ }
478
+ await unwrapped(handler).call(ctx, css, id);
479
+ }
480
+ var fedPages = /* @__PURE__ */ new WeakMap();
481
+ var warnedText = /* @__PURE__ */ new WeakMap();
482
+ function bookFor(book, emitted) {
483
+ const ids = book.get(emitted) ?? /* @__PURE__ */ new Set();
484
+ book.set(emitted, ids);
485
+ return ids;
486
+ }
487
+ function isPageStylesheet(id) {
488
+ return /[?&]html-proxy\b/.test(id);
489
+ }
490
+ function pageStylesheets(ctx, state, emitted) {
491
+ const prefix = `${ctx.environment.name}\0`;
492
+ const fed = bookFor(fedPages, emitted);
493
+ const ids = state.sheets.keys().filter((key) => key.startsWith(prefix) && isPageStylesheet(key)).map((key) => key.slice(prefix.length)).filter((id) => !fed.has(id)).toArray();
494
+ for (const id of ids) fed.add(id);
495
+ return ids;
496
+ }
497
+ function isInlineImport(id) {
498
+ return /[?&]inline\b/.test(id) && !isPageStylesheet(id);
499
+ }
500
+ function isRawImport(id) {
501
+ return /[?&]raw\b/.test(id) && isStylesheetPath(id);
502
+ }
503
+ function isLayerFile(id) {
504
+ try {
505
+ return inspectAtomicLayer(readFileSync(filePathOf(id), "utf8")).hasLayer;
506
+ } catch {
507
+ return false;
508
+ }
509
+ }
510
+ async function refeedChunkStylesheets(ctx, chunk, state, emitted) {
511
+ const prefix = `${ctx.environment.name}\0`;
512
+ for (const id of [...Object.keys(chunk.modules), ...pageStylesheets(ctx, state, emitted)]) {
513
+ const css = state.sheets.get(`${prefix}${id}`);
514
+ if (css === void 0 || isInlineImport(id)) continue;
515
+ await refeed(ctx, pruneAtomicLayer(css, emitted), id);
516
+ }
517
+ }
518
+ function warnTextImports(ctx, chunk, context, emitted) {
519
+ const prefix = `${ctx.environment.name}\0`;
520
+ const warned = bookFor(warnedText, emitted);
521
+ for (const id of Object.keys(chunk.modules)) {
522
+ if (warned.has(id)) continue;
523
+ const isInline = isInlineImport(id) && context.state.sheets.has(`${prefix}${id}`);
524
+ const isRaw = !isInline && isRawImport(id) && isLayerFile(id);
525
+ if (!isInline && !isRaw) continue;
526
+ warned.add(id);
527
+ const query = isInline ? "?inline" : "?raw";
528
+ ctx.warn(
529
+ `${moduleLabel(context.root, id)} is imported with ${query}, so its stylesheet is text in the JavaScript, which the plugin does not filter: every atom in its atomic layer ships, not only the atoms this build emits. Import it without ${query} to have the layer filtered.`
530
+ );
531
+ }
532
+ }
533
+ function textOf(entry) {
534
+ const { source } = entry;
535
+ if (source === void 0) return "";
536
+ return typeof source === "string" ? source : decoder.decode(source);
537
+ }
538
+ function readLayers(bundle, emitted) {
539
+ const reading = /* @__PURE__ */ new Map();
540
+ const assets = Object.values(bundle).filter((entry) => entry.type === "asset" && entry.fileName.toLowerCase().endsWith(".css")).map((entry) => ({ fileName: entry.fileName, css: textOf(entry) }));
541
+ for (const { fileName, css } of assets) {
542
+ const seen = inspectAtomicLayer(css);
543
+ if (!seen.hasLayer) continue;
544
+ const extra = unprunedAtoms(css, emitted);
545
+ reading.set(fileName, {
546
+ seen: new Set(seen.atoms),
547
+ extra: extra.length > 0 ? `${fileName}: the atomic layer holds a rule for ${extra.join(", ")}, which the build did not emit.` : void 0
548
+ });
549
+ }
550
+ return reading;
551
+ }
552
+ function mismatchLines(reading, emitted) {
553
+ const assets = reading.values().toArray();
554
+ const lines = assets.flatMap((asset) => asset.extra ? [asset.extra] : []);
555
+ const seenAnywhere = new Set(assets.flatMap((asset) => [...asset.seen]));
556
+ const missing = [...emitted.difference(seenAnywhere)];
557
+ if (reading.size > 0 && missing.length > 0) {
558
+ lines.push(`the atomic layers hold no rule for ${missing.join(", ")}, which the build emitted.`);
559
+ }
560
+ return lines;
561
+ }
562
+ function layerMessage(lines) {
563
+ return [
564
+ "nave: the built CSS does not hold exactly the atoms the build emitted, so the plugin could not remove the unused ones on this version of Vite.",
565
+ ...lines,
566
+ "Ship every atom with atomic: 'all' in navePlugin() until the plugin supports this version of Vite."
567
+ ].join("\n");
568
+ }
569
+ var HANDSHAKE_FILE = "nave-used-atoms.json";
570
+ function handshakePath(cacheDir) {
571
+ return path.join(cacheDir, HANDSHAKE_FILE);
572
+ }
573
+ function readHandshake(cacheDir) {
574
+ if (cacheDir === "") return void 0;
575
+ try {
576
+ const parsed2 = JSON.parse(readFileSync(handshakePath(cacheDir), "utf8"));
577
+ return Array.isArray(parsed2.emitted) && typeof parsed2.writer === "string" ? parsed2 : void 0;
578
+ } catch {
579
+ return void 0;
580
+ }
581
+ }
582
+ function writeHandshake(cacheDir, fields, warn) {
583
+ if (cacheDir === "") return;
584
+ const handshake = {
585
+ ...fields,
586
+ emitted: [...fields.emitted].toSorted(compareText),
587
+ writtenAt: fields.writtenAt ?? (/* @__PURE__ */ new Date()).toISOString(),
588
+ build: fields.build ?? randomUUID()
589
+ };
590
+ try {
591
+ mkdirSync(cacheDir, { recursive: true });
592
+ writeFileSync(handshakePath(cacheDir), `${JSON.stringify(handshake, void 0, 2)}
593
+ `);
594
+ } catch (error) {
595
+ const reason = error instanceof Error ? error.message : String(error);
596
+ warn?.(
597
+ `navePlugin(): could not write ${handshakePath(cacheDir)} (${reason}), so a build of the client and a build of the server run as two processes cannot share their atoms.`
598
+ );
599
+ }
600
+ }
601
+
602
+ // src/vite-emitted.ts
603
+ function positionText(place) {
604
+ return place.line === 0 ? place.file : `${place.file}:${place.line}:${place.column}`;
605
+ }
606
+ function packageRecords(context) {
607
+ const records = {};
608
+ for (const pkg of Object.keys(context.options.keepFor)) {
609
+ const modules = context.state.modules.values().filter((record) => record.pkg === pkg).toArray();
610
+ const places = modules.flatMap((record) => [...record.suppressed, ...record.dynamicCalls]);
611
+ records[pkg] = {
612
+ collected: [...new Set(modules.flatMap((record) => [...record.atoms]))].toSorted(compareText),
613
+ unreadable: places.map((place) => positionText(place))
614
+ };
615
+ }
616
+ return records;
617
+ }
618
+ function unmatchedKeys(context) {
619
+ const transformed = new Set(context.state.modules.values().map((record) => record.pkg));
620
+ return Object.keys(context.options.keepFor).filter((pkg) => !transformed.has(pkg));
621
+ }
622
+ function takenFromCache(context) {
623
+ const file = context.inProcess ? void 0 : readHandshake(context.cacheDir);
624
+ if (file === void 0) return { atoms: [], took: false };
625
+ if (file.writer !== "client") return { atoms: file.emitted, took: true };
626
+ const pending = file.pending ?? [];
627
+ return { atoms: pending, took: pending.length > 0 };
628
+ }
629
+ function canWriteStylesheets(context, environment) {
630
+ const { state } = context;
631
+ if (environment.config.consumer === "client")
632
+ return state.firstWriter !== "server" || hasStylesheet(state, environment.name);
633
+ if (!context.inProcess || state.firstWriter === "client") return false;
634
+ return environment.config.build?.emitAssets === true;
635
+ }
636
+ function emittedSet(context, environment, warn) {
637
+ const { state } = context;
638
+ const known = state.fixed.get(environment.name);
639
+ if (known) return known;
640
+ const atoms = collectedAtoms(state, context.kept);
641
+ const taken = takenFromCache(context);
642
+ for (const atom of taken.atoms) atoms.add(atom);
643
+ withRestorers(atoms);
644
+ state.fixed.set(environment.name, atoms);
645
+ if (state.emitted === void 0) {
646
+ state.emitted = atoms;
647
+ state.emittedBy = environment.name;
648
+ state.firstWriter = environment.config.consumer === "client" ? "client" : "server";
649
+ }
650
+ writeHandshake(
651
+ context.cacheDir,
652
+ {
653
+ emitted: [...atoms],
654
+ writer: environment.config.consumer === "client" ? "client" : environment.name,
655
+ consumed: taken.took,
656
+ keepFor: packageRecords(context),
657
+ unmatchedKeepFor: unmatchedKeys(context)
658
+ },
659
+ warn
660
+ );
661
+ return atoms;
662
+ }
663
+ function namingLines(ctx, context, atoms) {
664
+ return recordsOf(context.state, ctx.environment.name).flatMap(
665
+ (record) => atoms.filter((atom) => record.atoms.has(atom)).map((atom) => `${record.file}: names ${atom}.`)
666
+ );
667
+ }
668
+ function missingFromClient(ctx, context, missing) {
669
+ return [
670
+ "The client build already wrote its CSS without atoms this server build names, so their rules are missing from it:",
671
+ ...namingLines(ctx, context, missing),
672
+ `They are recorded in ${handshakePath(context.cacheDir)} for the next client build. List the atoms in keep in navePlugin(), or build the client again, then the server (vite build, then vite build --ssr). To keep this from recurring, build the server first, then the client (vite build --ssr, then vite build).`
673
+ ].join("\n");
674
+ }
675
+ function notInLastClient(ctx, context, missing) {
676
+ return [
677
+ `${handshakePath(context.cacheDir)} was written by a client build that was already used, so this server build could not be checked against the CSS. These atoms it names are not in that client build's set:`,
678
+ ...namingLines(ctx, context, missing),
679
+ "They are recorded in that file for a client build that runs next; to have them in the CSS, build the server first, then the client (vite build --ssr, then vite build)."
680
+ ].join("\n");
681
+ }
682
+ function recordForNextClient(ctx, context, atoms, held) {
683
+ writeHandshake(
684
+ context.cacheDir,
685
+ { emitted: [...withRestorers(new Set(atoms))], writer: ctx.environment.name, consumed: false },
686
+ (message) => ctx.warn(message)
687
+ );
688
+ const missing = [...atoms].filter((atom) => !held.includes(atom)).toSorted(compareText);
689
+ if (missing.length > 0) ctx.warn(notInLastClient(ctx, context, missing));
690
+ }
691
+ function checkWaitingClient(ctx, context, atoms, file) {
692
+ const missing = [...atoms].filter((atom) => !file.emitted.includes(atom)).toSorted(compareText);
693
+ if (missing.length === 0) {
694
+ writeHandshake(context.cacheDir, { ...file, consumed: true, pending: [] }, (message) => {
695
+ ctx.warn(message);
696
+ });
697
+ return;
698
+ }
699
+ const pending = [.../* @__PURE__ */ new Set([...file.pending ?? [], ...withRestorers(new Set(atoms))])];
700
+ writeHandshake(context.cacheDir, { ...file, pending }, (message) => ctx.warn(message));
701
+ ctx.error(missingFromClient(ctx, context, missing));
702
+ }
703
+ function checkServerInvocation(ctx, context) {
704
+ if (context.cacheDir === "" || context.inProcess || context.state.emitted) return;
705
+ const atoms = new Set(recordsOf(context.state, ctx.environment.name).flatMap((r) => [...r.atoms]));
706
+ const file = readHandshake(context.cacheDir);
707
+ if (file?.writer !== "client") {
708
+ const emitted = [...withRestorers(/* @__PURE__ */ new Set([...atoms, ...file?.emitted ?? []]))];
709
+ writeHandshake(
710
+ context.cacheDir,
711
+ { emitted, writer: ctx.environment.name, consumed: false },
712
+ (message) => ctx.warn(message)
713
+ );
714
+ } else if (file.consumed) {
715
+ recordForNextClient(ctx, context, atoms, file.emitted);
716
+ } else {
717
+ checkWaitingClient(ctx, context, atoms, file);
718
+ }
719
+ }
720
+
721
+ // src/vite-scan.ts
722
+ var decoder2 = new TextDecoder();
723
+ function isCssAsset(entry) {
724
+ return entry.type === "asset" && entry.fileName.toLowerCase().endsWith(".css");
725
+ }
726
+ function textOf2(entry) {
727
+ const { source } = entry;
728
+ if (source === void 0) return "";
729
+ return typeof source === "string" ? source : decoder2.decode(source);
730
+ }
731
+ function scanMessage(findings, assetCount) {
732
+ const noun = assetCount === 1 ? "asset" : "assets";
733
+ return [
734
+ "@nave survived into the built CSS:",
735
+ ...findings.map((finding) => formatFinding(finding)),
736
+ `Scanned ${assetCount} CSS ${noun} this build wrote.`
737
+ ].join("\n");
738
+ }
739
+ function scanAssets(bundle) {
740
+ const assets = Object.values(bundle).filter((entry) => isCssAsset(entry));
741
+ return {
742
+ findings: assets.flatMap((asset) => findingsInText(asset.fileName, textOf2(asset))),
743
+ names: assets.map((asset) => asset.fileName)
744
+ };
745
+ }
746
+
747
+ // src/vite-whole.ts
748
+ function stylesheetsLeftWhole(context, environment, chunk) {
749
+ const { state } = context;
750
+ const whole = /* @__PURE__ */ new Set();
751
+ if (state.firstWriter !== "server" || environment.config.consumer !== "server") return whole;
752
+ const earlier = [...state.writers].filter(([name, consumer]) => name !== environment.name && consumer === "server").map(([name]) => name);
753
+ const ids = Object.keys(chunk.modules);
754
+ for (const id of ids) {
755
+ if (earlier.every((name) => !state.sheets.has(moduleKey(name, id)))) continue;
756
+ whole.add(id);
757
+ state.whole.add(moduleKey(environment.name, id));
758
+ }
759
+ return whole;
760
+ }
761
+ function withoutWhole(chunk, whole) {
762
+ if (whole.size === 0) return chunk;
763
+ return {
764
+ modules: Object.fromEntries(Object.entries(chunk.modules).filter(([id]) => !whole.has(id)))
765
+ };
766
+ }
767
+ function assetKey(environment, entry) {
768
+ return `${environment}|${(entry.names ?? []).join(",")}|${(entry.originalFileNames ?? []).join(",")}`;
769
+ }
770
+ function noteWholeAssets(context, environment, bundle) {
771
+ const { state } = context;
772
+ if (state.whole.size === 0) return;
773
+ const chunks = Object.values(bundle).filter((entry) => entry.type === "chunk");
774
+ for (const entry of chunks) {
775
+ const ids = Object.keys(entry.modules ?? {});
776
+ if (ids.every((id) => !state.whole.has(moduleKey(environment.name, id)))) continue;
777
+ const files = entry.viteMetadata?.importedCss ?? /* @__PURE__ */ new Set();
778
+ for (const file of files) {
779
+ const asset = bundle[file];
780
+ if (asset) state.wholeAssets.add(assetKey(environment.name, asset));
781
+ }
782
+ }
783
+ }
784
+ function withoutWholeAssets(context, environment, bundle) {
785
+ const { wholeAssets } = context.state;
786
+ if (wholeAssets.size === 0) return { ...bundle };
787
+ return Object.fromEntries(
788
+ Object.entries(bundle).filter(
789
+ ([, entry]) => !(entry.type === "asset" && wholeAssets.has(assetKey(environment.name, entry)))
790
+ )
791
+ );
792
+ }
793
+
794
+ // src/vite-bundle.ts
795
+ var reads = /* @__PURE__ */ new WeakMap();
796
+ function sourceText(entry) {
797
+ return typeof entry.source === "string" ? entry.source : new TextDecoder().decode(entry.source);
798
+ }
799
+ function hasLayerAsset(bundle) {
800
+ return Object.values(bundle).some(
801
+ (entry) => entry.type === "asset" && entry.fileName.toLowerCase().endsWith(".css") && /@layer\s+atomic\b/.test(sourceText(entry))
802
+ );
803
+ }
804
+ function didWrite(context, environment, step) {
805
+ const { state } = context;
806
+ if (reads.get(step.output)?.wrote === true || hasLayerAsset(step.bundle)) {
807
+ state.writers.set(environment.name, environment.config.consumer);
808
+ return true;
809
+ }
810
+ if (state.emittedBy === environment.name && environment.config.consumer !== "client") {
811
+ state.emitted = void 0;
812
+ state.emittedBy = void 0;
813
+ state.firstWriter = void 0;
814
+ state.fixed.delete(environment.name);
815
+ }
816
+ return false;
817
+ }
818
+ function accumulate(step, layer, isWriter) {
819
+ const { bundle, output } = step;
820
+ const before = reads.get(output) ?? {
821
+ layer: /* @__PURE__ */ new Map(),
822
+ findings: /* @__PURE__ */ new Map(),
823
+ assets: /* @__PURE__ */ new Set(),
824
+ wrote: false
825
+ };
826
+ reads.set(output, before);
827
+ before.wrote ||= isWriter;
828
+ if (layer) for (const [name, asset] of layer) before.layer.set(name, asset);
829
+ const scanned = scanAssets(bundle);
830
+ for (const finding of scanned.findings) before.findings.set(formatFinding(finding), finding);
831
+ for (const name of scanned.names) before.assets.add(name);
832
+ return before;
833
+ }
834
+ function readWritten(ctx, context, step) {
835
+ const { environment } = ctx;
836
+ if (environment === void 0 || context.options.atomic !== "used") return void 0;
837
+ if (!canWriteStylesheets(context, environment)) return void 0;
838
+ if (!didWrite(context, environment, step)) return void 0;
839
+ noteWholeAssets(context, environment, step.bundle);
840
+ const emitted = emittedSet(context, environment, (message) => {
841
+ ctx.warn(message);
842
+ });
843
+ return {
844
+ emitted,
845
+ layer: readLayers(withoutWholeAssets(context, environment, step.bundle), emitted)
846
+ };
847
+ }
848
+ function failOnMismatch(ctx, lines) {
849
+ if (lines.length > 0) ctx.error({ message: layerMessage(lines) });
850
+ }
851
+ function failOnFindings(ctx, read) {
852
+ if (read.findings.size === 0) return;
853
+ ctx.error({ message: scanMessage(read.findings.values().toArray(), read.assets.size) });
854
+ }
855
+ function raise(ctx, seen) {
856
+ reads.delete(seen.output);
857
+ if (seen.emitted) failOnMismatch(ctx, mismatchLines(seen.read.layer, seen.emitted));
858
+ failOnFindings(ctx, seen.read);
859
+ }
860
+ function checkBundle(ctx, context, step) {
861
+ const { bundle, options, pass } = step;
862
+ const output = typeof options === "object" && options !== null ? options : bundle;
863
+ const written = readWritten(ctx, context, { bundle, output });
864
+ const read = accumulate({ bundle, output }, written?.layer, written !== void 0);
865
+ if (pass === "post") raise(ctx, { emitted: written?.emitted, output, read });
866
+ }
867
+
868
+ // src/vite-unread-record.ts
869
+ function isListed(context, pkg) {
870
+ return pkg !== void 0 && Object.hasOwn(context.options.keepFor, pkg);
871
+ }
872
+ var NOT_PARSED = "the module could not be read, so the atoms it names would not ship: it did not parse as JavaScript. TypeScript and JSX must be compiled by Vite's own transform first, so leave oxc on for this file.";
873
+ var TOO_DEEP = "the module could not be read, so the atoms it names would not ship: it is nested too deeply.";
874
+ function unreadableRecord(context, input, text) {
875
+ const { code, id, pkg } = input;
876
+ const file = moduleLabel(context.root, id);
877
+ const problem = {
878
+ kind: "unreadable",
879
+ offset: 0,
880
+ construct: "",
881
+ text,
882
+ file,
883
+ pkg,
884
+ line: 1,
885
+ column: 1
886
+ };
887
+ const isStandingIn = isListed(context, pkg);
888
+ return {
889
+ // The classes written whole need no parse to be found.
890
+ atoms: atomsWrittenIn(code),
891
+ problems: isStandingIn ? [] : [problem],
892
+ suppressed: isStandingIn ? [problem] : [],
893
+ dynamicCalls: [],
894
+ pkg,
895
+ file
896
+ };
897
+ }
898
+ var SOURCE_TYPES = /* @__PURE__ */ new Set(["js", "jsx", "ts", "tsx"]);
899
+ function jsonStrings(code) {
900
+ let parsed2;
901
+ try {
902
+ parsed2 = JSON.parse(code);
903
+ } catch {
904
+ return [];
905
+ }
906
+ const strings = [];
907
+ const stack = [parsed2];
908
+ while (stack.length > 0) {
909
+ const value = stack.pop();
910
+ if (typeof value === "string") strings.push(value);
911
+ else if (Array.isArray(value)) {
912
+ for (const item of value) stack.push(item);
913
+ } else if (typeof value === "object" && value !== null) {
914
+ for (const key of Object.keys(value)) strings.push(key);
915
+ for (const item of Object.values(value)) stack.push(item);
916
+ }
917
+ }
918
+ return strings;
919
+ }
920
+ function textRecord(context, input) {
921
+ const { code, id, moduleType, pkg } = input;
922
+ const decoded = moduleType === "json" ? jsonStrings(code) : [];
923
+ return {
924
+ atoms: new Set(
925
+ [atomsWrittenIn(code), ...decoded.map((text) => atomsWrittenIn(text))].flatMap((found) => [
926
+ ...found
927
+ ])
928
+ ),
929
+ problems: [],
930
+ suppressed: [],
931
+ dynamicCalls: [],
932
+ pkg,
933
+ file: moduleLabel(context.root, id)
934
+ };
148
935
  }
149
936
 
150
- // src/vite-css-id.ts
151
- var STYLESHEET = /\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
152
- var SPECIAL_QUERY = /[?&](?:worker|sharedworker|raw|url)\b/;
153
- function isStylesheetPath(id) {
154
- return STYLESHEET.test(id);
937
+ // src/vite-css-module-record.ts
938
+ function stringOf(node) {
939
+ return node?.type === "Literal" && typeof node.value === "string" ? node.value : void 0;
155
940
  }
156
- function isStylesheetId(id) {
157
- return STYLESHEET.test(id) && !SPECIAL_QUERY.test(id);
941
+ function namedStrings(declaration) {
942
+ return nodesAt(declaration, "declarations").map(
943
+ (declarator) => stringOf(nodeAt(declarator, "init")) ?? ""
944
+ );
158
945
  }
159
- function canHoldDirective(code) {
160
- return /@[n\\]/i.test(code);
946
+ function defaultStrings(declaration) {
947
+ return nodesAt(declaration, "properties").map(
948
+ (property) => stringOf(nodeAt(property, "value")) ?? ""
949
+ );
161
950
  }
162
- function filePathOf(id) {
163
- const query = id.indexOf("?");
164
- return query === -1 ? id : id.slice(0, query);
951
+ function exportedStrings(program) {
952
+ const strings = nodesAt(program, "body").flatMap((statement) => {
953
+ const declaration = nodeAt(statement, "declaration");
954
+ if (declaration === void 0) return [];
955
+ if (statement.type === "ExportNamedDeclaration" && declaration.type === "VariableDeclaration") {
956
+ return namedStrings(declaration);
957
+ }
958
+ if (statement.type === "ExportDefaultDeclaration" && declaration.type === "ObjectExpression") {
959
+ return defaultStrings(declaration);
960
+ }
961
+ return [];
962
+ });
963
+ return strings.filter((text) => text !== "");
964
+ }
965
+ function cssModuleRecord(context, ctx, input) {
966
+ const { code, id, pkg } = input;
967
+ let program;
968
+ try {
969
+ program = ctx.parse(code);
970
+ } catch {
971
+ const unreadable = unreadableRecord(context, { code: "", id, pkg }, CLASS_MAP_NOT_PARSED);
972
+ return {
973
+ ...unreadable,
974
+ problems: [...unreadable.problems, ...unreadable.suppressed],
975
+ suppressed: []
976
+ };
977
+ }
978
+ const strings = isNode(program) ? exportedStrings(program) : [];
979
+ return textRecord(context, { code: strings.join("\n"), id, pkg });
980
+ }
981
+ function recordWithoutCalls(context, ctx, module) {
982
+ if (isCssModuleId(module.id)) return cssModuleRecord(context, ctx, module);
983
+ const { moduleType } = module;
984
+ if (moduleType !== void 0 && !SOURCE_TYPES.has(moduleType)) return textRecord(context, module);
985
+ return void 0;
165
986
  }
166
987
 
167
988
  // src/vite-cx-text-test.ts
@@ -189,8 +1010,8 @@ function fileOf(id) {
189
1010
  return filePathOf(id).replaceAll("\\", "/");
190
1011
  }
191
1012
  function namesOf(file) {
192
- const name = path2.basename(file, path2.extname(file));
193
- return name === "index" ? [name, path2.basename(path2.dirname(file))] : [name];
1013
+ const name = path.basename(file, path.extname(file));
1014
+ return name === "index" ? [name, path.basename(path.dirname(file))] : [name];
194
1015
  }
195
1016
  function entriesNaming(declared, id) {
196
1017
  const file = fileOf(id);
@@ -213,7 +1034,7 @@ async function resolveOrNull(resolver, source, importer) {
213
1034
  }
214
1035
  }
215
1036
  async function resolveEntries(context, resolver) {
216
- const from = path2.join(context.root, "index.html");
1037
+ const from = path.join(context.root, "index.html");
217
1038
  const nave = await resolveOrNull(resolver, CX_SOURCE, from);
218
1039
  const naveFile = nave === void 0 ? void 0 : fileOf(nave.id);
219
1040
  const resolved = await Promise.all(
@@ -256,7 +1077,7 @@ function lastSegmentOf(specifier) {
256
1077
  function isNamingListed(specifier, declared) {
257
1078
  const segment = lastSegmentOf(specifier);
258
1079
  if (declared.names.has(segment)) return true;
259
- const extension = path2.extname(segment);
1080
+ const extension = path.extname(segment);
260
1081
  return extension !== "" && declared.names.has(segment.slice(0, -extension.length));
261
1082
  }
262
1083
  function isAboutListed(input, declared) {
@@ -273,49 +1094,6 @@ function isMentioningDeclared(code, declared) {
273
1094
  function recognisedKey(environment, file, importer) {
274
1095
  return `${environment}\0${file}\0${importer}`;
275
1096
  }
276
- var NAVE_MODULE_DIRS = ["src", "dist"].map(
277
- (name) => `${path2.resolve(path2.dirname(fileURLToPath(import.meta.url)), "..", name).replaceAll("\\", "/")}/`
278
- );
279
- function pathOfId(id) {
280
- return filePathOf(id).replaceAll("\\", "/");
281
- }
282
- function isNaveOwn(id) {
283
- const file = pathOfId(id);
284
- return NAVE_MODULE_DIRS.some((directory) => file.startsWith(directory));
285
- }
286
- function isDependencyId(id) {
287
- return pathOfId(id).includes("/node_modules/");
288
- }
289
- async function packageNameOf(file, cache) {
290
- const directory = path2.dirname(file);
291
- const cached = cache.get(directory);
292
- if (cached) return cached;
293
- const found = nameAbove(directory, cache);
294
- cache.set(directory, found);
295
- return found;
296
- }
297
- async function nameAbove(directory, cache) {
298
- const name = await readName(directory);
299
- const parent = path2.dirname(directory);
300
- if (name !== void 0 || parent === directory) return name;
301
- return packageNameOf(directory, cache);
302
- }
303
- async function readName(directory) {
304
- try {
305
- const manifest = JSON.parse(await readFile(path2.join(directory, "package.json"), "utf8"));
306
- return typeof manifest.name === "string" ? manifest.name : void 0;
307
- } catch {
308
- return void 0;
309
- }
310
- }
311
- function moduleLabel(root, id) {
312
- const file = filePathOf(id);
313
- if (file.startsWith("\0")) return String.raw`\0${file.slice(1)}`;
314
- if (!path2.isAbsolute(file)) return file;
315
- return path2.relative(root, file).replaceAll("\\", "/");
316
- }
317
-
318
- // src/vite-cx-importers.ts
319
1097
  function importerIdsOf(ctx, cxId) {
320
1098
  const info = ctx.getModuleInfo?.(cxId);
321
1099
  return [.../* @__PURE__ */ new Set([...info?.importers ?? [], ...info?.dynamicImporters ?? []])];
@@ -380,7 +1158,7 @@ async function lineOf(ctx, context, importer, known) {
380
1158
  return isRead ? void 0 : lineFor(label, []);
381
1159
  }
382
1160
  async function checkCxImporters(ctx, context) {
383
- const resolved = await ctx.resolve?.(CX_SOURCE, path2.join(context.root, "index.html"));
1161
+ const resolved = await ctx.resolve?.(CX_SOURCE, path.join(context.root, "index.html"));
384
1162
  if (!resolved) return;
385
1163
  const known = { cxId: resolved.id, answers: /* @__PURE__ */ new Map() };
386
1164
  const lines = [];
@@ -498,192 +1276,53 @@ function removeServerKeepMap(owner) {
498
1276
  publish();
499
1277
  }
500
1278
 
501
- // src/vite-dev-reloads.ts
502
- function freshReloads() {
503
- return {
504
- stale: /* @__PURE__ */ new Set(),
505
- reloading: /* @__PURE__ */ new Map(),
506
- listening: 0,
507
- unheard: /* @__PURE__ */ new Set(),
508
- reloadTimer: void 0,
509
- readAhead: 0
510
- };
511
- }
512
- function noteReloadSent(state, id) {
513
- state.reloading.set(id, Date.now());
514
- if (state.listening === 0) state.unheard.add(id);
515
- }
516
-
517
- // src/vite-state.ts
518
- var byConfig = /* @__PURE__ */ new WeakMap();
519
- var byBuild = /* @__PURE__ */ new WeakMap();
520
- function buildOf(config) {
521
- return config.command === "build" ? config.inlineConfig : void 0;
522
- }
523
- function mapOf(registry2, owner) {
524
- const found = registry2.get(owner) ?? /* @__PURE__ */ new Map();
525
- registry2.set(owner, found);
526
- return found;
527
- }
528
- function freshState() {
529
- return {
530
- started: false,
531
- modules: /* @__PURE__ */ new Map(),
532
- exposures: /* @__PURE__ */ new Map(),
533
- templateLinks: /* @__PURE__ */ new Map(),
534
- packages: /* @__PURE__ */ new Set(),
535
- declared: /* @__PURE__ */ new Map(),
536
- recognised: /* @__PURE__ */ new Map(),
537
- sheets: /* @__PURE__ */ new Map(),
538
- pages: /* @__PURE__ */ new Map(),
539
- emitted: void 0,
540
- externals: /* @__PURE__ */ new Set(),
541
- clientEnded: false,
542
- serverImports: [],
543
- client: void 0,
544
- expectedEnvironments: void 0,
545
- builtEnvironments: /* @__PURE__ */ new Set(),
546
- warned: /* @__PURE__ */ new Set(),
547
- served: /* @__PURE__ */ new Map(),
548
- ...freshReloads(),
549
- htmlRead: false,
550
- serverTransformed: false,
551
- directiveExpanded: false,
552
- markupJudged: false,
553
- warmedUp: false,
554
- requested: /* @__PURE__ */ new Set()
555
- };
556
- }
557
- function stateFor(root, config) {
558
- const known = byConfig.get(config)?.get(root);
559
- if (known) return known;
560
- const build = buildOf(config);
561
- const shared = build && byBuild.get(build)?.get(root);
562
- const state = shared && !shared.started ? shared : freshState();
563
- mapOf(byConfig, config).set(root, state);
564
- if (build) mapOf(byBuild, build).set(root, state);
565
- return state;
566
- }
567
- function moduleKey(environment, id) {
568
- return `${environment}\0${id}`;
569
- }
570
- function collectedAtoms(state, kept) {
571
- const atoms = new Set(kept);
572
- for (const record of state.modules.values()) for (const atom of record.atoms) atoms.add(atom);
573
- for (const page of state.pages.values()) for (const atom of page) atoms.add(atom);
574
- return atoms;
575
- }
576
- function withRestorers(atoms) {
577
- if (atoms.has("srOnly")) atoms.add("srOnlyFocusable");
578
- return atoms;
579
- }
580
- function servedAtoms(state, kept) {
581
- return withRestorers(collectedAtoms(state, kept));
582
- }
583
- function recordsOf(state, environment) {
584
- const prefix = `${environment}\0`;
585
- return [...state.modules].filter(([key]) => key.startsWith(prefix)).map(([, record]) => record);
586
- }
587
-
588
- // src/vite-setup-link.ts
589
- function importsContaining(program, marker) {
590
- const sources = nodesAt(program, "body").map(
591
- (node) => node.type === "ImportDeclaration" ? staticStringOf(nodeAt(node, "source")) : void 0
592
- );
593
- return sources.filter((source) => source?.includes(marker) === true);
594
- }
595
- async function resolveId(ctx, source, importer) {
596
- const resolved = await ctx.resolve?.(source, importer);
597
- return resolved?.id;
598
- }
599
- async function linkTemplates(context, ctx, input, scriptId) {
600
- const environment = ctx.environment?.name ?? "client";
601
- for (const template of importsContaining(input.program, "type=template")) {
602
- const templateId = await resolveId(ctx, template, input.id);
603
- if (templateId !== void 0) {
604
- context.state.templateLinks.set(moduleKey(environment, templateId), scriptId);
605
- }
606
- }
607
- }
608
- async function setupExposuresFor(context, ctx, input) {
609
- const environment = ctx.environment?.name ?? "client";
610
- const [script] = importsContaining(input.program, "type=script");
611
- const scriptId = script === void 0 ? void 0 : await resolveId(ctx, script, input.id);
612
- await linkTemplates(context, ctx, input, scriptId ?? input.id);
613
- if (!input.code.includes("$setup")) return void 0;
614
- const owner = scriptId ?? context.state.templateLinks.get(moduleKey(environment, input.id));
615
- if (owner === void 0) return void 0;
616
- await ctx.load?.({ id: owner });
617
- return context.state.exposures.get(moduleKey(environment, owner));
1279
+ // src/vite-serialised-css.ts
1280
+ var IDENTIFIER = /^[\w-]+/;
1281
+ var SELECTOR_REST = /^(?:[^{};'"`\\]|\\[nrt])*\{/;
1282
+ function isSerialisedStylesheet(code) {
1283
+ let mentions = 0;
1284
+ for (let at = code.indexOf("nave-"); at !== -1; at = code.indexOf("nave-", at + 5)) {
1285
+ const before = code[at - 1];
1286
+ if (before !== void 0 && /[\w-]/.test(before)) continue;
1287
+ const name = IDENTIFIER.exec(code.slice(at, at + 64))?.[0];
1288
+ if (name === void 0 || atomOfClass(name) === void 0) continue;
1289
+ mentions += 1;
1290
+ if (before !== "." || !SELECTOR_REST.test(code.slice(at + name.length, at + name.length + 600)))
1291
+ return false;
1292
+ }
1293
+ return mentions > 0;
618
1294
  }
619
1295
 
620
- // src/vite-unread-record.ts
621
- function isListed(context, pkg) {
622
- return pkg !== void 0 && Object.hasOwn(context.options.keepFor, pkg);
623
- }
624
- var NOT_PARSED = "the module could not be read, so the atoms it names would not ship: it did not parse as JavaScript. TypeScript and JSX must be compiled by Vite's own transform first, so leave oxc on for this file.";
625
- var TOO_DEEP = "the module could not be read, so the atoms it names would not ship: it is nested too deeply.";
626
- function unreadableRecord(context, input, text) {
627
- const { code, id, pkg } = input;
628
- const file = moduleLabel(context.root, id);
629
- const problem = {
630
- kind: "unreadable",
631
- offset: 0,
632
- construct: "",
633
- text,
634
- file,
635
- pkg,
636
- line: 1,
637
- column: 1
638
- };
639
- const isStandingIn = isListed(context, pkg);
640
- return {
641
- // The classes written whole need no parse to be found.
642
- atoms: atomsWrittenIn(code),
643
- problems: isStandingIn ? [] : [problem],
644
- suppressed: isStandingIn ? [problem] : [],
645
- dynamicCalls: [],
646
- pkg,
647
- file
648
- };
649
- }
650
- var SOURCE_TYPES = /* @__PURE__ */ new Set(["js", "jsx", "ts", "tsx"]);
651
- function jsonStrings(code) {
652
- let parsed2;
653
- try {
654
- parsed2 = JSON.parse(code);
655
- } catch {
656
- return [];
657
- }
658
- const strings = [];
659
- const stack = [parsed2];
660
- while (stack.length > 0) {
661
- const value = stack.pop();
662
- if (typeof value === "string") strings.push(value);
663
- else if (Array.isArray(value)) {
664
- for (const item of value) stack.push(item);
665
- } else if (typeof value === "object" && value !== null) {
666
- for (const key of Object.keys(value)) strings.push(key);
667
- for (const item of Object.values(value)) stack.push(item);
1296
+ // src/vite-setup-link.ts
1297
+ function importsContaining(program, marker) {
1298
+ const sources = nodesAt(program, "body").map(
1299
+ (node) => node.type === "ImportDeclaration" ? staticStringOf(nodeAt(node, "source")) : void 0
1300
+ );
1301
+ return sources.filter((source) => source?.includes(marker) === true);
1302
+ }
1303
+ async function resolveId(ctx, source, importer) {
1304
+ const resolved = await ctx.resolve?.(source, importer);
1305
+ return resolved?.id;
1306
+ }
1307
+ async function linkTemplates(context, ctx, input, scriptId) {
1308
+ const environment = ctx.environment?.name ?? "client";
1309
+ for (const template of importsContaining(input.program, "type=template")) {
1310
+ const templateId = await resolveId(ctx, template, input.id);
1311
+ if (templateId !== void 0) {
1312
+ context.state.templateLinks.set(moduleKey(environment, templateId), scriptId);
668
1313
  }
669
1314
  }
670
- return strings;
671
1315
  }
672
- function textRecord(context, input) {
673
- const { code, id, moduleType, pkg } = input;
674
- const decoded = moduleType === "json" ? jsonStrings(code) : [];
675
- return {
676
- atoms: new Set(
677
- [atomsWrittenIn(code), ...decoded.map((text) => atomsWrittenIn(text))].flatMap((found) => [
678
- ...found
679
- ])
680
- ),
681
- problems: [],
682
- suppressed: [],
683
- dynamicCalls: [],
684
- pkg,
685
- file: moduleLabel(context.root, id)
686
- };
1316
+ async function setupExposuresFor(context, ctx, input) {
1317
+ const environment = ctx.environment?.name ?? "client";
1318
+ const [script] = importsContaining(input.program, "type=script");
1319
+ const scriptId = script === void 0 ? void 0 : await resolveId(ctx, script, input.id);
1320
+ await linkTemplates(context, ctx, input, scriptId ?? input.id);
1321
+ if (!input.code.includes("$setup")) return void 0;
1322
+ const owner = scriptId ?? context.state.templateLinks.get(moduleKey(environment, input.id));
1323
+ if (owner === void 0) return void 0;
1324
+ await ctx.load?.({ id: owner });
1325
+ return context.state.exposures.get(moduleKey(environment, owner));
687
1326
  }
688
1327
 
689
1328
  // src/vite-used.ts
@@ -730,7 +1369,9 @@ async function ownAtomNames(context, watch = ignoreWatch) {
730
1369
  // src/vite-collect-module.ts
731
1370
  var ESCAPED_SPECIFIER = /(?:\bfrom|\bimport)[\s(]*(?:'[^'\\\n]*\\|"[^"\\\n]*\\|`[^`\\\n]*\\)/;
732
1371
  function isMentioningAtoms(code) {
733
- return code.includes(CX_SOURCE) || code.includes("nave-") || code.includes("$setup") || code.includes("vue&type=") || ESCAPED_SPECIFIER.test(code);
1372
+ if (code.includes(CX_SOURCE) || ESCAPED_SPECIFIER.test(code)) return true;
1373
+ if (isSerialisedStylesheet(code)) return false;
1374
+ return ["nave-", "&#", "$setup", "vue&type="].some((mention) => code.includes(mention));
734
1375
  }
735
1376
  var NO_PLACE = { line: 0, column: 0 };
736
1377
  function isInlineScript(id) {
@@ -740,7 +1381,7 @@ function lineUnknownNote(context, id) {
740
1381
  const isBuildWithoutMaps = context.command === "build" && !context.buildSourcemap;
741
1382
  return isBuildWithoutMaps && !isInlineScript(id) ? LINE_UNKNOWN_WITHOUT_MAP : LINE_UNKNOWN_UNMAPPED;
742
1383
  }
743
- function locate(problems, placing) {
1384
+ function locate2(problems, placing) {
744
1385
  return problems.map((problem) => {
745
1386
  const place = placing.place(problem.offset);
746
1387
  const where = place ?? { ...NO_PLACE, unknownLine: placing.unknownLine };
@@ -793,8 +1434,8 @@ async function recordOf(context, ctx, input, reading) {
793
1434
  const isStandingIn = isListed(context, pkg);
794
1435
  return {
795
1436
  atoms: /* @__PURE__ */ new Set([...reading.atoms, ...reading.classes]),
796
- problems: isStandingIn ? [] : locate(reading.problems, placing),
797
- suppressed: isStandingIn ? locate(reading.problems, placing) : [],
1437
+ problems: isStandingIn ? [] : locate2(reading.problems, placing),
1438
+ suppressed: isStandingIn ? locate2(reading.problems, placing) : [],
798
1439
  dynamicCalls: locateDynamic(reading, placing),
799
1440
  pkg,
800
1441
  file: placing.file,
@@ -849,11 +1490,11 @@ async function recordModule(context, ctx, module) {
849
1490
  }
850
1491
  const isDependency = isDependencyId(id);
851
1492
  const pkg = isDependency ? await packageNameOf(filePathOf(id), context.packageNames) : void 0;
852
- if (moduleType !== void 0 && !SOURCE_TYPES.has(moduleType)) {
1493
+ const unparsed = recordWithoutCalls(context, ctx, { code, id, moduleType, pkg });
1494
+ if (unparsed) {
853
1495
  context.state.exposures.delete(key);
854
- const record2 = textRecord(context, { code, id, moduleType, pkg });
855
- context.state.modules.set(key, record2);
856
- return record2;
1496
+ context.state.modules.set(key, unparsed);
1497
+ return unparsed;
857
1498
  }
858
1499
  const program = parseOrUndefined(ctx, code, moduleType);
859
1500
  const record = program ? await recordParsed(context, ctx, { code, id, pkg, program, declared }, key) : unreadableRecord(context, { code, id, pkg }, NOT_PARSED);
@@ -1022,7 +1663,7 @@ async function specifiersInto(ctx, context, input) {
1022
1663
  return found.values().toArray().toSorted(compareText);
1023
1664
  }
1024
1665
  async function clearingSpecifier(ctx, context, input) {
1025
- const from = path2.join(context.root, "index.html");
1666
+ const from = path.join(context.root, "index.html");
1026
1667
  const file = fileOf(input.id);
1027
1668
  if (await isResolvingTo(ctx, { file, from, specifier: input.pkg })) return input.pkg;
1028
1669
  const specifiers = await specifiersInto(ctx, context, input);
@@ -1079,9 +1720,9 @@ function entryOf(declared, id) {
1079
1720
  }
1080
1721
  async function replacementFor(ctx, input) {
1081
1722
  const file = fileOf(input.id);
1082
- const extension = path2.posix.extname(file);
1723
+ const extension = path.posix.extname(file);
1083
1724
  const relativeTo = (target) => {
1084
- const relative = path2.posix.relative(path2.posix.dirname(fileOf(input.importer)), target);
1725
+ const relative = path.posix.relative(path.posix.dirname(fileOf(input.importer)), target);
1085
1726
  return relative.startsWith("../") ? relative : `./${relative}`;
1086
1727
  };
1087
1728
  if (!RESOLVED_EXTENSIONS.has(extension)) return relativeTo(file);
@@ -1248,6 +1889,9 @@ async function transformQuietly(environment, url) {
1248
1889
  } catch {
1249
1890
  }
1250
1891
  }
1892
+ function isEndOfRead(module) {
1893
+ return module.id !== null && isCssModuleId(module.id);
1894
+ }
1251
1895
  async function transformReachable(environment, roots) {
1252
1896
  const seen = new Set(roots);
1253
1897
  let level = [...roots];
@@ -1255,8 +1899,9 @@ async function transformReachable(environment, roots) {
1255
1899
  const next = [];
1256
1900
  await Promise.all(
1257
1901
  level.map(async (module) => {
1258
- if (module.id !== null && isStylesheetId(module.id)) return;
1902
+ if (module.id !== null && isUnreadStylesheet(module.id)) return;
1259
1903
  await transformQuietly(environment, module.url);
1904
+ if (isEndOfRead(module)) return;
1260
1905
  for (const imported of module.importedModules) {
1261
1906
  if (seen.has(imported)) continue;
1262
1907
  seen.add(imported);
@@ -1283,6 +1928,7 @@ async function readAhead(context, environment, scripts) {
1283
1928
  const known = new Set(module.importedModules);
1284
1929
  environment.moduleGraph.invalidateModule(module);
1285
1930
  await transformQuietly(reader, module.url);
1931
+ if (isEndOfRead(module)) continue;
1286
1932
  const added = [...module.importedModules.difference(known)];
1287
1933
  await transformReachable(reader, added);
1288
1934
  }
@@ -1308,313 +1954,13 @@ function takeStaleModules(context, environment) {
1308
1954
  async function modulesWithGrownStylesheets(context, ctx, hot) {
1309
1955
  const { environment } = ctx;
1310
1956
  if (environment.config?.consumer !== "client" || context.state.served.size === 0) return;
1311
- const scripts = (hot.modules ?? []).filter((m) => m.id !== null && !isStylesheetId(m.id));
1957
+ const scripts = (hot.modules ?? []).filter((m) => m.id !== null && !isUnreadStylesheet(m.id));
1312
1958
  if (scripts.length === 0) return;
1313
1959
  await readAhead(context, environment, scripts);
1314
1960
  const sheets = takeStaleModules(context, environment);
1315
1961
  return sheets.length === 0 ? void 0 : [...hot.modules ?? [], ...sheets];
1316
1962
  }
1317
1963
 
1318
- // src/vite-css-blocks.ts
1319
- function matchBraces(tokens) {
1320
- const matches = /* @__PURE__ */ new Map();
1321
- const open = [];
1322
- for (const [index, token] of tokens.entries()) {
1323
- if (token.type === "{-token") open.push(index);
1324
- else if (token.type === "}-token" && open.length > 0) matches.set(open.pop(), index);
1325
- }
1326
- return matches;
1327
- }
1328
- function isBlank(tokens, from, to) {
1329
- for (let index = from; index < to; index += 1) {
1330
- const type = tokens[index].type;
1331
- if (type !== "whitespace-token" && type !== "comment") return false;
1332
- }
1333
- return true;
1334
- }
1335
- var OPENERS = /* @__PURE__ */ new Set(["(-token", "[-token", "function-token"]);
1336
- var CLOSERS = /* @__PURE__ */ new Set([")-token", "]-token"]);
1337
- function readSheet(css) {
1338
- const tokens = tokenize(css);
1339
- const matches = matchBraces(tokens);
1340
- return {
1341
- tokens,
1342
- slice: (from, to) => css.slice(tokens[from]?.startIndex ?? css.length, tokens[to - 1]?.endIndex ?? 0),
1343
- statements(from, to) {
1344
- const found = [];
1345
- let start = from;
1346
- let index = from;
1347
- let depth = 0;
1348
- while (index < to) {
1349
- const type = tokens[index].type;
1350
- if (OPENERS.has(type)) depth += 1;
1351
- else if (CLOSERS.has(type)) depth = Math.max(0, depth - 1);
1352
- const close = type === "{-token" && depth === 0 ? matches.get(index) : void 0;
1353
- if (close !== void 0 && close < to) {
1354
- found.push({ from: start, to: close + 1, open: index, close });
1355
- index = close + 1;
1356
- start = index;
1357
- } else if (type === "semicolon-token") {
1358
- found.push({ from: start, to: index + 1 });
1359
- index += 1;
1360
- start = index;
1361
- } else {
1362
- index += 1;
1363
- }
1364
- }
1365
- if (!isBlank(tokens, start, to)) found.push({ from: start, to });
1366
- return found;
1367
- }
1368
- };
1369
- }
1370
- function firstSignificant(tokens, from, to) {
1371
- let index = from;
1372
- while (index < to && isBlank(tokens, index, index + 1)) index += 1;
1373
- return index;
1374
- }
1375
-
1376
- // src/vite-selector-atoms.ts
1377
- var OPENERS2 = /* @__PURE__ */ new Set(["(-token", "[-token", "function-token"]);
1378
- var CLOSERS2 = /* @__PURE__ */ new Set([")-token", "]-token"]);
1379
- function membersOf(sheet, from, to) {
1380
- const members = [];
1381
- let start = from;
1382
- let depth = 0;
1383
- for (let index = from; index < to; index += 1) {
1384
- const type = sheet.tokens[index].type;
1385
- if (OPENERS2.has(type)) depth += 1;
1386
- else if (CLOSERS2.has(type)) depth -= 1;
1387
- else if (type === "comma-token" && depth === 0) {
1388
- members.push([start, index]);
1389
- start = index + 1;
1390
- }
1391
- }
1392
- members.push([start, to]);
1393
- return members;
1394
- }
1395
- var closings = /* @__PURE__ */ new WeakMap();
1396
- function closesOf(sheet) {
1397
- const known = closings.get(sheet);
1398
- if (known) return known;
1399
- const closes = /* @__PURE__ */ new Map();
1400
- const open = [];
1401
- for (const [index, token] of sheet.tokens.entries()) {
1402
- if (OPENERS2.has(token.type)) open.push(index);
1403
- else if (CLOSERS2.has(token.type) && open.length > 0) closes.set(open.pop(), index);
1404
- }
1405
- closings.set(sheet, closes);
1406
- return closes;
1407
- }
1408
- function afterGroup(sheet, index, to) {
1409
- return Math.min((closesOf(sheet).get(index) ?? to - 1) + 1, to);
1410
- }
1411
- function isTransparentList(sheet, index) {
1412
- const token = sheet.tokens[index];
1413
- if (token.type !== "function-token" || sheet.tokens[index - 1]?.type !== "colon-token") {
1414
- return false;
1415
- }
1416
- const name = token.structured.value.toLowerCase();
1417
- return name === "is" || name === "where";
1418
- }
1419
- function atomAt(sheet, index, to) {
1420
- const name = sheet.tokens[index + 1];
1421
- if (index + 1 >= to || name?.type !== "ident-token") return void 0;
1422
- const dot = sheet.tokens[index];
1423
- if (dot.type !== "delim-token" || dot.raw !== ".") return void 0;
1424
- return atomOfClass(name.structured.value);
1425
- }
1426
- function atomsNamedBy(sheet, from, to) {
1427
- const atoms = [];
1428
- let index = from;
1429
- while (index < to) {
1430
- const isGroup = OPENERS2.has(sheet.tokens[index].type);
1431
- if (isGroup && !isTransparentList(sheet, index)) {
1432
- index = afterGroup(sheet, index, to);
1433
- continue;
1434
- }
1435
- const atom = isGroup ? void 0 : atomAt(sheet, index, to);
1436
- if (atom) atoms.push(atom);
1437
- index += 1;
1438
- }
1439
- return atoms;
1440
- }
1441
- var newNeeds = () => ({ parts: [], size: 0 });
1442
- var newList = () => ({ finished: [], current: newNeeds() });
1443
- function closeList(done, parent) {
1444
- const all = [...done.finished, done.current];
1445
- if (all.some((needs) => needs.size === 0)) return;
1446
- for (const needs of all) {
1447
- parent.current.parts.push(needs.parts);
1448
- parent.current.size += needs.size;
1449
- }
1450
- }
1451
- function flatten(parts) {
1452
- const atoms = [];
1453
- const stack = [parts];
1454
- while (stack.length > 0) {
1455
- const part = stack.pop();
1456
- if (typeof part === "string") atoms.push(part);
1457
- else for (let index = part.length - 1; index >= 0; index -= 1) stack.push(part[index]);
1458
- }
1459
- return atoms;
1460
- }
1461
- function readToken(sheet, index, limit, lists) {
1462
- const type = sheet.tokens[index].type;
1463
- const list = lists.at(-1);
1464
- const isNested = lists.length > 1;
1465
- if (OPENERS2.has(type)) {
1466
- if (!isTransparentList(sheet, index)) return afterGroup(sheet, index, limit.to);
1467
- lists.push(newList());
1468
- } else if (isNested && type === ")-token") {
1469
- closeList(lists.pop(), lists.at(-1));
1470
- } else if (isNested && type === "comma-token") {
1471
- list.finished.push(list.current);
1472
- list.current = newNeeds();
1473
- } else {
1474
- const atom = atomAt(sheet, index, limit.to);
1475
- if (atom && !limit.emitted.has(atom)) {
1476
- list.current.parts.push(atom);
1477
- list.current.size += 1;
1478
- }
1479
- }
1480
- return index + 1;
1481
- }
1482
- function blockersOf(sheet, from, to, emitted) {
1483
- const lists = [newList()];
1484
- let index = from;
1485
- while (index < to) index = readToken(sheet, index, { emitted, to }, lists);
1486
- while (lists.length > 1) closeList(lists.pop(), lists.at(-1));
1487
- return flatten(lists[0].current.parts);
1488
- }
1489
-
1490
- // src/vite-prune.ts
1491
- var GROUPS = /* @__PURE__ */ new Set([
1492
- "container",
1493
- "document",
1494
- "layer",
1495
- "media",
1496
- "scope",
1497
- "starting-style",
1498
- "supports"
1499
- ]);
1500
- function atKeywordAt(sheet, index) {
1501
- const token = sheet.tokens[index];
1502
- if (token?.type !== "at-keyword-token") return void 0;
1503
- return token.structured.value.toLowerCase();
1504
- }
1505
- function isAtomicLayer(sheet, statement) {
1506
- if (statement.open === void 0) return false;
1507
- const significant = [];
1508
- for (let index = statement.from; index < statement.open; index += 1) {
1509
- const type = sheet.tokens[index].type;
1510
- if (type !== "whitespace-token" && type !== "comment") significant.push(index);
1511
- }
1512
- const name = sheet.tokens[significant[1] ?? -1];
1513
- return significant.length === 2 && atKeywordAt(sheet, significant[0]) === "layer" && name?.type === "ident-token" && name.structured.value === "atomic";
1514
- }
1515
- var CONDITIONALS = /* @__PURE__ */ new Set(["container", "document", "media", "scope", "supports"]);
1516
- function layerBlocks(sheet, from, to) {
1517
- const found = [];
1518
- for (const statement of sheet.statements(from, to)) {
1519
- const { open, close } = statement;
1520
- if (open === void 0 || close === void 0) continue;
1521
- if (isAtomicLayer(sheet, statement)) found.push(statement);
1522
- else {
1523
- const keyword = atKeywordAt(sheet, firstSignificant(sheet.tokens, statement.from, open));
1524
- if (keyword !== void 0 && CONDITIONALS.has(keyword)) {
1525
- found.push(...layerBlocks(sheet, open + 1, close));
1526
- }
1527
- }
1528
- }
1529
- return found;
1530
- }
1531
- function isEmptyRegion(sheet, from, to) {
1532
- return sheet.statements(from, to).length === 0;
1533
- }
1534
- function pruneRule(sheet, statement, emitted) {
1535
- const { from, open, close } = statement;
1536
- const first = firstSignificant(sheet.tokens, from, open);
1537
- const members = membersOf(sheet, first, open);
1538
- const kept = members.filter(([start, end]) => blockersOf(sheet, start, end, emitted).length === 0);
1539
- if (kept.length === members.length) return sheet.slice(from, close + 1);
1540
- if (kept.length === 0) return "";
1541
- let trailing = open;
1542
- while (trailing > first && firstSignificant(sheet.tokens, trailing - 1, trailing) === trailing) {
1543
- trailing -= 1;
1544
- }
1545
- const list = sheet.slice(first, trailing);
1546
- const separator = /,\s/.test(list) ? ", " : ",";
1547
- const text = kept.map(([start, end]) => sheet.slice(start, end).trim()).join(separator);
1548
- return `${sheet.slice(from, first)}${text}${sheet.slice(trailing, open)}${sheet.slice(open, close + 1)}`;
1549
- }
1550
- function pruneRegion(sheet, from, to, emitted) {
1551
- const statements = sheet.statements(from, to);
1552
- let out = "";
1553
- for (const statement of statements) out += pruneStatement(sheet, statement, emitted);
1554
- const last = statements.at(-1);
1555
- return last ? out + sheet.slice(last.to, to) : sheet.slice(from, to);
1556
- }
1557
- function pruneStatement(sheet, statement, emitted) {
1558
- const { open, close } = statement;
1559
- if (open === void 0 || close === void 0) return sheet.slice(statement.from, statement.to);
1560
- const first = firstSignificant(sheet.tokens, statement.from, open);
1561
- const keyword = atKeywordAt(sheet, first);
1562
- if (keyword === void 0) return pruneRule(sheet, statement, emitted);
1563
- if (!GROUPS.has(keyword)) return sheet.slice(statement.from, close + 1);
1564
- if (isEmptyRegion(sheet, open + 1, close)) return sheet.slice(statement.from, close + 1);
1565
- const inner = pruneRegion(sheet, open + 1, close, emitted);
1566
- if (inner.trim() === "") return "";
1567
- return `${sheet.slice(statement.from, open + 1)}${inner}}`;
1568
- }
1569
- function pruneAtomicLayer(css, emitted) {
1570
- if (!css.includes("@")) return css;
1571
- const sheet = readSheet(css);
1572
- let out = "";
1573
- let cursor = 0;
1574
- for (const statement of layerBlocks(sheet, 0, sheet.tokens.length)) {
1575
- const { open, close } = statement;
1576
- out += sheet.slice(cursor, open + 1) + pruneRegion(sheet, open + 1, close, emitted);
1577
- cursor = close;
1578
- }
1579
- return cursor === 0 ? css : out + sheet.slice(cursor, sheet.tokens.length);
1580
- }
1581
- function visitMembers(sheet, from, to, visit) {
1582
- for (const statement of sheet.statements(from, to)) {
1583
- const { open, close } = statement;
1584
- if (open === void 0 || close === void 0) continue;
1585
- const first = firstSignificant(sheet.tokens, statement.from, open);
1586
- const keyword = atKeywordAt(sheet, first);
1587
- if (keyword === void 0) {
1588
- for (const [start, end] of membersOf(sheet, first, open)) visit(start, end);
1589
- } else if (GROUPS.has(keyword)) {
1590
- visitMembers(sheet, open + 1, close, visit);
1591
- }
1592
- }
1593
- }
1594
- function inspectAtomicLayer(css) {
1595
- const atoms = /* @__PURE__ */ new Set();
1596
- if (!css.includes("@")) return { hasLayer: false, atoms };
1597
- const sheet = readSheet(css);
1598
- const blocks = layerBlocks(sheet, 0, sheet.tokens.length);
1599
- for (const { open, close } of blocks) {
1600
- visitMembers(sheet, open + 1, close, (start, end) => {
1601
- for (const atom of atomsNamedBy(sheet, start, end)) atoms.add(atom);
1602
- });
1603
- }
1604
- return { hasLayer: blocks.length > 0, atoms };
1605
- }
1606
- function unprunedAtoms(css, emitted) {
1607
- if (!css.includes("@")) return [];
1608
- const atoms = /* @__PURE__ */ new Set();
1609
- const sheet = readSheet(css);
1610
- for (const { open, close } of layerBlocks(sheet, 0, sheet.tokens.length)) {
1611
- visitMembers(sheet, open + 1, close, (start, end) => {
1612
- for (const atom of blockersOf(sheet, start, end, emitted)) atoms.add(atom);
1613
- });
1614
- }
1615
- return [...atoms].toSorted((a, b) => a.localeCompare(b));
1616
- }
1617
-
1618
1964
  // src/vite-dev.ts
1619
1965
  var RELOAD_ANSWER_MS = 2e3;
1620
1966
  var NO_MAP = JSON.stringify({ mappings: "" });
@@ -1683,174 +2029,37 @@ var devServing = {
1683
2029
  noteConnect(context) {
1684
2030
  const { state } = context;
1685
2031
  state.listening += 1;
1686
- if (state.unheard.size === 0) return;
1687
- const ids = [...state.unheard];
1688
- state.unheard.clear();
1689
- for (const id of ids) state.reloading.delete(id);
1690
- reloadOutgrown(context, ids);
1691
- },
1692
- noteDisconnect(context) {
1693
- const { state } = context;
1694
- state.listening = Math.max(0, state.listening - 1);
1695
- },
1696
- noteGrowth(context) {
1697
- if (context.state.served.size === 0) return;
1698
- reloadOutgrown(context, context.state.served.keys());
1699
- }
1700
- };
1701
- async function serveStylesheet(context, ctx, stylesheet) {
1702
- const { css, id } = stylesheet;
1703
- const { environment } = ctx;
1704
- if (!environment || !isServedAsStylesheet(id)) return void 0;
1705
- const isPossible = css.includes("\\") || /layer/i.test(css);
1706
- if (!isPossible || !inspectAtomicLayer(css).hasLayer) return void 0;
1707
- const dev = environment;
1708
- if (environment.config.consumer === "client") await devServing.hold(dev, id);
1709
- judgeWhenServed(context, id);
1710
- if (environment.config.consumer !== "client") return void 0;
1711
- const atoms = servedAtoms(context.state, context.kept);
1712
- context.state.served.set(id, { environment: dev, atoms });
1713
- context.state.reloading.delete(id);
1714
- return { code: pruneAtomicLayer(css, atoms), map: NO_MAP };
1715
- }
1716
- var HANDSHAKE_FILE = "nave-used-atoms.json";
1717
- function handshakePath(cacheDir) {
1718
- return path2.join(cacheDir, HANDSHAKE_FILE);
1719
- }
1720
- function readHandshake(cacheDir) {
1721
- if (cacheDir === "") return void 0;
1722
- try {
1723
- const parsed2 = JSON.parse(readFileSync(handshakePath(cacheDir), "utf8"));
1724
- return Array.isArray(parsed2.emitted) && typeof parsed2.writer === "string" ? parsed2 : void 0;
1725
- } catch {
1726
- return void 0;
1727
- }
1728
- }
1729
- function writeHandshake(cacheDir, fields, warn) {
1730
- if (cacheDir === "") return;
1731
- const handshake = {
1732
- ...fields,
1733
- emitted: [...fields.emitted].toSorted(compareText),
1734
- writtenAt: fields.writtenAt ?? (/* @__PURE__ */ new Date()).toISOString(),
1735
- build: fields.build ?? randomUUID()
1736
- };
1737
- try {
1738
- mkdirSync(cacheDir, { recursive: true });
1739
- writeFileSync(handshakePath(cacheDir), `${JSON.stringify(handshake, void 0, 2)}
1740
- `);
1741
- } catch (error) {
1742
- const reason = error instanceof Error ? error.message : String(error);
1743
- warn?.(
1744
- `navePlugin(): could not write ${handshakePath(cacheDir)} (${reason}), so a build of the client and a build of the server run as two processes cannot share their atoms.`
1745
- );
1746
- }
1747
- }
1748
-
1749
- // src/vite-emitted.ts
1750
- function positionText(place) {
1751
- return place.line === 0 ? place.file : `${place.file}:${place.line}:${place.column}`;
1752
- }
1753
- function packageRecords(context) {
1754
- const records = {};
1755
- for (const pkg of Object.keys(context.options.keepFor)) {
1756
- const modules = context.state.modules.values().filter((record) => record.pkg === pkg).toArray();
1757
- const places = modules.flatMap((record) => [...record.suppressed, ...record.dynamicCalls]);
1758
- records[pkg] = {
1759
- collected: [...new Set(modules.flatMap((record) => [...record.atoms]))].toSorted(compareText),
1760
- unreadable: places.map((place) => positionText(place))
1761
- };
1762
- }
1763
- return records;
1764
- }
1765
- function unmatchedKeys(context) {
1766
- const transformed = new Set(context.state.modules.values().map((record) => record.pkg));
1767
- return Object.keys(context.options.keepFor).filter((pkg) => !transformed.has(pkg));
1768
- }
1769
- function takenFromCache(context) {
1770
- const file = context.inProcess ? void 0 : readHandshake(context.cacheDir);
1771
- if (file === void 0) return { atoms: [], took: false };
1772
- if (file.writer !== "client") return { atoms: file.emitted, took: true };
1773
- const pending = file.pending ?? [];
1774
- return { atoms: pending, took: pending.length > 0 };
1775
- }
1776
- function emittedSet(context, environment, warn) {
1777
- const { state } = context;
1778
- if (state.emitted) return state.emitted;
1779
- const atoms = collectedAtoms(state, context.kept);
1780
- if (environment.config.consumer !== "client") return atoms;
1781
- const taken = takenFromCache(context);
1782
- for (const atom of taken.atoms) atoms.add(atom);
1783
- withRestorers(atoms);
1784
- state.emitted = atoms;
1785
- writeHandshake(
1786
- context.cacheDir,
1787
- {
1788
- emitted: [...atoms],
1789
- writer: "client",
1790
- consumed: taken.took,
1791
- keepFor: packageRecords(context),
1792
- unmatchedKeepFor: unmatchedKeys(context)
1793
- },
1794
- warn
1795
- );
1796
- return atoms;
1797
- }
1798
- function namingLines(ctx, context, atoms) {
1799
- return recordsOf(context.state, ctx.environment.name).flatMap(
1800
- (record) => atoms.filter((atom) => record.atoms.has(atom)).map((atom) => `${record.file}: names ${atom}.`)
1801
- );
1802
- }
1803
- function missingFromClient(ctx, context, missing) {
1804
- return [
1805
- "The client build already wrote its CSS without atoms this server build names, so their rules are missing from it:",
1806
- ...namingLines(ctx, context, missing),
1807
- `They are recorded in ${handshakePath(context.cacheDir)} for the next client build. List the atoms in keep in navePlugin(), or build the client again, then the server (vite build, then vite build --ssr). To keep this from recurring, build the server first, then the client (vite build --ssr, then vite build).`
1808
- ].join("\n");
1809
- }
1810
- function notInLastClient(ctx, context, missing) {
1811
- return [
1812
- `${handshakePath(context.cacheDir)} was written by a client build that was already used, so this server build could not be checked against the CSS. These atoms it names are not in that client build's set:`,
1813
- ...namingLines(ctx, context, missing),
1814
- "They are recorded in that file for a client build that runs next; to have them in the CSS, build the server first, then the client (vite build --ssr, then vite build)."
1815
- ].join("\n");
1816
- }
1817
- function recordForNextClient(ctx, context, atoms, held) {
1818
- writeHandshake(
1819
- context.cacheDir,
1820
- { emitted: [...withRestorers(new Set(atoms))], writer: ctx.environment.name, consumed: false },
1821
- (message) => ctx.warn(message)
1822
- );
1823
- const missing = [...atoms].filter((atom) => !held.includes(atom)).toSorted(compareText);
1824
- if (missing.length > 0) ctx.warn(notInLastClient(ctx, context, missing));
1825
- }
1826
- function checkWaitingClient(ctx, context, atoms, file) {
1827
- const missing = [...atoms].filter((atom) => !file.emitted.includes(atom)).toSorted(compareText);
1828
- if (missing.length === 0) {
1829
- writeHandshake(context.cacheDir, { ...file, consumed: true, pending: [] }, (message) => {
1830
- ctx.warn(message);
1831
- });
1832
- return;
1833
- }
1834
- const pending = [.../* @__PURE__ */ new Set([...file.pending ?? [], ...withRestorers(new Set(atoms))])];
1835
- writeHandshake(context.cacheDir, { ...file, pending }, (message) => ctx.warn(message));
1836
- ctx.error(missingFromClient(ctx, context, missing));
1837
- }
1838
- function checkServerInvocation(ctx, context) {
1839
- if (context.cacheDir === "" || context.inProcess || context.state.emitted) return;
1840
- const atoms = new Set(recordsOf(context.state, ctx.environment.name).flatMap((r) => [...r.atoms]));
1841
- const file = readHandshake(context.cacheDir);
1842
- if (file?.writer !== "client") {
1843
- const emitted = [...withRestorers(/* @__PURE__ */ new Set([...atoms, ...file?.emitted ?? []]))];
1844
- writeHandshake(
1845
- context.cacheDir,
1846
- { emitted, writer: ctx.environment.name, consumed: false },
1847
- (message) => ctx.warn(message)
1848
- );
1849
- } else if (file.consumed) {
1850
- recordForNextClient(ctx, context, atoms, file.emitted);
1851
- } else {
1852
- checkWaitingClient(ctx, context, atoms, file);
2032
+ if (state.unheard.size === 0) return;
2033
+ const ids = [...state.unheard];
2034
+ state.unheard.clear();
2035
+ for (const id of ids) state.reloading.delete(id);
2036
+ reloadOutgrown(context, ids);
2037
+ },
2038
+ noteDisconnect(context) {
2039
+ const { state } = context;
2040
+ state.listening = Math.max(0, state.listening - 1);
2041
+ },
2042
+ noteGrowth(context) {
2043
+ if (context.state.served.size === 0) return;
2044
+ reloadOutgrown(context, context.state.served.keys());
2045
+ }
2046
+ };
2047
+ async function serveStylesheet(context, ctx, stylesheet) {
2048
+ const { css, id } = stylesheet;
2049
+ const { environment } = ctx;
2050
+ if (!environment || !isServedAsStylesheet(id)) return void 0;
2051
+ const isPossible = css.includes("\\") || /layer/i.test(css);
2052
+ if (!isPossible || !inspectAtomicLayer(css).hasLayer) return void 0;
2053
+ const dev = environment;
2054
+ if (environment.config.consumer === "client" && !isCssModuleId(id)) {
2055
+ await devServing.hold(dev, id);
1853
2056
  }
2057
+ judgeWhenServed(context, id);
2058
+ if (environment.config.consumer !== "client") return void 0;
2059
+ const atoms = servedAtoms(context.state, context.kept);
2060
+ context.state.served.set(id, { environment: dev, atoms });
2061
+ context.state.reloading.delete(id);
2062
+ return { code: pruneAtomicLayer(css, atoms), map: NO_MAP };
1854
2063
  }
1855
2064
 
1856
2065
  // src/vite-cx-reexported.ts
@@ -2429,33 +2638,78 @@ function decideReexports(prepared, serverImports) {
2429
2638
  }
2430
2639
 
2431
2640
  // src/vite-order.ts
2641
+ var MISSING = "which the CSS already written does not hold.";
2642
+ function packageOfPath(file) {
2643
+ const marker = "node_modules/";
2644
+ const at = file.lastIndexOf(marker);
2645
+ if (at === -1) return void 0;
2646
+ const parts = file.slice(at + marker.length).split("/");
2647
+ return parts[0]?.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
2648
+ }
2649
+ function missLines(record, emitted) {
2650
+ return [...record.atoms].toSorted(compareText).filter((atom) => !emitted.has(atom)).map((atom) => `${record.file}: names ${atom}, ${MISSING}`);
2651
+ }
2652
+ function clientFirstMessage(lines) {
2653
+ return [
2654
+ "The build read atoms after it wrote the CSS, so their rules are missing from it:",
2655
+ ...lines,
2656
+ "List the atoms in keep in navePlugin(), or build the server environments first with builder.buildApp in your Vite config."
2657
+ ].join("\n");
2658
+ }
2659
+ function serverFirstMessage(records, emitted) {
2660
+ const missing = records.filter((record) => missLines(record, emitted).length > 0);
2661
+ const packages = [
2662
+ ...new Set(
2663
+ missing.map((record) => packageOfPath(record.file)).filter((name) => name !== void 0)
2664
+ )
2665
+ ].toSorted(compareText);
2666
+ return [
2667
+ "The build read atoms after it wrote the CSS, so their rules are missing from it:",
2668
+ ...missing.flatMap((record) => missLines(record, emitted)).toSorted(compareText),
2669
+ "A server build wrote the CSS, and only a build after it read these modules, such as code only the browser runs (an Astro client:only component, or a <script> in an .astro file).",
2670
+ "List the atoms in keep in navePlugin(), or have the server render that code too (a hydrated island rather than client:only).",
2671
+ ...packages.map(
2672
+ (name) => `${name} is a dependency the server build left external: add it to resolve.noExternal in your Vite config (on Astro, under vite in astro.config) so the server build reads it.`
2673
+ )
2674
+ ].join("\n");
2675
+ }
2676
+ function readByWriters(state) {
2677
+ const read = /* @__PURE__ */ new Set();
2678
+ for (const key of state.modules.keys()) {
2679
+ const at = key.indexOf("\0");
2680
+ if (state.writers.has(key.slice(0, at))) read.add(key.slice(at + 1));
2681
+ }
2682
+ return read;
2683
+ }
2684
+ function lateRecords(ctx, state) {
2685
+ const read = readByWriters(state);
2686
+ const prefix = `${ctx.environment.name}\0`;
2687
+ return [...state.modules].filter(([key]) => key.startsWith(prefix) && !read.has(key.slice(prefix.length))).map(([, record]) => record);
2688
+ }
2432
2689
  function checkEnvironmentOrder(ctx, context) {
2433
- const { emitted } = context.state;
2690
+ const { state } = context;
2691
+ const { emitted } = state;
2434
2692
  if (emitted === void 0) return;
2435
- const lines = [];
2436
- for (const record of recordsOf(context.state, ctx.environment.name)) {
2437
- for (const atom of [...record.atoms].toSorted(compareText)) {
2438
- if (!emitted.has(atom)) {
2439
- lines.push(`${record.file}: names ${atom}, which the CSS already written does not hold.`);
2440
- }
2441
- }
2693
+ if (state.firstWriter === "server") {
2694
+ if (state.writers.has(ctx.environment.name) || hasStylesheet(state, ctx.environment.name))
2695
+ return;
2696
+ const late = lateRecords(ctx, state);
2697
+ if (late.some((record) => missLines(record, emitted).length > 0))
2698
+ ctx.error(serverFirstMessage(late, emitted));
2699
+ return;
2442
2700
  }
2443
- if (lines.length === 0) return;
2444
- ctx.error(
2445
- [
2446
- `The build read atoms after it wrote the CSS, so their rules are missing from it:`,
2447
- ...lines,
2448
- "List the atoms in keep in navePlugin(), or build the server environments first with builder.buildApp in your Vite config."
2449
- ].join("\n")
2701
+ const lines = recordsOf(state, ctx.environment.name).flatMap(
2702
+ (record) => missLines(record, emitted)
2450
2703
  );
2704
+ if (lines.length > 0) ctx.error(clientFirstMessage(lines));
2451
2705
  }
2452
2706
  var PACKAGE_NAME = /^(@[^/]+\/[^/]+|[^./@][^/]*)(\/.*)?$/;
2453
2707
  var EXTENSIONS = ["", ".js", ".mjs", ".cjs", "/index.js", "/index.mjs", "/index.cjs"];
2454
2708
  function packageDirectory(directory, name) {
2455
- for (let current = directory; ; current = path2.dirname(current)) {
2456
- const found = path2.join(current, "node_modules", name);
2457
- if (existsSync(path2.join(found, "package.json"))) return found;
2458
- if (path2.dirname(current) === current) return void 0;
2709
+ for (let current = directory; ; current = path.dirname(current)) {
2710
+ const found = path.join(current, "node_modules", name);
2711
+ if (existsSync(path.join(found, "package.json"))) return found;
2712
+ if (path.dirname(current) === current) return void 0;
2459
2713
  }
2460
2714
  }
2461
2715
  function targetFile(target, input) {
@@ -2486,7 +2740,7 @@ function existingFile(base) {
2486
2740
  }
2487
2741
  function manifestOf(directory) {
2488
2742
  try {
2489
- return JSON.parse(readFileSync(path2.join(directory, "package.json"), "utf8"));
2743
+ return JSON.parse(readFileSync(path.join(directory, "package.json"), "utf8"));
2490
2744
  } catch {
2491
2745
  return void 0;
2492
2746
  }
@@ -2501,12 +2755,12 @@ function relativeTarget(manifest, input) {
2501
2755
  }
2502
2756
  function serverFileOf(input) {
2503
2757
  const parts = PACKAGE_NAME.exec(input.specifier);
2504
- const directory = parts && packageDirectory(path2.dirname(input.from), parts[1]);
2758
+ const directory = parts && packageDirectory(path.dirname(input.from), parts[1]);
2505
2759
  const manifest = directory ? manifestOf(directory) : void 0;
2506
2760
  if (!parts || !directory || !manifest) return void 0;
2507
2761
  const subpath = parts[2] === void 0 ? "." : `.${parts[2]}`;
2508
2762
  const relative = relativeTarget(manifest, { conditions: new Set(input.conditions), subpath });
2509
- const file = relative === void 0 ? void 0 : existingFile(path2.join(directory, relative));
2763
+ const file = relative === void 0 ? void 0 : existingFile(path.join(directory, relative));
2510
2764
  return file === void 0 ? void 0 : realpathSync(file);
2511
2765
  }
2512
2766
  var PACKAGE_NAME2 = /^(@[^/]+\/[^/]+|[^./@][^/]*)/;
@@ -2515,21 +2769,24 @@ function packageOfSpecifier(specifier) {
2515
2769
  return PACKAGE_NAME2.exec(specifier)?.[1];
2516
2770
  }
2517
2771
  function isDeclaringCore(root, name) {
2518
- for (let directory = root; ; directory = path2.dirname(directory)) {
2772
+ for (let directory = root; ; directory = path.dirname(directory)) {
2519
2773
  try {
2520
2774
  const manifest = JSON.parse(
2521
- readFileSync(path2.join(directory, "node_modules", name, "package.json"), "utf8")
2775
+ readFileSync(path.join(directory, "node_modules", name, "package.json"), "utf8")
2522
2776
  );
2523
2777
  return ["dependencies", "peerDependencies", "optionalDependencies"].some(
2524
2778
  (field) => manifest[field]?.["@navecss/core"] !== void 0
2525
2779
  );
2526
2780
  } catch {
2527
- if (path2.dirname(directory) === directory) return false;
2781
+ if (path.dirname(directory) === directory) return false;
2528
2782
  }
2529
2783
  }
2530
2784
  }
2531
- function warningFor(name) {
2532
- return `${name} depends on @navecss/core, but no environment of this build transforms it, so the atoms its cx() calls name are not read. Add it to ssr.noExternal in your Vite config so the build reads it, or list the atoms its calls can produce under its name in keepFor in navePlugin().`;
2785
+ function noExternalKey(firstWriter) {
2786
+ return firstWriter === "server" ? "resolve.noExternal in your Vite config (on Astro, under vite in astro.config)" : "ssr.noExternal in your Vite config";
2787
+ }
2788
+ function warningFor(name, firstWriter) {
2789
+ return `${name} depends on @navecss/core, but no environment of this build transforms it, so the atoms its cx() calls name are not read. Add it to ${noExternalKey(firstWriter)} so the build reads it, or list the atoms its calls can produce under its name in keepFor in navePlugin().`;
2533
2790
  }
2534
2791
  function judgeExternals(ctx, context) {
2535
2792
  const { state } = context;
@@ -2537,7 +2794,7 @@ function judgeExternals(ctx, context) {
2537
2794
  if (state.packages.has(name) || state.warned.has(name)) continue;
2538
2795
  if (Object.hasOwn(context.options.keepFor, name)) continue;
2539
2796
  state.warned.add(name);
2540
- ctx.warn(warningFor(name));
2797
+ ctx.warn(warningFor(name, state.firstWriter));
2541
2798
  }
2542
2799
  state.externals.clear();
2543
2800
  }
@@ -2576,7 +2833,7 @@ function conditionsOf(ctx) {
2576
2833
  function importsOf(ctx, input) {
2577
2834
  const { externals, id, root } = input;
2578
2835
  const program = parsed(ctx, id);
2579
- const taker = path2.relative(root, filePathOf(id)).replaceAll("\\", "/");
2836
+ const taker = path.relative(root, filePathOf(id)).replaceAll("\\", "/");
2580
2837
  const conditions = conditionsOf(ctx);
2581
2838
  const named = program ? specifiersIn(program).filter((one) => externals.has(one)) : [];
2582
2839
  const info = ctx.getModuleInfo?.(id);
@@ -2613,7 +2870,7 @@ function serverImportsOf(ctx, context) {
2613
2870
  };
2614
2871
  const externals = new Set(ids.filter((id) => isListed2(id)));
2615
2872
  if (externals.size === 0) return [];
2616
- return ids.filter((id) => path2.isAbsolute(filePathOf(id)) && !isDependencyId(id) && !isNaveOwn(id)).flatMap((id) => importsOf(ctx, { externals, id, root: context.root }));
2873
+ return ids.filter((id) => path.isAbsolute(filePathOf(id)) && !isDependencyId(id) && !isNaveOwn(id)).flatMap((id) => importsOf(ctx, { externals, id, root: context.root }));
2617
2874
  }
2618
2875
  function buildKeyOf(ctx) {
2619
2876
  const build = ctx.environment.config.build;
@@ -2622,7 +2879,7 @@ function buildKeyOf(ctx) {
2622
2879
  function readEntries(context) {
2623
2880
  try {
2624
2881
  const parsedFile = JSON.parse(
2625
- readFileSync(path2.join(context.cacheDir, SERVER_TAKES_FILE), "utf8")
2882
+ readFileSync(path.join(context.cacheDir, SERVER_TAKES_FILE), "utf8")
2626
2883
  );
2627
2884
  const isEntries = typeof parsedFile === "object" && parsedFile !== null && !Array.isArray(parsedFile);
2628
2885
  return isEntries ? parsedFile : {};
@@ -2632,7 +2889,7 @@ function readEntries(context) {
2632
2889
  }
2633
2890
  function writeServerImports(ctx, context, imports) {
2634
2891
  if (context.cacheDir === "") return;
2635
- const file = path2.join(context.cacheDir, SERVER_TAKES_FILE);
2892
+ const file = path.join(context.cacheDir, SERVER_TAKES_FILE);
2636
2893
  try {
2637
2894
  mkdirSync(context.cacheDir, { recursive: true });
2638
2895
  const entries = { ...readEntries(context), [buildKeyOf(ctx)]: imports };
@@ -2647,7 +2904,7 @@ function writeServerImports(ctx, context, imports) {
2647
2904
  }
2648
2905
  function readServerImports(context) {
2649
2906
  if (context.cacheDir === "") return [];
2650
- return Object.values(readEntries(context)).flat().filter((found) => existsSync(path2.resolve(context.root, found.taker))).map((found) => ({ ...found, isRecorded: true }));
2907
+ return Object.values(readEntries(context)).flat().filter((found) => existsSync(path.resolve(context.root, found.taker))).map((found) => ({ ...found, isRecorded: true }));
2651
2908
  }
2652
2909
  function graphOf(ctx) {
2653
2910
  return new Set([...ctx.getModuleIds?.() ?? []].map((id) => fileOf(id)));
@@ -2673,18 +2930,19 @@ function recordedSentence(takers) {
2673
2930
  function recordedTakers(imports) {
2674
2931
  return imports.filter((found) => found.isRecorded === true).map((found) => found.taker);
2675
2932
  }
2676
- function warningFor2(pkg, input) {
2677
- const { found, root } = input;
2933
+ function warningFor2(pkg, found, context) {
2934
+ const { root } = context;
2935
+ const { firstWriter } = context.state;
2678
2936
  const listed = found.map((one) => {
2679
2937
  if (one.isUnreadable === true)
2680
2938
  return `${one.taker} loads '${one.specifier}' in a way the build cannot read as a take, such as a require() or a # import`;
2681
2939
  if (one.file === void 0)
2682
2940
  return `${one.taker} imports '${one.specifier}', and the build cannot tell which file the server loads for it`;
2683
- const file = path2.relative(root, one.file).replaceAll("\\", "/");
2941
+ const file = path.relative(root, one.file).replaceAll("\\", "/");
2684
2942
  return `${one.taker} imports '${one.specifier}', which the server loads as ${file}, a file no environment of this build transforms`;
2685
2943
  }).toSorted(compareText).join("; ");
2686
2944
  const note = recordedSentence(recordedTakers(found));
2687
- const warning = `${pkg}, which keepFor lists, is imported by your server code where the build cannot tell whether that code takes cx from it: ${listed}. Add ${pkg} to ssr.noExternal in your Vite config so the build reads the package and checks what your server code takes; where a file takes cx from it, import cx from @navecss/core/cx there instead.`;
2945
+ const warning = `${pkg}, which keepFor lists, is imported by your server code where the build cannot tell whether that code takes cx from it: ${listed}. Add ${pkg} to ${noExternalKey(firstWriter)} so the build reads the package and checks what your server code takes; where a file takes cx from it, import cx from @navecss/core/cx there instead.`;
2688
2946
  return note === void 0 ? warning : `${warning} ${note}`;
2689
2947
  }
2690
2948
  function warnUnknown(ctx, context, unknown) {
@@ -2696,14 +2954,14 @@ function warnUnknown(ctx, context, unknown) {
2696
2954
  }
2697
2955
  for (const [pkg, imports] of byPackage) {
2698
2956
  context.state.warned.add(pkg);
2699
- ctx.warn(warningFor2(pkg, { found: imports, root: context.root }));
2957
+ ctx.warn(warningFor2(pkg, imports, context));
2700
2958
  }
2701
2959
  }
2702
2960
 
2703
2961
  // src/vite-collect-plugin.ts
2704
2962
  var OPTIONS_HOME = "navePlugin()";
2705
2963
  function isReadable(context, id) {
2706
- return isUsed(context) && !isStylesheetId(id) && !isNaveOwn(id);
2964
+ return isUsed(context) && !isUnreadStylesheet(id) && !isNaveOwn(id);
2707
2965
  }
2708
2966
  async function problemsOfBuild(ctx, context, serverImports) {
2709
2967
  const records = recordsOf(context.state, ctx.environment.name);
@@ -2772,9 +3030,9 @@ function createCollectPlugin(context) {
2772
3030
  context.state.started = true;
2773
3031
  assertOptions(context.options, await ownAtomNames(context));
2774
3032
  forgetDeclared(context.state, this.environment.name);
2775
- if (this.environment.config.consumer !== "client") return;
2776
- context.state.emitted = void 0;
2777
- context.state.clientEnded = false;
3033
+ if (this.environment.config.consumer === "client") context.state.clientEnded = false;
3034
+ const isWriter = context.inProcess ? context.state.emittedBy === this.environment.name : this.environment.config.consumer === "client";
3035
+ if (isWriter) forgetWriters(context.state);
2778
3036
  },
2779
3037
  async transform(code, id, meta) {
2780
3038
  if (!isReadable(context, id)) return;
@@ -2794,6 +3052,12 @@ function createCollectPlugin(context) {
2794
3052
  if (context.command === "serve") devServing.notePages(context);
2795
3053
  }
2796
3054
  },
3055
+ generateBundle: {
3056
+ order: "pre",
3057
+ handler(options, bundle) {
3058
+ checkBundle(this, context, { bundle, options, pass: "pre" });
3059
+ }
3060
+ },
2797
3061
  async buildEnd(error) {
2798
3062
  if (error || !isUsed(context) || context.command !== "build") return;
2799
3063
  const graph = graphOf(this);
@@ -2855,142 +3119,6 @@ function usedEnvironmentConfig(context, name, options) {
2855
3119
  return { resolve: { noExternal: ["@navecss/core"] } };
2856
3120
  }
2857
3121
 
2858
- // src/vite-css-capture.ts
2859
- var originals = /* @__PURE__ */ new WeakMap();
2860
- function transformHandler(plugin) {
2861
- const { transform } = plugin;
2862
- if (typeof transform === "function") return transform;
2863
- const handler = transform?.handler;
2864
- return typeof handler === "function" ? handler : void 0;
2865
- }
2866
- function unwrapped(handler) {
2867
- let current = handler;
2868
- for (let next = originals.get(current); next; next = originals.get(current)) current = next;
2869
- return current;
2870
- }
2871
- function remember(context, environment, id, css) {
2872
- const key = moduleKey(environment, id);
2873
- const isPossible = css.includes("\\") || /layer/i.test(css);
2874
- if (isPossible && inspectAtomicLayer(css).hasLayer) context.state.sheets.set(key, css);
2875
- else context.state.sheets.delete(key);
2876
- }
2877
- function captureStylesheets(context, plugins) {
2878
- const plugin = plugins?.find((candidate) => candidate.name === "vite:css-post");
2879
- const original = plugin && transformHandler(plugin);
2880
- if (!plugin || !original) return;
2881
- const wrapped = function(css, id) {
2882
- const environment = this.environment?.name ?? "client";
2883
- remember(context, environment, id, css);
2884
- return original.call(this, css, id);
2885
- };
2886
- originals.set(wrapped, original);
2887
- const { transform } = plugin;
2888
- plugin.transform = typeof transform === "function" ? wrapped : { ...transform, handler: wrapped };
2889
- }
2890
- var decoder = new TextDecoder();
2891
- async function refeed(ctx, css, id) {
2892
- const plugin = ctx.environment.plugins.find((candidate) => candidate.name === "vite:css-post");
2893
- const handler = plugin && transformHandler(plugin);
2894
- if (!handler) {
2895
- ctx.error(
2896
- "nave: this version of Vite has no CSS step the plugin knows how to hand a stylesheet back to, so it cannot remove the unused atoms. Ship every atom with atomic: 'all' in navePlugin() until the plugin supports this version of Vite."
2897
- );
2898
- }
2899
- await unwrapped(handler).call(ctx, css, id);
2900
- }
2901
- var fedPages = /* @__PURE__ */ new WeakMap();
2902
- var warnedText = /* @__PURE__ */ new WeakMap();
2903
- function bookFor(book, emitted) {
2904
- const ids = book.get(emitted) ?? /* @__PURE__ */ new Set();
2905
- book.set(emitted, ids);
2906
- return ids;
2907
- }
2908
- function isPageStylesheet(id) {
2909
- return /[?&]html-proxy\b/.test(id);
2910
- }
2911
- function pageStylesheets(ctx, state, emitted) {
2912
- const prefix = `${ctx.environment.name}\0`;
2913
- const fed = bookFor(fedPages, emitted);
2914
- const ids = state.sheets.keys().filter((key) => key.startsWith(prefix) && isPageStylesheet(key)).map((key) => key.slice(prefix.length)).filter((id) => !fed.has(id)).toArray();
2915
- for (const id of ids) fed.add(id);
2916
- return ids;
2917
- }
2918
- function isInlineImport(id) {
2919
- return /[?&]inline\b/.test(id) && !isPageStylesheet(id);
2920
- }
2921
- function isRawImport(id) {
2922
- return /[?&]raw\b/.test(id) && isStylesheetPath(id);
2923
- }
2924
- function isLayerFile(id) {
2925
- try {
2926
- return inspectAtomicLayer(readFileSync(filePathOf(id), "utf8")).hasLayer;
2927
- } catch {
2928
- return false;
2929
- }
2930
- }
2931
- async function refeedChunkStylesheets(ctx, chunk, state, emitted) {
2932
- const prefix = `${ctx.environment.name}\0`;
2933
- for (const id of [...Object.keys(chunk.modules), ...pageStylesheets(ctx, state, emitted)]) {
2934
- const css = state.sheets.get(`${prefix}${id}`);
2935
- if (css === void 0 || isInlineImport(id)) continue;
2936
- await refeed(ctx, pruneAtomicLayer(css, emitted), id);
2937
- }
2938
- }
2939
- function warnTextImports(ctx, chunk, context, emitted) {
2940
- const prefix = `${ctx.environment.name}\0`;
2941
- const warned = bookFor(warnedText, emitted);
2942
- for (const id of Object.keys(chunk.modules)) {
2943
- if (warned.has(id)) continue;
2944
- const isInline = isInlineImport(id) && context.state.sheets.has(`${prefix}${id}`);
2945
- const isRaw = !isInline && isRawImport(id) && isLayerFile(id);
2946
- if (!isInline && !isRaw) continue;
2947
- warned.add(id);
2948
- const query = isInline ? "?inline" : "?raw";
2949
- ctx.warn(
2950
- `${moduleLabel(context.root, id)} is imported with ${query}, so its stylesheet is text in the JavaScript, which the plugin does not filter: every atom in its atomic layer ships, not only the atoms this build emits. Import it without ${query} to have the layer filtered.`
2951
- );
2952
- }
2953
- }
2954
- function textOf(entry) {
2955
- const { source } = entry;
2956
- if (source === void 0) return "";
2957
- return typeof source === "string" ? source : decoder.decode(source);
2958
- }
2959
- function mismatchLines(assets, emitted) {
2960
- const lines = [];
2961
- const seenAnywhere = /* @__PURE__ */ new Set();
2962
- let hasLayer = false;
2963
- for (const { fileName, css } of assets) {
2964
- const seen = inspectAtomicLayer(css);
2965
- if (!seen.hasLayer) continue;
2966
- hasLayer = true;
2967
- for (const atom of seen.atoms) seenAnywhere.add(atom);
2968
- const extra = unprunedAtoms(css, emitted);
2969
- if (extra.length > 0) {
2970
- lines.push(
2971
- `${fileName}: the atomic layer holds a rule for ${extra.join(", ")}, which the build did not emit.`
2972
- );
2973
- }
2974
- }
2975
- const missing = [...emitted.difference(seenAnywhere)];
2976
- if (hasLayer && missing.length > 0) {
2977
- lines.push(`the atomic layers hold no rule for ${missing.join(", ")}, which the build emitted.`);
2978
- }
2979
- return lines;
2980
- }
2981
- function checkAtomicLayers(ctx, bundle, emitted) {
2982
- const assets = Object.values(bundle).filter((entry) => entry.type === "asset" && entry.fileName.toLowerCase().endsWith(".css")).map((entry) => ({ fileName: entry.fileName, css: textOf(entry) }));
2983
- const lines = mismatchLines(assets, emitted);
2984
- if (lines.length === 0) return;
2985
- ctx.error({
2986
- message: [
2987
- "nave: the built CSS does not hold exactly the atoms the build emitted, so the plugin could not remove the unused ones on this version of Vite.",
2988
- ...lines,
2989
- "Ship every atom with atomic: 'all' in navePlugin() until the plugin supports this version of Vite."
2990
- ].join("\n")
2991
- });
2992
- }
2993
-
2994
3122
  // src/vite-extend.ts
2995
3123
  function snapshotAndValidate(value) {
2996
3124
  const snapshot = snapshotExtendMap(value);
@@ -3047,30 +3175,6 @@ function dropLightningNaveWarning(logger) {
3047
3175
  wrappers.set(logger, wrapper);
3048
3176
  }
3049
3177
 
3050
- // src/vite-scan.ts
3051
- var decoder2 = new TextDecoder();
3052
- function isCssAsset(entry) {
3053
- return entry.type === "asset" && entry.fileName.toLowerCase().endsWith(".css");
3054
- }
3055
- function textOf2(entry) {
3056
- const { source } = entry;
3057
- if (source === void 0) return "";
3058
- return typeof source === "string" ? source : decoder2.decode(source);
3059
- }
3060
- function messageFor(findings, assetCount) {
3061
- const noun = assetCount === 1 ? "asset" : "assets";
3062
- return [
3063
- "@nave survived into the built CSS:",
3064
- ...findings.map((finding) => formatFinding(finding)),
3065
- `Scanned ${assetCount} CSS ${noun} this build wrote.`
3066
- ].join("\n");
3067
- }
3068
- function scanBundle(ctx, bundle) {
3069
- const assets = Object.values(bundle).filter((entry) => isCssAsset(entry));
3070
- const findings = assets.flatMap((asset) => findingsInText(asset.fileName, textOf2(asset)));
3071
- if (findings.length > 0) ctx.error({ message: messageFor(findings, assets.length) });
3072
- }
3073
-
3074
3178
  // src/vite-server-hooks.ts
3075
3179
  function warnThrough(ctx) {
3076
3180
  return (message) => {
@@ -3113,64 +3217,6 @@ function serverHooks(context) {
3113
3217
  };
3114
3218
  }
3115
3219
 
3116
- // src/vite-report.ts
3117
- function withSourceRoot(source, sourceRoot) {
3118
- if (!sourceRoot || /^(?:[a-z][a-z\d+.-]*:|\/)/i.test(source)) return source;
3119
- return `${sourceRoot.replace(/\/$/, "")}/${source}`;
3120
- }
3121
- function locate2(diagnostic, input) {
3122
- const text = formatDiagnostic(diagnostic, { extend: input.extend });
3123
- const origin = input.incoming?.originalPositionFor({
3124
- line: diagnostic.line,
3125
- column: diagnostic.column - 1
3126
- });
3127
- if (origin === void 0) {
3128
- const position = { line: diagnostic.line, column: diagnostic.column };
3129
- return { text, file: input.file, isProcessed: true, ...position };
3130
- }
3131
- return {
3132
- text,
3133
- file: withSourceRoot(origin.source, input.incoming?.sourceRoot),
3134
- isProcessed: false,
3135
- line: origin.line,
3136
- column: origin.column + 1
3137
- };
3138
- }
3139
- function withNoMapNote(body, input, at) {
3140
- if (!at.isProcessed) return body;
3141
- const reason = input.incoming === void 0 ? "no source map" : "the source map does not cover it";
3142
- const note = `(position in ${input.file} as processed; ${reason})`;
3143
- const lines = body.split("\n");
3144
- const hasAvailable = lines.at(-1)?.startsWith("Available: ") === true;
3145
- lines.splice(hasAvailable ? -1 : lines.length, 0, note);
3146
- return lines.join("\n");
3147
- }
3148
- function logFor(message, input, at) {
3149
- return {
3150
- message,
3151
- id: input.id,
3152
- loc: { file: at.file, line: at.line, column: at.column - 1 }
3153
- };
3154
- }
3155
- function frame(at) {
3156
- return `${at.file}:${at.line}:${at.column}: `;
3157
- }
3158
- function reportDiagnostics(input) {
3159
- if (input.onUnknown === "ignore" || input.diagnostics.length === 0) return;
3160
- const inSourceOrder = input.diagnostics.toSorted((a, b) => a.offset - b.offset);
3161
- const located = inSourceOrder.map((diagnostic) => locate2(diagnostic, input));
3162
- if (input.onUnknown === "warn") {
3163
- for (const at of located) {
3164
- const message2 = withNoMapNote(`${frame(at)}${at.text}`, input, at);
3165
- input.ctx.warn(logFor(message2, input, at));
3166
- }
3167
- return;
3168
- }
3169
- const first = located[0];
3170
- const message = withNoMapNote(`${frame(first)}${foldLocated(located)}`, input, first);
3171
- input.ctx.error(logFor(message, input, first));
3172
- }
3173
-
3174
3220
  // src/vite-transform.ts
3175
3221
  function incomingMapOf(input) {
3176
3222
  if (!input.hasStylesheetMaps) return void 0;
@@ -3184,15 +3230,22 @@ function transformStylesheet(input) {
3184
3230
  extend: input.extend,
3185
3231
  onUnknown: input.onUnknown,
3186
3232
  from: file,
3187
- inputSourceMap
3233
+ inputSourceMap,
3234
+ reportStaleMarkers: input.reportStaleMarkers
3188
3235
  });
3236
+ const incoming = inputSourceMap && decodeIncomingMap(inputSourceMap);
3237
+ reportOrderWarnings(
3238
+ { ctx: input.ctx, id: input.id, file, incoming, warnings: result.warnings },
3239
+ input.warnings.memory,
3240
+ input.warnings.command
3241
+ );
3189
3242
  reportDiagnostics({
3190
3243
  ctx: input.ctx,
3191
3244
  diagnostics: result.diagnostics,
3192
3245
  extend: input.extend,
3193
3246
  id: input.id,
3194
3247
  file,
3195
- incoming: inputSourceMap && decodeIncomingMap(inputSourceMap),
3248
+ incoming,
3196
3249
  onUnknown: input.onUnknown
3197
3250
  });
3198
3251
  return { code: result.css, map: result.map };
@@ -3205,8 +3258,18 @@ function hasStylesheetMapsFor(config) {
3205
3258
  function withForwardSlashes(file) {
3206
3259
  return file.replaceAll("\\", "/");
3207
3260
  }
3208
- function createStylesheets(extend, onUnknown) {
3209
- let hasStylesheetMaps = false;
3261
+ function settingsOf(config) {
3262
+ if (config === void 0) return { hasStylesheetMaps: false, reportStaleMarkers: true };
3263
+ return {
3264
+ hasStylesheetMaps: hasStylesheetMapsFor(config),
3265
+ reportStaleMarkers: config.css?.transformer !== "lightningcss"
3266
+ };
3267
+ }
3268
+ function warningsOf(context) {
3269
+ return { command: context.command, memory: context.state.orderWarnings };
3270
+ }
3271
+ function createStylesheets(extend, onUnknown, context) {
3272
+ let settings = settingsOf(void 0);
3210
3273
  const failed = /* @__PURE__ */ new Map();
3211
3274
  async function expand(ctx, code, id) {
3212
3275
  const environment = ctx.environment?.name ?? "client";
@@ -3220,19 +3283,26 @@ function createStylesheets(extend, onUnknown) {
3220
3283
  throw error;
3221
3284
  }
3222
3285
  failed.get(environment)?.delete(id);
3223
- return transformStylesheet({ ctx, code, id, extend: atoms, onUnknown, hasStylesheetMaps });
3286
+ return transformStylesheet({
3287
+ ctx,
3288
+ code,
3289
+ id,
3290
+ extend: atoms,
3291
+ onUnknown,
3292
+ ...settings,
3293
+ warnings: warningsOf(context)
3294
+ });
3224
3295
  }
3225
3296
  return {
3226
3297
  configure(config) {
3227
- hasStylesheetMaps = hasStylesheetMapsFor(config);
3298
+ settings = settingsOf(config);
3228
3299
  },
3229
3300
  async transform(ctx, code, id) {
3230
3301
  if (!isStylesheetId(id)) return;
3231
3302
  const environment = ctx.environment?.name ?? "client";
3232
- const hasDirective = canHoldDirective(code);
3233
- if (!hasDirective) failed.get(environment)?.delete(id);
3234
- const result = hasDirective ? await expand(ctx, code, id) : void 0;
3235
- return result;
3303
+ if (canHoldDirective(code)) return expand(ctx, code, id);
3304
+ failed.get(environment)?.delete(id);
3305
+ noteNoDirective(context.state.orderWarnings, id);
3236
3306
  },
3237
3307
  hotUpdate(ctx, hot) {
3238
3308
  const ids = failed.get(ctx.environment.name);
@@ -3254,7 +3324,7 @@ function createStylesheets(extend, onUnknown) {
3254
3324
  // src/vite.ts
3255
3325
  function assemble(options, extend) {
3256
3326
  const context = createUsedContext(resolveUsedOptions(options), extend);
3257
- const stylesheets = createStylesheets(extend, options.onUnknown ?? "error");
3327
+ const stylesheets = createStylesheets(extend, options.onUnknown ?? "error", context);
3258
3328
  const nave = {
3259
3329
  name: "nave",
3260
3330
  config: (_config, env) => usedConfig(context, env?.command),
@@ -3281,26 +3351,18 @@ function assemble(options, extend) {
3281
3351
  return devServing.modulesWithGrown(context, this, hot);
3282
3352
  },
3283
3353
  async renderChunk(_code, chunk) {
3284
- if (!isUsed(context) || this.environment.config.consumer !== "client") return;
3354
+ if (!isUsed(context) || !canWriteStylesheets(context, this.environment)) return;
3285
3355
  const emitted = emittedSet(context, this.environment, (message) => {
3286
3356
  this.warn(message);
3287
3357
  });
3288
- await refeedChunkStylesheets(this, chunk, context.state, emitted);
3358
+ const fed = withoutWhole(chunk, stylesheetsLeftWhole(context, this.environment, chunk));
3359
+ await refeedChunkStylesheets(this, fed, context.state, emitted);
3289
3360
  warnTextImports(this, chunk, context, emitted);
3290
3361
  },
3291
3362
  generateBundle: {
3292
3363
  order: "post",
3293
- handler(_options, bundle) {
3294
- if (isUsed(context) && this.environment?.config.consumer === "client") {
3295
- checkAtomicLayers(
3296
- this,
3297
- bundle,
3298
- emittedSet(context, this.environment, (message) => {
3299
- this.warn(message);
3300
- })
3301
- );
3302
- }
3303
- scanBundle(this, bundle);
3364
+ handler(options2, bundle) {
3365
+ checkBundle(this, context, { bundle, options: options2, pass: "post" });
3304
3366
  }
3305
3367
  }
3306
3368
  };