praxis-kit 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,159 +1,45 @@
1
- import { Except, RequireAtLeastOne, Simplify } from 'type-fest';
1
+ import { Diagnostics } from '../_shared/diagnostics.js';
2
+ import { RequireAtLeastOne, Simplify } from 'type-fest';
2
3
 
3
4
  type StringMap<T = unknown> = Record<string, T>;
4
5
  type AnyRecord = StringMap<unknown>;
6
+ type EmptyRecord = Record<never, never>;
5
7
 
6
8
  type IntrinsicTag = keyof HTMLElementTagNameMap;
7
9
 
8
10
  type Booleanish = boolean | 'true' | 'false';
9
11
  type ClassName = string | string[];
10
- type EmptyRecord = Record<never, never>;
11
12
  type NonEmptyArray<T> = [T, ...T[]];
12
13
  type Numberish = number | `${number}`;
13
14
  type Primitive = string | number | boolean;
14
15
  type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
15
16
 
16
- declare enum DiagnosticCategory {
17
- Contract = 0,
18
- HTML = 1,
19
- ARIA = 2,
20
- Composition = 3,
21
- Rendering = 4,
22
- Accessibility = 5,
23
- Performance = 6,
24
- Internal = 7,
25
- Deprecation = 8,
26
- Lint = 9
27
- }
28
-
29
- declare enum DiagnosticCode {
30
- MissingRequiredChild = "COMP1001",
31
- InvalidParent = "COMP1002",
32
- InvalidChild = "COMP1003",
33
- UnexpectedChild = "COMP1004",
34
- AmbiguousChild = "COMP1005",
35
- CardinalityMin = "COMP1006",
36
- CardinalityMax = "COMP1007",
37
- PositionViolation = "COMP1008",
38
- AllowedAsViolation = "COMP1009",
39
- SlotExclusive = "SLOT1001",
40
- SlotSingleChild = "SLOT1002",
41
- SlotDiscardedChildren = "SLOT1003",
42
- SlotRenderFn = "SLOT1004",
43
- MissingAriaRelationship = "ARIA2001",
44
- AriaViolation = "ARIA2002",
45
- AriaAttributeInvalid = "ARIA2003",
46
- AriaMissingLiveRegion = "ARIA2004",
47
- AriaMissingAtomic = "ARIA2005",
48
- AriaRelevantInvalidToken = "ARIA2006",
49
- AriaRelevantSuperseded = "ARIA2007",
50
- AriaInvalidRole = "ARIA2008",
51
- AriaMissingAccessibleName = "ARIA2009",
52
- AriaAttributeOnPresentational = "ARIA2010",
53
- AriaHiddenOnFocusable = "ARIA2011",
54
- AriaRequiredProperty = "ARIA2012",
55
- AriaInvalidAttributeValue = "ARIA2013",
56
- AriaRedundantLevelAttribute = "ARIA2014",
57
- InvalidHeadingHierarchy = "HTML3001",
58
- HtmlEmptyRole = "HTML3002",
59
- HtmlImplicitRoleRedundant = "HTML3003",
60
- HtmlImplicitRoleOverride = "HTML3004",
61
- HtmlStandaloneRegionOverride = "HTML3005",
62
- HtmlLandmarkRoleOverride = "HTML3006",
63
- HtmlInvalidChild = "HTML3007",
64
- InvalidRenderingTarget = "RENDER4001",
65
- LintDeadCompoundKey = "LINT5001",
66
- LintDeadCompoundValue = "LINT5002",
67
- LintDeadCompoundNonLiteral = "LINT5003",
68
- LintMissingStrict = "LINT5004",
69
- LintInvalidDefaultKey = "LINT5005",
70
- LintInvalidDefaultValue = "LINT5006",
71
- LintInvalidDefaultNonLiteral = "LINT5007",
72
- LintNegativeMin = "LINT5008",
73
- LintNegativeMax = "LINT5009",
74
- LintMaxLessThanMin = "LINT5010",
75
- LintZeroMax = "LINT5011",
76
- LintMultipleFirst = "LINT5012",
77
- LintMultipleLast = "LINT5013",
78
- LintMinSumExceedsCapacity = "LINT5014",
79
- LintCardinalityViolation = "LINT5015",
80
- LintAriaTagOverride = "LINT5016",
81
- ContractUnknownVariantDim = "COMP1010",
82
- ContractUnknownVariantValue = "COMP1011",
83
- ContractUnknownRecipeKey = "COMP1012",
84
- ContractInvalidVariantValue = "COMP1013",
85
- TailwindMultipleDisplayProps = "CSS6001",
86
- TailwindReservedLayoutLiteral = "CSS6002",
87
- TailwindDeadVariantClass = "CSS6003",
88
- PluginInvalidShape = "PLUGIN7001",
89
- PluginPipelineReturnType = "PLUGIN7002",
90
- InternalError = "INTERNAL9000"
91
- }
17
+ type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
92
18
 
