schema-components 2.0.2 → 2.1.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.
Files changed (197) hide show
  1. package/README.md +133 -1
  2. package/dist/SchemaComponent-B__6-5-E.d.mts +277 -0
  3. package/dist/SchemaComponent-BxzzsHsK.mjs +668 -0
  4. package/dist/adapter-ktQaheWB.d.mts +213 -0
  5. package/dist/constructorTypes-BdCiMS6e.d.mts +30 -0
  6. package/dist/core/adapter.d.mts +3 -213
  7. package/dist/core/constraintHint.d.mts +1 -1
  8. package/dist/core/constraints.d.mts +2 -2
  9. package/dist/core/contexts.d.mts +71 -0
  10. package/dist/core/contexts.mjs +1 -0
  11. package/dist/core/diagnostics.d.mts +1 -1
  12. package/dist/core/errors.d.mts +1 -1
  13. package/dist/core/fieldOrder.d.mts +1 -1
  14. package/dist/{react → core}/fieldPath.d.mts +2 -2
  15. package/dist/{react → core}/fieldPath.mjs +3 -3
  16. package/dist/core/formats.d.mts +1 -1
  17. package/dist/core/inferValue.d.mts +1 -1
  18. package/dist/core/limits.d.mts +1 -1
  19. package/dist/core/merge.d.mts +1 -1
  20. package/dist/core/normalise.d.mts +2 -2
  21. package/dist/core/ref.d.mts +1 -1
  22. package/dist/core/renderField.d.mts +147 -0
  23. package/dist/core/renderField.mjs +115 -0
  24. package/dist/core/renderer.d.mts +2 -199
  25. package/dist/core/swagger2.d.mts +1 -1
  26. package/dist/core/typeInference.d.mts +1 -982
  27. package/dist/core/types.d.mts +1 -1
  28. package/dist/core/unionMatch.d.mts +1 -1
  29. package/dist/core/version.d.mts +1 -1
  30. package/dist/core/walkBuilders.d.mts +3 -3
  31. package/dist/core/walker.d.mts +1 -1
  32. package/dist/{errors-Dki7tji4.d.mts → errors-DbaI04x2.d.mts} +1 -1
  33. package/dist/html/a11y.d.mts +2 -2
  34. package/dist/html/renderToHtml.d.mts +5 -5
  35. package/dist/html/renderToHtml.mjs +33 -18
  36. package/dist/html/renderToHtmlStream.d.mts +5 -5
  37. package/dist/html/renderers.d.mts +1 -1
  38. package/dist/html/streamRenderers.d.mts +15 -6
  39. package/dist/html/streamRenderers.mjs +56 -10
  40. package/dist/{inferValue-Ce-PviSD.d.mts → inferValue-eAnh50EM.d.mts} +3 -3
  41. package/dist/lit/SchemaComponent.d.mts +125 -0
  42. package/dist/lit/SchemaComponent.mjs +2 -0
  43. package/dist/lit/SchemaField.d.mts +65 -0
  44. package/dist/lit/SchemaField.mjs +2 -0
  45. package/dist/lit/SchemaView.d.mts +14 -0
  46. package/dist/lit/SchemaView.mjs +2 -0
  47. package/dist/lit/constructorTypes.d.mts +2 -0
  48. package/dist/lit/constructorTypes.mjs +1 -0
  49. package/dist/lit/contexts.d.mts +78 -0
  50. package/dist/lit/contexts.mjs +238 -0
  51. package/dist/lit/defaultResolver.d.mts +33 -0
  52. package/dist/lit/defaultResolver.mjs +2 -0
  53. package/dist/lit/registry.d.mts +66 -0
  54. package/dist/lit/registry.mjs +2 -0
  55. package/dist/lit/renderers/baseElement.d.mts +131 -0
  56. package/dist/lit/renderers/baseElement.mjs +109 -0
  57. package/dist/lit/renderers/recordHelpers.d.mts +25 -0
  58. package/dist/lit/renderers/recordHelpers.mjs +55 -0
  59. package/dist/lit/renderers/scArray.d.mts +14 -0
  60. package/dist/lit/renderers/scArray.mjs +86 -0
  61. package/dist/lit/renderers/scBoolean.d.mts +15 -0
  62. package/dist/lit/renderers/scBoolean.mjs +47 -0
  63. package/dist/lit/renderers/scConditional.d.mts +23 -0
  64. package/dist/lit/renderers/scConditional.mjs +65 -0
  65. package/dist/lit/renderers/scDiscriminated.d.mts +23 -0
  66. package/dist/lit/renderers/scDiscriminated.mjs +138 -0
  67. package/dist/lit/renderers/scEnum.d.mts +16 -0
  68. package/dist/lit/renderers/scEnum.mjs +66 -0
  69. package/dist/lit/renderers/scFile.d.mts +15 -0
  70. package/dist/lit/renderers/scFile.mjs +53 -0
  71. package/dist/lit/renderers/scLiteralNullNever.d.mts +30 -0
  72. package/dist/lit/renderers/scLiteralNullNever.mjs +57 -0
  73. package/dist/lit/renderers/scNumber.d.mts +15 -0
  74. package/dist/lit/renderers/scNumber.mjs +64 -0
  75. package/dist/lit/renderers/scObject.d.mts +14 -0
  76. package/dist/lit/renderers/scObject.mjs +57 -0
  77. package/dist/lit/renderers/scRecord.d.mts +14 -0
  78. package/dist/lit/renderers/scRecord.mjs +112 -0
  79. package/dist/lit/renderers/scString.d.mts +19 -0
  80. package/dist/lit/renderers/scString.mjs +165 -0
  81. package/dist/lit/renderers/scTuple.d.mts +14 -0
  82. package/dist/lit/renderers/scTuple.mjs +58 -0
  83. package/dist/lit/renderers/scUnion.d.mts +14 -0
  84. package/dist/lit/renderers/scUnion.mjs +44 -0
  85. package/dist/lit/renderers/scUnknown.d.mts +15 -0
  86. package/dist/lit/renderers/scUnknown.mjs +45 -0
  87. package/dist/lit/ssr.d.mts +37 -0
  88. package/dist/lit/ssr.mjs +9565 -0
  89. package/dist/lit/types.d.mts +2 -0
  90. package/dist/lit/types.mjs +1 -0
  91. package/dist/lit/widget.d.mts +71 -0
  92. package/dist/lit/widget.mjs +87 -0
  93. package/dist/openapi/ApiCallbacks.d.mts +1 -1
  94. package/dist/openapi/ApiLinks.d.mts +1 -1
  95. package/dist/openapi/ApiResponseHeaders.d.mts +1 -1
  96. package/dist/openapi/ApiSecurity.d.mts +1 -1
  97. package/dist/openapi/components.d.mts +4 -4
  98. package/dist/openapi/parser.d.mts +2 -2
  99. package/dist/openapi/resolve.d.mts +1 -1
  100. package/dist/preact/SchemaComponent.d.mts +3 -0
  101. package/dist/preact/SchemaComponent.mjs +26 -0
  102. package/dist/preact/SchemaErrorBoundary.d.mts +2 -0
  103. package/dist/preact/SchemaErrorBoundary.mjs +20 -0
  104. package/dist/preact/SchemaView.d.mts +2 -0
  105. package/dist/preact/SchemaView.mjs +22 -0
  106. package/dist/preact/headless.d.mts +2 -0
  107. package/dist/preact/headless.mjs +18 -0
  108. package/dist/react/SchemaComponent.d.mts +3 -270
  109. package/dist/react/SchemaComponent.mjs +41 -32
  110. package/dist/react/SchemaView.d.mts +6 -6
  111. package/dist/react/SchemaView.mjs +32 -29
  112. package/dist/react/a11y.d.mts +2 -2
  113. package/dist/react/fieldShell.d.mts +1 -1
  114. package/dist/react/headless.d.mts +1 -1
  115. package/dist/react/headlessRenderers.d.mts +2 -2
  116. package/dist/{ref-DdsbekXX.d.mts → ref-DWrQG1Er.d.mts} +1 -1
  117. package/dist/renderer-ab9E52Bp.d.mts +245 -0
  118. package/dist/solid/SchemaComponent.d.mts +136 -0
  119. package/dist/solid/SchemaComponent.mjs +391 -0
  120. package/dist/solid/SchemaErrorBoundary.d.mts +38 -0
  121. package/dist/solid/SchemaErrorBoundary.mjs +57 -0
  122. package/dist/solid/SchemaField.d.mts +40 -0
  123. package/dist/solid/SchemaField.mjs +113 -0
  124. package/dist/solid/SchemaView.d.mts +54 -0
  125. package/dist/solid/SchemaView.mjs +168 -0
  126. package/dist/solid/a11y.d.mts +70 -0
  127. package/dist/solid/a11y.mjs +71 -0
  128. package/dist/solid/contexts.d.mts +37 -0
  129. package/dist/solid/contexts.mjs +66 -0
  130. package/dist/solid/headless.d.mts +10 -0
  131. package/dist/solid/headless.mjs +27 -0
  132. package/dist/solid/renderers.d.mts +79 -0
  133. package/dist/solid/renderers.mjs +840 -0
  134. package/dist/solid/types.d.mts +90 -0
  135. package/dist/solid/types.mjs +1 -0
  136. package/dist/solid/widget.d.mts +29 -0
  137. package/dist/solid/widget.mjs +35 -0
  138. package/dist/themes/mantine.d.mts +1 -1
  139. package/dist/themes/mui.d.mts +1 -1
  140. package/dist/themes/radix.d.mts +1 -1
  141. package/dist/themes/shadcn.d.mts +1 -1
  142. package/dist/typeInference-Y8tNEQJk.d.mts +983 -0
  143. package/dist/types-BCy7K3nk.d.mts +125 -0
  144. package/package.json +73 -1
  145. package/src/svelte/SchemaComponent.svelte +427 -0
  146. package/src/svelte/SchemaErrorBoundary.svelte +66 -0
  147. package/src/svelte/SchemaField.svelte +216 -0
  148. package/src/svelte/SchemaProvider.svelte +46 -0
  149. package/src/svelte/SchemaView.svelte +244 -0
  150. package/src/svelte/a11y.ts +112 -0
  151. package/src/svelte/contexts.ts +79 -0
  152. package/src/svelte/dispatch.ts +267 -0
  153. package/src/svelte/headless.ts +73 -0
  154. package/src/svelte/headlessFns.ts +124 -0
  155. package/src/svelte/renderers/Array.svelte +98 -0
  156. package/src/svelte/renderers/Boolean.svelte +43 -0
  157. package/src/svelte/renderers/Conditional.svelte +67 -0
  158. package/src/svelte/renderers/DiscriminatedUnion.svelte +197 -0
  159. package/src/svelte/renderers/Enum.svelte +53 -0
  160. package/src/svelte/renderers/Fallback.svelte +24 -0
  161. package/src/svelte/renderers/File.svelte +46 -0
  162. package/src/svelte/renderers/Literal.svelte +29 -0
  163. package/src/svelte/renderers/Mount.svelte +24 -0
  164. package/src/svelte/renderers/Negation.svelte +35 -0
  165. package/src/svelte/renderers/Never.svelte +24 -0
  166. package/src/svelte/renderers/Null.svelte +19 -0
  167. package/src/svelte/renderers/Number.svelte +68 -0
  168. package/src/svelte/renderers/Object.svelte +74 -0
  169. package/src/svelte/renderers/Record.svelte +134 -0
  170. package/src/svelte/renderers/RecursionSentinel.svelte +27 -0
  171. package/src/svelte/renderers/String.svelte +152 -0
  172. package/src/svelte/renderers/Tuple.svelte +84 -0
  173. package/src/svelte/renderers/Union.svelte +49 -0
  174. package/src/svelte/renderers/Unknown.svelte +42 -0
  175. package/src/svelte/svelte-modules.d.ts +25 -0
  176. package/src/svelte/types.ts +238 -0
  177. package/src/svelte/widget.ts +62 -0
  178. package/src/vue/SchemaComponent.vue +274 -0
  179. package/src/vue/SchemaErrorBoundary.vue +60 -0
  180. package/src/vue/SchemaField.vue +178 -0
  181. package/src/vue/SchemaProvider.vue +39 -0
  182. package/src/vue/SchemaView.vue +198 -0
  183. package/src/vue/VNodeHost.ts +32 -0
  184. package/src/vue/contexts.ts +116 -0
  185. package/src/vue/eventTargets.ts +35 -0
  186. package/src/vue/headless.ts +61 -0
  187. package/src/vue/idPrefix.ts +79 -0
  188. package/src/vue/renderField.ts +182 -0
  189. package/src/vue/renderers.ts +1297 -0
  190. package/src/vue/resolver.ts +45 -0
  191. package/src/vue/types.ts +140 -0
  192. package/src/vue/vue-shim.d.ts +25 -0
  193. package/src/vue/widget.ts +51 -0
  194. /package/dist/{diagnostics-BTrm3O6J.d.mts → diagnostics-mftUZI7c.d.mts} +0 -0
  195. /package/dist/{limits-x4OiyJxh.d.mts → limits-Vv9hUbI_.d.mts} +0 -0
  196. /package/dist/{types-BrYbjC7_.d.mts → types-BBQaEPfE.d.mts} +0 -0
  197. /package/dist/{version-DL8U5RuA.d.mts → version-BEBx10ND.d.mts} +0 -0
