typesea 0.1.0 → 0.3.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/CHANGELOG.md +85 -6
- package/README.md +143 -28
- package/dist/adapters/index.d.ts +50 -8
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +169 -48
- package/dist/aot/index.d.ts +19 -3
- package/dist/aot/index.d.ts.map +1 -1
- package/dist/aot/index.js +115 -17
- package/dist/async/index.d.ts +28 -56
- package/dist/async/index.d.ts.map +1 -1
- package/dist/async/index.js +94 -37
- package/dist/builders/composite.d.ts +43 -9
- package/dist/builders/composite.d.ts.map +1 -1
- package/dist/builders/composite.js +100 -17
- package/dist/builders/index.d.ts +8 -5
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +7 -4
- package/dist/builders/modifier.d.ts +36 -5
- package/dist/builders/modifier.d.ts.map +1 -1
- package/dist/builders/modifier.js +52 -5
- package/dist/builders/object/guard.d.ts +72 -24
- package/dist/builders/object/guard.d.ts.map +1 -1
- package/dist/builders/object/guard.js +139 -29
- package/dist/builders/object/index.d.ts +4 -2
- package/dist/builders/object/index.d.ts.map +1 -1
- package/dist/builders/object/index.js +3 -1
- package/dist/builders/object/schema.d.ts +88 -11
- package/dist/builders/object/schema.d.ts.map +1 -1
- package/dist/builders/object/schema.js +290 -23
- package/dist/builders/object/types.d.ts +20 -31
- package/dist/builders/object/types.d.ts.map +1 -1
- package/dist/builders/object/types.js +2 -0
- package/dist/builders/runtime.d.ts +40 -0
- package/dist/builders/runtime.d.ts.map +1 -0
- package/dist/builders/runtime.js +150 -0
- package/dist/builders/scalar.d.ts +49 -9
- package/dist/builders/scalar.d.ts.map +1 -1
- package/dist/builders/scalar.js +87 -9
- package/dist/builders/table.d.ts +35 -5
- package/dist/builders/table.d.ts.map +1 -1
- package/dist/builders/table.js +35 -5
- package/dist/builders/types.d.ts +20 -4
- package/dist/builders/types.d.ts.map +1 -1
- package/dist/builders/types.js +2 -0
- package/dist/compile/check-composite.d.ts +25 -2
- package/dist/compile/check-composite.d.ts.map +1 -1
- package/dist/compile/check-composite.js +699 -27
- package/dist/compile/check-scalar.d.ts +88 -0
- package/dist/compile/check-scalar.d.ts.map +1 -1
- package/dist/compile/check-scalar.js +570 -3
- package/dist/compile/check.d.ts +12 -0
- package/dist/compile/check.d.ts.map +1 -1
- package/dist/compile/check.js +62 -3
- package/dist/compile/context.d.ts +47 -9
- package/dist/compile/context.d.ts.map +1 -1
- package/dist/compile/context.js +53 -8
- package/dist/compile/first.d.ts +26 -0
- package/dist/compile/first.d.ts.map +1 -0
- package/dist/compile/first.js +850 -0
- package/dist/compile/graph-predicate.d.ts +4 -2
- package/dist/compile/graph-predicate.d.ts.map +1 -1
- package/dist/compile/graph-predicate.js +2272 -165
- package/dist/compile/guard.d.ts +16 -24
- package/dist/compile/guard.d.ts.map +1 -1
- package/dist/compile/guard.js +202 -72
- package/dist/compile/index.d.ts +3 -1
- package/dist/compile/index.d.ts.map +1 -1
- package/dist/compile/index.js +2 -0
- package/dist/compile/issue.d.ts +110 -0
- package/dist/compile/issue.d.ts.map +1 -1
- package/dist/compile/issue.js +184 -1
- package/dist/compile/names.d.ts +12 -2
- package/dist/compile/names.d.ts.map +1 -1
- package/dist/compile/names.js +19 -3
- package/dist/compile/predicate.d.ts +24 -0
- package/dist/compile/predicate.d.ts.map +1 -1
- package/dist/compile/predicate.js +287 -10
- package/dist/compile/runtime.d.ts +100 -13
- package/dist/compile/runtime.d.ts.map +1 -1
- package/dist/compile/runtime.js +56 -6
- package/dist/compile/source.d.ts +10 -2
- package/dist/compile/source.d.ts.map +1 -1
- package/dist/compile/source.js +385 -26
- package/dist/compile/types.d.ts +22 -0
- package/dist/compile/types.d.ts.map +1 -1
- package/dist/compile/types.js +2 -0
- package/dist/decoder/index.d.ts +92 -46
- package/dist/decoder/index.d.ts.map +1 -1
- package/dist/decoder/index.js +266 -39
- package/dist/evaluate/check-composite.d.ts +111 -2
- package/dist/evaluate/check-composite.d.ts.map +1 -1
- package/dist/evaluate/check-composite.js +343 -8
- package/dist/evaluate/check-scalar.d.ts +25 -0
- package/dist/evaluate/check-scalar.d.ts.map +1 -1
- package/dist/evaluate/check-scalar.js +124 -3
- package/dist/evaluate/check.d.ts +7 -0
- package/dist/evaluate/check.d.ts.map +1 -1
- package/dist/evaluate/check.js +62 -4
- package/dist/evaluate/index.d.ts +2 -0
- package/dist/evaluate/index.d.ts.map +1 -1
- package/dist/evaluate/index.js +2 -0
- package/dist/evaluate/issue.d.ts +11 -1
- package/dist/evaluate/issue.d.ts.map +1 -1
- package/dist/evaluate/issue.js +15 -1
- package/dist/evaluate/predicate.d.ts +16 -5
- package/dist/evaluate/predicate.d.ts.map +1 -1
- package/dist/evaluate/predicate.js +20 -5
- package/dist/evaluate/shared.d.ts +78 -13
- package/dist/evaluate/shared.d.ts.map +1 -1
- package/dist/evaluate/shared.js +101 -8
- package/dist/evaluate/state.d.ts +35 -13
- package/dist/evaluate/state.d.ts.map +1 -1
- package/dist/evaluate/state.js +35 -2
- package/dist/guard/array.d.ts +48 -0
- package/dist/guard/array.d.ts.map +1 -0
- package/dist/guard/array.js +84 -0
- package/dist/guard/base.d.ts +111 -31
- package/dist/guard/base.d.ts.map +1 -1
- package/dist/guard/base.js +165 -32
- package/dist/guard/date.d.ts +34 -0
- package/dist/guard/date.d.ts.map +1 -0
- package/dist/guard/date.js +60 -0
- package/dist/guard/error.d.ts +10 -5
- package/dist/guard/error.d.ts.map +1 -1
- package/dist/guard/error.js +10 -5
- package/dist/guard/index.d.ts +4 -0
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +4 -0
- package/dist/guard/number.d.ts +86 -11
- package/dist/guard/number.d.ts.map +1 -1
- package/dist/guard/number.js +159 -11
- package/dist/guard/props.d.ts +27 -3
- package/dist/guard/props.d.ts.map +1 -1
- package/dist/guard/props.js +27 -3
- package/dist/guard/read.d.ts +115 -10
- package/dist/guard/read.d.ts.map +1 -1
- package/dist/guard/read.js +185 -10
- package/dist/guard/registry.d.ts +12 -2
- package/dist/guard/registry.d.ts.map +1 -1
- package/dist/guard/registry.js +15 -3
- package/dist/guard/string.d.ts +115 -13
- package/dist/guard/string.d.ts.map +1 -1
- package/dist/guard/string.js +250 -13
- package/dist/guard/types.d.ts +110 -40
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/guard/types.js +2 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/internal/index.d.ts +42 -6
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +51 -8
- package/dist/ir/builder.d.ts +17 -127
- package/dist/ir/builder.d.ts.map +1 -1
- package/dist/ir/builder.js +80 -137
- package/dist/ir/freeze.d.ts +4 -0
- package/dist/ir/freeze.d.ts.map +1 -1
- package/dist/ir/freeze.js +66 -0
- package/dist/ir/index.d.ts +3 -1
- package/dist/ir/index.d.ts.map +1 -1
- package/dist/ir/index.js +2 -0
- package/dist/ir/regexp.d.ts +2 -0
- package/dist/ir/regexp.d.ts.map +1 -1
- package/dist/ir/regexp.js +2 -0
- package/dist/ir/types.d.ts +94 -56
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/ir/types.js +2 -0
- package/dist/ir/validate.d.ts +8 -1
- package/dist/ir/validate.d.ts.map +1 -1
- package/dist/ir/validate.js +511 -61
- package/dist/issue/index.d.ts +42 -10
- package/dist/issue/index.d.ts.map +1 -1
- package/dist/issue/index.js +65 -11
- package/dist/json-schema/emit-combinator.d.ts +44 -4
- package/dist/json-schema/emit-combinator.d.ts.map +1 -1
- package/dist/json-schema/emit-combinator.js +44 -4
- package/dist/json-schema/emit-composite.d.ts +16 -2
- package/dist/json-schema/emit-composite.d.ts.map +1 -1
- package/dist/json-schema/emit-composite.js +81 -13
- package/dist/json-schema/emit-scalar.d.ts +26 -3
- package/dist/json-schema/emit-scalar.d.ts.map +1 -1
- package/dist/json-schema/emit-scalar.js +124 -10
- package/dist/json-schema/emit-types.d.ts +11 -1
- package/dist/json-schema/emit-types.d.ts.map +1 -1
- package/dist/json-schema/emit-types.js +2 -0
- package/dist/json-schema/emit.d.ts +12 -1
- package/dist/json-schema/emit.d.ts.map +1 -1
- package/dist/json-schema/emit.js +23 -3
- package/dist/json-schema/freeze.d.ts +13 -2
- package/dist/json-schema/freeze.d.ts.map +1 -1
- package/dist/json-schema/freeze.js +41 -8
- package/dist/json-schema/index.d.ts +16 -2
- package/dist/json-schema/index.d.ts.map +1 -1
- package/dist/json-schema/index.js +23 -3
- package/dist/json-schema/issue.d.ts +4 -1
- package/dist/json-schema/issue.d.ts.map +1 -1
- package/dist/json-schema/issue.js +4 -1
- package/dist/json-schema/read.d.ts +24 -3
- package/dist/json-schema/read.d.ts.map +1 -1
- package/dist/json-schema/read.js +59 -12
- package/dist/json-schema/types.d.ts +45 -16
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/json-schema/types.js +2 -0
- package/dist/kind/index.d.ts +40 -28
- package/dist/kind/index.d.ts.map +1 -1
- package/dist/kind/index.js +41 -13
- package/dist/lower/index.d.ts +6 -1
- package/dist/lower/index.d.ts.map +1 -1
- package/dist/lower/index.js +462 -46
- package/dist/message/index.d.ts +64 -10
- package/dist/message/index.d.ts.map +1 -1
- package/dist/message/index.js +155 -17
- package/dist/optimize/algebraic.d.ts +54 -0
- package/dist/optimize/algebraic.d.ts.map +1 -0
- package/dist/optimize/algebraic.js +314 -0
- package/dist/optimize/compact.d.ts +8 -1
- package/dist/optimize/compact.d.ts.map +1 -1
- package/dist/optimize/compact.js +13 -2
- package/dist/optimize/domain.d.ts +16 -0
- package/dist/optimize/domain.d.ts.map +1 -0
- package/dist/optimize/domain.js +619 -0
- package/dist/optimize/fold-boolean.d.ts +17 -2
- package/dist/optimize/fold-boolean.d.ts.map +1 -1
- package/dist/optimize/fold-boolean.js +59 -14
- package/dist/optimize/fold-common.d.ts +43 -8
- package/dist/optimize/fold-common.d.ts.map +1 -1
- package/dist/optimize/fold-common.js +37 -6
- package/dist/optimize/fold-constraints.d.ts +33 -0
- package/dist/optimize/fold-constraints.d.ts.map +1 -0
- package/dist/optimize/fold-constraints.js +484 -0
- package/dist/optimize/fold-scalar.d.ts +98 -13
- package/dist/optimize/fold-scalar.d.ts.map +1 -1
- package/dist/optimize/fold-scalar.js +98 -13
- package/dist/optimize/fold.d.ts +8 -1
- package/dist/optimize/fold.d.ts.map +1 -1
- package/dist/optimize/fold.js +22 -2
- package/dist/optimize/index.d.ts +9 -1
- package/dist/optimize/index.d.ts.map +1 -1
- package/dist/optimize/index.js +18 -3
- package/dist/optimize/map-node.d.ts +3 -1
- package/dist/optimize/map-node.d.ts.map +1 -1
- package/dist/optimize/map-node.js +48 -3
- package/dist/optimize/peephole.d.ts +16 -0
- package/dist/optimize/peephole.d.ts.map +1 -0
- package/dist/optimize/peephole.js +254 -0
- package/dist/optimize/remap.d.ts +2 -0
- package/dist/optimize/remap.d.ts.map +1 -1
- package/dist/optimize/remap.js +2 -0
- package/dist/optimize/rewrite.d.ts +13 -8
- package/dist/optimize/rewrite.d.ts.map +1 -1
- package/dist/optimize/rewrite.js +13 -8
- package/dist/plan/cache.d.ts +9 -3
- package/dist/plan/cache.d.ts.map +1 -1
- package/dist/plan/cache.js +34 -6
- package/dist/plan/index.d.ts +2 -0
- package/dist/plan/index.d.ts.map +1 -1
- package/dist/plan/index.js +2 -0
- package/dist/plan/predicate.d.ts +2 -0
- package/dist/plan/predicate.d.ts.map +1 -1
- package/dist/plan/predicate.js +298 -29
- package/dist/plan/schema-predicate.d.ts +6 -0
- package/dist/plan/schema-predicate.d.ts.map +1 -1
- package/dist/plan/schema-predicate.js +382 -19
- package/dist/plan/types.d.ts +2 -0
- package/dist/plan/types.d.ts.map +1 -1
- package/dist/plan/types.js +2 -0
- package/dist/result/index.d.ts +19 -5
- package/dist/result/index.d.ts.map +1 -1
- package/dist/result/index.js +10 -2
- package/dist/schema/common.d.ts +69 -6
- package/dist/schema/common.d.ts.map +1 -1
- package/dist/schema/common.js +104 -10
- package/dist/schema/freeze.d.ts +4 -0
- package/dist/schema/freeze.d.ts.map +1 -1
- package/dist/schema/freeze.js +40 -0
- package/dist/schema/index.d.ts +5 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +4 -1
- package/dist/schema/lazy.d.ts +4 -0
- package/dist/schema/lazy.d.ts.map +1 -1
- package/dist/schema/lazy.js +4 -0
- package/dist/schema/literal.d.ts +7 -1
- package/dist/schema/literal.d.ts.map +1 -1
- package/dist/schema/literal.js +7 -1
- package/dist/schema/types.d.ts +109 -100
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +13 -2
- package/dist/schema/undefined.d.ts +17 -0
- package/dist/schema/undefined.d.ts.map +1 -0
- package/dist/schema/undefined.js +77 -0
- package/dist/schema/validate.d.ts +8 -1
- package/dist/schema/validate.d.ts.map +1 -1
- package/dist/schema/validate.js +255 -57
- package/docs/api.md +128 -8
- package/docs/assets/benchmark-headline.svg +163 -0
- package/docs/engine-notes.md +62 -15
- package/docs/index.html +1340 -702
- package/docs/ko/api.md +375 -0
- package/docs/ko/engine-notes.md +156 -0
- package/docs/ko/readme.md +378 -0
- package/package.json +66 -65
package/dist/message/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { type CheckResult, type Issue, type IssueCode, type PathSegment } from "../issue/index.js";
|
|
2
2
|
/**
|
|
3
|
-
* @brief message
|
|
3
|
+
* @brief Built-in locale identifiers accepted by the message renderer.
|
|
4
|
+
* @details Message helpers keep structured issues separate from human-readable formatting
|
|
5
|
+
* until callers request text.
|
|
4
6
|
*/
|
|
5
7
|
export type MessageLocale = "en" | "ko";
|
|
6
8
|
/**
|
|
7
|
-
* @brief
|
|
9
|
+
* @brief Render-time fields exposed to message templates.
|
|
10
|
+
* @details The context is deliberately string-only so user formatters never
|
|
11
|
+
* depend on internal issue object layout beyond the documented fields.
|
|
8
12
|
*/
|
|
9
13
|
export interface IssueMessageContext {
|
|
10
14
|
readonly path: string;
|
|
@@ -13,19 +17,31 @@ export interface IssueMessageContext {
|
|
|
13
17
|
readonly actual: string;
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
16
|
-
* @brief issue
|
|
20
|
+
* @brief User supplied issue formatter callback.
|
|
21
|
+
* @details Message helpers keep structured issues separate from human-readable formatting
|
|
22
|
+
* until callers request text.
|
|
23
|
+
* @param issue Frozen issue being rendered.
|
|
24
|
+
* @param context Preformatted string fields for template authors.
|
|
25
|
+
* @returns Final message text for that issue.
|
|
17
26
|
*/
|
|
18
27
|
export type IssueMessageFormatter = (issue: Issue, context: IssueMessageContext) => string;
|
|
19
28
|
/**
|
|
20
|
-
* @brief
|
|
29
|
+
* @brief Message template accepted by a locale catalog.
|
|
30
|
+
* @details String templates use `{path}`, `{code}`, `{expected}`, and
|
|
31
|
+
* `{actual}` replacement tokens. Function templates are checked at runtime so
|
|
32
|
+
* incorrect user callbacks fail at the API boundary.
|
|
21
33
|
*/
|
|
22
34
|
export type IssueMessageTemplate = string | IssueMessageFormatter;
|
|
23
35
|
/**
|
|
24
|
-
* @brief issue
|
|
36
|
+
* @brief Partial mapping from TypeSea issue codes to render templates.
|
|
37
|
+
* @details Message helpers keep structured issues separate from human-readable formatting
|
|
38
|
+
* until callers request text.
|
|
25
39
|
*/
|
|
26
40
|
export type IssueMessageCatalog = Partial<Readonly<Record<IssueCode, IssueMessageTemplate>>>;
|
|
27
41
|
/**
|
|
28
|
-
* @brief
|
|
42
|
+
* @brief Optional message rendering configuration supplied by callers.
|
|
43
|
+
* @details Every field is optional at the API edge; `readOptions` normalizes
|
|
44
|
+
* this shape into a fully populated internal configuration.
|
|
29
45
|
*/
|
|
30
46
|
export interface IssueMessageOptions {
|
|
31
47
|
readonly locale: MessageLocale | undefined;
|
|
@@ -33,19 +49,57 @@ export interface IssueMessageOptions {
|
|
|
33
49
|
readonly pathFormatter: ((path: readonly PathSegment[]) => string) | undefined;
|
|
34
50
|
}
|
|
35
51
|
/**
|
|
36
|
-
* @brief
|
|
52
|
+
* @brief Zod-style flattened message view.
|
|
53
|
+
* @details Root issues go into formErrors. Field issues are grouped by the
|
|
54
|
+
* first path segment so form adapters can attach messages to top-level fields.
|
|
55
|
+
*/
|
|
56
|
+
export interface FlattenedIssueMessages {
|
|
57
|
+
readonly formErrors: readonly string[];
|
|
58
|
+
readonly fieldErrors: Readonly<Record<string, readonly string[]>>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @brief Freeze a user catalog after validating its keys and templates.
|
|
62
|
+
* @details Message helpers keep structured issues separate from human-readable formatting
|
|
63
|
+
* until callers request text.
|
|
64
|
+
* @param catalog Partial message catalog supplied by the application.
|
|
65
|
+
* @returns Frozen catalog that can be reused across validations.
|
|
37
66
|
*/
|
|
38
67
|
export declare function defineMessages(catalog: IssueMessageCatalog): IssueMessageCatalog;
|
|
39
68
|
/**
|
|
40
|
-
* @brief
|
|
69
|
+
* @brief Render one issue into a localized human-readable message.
|
|
70
|
+
* @details The issue is copied before rendering so user callbacks cannot mutate
|
|
71
|
+
* shared diagnostic objects through accidental aliasing.
|
|
72
|
+
* @param issue Issue object to render.
|
|
73
|
+
* @param options Optional locale, catalog, and path formatter.
|
|
74
|
+
* @returns Rendered message text.
|
|
41
75
|
*/
|
|
42
76
|
export declare function formatIssue(issue: Issue, options?: Partial<IssueMessageOptions>): string;
|
|
43
77
|
/**
|
|
44
|
-
* @brief
|
|
78
|
+
* @brief Render a frozen list of issues into localized message strings.
|
|
79
|
+
* @details The issue array is copied before rendering so caller-owned issue
|
|
80
|
+
* objects cannot change while user path formatters or templates execute.
|
|
81
|
+
* @param issues Issue list to render.
|
|
82
|
+
* @param options Optional locale, catalog, and path formatter.
|
|
83
|
+
* @returns Frozen list of rendered messages aligned with the input issue order.
|
|
45
84
|
*/
|
|
46
85
|
export declare function formatIssues(issues: readonly Issue[], options?: Partial<IssueMessageOptions>): readonly string[];
|
|
47
86
|
/**
|
|
48
|
-
* @brief
|
|
87
|
+
* @brief Flatten issues into root and top-level field message buckets.
|
|
88
|
+
* @param issues Issue list returned by check-like APIs.
|
|
89
|
+
* @param options Optional locale, catalog, and path formatter.
|
|
90
|
+
* @returns Frozen flattened message object.
|
|
91
|
+
* @details This mirrors the practical shape of Zod's `error.flatten()` without
|
|
92
|
+
* changing TypeSea's allocation-free boolean path or array-based diagnostics.
|
|
93
|
+
*/
|
|
94
|
+
export declare function flattenIssues(issues: readonly Issue[], options?: Partial<IssueMessageOptions>): FlattenedIssueMessages;
|
|
95
|
+
/**
|
|
96
|
+
* @brief Attach rendered messages to every issue in a failed check result.
|
|
97
|
+
* @details Successful results are returned unchanged. Failed results are copied
|
|
98
|
+
* into fresh issue objects so structured diagnostics keep their original fields
|
|
99
|
+
* while gaining a stable human-readable message.
|
|
100
|
+
* @param result Check result to decorate.
|
|
101
|
+
* @param options Optional locale, catalog, and path formatter.
|
|
102
|
+
* @returns Original success result or a failed result with rendered messages.
|
|
49
103
|
*/
|
|
50
104
|
export declare function withMessages<TValue>(result: CheckResult<TValue>, options?: Partial<IssueMessageOptions>): CheckResult<TValue>;
|
|
51
105
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/message/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/message/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,WAAW,EACnB,MAAM,mBAAmB,CAAC;AAG3B;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAChC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,mBAAmB,KAC3B,MAAM,CAAC;AAEZ;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,qBAAqB,CAAC;AAElE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,CACrC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC,CACpD,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAClD,QAAQ,CAAC,aAAa,EAChB,CAAC,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,KAAK,MAAM,CAAC,GAC1C,SAAS,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;CACrE;AAaD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,mBAAmB,CAEhF;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACvB,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACvC,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CACxB,MAAM,EAAE,SAAS,KAAK,EAAE,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACvC,SAAS,MAAM,EAAE,CAWnB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CACzB,MAAM,EAAE,SAAS,KAAK,EAAE,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACvC,sBAAsB,CA4BxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAC/B,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,EAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACvC,WAAW,CAAC,MAAM,CAAC,CAoBrB"}
|
package/dist/message/index.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { copyIssueArray, freezeIssueArray, isIssueCodeValue, makeIssue } from "../issue/index.js";
|
|
2
2
|
import { err } from "../result/index.js";
|
|
3
3
|
/**
|
|
4
|
-
* @brief
|
|
4
|
+
* @brief Freeze a user catalog after validating its keys and templates.
|
|
5
|
+
* @details Message helpers keep structured issues separate from human-readable formatting
|
|
6
|
+
* until callers request text.
|
|
7
|
+
* @param catalog Partial message catalog supplied by the application.
|
|
8
|
+
* @returns Frozen catalog that can be reused across validations.
|
|
5
9
|
*/
|
|
6
10
|
export function defineMessages(catalog) {
|
|
7
11
|
return Object.freeze(copyCatalog(catalog));
|
|
8
12
|
}
|
|
9
13
|
/**
|
|
10
|
-
* @brief
|
|
14
|
+
* @brief Render one issue into a localized human-readable message.
|
|
15
|
+
* @details The issue is copied before rendering so user callbacks cannot mutate
|
|
16
|
+
* shared diagnostic objects through accidental aliasing.
|
|
17
|
+
* @param issue Issue object to render.
|
|
18
|
+
* @param options Optional locale, catalog, and path formatter.
|
|
19
|
+
* @returns Rendered message text.
|
|
11
20
|
*/
|
|
12
21
|
export function formatIssue(issue, options) {
|
|
13
22
|
const copied = copyIssueArray([issue]);
|
|
@@ -18,7 +27,12 @@ export function formatIssue(issue, options) {
|
|
|
18
27
|
return renderIssue(first, readOptions(options));
|
|
19
28
|
}
|
|
20
29
|
/**
|
|
21
|
-
* @brief
|
|
30
|
+
* @brief Render a frozen list of issues into localized message strings.
|
|
31
|
+
* @details The issue array is copied before rendering so caller-owned issue
|
|
32
|
+
* objects cannot change while user path formatters or templates execute.
|
|
33
|
+
* @param issues Issue list to render.
|
|
34
|
+
* @param options Optional locale, catalog, and path formatter.
|
|
35
|
+
* @returns Frozen list of rendered messages aligned with the input issue order.
|
|
22
36
|
*/
|
|
23
37
|
export function formatIssues(issues, options) {
|
|
24
38
|
const copied = copyIssueArray(issues);
|
|
@@ -33,7 +47,51 @@ export function formatIssues(issues, options) {
|
|
|
33
47
|
return Object.freeze(messages);
|
|
34
48
|
}
|
|
35
49
|
/**
|
|
36
|
-
* @brief
|
|
50
|
+
* @brief Flatten issues into root and top-level field message buckets.
|
|
51
|
+
* @param issues Issue list returned by check-like APIs.
|
|
52
|
+
* @param options Optional locale, catalog, and path formatter.
|
|
53
|
+
* @returns Frozen flattened message object.
|
|
54
|
+
* @details This mirrors the practical shape of Zod's `error.flatten()` without
|
|
55
|
+
* changing TypeSea's allocation-free boolean path or array-based diagnostics.
|
|
56
|
+
*/
|
|
57
|
+
export function flattenIssues(issues, options) {
|
|
58
|
+
const copied = copyIssueArray(issues);
|
|
59
|
+
const config = readOptions(options);
|
|
60
|
+
const formErrors = [];
|
|
61
|
+
const fieldErrors = Object.create(null);
|
|
62
|
+
for (let index = 0; index < copied.length; index += 1) {
|
|
63
|
+
const issue = copied[index];
|
|
64
|
+
if (issue === undefined) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const message = renderIssue(issue, config);
|
|
68
|
+
const first = issue.path[0];
|
|
69
|
+
if (first === undefined) {
|
|
70
|
+
formErrors.push(message);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const key = String(first);
|
|
74
|
+
const bucket = fieldErrors[key];
|
|
75
|
+
if (bucket === undefined) {
|
|
76
|
+
fieldErrors[key] = [message];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
bucket.push(message);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return Object.freeze({
|
|
83
|
+
formErrors: Object.freeze(formErrors),
|
|
84
|
+
fieldErrors: freezeFieldErrors(fieldErrors)
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @brief Attach rendered messages to every issue in a failed check result.
|
|
89
|
+
* @details Successful results are returned unchanged. Failed results are copied
|
|
90
|
+
* into fresh issue objects so structured diagnostics keep their original fields
|
|
91
|
+
* while gaining a stable human-readable message.
|
|
92
|
+
* @param result Check result to decorate.
|
|
93
|
+
* @param options Optional locale, catalog, and path formatter.
|
|
94
|
+
* @returns Original success result or a failed result with rendered messages.
|
|
37
95
|
*/
|
|
38
96
|
export function withMessages(result, options) {
|
|
39
97
|
if (result.ok) {
|
|
@@ -51,7 +109,13 @@ export function withMessages(result, options) {
|
|
|
51
109
|
return err(freezeIssueArray(issues));
|
|
52
110
|
}
|
|
53
111
|
/**
|
|
54
|
-
* @brief render issue.
|
|
112
|
+
* @brief Select the template source and render one normalized issue.
|
|
113
|
+
* @details Custom catalogs take precedence, issue-local messages are respected
|
|
114
|
+
* next, and built-in catalogs are the final fallback. That order lets adapters
|
|
115
|
+
* inject precise messages without losing defaults.
|
|
116
|
+
* @param issue Issue currently being rendered.
|
|
117
|
+
* @param options Resolved message rendering configuration.
|
|
118
|
+
* @returns Rendered message text.
|
|
55
119
|
*/
|
|
56
120
|
function renderIssue(issue, options) {
|
|
57
121
|
const context = makeContext(issue, options.pathFormatter);
|
|
@@ -65,7 +129,27 @@ function renderIssue(issue, options) {
|
|
|
65
129
|
return renderTemplate(defaultCatalogs[options.locale][issue.code], issue, context);
|
|
66
130
|
}
|
|
67
131
|
/**
|
|
68
|
-
* @brief
|
|
132
|
+
* @brief Freeze flattened field-error buckets.
|
|
133
|
+
* @param value Mutable field-error table.
|
|
134
|
+
* @returns Frozen table with frozen message arrays.
|
|
135
|
+
*/
|
|
136
|
+
function freezeFieldErrors(value) {
|
|
137
|
+
const keys = Object.keys(value);
|
|
138
|
+
for (let index = 0; index < keys.length; index += 1) {
|
|
139
|
+
const key = keys[index];
|
|
140
|
+
if (key !== undefined) {
|
|
141
|
+
Object.freeze(value[key]);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return Object.freeze(value);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* @brief Build the stable template context for one issue.
|
|
148
|
+
* @details Missing expected or actual fields become `"unknown"` so templates
|
|
149
|
+
* can stay branch-free and every placeholder always has a string value.
|
|
150
|
+
* @param issue Issue currently being rendered.
|
|
151
|
+
* @param pathFormatter Formatter selected by resolved options.
|
|
152
|
+
* @returns Context object passed to string and function templates.
|
|
69
153
|
*/
|
|
70
154
|
function makeContext(issue, pathFormatter) {
|
|
71
155
|
return {
|
|
@@ -76,7 +160,14 @@ function makeContext(issue, pathFormatter) {
|
|
|
76
160
|
};
|
|
77
161
|
}
|
|
78
162
|
/**
|
|
79
|
-
* @brief
|
|
163
|
+
* @brief Render a string or callback template against one issue context.
|
|
164
|
+
* @details Function templates are checked at runtime because they cross into
|
|
165
|
+
* user code. String templates use fixed token replacement without regular
|
|
166
|
+
* expressions, keeping the common path allocation pattern predictable.
|
|
167
|
+
* @param template Template selected for this issue code.
|
|
168
|
+
* @param issue Issue currently being rendered.
|
|
169
|
+
* @param context Preformatted replacement context.
|
|
170
|
+
* @returns Rendered message text.
|
|
80
171
|
*/
|
|
81
172
|
function renderTemplate(template, issue, context) {
|
|
82
173
|
if (typeof template === "function") {
|
|
@@ -93,7 +184,11 @@ function renderTemplate(template, issue, context) {
|
|
|
93
184
|
.split("{actual}").join(context.actual);
|
|
94
185
|
}
|
|
95
186
|
/**
|
|
96
|
-
* @brief
|
|
187
|
+
* @brief Normalize public rendering options into the internal shape.
|
|
188
|
+
* @details Validation happens once at the entry point. The render loop then
|
|
189
|
+
* works with concrete locale and formatter values without repeated guards.
|
|
190
|
+
* @param options Optional user configuration.
|
|
191
|
+
* @returns Resolved message rendering configuration.
|
|
97
192
|
*/
|
|
98
193
|
function readOptions(options) {
|
|
99
194
|
if (options === undefined) {
|
|
@@ -116,7 +211,11 @@ function readOptions(options) {
|
|
|
116
211
|
};
|
|
117
212
|
}
|
|
118
213
|
/**
|
|
119
|
-
* @brief
|
|
214
|
+
* @brief Validate and normalize the requested message locale.
|
|
215
|
+
* @details Message helpers keep structured issues separate from human-readable formatting
|
|
216
|
+
* until callers request text.
|
|
217
|
+
* @param value Locale field from the public options object.
|
|
218
|
+
* @returns Built-in locale identifier, defaulting to English.
|
|
120
219
|
*/
|
|
121
220
|
function readLocale(value) {
|
|
122
221
|
if (value === undefined || value === "en") {
|
|
@@ -128,7 +227,12 @@ function readLocale(value) {
|
|
|
128
227
|
throw new TypeError("message locale must be en or ko");
|
|
129
228
|
}
|
|
130
229
|
/**
|
|
131
|
-
* @brief
|
|
230
|
+
* @brief Validate the optional user path formatter.
|
|
231
|
+
* @details The returned wrapper enforces the string return contract at the
|
|
232
|
+
* boundary where user code is invoked, keeping downstream template replacement
|
|
233
|
+
* code simple.
|
|
234
|
+
* @param value Formatter value from public options.
|
|
235
|
+
* @returns Safe formatter callback used by the renderer.
|
|
132
236
|
*/
|
|
133
237
|
function readPathFormatter(value) {
|
|
134
238
|
if (value === undefined) {
|
|
@@ -147,7 +251,12 @@ function readPathFormatter(value) {
|
|
|
147
251
|
};
|
|
148
252
|
}
|
|
149
253
|
/**
|
|
150
|
-
* @brief copy catalog.
|
|
254
|
+
* @brief Validate and copy a user message catalog.
|
|
255
|
+
* @details The renderer stores only recognized issue-code keys and accepted
|
|
256
|
+
* template forms. Copying also prevents later caller mutation from changing
|
|
257
|
+
* messages during validation.
|
|
258
|
+
* @param value Candidate catalog object.
|
|
259
|
+
* @returns Catalog copy accepted by the renderer.
|
|
151
260
|
*/
|
|
152
261
|
function copyCatalog(value) {
|
|
153
262
|
if (!isRecord(value)) {
|
|
@@ -172,13 +281,21 @@ function copyCatalog(value) {
|
|
|
172
281
|
return copied;
|
|
173
282
|
}
|
|
174
283
|
/**
|
|
175
|
-
* @brief is
|
|
284
|
+
* @brief Check whether a catalog value is an accepted template form.
|
|
285
|
+
* @details Message helpers keep structured issues separate from human-readable formatting
|
|
286
|
+
* until callers request text.
|
|
287
|
+
* @param value Candidate catalog entry value.
|
|
288
|
+
* @returns True for string templates or formatter functions.
|
|
176
289
|
*/
|
|
177
290
|
function isIssueMessageTemplate(value) {
|
|
178
291
|
return typeof value === "string" || typeof value === "function";
|
|
179
292
|
}
|
|
180
293
|
/**
|
|
181
|
-
* @brief
|
|
294
|
+
* @brief Render a TypeSea issue path using JSON-like bracket segments.
|
|
295
|
+
* @details The root is `$`, numeric segments render as indexes, and string
|
|
296
|
+
* segments are JSON-escaped so dots or brackets in field names stay unambiguous.
|
|
297
|
+
* @param path Issue path to render.
|
|
298
|
+
* @returns Stable path string for message templates.
|
|
182
299
|
*/
|
|
183
300
|
function defaultPathFormatter(path) {
|
|
184
301
|
if (path.length === 0) {
|
|
@@ -197,23 +314,30 @@ function defaultPathFormatter(path) {
|
|
|
197
314
|
return result;
|
|
198
315
|
}
|
|
199
316
|
/**
|
|
200
|
-
* @brief
|
|
317
|
+
* @brief Check record.
|
|
318
|
+
* @details This helper keeps a local invariant explicit at the module boundary.
|
|
201
319
|
*/
|
|
202
320
|
function isRecord(value) {
|
|
203
321
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
204
322
|
}
|
|
205
323
|
/**
|
|
206
|
-
* @brief
|
|
324
|
+
* @brief Built-in English issue message catalog.
|
|
325
|
+
* @details Templates stay terse and token-based so the same renderer can handle
|
|
326
|
+
* built-in and user-defined catalogs without locale-specific code paths.
|
|
207
327
|
*/
|
|
208
328
|
const enCatalog = Object.freeze({
|
|
209
329
|
expected_string: "Expected string at {path}; received {actual}.",
|
|
210
330
|
expected_number: "Expected number at {path}; received {actual}.",
|
|
331
|
+
expected_date: "Expected valid Date at {path}; received {actual}.",
|
|
211
332
|
expected_bigint: "Expected bigint at {path}; received {actual}.",
|
|
212
333
|
expected_symbol: "Expected symbol at {path}; received {actual}.",
|
|
213
334
|
expected_boolean: "Expected boolean at {path}; received {actual}.",
|
|
214
335
|
expected_never: "Expected never at {path}; received {actual}.",
|
|
215
336
|
expected_literal: "Expected literal {expected} at {path}; received {actual}.",
|
|
216
337
|
expected_array: "Expected array at {path}; received {actual}.",
|
|
338
|
+
expected_map: "Expected Map at {path}; received {actual}.",
|
|
339
|
+
expected_set: "Expected Set at {path}; received {actual}.",
|
|
340
|
+
expected_instance: "Expected instance of {expected} at {path}; received {actual}.",
|
|
217
341
|
expected_tuple: "Expected tuple at {path}; received {actual}.",
|
|
218
342
|
expected_tuple_length: "Expected tuple {expected} at {path}; received {actual}.",
|
|
219
343
|
expected_object: "Expected object at {path}; received {actual}.",
|
|
@@ -224,6 +348,9 @@ const enCatalog = Object.freeze({
|
|
|
224
348
|
expected_pattern: "Expected pattern {expected} at {path}; received {actual}.",
|
|
225
349
|
expected_gte: "Expected value {expected} at {path}; received {actual}.",
|
|
226
350
|
expected_lte: "Expected value {expected} at {path}; received {actual}.",
|
|
351
|
+
expected_gt: "Expected value {expected} at {path}; received {actual}.",
|
|
352
|
+
expected_lt: "Expected value {expected} at {path}; received {actual}.",
|
|
353
|
+
expected_multiple_of: "Expected value {expected} at {path}; received {actual}.",
|
|
227
354
|
expected_required_key: "Expected required key at {path}; received {actual}.",
|
|
228
355
|
expected_union: "Expected union at {path}; received {actual}.",
|
|
229
356
|
expected_discriminant: "Expected discriminant {expected} at {path}; received {actual}.",
|
|
@@ -232,17 +359,23 @@ const enCatalog = Object.freeze({
|
|
|
232
359
|
unrecognized_key: "Unrecognized key at {path}; expected {expected}."
|
|
233
360
|
});
|
|
234
361
|
/**
|
|
235
|
-
* @brief
|
|
362
|
+
* @brief Built-in Korean issue message catalog.
|
|
363
|
+
* @details The catalog mirrors English issue-code coverage exactly so locale
|
|
364
|
+
* switching cannot expose missing template keys at runtime.
|
|
236
365
|
*/
|
|
237
366
|
const koCatalog = Object.freeze({
|
|
238
367
|
expected_string: "{path}에서 문자열이 필요하지만 {actual}을 받았습니다.",
|
|
239
368
|
expected_number: "{path}에서 숫자가 필요하지만 {actual}을 받았습니다.",
|
|
369
|
+
expected_date: "{path}에서 유효한 Date가 필요하지만 {actual}을 받았습니다.",
|
|
240
370
|
expected_bigint: "{path}에서 bigint가 필요하지만 {actual}을 받았습니다.",
|
|
241
371
|
expected_symbol: "{path}에서 symbol이 필요하지만 {actual}을 받았습니다.",
|
|
242
372
|
expected_boolean: "{path}에서 boolean이 필요하지만 {actual}을 받았습니다.",
|
|
243
373
|
expected_never: "{path}에서 never가 필요하지만 {actual}을 받았습니다.",
|
|
244
374
|
expected_literal: "{path}에서 literal {expected}이 필요하지만 {actual}을 받았습니다.",
|
|
245
375
|
expected_array: "{path}에서 배열이 필요하지만 {actual}을 받았습니다.",
|
|
376
|
+
expected_map: "{path}에서 Map이 필요하지만 {actual}을 받았습니다.",
|
|
377
|
+
expected_set: "{path}에서 Set이 필요하지만 {actual}을 받았습니다.",
|
|
378
|
+
expected_instance: "{path}에서 {expected} 인스턴스가 필요하지만 {actual}을 받았습니다.",
|
|
246
379
|
expected_tuple: "{path}에서 튜플이 필요하지만 {actual}을 받았습니다.",
|
|
247
380
|
expected_tuple_length: "{path}에서 튜플 {expected}이 필요하지만 {actual}을 받았습니다.",
|
|
248
381
|
expected_object: "{path}에서 객체가 필요하지만 {actual}을 받았습니다.",
|
|
@@ -253,6 +386,9 @@ const koCatalog = Object.freeze({
|
|
|
253
386
|
expected_pattern: "{path}에서 패턴 {expected}이 필요하지만 {actual}을 받았습니다.",
|
|
254
387
|
expected_gte: "{path}에서 값 {expected}이 필요하지만 {actual}을 받았습니다.",
|
|
255
388
|
expected_lte: "{path}에서 값 {expected}이 필요하지만 {actual}을 받았습니다.",
|
|
389
|
+
expected_gt: "{path}에서 값 {expected}이 필요하지만 {actual}을 받았습니다.",
|
|
390
|
+
expected_lt: "{path}에서 값 {expected}이 필요하지만 {actual}을 받았습니다.",
|
|
391
|
+
expected_multiple_of: "{path}에서 값 {expected}이 필요하지만 {actual}을 받았습니다.",
|
|
256
392
|
expected_required_key: "{path}에 필수 키가 필요하지만 {actual}입니다.",
|
|
257
393
|
expected_union: "{path}에서 유니온 값이 필요하지만 {actual}을 받았습니다.",
|
|
258
394
|
expected_discriminant: "{path}에서 discriminant {expected}이 필요하지만 {actual}을 받았습니다.",
|
|
@@ -261,7 +397,9 @@ const koCatalog = Object.freeze({
|
|
|
261
397
|
unrecognized_key: "{path}에서 알 수 없는 키입니다. 기대값은 {expected}입니다."
|
|
262
398
|
});
|
|
263
399
|
/**
|
|
264
|
-
* @brief
|
|
400
|
+
* @brief Frozen lookup table for built-in message catalogs.
|
|
401
|
+
* @details The table is keyed by normalized locale values, letting renderIssue
|
|
402
|
+
* index without optional fallback logic after option resolution.
|
|
265
403
|
*/
|
|
266
404
|
const defaultCatalogs = Object.freeze({
|
|
267
405
|
en: enCatalog,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file algebraic.ts
|
|
3
|
+
* @brief Boolean algebra simplification for validation predicates.
|
|
4
|
+
* @details Optimizer helpers preserve graph equivalence while shrinking redundant nodes
|
|
5
|
+
* before code generation consumes the graph.
|
|
6
|
+
*/
|
|
7
|
+
import { NodeTag } from "../kind/index.js";
|
|
8
|
+
import type { GraphNode, NodeId } from "../ir/index.js";
|
|
9
|
+
export interface AlgebraicFold {
|
|
10
|
+
/**
|
|
11
|
+
* @brief True when an And fold has proven false.
|
|
12
|
+
* @details The caller replaces the whole conjunction with a constant false node.
|
|
13
|
+
*/
|
|
14
|
+
readonly contradiction: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* @brief True when an Or fold has proven true.
|
|
17
|
+
* @details The caller replaces the whole disjunction with a constant true node.
|
|
18
|
+
*/
|
|
19
|
+
readonly tautology: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @brief Remaining operand ids after algebraic simplification.
|
|
22
|
+
* @details Operand order is preserved so generated code keeps stable branch ordering.
|
|
23
|
+
*/
|
|
24
|
+
readonly values: readonly NodeId[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @brief Flatten nested boolean folds of the same kind.
|
|
28
|
+
* @details Optimizer helpers preserve graph equivalence while shrinking redundant nodes
|
|
29
|
+
* before code generation consumes the graph.
|
|
30
|
+
* @param values Input operand ids.
|
|
31
|
+
* @param nodes Graph node table used to inspect nested folds.
|
|
32
|
+
* @param tag Boolean fold kind to flatten.
|
|
33
|
+
* @returns Operand list with same-kind nested folds expanded in place.
|
|
34
|
+
*/
|
|
35
|
+
export declare function flattenBooleanValues(values: readonly NodeId[], nodes: readonly GraphNode[], tag: typeof NodeTag.And | typeof NodeTag.Or): readonly NodeId[];
|
|
36
|
+
/**
|
|
37
|
+
* @brief Simplify operands of an And fold.
|
|
38
|
+
* @details Optimizer helpers preserve graph equivalence while shrinking redundant nodes
|
|
39
|
+
* before code generation consumes the graph.
|
|
40
|
+
* @param values Input operand ids.
|
|
41
|
+
* @param nodes Graph node table used to inspect nested complement forms.
|
|
42
|
+
* @returns Simplification result with contradiction status and kept operands.
|
|
43
|
+
*/
|
|
44
|
+
export declare function simplifyAndValues(values: readonly NodeId[], nodes: readonly GraphNode[]): AlgebraicFold;
|
|
45
|
+
/**
|
|
46
|
+
* @brief Simplify operands of an Or fold.
|
|
47
|
+
* @details Optimizer helpers preserve graph equivalence while shrinking redundant nodes
|
|
48
|
+
* before code generation consumes the graph.
|
|
49
|
+
* @param values Input operand ids.
|
|
50
|
+
* @param nodes Graph node table used to inspect nested complement forms.
|
|
51
|
+
* @returns Simplification result with tautology status and kept operands.
|
|
52
|
+
*/
|
|
53
|
+
export declare function simplifyOrValues(values: readonly NodeId[], nodes: readonly GraphNode[]): AlgebraicFold;
|
|
54
|
+
//# sourceMappingURL=algebraic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algebraic.d.ts","sourceRoot":"","sources":["../../src/optimize/algebraic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,EACR,SAAS,EACT,MAAM,EACT,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,aAAa;IAC1B;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,GAAG,EAAE,OAAO,OAAO,CAAC,GAAG,GAAG,OAAO,OAAO,CAAC,EAAE,GAC5C,SAAS,MAAM,EAAE,CAmBnB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,KAAK,EAAE,SAAS,SAAS,EAAE,GAC5B,aAAa,CAuCf;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,KAAK,EAAE,SAAS,SAAS,EAAE,GAC5B,aAAa,CAuCf"}
|