@navecss/core 0.4.0 → 0.6.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/cx.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as AtomName } from './atom-names-2OreuBx9.js';
1
+ import { A as AtomName } from './atom-names-B8Ud-7zD.js';
2
2
 
3
3
  /**
4
4
  * cx — typed atomic class composer for Nave.
@@ -1,5 +1,5 @@
1
1
  import { AtomDefinition } from './atoms.js';
2
- import './atom-names-2OreuBx9.js';
2
+ import './atom-names-B8Ud-7zD.js';
3
3
 
4
4
  interface NaveLightningOptions {
5
5
  /**
@@ -48,4 +48,5 @@ interface NaveLightningAdapter {
48
48
  */
49
49
  declare function navePlugin(options?: NaveLightningOptions): NaveLightningAdapter;
50
50
 
51
- export { type NaveLightningAdapter, type NaveLightningOptions, navePlugin as default, navePlugin };
51
+ export { navePlugin as default, navePlugin };
52
+ export type { NaveLightningAdapter, NaveLightningOptions };
@@ -1,9 +1,11 @@
1
- import { splitByteOrderMark, warningTexts, foldedText } from './chunk-2A7IUZBH.js';
2
- import { validateExtendAtomsHostFree } from './chunk-LQSGQ2OA.js';
3
- import { snapshotExtendMap, expandText } from './chunk-LADFXRWQ.js';
4
- import './chunk-NFS2REPQ.js';
1
+ import { splitByteOrderMark } from './chunk-2TNTYI4L.js';
2
+ import { orderWarningTexts, warningTexts, foldedText } from './chunk-R6R5DSTT.js';
3
+ import { validateExtendAtomsHostFree } from './chunk-B5CWZIBK.js';
4
+ import { snapshotExtendMap, expandText } from './chunk-KDLLTOAM.js';
5
+ import './chunk-UVHGEVMV.js';
5
6
  import './chunk-SYNQJNVB.js';
6
7
  import './chunk-CUL5PLPI.js';
8
+ import './chunk-2K5EBBF2.js';
7
9
  import './chunk-GZL2VW7C.js';
8
10
  import { readFileSync } from 'fs';
9
11
 
@@ -21,6 +23,7 @@ function navePlugin(options = {}) {
21
23
  validateExtendAtomsHostFree(extend);
22
24
  const expandToText = (text, file) => {
23
25
  const result = expandText(text, { extend, onUnknown, from: file });
26
+ for (const line of orderWarningTexts(result.warnings, file)) console.warn(line);
24
27
  report(result.diagnostics, file, extend, onUnknown);
25
28
  return result;
26
29
  };
package/dist/postcss.d.ts CHANGED
@@ -1,6 +1,22 @@
1
- import { Plugin } from 'postcss';
1
+ import { Warning, Plugin } from 'postcss';
2
2
  import { AtomDefinition } from './atoms.js';
3
- import './atom-names-2OreuBx9.js';
3
+ import './atom-names-B8Ud-7zD.js';
4
+
5
+ /**
6
+ * The one place the PostCSS host reports a warning: `node.warn()`, except under Next.js's
7
+ * Turbopack, which drops every PostCSS warning. There (detected by `process.env.TURBOPACK` being
8
+ * set) the text is printed with `console.warn` behind the same `file:line:column: ` frame the
9
+ * Lightning CSS adapter prints, and `node.warn()` is not called as well. A tool that runs the
10
+ * plugin itself and reports its warnings turns the printing off (`printWarnings: false`): every
11
+ * warning is then raised, whatever `TURBOPACK` says.
12
+ */
13
+
14
+ /**
15
+ * Whether `warning` is an order warning (one `order-warnings.ts` or `shape-warnings.ts` makes)
16
+ * and not an `onUnknown` problem. No `onUnknown` governs it and it never fails a build, so a tool
17
+ * running the plugin with `printWarnings: false` reports it as a warning, never as a problem.
18
+ */
19
+ declare function isOrderWarning(warning: Warning): boolean;
4
20
 
5
21
  /**
6
22
  * Nave PostCSS plugin — resolves @nave directives.
@@ -18,6 +34,7 @@ import './atom-names-2OreuBx9.js';
18
34
  * navePlugin() // Nave atoms only, fails build on unknown atom
19
35
  * navePlugin({ extend: myAtoms }) // Nave + consumer atoms
20
36
  * navePlugin({ onUnknown: 'warn' }) // Log and skip instead of failing the build
37
+ * navePlugin({ onUnknown: 'warn', printWarnings: false }) // Raise warnings only, never print
21
38
  *
22
39
  * `extend` is trusted, consumer-authored code (your build config, or the module a path names),
23
40
  * which can already run arbitrary JavaScript at build time: it is not sanitised input. Every
@@ -77,10 +94,19 @@ interface NavePluginOptions {
77
94
  * 'ignore' — silently skip
78
95
  */
79
96
  onUnknown?: 'warn' | 'error' | 'ignore';
97
+ /**
98
+ * Whether a warning may be printed: a problem under 'warn', or an order warning. Under
99
+ * Turbopack (`TURBOPACK` set), which shows no PostCSS warning, the plugin prints each one with
100
+ * `console.warn` instead of raising it (default `true`). `false` raises it as a PostCSS warning
101
+ * only, whatever `TURBOPACK` says: for a tool that runs the plugin itself and reports the
102
+ * warnings it raises, telling the two apart with `isOrderWarning()`.
103
+ */
104
+ printWarnings?: boolean;
80
105
  }