93
- interface SourcePosition {
94
- line: number;
95
- col: number;
96
- }
97
- interface SourceLocation {
98
- file: string;
99
- start: SourcePosition;
100
- end?: SourcePosition;
101
- }
19
+ type VariantValue = string | string[];
102
20
 
103
- declare enum Severity {
104
- Debug = 0,
105
- Info = 1,
106
- Warning = 2,
107
- Error = 3,
108
- Fatal = 4
109
- }
21
+ type VariantStates<K extends string = string> = Record<K, VariantValue>;
110
22
 
111
- interface DiagnosticSuggestion {
112
- title: string;
113
- description?: string;
114
- fix?: string;
115
- }
23
+ type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
116
24
 
117
- type Context = AnyRecord;
118
- type Metadata = AnyRecord;
119
- interface Diagnostic {
120
- code: DiagnosticCode;
121
- severity: Severity;
122
- category: DiagnosticCategory;
123
- message: string;
124
- rationale?: string;
125
- component?: string;
126
- contract?: string;
127
- location?: SourceLocation;
128
- suggestions?: DiagnosticSuggestion[];
129
- context?: Context;
130
- metadata?: Metadata;
131
- }
25
+ type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
132
26
 
133
- declare enum Enforcement {
134
- Ignore = 0,
135
- Report = 1,
136
- Throw = 2
137
- }
138
- interface DiagnosticPolicy {
139
- resolve(diagnostic: Diagnostic): Enforcement;
140
- }
27
+ /**
28
+ * A partial selection of variant states authored at factory definition time.
29
+ *
30
+ * Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
31
+ * resolve the union at constraint-check time without deferred conditional types.
32
+ */
33
+ type VariantSelection$1<V extends VariantMap> = {
34
+ [K in keyof V]?: keyof V[K];
35
+ };
141
36
 
