praxis-kit 3.1.1 → 4.0.1

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.
@@ -241697,17 +241697,17 @@ Node text: ${this.#forgottenText}`;
241697
241697
  }
241698
241698
  });
241699
241699
 
241700
- // ../codemod/src/index.ts
241700
+ // ../../tooling/codemod/src/index.ts
241701
241701
  import { fileURLToPath } from "url";
241702
241702
 
241703
- // ../codemod/src/cli/usage.ts
241703
+ // ../../tooling/codemod/src/cli/usage.ts
241704
241704
  import { readFileSync } from "fs";
241705
241705
  var usage = readFileSync(new URL("./usage.md", import.meta.url), "utf8");
241706
241706
  function printUsage() {
241707
241707
  console.error(usage);
241708
241708
  }
241709
241709
 
241710
- // ../codemod/src/cli/build-project.ts
241710
+ // ../../tooling/codemod/src/cli/build-project.ts
241711
241711
  var import_ts_morph = __toESM(require_ts_morph(), 1);
241712
241712
  function buildProject(glob, tsconfig) {
241713
241713
  const project = tsconfig ? new import_ts_morph.Project({ tsConfigFilePath: tsconfig }) : new import_ts_morph.Project({ skipAddingFilesFromTsConfig: true });
@@ -241715,7 +241715,7 @@ function buildProject(glob, tsconfig) {
241715
241715
  return project;
241716
241716
  }
241717
241717
 
241718
- // ../codemod/src/cli/create-command.ts
241718
+ // ../../tooling/codemod/src/cli/create-command.ts
241719
241719
  function createCommand(command) {
241720
241720
  return (argv) => {
241721
241721
  const options = command.parse(argv);
@@ -241732,16 +241732,16 @@ function createCommand(command) {
241732
241732
  };
241733
241733
  }
241734
241734
 
241735
- // ../codemod/src/cli/parse-options.ts
241735
+ // ../../tooling/codemod/src/cli/parse-options.ts
241736
241736
  import { parseArgs } from "util";
241737
241737
 
241738
- // ../codemod/src/cli/constants.ts
241738
+ // ../../tooling/codemod/src/cli/constants.ts
241739
241739
  var DEFAULT_FROM = "createPolymorphicComponent";
241740
241740
  var DEFAULT_TO = "createContractComponent";
241741
241741
  var TS_ONLY_GLOB = "**/*.{ts,tsx}";
241742
241742
  var ALL_SOURCE_GLOB = "**/*.{ts,tsx,cts,mts,js,jsx,cjs,mjs}";
241743
241743
 
241744
- // ../codemod/src/cli/options.ts
241744
+ // ../../tooling/codemod/src/cli/options.ts
241745
241745
  var sharedOptions = {
241746
241746
  "dry-run": { type: "boolean", default: false },
241747
241747
  verbose: { type: "boolean", default: false },
@@ -241755,7 +241755,7 @@ var tsconfigOption = {
241755
241755
  tsconfig: { type: "string" }
241756
241756
  };
241757
241757
 
241758
- // ../codemod/src/cli/parse-options.ts
241758
+ // ../../tooling/codemod/src/cli/parse-options.ts
241759
241759
  function parseOptions(argv, options) {
241760
241760
  return parseArgs({ args: argv, options, strict: true }).values;
241761
241761
  }
@@ -241789,34 +241789,34 @@ var parseMigrateOptions = (argv) => parseRenameLikeOptions(argv, ALL_SOURCE_GLOB
241789
241789
  var parseRenameOptions = (argv) => parseRenameLikeOptions(argv, TS_ONLY_GLOB);
241790
241790
  var parseMigratePathsOptions = (argv) => parseBaseOptions(argv, ALL_SOURCE_GLOB);
241791
241791
 
241792
- // ../codemod/src/utils.ts
241792
+ // ../../tooling/codemod/src/utils.ts
241793
241793
  function dryRunSuffix(isDryRun) {
241794
241794
  return isDryRun ? " (dry run \u2014 no files written)" : "";
241795
241795
  }
241796
241796
 
241797
- // ../codemod/src/transforms/migrate-paths.ts
241797
+ // ../../tooling/codemod/src/transforms/migrate-paths.ts
241798
241798
  var import_ts_morph2 = __toESM(require_ts_morph(), 1);
241799
241799
 
241800
- // ../codemod/src/transforms/constants.ts
241800
+ // ../../tooling/codemod/src/transforms/constants.ts
241801
241801
  var SPECIAL_CASES = {
241802
241802
  "@praxis-kit/eslint-plugin": "praxis-kit/eslint"
241803
241803
  };
241804
241804
  var PRAXIS_PACKAGE = /^(?:@praxis-kit|praxis-kit)\//;
241805
241805
 
241806
- // ../codemod/src/transforms/resolve-replacement.ts
241806
+ // ../../tooling/codemod/src/transforms/resolve-replacement.ts
241807
241807
  function resolveReplacement(specifier) {
241808
241808
  if (!specifier.startsWith("@praxis-kit/")) return void 0;
241809
241809
  return SPECIAL_CASES[specifier] ?? specifier.replace("@praxis-kit/", "praxis-kit/");
241810
241810
  }
241811
241811
 
241812
- // ../codemod/src/transforms/utils.ts
241812
+ // ../../tooling/codemod/src/transforms/utils.ts
241813
241813
  function logRewrite(isVerbose, isDryRun, message) {
241814
241814
  if (!isVerbose) return;
241815
241815
  const prefix = isDryRun ? "[dry-run] " : "";
241816
241816
  console.log(prefix + message);
241817
241817
  }
241818
241818
 
241819
- // ../codemod/src/transforms/migrate-paths.ts
241819
+ // ../../tooling/codemod/src/transforms/migrate-paths.ts
241820
241820
  function rewriteModuleSpecifier(decl, options, filePath) {
241821
241821
  const specifier = decl.getModuleSpecifierValue();
241822
241822
  if (specifier === void 0) return 0;
@@ -241874,7 +241874,7 @@ function migratePathsInProject(project, options) {
241874
241874
  };
241875
241875
  }
241876
241876
 
241877
- // ../codemod/src/transforms/rename.ts
241877
+ // ../../tooling/codemod/src/transforms/rename.ts
241878
241878
  var import_ts_morph3 = __toESM(require_ts_morph(), 1);
241879
241879
  function renameInProject(project, options) {
241880
241880
  const { from, to, isDryRun, isVerbose } = options;
@@ -241912,7 +241912,7 @@ function renameInProject(project, options) {
241912
241912
  };
241913
241913
  }
241914
241914
 
241915
- // ../codemod/src/transforms/migrate.ts
241915
+ // ../../tooling/codemod/src/transforms/migrate.ts
241916
241916
  function migrate(project, options) {
241917
241917
  const renames = renameInProject(project, options);
241918
241918
  const paths = migratePathsInProject(project, options);
@@ -241924,25 +241924,25 @@ function migrate(project, options) {
241924
241924
  };
241925
241925
  }
241926
241926
 
241927
- // ../codemod/src/commands/migrate.ts
241927
+ // ../../tooling/codemod/src/commands/migrate.ts
241928
241928
  var runMigrate = createCommand({
241929
241929
  parse: parseMigrateOptions,
241930
241930
  execute: migrate
241931
241931
  });
241932
241932
 
241933
- // ../codemod/src/commands/migrate-paths.ts
241933
+ // ../../tooling/codemod/src/commands/migrate-paths.ts
241934
241934
  var runMigratePaths = createCommand({
241935
241935
  parse: parseMigratePathsOptions,
241936
241936
  execute: migratePathsInProject
241937
241937
  });
241938
241938
 
241939
- // ../codemod/src/commands/rename.ts
241939
+ // ../../tooling/codemod/src/commands/rename.ts
241940
241940
  var runRename = createCommand({
241941
241941
  parse: parseRenameOptions,
241942
241942
  execute: renameInProject
241943
241943
  });
241944
241944
 
241945
- // ../codemod/src/index.ts
241945
+ // ../../tooling/codemod/src/index.ts
241946
241946
  function main() {
241947
241947
  const [, , command, ...rest] = process.argv;
241948
241948
  if (!command || command === "--help" || command === "-h") {
@@ -1,6 +1,7 @@
1
- import { RequireAtLeastOne, Simplify, ReadonlyDeep } from 'type-fest';
1
+ import { Except, RequireAtLeastOne, Simplify, ReadonlyDeep } from 'type-fest';
2
2
 
3
- type AnyRecord = Record<string, unknown>;
3
+ type StringMap<T = unknown> = Record<string, T>;
4
+ type AnyRecord = StringMap<unknown>;
4
5
 
5
6
  type IntrinsicTag = keyof HTMLElementTagNameMap;
6
7
 
@@ -9,32 +10,165 @@ type ElementType = IntrinsicTag | (string & {});
9
10
  declare const KNOWN_ARIA_ROLES: readonly ["alert", "alertdialog", "application", "article", "banner", "blockquote", "button", "caption", "cell", "checkbox", "code", "columnheader", "combobox", "complementary", "contentinfo", "definition", "deletion", "dialog", "document", "emphasis", "feed", "figure", "form", "generic", "grid", "gridcell", "group", "heading", "img", "insertion", "link", "list", "listbox", "listitem", "log", "main", "marquee", "math", "menu", "menubar", "menuitem", "menuitemcheckbox", "menuitemradio", "meter", "navigation", "none", "note", "option", "paragraph", "presentation", "progressbar", "radio", "radiogroup", "region", "row", "rowgroup", "rowheader", "scrollbar", "search", "searchbox", "separator", "slider", "spinbutton", "status", "strong", "subscript", "superscript", "switch", "tab", "table", "tablist", "tabpanel", "term", "textbox", "time", "timer", "toolbar", "tooltip", "tree", "treegrid", "treeitem"];
10
11
  type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
11
12
 
12
- type AriaRole = KnownAriaRole | (string & {});
13
-
14
13
  type Booleanish = boolean | 'true' | 'false';
15
-
16
14
  type ClassName = string | string[];
17
-
18
15
  type EmptyRecord = Record<never, never>;
19
-
16
+ type NonEmptyArray<T> = [T, ...T[]];
17
+ type Numberish = number | `${number}`;
18
+ type Primitive = string | number | boolean;
19
+ type AriaRole = KnownAriaRole | (string & {});
20
20
  type IntrinsicProps = AnyRecord & {
21
21
  role?: AriaRole;
22
22
  };
23
+ type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
23
24
 
24
- type NonEmptyArray<T> = [T, ...T[]];
25
+ declare enum DiagnosticCategory {
26
+ Contract = 0,
27
+ HTML = 1,
28
+ ARIA = 2,
29
+ Composition = 3,
30
+ Rendering = 4,
31
+ Accessibility = 5,
32
+ Performance = 6,
33
+ Internal = 7,
34
+ Deprecation = 8,
35
+ Lint = 9
36
+ }
25
37
 
26
- type Numberish = number | `${number}`;
38
+ declare enum DiagnosticCode {
39
+ MissingRequiredChild = "COMP1001",
40
+ InvalidParent = "COMP1002",
41
+ InvalidChild = "COMP1003",
42
+ UnexpectedChild = "COMP1004",
43
+ AmbiguousChild = "COMP1005",
44
+ CardinalityMin = "COMP1006",
45
+ CardinalityMax = "COMP1007",
46
+ PositionViolation = "COMP1008",
47
+ AllowedAsViolation = "COMP1009",
48
+ SlotExclusive = "SLOT1001",
49
+ SlotSingleChild = "SLOT1002",
50
+ SlotDiscardedChildren = "SLOT1003",
51
+ SlotRenderFn = "SLOT1004",
52
+ MissingAriaRelationship = "ARIA2001",
53
+ AriaViolation = "ARIA2002",
54
+ AriaAttributeInvalid = "ARIA2003",
55
+ AriaMissingLiveRegion = "ARIA2004",
56
+ AriaMissingAtomic = "ARIA2005",
57
+ AriaRelevantInvalidToken = "ARIA2006",
58
+ AriaRelevantSuperseded = "ARIA2007",
59
+ AriaInvalidRole = "ARIA2008",
60
+ AriaMissingAccessibleName = "ARIA2009",
61
+ AriaAttributeOnPresentational = "ARIA2010",
62
+ AriaHiddenOnFocusable = "ARIA2011",
63
+ AriaRequiredProperty = "ARIA2012",
64
+ AriaInvalidAttributeValue = "ARIA2013",
65
+ AriaRedundantLevelAttribute = "ARIA2014",
66
+ InvalidHeadingHierarchy = "HTML3001",
67
+ HtmlEmptyRole = "HTML3002",
68
+ HtmlImplicitRoleRedundant = "HTML3003",
69
+ HtmlImplicitRoleOverride = "HTML3004",
70
+ HtmlStandaloneRegionOverride = "HTML3005",
71
+ HtmlLandmarkRoleOverride = "HTML3006",
72
+ HtmlInvalidChild = "HTML3007",
73
+ InvalidRenderingTarget = "RENDER4001",
74
+ LintDeadCompoundKey = "LINT5001",
75
+ LintDeadCompoundValue = "LINT5002",
76
+ LintDeadCompoundNonLiteral = "LINT5003",
77
+ LintMissingStrict = "LINT5004",
78
+ LintInvalidDefaultKey = "LINT5005",
79
+ LintInvalidDefaultValue = "LINT5006",
80
+ LintInvalidDefaultNonLiteral = "LINT5007",
81
+ LintNegativeMin = "LINT5008",
82
+ LintNegativeMax = "LINT5009",
83
+ LintMaxLessThanMin = "LINT5010",
84
+ LintZeroMax = "LINT5011",
85
+ LintMultipleFirst = "LINT5012",
86
+ LintMultipleLast = "LINT5013",
87
+ LintMinSumExceedsCapacity = "LINT5014",
88
+ LintCardinalityViolation = "LINT5015",
89
+ LintAriaTagOverride = "LINT5016",
90
+ ContractUnknownVariantDim = "COMP1010",
91
+ ContractUnknownVariantValue = "COMP1011",
92
+ ContractUnknownRecipeKey = "COMP1012",
93
+ ContractInvalidVariantValue = "COMP1013",
94
+ TailwindMultipleDisplayProps = "CSS6001",
95
+ TailwindReservedLayoutLiteral = "CSS6002",
96
+ TailwindDeadVariantClass = "CSS6003",
97
+ PluginInvalidShape = "PLUGIN7001",
98
+ PluginPipelineReturnType = "PLUGIN7002",
99
+ InternalError = "INTERNAL9000"
100
+ }
27
101
 
28
- type Primitive = string | number | boolean;
102
+ interface SourcePosition {
103
+ line: number;
104
+ col: number;
105
+ }
106
+ interface SourceLocation {
107
+ file: string;
108
+ start: SourcePosition;
109
+ end?: SourcePosition;
110
+ }
29
111
 
30
- type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
112
+ declare enum Severity$1 {
113
+ Debug = 0,
114
+ Info = 1,
115
+ Warning = 2,
116
+ Error = 3,
117
+ Fatal = 4
118
+ }
119
+
120
+ interface DiagnosticSuggestion {
121
+ title: string;
122
+ description?: string;
123
+ fix?: string;
124
+ }
31
125
 
32
- type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
126
+ type Context = AnyRecord;
127
+ type Metadata = AnyRecord;
128
+ interface Diagnostic {
129
+ code: DiagnosticCode;
130
+ severity: Severity$1;
131
+ category: DiagnosticCategory;
132
+ message: string;
133
+ rationale?: string;
134
+ component?: string;
135
+ contract?: string;
136
+ location?: SourceLocation;
137
+ suggestions?: DiagnosticSuggestion[];
138
+ context?: Context;
139
+ metadata?: Metadata;
140
+ }
33
141
 
34
- type CardinalityInput = {
35
- min?: number;
36
- max?: number;
142
+ declare enum Enforcement {
143
+ Ignore = 0,
144
+ Report = 1,
145
+ Throw = 2
146
+ }
147
+ interface DiagnosticPolicy {
148
+ resolve(diagnostic: Diagnostic): Enforcement;
149
+ }
150
+
151
+ interface DiagnosticReporter {
152
+ report(diagnostic: Diagnostic): void;
153
+ }
154
+
155
+ type DiagnosticInput = Except<Diagnostic, 'severity'>;
156
+ declare class Diagnostics {
157
+ private readonly reporter;
158
+ private readonly policy;
159
+ readonly active: boolean;
160
+ constructor(reporter: DiagnosticReporter, policy?: DiagnosticPolicy);
161
+ report(diagnostic: Diagnostic): Diagnostic;
162
+ warn(input: DiagnosticInput): Diagnostic;
163
+ error(input: DiagnosticInput): Diagnostic;
164
+ info(input: DiagnosticInput): Diagnostic;
165
+ }
166
+
167
+ type MinMax = {
168
+ min: number;
169
+ max: number;
37
170
  };
171
+ type CardinalityInput = Partial<MinMax>;
38
172
 
39
173
  type ChildRuleMatch<T, U extends T = T> = (child: T) => child is U;
40
174
 
@@ -57,16 +191,6 @@ type ValidResult = {
57
191
  valid: true;
58
192
  };
59
193
 
60
- type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
61
-
62
- type VariantValue$1 = string | string[];
63
-
64
- type VariantStates<K extends string = string> = Record<K, VariantValue$1>;
65
-
66
- type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
67
-
68
- type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
69
-
70
194
  type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
71
195
  type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
72
196
  type CompoundVariantConditions<V extends VariantMap> = Simplify<{
@@ -75,18 +199,13 @@ type CompoundVariantConditions<V extends VariantMap> = Simplify<{
75
199
  type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
76
200
  type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
77
201
  type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
78
- class: VariantValue$1;
202
+ class: VariantValue;
79
203
  };
80
204
 
81
205
  interface CVACompounds<V extends VariantMap> {
82
206
  compoundVariants?: readonly CompoundVariant<V>[];
83
207
  }
84
208
 
85
- type VariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
86
- type DefaultVariants<V extends VariantMap> = {
87
- [K in keyof V]?: VariantValue<keyof V[K] & string>;
88
- };
89
-
90
209
  interface CVADefaults<V extends VariantMap> {
91
210
  defaultVariants?: DefaultVariants<V>;
92
211
  }
@@ -95,6 +214,11 @@ interface CVAVariants<V extends VariantMap> {
95
214
  variants?: V;
96
215
  }
97
216
 
217
+ type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
218
+ type VariantValue = string | string[];
219
+ type VariantStates<K extends string = string> = Record<K, VariantValue>;
220
+ type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
221
+ type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
98
222
  /**
99
223
  * A partial selection of variant states authored at factory definition time.
100
224
  *
@@ -104,7 +228,10 @@ interface CVAVariants<V extends VariantMap> {
104
228
  type VariantSelection<V extends VariantMap> = {
105
229
  [K in keyof V]?: keyof V[K];
106
230
  };
107
-
231
+ type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
232
+ type DefaultVariants<V extends VariantMap> = {
233
+ [K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
234
+ };
108
235
  /**
109
236
  * A static, immutable map of named presets to partial variant selections.
110
237
  *
@@ -112,7 +239,6 @@ type VariantSelection<V extends VariantMap> = {
112
239
  * avoiding the need to repeat variant combinations at each call site.
113
240
  */
114
241
  type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
115
-
116
242
  type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
117
243
 
118
244
  interface BaseClassOptions {
@@ -145,7 +271,7 @@ type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
145
271
  readonly _pluginProps?: TProps;
146
272
  }>;
147
273
 
148
- type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, strict: StrictMode) => ClassPlugin<TProps>;
274
+ type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, diagnostics: Diagnostics) => ClassPlugin<TProps>;
149
275
 
150
276
  type AriaContext = {
151
277
  readonly tag: IntrinsicTag;
@@ -178,8 +304,9 @@ type Severity = 'error' | 'warning' | (string & {});
178
304
  type AriaInvalidBase<M extends string = string> = {
179
305
  valid: false;
180
306
  severity: Severity;
181
- message: M;
307
+ message?: M;
182
308
  attribute?: string;
309
+ diagnostic?: DiagnosticInput;
183
310
  };
184
311
  type AriaInvalidWithFix<M extends string = string> = AriaInvalidBase<M> & {
185
312
  fixable: true;
@@ -196,11 +323,11 @@ type AriaRule<C extends AriaContext = AriaContext> = (context: C) => readonly Ar
196
323
  type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
197
324
 
198
325
  type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
199
- readonly strict?: StrictMode;
326
+ readonly diagnostics?: Diagnostics;
200
327
  readonly aria?: readonly AriaRule[];
201
328
  readonly children?: readonly ChildRuleInput[];
202
329
  readonly props?: readonly PropNormalizer[];
203
- /** Restricts the `as` prop to this set of tags. Violations route through strict mode. */
330
+ /** Restricts the `as` prop to this set of tags. Violations route through diagnostics. */
204
331
  readonly allowedAs?: readonly TAllowed[];
205
332
  };
206
333