@navecss/core 0.3.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/postcss.js CHANGED
@@ -1,15 +1,32 @@
1
+ import { framedText } from './chunk-KKUYU75D.js';
1
2
  import { resolveExtendSpecifier, applyExtendModule } from './chunk-NKUZNRF4.js';
2
- import { snapshotExtendMap, walkExtendAtoms, foldLocated, anchorSelectorList, plan, formatDiagnostic, WORKAROUND_GROUP_AT_RULE_NAMES } from './chunk-S7DZUVV3.js';
3
- import { tokenize } from './chunk-NFS2REPQ.js';
4
- import './chunk-LIUB4EES.js';
3
+ import { snapshotExtendMap, walkExtendAtoms, foldLocated, anchorSelectorList, plan, planRule, DirectiveFailure, WORKAROUND_GROUP_AT_RULE_NAMES } from './chunk-MWHZ26S4.js';
4
+ import './chunk-UVHGEVMV.js';
5
+ import { formatDiagnostic } from './chunk-SYNQJNVB.js';
6
+ import './chunk-CUL5PLPI.js';
7
+ import { tokenize } from './chunk-2K5EBBF2.js';
8
+ import './chunk-GZL2VW7C.js';
5
9
  import postcss from 'postcss';
6
10
 
7
- // src/postcss-nested-builders.ts
8
- function isNestedNode(node) {
9
- return node.type === "rule" || node.type === "atrule" && node.name.toLowerCase() !== "nave";
11
+ // src/postcss-fold.ts
12
+ function positionOf(entry, fallbackLine) {
13
+ if (!entry.atRule.source) return { column: 0, line: fallbackLine };
14
+ return entry.atRule.positionBy(entry.index === void 0 ? {} : { index: entry.index });
15
+ }
16
+ function sortFoldBySourceOrder(entries) {
17
+ return entries.map((entry, originalIndex) => ({ entry, originalIndex })).toSorted((a, b) => {
18
+ const pa = positionOf(a.entry, a.originalIndex);
19
+ const pb = positionOf(b.entry, b.originalIndex);
20
+ return pa.line - pb.line || pa.column - pb.column;
21
+ }).map(({ entry }) => entry);
10
22
  }
11
- function isFollowingNestedNode(rule, atRule) {
12
- return rule.nodes.slice(0, rule.index(atRule)).some((node) => isNestedNode(node));
23
+ function foldMessage(entries) {
24
+ return foldLocated(
25
+ entries.map((entry, i) => {
26
+ const position = positionOf(entry, i);
27
+ return { text: entry.text, line: position.line, column: position.column };
28
+ })
29
+ );
13
30
  }
14
31
 
15
32
  // src/postcss-node-utils.ts
@@ -41,6 +58,38 @@ function stampSource(node, source) {
41
58
  child.source = source;
42
59
  });
43
60
  }
61
+ function writtenText(cleaned, raws) {
62
+ return raws?.value === cleaned ? raws.raw.trim() : cleaned;
63
+ }
64
+
65
+ // src/postcss-warn.ts
66
+ function isTurbopack() {
67
+ return (process.env.TURBOPACK ?? "") !== "";
68
+ }
69
+ function framedAtNode(node, result, text, index) {
70
+ const input = node.source?.input;
71
+ if (input === void 0) return text;
72
+ const { line, column } = node.rangeBy(index === void 0 ? {} : { index }).start;
73
+ const origin = input.origin(line, column);
74
+ if (origin !== false)
75
+ return framedText(origin.file ?? origin.url, origin.line, origin.column, text);
76
+ return framedText(result.opts.from ?? input.file ?? input.id ?? "", line, column, text);
77
+ }
78
+ var ORDER_MARK = "naveOrderWarning";
79
+ function isOrderWarning(warning) {
80
+ return warning[ORDER_MARK] === true;
81
+ }
82
+ function reportWarning(node, result, text, place = {}) {
83
+ const { index } = place;
84
+ if (place.printWarnings !== false && isTurbopack()) {
85
+ console.warn(framedAtNode(node, result, text, index));
86
+ return;
87
+ }
88
+ node.warn(result, text, {
89
+ ...index !== void 0 && { index },
90
+ ...place.isOrder === true && { [ORDER_MARK]: true }
91
+ });
92
+ }
44
93
 
