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.
- package/dist/_shared/diagnostics.d.ts +209 -0
- package/dist/_shared/diagnostics.js +289 -0
- package/dist/{chunk-TJRHF6MS.js → chunk-LA6WGQA6.js} +1023 -822
- package/dist/codemod/index.js +23 -15
- package/dist/contract/index.d.ts +46 -173
- package/dist/eslint/index.js +21 -17
- package/dist/lit/index.d.ts +44 -173
- package/dist/lit/index.js +705 -598
- package/dist/preact/index.d.ts +47 -174
- package/dist/preact/index.js +1077 -886
- package/dist/react/index.d.ts +25 -11
- package/dist/react/index.js +21 -143
- package/dist/react/legacy.d.ts +4 -3
- package/dist/react/legacy.js +28 -147
- package/dist/{merge-refs-CEpa0zK1.d.ts → react-options-XrRof248.d.ts} +170 -255
- package/dist/solid/index.d.ts +47 -174
- package/dist/solid/index.js +630 -538
- package/dist/svelte/index.d.ts +57 -177
- package/dist/svelte/index.js +609 -534
- package/dist/tailwind/index.d.ts +23 -157
- package/dist/tailwind/index.js +11 -119
- package/dist/vite-plugin/index.d.ts +10 -12
- package/dist/vue/index.d.ts +47 -174
- package/dist/vue/index.js +969 -897
- package/dist/web/index.d.ts +45 -174
- package/dist/web/index.js +707 -594
- package/package.json +6 -6
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Except } from 'type-fest';
|
|
2
|
+
|
|
3
|
+
declare enum DiagnosticCategory {
|
|
4
|
+
Contract = 0,
|
|
5
|
+
HTML = 1,
|
|
6
|
+
ARIA = 2,
|
|
7
|
+
Composition = 3,
|
|
8
|
+
Rendering = 4,
|
|
9
|
+
Accessibility = 5,
|
|
10
|
+
Performance = 6,
|
|
11
|
+
Internal = 7,
|
|
12
|
+
Deprecation = 8,
|
|
13
|
+
Lint = 9
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare enum DiagnosticCode {
|
|
17
|
+
MissingRequiredChild = "COMP1001",
|
|
18
|
+
InvalidParent = "COMP1002",
|
|
19
|
+
InvalidChild = "COMP1003",
|
|
20
|
+
UnexpectedChild = "COMP1004",
|
|
21
|
+
AmbiguousChild = "COMP1005",
|
|
22
|
+
CardinalityMin = "COMP1006",
|
|
23
|
+
CardinalityMax = "COMP1007",
|
|
24
|
+
PositionViolation = "COMP1008",
|
|
25
|
+
AllowedAsViolation = "COMP1009",
|
|
26
|
+
SlotExclusive = "SLOT1001",
|
|
27
|
+
SlotSingleChild = "SLOT1002",
|
|
28
|
+
SlotDiscardedChildren = "SLOT1003",
|
|
29
|
+
SlotRenderFn = "SLOT1004",
|
|
30
|
+
MissingAriaRelationship = "ARIA2001",
|
|
31
|
+
AriaViolation = "ARIA2002",
|
|
32
|
+
AriaAttributeInvalid = "ARIA2003",
|
|
33
|
+
AriaMissingLiveRegion = "ARIA2004",
|
|
34
|
+
AriaMissingAtomic = "ARIA2005",
|
|
35
|
+
AriaRelevantInvalidToken = "ARIA2006",
|
|
36
|
+
AriaRelevantSuperseded = "ARIA2007",
|
|
37
|
+
AriaInvalidRole = "ARIA2008",
|
|
38
|
+
AriaMissingAccessibleName = "ARIA2009",
|
|
39
|
+
AriaAttributeOnPresentational = "ARIA2010",
|
|
40
|
+
AriaHiddenOnFocusable = "ARIA2011",
|
|
41
|
+
AriaRequiredProperty = "ARIA2012",
|
|
42
|
+
AriaInvalidAttributeValue = "ARIA2013",
|
|
43
|
+
AriaRedundantLevelAttribute = "ARIA2014",
|
|
44
|
+
InvalidHeadingHierarchy = "HTML3001",
|
|
45
|
+
HtmlEmptyRole = "HTML3002",
|
|
46
|
+
HtmlImplicitRoleRedundant = "HTML3003",
|
|
47
|
+
HtmlImplicitRoleOverride = "HTML3004",
|
|
48
|
+
HtmlStandaloneRegionOverride = "HTML3005",
|
|
49
|
+
HtmlLandmarkRoleOverride = "HTML3006",
|
|
50
|
+
HtmlInvalidChild = "HTML3007",
|
|
51
|
+
InvalidRenderingTarget = "RENDER4001",
|
|
52
|
+
LintDeadCompoundKey = "LINT5001",
|
|
53
|
+
LintDeadCompoundValue = "LINT5002",
|
|
54
|
+
LintDeadCompoundNonLiteral = "LINT5003",
|
|
55
|
+
LintMissingStrict = "LINT5004",
|
|
56
|
+
LintInvalidDefaultKey = "LINT5005",
|
|
57
|
+
LintInvalidDefaultValue = "LINT5006",
|
|
58
|
+
LintInvalidDefaultNonLiteral = "LINT5007",
|
|
59
|
+
LintNegativeMin = "LINT5008",
|
|
60
|
+
LintNegativeMax = "LINT5009",
|
|
61
|
+
LintMaxLessThanMin = "LINT5010",
|
|
62
|
+
LintZeroMax = "LINT5011",
|
|
63
|
+
LintMultipleFirst = "LINT5012",
|
|
64
|
+
LintMultipleLast = "LINT5013",
|
|
65
|
+
LintMinSumExceedsCapacity = "LINT5014",
|
|
66
|
+
LintCardinalityViolation = "LINT5015",
|
|
67
|
+
LintAriaTagOverride = "LINT5016",
|
|
68
|
+
ContractUnknownVariantDim = "COMP1010",
|
|
69
|
+
ContractUnknownVariantValue = "COMP1011",
|
|
70
|
+
ContractUnknownRecipeKey = "COMP1012",
|
|
71
|
+
ContractInvalidVariantValue = "COMP1013",
|
|
72
|
+
TailwindMultipleDisplayProps = "CSS6001",
|
|
73
|
+
TailwindReservedLayoutLiteral = "CSS6002",
|
|
74
|
+
TailwindDeadVariantClass = "CSS6003",
|
|
75
|
+
PluginInvalidShape = "PLUGIN7001",
|
|
76
|
+
PluginPipelineReturnType = "PLUGIN7002",
|
|
77
|
+
InternalError = "INTERNAL9000"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type StringMap<T = unknown> = Record<string, T>;
|
|
81
|
+
type AnyRecord = StringMap<unknown>;
|
|
82
|
+
|
|
83
|
+
declare enum Severity {
|
|
84
|
+
Debug = 0,
|
|
85
|
+
Info = 1,
|
|
86
|
+
Warning = 2,
|
|
87
|
+
Error = 3,
|
|
88
|
+
Fatal = 4
|
|
89
|
+
}
|
|
90
|
+
declare function isAtLeast(s: Severity, threshold: Severity): boolean;
|
|
91
|
+
|
|
92
|
+
type Context = AnyRecord;
|
|
93
|
+
type Metadata = AnyRecord;
|
|
94
|
+
interface SourcePosition {
|
|
95
|
+
line: number;
|
|
96
|
+
col: number;
|
|
97
|
+
}
|
|
98
|
+
interface SourceLocation {
|
|
99
|
+
file: string;
|
|
100
|
+
start: SourcePosition;
|
|
101
|
+
end?: SourcePosition;
|
|
102
|
+
}
|
|
103
|
+
interface DiagnosticSuggestion {
|
|
104
|
+
title: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
fix?: string;
|
|
107
|
+
}
|
|
108
|
+
interface Diagnostic {
|
|
109
|
+
code: DiagnosticCode;
|
|
110
|
+
severity: Severity;
|
|
111
|
+
category: DiagnosticCategory;
|
|
112
|
+
message: string;
|
|
113
|
+
rationale?: string;
|
|
114
|
+
component?: string;
|
|
115
|
+
contract?: string;
|
|
116
|
+
location?: SourceLocation;
|
|
117
|
+
suggestions?: DiagnosticSuggestion[];
|
|
118
|
+
context?: Context;
|
|
119
|
+
metadata?: Metadata;
|
|
120
|
+
}
|
|
121
|
+
interface DiagnosticReporter {
|
|
122
|
+
report(diagnostic: Diagnostic): void;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare enum Enforcement {
|
|
126
|
+
Ignore = 0,
|
|
127
|
+
Report = 1,
|
|
128
|
+
Throw = 2
|
|
129
|
+
}
|
|
130
|
+
interface DiagnosticPolicy {
|
|
131
|
+
resolve(diagnostic: Diagnostic): Enforcement;
|
|
132
|
+
}
|
|
133
|
+
interface DefaultPolicyOptions {
|
|
134
|
+
reportThreshold?: Severity;
|
|
135
|
+
throwThreshold?: Severity;
|
|
136
|
+
}
|
|
137
|
+
declare class DefaultPolicy implements DiagnosticPolicy {
|
|
138
|
+
private readonly reportThreshold;
|
|
139
|
+
private readonly throwThreshold;
|
|
140
|
+
constructor({ reportThreshold, throwThreshold, }?: DefaultPolicyOptions);
|
|
141
|
+
resolve(diagnostic: Diagnostic): Enforcement;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
type DiagnosticInput = Except<Diagnostic, 'severity'>;
|
|
145
|
+
declare class Diagnostics {
|
|
146
|
+
private readonly reporter;
|
|
147
|
+
private readonly policy;
|
|
148
|
+
readonly active: boolean;
|
|
149
|
+
constructor(reporter: DiagnosticReporter, policy?: DiagnosticPolicy);
|
|
150
|
+
report(diagnostic: Diagnostic): Diagnostic;
|
|
151
|
+
warn(input: DiagnosticInput): Diagnostic;
|
|
152
|
+
error(input: DiagnosticInput): Diagnostic;
|
|
153
|
+
info(input: DiagnosticInput): Diagnostic;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare class PraxisError extends Error {
|
|
157
|
+
readonly diagnostic: Diagnostic;
|
|
158
|
+
constructor(diagnostic: Diagnostic);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
type Formatter = (diagnostic: Diagnostic) => string;
|
|
162
|
+
declare function formatDiagnostic(diagnostic: Diagnostic): string;
|
|
163
|
+
|
|
164
|
+
interface ValidationResult {
|
|
165
|
+
valid: boolean;
|
|
166
|
+
diagnostics: readonly Diagnostic[];
|
|
167
|
+
}
|
|
168
|
+
type Ok<T> = {
|
|
169
|
+
readonly ok: true;
|
|
170
|
+
readonly value: T;
|
|
171
|
+
};
|
|
172
|
+
type Err<E> = {
|
|
173
|
+
readonly ok: false;
|
|
174
|
+
readonly error: E;
|
|
175
|
+
};
|
|
176
|
+
type Result<T, E = ValidationResult> = Ok<T> | Err<E>;
|
|
177
|
+
declare function ok<T>(value: T): Ok<T>;
|
|
178
|
+
declare function err<E>(error: E): Err<E>;
|
|
179
|
+
|
|
180
|
+
declare class AsyncConsoleReporter implements DiagnosticReporter {
|
|
181
|
+
private readonly pending;
|
|
182
|
+
private scheduled;
|
|
183
|
+
report(diagnostic: Diagnostic): void;
|
|
184
|
+
/** Clears pending messages. Exposed for test isolation only. */
|
|
185
|
+
reset(): void;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare class CollectingReporter implements DiagnosticReporter {
|
|
189
|
+
private readonly collected;
|
|
190
|
+
report(diagnostic: Diagnostic): void;
|
|
191
|
+
get diagnostics(): readonly Diagnostic[];
|
|
192
|
+
clear(): void;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
declare class ConsoleReporter implements DiagnosticReporter {
|
|
196
|
+
report(diagnostic: Diagnostic): void;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare const nullReporter: DiagnosticReporter;
|
|
200
|
+
|
|
201
|
+
declare class ThrowingReporter implements DiagnosticReporter {
|
|
202
|
+
report(diagnostic: Diagnostic): void;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
declare const silentDiagnostics: Diagnostics;
|
|
206
|
+
declare const warnDiagnostics: Diagnostics;
|
|
207
|
+
declare const throwDiagnostics: Diagnostics;
|
|
208
|
+
|
|
209
|
+
export { AsyncConsoleReporter, CollectingReporter, ConsoleReporter, DefaultPolicy, type DefaultPolicyOptions, type Diagnostic, DiagnosticCategory, DiagnosticCode, type DiagnosticInput, type DiagnosticPolicy, type DiagnosticReporter, type DiagnosticSuggestion, Diagnostics, Enforcement, type Err, type Formatter, type Ok, PraxisError, type Result, Severity, type SourceLocation, type SourcePosition, ThrowingReporter, type ValidationResult, err, formatDiagnostic, isAtLeast, nullReporter, ok, silentDiagnostics, throwDiagnostics, warnDiagnostics };
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
// ../../lib/diagnostics/src/category.ts
|
|
2
|
+
var DiagnosticCategory = /* @__PURE__ */ ((DiagnosticCategory2) => {
|
|
3
|
+
DiagnosticCategory2[DiagnosticCategory2["Contract"] = 0] = "Contract";
|
|
4
|
+
DiagnosticCategory2[DiagnosticCategory2["HTML"] = 1] = "HTML";
|
|
5
|
+
DiagnosticCategory2[DiagnosticCategory2["ARIA"] = 2] = "ARIA";
|
|
6
|
+
DiagnosticCategory2[DiagnosticCategory2["Composition"] = 3] = "Composition";
|
|
7
|
+
DiagnosticCategory2[DiagnosticCategory2["Rendering"] = 4] = "Rendering";
|
|
8
|
+
DiagnosticCategory2[DiagnosticCategory2["Accessibility"] = 5] = "Accessibility";
|
|
9
|
+
DiagnosticCategory2[DiagnosticCategory2["Performance"] = 6] = "Performance";
|
|
10
|
+
DiagnosticCategory2[DiagnosticCategory2["Internal"] = 7] = "Internal";
|
|
11
|
+
DiagnosticCategory2[DiagnosticCategory2["Deprecation"] = 8] = "Deprecation";
|
|
12
|
+
DiagnosticCategory2[DiagnosticCategory2["Lint"] = 9] = "Lint";
|
|
13
|
+
return DiagnosticCategory2;
|
|
14
|
+
})(DiagnosticCategory || {});
|
|
15
|
+
|
|
16
|
+
// ../../lib/diagnostics/src/codes.ts
|
|
17
|
+
var DiagnosticCode = /* @__PURE__ */ ((DiagnosticCode2) => {
|
|
18
|
+
DiagnosticCode2["MissingRequiredChild"] = "COMP1001";
|
|
19
|
+
DiagnosticCode2["InvalidParent"] = "COMP1002";
|
|
20
|
+
DiagnosticCode2["InvalidChild"] = "COMP1003";
|
|
21
|
+
DiagnosticCode2["UnexpectedChild"] = "COMP1004";
|
|
22
|
+
DiagnosticCode2["AmbiguousChild"] = "COMP1005";
|
|
23
|
+
DiagnosticCode2["CardinalityMin"] = "COMP1006";
|
|
24
|
+
DiagnosticCode2["CardinalityMax"] = "COMP1007";
|
|
25
|
+
DiagnosticCode2["PositionViolation"] = "COMP1008";
|
|
26
|
+
DiagnosticCode2["AllowedAsViolation"] = "COMP1009";
|
|
27
|
+
DiagnosticCode2["SlotExclusive"] = "SLOT1001";
|
|
28
|
+
DiagnosticCode2["SlotSingleChild"] = "SLOT1002";
|
|
29
|
+
DiagnosticCode2["SlotDiscardedChildren"] = "SLOT1003";
|
|
30
|
+
DiagnosticCode2["SlotRenderFn"] = "SLOT1004";
|
|
31
|
+
DiagnosticCode2["MissingAriaRelationship"] = "ARIA2001";
|
|
32
|
+
DiagnosticCode2["AriaViolation"] = "ARIA2002";
|
|
33
|
+
DiagnosticCode2["AriaAttributeInvalid"] = "ARIA2003";
|
|
34
|
+
DiagnosticCode2["AriaMissingLiveRegion"] = "ARIA2004";
|
|
35
|
+
DiagnosticCode2["AriaMissingAtomic"] = "ARIA2005";
|
|
36
|
+
DiagnosticCode2["AriaRelevantInvalidToken"] = "ARIA2006";
|
|
37
|
+
DiagnosticCode2["AriaRelevantSuperseded"] = "ARIA2007";
|
|
38
|
+
DiagnosticCode2["AriaInvalidRole"] = "ARIA2008";
|
|
39
|
+
DiagnosticCode2["AriaMissingAccessibleName"] = "ARIA2009";
|
|
40
|
+
DiagnosticCode2["AriaAttributeOnPresentational"] = "ARIA2010";
|
|
41
|
+
DiagnosticCode2["AriaHiddenOnFocusable"] = "ARIA2011";
|
|
42
|
+
DiagnosticCode2["AriaRequiredProperty"] = "ARIA2012";
|
|
43
|
+
DiagnosticCode2["AriaInvalidAttributeValue"] = "ARIA2013";
|
|
44
|
+
DiagnosticCode2["AriaRedundantLevelAttribute"] = "ARIA2014";
|
|
45
|
+
DiagnosticCode2["InvalidHeadingHierarchy"] = "HTML3001";
|
|
46
|
+
DiagnosticCode2["HtmlEmptyRole"] = "HTML3002";
|
|
47
|
+
DiagnosticCode2["HtmlImplicitRoleRedundant"] = "HTML3003";
|
|
48
|
+
DiagnosticCode2["HtmlImplicitRoleOverride"] = "HTML3004";
|
|
49
|
+
DiagnosticCode2["HtmlStandaloneRegionOverride"] = "HTML3005";
|
|
50
|
+
DiagnosticCode2["HtmlLandmarkRoleOverride"] = "HTML3006";
|
|
51
|
+
DiagnosticCode2["HtmlInvalidChild"] = "HTML3007";
|
|
52
|
+
DiagnosticCode2["InvalidRenderingTarget"] = "RENDER4001";
|
|
53
|
+
DiagnosticCode2["LintDeadCompoundKey"] = "LINT5001";
|
|
54
|
+
DiagnosticCode2["LintDeadCompoundValue"] = "LINT5002";
|
|
55
|
+
DiagnosticCode2["LintDeadCompoundNonLiteral"] = "LINT5003";
|
|
56
|
+
DiagnosticCode2["LintMissingStrict"] = "LINT5004";
|
|
57
|
+
DiagnosticCode2["LintInvalidDefaultKey"] = "LINT5005";
|
|
58
|
+
DiagnosticCode2["LintInvalidDefaultValue"] = "LINT5006";
|
|
59
|
+
DiagnosticCode2["LintInvalidDefaultNonLiteral"] = "LINT5007";
|
|
60
|
+
DiagnosticCode2["LintNegativeMin"] = "LINT5008";
|
|
61
|
+
DiagnosticCode2["LintNegativeMax"] = "LINT5009";
|
|
62
|
+
DiagnosticCode2["LintMaxLessThanMin"] = "LINT5010";
|
|
63
|
+
DiagnosticCode2["LintZeroMax"] = "LINT5011";
|
|
64
|
+
DiagnosticCode2["LintMultipleFirst"] = "LINT5012";
|
|
65
|
+
DiagnosticCode2["LintMultipleLast"] = "LINT5013";
|
|
66
|
+
DiagnosticCode2["LintMinSumExceedsCapacity"] = "LINT5014";
|
|
67
|
+
DiagnosticCode2["LintCardinalityViolation"] = "LINT5015";
|
|
68
|
+
DiagnosticCode2["LintAriaTagOverride"] = "LINT5016";
|
|
69
|
+
DiagnosticCode2["ContractUnknownVariantDim"] = "COMP1010";
|
|
70
|
+
DiagnosticCode2["ContractUnknownVariantValue"] = "COMP1011";
|
|
71
|
+
DiagnosticCode2["ContractUnknownRecipeKey"] = "COMP1012";
|
|
72
|
+
DiagnosticCode2["ContractInvalidVariantValue"] = "COMP1013";
|
|
73
|
+
DiagnosticCode2["TailwindMultipleDisplayProps"] = "CSS6001";
|
|
74
|
+
DiagnosticCode2["TailwindReservedLayoutLiteral"] = "CSS6002";
|
|
75
|
+
DiagnosticCode2["TailwindDeadVariantClass"] = "CSS6003";
|
|
76
|
+
DiagnosticCode2["PluginInvalidShape"] = "PLUGIN7001";
|
|
77
|
+
DiagnosticCode2["PluginPipelineReturnType"] = "PLUGIN7002";
|
|
78
|
+
DiagnosticCode2["InternalError"] = "INTERNAL9000";
|
|
79
|
+
return DiagnosticCode2;
|
|
80
|
+
})(DiagnosticCode || {});
|
|
81
|
+
|
|
82
|
+
// ../../lib/diagnostics/src/error.ts
|
|
83
|
+
var PraxisError = class extends Error {
|
|
84
|
+
diagnostic;
|
|
85
|
+
constructor(diagnostic) {
|
|
86
|
+
super(diagnostic.message);
|
|
87
|
+
this.name = "PraxisError";
|
|
88
|
+
this.diagnostic = diagnostic;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// ../../lib/diagnostics/src/severity.ts
|
|
93
|
+
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
94
|
+
Severity2[Severity2["Debug"] = 0] = "Debug";
|
|
95
|
+
Severity2[Severity2["Info"] = 1] = "Info";
|
|
96
|
+
Severity2[Severity2["Warning"] = 2] = "Warning";
|
|
97
|
+
Severity2[Severity2["Error"] = 3] = "Error";
|
|
98
|
+
Severity2[Severity2["Fatal"] = 4] = "Fatal";
|
|
99
|
+
return Severity2;
|
|
100
|
+
})(Severity || {});
|
|
101
|
+
function isAtLeast(s, threshold) {
|
|
102
|
+
return s >= threshold;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ../../lib/diagnostics/src/policy.ts
|
|
106
|
+
var Enforcement = /* @__PURE__ */ ((Enforcement2) => {
|
|
107
|
+
Enforcement2[Enforcement2["Ignore"] = 0] = "Ignore";
|
|
108
|
+
Enforcement2[Enforcement2["Report"] = 1] = "Report";
|
|
109
|
+
Enforcement2[Enforcement2["Throw"] = 2] = "Throw";
|
|
110
|
+
return Enforcement2;
|
|
111
|
+
})(Enforcement || {});
|
|
112
|
+
var DefaultPolicy = class {
|
|
113
|
+
reportThreshold;
|
|
114
|
+
throwThreshold;
|
|
115
|
+
constructor({
|
|
116
|
+
reportThreshold = 1 /* Info */,
|
|
117
|
+
throwThreshold = 4 /* Fatal */
|
|
118
|
+
} = {}) {
|
|
119
|
+
this.reportThreshold = reportThreshold;
|
|
120
|
+
this.throwThreshold = throwThreshold;
|
|
121
|
+
}
|
|
122
|
+
resolve(diagnostic) {
|
|
123
|
+
if (diagnostic.severity >= this.throwThreshold) return 2 /* Throw */;
|
|
124
|
+
if (diagnostic.severity >= this.reportThreshold) return 1 /* Report */;
|
|
125
|
+
return 0 /* Ignore */;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// ../../lib/diagnostics/src/diagnostics.ts
|
|
130
|
+
var Diagnostics = class {
|
|
131
|
+
reporter;
|
|
132
|
+
policy;
|
|
133
|
+
// Pre-computed at construction time: true if Warning-level diagnostics are not ignored.
|
|
134
|
+
active;
|
|
135
|
+
constructor(reporter, policy = new DefaultPolicy()) {
|
|
136
|
+
this.reporter = reporter;
|
|
137
|
+
this.policy = policy;
|
|
138
|
+
this.active = policy.resolve({ severity: 2 /* Warning */ }) !== 0 /* Ignore */;
|
|
139
|
+
}
|
|
140
|
+
report(diagnostic) {
|
|
141
|
+
const enforcement = this.policy.resolve(diagnostic);
|
|
142
|
+
if (enforcement === 0 /* Ignore */) return diagnostic;
|
|
143
|
+
if (enforcement === 2 /* Throw */) throw new PraxisError(diagnostic);
|
|
144
|
+
this.reporter.report(diagnostic);
|
|
145
|
+
return diagnostic;
|
|
146
|
+
}
|
|
147
|
+
warn(input) {
|
|
148
|
+
return this.report({ ...input, severity: 2 /* Warning */ });
|
|
149
|
+
}
|
|
150
|
+
error(input) {
|
|
151
|
+
return this.report({ ...input, severity: 3 /* Error */ });
|
|
152
|
+
}
|
|
153
|
+
info(input) {
|
|
154
|
+
return this.report({ ...input, severity: 1 /* Info */ });
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// ../../lib/diagnostics/src/formatter.ts
|
|
159
|
+
function formatDiagnostic(diagnostic) {
|
|
160
|
+
const level = Severity[diagnostic.severity];
|
|
161
|
+
const category = DiagnosticCategory[diagnostic.category];
|
|
162
|
+
const prefix = category !== void 0 ? `[${category}] ` : "";
|
|
163
|
+
return `${level} ${diagnostic.code}: ${prefix}${diagnostic.message}`;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ../../lib/diagnostics/src/result.ts
|
|
167
|
+
function ok(value) {
|
|
168
|
+
return { ok: true, value };
|
|
169
|
+
}
|
|
170
|
+
function err(error) {
|
|
171
|
+
return { ok: false, error };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ../../lib/diagnostics/src/async-console-reporter.ts
|
|
175
|
+
var AsyncConsoleReporter = class {
|
|
176
|
+
pending = /* @__PURE__ */ new Set();
|
|
177
|
+
scheduled = false;
|
|
178
|
+
report(diagnostic) {
|
|
179
|
+
const message = formatDiagnostic(diagnostic);
|
|
180
|
+
if (this.pending.has(message)) return;
|
|
181
|
+
this.pending.add(message);
|
|
182
|
+
if (!this.scheduled) {
|
|
183
|
+
this.scheduled = true;
|
|
184
|
+
queueMicrotask(() => {
|
|
185
|
+
this.scheduled = false;
|
|
186
|
+
for (const msg of this.pending) {
|
|
187
|
+
console.warn(msg);
|
|
188
|
+
}
|
|
189
|
+
this.pending.clear();
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** Clears pending messages. Exposed for test isolation only. */
|
|
194
|
+
reset() {
|
|
195
|
+
this.pending.clear();
|
|
196
|
+
this.scheduled = false;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
// ../../lib/diagnostics/src/collecting-reporter.ts
|
|
201
|
+
var CollectingReporter = class {
|
|
202
|
+
collected = [];
|
|
203
|
+
report(diagnostic) {
|
|
204
|
+
this.collected.push(diagnostic);
|
|
205
|
+
}
|
|
206
|
+
get diagnostics() {
|
|
207
|
+
return this.collected;
|
|
208
|
+
}
|
|
209
|
+
clear() {
|
|
210
|
+
this.collected.length = 0;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// ../../lib/diagnostics/src/console-reporter.ts
|
|
215
|
+
var ConsoleReporter = class {
|
|
216
|
+
report(diagnostic) {
|
|
217
|
+
const message = formatDiagnostic(diagnostic);
|
|
218
|
+
switch (diagnostic.severity) {
|
|
219
|
+
case 0 /* Debug */:
|
|
220
|
+
console.debug(message);
|
|
221
|
+
break;
|
|
222
|
+
case 1 /* Info */:
|
|
223
|
+
console.info(message);
|
|
224
|
+
break;
|
|
225
|
+
case 2 /* Warning */:
|
|
226
|
+
console.warn(message);
|
|
227
|
+
break;
|
|
228
|
+
case 3 /* Error */:
|
|
229
|
+
case 4 /* Fatal */:
|
|
230
|
+
console.error(message);
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// ../../lib/diagnostics/src/null-reporter.ts
|
|
237
|
+
var nullReporter = {
|
|
238
|
+
report() {
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// ../../lib/diagnostics/src/throwing-reporter.ts
|
|
243
|
+
var ThrowingReporter = class {
|
|
244
|
+
report(diagnostic) {
|
|
245
|
+
throw new PraxisError(diagnostic);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// ../../lib/diagnostics/src/presets.ts
|
|
250
|
+
var ignoreAllPolicy = {
|
|
251
|
+
resolve(_) {
|
|
252
|
+
return 0 /* Ignore */;
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
var warnOnlyReporter = {
|
|
256
|
+
report(diagnostic) {
|
|
257
|
+
console.warn(formatDiagnostic(diagnostic));
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
var silentDiagnostics = new Diagnostics(nullReporter, ignoreAllPolicy);
|
|
261
|
+
var warnDiagnostics = new Diagnostics(
|
|
262
|
+
warnOnlyReporter,
|
|
263
|
+
new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 4 /* Fatal */ })
|
|
264
|
+
);
|
|
265
|
+
var throwDiagnostics = new Diagnostics(
|
|
266
|
+
new ConsoleReporter(),
|
|
267
|
+
new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 3 /* Error */ })
|
|
268
|
+
);
|
|
269
|
+
export {
|
|
270
|
+
AsyncConsoleReporter,
|
|
271
|
+
CollectingReporter,
|
|
272
|
+
ConsoleReporter,
|
|
273
|
+
DefaultPolicy,
|
|
274
|
+
DiagnosticCategory,
|
|
275
|
+
DiagnosticCode,
|
|
276
|
+
Diagnostics,
|
|
277
|
+
Enforcement,
|
|
278
|
+
PraxisError,
|
|
279
|
+
Severity,
|
|
280
|
+
ThrowingReporter,
|
|
281
|
+
err,
|
|
282
|
+
formatDiagnostic,
|
|
283
|
+
isAtLeast,
|
|
284
|
+
nullReporter,
|
|
285
|
+
ok,
|
|
286
|
+
silentDiagnostics,
|
|
287
|
+
throwDiagnostics,
|
|
288
|
+
warnDiagnostics
|
|
289
|
+
};
|