81
106
  declare const navePlugin: {
82
107
  (options?: NavePluginOptions): Plugin;
83
108
  postcss: boolean;
84
109
  };
85
110
 
86
- export { AtomDefinition, type NavePluginOptions, navePlugin as default, navePlugin };
111
+ export { AtomDefinition, navePlugin as default, isOrderWarning, navePlugin };
112
+ export type { NavePluginOptions };
package/dist/postcss.js CHANGED
@@ -1,17 +1,32 @@
1
+ import { framedText } from './chunk-R6R5DSTT.js';
1
2
  import { resolveExtendSpecifier, applyExtendModule } from './chunk-NKUZNRF4.js';
2
- import { snapshotExtendMap, walkExtendAtoms, foldLocated, anchorSelectorList, plan, WORKAROUND_GROUP_AT_RULE_NAMES } from './chunk-LADFXRWQ.js';
3
- import { tokenize } from './chunk-NFS2REPQ.js';
3
+ import { snapshotExtendMap, walkExtendAtoms, foldLocated, anchorSelectorList, plan, planRule, DirectiveFailure, WORKAROUND_GROUP_AT_RULE_NAMES } from './chunk-KDLLTOAM.js';
4
+ import './chunk-UVHGEVMV.js';
4
5
  import { formatDiagnostic } from './chunk-SYNQJNVB.js';
5
6
  import './chunk-CUL5PLPI.js';
7
+ import { tokenize } from './chunk-2K5EBBF2.js';
6
8
  import './chunk-GZL2VW7C.js';
7
9
  import postcss from 'postcss';
8
10
 
9
- // src/postcss-nested-builders.ts
10
- function isNestedNode(node) {
11
- 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);
12
22
  }
13
- function isFollowingNestedNode(rule, atRule) {
14
- 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
+ );
15
30
  }
16
31
 
17
32
  // src/postcss-node-utils.ts
@@ -43,6 +58,38 @@ function stampSource(node, source) {
43
58
  child.source = source;
44
59
  });
45
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
+ }
46
93
 
47
94
  // src/postcss-at-rule.ts