@@ -0,0 +1,213 @@
1
+ import { m as JsonObject, w as SchemaMeta } from "./types-BBQaEPfE.mjs";
2
+ import { i as DiagnosticsOptions } from "./diagnostics-mftUZI7c.mjs";
3
+
4
+ //#region src/core/adapter.d.ts
5
+ /**
6
+ * Classification produced by {@link detectSchemaKind} when inspecting a
7
+ * runtime schema input.
8
+ *
9
+ * @group Adapter
10
+ */
11
+ type SchemaKind = "zod4" | "zod3" | "jsonSchema" | "openapi" | "unsupported-schema-lib";
12
+ /**
13
+ * Classify a runtime schema input by structural markers — Zod 4, Zod 3,
14
+ * OpenAPI document, plain JSON Schema, or an unsupported third-party
15
+ * schema library.
16
+ *
17
+ * - `zod4` — has a `_zod` marker (further validation that `_zod.def` is a
18
+ * non-null object happens inside `normaliseZod4`).
19
+ * - `zod3` — has `_def` and no `_zod`. The `typeName` field is no longer
20
+ * required: any `_def` without `_zod` is treated as a probable Zod 3
21
+ * schema. Third-party libraries that expose `_def` without `_zod` are
22
+ * nearly always Zod 3 forks; surfacing the migration message is the
23
+ * correct response.
24
+ * - `openapi` — has `openapi` or `swagger` at the root.
25
+ * - `unsupported-schema-lib` — has `parse` and `safeParse` callables but
26
+ * no `_zod` and no `_def` marker. This catches Standard Schema
27
+ * implementations (valibot, arktype, etc.) that would otherwise flow
28
+ * through as "malformed JSON Schema".
29
+ * - `jsonSchema` — fallback for anything that does not match the above.
30
+ *
31
+ * @group Adapter
32
+ */
33
+ declare function detectSchemaKind(input: unknown): SchemaKind;
34
+ /**
35
+ * Wraps z.toJSONSchema() for a runtime-validated Zod schema.
36
+ *
37
+ * The _zod guard in normaliseZod4 has confirmed this is a valid Zod schema,
38
+ * but TypeScript cannot represent "has _zod.def" as the $ZodType parameter
39
+ * that z.toJSONSchema expects. This is the library boundary equivalent of
40
+ * `object → Record<string, unknown>` — the type mismatch is genuinely unavoidable.
41
+ *
42
+ * # Options
43
+ *
44
+ * `z.toJSONSchema` is invoked with an explicit options object rather than
45
+ * Zod's defaults so the conversion contract is pinned and stable:
46
+ *
47
+ * - `target: "draft-2020-12"` — matches the walker's draft target.
48
+ * - `unrepresentable: "throw"` — keeps the unrepresentable-type rules in
49
+ * the classifier table firing instead of silently emitting `{}`.
50
+ * - `cycles: "ref"` — converts cyclic graphs into $ref pairs rather than
51
+ * throwing. Cycles in user schemas surface through the walker's $ref
52
+ * resolution rather than the adapter.
53
+ * - `io` — selects which side of every transform / pipe / codec is
54
+ * converted. Defaults to `"output"` (the OUTPUT side); pass `"input"`
55
+ * to render the INPUT side instead. The input side is invisible to
56
+ * the converted schema when `io: "output"` is in force, even though
57
+ * `safeParse` on the same Zod schema consumes the input shape. For
58
+ * transforms this divergence is fatal and the call throws via
59
+ * `Transforms cannot be represented`; for `z.codec(...)` the call
60
+ * succeeds but only the selected side is rendered. Consumers receive
61
+ * a `zod-codec-output-only` diagnostic in the codec case so the
62
+ * asymmetry is visible — see `screenPreConversion`.
63
+ *
64
+ * # Error classification
65
+ *
66
+ * Any exception thrown by z.toJSONSchema is classified into a
67
+ * SchemaNormalisationError so the caller does not have to re-parse error
68
+ * message strings. The classification covers:
69
+ *
70
+ * - Nested Zod 3 schemas inside a Zod 4 tree → zod3-unsupported.
71
+ * Detected structurally (presence of `_def.typeName` markers anywhere
72
+ * in the schema tree) so the check works across V8, JavaScriptCore,
73
+ * and SpiderMonkey, none of which agree on the wording of
74
+ * "Cannot read properties of undefined".
75
+ * - Transforms → zod-transform-unsupported. This also catches `z.codec(…)`
76
+ * because Zod implements codecs as a pipe + transform internally, so
77
+ * they trip the same processor when round-tripping is forced. (Plain
78
+ * `z.toJSONSchema(codec)` itself does NOT throw because Zod picks one
79
+ * side of the codec; the static rejection in `typeInference.ts` is the
80
+ * compile-time guard.)
81
+ * - Dynamic catch values whose handler throws → zod-type-unrepresentable
82
+ * with zodType "dynamic-catch".
83
+ * - Unrepresentable types — bigint, date, map, set, symbol, function, custom,
84
+ * undefined, void, NaN, and the literal-only forms `z.literal(undefined)`
85
+ * ("undefined-literal") and `z.literal(<bigint>)` ("bigint-literal") →
86
+ * zod-type-unrepresentable.
87
+ * - The catch-all "Non-representable type encountered: <type>" fallback Zod
88
+ * emits for any new schema kind without a registered processor →
89
+ * zod-type-unrepresentable with zodType set to the offending def.type.
90
+ * - Cycle detected (`cycles: "throw"`) → zod-cycle-detected.
91
+ * - Duplicate schema id → zod-duplicate-id.
92
+ * - "Unprocessed schema. This is a bug in Zod." → zod-conversion-bug.
93
+ * - "Error converting schema to JSON." → zod-conversion-failed (explicit
94
+ * classification rather than the generic fallback so the contract test
95
+ * protects the prefix from drift).
96
+ * - Anything else → zod-conversion-failed.
97
+ *
98
+ * The original error is preserved on each classified error via the `cause`
99
+ * field so consumers can still inspect the Zod stack trace.
100
+ */
101
+ /**
102
+ * Direction of the Zod transform / pipe / codec that
103
+ * {@link normaliseSchema} should surface to the renderer.
104
+ *
105
+ * - `"output"` (default) — the server-facing side of every transform,
106
+ * matching `z.toJSONSchema`'s default and the historic adapter
107
+ * behaviour.
108
+ * - `"input"` — the client-facing side; flips a `z.codec(...)` chain
109
+ * so consumers can render its input shape.
110
+ *
111
+ * @group Adapter
112
+ */
113
+ type SchemaIoSide = "input" | "output";
114
+ /**
115
+ * True when `value` is a Zod schema implemented as a codec
116
+ * (`z.codec(...)`). Detection looks for the `$ZodCodec` marker on the
117
+ * schema's `_zod.traits` Set — the same structural check used by Zod
118
+ * itself in `to-json-schema.ts`'s `isTransforming` helper.
119
+ *
120
+ * Promoted from a duplicated local helper in `react/SchemaComponent.tsx`
121
+ * so the validation boundary inside `runValidation` can branch on
122
+ * codec-vs-not-codec without re-implementing the trait check. The
123
+ * shared helper anchors a single source of truth for codec detection:
124
+ * any future change to Zod's trait naming flows through here, not
125
+ * through two parallel copies.
126
+ *
127
+ * Returns `false` for non-objects, plain JSON Schema inputs, OpenAPI
128
+ * documents, or Zod schemas of any other kind. This is structural
129
+ * rather than nominal — a Zod 4 codec produced by any path that ends
130
+ * up tagging `_zod.traits` with `$ZodCodec` is recognised, including
131
+ * schemas wrapped by user-defined helpers.
132
+ */
133
+ declare function isCodecSchema(value: unknown): boolean;
134
+ /**
135
+ * Exposed for unit testing — lets the contract test enumerate every rule's
136
+ * `prefix` value and assert mutual non-prefixing.
137
+ */
138
+ declare const __CLASSIFIER_RULES_FOR_TEST: readonly {
139
+ readonly prefix: string;
140
+ }[];
141
+ /**
142
+ * Result of {@link normaliseSchema}. Carries the canonical Draft 2020-12
143
+ * JSON Schema the walker consumes, the optional original Zod schema
144
+ * (used for validation), and the resolved root document so cross-document
145
+ * `$ref`s can be dereferenced downstream.
146
+ *
147
+ * @group Adapter
148
+ */
149
+ interface NormalisedSchema {
150
+ /** JSON Schema object — the authoritative schema for rendering. */
151
+ jsonSchema: JsonObject;
152
+ /** Original Zod schema, if input was Zod. Used for validation. */
153
+ zodSchema?: unknown;
154
+ /** Root-level metadata. */
155
+ rootMeta: SchemaMeta | undefined;
156
+ /** The root document for $ref resolution. */
157
+ rootDocument: JsonObject;
158
+ }
159
+ /**
160
+ * Options accepted by {@link normaliseSchema}.
161
+ *
162
+ * @group Adapter
163
+ */
164
+ interface NormaliseOptions {
165
+ /** Diagnostics channel for surfacing silent fallbacks. */
166
+ diagnostics?: DiagnosticsOptions;
167
+ /**
168
+ * Side of every transform / pipe / codec to render. Defaults to
169
+ * `"output"`, matching `z.toJSONSchema`'s default and the
170
+ * historic behaviour of the adapter. Passing `"input"` flips the
171
+ * conversion so consumers rendering the input shape of a
172
+ * `z.codec(...)` chain receive that side instead of the output
173
+ * side. Only the Zod 4 branch consults this option — JSON Schema
174
+ * and OpenAPI inputs are already a single canonical shape.
175
+ */
176
+ io?: SchemaIoSide;
177
+ }
178
+ /**
179
+ * Normalise any supported schema input — Zod 4 schema, plain JSON
180
+ * Schema (any draft), Swagger 2.0, OpenAPI 3.0 or 3.1 document — into
181
+ * a canonical Draft 2020-12 {@link NormalisedSchema} the walker can
182
+ * consume.
183
+ *
184
+ * Dispatches on {@link detectSchemaKind}, applies the appropriate
185
+ * version normaliser, and returns the JSON Schema alongside the
186
+ * original Zod schema (for validation) and the resolved root document
187
+ * (for cross-document `$ref` resolution). Throws
188
+ * `SchemaNormalisationError` for unsupported inputs (Zod 3, valibot,
189
+ * arktype, codec or other unrepresentable Zod types).
190
+ *
191
+ * @group Adapter
192
+ */
193
+ declare function normaliseSchema(input: unknown, ref?: string, options?: NormaliseOptions): NormalisedSchema;
194
+ /**
195
+ * Surface root-level metadata from the JSON Schema into the `rootMeta`
196
+ * shape consumed by the walker. Pulls `readOnly`, `writeOnly`,
197
+ * `description`, `title`, `deprecated`, `examples`, and `default`
198
+ * directly from the schema root.
199
+ *
200
+ * `examples` is forwarded only when present as an array (per JSON Schema
201
+ * Draft 2020-12 — Draft 04's `example` singular is normalised upstream).
202
+ * `default` is forwarded for any value the schema declares (any JSON
203
+ * value, including `null` and `false`); the presence check uses `in`
204
+ * so a literal `false` or `null` default is preserved.
205
+ *
206
+ * `examples` and `default` ride on the `[key: string]: unknown` index
207
+ * signature of {@link SchemaMeta}. They are not declared as named fields
208
+ * on `SchemaMeta` because that type lives in `types.ts` and is shared
209
+ * with the walker; the index signature is the agreed extension point.
210
+ */
211
+ declare function extractRootMetaFromJson(jsonSchema: JsonObject): SchemaMeta | undefined;
212
+ //#endregion
213
+ export { __CLASSIFIER_RULES_FOR_TEST as a, isCodecSchema as c, SchemaKind as i, normaliseSchema as l, NormalisedSchema as n, detectSchemaKind as o, SchemaIoSide as r, extractRootMetaFromJson as s, NormaliseOptions as t };
@@ -0,0 +1,30 @@
1
+ //#region src/lit/constructorTypes.d.ts
2
+ /**
3
+ * Tiny structural-type helpers for the Lit adapter.
4
+ *
5
+ * Lives alongside `lit/registry.ts` rather than under `core/` because
6
+ * the Custom-Element constructor signature is only needed by the Lit
7
+ * surface — other adapter directories model their renderers as plain
8
+ * functions and have no use for it.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ /**
13
+ * Generic newable constructor type compatible with the DOM's
14
+ * `CustomElementConstructor`. Used by {@link BUILT_IN_ELEMENTS} (the
15
+ * canonical-tag → element-constructor map) so the map's value type
16
+ * carries enough structure for `customElements.define` to accept it
17
+ * without an `as` cast.
18
+ *
19
+ * Matches the DOM type-library signature
20
+ * `interface CustomElementConstructor { new (...params: any[]): HTMLElement; }`
21
+ * but parameterised over a `T extends HTMLElement` so it can also be
22
+ * used in narrower contexts.
23
+ *
24
+ * `unknown[]` is used in the parameter list — the DOM lib uses
25
+ * `any[]`, but `unknown[]` is the strict-mode equivalent that
26
+ * accepts any positional argument shape without using `any`.
27
+ */
28
+ type Constructor<T extends HTMLElement> = new (...params: unknown[]) => T;
29
+ //#endregion
30
+ export { Constructor as t };
@@ -1,213 +1,3 @@
1
- import { m as JsonObject, w as SchemaMeta } from "../types-BrYbjC7_.mjs";
2
- import { i as DiagnosticsOptions } from "../diagnostics-BTrm3O6J.mjs";
3
-
4
- //#region src/core/adapter.d.ts
5
- /**
6
- * Classification produced by {@link detectSchemaKind} when inspecting a
7
- * runtime schema input.
8
- *
9
- * @group Adapter
10
- */
11
- type SchemaKind = "zod4" | "zod3" | "jsonSchema" | "openapi" | "unsupported-schema-lib";
12
- /**
13
- * Classify a runtime schema input by structural markers — Zod 4, Zod 3,
14
- * OpenAPI document, plain JSON Schema, or an unsupported third-party
15
- * schema library.
16
- *
17
- * - `zod4` — has a `_zod` marker (further validation that `_zod.def` is a
18
- * non-null object happens inside `normaliseZod4`).
19
- * - `zod3` — has `_def` and no `_zod`. The `typeName` field is no longer
20
- * required: any `_def` without `_zod` is treated as a probable Zod 3
21
- * schema. Third-party libraries that expose `_def` without `_zod` are
22
- * nearly always Zod 3 forks; surfacing the migration message is the
23
- * correct response.
24
- * - `openapi` — has `openapi` or `swagger` at the root.
25
- * - `unsupported-schema-lib` — has `parse` and `safeParse` callables but
26
- * no `_zod` and no `_def` marker. This catches Standard Schema
27
- * implementations (valibot, arktype, etc.) that would otherwise flow
28
- * through as "malformed JSON Schema".
29
- * - `jsonSchema` — fallback for anything that does not match the above.
30
- *
31
- * @group Adapter
32
- */
33
- declare function detectSchemaKind(input: unknown): SchemaKind;
34
- /**
35
- * Wraps z.toJSONSchema() for a runtime-validated Zod schema.
36
- *
37
- * The _zod guard in normaliseZod4 has confirmed this is a valid Zod schema,
38
- * but TypeScript cannot represent "has _zod.def" as the $ZodType parameter
39
- * that z.toJSONSchema expects. This is the library boundary equivalent of
40
- * `object → Record<string, unknown>` — the type mismatch is genuinely unavoidable.
41
- *
42
- * # Options
43
- *
44
- * `z.toJSONSchema` is invoked with an explicit options object rather than
45
- * Zod's defaults so the conversion contract is pinned and stable:
46
- *
47
- * - `target: "draft-2020-12"` — matches the walker's draft target.
48
- * - `unrepresentable: "throw"` — keeps the unrepresentable-type rules in
49
- * the classifier table firing instead of silently emitting `{}`.
50
- * - `cycles: "ref"` — converts cyclic graphs into $ref pairs rather than
51
- * throwing. Cycles in user schemas surface through the walker's $ref
52
- * resolution rather than the adapter.
53
- * - `io` — selects which side of every transform / pipe / codec is
54
- * converted. Defaults to `"output"` (the OUTPUT side); pass `"input"`
55
- * to render the INPUT side instead. The input side is invisible to
56
- * the converted schema when `io: "output"` is in force, even though
57
- * `safeParse` on the same Zod schema consumes the input shape. For
58
- * transforms this divergence is fatal and the call throws via
59
- * `Transforms cannot be represented`; for `z.codec(...)` the call
60
- * succeeds but only the selected side is rendered. Consumers receive
61
- * a `zod-codec-output-only` diagnostic in the codec case so the
62
- * asymmetry is visible — see `screenPreConversion`.
63
- *
64
- * # Error classification
65
- *
66
- * Any exception thrown by z.toJSONSchema is classified into a
67
- * SchemaNormalisationError so the caller does not have to re-parse error
68
- * message strings. The classification covers:
69
- *
70
- * - Nested Zod 3 schemas inside a Zod 4 tree → zod3-unsupported.
71
- * Detected structurally (presence of `_def.typeName` markers anywhere
72
- * in the schema tree) so the check works across V8, JavaScriptCore,
73
- * and SpiderMonkey, none of which agree on the wording of
74
- * "Cannot read properties of undefined".
75
- * - Transforms → zod-transform-unsupported. This also catches `z.codec(…)`
76
- * because Zod implements codecs as a pipe + transform internally, so
77
- * they trip the same processor when round-tripping is forced. (Plain
78
- * `z.toJSONSchema(codec)` itself does NOT throw because Zod picks one
79
- * side of the codec; the static rejection in `typeInference.ts` is the
80
- * compile-time guard.)
81
- * - Dynamic catch values whose handler throws → zod-type-unrepresentable
82
- * with zodType "dynamic-catch".
83
- * - Unrepresentable types — bigint, date, map, set, symbol, function, custom,
84
- * undefined, void, NaN, and the literal-only forms `z.literal(undefined)`
85
- * ("undefined-literal") and `z.literal(<bigint>)` ("bigint-literal") →
86
- * zod-type-unrepresentable.
87
- * - The catch-all "Non-representable type encountered: <type>" fallback Zod
88
- * emits for any new schema kind without a registered processor →
89
- * zod-type-unrepresentable with zodType set to the offending def.type.
90
- * - Cycle detected (`cycles: "throw"`) → zod-cycle-detected.
91
- * - Duplicate schema id → zod-duplicate-id.
92
- * - "Unprocessed schema. This is a bug in Zod." → zod-conversion-bug.
93
- * - "Error converting schema to JSON." → zod-conversion-failed (explicit
94
- * classification rather than the generic fallback so the contract test
95
- * protects the prefix from drift).
96
- * - Anything else → zod-conversion-failed.
97
- *
98
- * The original error is preserved on each classified error via the `cause`
99
- * field so consumers can still inspect the Zod stack trace.
100
- */
101
- /**
102
- * Direction of the Zod transform / pipe / codec that
103
- * {@link normaliseSchema} should surface to the renderer.
104
- *
105
- * - `"output"` (default) — the server-facing side of every transform,
106
- * matching `z.toJSONSchema`'s default and the historic adapter
107
- * behaviour.
108
- * - `"input"` — the client-facing side; flips a `z.codec(...)` chain
109
- * so consumers can render its input shape.
110
- *
111
- * @group Adapter
112
- */
113
- type SchemaIoSide = "input" | "output";
114
- /**
115
- * True when `value` is a Zod schema implemented as a codec
116
- * (`z.codec(...)`). Detection looks for the `$ZodCodec` marker on the
117
- * schema's `_zod.traits` Set — the same structural check used by Zod
118
- * itself in `to-json-schema.ts`'s `isTransforming` helper.
119
- *
120
- * Promoted from a duplicated local helper in `react/SchemaComponent.tsx`
121
- * so the validation boundary inside `runValidation` can branch on
122
- * codec-vs-not-codec without re-implementing the trait check. The
123
- * shared helper anchors a single source of truth for codec detection:
124
- * any future change to Zod's trait naming flows through here, not
125
- * through two parallel copies.
126
- *
127
- * Returns `false` for non-objects, plain JSON Schema inputs, OpenAPI
128
- * documents, or Zod schemas of any other kind. This is structural
129
- * rather than nominal — a Zod 4 codec produced by any path that ends
130
- * up tagging `_zod.traits` with `$ZodCodec` is recognised, including
131
- * schemas wrapped by user-defined helpers.
132
- */
133
- declare function isCodecSchema(value: unknown): boolean;
134
- /**
135
- * Exposed for unit testing — lets the contract test enumerate every rule's
136
- * `prefix` value and assert mutual non-prefixing.
137
- */
138
- declare const __CLASSIFIER_RULES_FOR_TEST: readonly {
139
- readonly prefix: string;
140
- }[];
141
- /**
142
- * Result of {@link normaliseSchema}. Carries the canonical Draft 2020-12
143
- * JSON Schema the walker consumes, the optional original Zod schema
144
- * (used for validation), and the resolved root document so cross-document
145
- * `$ref`s can be dereferenced downstream.
146
- *
147
- * @group Adapter
148
- */
149
- interface NormalisedSchema {
150
- /** JSON Schema object — the authoritative schema for rendering. */
151
- jsonSchema: JsonObject;
152
- /** Original Zod schema, if input was Zod. Used for validation. */
153
- zodSchema?: unknown;
154
- /** Root-level metadata. */
155
- rootMeta: SchemaMeta | undefined;
156
- /** The root document for $ref resolution. */
157
- rootDocument: JsonObject;
158
- }
159
- /**
160
- * Options accepted by {@link normaliseSchema}.
161
- *
162
- * @group Adapter
163
- */
164
- interface NormaliseOptions {
165
- /** Diagnostics channel for surfacing silent fallbacks. */
166
- diagnostics?: DiagnosticsOptions;
167
- /**
168
- * Side of every transform / pipe / codec to render. Defaults to
169
- * `"output"`, matching `z.toJSONSchema`'s default and the
170
- * historic behaviour of the adapter. Passing `"input"` flips the
171
- * conversion so consumers rendering the input shape of a
172
- * `z.codec(...)` chain receive that side instead of the output
173
- * side. Only the Zod 4 branch consults this option — JSON Schema
174
- * and OpenAPI inputs are already a single canonical shape.
175
- */
176
- io?: SchemaIoSide;
177
- }
178
- /**
179
- * Normalise any supported schema input — Zod 4 schema, plain JSON
180
- * Schema (any draft), Swagger 2.0, OpenAPI 3.0 or 3.1 document — into
181
- * a canonical Draft 2020-12 {@link NormalisedSchema} the walker can
182
- * consume.
183
- *
184
- * Dispatches on {@link detectSchemaKind}, applies the appropriate
185
- * version normaliser, and returns the JSON Schema alongside the
186
- * original Zod schema (for validation) and the resolved root document
187
- * (for cross-document `$ref` resolution). Throws
188
- * `SchemaNormalisationError` for unsupported inputs (Zod 3, valibot,
189
- * arktype, codec or other unrepresentable Zod types).
190
- *
191
- * @group Adapter
192
- */
193
- declare function normaliseSchema(input: unknown, ref?: string, options?: NormaliseOptions): NormalisedSchema;
194
- /**
195
- * Surface root-level metadata from the JSON Schema into the `rootMeta`
196
- * shape consumed by the walker. Pulls `readOnly`, `writeOnly`,
197
- * `description`, `title`, `deprecated`, `examples`, and `default`
198
- * directly from the schema root.
199
- *
200
- * `examples` is forwarded only when present as an array (per JSON Schema
201
- * Draft 2020-12 — Draft 04's `example` singular is normalised upstream).
202
- * `default` is forwarded for any value the schema declares (any JSON
203
- * value, including `null` and `false`); the presence check uses `in`
204
- * so a literal `false` or `null` default is preserved.
205
- *
206
- * `examples` and `default` ride on the `[key: string]: unknown` index
207
- * signature of {@link SchemaMeta}. They are not declared as named fields
208
- * on `SchemaMeta` because that type lives in `types.ts` and is shared
209
- * with the walker; the index signature is the agreed extension point.
210
- */
211
- declare function extractRootMetaFromJson(jsonSchema: JsonObject): SchemaMeta | undefined;
212
- //#endregion
213
- export { type JsonObject, NormaliseOptions, NormalisedSchema, SchemaIoSide, SchemaKind, type SchemaMeta, __CLASSIFIER_RULES_FOR_TEST, detectSchemaKind, extractRootMetaFromJson, isCodecSchema, normaliseSchema };
1
+ import { m as JsonObject, w as SchemaMeta } from "../types-BBQaEPfE.mjs";
2
+ import { a as __CLASSIFIER_RULES_FOR_TEST, c as isCodecSchema, i as SchemaKind, l as normaliseSchema, n as NormalisedSchema, o as detectSchemaKind, r as SchemaIoSide, s as extractRootMetaFromJson, t as NormaliseOptions } from "../adapter-ktQaheWB.mjs";
3
+ export { JsonObject, NormaliseOptions, NormalisedSchema, SchemaIoSide, SchemaKind, SchemaMeta, __CLASSIFIER_RULES_FOR_TEST, detectSchemaKind, extractRootMetaFromJson, isCodecSchema, normaliseSchema };
@@ -1,4 +1,4 @@
1
- import { AllConstraints } from "./renderer.mjs";
1
+ import { t as AllConstraints } from "../renderer-ab9E52Bp.mjs";
2
2
 
