@uapkg/diagnostics-format 1.2.0 → 1.3.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.
- package/dist/contracts/FormatterTypes.d.ts +13 -10
- package/dist/contracts/FormatterTypes.d.ts.map +1 -1
- package/dist/contracts/FormatterTypes.js +1 -2
- package/dist/defaults/defaultFormatters.d.ts +5 -2
- package/dist/defaults/defaultFormatters.d.ts.map +1 -1
- package/dist/defaults/defaultFormatters.js +30 -23
- package/dist/defaults/defaultFormatters.js.map +1 -1
- package/dist/formatters/PlainTextFormatter.d.ts +5 -2
- package/dist/formatters/PlainTextFormatter.d.ts.map +1 -1
- package/dist/formatters/PlainTextFormatter.js +13 -12
- package/dist/formatters/PlainTextFormatter.js.map +1 -1
- package/dist/formatters/config/configFormatters.d.ts +5 -2
- package/dist/formatters/config/configFormatters.d.ts.map +1 -1
- package/dist/formatters/config/configFormatters.js +50 -56
- package/dist/formatters/config/configFormatters.js.map +1 -1
- package/dist/formatters/installer/installerFormatters.d.ts +5 -2
- package/dist/formatters/installer/installerFormatters.d.ts.map +1 -1
- package/dist/formatters/installer/installerFormatters.js +51 -47
- package/dist/formatters/installer/installerFormatters.js.map +1 -1
- package/dist/formatters/manifest/manifestFormatters.d.ts +5 -2
- package/dist/formatters/manifest/manifestFormatters.d.ts.map +1 -1
- package/dist/formatters/manifest/manifestFormatters.js +40 -45
- package/dist/formatters/manifest/manifestFormatters.js.map +1 -1
- package/dist/formatters/pack/packFormatters.d.ts +5 -2
- package/dist/formatters/pack/packFormatters.d.ts.map +1 -1
- package/dist/formatters/pack/packFormatters.js +9 -9
- package/dist/formatters/pack/packFormatters.js.map +1 -1
- package/dist/formatters/postinstall/postinstallFormatters.d.ts +5 -2
- package/dist/formatters/postinstall/postinstallFormatters.d.ts.map +1 -1
- package/dist/formatters/postinstall/postinstallFormatters.js +35 -36
- package/dist/formatters/postinstall/postinstallFormatters.js.map +1 -1
- package/dist/formatters/publishing/publishingFormatters.d.ts +14 -0
- package/dist/formatters/publishing/publishingFormatters.d.ts.map +1 -0
- package/dist/formatters/publishing/publishingFormatters.js +45 -0
- package/dist/formatters/publishing/publishingFormatters.js.map +1 -0
- package/dist/formatters/registry/registryFormatters.d.ts +5 -2
- package/dist/formatters/registry/registryFormatters.d.ts.map +1 -1
- package/dist/formatters/registry/registryFormatters.js +33 -34
- package/dist/formatters/registry/registryFormatters.js.map +1 -1
- package/dist/formatters/registryTools/registryToolsFormatters.d.ts +5 -2
- package/dist/formatters/registryTools/registryToolsFormatters.d.ts.map +1 -1
- package/dist/formatters/registryTools/registryToolsFormatters.js +160 -135
- package/dist/formatters/registryTools/registryToolsFormatters.js.map +1 -1
- package/dist/formatters/resolver/resolverFormatters.d.ts +5 -2
- package/dist/formatters/resolver/resolverFormatters.d.ts.map +1 -1
- package/dist/formatters/resolver/resolverFormatters.js +20 -18
- package/dist/formatters/resolver/resolverFormatters.js.map +1 -1
- package/dist/formatters/safety/safetyFormatters.d.ts +5 -2
- package/dist/formatters/safety/safetyFormatters.d.ts.map +1 -1
- package/dist/formatters/safety/safetyFormatters.js +28 -26
- package/dist/formatters/safety/safetyFormatters.js.map +1 -1
- package/dist/formatters/spec/specFormatters.d.ts +5 -2
- package/dist/formatters/spec/specFormatters.d.ts.map +1 -1
- package/dist/formatters/spec/specFormatters.js +32 -19
- package/dist/formatters/spec/specFormatters.js.map +1 -1
- package/dist/index.d.ts +15 -14
- package/dist/index.js +15 -16
- package/dist/ink/components/configInkComponents.d.ts +5 -2
- package/dist/ink/components/configInkComponents.d.ts.map +1 -1
- package/dist/ink/components/configInkComponents.js +93 -18
- package/dist/ink/components/configInkComponents.js.map +1 -1
- package/dist/ink/components/installerInkComponents.d.ts +5 -2
- package/dist/ink/components/installerInkComponents.d.ts.map +1 -1
- package/dist/ink/components/installerInkComponents.js +170 -24
- package/dist/ink/components/installerInkComponents.js.map +1 -1
- package/dist/ink/components/manifestInkComponents.d.ts +5 -2
- package/dist/ink/components/manifestInkComponents.d.ts.map +1 -1
- package/dist/ink/components/manifestInkComponents.js +139 -34
- package/dist/ink/components/manifestInkComponents.js.map +1 -1
- package/dist/ink/components/packInkComponents.d.ts +5 -2
- package/dist/ink/components/packInkComponents.d.ts.map +1 -1
- package/dist/ink/components/packInkComponents.js +22 -7
- package/dist/ink/components/packInkComponents.js.map +1 -1
- package/dist/ink/components/postinstallInkComponents.d.ts +5 -2
- package/dist/ink/components/postinstallInkComponents.d.ts.map +1 -1
- package/dist/ink/components/postinstallInkComponents.js +124 -21
- package/dist/ink/components/postinstallInkComponents.js.map +1 -1
- package/dist/ink/components/publishingInkComponents.d.ts +6 -0
- package/dist/ink/components/publishingInkComponents.d.ts.map +1 -0
- package/dist/ink/components/publishingInkComponents.js +55 -0
- package/dist/ink/components/publishingInkComponents.js.map +1 -0
- package/dist/ink/components/registryInkComponents.d.ts +5 -2
- package/dist/ink/components/registryInkComponents.d.ts.map +1 -1
- package/dist/ink/components/registryInkComponents.js +109 -24
- package/dist/ink/components/registryInkComponents.js.map +1 -1
- package/dist/ink/components/resolverInkComponents.d.ts +5 -2
- package/dist/ink/components/resolverInkComponents.d.ts.map +1 -1
- package/dist/ink/components/resolverInkComponents.js +97 -18
- package/dist/ink/components/resolverInkComponents.js.map +1 -1
- package/dist/ink/components/safetyInkComponents.d.ts +5 -2
- package/dist/ink/components/safetyInkComponents.d.ts.map +1 -1
- package/dist/ink/components/safetyInkComponents.js +72 -12
- package/dist/ink/components/safetyInkComponents.js.map +1 -1
- package/dist/ink/components/specInkComponents.d.ts +5 -2
- package/dist/ink/components/specInkComponents.d.ts.map +1 -1
- package/dist/ink/components/specInkComponents.js +44 -12
- package/dist/ink/components/specInkComponents.js.map +1 -1
- package/dist/ink/contracts/InkTypes.d.ts +15 -9
- package/dist/ink/contracts/InkTypes.d.ts.map +1 -1
- package/dist/ink/contracts/InkTypes.js +1 -2
- package/dist/ink/defaults/defaultInkComponents.d.ts +5 -2
- package/dist/ink/defaults/defaultInkComponents.d.ts.map +1 -1
- package/dist/ink/defaults/defaultInkComponents.js +35 -28
- package/dist/ink/defaults/defaultInkComponents.js.map +1 -1
- package/dist/ink/index.d.ts +17 -16
- package/dist/ink/index.js +17 -28
- package/dist/ink/primitives/HintLine.d.ts +7 -4
- package/dist/ink/primitives/HintLine.d.ts.map +1 -1
- package/dist/ink/primitives/HintLine.js +22 -9
- package/dist/ink/primitives/HintLine.js.map +1 -1
- package/dist/ink/primitives/PlainTextBody.d.ts +6 -3
- package/dist/ink/primitives/PlainTextBody.d.ts.map +1 -1
- package/dist/ink/primitives/PlainTextBody.js +13 -8
- package/dist/ink/primitives/PlainTextBody.js.map +1 -1
- package/dist/ink/primitives/SeverityBadge.d.ts +8 -5
- package/dist/ink/primitives/SeverityBadge.d.ts.map +1 -1
- package/dist/ink/primitives/SeverityBadge.js +28 -11
- package/dist/ink/primitives/SeverityBadge.js.map +1 -1
- package/dist/ink/registry/DiagnosticInkRegistry.d.ts +11 -8
- package/dist/ink/registry/DiagnosticInkRegistry.d.ts.map +1 -1
- package/dist/ink/registry/DiagnosticInkRegistry.js +32 -29
- package/dist/ink/registry/DiagnosticInkRegistry.js.map +1 -1
- package/dist/ink/views/DiagnosticView.d.ts +10 -7
- package/dist/ink/views/DiagnosticView.d.ts.map +1 -1
- package/dist/ink/views/DiagnosticView.js +42 -17
- package/dist/ink/views/DiagnosticView.js.map +1 -1
- package/dist/ink/views/DiagnosticsListView.d.ts +10 -7
- package/dist/ink/views/DiagnosticsListView.d.ts.map +1 -1
- package/dist/ink/views/DiagnosticsListView.js +24 -16
- package/dist/ink/views/DiagnosticsListView.js.map +1 -1
- package/dist/registry/FormatterRegistry.d.ts +18 -15
- package/dist/registry/FormatterRegistry.d.ts.map +1 -1
- package/dist/registry/FormatterRegistry.js +38 -40
- package/dist/registry/FormatterRegistry.js.map +1 -1
- package/dist/utils/indent.d.ts +5 -2
- package/dist/utils/indent.d.ts.map +1 -1
- package/dist/utils/indent.js +9 -8
- package/dist/utils/indent.js.map +1 -1
- package/package.json +15 -17
- package/dist/contracts/FormatterTypes.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/ink/contracts/InkTypes.js.map +0 -1
- package/dist/ink/index.d.ts.map +0 -1
- package/dist/ink/index.js.map +0 -1
|
@@ -1,20 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { HintLine } from "../primitives/HintLine.js";
|
|
2
|
+
import { PlainTextBody } from "../primitives/PlainTextBody.js";
|
|
3
|
+
import { SeverityBadge } from "../primitives/SeverityBadge.js";
|
|
4
|
+
import { Box, Text } from "ink";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/ink/views/DiagnosticView.tsx
|
|
6
8
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
* Renders one diagnostic in three layers:
|
|
10
|
+
*
|
|
11
|
+
* 1. Header — severity badge + code + message.
|
|
12
|
+
* 2. Body — family-specific component (resolved from {@link IDiagnosticInkRegistry})
|
|
13
|
+
* or {@link PlainTextBody} as a safe fallback.
|
|
14
|
+
* 3. Hint — the `hint` field when present.
|
|
15
|
+
*
|
|
16
|
+
* This component is pure — it neither reads config nor talks to I/O.
|
|
17
|
+
*/
|
|
18
|
+
function DiagnosticView({ diagnostic, registry }) {
|
|
19
|
+
const Body = registry.resolve(diagnostic.code) ?? PlainTextBody;
|
|
20
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
21
|
+
flexDirection: "column",
|
|
22
|
+
marginBottom: 1,
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
25
|
+
/* @__PURE__ */ jsx(SeverityBadge, { level: diagnostic.level }),
|
|
26
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
27
|
+
/* @__PURE__ */ jsx(Text, {
|
|
28
|
+
bold: true,
|
|
29
|
+
color: "whiteBright",
|
|
30
|
+
children: diagnostic.code
|
|
31
|
+
})
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ jsx(Box, {
|
|
34
|
+
marginLeft: 2,
|
|
35
|
+
flexDirection: "column",
|
|
36
|
+
children: /* @__PURE__ */ jsx(Body, { diagnostic })
|
|
37
|
+
}),
|
|
38
|
+
diagnostic.hint && !Body.rendersHint ? /* @__PURE__ */ jsx(HintLine, { hint: diagnostic.hint }) : null
|
|
39
|
+
]
|
|
40
|
+
});
|
|
19
41
|
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { DiagnosticView };
|
|
20
45
|
//# sourceMappingURL=DiagnosticView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagnosticView.js","
|
|
1
|
+
{"version":3,"file":"DiagnosticView.js","names":[],"sources":["../../../src/ink/views/DiagnosticView.tsx"],"sourcesContent":["import type { Diagnostic } from '@uapkg/diagnostics';\nimport { Box, Text } from 'ink';\nimport type { ReactElement } from 'react';\nimport type { DiagnosticBodyComponent, IDiagnosticInkRegistry } from '../contracts/InkTypes.js';\nimport { HintLine } from '../primitives/HintLine.js';\nimport { PlainTextBody } from '../primitives/PlainTextBody.js';\nimport { SeverityBadge } from '../primitives/SeverityBadge.js';\n\nexport interface DiagnosticViewProps {\n readonly diagnostic: Diagnostic;\n readonly registry: IDiagnosticInkRegistry;\n}\n\n/**\n * Renders one diagnostic in three layers:\n *\n * 1. Header — severity badge + code + message.\n * 2. Body — family-specific component (resolved from {@link IDiagnosticInkRegistry})\n * or {@link PlainTextBody} as a safe fallback.\n * 3. Hint — the `hint` field when present.\n *\n * This component is pure — it neither reads config nor talks to I/O.\n */\nexport function DiagnosticView({ diagnostic, registry }: DiagnosticViewProps): ReactElement {\n const Body: DiagnosticBodyComponent = registry.resolve(diagnostic.code) ?? PlainTextBody;\n return (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <SeverityBadge level={diagnostic.level} />\n <Text> </Text>\n <Text bold color=\"whiteBright\">\n {diagnostic.code}\n </Text>\n </Box>\n <Box marginLeft={2} flexDirection=\"column\">\n <Body diagnostic={diagnostic} />\n </Box>\n {diagnostic.hint && !Body.rendersHint ? <HintLine hint={diagnostic.hint} /> : null}\n </Box>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,SAAgB,eAAe,EAAE,YAAY,YAA+C;CAC1F,MAAM,OAAgC,SAAS,QAAQ,WAAW,IAAI,KAAK;CAC3E,OACE,qBAAC,KAAD;EAAK,eAAc;EAAS,cAAc;YAA1C;GACE,qBAAC,KAAD;IACE,oBAAC,eAAD,EAAe,OAAO,WAAW,MAAQ;IACzC,oBAAC,MAAD,YAAM,IAAO;IACb,oBAAC,MAAD;KAAM;KAAK,OAAM;eACd,WAAW;IACR;GACH;GACL,oBAAC,KAAD;IAAK,YAAY;IAAG,eAAc;cAChC,oBAAC,MAAD,EAAkB,WAAa;GAC5B;GACJ,WAAW,QAAQ,CAAC,KAAK,cAAc,oBAAC,UAAD,EAAU,MAAM,WAAW,KAAO,KAAI;EAC3E;;AAET"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { IDiagnosticInkRegistry } from "../contracts/InkTypes.js";
|
|
2
|
+
import { Diagnostic } from "@uapkg/diagnostics";
|
|
3
|
+
import { ReactElement } from "react";
|
|
4
|
+
//#region src/ink/views/DiagnosticsListView.d.ts
|
|
5
|
+
interface DiagnosticsListViewProps {
|
|
6
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
7
|
+
readonly registry: IDiagnosticInkRegistry;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Renders a list of diagnostics (already pre-sorted by the caller — usually
|
|
10
11
|
* severity-descending). Produces nothing for an empty input so the host
|
|
11
12
|
* Ink tree stays quiet.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
declare function DiagnosticsListView({ diagnostics, registry }: DiagnosticsListViewProps): ReactElement | null;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DiagnosticsListView, DiagnosticsListViewProps };
|
|
14
17
|
//# sourceMappingURL=DiagnosticsListView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagnosticsListView.d.ts","
|
|
1
|
+
{"version":3,"file":"DiagnosticsListView.d.ts","names":[],"sources":["../../../src/ink/views/DiagnosticsListView.tsx"],"mappings":";;;;UAMiB;WACN,sBAAsB;WACtB,UAAU;;;;;;;iBAQL,sBAAsB,aAAa,YAAY,2BAA2B"}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Box } from
|
|
3
|
-
import {
|
|
1
|
+
import { DiagnosticView } from "./DiagnosticView.js";
|
|
2
|
+
import { Box } from "ink";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/ink/views/DiagnosticsListView.tsx
|
|
4
6
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
* Renders a list of diagnostics (already pre-sorted by the caller — usually
|
|
8
|
+
* severity-descending). Produces nothing for an empty input so the host
|
|
9
|
+
* Ink tree stays quiet.
|
|
10
|
+
*/
|
|
11
|
+
function DiagnosticsListView({ diagnostics, registry }) {
|
|
12
|
+
if (diagnostics.length === 0) return null;
|
|
13
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
14
|
+
flexDirection: "column",
|
|
15
|
+
children: diagnostics.map((diagnostic, i) => {
|
|
16
|
+
const key = `${diagnostic.code}:${i}:${diagnostic.message.length}`;
|
|
17
|
+
return /* @__PURE__ */ jsx(DiagnosticView, {
|
|
18
|
+
diagnostic,
|
|
19
|
+
registry
|
|
20
|
+
}, key);
|
|
21
|
+
})
|
|
22
|
+
});
|
|
18
23
|
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { DiagnosticsListView };
|
|
19
27
|
//# sourceMappingURL=DiagnosticsListView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiagnosticsListView.js","
|
|
1
|
+
{"version":3,"file":"DiagnosticsListView.js","names":[],"sources":["../../../src/ink/views/DiagnosticsListView.tsx"],"sourcesContent":["import type { Diagnostic } from '@uapkg/diagnostics';\nimport { Box } from 'ink';\nimport type { ReactElement } from 'react';\nimport type { IDiagnosticInkRegistry } from '../contracts/InkTypes.js';\nimport { DiagnosticView } from './DiagnosticView.js';\n\nexport interface DiagnosticsListViewProps {\n readonly diagnostics: readonly Diagnostic[];\n readonly registry: IDiagnosticInkRegistry;\n}\n\n/**\n * Renders a list of diagnostics (already pre-sorted by the caller — usually\n * severity-descending). Produces nothing for an empty input so the host\n * Ink tree stays quiet.\n */\nexport function DiagnosticsListView({ diagnostics, registry }: DiagnosticsListViewProps): ReactElement | null {\n if (diagnostics.length === 0) return null;\n return (\n <Box flexDirection=\"column\">\n {diagnostics.map((diagnostic, i) => {\n // Diagnostics don't carry stable ids; the (code, message, index) triple\n // is stable for a one-shot static render and unique within the list.\n const key = `${diagnostic.code}:${i}:${diagnostic.message.length}`;\n return <DiagnosticView key={key} diagnostic={diagnostic} registry={registry} />;\n })}\n </Box>\n );\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAgB,oBAAoB,EAAE,aAAa,YAA2D;CAC5G,IAAI,YAAY,WAAW,GAAG,OAAO;CACrC,OACE,oBAAC,KAAD;EAAK,eAAc;YAChB,YAAY,KAAK,YAAY,MAAM;GAGlC,MAAM,MAAM,GAAG,WAAW,KAAK,GAAG,EAAE,GAAG,WAAW,QAAQ;GAC1D,OAAO,oBAAC,gBAAD;IAAsC;IAAsB;GAAW,GAAlD,GAAkD;EAChF,CAAC;CACE;AAET"}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { DiagnosticFormatterFn, FormatterMap, IFormatterRegistry } from "../contracts/FormatterTypes.js";
|
|
2
|
+
import { Diagnostic, DiagnosticCode } from "@uapkg/diagnostics";
|
|
3
|
+
//#region src/registry/FormatterRegistry.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Registry that maps diagnostic codes to formatter functions.
|
|
5
6
|
* Falls back to a plain-text default when no specific formatter is registered.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
declare class FormatterRegistry implements IFormatterRegistry {
|
|
9
|
+
private readonly formatters;
|
|
10
|
+
private readonly fallback;
|
|
11
|
+
constructor(fallback?: DiagnosticFormatterFn);
|
|
12
|
+
/** Register a formatter for a single diagnostic code. */
|
|
13
|
+
register(code: DiagnosticCode, formatter: DiagnosticFormatterFn): void;
|
|
14
|
+
/** Bulk-register multiple formatters from a partial map. */
|
|
15
|
+
registerAll(map: FormatterMap): void;
|
|
16
|
+
/** Format a single diagnostic using the registered (or fallback) formatter. */
|
|
17
|
+
format(diagnostic: Diagnostic): string;
|
|
18
|
+
/** Format an array of diagnostics, joining with newlines. */
|
|
19
|
+
formatAll(diagnostics: readonly Diagnostic[]): string;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* Create a new `FormatterRegistry` optionally pre-loaded with formatters.
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
+
declare function createFormatterRegistry(initial?: FormatterMap, fallback?: DiagnosticFormatterFn): FormatterRegistry;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { FormatterRegistry, createFormatterRegistry };
|
|
24
27
|
//# sourceMappingURL=FormatterRegistry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatterRegistry.d.ts","
|
|
1
|
+
{"version":3,"file":"FormatterRegistry.d.ts","names":[],"sources":["../../src/registry/FormatterRegistry.ts"],"mappings":";;;;;;;cAQa,6BAA6B;mBACvB;mBACA;EAEjB,YAAY,WAAU;;EAKtB,SAAS,MAAM,gBAAgB,WAAW;;EAK1C,YAAY,KAAK;;EASjB,OAAO,YAAY;;EAMnB,UAAU,sBAAsB;;;;;iBAQlB,wBAAwB,UAAU,cAAc,WAAW,wBAAwB"}
|
|
@@ -1,44 +1,42 @@
|
|
|
1
|
-
import { formatPlainText } from
|
|
1
|
+
import { formatPlainText } from "../formatters/PlainTextFormatter.js";
|
|
2
|
+
|
|
3
|
+
//#region src/registry/FormatterRegistry.ts
|
|
2
4
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/** Format an array of diagnostics, joining with newlines. */
|
|
30
|
-
formatAll(diagnostics) {
|
|
31
|
-
return diagnostics.map((d) => this.format(d)).join('\n');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
5
|
+
* Registry that maps diagnostic codes to formatter functions.
|
|
6
|
+
* Falls back to a plain-text default when no specific formatter is registered.
|
|
7
|
+
*/
|
|
8
|
+
var FormatterRegistry = class {
|
|
9
|
+
formatters = /* @__PURE__ */ new Map();
|
|
10
|
+
fallback;
|
|
11
|
+
constructor(fallback = formatPlainText) {
|
|
12
|
+
this.fallback = fallback;
|
|
13
|
+
}
|
|
14
|
+
/** Register a formatter for a single diagnostic code. */
|
|
15
|
+
register(code, formatter) {
|
|
16
|
+
this.formatters.set(code, formatter);
|
|
17
|
+
}
|
|
18
|
+
/** Bulk-register multiple formatters from a partial map. */
|
|
19
|
+
registerAll(map) {
|
|
20
|
+
for (const [code, fn] of Object.entries(map)) if (fn) this.formatters.set(code, fn);
|
|
21
|
+
}
|
|
22
|
+
/** Format a single diagnostic using the registered (or fallback) formatter. */
|
|
23
|
+
format(diagnostic) {
|
|
24
|
+
return (this.formatters.get(diagnostic.code) ?? this.fallback)(diagnostic);
|
|
25
|
+
}
|
|
26
|
+
/** Format an array of diagnostics, joining with newlines. */
|
|
27
|
+
formatAll(diagnostics) {
|
|
28
|
+
return diagnostics.map((d) => this.format(d)).join("\n");
|
|
29
|
+
}
|
|
30
|
+
};
|
|
34
31
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
return registry;
|
|
32
|
+
* Create a new `FormatterRegistry` optionally pre-loaded with formatters.
|
|
33
|
+
*/
|
|
34
|
+
function createFormatterRegistry(initial, fallback) {
|
|
35
|
+
const registry = new FormatterRegistry(fallback);
|
|
36
|
+
if (initial) registry.registerAll(initial);
|
|
37
|
+
return registry;
|
|
43
38
|
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { FormatterRegistry, createFormatterRegistry };
|
|
44
42
|
//# sourceMappingURL=FormatterRegistry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatterRegistry.js","
|
|
1
|
+
{"version":3,"file":"FormatterRegistry.js","names":[],"sources":["../../src/registry/FormatterRegistry.ts"],"sourcesContent":["import type { Diagnostic, DiagnosticCode } from '@uapkg/diagnostics';\nimport type { DiagnosticFormatterFn, FormatterMap, IFormatterRegistry } from '../contracts/FormatterTypes.js';\nimport { formatPlainText } from '../formatters/PlainTextFormatter.js';\n\n/**\n * Registry that maps diagnostic codes to formatter functions.\n * Falls back to a plain-text default when no specific formatter is registered.\n */\nexport class FormatterRegistry implements IFormatterRegistry {\n private readonly formatters = new Map<DiagnosticCode, DiagnosticFormatterFn>();\n private readonly fallback: DiagnosticFormatterFn;\n\n constructor(fallback: DiagnosticFormatterFn = formatPlainText) {\n this.fallback = fallback;\n }\n\n /** Register a formatter for a single diagnostic code. */\n register(code: DiagnosticCode, formatter: DiagnosticFormatterFn): void {\n this.formatters.set(code, formatter);\n }\n\n /** Bulk-register multiple formatters from a partial map. */\n registerAll(map: FormatterMap): void {\n for (const [code, fn] of Object.entries(map)) {\n if (fn) {\n this.formatters.set(code as DiagnosticCode, fn);\n }\n }\n }\n\n /** Format a single diagnostic using the registered (or fallback) formatter. */\n format(diagnostic: Diagnostic): string {\n const fn = this.formatters.get(diagnostic.code) ?? this.fallback;\n return fn(diagnostic);\n }\n\n /** Format an array of diagnostics, joining with newlines. */\n formatAll(diagnostics: readonly Diagnostic[]): string {\n return diagnostics.map((d) => this.format(d)).join('\\n');\n }\n}\n\n/**\n * Create a new `FormatterRegistry` optionally pre-loaded with formatters.\n */\nexport function createFormatterRegistry(initial?: FormatterMap, fallback?: DiagnosticFormatterFn): FormatterRegistry {\n const registry = new FormatterRegistry(fallback);\n if (initial) {\n registry.registerAll(initial);\n }\n return registry;\n}\n"],"mappings":";;;;;;;AAQA,IAAa,oBAAb,MAA6D;CAC3D,AAAiB,6BAAa,IAAI,IAA2C;CAC7E,AAAiB;CAEjB,YAAY,WAAkC,iBAAiB;EAC7D,KAAK,WAAW;CAClB;;CAGA,SAAS,MAAsB,WAAwC;EACrE,KAAK,WAAW,IAAI,MAAM,SAAS;CACrC;;CAGA,YAAY,KAAyB;EACnC,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,GAAG,GACzC,IAAI,IACF,KAAK,WAAW,IAAI,MAAwB,EAAE;CAGpD;;CAGA,OAAO,YAAgC;EAErC,QADW,KAAK,WAAW,IAAI,WAAW,IAAI,KAAK,KAAK,SAC/C,CAAC,UAAU;CACtB;;CAGA,UAAU,aAA4C;EACpD,OAAO,YAAY,KAAK,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;CACzD;AACF;;;;AAKA,SAAgB,wBAAwB,SAAwB,UAAqD;CACnH,MAAM,WAAW,IAAI,kBAAkB,QAAQ;CAC/C,IAAI,SACF,SAAS,YAAY,OAAO;CAE9B,OAAO;AACT"}
|
package/dist/utils/indent.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
//#region src/utils/indent.d.ts
|
|
1
2
|
/** Indent every line of `text` by `spaces` spaces. */
|
|
2
|
-
|
|
3
|
+
declare function indent(text: string, spaces?: number): string;
|
|
3
4
|
/** Format an array of items as a bulleted list. */
|
|
4
|
-
|
|
5
|
+
declare function bulletList(items: readonly string[], bullet?: string): string;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { bulletList, indent };
|
|
5
8
|
//# sourceMappingURL=indent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indent.d.ts","
|
|
1
|
+
{"version":3,"file":"indent.d.ts","names":[],"sources":["../../src/utils/indent.ts"],"mappings":";;iBACgB,OAAO,cAAc;;iBASrB,WAAW,0BAA0B"}
|
package/dist/utils/indent.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
//#region src/utils/indent.ts
|
|
1
2
|
/** Indent every line of `text` by `spaces` spaces. */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
.split('\n')
|
|
6
|
-
.map((line) => `${pad}${line}`)
|
|
7
|
-
.join('\n');
|
|
3
|
+
function indent(text, spaces = 2) {
|
|
4
|
+
const pad = " ".repeat(spaces);
|
|
5
|
+
return text.split("\n").map((line) => `${pad}${line}`).join("\n");
|
|
8
6
|
}
|
|
9
7
|
/** Format an array of items as a bulleted list. */
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
function bulletList(items, bullet = "- ") {
|
|
9
|
+
return items.map((item) => `${bullet}${item}`).join("\n");
|
|
12
10
|
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { bulletList, indent };
|
|
13
14
|
//# sourceMappingURL=indent.js.map
|
package/dist/utils/indent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indent.js","
|
|
1
|
+
{"version":3,"file":"indent.js","names":[],"sources":["../../src/utils/indent.ts"],"sourcesContent":["/** Indent every line of `text` by `spaces` spaces. */\nexport function indent(text: string, spaces = 2): string {\n const pad = ' '.repeat(spaces);\n return text\n .split('\\n')\n .map((line) => `${pad}${line}`)\n .join('\\n');\n}\n\n/** Format an array of items as a bulleted list. */\nexport function bulletList(items: readonly string[], bullet = '- '): string {\n return items.map((item) => `${bullet}${item}`).join('\\n');\n}\n"],"mappings":";;AACA,SAAgB,OAAO,MAAc,SAAS,GAAW;CACvD,MAAM,MAAM,IAAI,OAAO,MAAM;CAC7B,OAAO,KACJ,MAAM,IAAI,CAAC,CACX,KAAK,SAAS,GAAG,MAAM,MAAM,CAAC,CAC9B,KAAK,IAAI;AACd;;AAGA,SAAgB,WAAW,OAA0B,SAAS,MAAc;CAC1E,OAAO,MAAM,KAAK,SAAS,GAAG,SAAS,MAAM,CAAC,CAAC,KAAK,IAAI;AAC1D"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uapkg/diagnostics-format",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "1.3.1",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=22"
|
|
6
|
+
},
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/MaximDevoir/uapkg.git",
|
|
10
|
+
"directory": "packages/uapkg-diagnostics-format"
|
|
11
|
+
},
|
|
6
12
|
"files": [
|
|
7
13
|
"dist",
|
|
8
14
|
"README.md"
|
|
9
15
|
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
10
19
|
"exports": {
|
|
11
20
|
".": {
|
|
12
21
|
"types": "./dist/index.d.ts",
|
|
@@ -17,27 +26,16 @@
|
|
|
17
26
|
"default": "./dist/ink/index.js"
|
|
18
27
|
}
|
|
19
28
|
},
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
29
|
"dependencies": {
|
|
22
30
|
"ink": "6.8.0",
|
|
23
31
|
"react": "19.2.4",
|
|
24
|
-
"@uapkg/diagnostics": "^1.
|
|
32
|
+
"@uapkg/diagnostics": "^1.3.1"
|
|
25
33
|
},
|
|
26
34
|
"devDependencies": {
|
|
27
35
|
"@types/react": "19.2.14"
|
|
28
36
|
},
|
|
29
|
-
"repository": {
|
|
30
|
-
"type": "git",
|
|
31
|
-
"url": "https://github.com/MaximDevoir/uapkg.git",
|
|
32
|
-
"directory": "packages/uapkg-diagnostics-format"
|
|
33
|
-
},
|
|
34
37
|
"scripts": {
|
|
35
|
-
"build": "
|
|
36
|
-
"build:watch": "
|
|
37
|
-
"lint": "biome lint .",
|
|
38
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
39
|
-
"test": "vitest run --config vitest.config.ts",
|
|
40
|
-
"test:coverage": "vitest run --coverage --config vitest.config.ts",
|
|
41
|
-
"test:watch": "vitest --config vitest.config.ts"
|
|
38
|
+
"build": "vp pack",
|
|
39
|
+
"build:watch": "vp pack --watch"
|
|
42
40
|
}
|
|
43
41
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormatterTypes.js","sourceRoot":"","sources":["../../src/contracts/FormatterTypes.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC7G,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,yCAAyC;AACzC,8EAA8E;AAG9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InkTypes.js","sourceRoot":"","sources":["../../../src/ink/contracts/InkTypes.ts"],"names":[],"mappings":""}
|
package/dist/ink/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ink/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,YAAY,EACV,uBAAuB,EACvB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC/F,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,GAC9B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/ink/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ink/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0CAA0C;AAC1C,EAAE;AACF,6EAA6E;AAC7E,oEAAoE;AACpE,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,2BAA2B;AAC3B,8EAA8E;AAE9E,8EAA8E;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAOtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,cAAc;AACd,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC/F,OAAO,EACL,mBAAmB,GAEpB,MAAM,gCAAgC,CAAC;AACxC,SAAS;AACT,OAAO,EAAE,cAAc,EAA4B,MAAM,2BAA2B,CAAC"}
|