45
94
  // src/postcss-at-rule.ts
46
95
  function currentParams(atRule) {
@@ -51,10 +100,11 @@ function currentParams(atRule) {
51
100
  function matchNaveAtRule(atRule) {
52
101
  const afterName = atRule.raws.afterName ?? " ";
53
102
  const paramsRaw = currentParams(atRule);
103
+ const between = atRule.raws.between ?? "";
54
104
  const nameBoundary = 1 + atRule.name.length;
55
- const full = `@${atRule.name}${afterName}${paramsRaw}`;
105
+ const full = `@${atRule.name}${afterName}${paramsRaw}${between}`;
56
106
  const token = tokenize(full)[0];
57
- const commonPrelude = { prelude: paramsRaw, preludeStartIndex: nameBoundary + afterName.length };
107
+ const commonPrelude = { prelude: full.slice(nameBoundary), preludeStartIndex: nameBoundary };
58
108
  if (token?.type !== "at-keyword-token") return { isNave: false, ...commonPrelude };
59
109
  const isNave = (token.structured?.value).toLowerCase() === "nave";
60
110
  if (token.endIndex === nameBoundary) return { isNave, ...commonPrelude };
@@ -75,79 +125,239 @@ function reportDiagnostic(diagnostic, ctx, preludeStartIndex) {
75
125
  );
76
126
  const index = atRuleErrorIndex(preludeStartIndex, diagnostic);
77
127
  if (ctx.onUnknown === "warn") {
78
- ctx.atRule.warn(ctx.result, text, index === void 0 ? {} : { index });
128
+ reportWarning(ctx.atRule, ctx.result, text, {
129
+ index,
130
+ printWarnings: ctx.printWarnings
131
+ });
79
132
  return;
80
133
  }
81
134
  if (ctx.onUnknown === "ignore") return;
82
135
  ctx.fold.push({ atRule: ctx.atRule, text, index });
83
136
  }
137
+ function hasBlock(atRule) {
138
+ return atRule.nodes !== void 0;
139
+ }
140
+ function throwMalformedAtom(atRule, error) {
141
+ const message = error instanceof Error ? error.message : String(error);
142
+ throw atRule.error(message);
143
+ }
144
+ function handleAtRule(atRule, ctx) {
145
+ const match = matchNaveAtRule(atRule);
146
+ if (!match.isNave) return;
147
+ const parent = atRule.parent;
148
+ if (parent?.type === "rule") return;
149
+ const fullCtx = { ...ctx, atRule };
150
+ const diagnostics = plan(
151
+ match.prelude,
152
+ {
153
+ isStyleRuleParent: false,
154
+ isInsideKeyframes: parent !== void 0 && isInsideKeyframes(parent)
155
+ },
156
+ { extend: ctx.extend }
157
+ ).diagnostics;
158
+ for (const diagnostic of diagnostics) {
159
+ reportDiagnostic(diagnostic, fullCtx, match.preludeStartIndex);
160
+ }
161
+ if (hasBlock(atRule)) {
162
+ reportDiagnostic(
163
+ { code: "has-block", offset: 0, endOffset: atRule.toString().length },
164
+ fullCtx,
165
+ match.preludeStartIndex
166
+ );
167
+ }
168
+ atRule.remove();
169
+ }
84
170
  function declNode(atRule, decl) {
85
171
  const node = postcss.decl({ prop: decl.prop, value: decl.value });
86
172
  if (atRule.source) node.source = atRule.source;
87
173
  return node;
88
174
  }
89
- function insertDeclarations(atRule, declarations, isWrapped) {
90
- if (declarations.length === 0) return;
91
- if (!isWrapped) {
92
- for (const decl of declarations) atRule.before(declNode(atRule, decl));
93
- return;
94
- }
95
- const wrapper = postcss.rule({ selector: "&" });
96
- if (atRule.source) wrapper.source = atRule.source;
97
- for (const decl of declarations) wrapper.append(declNode(atRule, decl));
98
- atRule.before(wrapper);
99
- }
100
175
  function buildRule(selector, declarations) {
101
176
  const rule = postcss.rule({ selector });
102
177
  for (const decl of declarations) rule.append(postcss.decl({ prop: decl.prop, value: decl.value }));
103
178
  return rule;
104
179
  }
105
- function buildAppendedNode(block) {
180
+ function buildBlockNode(block) {
106
181
  if (block.kind === "pseudo") return buildRule(block.selector, block.declarations);
107
182
  const node = postcss.atRule({ name: block.kind, params: block.condition });
108
183
  if (block.declarations.length > 0) node.append(buildRule("&", block.declarations));
109
184
  for (const pseudo of block.pseudos) node.append(buildRule(pseudo.selector, pseudo.declarations));
110
185
  return node;
111
186
  }
112
- function throwMalformedAtom(atRule, error) {
113
- const message = error instanceof Error ? error.message : String(error);
114
- throw atRule.error(message);
187
+ function nodesOf(atRule, emission) {
188
+ if (emission.kind === "block") {
189
+ const node = buildBlockNode(emission.block);
190
+ stampSource(node, atRule.source);
191
+ return [node];
192
+ }
193
+ if (!emission.isWrapped) return emission.declarations.map((decl) => declNode(atRule, decl));
194
+ const wrapper = postcss.rule({ selector: "&" });
195
+ if (atRule.source) wrapper.source = atRule.source;
196
+ for (const decl of emission.declarations) wrapper.append(declNode(atRule, decl));
197
+ return [wrapper];
115
198
  }
116
- function planAtRule(atRule, extend, prelude) {
117
- const parent = atRule.parent;
118
- const isStyleRuleParent = parent?.type === "rule";
119
- const isFollowingNestedNodeHere = isStyleRuleParent ? isFollowingNestedNode(parent, atRule) : false;
120
- try {
199
+ function insertBlock(atRule, node) {
200
+ const previous = atRule.prev();
201
+ atRule.before(node);
202
+ if (previous?.raws.before === void 0) delete node.raws.before;
203
+ else node.raws.before = previous.raws.before.replaceAll(/\S/g, "");
204
+ }
205
+ function insertEmissions(atRule, emissions) {
206
+ for (const emission of emissions) {
207
+ for (const node of nodesOf(atRule, emission)) {
208
+ if (emission.kind === "block") insertBlock(atRule, node);
209
+ else atRule.before(node);
210
+ }
211
+ }
212
+ }
213
+ function wrapRun(nodes, source) {
214
+ const wrapper = postcss.rule({ selector: "&" });
215
+ if (source) wrapper.source = source;
216
+ nodes[0].before(wrapper);
217
+ for (const node of nodes) wrapper.append(node);
218
+ }
219
+
220
+ // src/postcss-rule-nesting.ts
221
+ function isRuleDirective(node) {
222
+ return node.type === "atrule" && node.parent?.type === "rule" && matchNaveAtRule(node).isNave;
223
+ }
224
+ function isOrHoldsRuleDirective(node) {
225
+ const stack = [node];
226
+ while (stack.length > 0) {
227
+ const next = stack.pop();
228
+ if (isRuleDirective(next)) return true;
229
+ if (next.type === "rule" || next.type === "atrule") stack.push(...next.nodes ?? []);
230
+ }
231
+ return false;
232
+ }
233
+ function isLastDirectiveUnder(root, atRule) {
234
+ let node = atRule;
235
+ for (; ; ) {
236
+ const parent = node.parent;
237
+ const later = (parent.nodes ?? []).slice(parent.index(node) + 1);
238
+ if (later.some((child) => isOrHoldsRuleDirective(child))) {
239
+ return false;
240
+ }
241
+ if (parent === root) return true;
242
+ node = parent;
243
+ }
244
+ }
245
+ function outermostRule(rule) {
246
+ let outer = rule;
247
+ let node = rule.parent;
248
+ while (node !== void 0 && node !== null) {
249
+ const container = node;
250
+ if (container.type === "rule") outer = node;
251
+ node = container.parent;
252
+ }
253
+ return outer;
254
+ }
255
+ function markAncestors(directive, root, marked) {
256
+ let up = directive.parent;
257
+ while (up !== void 0 && up !== null && !marked.has(up)) {
258
+ marked.add(up);
259
+ up = up === root ? void 0 : up.parent;
260
+ }
261
+ }
262
+ function rulesAboveDirectives(root) {
263
+ const marked = /* @__PURE__ */ new Set();
264
+ const stack = [root];
265
+ while (stack.length > 0) {
266
+ const node = stack.pop();
267
+ if (isRuleDirective(node)) markAncestors(node, root, marked);
268
+ if (node.type === "rule" || node.type === "atrule") stack.push(...node.nodes ?? []);
269
+ }
270
+ return marked;
271
+ }
272
+
273
+ // src/postcss-rule.ts
274
+ var GROUP_NAMES = /* @__PURE__ */ new Set(["container", "media", "supports"]);
275
+ function contentOf(container, table) {
276
+ let nodes;
277
+ return () => {
278
+ nodes ??= (container.nodes ?? []).map((child) => toModel(child, table));
279
+ return nodes;
280
+ };
281
+ }
282
+ function toModel(node, table) {
283
+ const ref = table.length;
284
+ table.push(node);
285
+ if (node.type === "decl") {
286
+ const raw = node.raws.value;
287
+ const value = raw?.value === node.value ? raw.raw : node.value;
288
+ return { kind: "decl", ref, prop: node.prop, value, important: node.important };
289
+ }
290
+ if (node.type === "comment") return { kind: "comment", ref };
291
+ if (node.type === "rule") {
292
+ const content2 = contentOf(node, table);
121
293
  return {
122
- isStyleRuleParent,
123
- parent,
124
- result: plan(
125
- prelude,
126
- {
127
- isStyleRuleParent,
128
- isInsideKeyframes: parent !== void 0 && isInsideKeyframes(parent),
129
- isFollowingNestedNode: isFollowingNestedNodeHere
130
- },
131
- { extend }
132
- )
294
+ kind: "rule",
295
+ ref,
296
+ selector: writtenText(node.selector, node.raws.selector),
297
+ get nodes() {
298
+ return content2();
299
+ }
133
300
  };
134
- } catch (error) {
135
- return throwMalformedAtom(atRule, error);
136
301
  }
302
+ const match = matchNaveAtRule(node);
303
+ if (match.isNave) return { kind: "directive", ref, prelude: match.prelude };
304
+ const name = node.name.toLowerCase();
305
+ if (!GROUP_NAMES.has(name) || node.nodes === void 0) {
306
+ return { kind: "opaque", ref, name, prelude: writtenText(node.params, node.raws.params) };
307
+ }
308
+ const content = contentOf(node, table);
309
+ return {
310
+ kind: "group",
311
+ ref,
312
+ name,
313
+ prelude: writtenText(node.params, node.raws.params),
314
+ get nodes() {
315
+ return content();
316
+ }
317
+ };
137
318
  }
138
- function hasBlock(atRule) {
139
- return atRule.nodes !== void 0;
319
+ function readRule(rule) {
320
+ const table = [];
321
+ return { table, nodes: rule.nodes.map((child) => toModel(child, table)) };
140
322
  }
141
- function handleAtRule(atRule, ctx) {
323
+ function pendingWarnings(warnings, table) {
324
+ return warnings.map(({ anchor, text }) => {
325
+ const node = table[anchor.ref];
326
+ if (anchor.offset === void 0) return { node, text, index: void 0 };
327
+ const { preludeStartIndex } = matchNaveAtRule(node);
328
+ return { node, text, index: preludeStartIndex + anchor.offset };
329
+ });
330
+ }
331
+ function placeOf(warning) {
332
+ if (warning.node.source === void 0) return [Number.MAX_SAFE_INTEGER, 0];
333
+ const { column, line } = warning.node.positionInside(warning.index ?? 0);
334
+ return [line, column];
335
+ }
336
+ function reportInSourceOrder(warnings, ctx) {
337
+ const placed = warnings.map((warning) => ({ warning, place: placeOf(warning) }));
338
+ const ordered = placed.toSorted((a, b) => a.place[0] - b.place[0] || a.place[1] - b.place[1]);
339
+ for (const { warning } of ordered) {
340
+ reportWarning(warning.node, ctx.result, warning.text, {
341
+ index: warning.index,
342
+ isOrder: true,
343
+ printWarnings: ctx.printWarnings
344
+ });
345
+ }
346
+ }
347
+ function applyItem(item, table, ctx) {
348
+ if (item.kind === "keep") return;
349
+ if (item.kind === "wrap") {
350
+ const source = table[item.after].source;
351
+ wrapRun(
352
+ item.refs.map((ref) => table[ref]),
353
+ source
354
+ );
355
+ return;
356
+ }
357
+ const atRule = table[item.ref];
142
358
  const match = matchNaveAtRule(atRule);
143
- if (!match.isNave) return;
144
359
  const fullCtx = { ...ctx, atRule };
145
- const {
146
- isStyleRuleParent,
147
- parent,
148
- result: planResult
149
- } = planAtRule(atRule, ctx.extend, match.prelude);
150
- for (const diagnostic of planResult.diagnostics) {
360
+ for (const diagnostic of item.diagnostics) {
151
361
  reportDiagnostic(diagnostic, fullCtx, match.preludeStartIndex);
152
362
  }
153
363
  if (hasBlock(atRule)) {
@@ -157,36 +367,77 @@ function handleAtRule(atRule, ctx) {
157
367
  match.preludeStartIndex
158
368
  );
159
369
  }
160
- insertDeclarations(atRule, planResult.declarations, planResult.wrapInAmpersand);
370
+ insertEmissions(atRule, item.emissions);
161
371
  atRule.remove();
162
- if (isStyleRuleParent && parent) {
163
- for (const block of planResult.blocks) {
164
- const node = buildAppendedNode(block);
165
- stampSource(node, atRule.source);
166
- parent.append(node);
372
+ }
373
+ function planOrThrow(rule, read, ctx) {
374
+ try {
375
+ return planRule({
376
+ selector: rule.selector,
377
+ nodes: read.nodes,
378
+ isInsideKeyframes: isInsideKeyframes(rule),
379
+ extend: ctx.extend,
380
+ emittedCache: ctx.emittedCache,
381
+ outward: ctx.outward
382
+ });
383
+ } catch (error) {
384
+ if (error instanceof DirectiveFailure) {
385
+ return throwMalformedAtom(read.table[error.ref], error.cause);
167
386
  }
387
+ throw error;
168
388
  }
169
389
  }
170
-
171
- // src/postcss-fold.ts
172
- function positionOf(entry, fallbackLine) {
173
- if (!entry.atRule.source) return { column: 0, line: fallbackLine };
174
- return entry.atRule.positionBy(entry.index === void 0 ? {} : { index: entry.index });
175
- }
176
- function sortFoldBySourceOrder(entries) {
177
- return entries.map((entry, originalIndex) => ({ entry, originalIndex })).toSorted((a, b) => {
178
- const pa = positionOf(a.entry, a.originalIndex);
179
- const pb = positionOf(b.entry, b.originalIndex);
180
- return pa.line - pb.line || pa.column - pb.column;
181
- }).map(({ entry }) => entry);
390
+ function planTree(root, ctx) {
391
+ const emittedCache = /* @__PURE__ */ new Map();
392
+ const known = /* @__PURE__ */ new Map();
393
+ const holders = rulesAboveDirectives(root);
394
+ const planned = [];
395
+ const stack = [root];
396
+ while (stack.length > 0) {
397
+ const container = stack.pop();
398
+ if (container.type === "rule" && holders.has(container)) {
399
+ const read = readRule(container);
400
+ const outward = { identityOf: (ref) => read.table[ref], known };
401
+ const plan2 = planOrThrow(container, read, { ...ctx, emittedCache, outward });
402
+ for (const finding of plan2.outwardFindings) {
403
+ const key = read.table[finding.unit.directive.ref];
404
+ known.set(key, [...known.get(key) ?? [], finding]);
405
+ }
406
+ planned.push({ table: read.table, plan: plan2 });
407
+ }
408
+ const inner = (container.nodes ?? []).filter(
409
+ (child) => child.type === "rule" || child.type === "atrule"
410
+ );
411
+ stack.push(...inner.toReversed());
412
+ }
413
+ return planned;
182
414
  }
183
- function foldMessage(entries) {
184
- return foldLocated(
185
- entries.map((entry, i) => {
186
- const position = positionOf(entry, i);
187
- return { text: entry.text, line: position.line, column: position.column };
188
- })
415
+ function handleRuleTree(root, ctx) {
416
+ const planned = planTree(root, ctx);
417
+ reportInSourceOrder(
418
+ planned.flatMap(({ plan: plan2, table }) => pendingWarnings(plan2.warnings, table)),
419
+ ctx
189
420
  );
421
+ for (const { plan: plan2, table } of planned) {
422
+ for (const item of plan2.items) applyItem(item, table, ctx);
423
+ }
424
+ }
425
+ function expandLeftovers(root, ctx) {
426
+ const outer = /* @__PURE__ */ new Set();
427
+ root.walkAtRules((atRule) => {
428
+ if (isRuleDirective(atRule)) outer.add(outermostRule(atRule.parent));
429
+ });
430
+ for (const rule of outer) handleRuleTree(rule, ctx);
431
+ }
432
+ function handleDirective(atRule, ctx) {
433
+ const parent = atRule.parent;
434
+ if (parent?.type !== "rule") {
435
+ handleAtRule(atRule, ctx);
436
+ return;
437
+ }
438
+ if (!matchNaveAtRule(atRule).isNave) return;
439
+ const root = outermostRule(parent);
440
+ if (isLastDirectiveUnder(root, atRule)) handleRuleTree(root, ctx);
190
441
  }
191
442
  function unescapeHtml(text) {
192
443
  return text.replaceAll(/\\3c (?=\/?style\b|!--)/gi, "<");
@@ -253,7 +504,7 @@ function validateExtendAtoms(extend) {
253
504
 
254
505
  // src/postcss.ts
255
506
  var navePlugin = (options = {}) => {
256
- const { onUnknown = "error", extend: extendOption } = options;
507
+ const { onUnknown = "error", printWarnings = true, extend: extendOption } = options;
257
508
  const extendFile = typeof extendOption === "string" ? resolveExtendSpecifier(extendOption) : void 0;
258
509
  const staticExtend = typeof extendOption === "object" ? snapshotExtendMap(extendOption) : {};
259
510
  validateExtendAtoms(staticExtend);
@@ -285,9 +536,10 @@ var navePlugin = (options = {}) => {
285
536
  });
286
537
  },
287
538
  AtRule(atRule) {
288
- handleAtRule(atRule, { onUnknown, result, extend, fold });
539
+ handleDirective(atRule, { onUnknown, printWarnings, result, extend, fold });
289
540
  },
290
- OnceExit() {
541
+ OnceExit(root) {
542
+ expandLeftovers(root, { onUnknown, printWarnings, result, extend, fold });
291
543
  if (fold.length === 0) return;
292
544
  const ordered = sortFoldBySourceOrder(fold);
293
545
  const first = ordered[0];
@@ -303,4 +555,4 @@ var navePlugin = (options = {}) => {
303
555
  navePlugin.postcss = true;
304
556
  var postcss_default = navePlugin;
305
557
 
306
- export { postcss_default as default, navePlugin };
558
+ export { postcss_default as default, isOrderWarning, navePlugin };
@@ -475,6 +475,9 @@
475
475
  --nave-color-action-primary-active: light-dark(oklch(0.27 0.0398 186.17), oklch(0.94 0.0574 186.17));
476
476
  --nave-color-on-action-primary: light-dark(oklch(from var(--nave-color-tint) 1 0 h / 1), oklch(from var(--nave-color-tint) 0.18 0.0067 h / 1));
477
477
  --nave-color-action-secondary: light-dark(oklch(from var(--nave-color-tint) 0.965 0.0067 h / 1), oklch(from var(--nave-color-tint) 0.27 0.0067 h / 1));
478
+ --nave-color-action-secondary-hover: light-dark(oklch(from var(--nave-color-tint) 0.94 0.0067 h / 1), oklch(from var(--nave-color-tint) 0.37 0.0067 h / 1));
479
+ --nave-color-action-secondary-active: light-dark(oklch(from var(--nave-color-tint) 0.905 0.0067 h / 1), oklch(from var(--nave-color-tint) 0.225 0.0067 h / 1));
480
+ --nave-color-action-highlight: light-dark(oklch(from var(--nave-color-tint) 0.965 0.0067 h / 1), oklch(from var(--nave-color-tint) 0.37 0.0067 h / 1));
478
481
  --nave-color-feedback-danger: light-dark(oklch(0.47 0.1455 15.02), oklch(0.835 0.0661 15.02));
479
482
  --nave-color-feedback-danger-foreground: light-dark(oklch(0.47 0.1455 15.02), oklch(0.835 0.0661 15.02));
480
483
  --nave-color-on-feedback-danger: light-dark(oklch(from var(--nave-color-tint) 1 0 h / 1), oklch(from var(--nave-color-tint) 0.18 0.0067 h / 1));
@@ -488,6 +491,7 @@
488
491
  --nave-color-feedback-info: light-dark(oklch(from var(--nave-color-tint) 0.47 0.0067 h / 1), oklch(from var(--nave-color-tint) 0.835 0.0067 h / 1));
489
492
  --nave-color-feedback-info-foreground: light-dark(oklch(from var(--nave-color-tint) 0.47 0.0067 h / 1), oklch(from var(--nave-color-tint) 0.835 0.0067 h / 1));
490
493
  --nave-color-on-feedback-info: light-dark(oklch(from var(--nave-color-tint) 1 0 h / 1), oklch(from var(--nave-color-tint) 0.18 0.0067 h / 1));
494
+ --nave-color-backdrop-modal: light-dark(oklch(from var(--nave-color-tint) 0.12 0.0067 h / 0.3), oklch(from var(--nave-color-tint) 0.12 0.0067 h / 0.6));
491
495
  }
492
496
  }
493
497
 
@@ -0,0 +1,87 @@
1
+ import { A as AtomName } from './atom-names-B8Ud-7zD.js';
2
+
3
+ /**
4
+ * The options that choose which atoms the Vite plugin ships, and their validation. A value a
5
+ * type would refuse in TypeScript is refused here too, so a JavaScript config gets the same
6
+ * answer; every text opens `navePlugin(): `, the prefix of the plugin's config-level messages.
7
+ */
8
+
9
+ interface UsedAtomOptions {
10
+ /**
11
+ * Which atoms the build ships. `'used'` (the default): the atoms your `cx()` calls and your
12
+ * written Nave classes name, plus those in `keep` and `keepFor`. Under the default the build
13
+ * filters the atomic layer of every stylesheet it can reach, and the dev server serves the same
14
+ * set as far as it has read; a stylesheet imported with `?inline` or `?raw` ships every atom
15
+ * with a warning; a `cx()` call whose atoms the build cannot read fails the build, and is an
16
+ * error in the dev server. In a build, each `cx()` call the plugin read also becomes the class
17
+ * string it returns.
18
+ * `'all'`: every atom, and no `cx()` call is read or rewritten, as with the PostCSS plugin.
19
+ */
20
+ atomic?: 'all' | 'used';
21
+ /**
22
+ * Atoms always shipped, whether or not the build reads a use of them: every atom your own
23
+ * `cx.dynamic()` calls can take, and the atom of each Nave class written where the build cannot
24
+ * read it, such as in a server template or in CMS text.
25
+ */
26
+ keep?: readonly AtomName[];
27
+ /**
28
+ * By package name: the atoms a dependency's own `cx()` calls can produce, for a package whose
29
+ * calls the build cannot read. They ship as if they were in `keep`, beside the atoms of the
30
+ * package's calls the build does read. The calls it cannot read are not changed, so any other
31
+ * atom they apply has no rule unless the build ships it for another reason. An empty list is
32
+ * accepted: it says those calls produce no atom, so the list adds none, and a `cx.dynamic()` call
33
+ * in the package still fails the build, as it does with no entry. A package in your own workspace
34
+ * is your code, not a dependency. The entry stands in for the package's own calls only: a
35
+ * re-export of `cx` in the package that the build reads and a module of yours takes (imports,
36
+ * re-exports or reads off a namespace, directly or through re-exports of it that the build reads,
37
+ * as `export ... from` or an import exported unchanged, in this package or another) still fails
38
+ * the build, because the calls your module makes through it would ship with no rule, and the
39
+ * message says how to clear it. Listing here a package that only re-exports it does not clear a
40
+ * take of yours, since a re-export is not a call. A server build that leaves the package external
41
+ * does not read it, so a take only your server code makes is judged by what the client build
42
+ * read: it fails the build as above when the client build read the re-export it takes and the
43
+ * build can read the take, and gets a warning naming `ssr.noExternal` when the build cannot tell,
44
+ * because no environment read the file the server loads, or your file reaches the package in a
45
+ * way the build cannot read as a take (a `require()`, say, or a `#` import); with separate client
46
+ * and server commands, the next client command judges what the last build of each server recorded
47
+ * of server files that still exist.
48
+ */
49
+ keepFor?: Readonly<Record<string, readonly AtomName[]>>;
50
+ /**
51
+ * Modules that re-export `cx` from `@navecss/core/cx` unchanged, as
52
+ * `export { cx } from '@navecss/core/cx'`, in your code or in a dependency: a file that imports
53
+ * `cx` from one is read as if it imported it from `@navecss/core/cx`. The build follows a listed
54
+ * module one step. A relative entry (`'./src/ui/index.ts'`) is a path from Vite's `root`. A
55
+ * package name or subpath, an alias or an absolute path matches an import written the same way.
56
+ * A `#` entry matches an import written the same way only where that import resolves to a listed
57
+ * file, since a `#` import resolves through the `package.json` nearest the file that writes it.
58
+ * Every entry also matches an import that resolves to its file through a specifier naming that
59
+ * file or, for an `index` file, its directory; in your code, an import that reaches the file
60
+ * through any other specifier fails the build instead. A relative entry that resolves to no file
61
+ * is ignored, and so is an entry naming `@navecss/core/cx`, which the build always reads. The
62
+ * same setting, with the same entries, as `@navecss/eslint-plugin`'s `cxModules`, which reads a
63
+ * relative entry from the working directory instead of Vite's `root`.
64
+ */
65
+ cxModules?: readonly string[];
66
+ }
67
+ interface ResolvedUsedOptions {
68
+ readonly atomic: 'all' | 'used';
69
+ readonly keep: readonly string[];
70
+ readonly keepFor: Readonly<Record<string, readonly string[]>>;
71
+ readonly cxModules: readonly string[];
72
+ }
73
+ /**
74
+ * Throws the first problem in the options, if there is one.
75
+ */
76
+ declare function assertOptions(options: UsedAtomOptions | ResolvedUsedOptions, own: ReadonlySet<string> | undefined): void;
77
+ /**
78
+ * The options with their defaults filled in.
79
+ */
80
+ declare function resolveUsedOptions(options: UsedAtomOptions): ResolvedUsedOptions;
81
+ /**
82
+ * Every atom the options always ship: `keep` and every `keepFor` list.
83
+ */
84
+ declare function keptAtoms(options: ResolvedUsedOptions): string[];
85
+
86
+ export { assertOptions as a, keptAtoms as k, resolveUsedOptions as r };
87
+ export type { ResolvedUsedOptions as R, UsedAtomOptions as U };