142
- interface DiagnosticReporter {
143
- report(diagnostic: Diagnostic): void;
144
- }
37
+ type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
38
+ type DefaultVariants<V extends VariantMap> = {
39
+ [K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
40
+ };
145
41
 
146
- type DiagnosticInput = Except<Diagnostic, 'severity'>;
147
- declare class Diagnostics {
148
- private readonly reporter;
149
- private readonly policy;
150
- readonly active: boolean;
151
- constructor(reporter: DiagnosticReporter, policy?: DiagnosticPolicy);
152
- report(diagnostic: Diagnostic): Diagnostic;
153
- warn(input: DiagnosticInput): Diagnostic;
154
- error(input: DiagnosticInput): Diagnostic;
155
- info(input: DiagnosticInput): Diagnostic;
156
- }
42
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection$1<TVariants>;
157
43
 
158
44
  type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
159
45
  type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
@@ -178,26 +64,6 @@ interface CVAVariants<V extends VariantMap> {
178
64
  variants?: V;
179
65
  }
180
66
 
181
- type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
182
- type VariantValue = string | string[];
183
- type VariantStates<K extends string = string> = Record<K, VariantValue>;
184
- type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
185
- type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
186
- /**
187
- * A partial selection of variant states authored at factory definition time.
188
- *
189
- * Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
190
- * resolve the union at constraint-check time without deferred conditional types.
191
- */
192
- type VariantSelection$1<V extends VariantMap> = {
193
- [K in keyof V]?: keyof V[K];
194
- };
195
- type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
196
- type DefaultVariants<V extends VariantMap> = {
197
- [K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
198
- };
199
- type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection$1<TVariants>;
200
-
201
67
  interface BaseClassOptions {
202
68
  baseClassName?: ClassName;
203
69
  }
@@ -287,7 +153,7 @@ type ClassifiedToken = Simplify<LayoutToken | ConditionalToken | GapToken | Util
287
153
  type VariantSelection = Record<string, string>;
288
154
  type CompoundVariant = {
289
155
  class?: unknown;
290
- } & Record<string, unknown>;
156
+ } & AnyRecord;
291
157
 
292
158
  /**
293
159
  * Layout-aware class pipeline for Tailwind CSS utility class strings.
@@ -184,118 +184,6 @@ var iterate = Object.freeze({
184
184
  values
185
185
  });
186
186
 
187
- // ../../lib/diagnostics/src/category.ts
188
- var DiagnosticCategory = /* @__PURE__ */ ((DiagnosticCategory2) => {
189
- DiagnosticCategory2[DiagnosticCategory2["Contract"] = 0] = "Contract";
190
- DiagnosticCategory2[DiagnosticCategory2["HTML"] = 1] = "HTML";
191
- DiagnosticCategory2[DiagnosticCategory2["ARIA"] = 2] = "ARIA";
192
- DiagnosticCategory2[DiagnosticCategory2["Composition"] = 3] = "Composition";
193
- DiagnosticCategory2[DiagnosticCategory2["Rendering"] = 4] = "Rendering";
194
- DiagnosticCategory2[DiagnosticCategory2["Accessibility"] = 5] = "Accessibility";
195
- DiagnosticCategory2[DiagnosticCategory2["Performance"] = 6] = "Performance";
196
- DiagnosticCategory2[DiagnosticCategory2["Internal"] = 7] = "Internal";
197
- DiagnosticCategory2[DiagnosticCategory2["Deprecation"] = 8] = "Deprecation";
198
- DiagnosticCategory2[DiagnosticCategory2["Lint"] = 9] = "Lint";
199
- return DiagnosticCategory2;
200
- })(DiagnosticCategory || {});
201
-
202
- // ../../lib/diagnostics/src/error.ts
203
- var PraxisError = class extends Error {
204
- diagnostic;
205
- constructor(diagnostic) {
206
- super(diagnostic.message);
207
- this.name = "PraxisError";
208
- this.diagnostic = diagnostic;
209
- }
210
- };
211
-
212
- // ../../lib/diagnostics/src/severity.ts
213
- var Severity = /* @__PURE__ */ ((Severity2) => {
214
- Severity2[Severity2["Debug"] = 0] = "Debug";
215
- Severity2[Severity2["Info"] = 1] = "Info";
216
- Severity2[Severity2["Warning"] = 2] = "Warning";
217
- Severity2[Severity2["Error"] = 3] = "Error";
218
- Severity2[Severity2["Fatal"] = 4] = "Fatal";
219
- return Severity2;
220
- })(Severity || {});
221
-
222
- // ../../lib/diagnostics/src/policy.ts
223
- var DefaultPolicy = class {
224
- reportThreshold;
225
- throwThreshold;
226
- constructor({
227
- reportThreshold = 1 /* Info */,
228
- throwThreshold = 4 /* Fatal */
229
- } = {}) {
230
- this.reportThreshold = reportThreshold;
231
- this.throwThreshold = throwThreshold;
232
- }
233
- resolve(diagnostic) {
234
- if (diagnostic.severity >= this.throwThreshold) return 2 /* Throw */;
235
- if (diagnostic.severity >= this.reportThreshold) return 1 /* Report */;
236
- return 0 /* Ignore */;
237
- }
238
- };
239
-
240
- // ../../lib/diagnostics/src/diagnostics.ts
241
- var Diagnostics = class {
242
- reporter;
243
- policy;
244
- // Pre-computed at construction time: true if Warning-level diagnostics are not ignored.
245
- active;
246
- constructor(reporter, policy = new DefaultPolicy()) {
247
- this.reporter = reporter;
248
- this.policy = policy;
249
- this.active = policy.resolve({ severity: 2 /* Warning */ }) !== 0 /* Ignore */;
250
- }
251
- report(diagnostic) {
252
- const enforcement = this.policy.resolve(diagnostic);
253
- if (enforcement === 0 /* Ignore */) return diagnostic;
254
- if (enforcement === 2 /* Throw */) throw new PraxisError(diagnostic);
255
- this.reporter.report(diagnostic);
256
- return diagnostic;
257
- }
258
- warn(input) {
259
- return this.report({ ...input, severity: 2 /* Warning */ });
260
- }
261
- error(input) {
262
- return this.report({ ...input, severity: 3 /* Error */ });
263
- }
264
- info(input) {
265
- return this.report({ ...input, severity: 1 /* Info */ });
266
- }
267
- };
268
-
269
- // ../../lib/diagnostics/src/formatter.ts
270
- function formatDiagnostic(diagnostic) {
271
- const level = Severity[diagnostic.severity];
272
- const category = DiagnosticCategory[diagnostic.category];
273
- const prefix = category !== void 0 ? `[${category}] ` : "";
274
- return `${level} ${diagnostic.code}: ${prefix}${diagnostic.message}`;
275
- }
276
-
277
- // ../../lib/diagnostics/src/console-reporter.ts
278
- var ConsoleReporter = class {
279
- report(diagnostic) {
280
- const message = formatDiagnostic(diagnostic);
281
- switch (diagnostic.severity) {
282
- case 0 /* Debug */:
283
- console.debug(message);
284
- break;
285
- case 1 /* Info */:
286
- console.info(message);
287
- break;
288
- case 2 /* Warning */:
289
- console.warn(message);
290
- break;
291
- case 3 /* Error */:
292
- case 4 /* Fatal */:
293
- console.error(message);
294
- break;
295
- }
296
- }
297
- };
298
-
299
187
  // ../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.mjs
300
188
  import { clsx as clsx2 } from "clsx";
301
189
  var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
@@ -649,26 +537,30 @@ var LayoutState = class {
649
537
  }
650
538
  };