3
3
  //#region src/core/constraintHint.d.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { E as StringConstraints, f as FileConstraints, t as ArrayConstraints, x as ObjectConstraints, y as NumberConstraints } from "../types-BrYbjC7_.mjs";
2
- import { i as DiagnosticsOptions } from "../diagnostics-BTrm3O6J.mjs";
1
+ import { E as StringConstraints, f as FileConstraints, t as ArrayConstraints, x as ObjectConstraints, y as NumberConstraints } from "../types-BBQaEPfE.mjs";
2
+ import { i as DiagnosticsOptions } from "../diagnostics-mftUZI7c.mjs";
3
3
 
4
4
  //#region src/core/constraints.d.ts
5
5
  /**
@@ -0,0 +1,71 @@
1
+ import { d as WidgetMap, i as ComponentResolver } from "../renderer-ab9E52Bp.mjs";
2
+
3
+ //#region src/core/contexts.d.ts
4
+ /**
5
+ * Abstract provide / consume port that framework adapters implement
6
+ * against their native context primitive. The {@link provide} step
7
+ * wraps its `children` in the framework's provider machinery so any
8
+ * descendant calling {@link consume} receives the supplied value;
9
+ * {@link consume} is called from inside a child renderer to read the
10
+ * current value.
11
+ *
12
+ * The return type of `provide` and the argument type of `consume` are
13
+ * deliberately `unknown` so the port works for both React-style
14
+ * "wrap children in a provider component" implementations and
15
+ * Svelte-style "set on the current component instance" implementations
16
+ * without forcing one shape on the other.
17
+ *
18
+ * @typeParam T - The value carried by the context.
19
+ */
20
+ interface ContextPort<T> {
21
+ /**
22
+ * Provide `value` to every descendant of `children`. The exact
23
+ * shape of `children` is framework-specific — `ReactNode` for
24
+ * React, the slot's render function for Svelte, the `setup`
25
+ * return value for Vue. The implementation simply makes the
26
+ * supplied value available to subsequent {@link consume} calls
27
+ * within that scope.
28
+ */
29
+ provide(value: T, children: unknown): unknown;
30
+ /**
31
+ * Read the currently provided value. The exact host primitive is
32
+ * framework-specific — `useContext(ctx)` in React, `inject(key)`
33
+ * in Vue, `getContext(key)` in Svelte. When no provider is
34
+ * mounted in scope, adapter implementations may return their
35
+ * canonical "default" value or `undefined` — the choice is
36
+ * adapter-defined.
37
+ */
38
+ consume(): T;
39
+ }
40
+ /**
41
+ * Shape carried by the resolver context. Adapters expose this through
42
+ * a `ContextPort<ResolverContextShape>` so the dispatcher can read
43
+ * the active theme adapter without taking a direct dependency on the
44
+ * host framework's context system.
45
+ *
46
+ * Mirrors the value carried by the React adapter's
47
+ * `UserResolverContext` (defined in `react/SchemaComponent.tsx`) —
48
+ * an optional {@link ComponentResolver}. The `undefined` branch
49
+ * signals "no theme provider mounted; fall through to the headless
50
+ * resolver".
51
+ *
52
+ * @group Framework Adapters
53
+ */
54
+ type ResolverContextShape = ComponentResolver | undefined;
55
+ /**
56
+ * Shape carried by the widgets context. Adapters expose this through
57
+ * a `ContextPort<WidgetsContextShape>` so the dispatcher can read
58
+ * the active widget map without binding to the host framework's
59
+ * context system.
60
+ *
61
+ * Mirrors the value carried by the React adapter's `WidgetsContext`
62
+ * (defined in `react/SchemaComponent.tsx`) — an optional
63
+ * {@link WidgetMap}. The `undefined` branch signals "no scoped widgets
64
+ * for this subtree; fall through to per-instance widgets, then the
65
+ * global registry, then the resolver".
66
+ *
67
+ * @group Framework Adapters
68
+ */
69
+ type WidgetsContextShape = WidgetMap | undefined;
70
+ //#endregion
71
+ export { ContextPort, ResolverContextShape, WidgetsContextShape };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,2 @@
1
- import { a as appendPointer, i as DiagnosticsOptions, n as DiagnosticCode, o as emitDiagnostic, r as DiagnosticSink, t as Diagnostic } from "../diagnostics-BTrm3O6J.mjs";
1
+ import { a as appendPointer, i as DiagnosticsOptions, n as DiagnosticCode, o as emitDiagnostic, r as DiagnosticSink, t as Diagnostic } from "../diagnostics-mftUZI7c.mjs";
2
2
  export { Diagnostic, DiagnosticCode, DiagnosticSink, DiagnosticsOptions, appendPointer, emitDiagnostic };