48
95
  function currentParams(atRule) {
@@ -53,10 +100,11 @@ function currentParams(atRule) {
53
100
  function matchNaveAtRule(atRule) {
54
101
  const afterName = atRule.raws.afterName ?? " ";
55
102
  const paramsRaw = currentParams(atRule);
103
+ const between = atRule.raws.between ?? "";
56
104
  const nameBoundary = 1 + atRule.name.length;
57
- const full = `@${atRule.name}${afterName}${paramsRaw}`;
105
+ const full = `@${atRule.name}${afterName}${paramsRaw}${between}`;
58
106
  const token = tokenize(full)[0];
59
- const commonPrelude = { prelude: paramsRaw, preludeStartIndex: nameBoundary + afterName.length };
107
+ const commonPrelude = { prelude: full.slice(nameBoundary), preludeStartIndex: nameBoundary };
60
108
  if (token?.type !== "at-keyword-token") return { isNave: false, ...commonPrelude };
61
109
  const isNave = (token.structured?.value).toLowerCase() === "nave";
62
110
  if (token.endIndex === nameBoundary) return { isNave, ...commonPrelude };
@@ -77,79 +125,239 @@ function reportDiagnostic(diagnostic, ctx, preludeStartIndex) {
77
125
  );
78
126
  const index = atRuleErrorIndex(preludeStartIndex, diagnostic);
79
127
  if (ctx.onUnknown === "warn") {
80
- ctx.atRule.warn(ctx.result, text, index === void 0 ? {} : { index });
128
+ reportWarning(ctx.atRule, ctx.result, text, {
129
+ index,
130
+ printWarnings: ctx.printWarnings
131
+ });
81
132
  return;
82
133
  }
83
134
  if (ctx.onUnknown === "ignore") return;
84
135
  ctx.fold.push({ atRule: ctx.atRule, text, index });
85
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
+ }
86
170
  function declNode(atRule, decl) {
87
171
  const node = postcss.decl({ prop: decl.prop, value: decl.value });
88
172
  if (atRule.source) node.source = atRule.source;
89
173
  return node;
90
174
  }
91
- function insertDeclarations(atRule, declarations, isWrapped) {
92
- if (declarations.length === 0) return;
93
- if (!isWrapped) {
94
- for (const decl of declarations) atRule.before(declNode(atRule, decl));
95
- return;
96
- }
97
- const wrapper = postcss.rule({ selector: "&" });
98
- if (atRule.source) wrapper.source = atRule.source;
99
- for (const decl of declarations) wrapper.append(declNode(atRule, decl));
100
- atRule.before(wrapper);
101
- }
102
175
  function buildRule(selector, declarations) {
103
176
  const rule = postcss.rule({ selector });
104
177
  for (const decl of declarations) rule.append(postcss.decl({ prop: decl.prop, value: decl.value }));
105
178
  return rule;
106
179
  }
107
- function buildAppendedNode(block) {
180
+ function buildBlockNode(block) {
108
181
  if (block.kind === "pseudo") return buildRule(block.selector, block.declarations);
109
182
  const node = postcss.atRule({ name: block.kind, params: block.condition });
110
183
  if (block.declarations.length > 0) node.append(buildRule("&", block.declarations));
111
184
  for (const pseudo of block.pseudos) node.append(buildRule(pseudo.selector, pseudo.declarations));
112
185
  return node;
113
186
  }
114
- function throwMalformedAtom(atRule, error) {
115
- const message = error instanceof Error ? error.message : String(error);
116
- 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];
117
198
  }
118
- function planAtRule(atRule, extend, prelude) {
119
- const parent = atRule.parent;
120
- const isStyleRuleParent = parent?.type === "rule";
121
- const isFollowingNestedNodeHere = isStyleRuleParent ? isFollowingNestedNode(parent, atRule) : false;
122
- 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);
123
293
  return {
124
- isStyleRuleParent,
125
- parent,
126
- result: plan(
127
- prelude,
128
- {
129
- isStyleRuleParent,
130
- isInsideKeyframes: parent !== void 0 && isInsideKeyframes(parent),
131
- isFollowingNestedNode: isFollowingNestedNodeHere
132
- },
133
- { extend }
134
- )
294
+ kind: "rule",
295
+ ref,
296
+ selector: writtenText(node.selector, node.raws.selector),
297
+ get nodes() {
298
+ return content2();
299
+ }
135
300
  };
136
- } catch (error) {
137
- return throwMalformedAtom(atRule, error);
138
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
+ };
139
318
  }
140
- function hasBlock(atRule) {
141
- return atRule.nodes !== void 0;
319
+ function readRule(rule) {
320
+ const table = [];
321
+ return { table, nodes: rule.nodes.map((child) => toModel(child, table)) };
142
322
  }
143
- 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];
144
358
  const match = matchNaveAtRule(atRule);
145
- if (!match.isNave) return;
146
359
  const fullCtx = { ...ctx, atRule };
147
- const {
148
- isStyleRuleParent,
149
- parent,
150
- result: planResult
151
- } = planAtRule(atRule, ctx.extend, match.prelude);
152
- for (const diagnostic of planResult.diagnostics) {
360
+ for (const diagnostic of item.diagnostics) {
153
361
  reportDiagnostic(diagnostic, fullCtx, match.preludeStartIndex);
154
362
  }
155
363
  if (hasBlock(atRule)) {
@@ -159,36 +367,77 @@ function handleAtRule(atRule, ctx) {
159
367
  match.preludeStartIndex
160
368
  );
161
369
  }
162
- insertDeclarations(atRule, planResult.declarations, planResult.wrapInAmpersand);
370
+ insertEmissions(atRule, item.emissions);
163
371
  atRule.remove();
164
- if (isStyleRuleParent && parent) {
165
- for (const block of planResult.blocks) {
166
- const node = buildAppendedNode(block);
167
- stampSource(node, atRule.source);
168
- 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);
169
386
  }
387
+ throw error;
170
388
  }