651
539
 
540
+ // ../../lib/tailwind/src/create-tailwind-pipeline.ts
541
+ import { ConsoleReporter, Diagnostics, DefaultPolicy, Severity } from "../_shared/diagnostics.js";
542
+
652
543
  // ../../lib/tailwind/src/diagnostics.ts
544
+ import { DiagnosticCategory, DiagnosticCode } from "../_shared/diagnostics.js";
653
545
  var TailwindDiagnostics = {
654
546
  multipleDisplayProps(active) {
655
547
  return {
656
- code: "CSS6001" /* TailwindMultipleDisplayProps */,
657
- category: 0 /* Contract */,
548
+ code: DiagnosticCode.TailwindMultipleDisplayProps,
549
+ category: DiagnosticCategory.Contract,
658
550
  message: `[createTailwindPipeline] Multiple display props set (${active.join(", ")}); "${active[0]}" takes precedence.`
659
551
  };
660
552
  },
661
553
  reservedLayoutLiteral(reserved) {
662
554
  return {
663
- code: "CSS6002" /* TailwindReservedLayoutLiteral */,
664
- category: 0 /* Contract */,
555
+ code: DiagnosticCode.TailwindReservedLayoutLiteral,
556
+ category: DiagnosticCategory.Contract,
665
557
  message: `[createTailwindPipeline] Reserved display class(es) ${reserved.map((r) => `"${r}"`).join(", ")} found in resolved classes. The display mode is controlled by the display props (flex, inline-flex, grid, block, hidden, etc.), not by class strings.`
666
558
  };
667
559
  },
668
560
  deadVariantClass(dim, value, mode, classStr) {
669
561
  return {
670
- code: "CSS6003" /* TailwindDeadVariantClass */,
671
- category: 0 /* Contract */,
562
+ code: DiagnosticCode.TailwindDeadVariantClass,
563
+ category: DiagnosticCategory.Contract,
672
564
  message: `[createTailwindPipeline] Variant "${dim}=${value}" contributes only classes stripped under layout mode "${mode}" ("${classStr}") \u2014 it produces nothing in this mode.`
673
565
  };
674
566
  }
@@ -678,7 +570,7 @@ var TailwindDiagnostics = {
678
570
  var DEV = process.env.NODE_ENV !== "production";
679
571
  var devDiagnostics = new Diagnostics(
680
572
  new ConsoleReporter(),
681
- new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 4 /* Fatal */ })
573
+ new DefaultPolicy({ reportThreshold: Severity.Warning, throwThreshold: Severity.Fatal })
682
574
  );
683
575
  var classifier = new ClassClassifier();
684
576
  var evaluator = new DependencyEvaluator(defaultDependencyRules);
@@ -82,6 +82,16 @@ declare enum DiagnosticCode {
82
82
  InternalError = "INTERNAL9000"
83
83
  }
84
84
 
85
+ declare enum Severity$1 {
86
+ Debug = 0,
87
+ Info = 1,
88
+ Warning = 2,
89
+ Error = 3,
90
+ Fatal = 4
91
+ }
92
+
93
+ type Context = AnyRecord;
94
+ type Metadata = AnyRecord;
85
95
  interface SourcePosition {
86
96
  line: number;
87
97
  col: number;
@@ -91,23 +101,11 @@ interface SourceLocation {
91
101
  start: SourcePosition;
92
102
  end?: SourcePosition;
93
103
  }
94
-
95
- declare enum Severity$1 {
96
- Debug = 0,
97
- Info = 1,
98
- Warning = 2,
99
- Error = 3,
100
- Fatal = 4
101
- }
102
-
103
104
  interface DiagnosticSuggestion {
104
105
  title: string;
105
106
  description?: string;
106
107
  fix?: string;
107
108
  }
108
-
109
- type Context = AnyRecord;
110
- type Metadata = AnyRecord;
111
109
  interface Diagnostic$1 {
112
110
  code: DiagnosticCode;
113
111
  severity: Severity$1;