@@ -1,2 +1,2 @@
1
- import { i as SchemaRenderError, n as SchemaFieldError, r as SchemaNormalisationError, t as SchemaError } from "../errors-Dki7tji4.mjs";
1
+ import { i as SchemaRenderError, n as SchemaFieldError, r as SchemaNormalisationError, t as SchemaError } from "../errors-DbaI04x2.mjs";
2
2
  export { SchemaError, SchemaFieldError, SchemaNormalisationError, SchemaRenderError };
@@ -1,4 +1,4 @@
1
- import { j as WalkedField } from "../types-BrYbjC7_.mjs";
1
+ import { j as WalkedField } from "../types-BBQaEPfE.mjs";
2
2
 
3
3
  //#region src/core/fieldOrder.d.ts
4
4
  /**
@@ -1,6 +1,6 @@
1
- import { j as WalkedField } from "../types-BrYbjC7_.mjs";
1
+ import { j as WalkedField } from "../types-BBQaEPfE.mjs";
2
2
 
3
- //#region src/react/fieldPath.d.ts
3
+ //#region src/core/fieldPath.d.ts
4
4
  /**
5
5
  * Resolve a dot-separated path through a WalkedField tree.
6
6
  * Supports array index notation: `field[0]`.
@@ -1,6 +1,6 @@
1
- import { isObject } from "../core/guards.mjs";
2
- import { isPrototypePollutingKey } from "../core/uri.mjs";
3
- //#region src/react/fieldPath.ts
1
+ import { isObject } from "./guards.mjs";
2
+ import { isPrototypePollutingKey } from "./uri.mjs";
3
+ //#region src/core/fieldPath.ts
4
4
  /**
5
5
  * Resolve a dot-separated path through a WalkedField tree.
6
6
  * Supports array index notation: `field[0]`.
@@ -1,4 +1,4 @@
1
- import { i as DiagnosticsOptions } from "../diagnostics-BTrm3O6J.mjs";
1
+ import { i as DiagnosticsOptions } from "../diagnostics-mftUZI7c.mjs";
2
2
 
3
3
  //#region src/core/formats.d.ts
4
4
  /**
@@ -1,2 +1,2 @@
1
- import { a as InferredValue, i as InferredOutputValue, n as InferSchemaValue, r as InferredInputValue, t as InferFields } from "../inferValue-Ce-PviSD.mjs";
1
+ import { a as InferredValue, i as InferredOutputValue, n as InferSchemaValue, r as InferredInputValue, t as InferFields } from "../inferValue-eAnh50EM.mjs";
2
2
  export { InferFields, InferSchemaValue, InferredInputValue, InferredOutputValue, InferredValue };
@@ -1,2 +1,2 @@
1
- import { i as MaxRefDepth, n as MAX_REF_DEPTH, r as MAX_RENDER_DEPTH, t as MAX_PATH_ITEM_REF_HOPS } from "../limits-x4OiyJxh.mjs";
1
+ import { i as MaxRefDepth, n as MAX_REF_DEPTH, r as MAX_RENDER_DEPTH, t as MAX_PATH_ITEM_REF_HOPS } from "../limits-Vv9hUbI_.mjs";
2
2
  export { MAX_PATH_ITEM_REF_HOPS, MAX_REF_DEPTH, MAX_RENDER_DEPTH, MaxRefDepth };
@@ -1,4 +1,4 @@
1
- import { i as DiagnosticsOptions } from "../diagnostics-BTrm3O6J.mjs";
1
+ import { i as DiagnosticsOptions } from "../diagnostics-mftUZI7c.mjs";
2
2
 
3
3
  //#region src/core/merge.d.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { i as DiagnosticsOptions } from "../diagnostics-BTrm3O6J.mjs";
2
- import { i as OpenApiVersionInfo, r as JsonSchemaDraft } from "../version-DL8U5RuA.mjs";
1
+ import { i as DiagnosticsOptions } from "../diagnostics-mftUZI7c.mjs";
2
+ import { i as OpenApiVersionInfo, r as JsonSchemaDraft } from "../version-BEBx10ND.mjs";
3
3
 
4
4
  //#region src/core/normalise.d.ts
5
5
  /**
@@ -1,2 +1,2 @@
1
- import { a as dereference, i as countDistinctRefs, n as RECURSIVE_ANCHOR_SENTINEL, o as findAnchor, r as RefOptions, s as resolveRef, t as ExternalResolver } from "../ref-DdsbekXX.mjs";
1
+ import { a as dereference, i as countDistinctRefs, n as RECURSIVE_ANCHOR_SENTINEL, o as findAnchor, r as RefOptions, s as resolveRef, t as ExternalResolver } from "../ref-DWrQG1Er.mjs";
2
2
  export { ExternalResolver, RECURSIVE_ANCHOR_SENTINEL, RefOptions, countDistinctRefs, dereference, findAnchor, resolveRef };