171
389
  }
172
-
173
- // src/postcss-fold.ts
174
- function positionOf(entry, fallbackLine) {
175
- if (!entry.atRule.source) return { column: 0, line: fallbackLine };
176
- return entry.atRule.positionBy(entry.index === void 0 ? {} : { index: entry.index });
177
- }
178
- function sortFoldBySourceOrder(entries) {
179
- return entries.map((entry, originalIndex) => ({ entry, originalIndex })).toSorted((a, b) => {
180
- const pa = positionOf(a.entry, a.originalIndex);
181
- const pb = positionOf(b.entry, b.originalIndex);
182
- return pa.line - pb.line || pa.column - pb.column;
183
- }).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;
184
414
  }
185
- function foldMessage(entries) {
186
- return foldLocated(
187
- entries.map((entry, i) => {
188
- const position = positionOf(entry, i);
189
- return { text: entry.text, line: position.line, column: position.column };
190
- })
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
191
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);
192
441
  }
193
442
  function unescapeHtml(text) {
194
443
  return text.replaceAll(/\\3c (?=\/?style\b|!--)/gi, "<");
@@ -255,7 +504,7 @@ function validateExtendAtoms(extend) {
255
504
 
256
505
  // src/postcss.ts
257
506
  var navePlugin = (options = {}) => {
258
- const { onUnknown = "error", extend: extendOption } = options;
507
+ const { onUnknown = "error", printWarnings = true, extend: extendOption } = options;
259
508
  const extendFile = typeof extendOption === "string" ? resolveExtendSpecifier(extendOption) : void 0;
260
509
  const staticExtend = typeof extendOption === "object" ? snapshotExtendMap(extendOption) : {};
261
510
  validateExtendAtoms(staticExtend);
@@ -287,9 +536,10 @@ var navePlugin = (options = {}) => {
287
536
  });
288
537
  },
289
538
  AtRule(atRule) {
290
- handleAtRule(atRule, { onUnknown, result, extend, fold });
539
+ handleDirective(atRule, { onUnknown, printWarnings, result, extend, fold });
291
540
  },
292
- OnceExit() {
541
+ OnceExit(root) {
542
+ expandLeftovers(root, { onUnknown, printWarnings, result, extend, fold });
293
543
  if (fold.length === 0) return;
294
544
  const ordered = sortFoldBySourceOrder(fold);
295
545
  const first = ordered[0];
@@ -305,4 +555,4 @@ var navePlugin = (options = {}) => {
305
555
  navePlugin.postcss = true;
306
556
  var postcss_default = navePlugin;
307
557
 
308
- export { postcss_default as default, navePlugin };
558
+ export { postcss_default as default, isOrderWarning, navePlugin };
@@ -475,6 +475,8 @@
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));
478
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));
479
481
  --nave-color-feedback-danger: light-dark(oklch(0.47 0.1455 15.02), oklch(0.835 0.0661 15.02));
480
482
  --nave-color-feedback-danger-foreground: light-dark(oklch(0.47 0.1455 15.02), oklch(0.835 0.0661 15.02));
@@ -1,4 +1,4 @@
1
- import { A as AtomName } from './atom-names-2OreuBx9.js';
1
+ import { A as AtomName } from './atom-names-B8Ud-7zD.js';
2
2
 
3
3
  /**
4
4
  * The options that choose which atoms the Vite plugin ships, and their validation. A value a
@@ -83,4 +83,5 @@ declare function resolveUsedOptions(options: UsedAtomOptions): ResolvedUsedOptio
83
83
  */
84
84
  declare function keptAtoms(options: ResolvedUsedOptions): string[];
85
85
 
86
- export { type ResolvedUsedOptions as R, type UsedAtomOptions as U, assertOptions as a, keptAtoms as k, resolveUsedOptions as r };
86
+ export { assertOptions as a, keptAtoms as k, resolveUsedOptions as r };
87
+ export type { ResolvedUsedOptions as R, UsedAtomOptions as U };