arktype 3.0.0-beta.1 → 3.0.0-rc.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/README.md +48 -144
- package/out/_internal/regex/charset.d.ts +24 -0
- package/out/_internal/regex/escape.d.ts +29 -0
- package/out/_internal/regex/execArray.d.ts +24 -0
- package/out/_internal/regex/group.d.ts +34 -0
- package/out/_internal/regex/index.d.ts +2 -0
- package/out/_internal/regex/internal.d.ts +9 -0
- package/out/_internal/regex/parse.d.ts +10 -0
- package/out/_internal/regex/quantify.d.ts +59 -0
- package/out/_internal/regex/regex.d.ts +38 -0
- package/out/_internal/regex/state.d.ts +383 -0
- package/out/_internal/schema/codecs.d.ts +2 -0
- package/out/_internal/schema/config.d.ts +103 -0
- package/out/_internal/schema/constraint.d.ts +78 -0
- package/out/_internal/schema/errors.d.ts +1 -0
- package/out/_internal/schema/generic.d.ts +85 -0
- package/out/_internal/schema/i18n.d.ts +3 -0
- package/out/_internal/schema/index.d.ts +54 -0
- package/out/_internal/schema/internal.d.ts +15 -0
- package/out/_internal/schema/intrinsic.d.ts +28 -0
- package/out/_internal/schema/kinds.d.ts +76 -0
- package/out/_internal/schema/module.d.ts +23 -0
- package/out/_internal/schema/mutatesInput.d.ts +2 -0
- package/out/_internal/schema/node.d.ts +349 -0
- package/out/_internal/schema/parse.d.ts +77 -0
- package/out/_internal/schema/parseSchema.d.ts +116 -0
- package/out/_internal/schema/predicate.d.ts +46 -0
- package/out/_internal/schema/refinements/after.d.ts +32 -0
- package/out/_internal/schema/refinements/before.d.ts +32 -0
- package/out/_internal/schema/refinements/divisor.d.ts +41 -0
- package/out/_internal/schema/refinements/exactLength.d.ts +43 -0
- package/out/_internal/schema/refinements/kinds.d.ts +40 -0
- package/out/_internal/schema/refinements/max.d.ts +33 -0
- package/out/_internal/schema/refinements/maxLength.d.ts +32 -0
- package/out/_internal/schema/refinements/min.d.ts +33 -0
- package/out/_internal/schema/refinements/minLength.d.ts +32 -0
- package/out/_internal/schema/refinements/notEqual.d.ts +38 -0
- package/out/_internal/schema/refinements/notEqualLength.d.ts +38 -0
- package/out/_internal/schema/refinements/pattern.d.ts +43 -0
- package/out/_internal/schema/refinements/range.d.ts +101 -0
- package/out/_internal/schema/roots/alias.d.ts +49 -0
- package/out/_internal/schema/roots/basis.d.ts +12 -0
- package/out/_internal/schema/roots/domain.d.ts +45 -0
- package/out/_internal/schema/roots/intersection.d.ts +72 -0
- package/out/_internal/schema/roots/morph.d.ts +59 -0
- package/out/_internal/schema/roots/proto.d.ts +42 -0
- package/out/_internal/schema/roots/root.d.ts +163 -0
- package/out/_internal/schema/roots/union.d.ts +146 -0
- package/out/_internal/schema/roots/unit.d.ts +36 -0
- package/out/_internal/schema/runtime.d.ts +29 -0
- package/out/_internal/schema/runtimeLean.d.ts +2 -0
- package/out/_internal/schema/runtimeNone.d.ts +2 -0
- package/out/_internal/schema/runtimeNoneLean.d.ts +2 -0
- package/out/_internal/schema/scope.d.ts +203 -0
- package/out/_internal/schema/shared/codecs.d.ts +5 -0
- package/out/_internal/schema/shared/compile.d.ts +144 -0
- package/out/_internal/schema/shared/configured.d.ts +14 -0
- package/out/_internal/schema/shared/declare.d.ts +100 -0
- package/out/_internal/schema/shared/disjoint.d.ts +45 -0
- package/out/_internal/schema/shared/enWriters.d.ts +30 -0
- package/out/_internal/schema/shared/errorModes.d.ts +25 -0
- package/out/_internal/schema/shared/errorWriters.d.ts +34 -0
- package/out/_internal/schema/shared/errors.d.ts +264 -0
- package/out/_internal/schema/shared/implement.d.ts +154 -0
- package/out/_internal/schema/shared/inPlace.d.ts +8 -0
- package/out/_internal/schema/shared/issueFeatures.d.ts +38 -0
- package/out/_internal/schema/shared/issues.d.ts +261 -0
- package/out/_internal/schema/shared/issuesLean.d.ts +80 -0
- package/out/_internal/schema/shared/issuesNone.d.ts +22 -0
- package/out/_internal/schema/shared/issuesNoneLean.d.ts +20 -0
- package/out/_internal/schema/shared/issuesUndetailed.d.ts +25 -0
- package/out/_internal/schema/shared/jsonSchema.d.ts +153 -0
- package/out/_internal/schema/shared/listed.d.ts +15 -0
- package/out/_internal/schema/shared/locale.d.ts +149 -0
- package/out/_internal/schema/shared/registry.d.ts +16 -0
- package/out/_internal/schema/shared/render.d.ts +3 -0
- package/out/_internal/schema/shared/rootApply.d.ts +19 -0
- package/out/_internal/schema/shared/sets.d.ts +26 -0
- package/out/_internal/schema/shared/standardFailure.d.ts +22 -0
- package/out/_internal/schema/shared/standardSchema.d.ts +124 -0
- package/out/_internal/schema/shared/toJsonSchema.d.ts +229 -0
- package/out/_internal/schema/shared/transform.d.ts +35 -0
- package/out/_internal/schema/shared/traversal.d.ts +288 -0
- package/out/_internal/schema/shared/utils.d.ts +59 -0
- package/out/_internal/schema/structure/index.d.ts +43 -0
- package/out/_internal/schema/structure/optional.d.ts +61 -0
- package/out/_internal/schema/structure/prop.d.ts +45 -0
- package/out/_internal/schema/structure/required.d.ts +49 -0
- package/out/_internal/schema/structure/sequence.d.ts +127 -0
- package/out/_internal/schema/structure/shared.d.ts +3 -0
- package/out/_internal/schema/structure/structure.d.ts +178 -0
- package/out/_internal/schema/units.d.ts +123 -0
- package/out/_internal/sets/algebra.d.ts +26 -0
- package/out/_internal/sets/constraint.d.ts +19 -0
- package/out/_internal/sets/engine.d.ts +2 -0
- package/out/_internal/sets/formats.d.ts +23 -0
- package/out/_internal/sets/fromJsonSchema.d.ts +15 -0
- package/out/_internal/sets/implement.d.ts +16 -0
- package/out/_internal/sets/index.d.ts +2 -0
- package/out/_internal/sets/internal.d.ts +20 -0
- package/out/_internal/sets/intersections.d.ts +5 -0
- package/out/_internal/sets/kinds.d.ts +3 -0
- package/out/_internal/sets/refinements.d.ts +14 -0
- package/out/_internal/sets/roots/alias.d.ts +3 -0
- package/out/_internal/sets/roots/domain.d.ts +3 -0
- package/out/_internal/sets/roots/intersection.d.ts +4 -0
- package/out/_internal/sets/roots/morph.d.ts +4 -0
- package/out/_internal/sets/roots/proto.d.ts +3 -0
- package/out/_internal/sets/roots/union.d.ts +16 -0
- package/out/_internal/sets/roots/unit.d.ts +3 -0
- package/out/_internal/sets/structure/index.d.ts +3 -0
- package/out/_internal/sets/structure/prop.d.ts +8 -0
- package/out/_internal/sets/structure/sequence.d.ts +3 -0
- package/out/_internal/sets/structure/structure.d.ts +3 -0
- package/out/_internal/sets/toJsonSchema.d.ts +25 -0
- package/out/_internal/util/arrays.d.ts +130 -0
- package/out/_internal/util/clone.d.ts +4 -0
- package/out/_internal/util/describe.d.ts +25 -0
- package/out/_internal/util/domain.d.ts +49 -0
- package/out/_internal/util/errors.d.ts +29 -0
- package/out/_internal/util/facts.d.ts +22 -0
- package/out/_internal/util/flatMorph.d.ts +41 -0
- package/out/_internal/util/formats.d.ts +8 -0
- package/out/_internal/util/functions.d.ts +33 -0
- package/out/_internal/util/generics.d.ts +65 -0
- package/out/_internal/util/get.d.ts +9 -0
- package/out/_internal/util/hkt.d.ts +27 -0
- package/out/_internal/util/i18n.d.ts +12 -0
- package/out/_internal/util/index.d.ts +28 -0
- package/out/_internal/util/internal.d.ts +2 -0
- package/out/_internal/util/intersections.d.ts +50 -0
- package/out/_internal/util/isomorphic.d.ts +8 -0
- package/out/_internal/util/keys.d.ts +18 -0
- package/out/_internal/util/lazily.d.ts +7 -0
- package/out/_internal/util/numbers.d.ts +82 -0
- package/out/_internal/util/objectKinds.d.ts +157 -0
- package/out/_internal/util/path.d.ts +16 -0
- package/out/_internal/util/primitive.d.ts +16 -0
- package/out/_internal/util/records.d.ts +173 -0
- package/out/_internal/util/registry.d.ts +13 -0
- package/out/_internal/util/scanner.d.ts +110 -0
- package/out/_internal/util/serialize.d.ts +40 -0
- package/out/_internal/util/strings.d.ts +35 -0
- package/out/_internal/util/traits.d.ts +89 -0
- package/out/_internal/util/unionToTuple.d.ts +14 -0
- package/out/_internal/util/weak.d.ts +8 -0
- package/out/attributes.d.ts +15 -11
- package/out/checkers.d.ts +1 -1
- package/out/chunk-22RQSVV3.js +0 -0
- package/out/chunk-3HZC67MT.js +965 -0
- package/out/chunk-3KBOPH3J.js +1564 -0
- package/out/chunk-3SH2BQ4T.js +15 -0
- package/out/chunk-46PLKNON.js +126 -0
- package/out/{chunk-G45P2CLE.js → chunk-4FTHWK63.js} +6 -1
- package/out/{chunk-UK5UGFOX.js → chunk-4HREHNIV.js} +23 -11
- package/out/chunk-4NZCLVBD.js +14 -0
- package/out/chunk-6FMBO47M.js +7 -0
- package/out/chunk-7TALAWYX.js +10 -0
- package/out/{chunk-DLWCO4RV.js → chunk-BCYKO54Z.js} +11 -2
- package/out/chunk-BDJVONP7.js +168 -0
- package/out/{chunk-E3DZXEZK.js → chunk-C2JOL5M2.js} +4 -2
- package/out/{chunk-2U2AWCI3.js → chunk-C2V6QPE3.js} +126 -97
- package/out/chunk-C3B4IFQL.js +6408 -0
- package/out/chunk-CWSF57VM.js +10 -0
- package/out/chunk-F5BACUJS.js +7 -0
- package/out/{chunk-EVCML554.js → chunk-FWRSDUJ2.js} +14 -5
- package/out/chunk-GID3FSQA.js +161 -0
- package/out/chunk-I2KLQ2HA.js +22 -0
- package/out/chunk-K7SLP5D2.js +84 -0
- package/out/chunk-KQPSKGUI.js +9 -0
- package/out/chunk-KXOC3JEX.js +8234 -0
- package/out/chunk-KXOSUYRA.js +405 -0
- package/out/chunk-LHNEY6QW.js +0 -0
- package/out/chunk-MTWKGAGO.js +323 -0
- package/out/chunk-NU73GNCX.js +170 -0
- package/out/{chunk-RAZ3TXOE.js → chunk-P5W67FQH.js} +34 -19
- package/out/chunk-PDLTEX6Z.js +1118 -0
- package/out/{chunk-VV6YDN2D.js → chunk-QUS4IAXJ.js} +304 -263
- package/out/chunk-R7WXIH5P.js +94 -0
- package/out/chunk-TACLEIDM.js +95 -0
- package/out/chunk-UJJGG4VQ.js +71 -0
- package/out/chunk-US6BWOGJ.js +109 -0
- package/out/chunk-VMMMOO4R.js +945 -0
- package/out/chunk-VYMXHSFR.js +439 -0
- package/out/chunk-W2XOI5DY.js +141 -0
- package/out/chunk-WC5L5YRP.js +25 -0
- package/out/{chunk-NRIGTMPM.js → chunk-WKOSL2G6.js} +4 -1
- package/out/chunk-XLG66ZDF.js +0 -0
- package/out/{chunk-5U2ZMDNI.js → chunk-XNUAQSJ4.js} +52 -30
- package/out/chunk-ZRYEHGSG.js +79 -0
- package/out/cli.d.ts +28 -0
- package/out/cli.js +636 -0
- package/out/codecs.d.ts +6 -5
- package/out/codecs.js +23 -7
- package/out/config.d.ts +5 -17
- package/out/config.js +11 -2
- package/out/declare.d.ts +40 -12
- package/out/deferred.d.ts +2 -2
- package/out/errors.d.ts +1 -1
- package/out/errors.js +10 -2
- package/out/fn.d.ts +20 -13
- package/out/fromJsonSchema.d.ts +18 -0
- package/out/generic.d.ts +9 -6
- package/out/i18n.d.ts +2 -2
- package/out/i18n.js +9 -2
- package/out/index.d.ts +16 -7
- package/out/index.js +25 -8
- package/out/internal.d.ts +4 -0
- package/out/internal.js +41 -17
- package/out/island.js +22 -6
- package/out/islandDependency.js +42 -18
- package/out/jsonSchema/infer.d.ts +805 -0
- package/out/jsonSchema/validate.d.ts +416 -0
- package/out/keywords/Array.d.ts +2 -2
- package/out/keywords/builtins.d.ts +3 -3
- package/out/keywords/constructors.d.ts +1 -1
- package/out/keywords/functions.d.ts +5 -192
- package/out/keywords/keywords.d.ts +3 -3
- package/out/keywords/number.d.ts +2 -2
- package/out/keywords/phrases.d.ts +4 -191
- package/out/keywords/string.d.ts +3 -3
- package/out/keywords/ts.d.ts +18 -18
- package/out/keywords/ts.js +19 -4
- package/out/locale.d.ts +6 -2
- package/out/locales/de.js +9 -2
- package/out/locales/en.js +21 -5
- package/out/match.d.ts +13 -10
- package/out/module.d.ts +2 -2
- package/out/mutatesInput.js +18 -3
- package/out/nary.d.ts +220 -194
- package/out/parser/ast/bounds.d.ts +2 -2
- package/out/parser/ast/default.d.ts +2 -2
- package/out/parser/ast/divisor.d.ts +2 -2
- package/out/parser/ast/generic.d.ts +2 -2
- package/out/parser/ast/infer.d.ts +1 -1
- package/out/parser/ast/keyof.d.ts +2 -2
- package/out/parser/ast/utils.d.ts +1 -1
- package/out/parser/ast/validate.d.ts +2 -2
- package/out/parser/definition.d.ts +4 -4
- package/out/parser/objectLiteral.d.ts +2 -2
- package/out/parser/property.d.ts +2 -2
- package/out/parser/reduce/dynamic.d.ts +2 -2
- package/out/parser/reduce/shared.d.ts +1 -1
- package/out/parser/reduce/static.d.ts +1 -1
- package/out/parser/shift/operand/enclosed.d.ts +2 -2
- package/out/parser/shift/operand/genericArgs.d.ts +2 -2
- package/out/parser/shift/operand/operand.d.ts +1 -1
- package/out/parser/shift/operand/unenclosed.d.ts +2 -2
- package/out/parser/shift/operand/unresolvable.d.ts +2 -2
- package/out/parser/shift/operator/bounds.d.ts +2 -2
- package/out/parser/shift/operator/brand.d.ts +2 -2
- package/out/parser/shift/operator/default.d.ts +4 -4
- package/out/parser/shift/operator/divisor.d.ts +1 -1
- package/out/parser/shift/operator/operator.d.ts +1 -1
- package/out/parser/shift/tokens.d.ts +1 -1
- package/out/parser/string.d.ts +2 -2
- package/out/parser/tupleExpressions.d.ts +6 -8
- package/out/parser/tupleLiteral.d.ts +2 -2
- package/out/precompiled.d.ts +1 -1
- package/out/precompiled.js +16 -2
- package/out/regex.d.ts +1 -0
- package/out/regex.js +2 -0
- package/out/runtime.d.ts +10 -8
- package/out/runtime.js +6 -4
- package/out/runtimeDevelopment.js +70 -52
- package/out/schema.d.ts +1 -0
- package/out/schema.js +15 -0
- package/out/schemaInternal.d.ts +1 -0
- package/out/schemaInternal.js +1401 -0
- package/out/schemaIssueFeatures.d.ts +1 -0
- package/out/schemaRuntime.d.ts +1 -0
- package/out/schemaRuntime.js +7 -0
- package/out/schemaRuntimeLean.d.ts +1 -0
- package/out/schemaRuntimeLean.js +1870 -0
- package/out/schemaRuntimeNone.d.ts +1 -0
- package/out/schemaRuntimeNone.js +1774 -0
- package/out/schemaRuntimeNoneLean.d.ts +1 -0
- package/out/schemaRuntimeNoneLean.js +1767 -0
- package/out/scope.d.ts +3 -4
- package/out/shared/issueFeatures.d.ts +38 -0
- package/out/shared/issueFeatures.js +40 -0
- package/out/standalone/artifact.d.ts +6 -6
- package/out/standalone/baking.d.ts +2 -2
- package/out/standalone/combinators.d.ts +1 -1
- package/out/standalone/compilers.d.ts +1 -1
- package/out/standalone/fallbacks.d.ts +1 -1
- package/out/standalone/keys.d.ts +1 -1
- package/out/standalone/sites.d.ts +3 -3
- package/out/standalone/units.d.ts +1 -1
- package/out/standalone/values.d.ts +1 -1
- package/out/type.d.ts +6 -6
- package/out/util.d.ts +1 -0
- package/out/util.js +137 -0
- package/out/variants/array.d.ts +6 -6
- package/out/variants/base.d.ts +61 -10
- package/out/variants/date.d.ts +5 -5
- package/out/variants/instantiate.d.ts +1 -1
- package/out/variants/number.d.ts +6 -6
- package/out/variants/object.d.ts +25 -12
- package/out/variants/string.d.ts +8 -8
- package/package.json +183 -8
- package/skills/arktype/SKILL.md +93 -93
- package/skills/arktype/references/migrating.md +144 -158
- package/skills/arktype/references/precompile.md +7 -7
- package/out/chunk-4CUA5XIP.js +0 -7
- package/out/chunk-GPNK5353.js +0 -2529
- package/out/chunk-MLKGABMK.js +0 -9
- package/out/chunk-PRTMQCHS.js +0 -3
- package/out/chunk-R5G57XC7.js +0 -7
- package/out/chunk-SWOOCAHN.js +0 -4
- package/out/chunk-TAHPKDNM.js +0 -3
- package/out/chunk-UETB6YE2.js +0 -14
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
FirstIssues,
|
|
5
5
|
InternalTraversal,
|
|
6
6
|
InvalidErrors,
|
|
7
|
-
ParseError,
|
|
8
7
|
TransformErrors,
|
|
9
8
|
Traversal,
|
|
10
9
|
TraversalError,
|
|
@@ -38,7 +37,6 @@ import {
|
|
|
38
37
|
bakedJsonSchema,
|
|
39
38
|
bakedJsonSchemaOptionsMessage,
|
|
40
39
|
bakedStandardJsonSchema,
|
|
41
|
-
baseNameOf,
|
|
42
40
|
booleanChecker,
|
|
43
41
|
callMorph,
|
|
44
42
|
callingDeferredRootApply,
|
|
@@ -118,7 +116,6 @@ import {
|
|
|
118
116
|
fixConfigured,
|
|
119
117
|
foundErrors,
|
|
120
118
|
freeze,
|
|
121
|
-
functionNameOf,
|
|
122
119
|
holdHoles,
|
|
123
120
|
holdingAlias,
|
|
124
121
|
holdsOnlyIndices,
|
|
@@ -133,19 +130,9 @@ import {
|
|
|
133
130
|
internedTable,
|
|
134
131
|
intersection,
|
|
135
132
|
is,
|
|
136
|
-
isIpv4,
|
|
137
|
-
isIpv6,
|
|
138
|
-
isIso8601,
|
|
139
|
-
isNumericString,
|
|
140
|
-
isPlainObjectOrArray,
|
|
141
|
-
isUuid,
|
|
142
|
-
isValidDate,
|
|
143
|
-
isWellFormedInteger,
|
|
144
|
-
jsTypeOfDescriptions,
|
|
145
133
|
keepOwn,
|
|
146
134
|
keySiteOf,
|
|
147
135
|
lessThan,
|
|
148
|
-
liftArray,
|
|
149
136
|
listedIssue,
|
|
150
137
|
matchesRepeated,
|
|
151
138
|
max,
|
|
@@ -179,9 +166,8 @@ import {
|
|
|
179
166
|
pipeTransformed,
|
|
180
167
|
piped,
|
|
181
168
|
pipedIntoUndetailed,
|
|
182
|
-
|
|
169
|
+
precompiledForArktype_3_0_0_rc_0,
|
|
183
170
|
printKind,
|
|
184
|
-
printable,
|
|
185
171
|
props,
|
|
186
172
|
raisingTraversalOf,
|
|
187
173
|
readingCtx,
|
|
@@ -207,14 +193,13 @@ import {
|
|
|
207
193
|
sited,
|
|
208
194
|
sitedProps,
|
|
209
195
|
standardResultOf,
|
|
196
|
+
standardValidated,
|
|
210
197
|
stringCheck,
|
|
211
198
|
stringRange,
|
|
212
199
|
throwIssues,
|
|
213
200
|
throwJsonSchemaError,
|
|
214
201
|
throwOnDefault,
|
|
215
|
-
throwParseError,
|
|
216
202
|
throwUnbaked,
|
|
217
|
-
timeOf,
|
|
218
203
|
transformIfAllowed,
|
|
219
204
|
transformOf,
|
|
220
205
|
transformResolution,
|
|
@@ -236,6 +221,7 @@ import {
|
|
|
236
221
|
unreadCallErrors,
|
|
237
222
|
unreadElements,
|
|
238
223
|
unreadErrors,
|
|
224
|
+
withContextOf,
|
|
239
225
|
writeCreationMismatchMessage,
|
|
240
226
|
writeDigestMismatchMessage,
|
|
241
227
|
writeDomainActual,
|
|
@@ -243,21 +229,25 @@ import {
|
|
|
243
229
|
writeLengthActual,
|
|
244
230
|
writeMessage,
|
|
245
231
|
writeNotEqualActual,
|
|
246
|
-
writeNullableJsonSchema,
|
|
232
|
+
writeNullableJsonSchema as writeNullableJsonSchema2,
|
|
247
233
|
writeProtoActual,
|
|
248
234
|
writeUnbakedMessage,
|
|
249
|
-
writeUnionJsonSchema,
|
|
235
|
+
writeUnionJsonSchema as writeUnionJsonSchema2,
|
|
250
236
|
writeUnitActual,
|
|
251
237
|
writeUnitMessage,
|
|
252
238
|
writtenBy,
|
|
253
239
|
writtenSiteOf
|
|
254
|
-
} from "./chunk-
|
|
240
|
+
} from "./chunk-XNUAQSJ4.js";
|
|
241
|
+
import "./chunk-VMMMOO4R.js";
|
|
255
242
|
import {
|
|
256
243
|
keywords
|
|
257
|
-
} from "./chunk-
|
|
244
|
+
} from "./chunk-C2V6QPE3.js";
|
|
258
245
|
import {
|
|
259
246
|
InternalTypedFn
|
|
260
|
-
} from "./chunk-
|
|
247
|
+
} from "./chunk-4FTHWK63.js";
|
|
248
|
+
import {
|
|
249
|
+
writesInPlace
|
|
250
|
+
} from "./chunk-MTWKGAGO.js";
|
|
261
251
|
import {
|
|
262
252
|
capitalizeString,
|
|
263
253
|
emptyCollectionDefaults,
|
|
@@ -287,21 +277,98 @@ import {
|
|
|
287
277
|
uppercaseString,
|
|
288
278
|
writeEpoch,
|
|
289
279
|
writeIsoDate,
|
|
290
|
-
writeJsonSyntaxErrorMessage,
|
|
291
280
|
writeUrl
|
|
292
|
-
} from "./chunk-
|
|
281
|
+
} from "./chunk-4HREHNIV.js";
|
|
282
|
+
import {
|
|
283
|
+
LazyGenericRoot,
|
|
284
|
+
TraversalCompiler,
|
|
285
|
+
compileDomainOf,
|
|
286
|
+
hashedPrefixLength,
|
|
287
|
+
madeMorphs,
|
|
288
|
+
precompileRootUnits
|
|
289
|
+
} from "./chunk-KXOC3JEX.js";
|
|
290
|
+
import {
|
|
291
|
+
isIpv4,
|
|
292
|
+
isIpv6,
|
|
293
|
+
isIso8601,
|
|
294
|
+
isUuid
|
|
295
|
+
} from "./chunk-US6BWOGJ.js";
|
|
296
|
+
import {
|
|
297
|
+
ToJsonSchema,
|
|
298
|
+
foreignTypesByMorph,
|
|
299
|
+
unionJsonSchemaWritersKey
|
|
300
|
+
} from "./chunk-KXOSUYRA.js";
|
|
301
|
+
import {
|
|
302
|
+
supportedJsonSchemaTargets,
|
|
303
|
+
writeNullableJsonSchema,
|
|
304
|
+
writeUnionJsonSchema
|
|
305
|
+
} from "./chunk-W2XOI5DY.js";
|
|
306
|
+
import {
|
|
307
|
+
hashOf
|
|
308
|
+
} from "./chunk-TACLEIDM.js";
|
|
309
|
+
import {
|
|
310
|
+
rootApplyParts,
|
|
311
|
+
rootApplyRuntime
|
|
312
|
+
} from "./chunk-K7SLP5D2.js";
|
|
313
|
+
import {
|
|
314
|
+
isDecidedByAllows,
|
|
315
|
+
isRefinedPattern
|
|
316
|
+
} from "./chunk-VYMXHSFR.js";
|
|
317
|
+
import {
|
|
318
|
+
$ark,
|
|
319
|
+
describesData,
|
|
320
|
+
errorWriters,
|
|
321
|
+
errorWritersByCode,
|
|
322
|
+
registryName
|
|
323
|
+
} from "./chunk-PDLTEX6Z.js";
|
|
324
|
+
import {
|
|
325
|
+
describeBranches,
|
|
326
|
+
describeCases,
|
|
327
|
+
hasArkKind,
|
|
328
|
+
holeNameMarker,
|
|
329
|
+
isNode
|
|
330
|
+
} from "./chunk-3KBOPH3J.js";
|
|
331
|
+
import {
|
|
332
|
+
nameOf
|
|
333
|
+
} from "./chunk-ZRYEHGSG.js";
|
|
334
|
+
import {
|
|
335
|
+
ParseError,
|
|
336
|
+
appendStringifiedKey,
|
|
337
|
+
arkKindOf,
|
|
338
|
+
baseNameOf,
|
|
339
|
+
cached,
|
|
340
|
+
constructorNameOf,
|
|
341
|
+
dateGetTime,
|
|
342
|
+
domainOf,
|
|
343
|
+
flatMorph,
|
|
344
|
+
functionNameOf,
|
|
345
|
+
hasDomain,
|
|
346
|
+
isArray,
|
|
347
|
+
isDate,
|
|
348
|
+
isDateObject,
|
|
349
|
+
isDotAccessible,
|
|
350
|
+
isNumericString,
|
|
351
|
+
isPlainObjectOrArray,
|
|
352
|
+
isRegExpObject,
|
|
353
|
+
isStandardSchema,
|
|
354
|
+
isThunk,
|
|
355
|
+
isValidDate,
|
|
356
|
+
isWellFormedInteger,
|
|
357
|
+
jsTypeOfDescriptions,
|
|
358
|
+
liftArray,
|
|
359
|
+
printable,
|
|
360
|
+
prototypeOf,
|
|
361
|
+
readsOnlyData,
|
|
362
|
+
returnsReports,
|
|
363
|
+
testsOrRejects,
|
|
364
|
+
throwInternalError,
|
|
365
|
+
throwParseError,
|
|
366
|
+
timeOf,
|
|
367
|
+
unset
|
|
368
|
+
} from "./chunk-3HZC67MT.js";
|
|
293
369
|
import {
|
|
294
370
|
__export
|
|
295
|
-
} from "./chunk-
|
|
296
|
-
|
|
297
|
-
// out/attributes.js
|
|
298
|
-
import { noSuggest } from "@ark/util";
|
|
299
|
-
var isMorphOutKey = noSuggest("isMorphOut");
|
|
300
|
-
var defaultsToKey = noSuggest("defaultsTo");
|
|
301
|
-
|
|
302
|
-
// out/standalone.js
|
|
303
|
-
import { hasArkKind as hasArkKind6 } from "@ark/schema";
|
|
304
|
-
import { arkKindOf as arkKindOf3, ParseError as ParseError3 } from "@ark/util";
|
|
371
|
+
} from "./chunk-I2KLQ2HA.js";
|
|
305
372
|
|
|
306
373
|
// out/runtimeExports.js
|
|
307
374
|
var runtimeExports_exports = {};
|
|
@@ -508,7 +575,7 @@ __export(runtimeExports_exports, {
|
|
|
508
575
|
pipeTransformed: () => pipeTransformed,
|
|
509
576
|
piped: () => piped,
|
|
510
577
|
pipedIntoUndetailed: () => pipedIntoUndetailed,
|
|
511
|
-
|
|
578
|
+
precompiledForArktype_3_0_0_rc_0: () => precompiledForArktype_3_0_0_rc_0,
|
|
512
579
|
printKind: () => printKind,
|
|
513
580
|
printable: () => printable,
|
|
514
581
|
props: () => props,
|
|
@@ -537,6 +604,7 @@ __export(runtimeExports_exports, {
|
|
|
537
604
|
sited: () => sited,
|
|
538
605
|
sitedProps: () => sitedProps,
|
|
539
606
|
standardResultOf: () => standardResultOf,
|
|
607
|
+
standardValidated: () => standardValidated,
|
|
540
608
|
stringCheck: () => stringCheck,
|
|
541
609
|
stringRange: () => stringRange,
|
|
542
610
|
stringifyJson: () => stringifyJson,
|
|
@@ -569,20 +637,20 @@ __export(runtimeExports_exports, {
|
|
|
569
637
|
unreadElements: () => unreadElements,
|
|
570
638
|
unreadErrors: () => unreadErrors,
|
|
571
639
|
uppercaseString: () => uppercaseString,
|
|
640
|
+
withContextOf: () => withContextOf,
|
|
572
641
|
writeCreationMismatchMessage: () => writeCreationMismatchMessage,
|
|
573
642
|
writeDigestMismatchMessage: () => writeDigestMismatchMessage,
|
|
574
643
|
writeDomainActual: () => writeDomainActual,
|
|
575
644
|
writeEpoch: () => writeEpoch,
|
|
576
645
|
writeIdentityMismatchMessage: () => writeIdentityMismatchMessage,
|
|
577
646
|
writeIsoDate: () => writeIsoDate,
|
|
578
|
-
writeJsonSyntaxErrorMessage: () => writeJsonSyntaxErrorMessage,
|
|
579
647
|
writeLengthActual: () => writeLengthActual,
|
|
580
648
|
writeMessage: () => writeMessage,
|
|
581
649
|
writeNotEqualActual: () => writeNotEqualActual,
|
|
582
|
-
writeNullableJsonSchema: () =>
|
|
650
|
+
writeNullableJsonSchema: () => writeNullableJsonSchema2,
|
|
583
651
|
writeProtoActual: () => writeProtoActual,
|
|
584
652
|
writeUnbakedMessage: () => writeUnbakedMessage,
|
|
585
|
-
writeUnionJsonSchema: () =>
|
|
653
|
+
writeUnionJsonSchema: () => writeUnionJsonSchema2,
|
|
586
654
|
writeUnitActual: () => writeUnitActual,
|
|
587
655
|
writeUnitMessage: () => writeUnitMessage,
|
|
588
656
|
writeUrl: () => writeUrl,
|
|
@@ -590,40 +658,7 @@ __export(runtimeExports_exports, {
|
|
|
590
658
|
writtenSiteOf: () => writtenSiteOf
|
|
591
659
|
});
|
|
592
660
|
|
|
593
|
-
// out/standalone/artifact.js
|
|
594
|
-
import { $ark as $ark2, hasArkKind as hasArkKind5, holeNameMarker as holeNameMarker3, hashedPrefixLength, isDecidedByAllows as isDecidedByAllows3, isNode as isNode4, isRefinedPattern, madeMorphs as madeMorphs3, registryName, supportedJsonSchemaTargets, ToJsonSchema as ToJsonSchema2, unionJsonSchemaWritersKey } from "@ark/schema";
|
|
595
|
-
import { rootApplyRuntime, rootApplyParts } from "@ark/schema/internal";
|
|
596
|
-
import { writesInPlace } from "@ark/schema/mutatesInput";
|
|
597
|
-
import { appendStringifiedKey as appendStringifiedKey3, arkKindOf as arkKindOf2, cached as cached2, constructorNameOf, flatMorph, functionNameOf as functionNameOf3, hashOf as hashOf2, hasDomain as hasDomain6, isArray as isArray3, isDateObject as isDateObject2, isRegExpObject as isRegExpObject2, isStandardSchema, isThunk as isThunk2, nameOf, ParseError as ParseError2, printable as printable3, prototypeOf as prototypeOf3, testsOrRejects as testsOrRejects3, throwInternalError as throwInternalError2, throwParseError as throwParseError4, unset } from "@ark/util";
|
|
598
|
-
|
|
599
|
-
// out/standalone/baking.js
|
|
600
|
-
import { hasArkKind as hasArkKind4 } from "@ark/schema";
|
|
601
|
-
import { arkKindOf } from "@ark/util";
|
|
602
|
-
|
|
603
|
-
// out/standalone/combinators.js
|
|
604
|
-
import { hasArkKind as hasArkKind3, isDecidedByAllows as isDecidedByAllows2 } from "@ark/schema";
|
|
605
|
-
import { domainOf, isWellFormedInteger as isWellFormedInteger2, returnsReports, testsOrRejects as testsOrRejects2 } from "@ark/util";
|
|
606
|
-
|
|
607
|
-
// out/standalone/compilers.js
|
|
608
|
-
import { compileDomainOf, describeBranches, describeCases, isDecidedByAllows, precompileRootUnits, TraversalCompiler } from "@ark/schema";
|
|
609
|
-
import { throwInternalError } from "@ark/util";
|
|
610
|
-
|
|
611
|
-
// out/standalone/sites.js
|
|
612
|
-
import { $ark } from "@ark/schema";
|
|
613
|
-
import { describesData, errorWriters, errorWritersByCode } from "@ark/schema/internal";
|
|
614
|
-
import { hasDomain as hasDomain4, isDotAccessible, readsOnlyData, testsOrRejects, throwParseError as throwParseError3 } from "@ark/util";
|
|
615
|
-
|
|
616
|
-
// out/standalone/keys.js
|
|
617
|
-
import { hasArkKind as hasArkKind2, holeNameMarker as holeNameMarker2, isNode as isNode3, LazyGenericRoot, madeMorphs as madeMorphs2 } from "@ark/schema";
|
|
618
|
-
import { appendStringifiedKey as appendStringifiedKey2, dateGetTime, hashOf, hasDomain as hasDomain3, isArray, isDateObject, isRegExpObject, isThunk, printable as printable2 } from "@ark/util";
|
|
619
|
-
|
|
620
|
-
// out/standalone/units.js
|
|
621
|
-
import { isNode as isNode2 } from "@ark/schema";
|
|
622
|
-
import { hasDomain as hasDomain2, isDate } from "@ark/util";
|
|
623
|
-
|
|
624
661
|
// out/standalone/values.js
|
|
625
|
-
import { hasArkKind, holeNameMarker, isNode, madeMorphs } from "@ark/schema";
|
|
626
|
-
import { appendStringifiedKey, cached, functionNameOf as functionNameOf2, hasDomain, prototypeOf, throwParseError as throwParseError2 } from "@ark/util";
|
|
627
662
|
var defaultBakedLimit = 1 << 20;
|
|
628
663
|
var dataReference = /\0(\d+)\0/g;
|
|
629
664
|
var minRepeatedPartSize = 32;
|
|
@@ -693,10 +728,10 @@ var indexRuntime = function (value, path) {
|
|
|
693
728
|
};
|
|
694
729
|
for (const [name, value] of Object.entries(runtimeExports_exports))
|
|
695
730
|
indexRuntime(value, `runtime.${name}`);
|
|
696
|
-
var runtimeKeyOf = function (value) { return typeof value === "string" ? void 0 : runtimePathsByValue.get(value) ?? (typeof value === "function" && Reflect.get(globalThis,
|
|
731
|
+
var runtimeKeyOf = function (value) { return typeof value === "string" ? void 0 : runtimePathsByValue.get(value) ?? (typeof value === "function" && Reflect.get(globalThis, functionNameOf(value)) === value ? `globalThis.${functionNameOf(value)}` : void 0) };
|
|
697
732
|
var assertBakeableJsonSchema = function (root) {
|
|
698
733
|
if (root.references.some(callsDefaultThunk)) {
|
|
699
|
-
|
|
734
|
+
throwParseError(writeUnprecompilableMessage("a JSON Schema calling a default's thunk"));
|
|
700
735
|
}
|
|
701
736
|
};
|
|
702
737
|
var callsDefaultThunk = function (node) { return node.is("optional") ? typeof node.inner.default === "function" : node.is("sequence") ? !!node.defaultables?.some(([, value]) => typeof value === "function") : false };
|
|
@@ -704,7 +739,7 @@ var isPlainLiteral = function (value) {
|
|
|
704
739
|
const prototype = prototypeOf(value);
|
|
705
740
|
return prototype === Object.prototype || prototype === null || prototype === Array.prototype;
|
|
706
741
|
};
|
|
707
|
-
var isHole = function (value) { return typeof value === "symbol" || typeof value === "function" && !isNode(value) && !runtimePathsByValue.has(value) && Reflect.get(globalThis,
|
|
742
|
+
var isHole = function (value) { return typeof value === "symbol" || typeof value === "function" && !isNode(value) && !runtimePathsByValue.has(value) && Reflect.get(globalThis, functionNameOf(value)) !== value };
|
|
708
743
|
var keywordMetas = cached(function () {
|
|
709
744
|
const metas = /* @__PURE__ */ new Set();
|
|
710
745
|
const collect = (module) => {
|
|
@@ -776,7 +811,7 @@ var readWritten = function (units2, nodes) {
|
|
|
776
811
|
written.patternInstances.add(node.instance).add(node.tested);
|
|
777
812
|
else if (node.is("optional") || node.is("sequence"))
|
|
778
813
|
collectDefaults(node, written.defaultsByMorph);
|
|
779
|
-
else if (node.is("unit") &&
|
|
814
|
+
else if (node.is("unit") && hasDomain(node.unit, "object") && !isDate(node.unit))
|
|
780
815
|
written.objectUnits.add(node.unit);
|
|
781
816
|
}
|
|
782
817
|
return written;
|
|
@@ -793,7 +828,7 @@ var collectDefaults = function (node, defaultsByMorph) {
|
|
|
793
828
|
if (node.defMorph) {
|
|
794
829
|
defaultsByMorph.set(node.defMorph, [
|
|
795
830
|
node.key,
|
|
796
|
-
node.
|
|
831
|
+
node.requiredValue,
|
|
797
832
|
node.inner.default
|
|
798
833
|
]);
|
|
799
834
|
}
|
|
@@ -803,7 +838,7 @@ var collectDefaults = function (node, defaultsByMorph) {
|
|
|
803
838
|
const [value, defaultValue] = node.defaultables[i];
|
|
804
839
|
defaultsByMorph.set(node.defMorphs[i], [
|
|
805
840
|
node.preLen + i,
|
|
806
|
-
value,
|
|
841
|
+
node.requiredOf(value),
|
|
807
842
|
defaultValue
|
|
808
843
|
]);
|
|
809
844
|
}
|
|
@@ -851,7 +886,7 @@ var namesReadBy = (unit2, returned) => new Set(calledMembersOf(unit2.members, re
|
|
|
851
886
|
var isWriting = (member) => member.endsWith("Transform") || member.endsWith("Copy");
|
|
852
887
|
var readUnitsOf = function (unit2) { return [
|
|
853
888
|
...Object.values(unit2.dependencies).map(([node]) => node),
|
|
854
|
-
...unit2.refs.filter((ref) =>
|
|
889
|
+
...unit2.refs.filter((ref) => isNode(ref) && ref.isRoot())
|
|
855
890
|
].map((node) => unitOf(node, unit2)) };
|
|
856
891
|
var isVariadicArray = function (root) { return root.is("intersection") && root.basis?.is("proto") === true && root.basis.proto === Array && Object.keys(root.inner).length === 2 && Object.keys(root.structure?.inner ?? {}).join() === "sequence" && Object.keys(root.structure.sequence.inner).join() === "variadic" };
|
|
857
892
|
var sharedByUnit = /* @__PURE__ */ new WeakMap();
|
|
@@ -859,7 +894,7 @@ var isSharedUnit = function (unit2, cells) {
|
|
|
859
894
|
let shared = sharedByUnit.get(unit2);
|
|
860
895
|
if (shared === void 0) {
|
|
861
896
|
sharedByUnit.set(unit2, true);
|
|
862
|
-
shared = !unit2.identityNamed.has(unit2.roots[0].id) && !unit2.refs.some((ref) => !
|
|
897
|
+
shared = !unit2.identityNamed.has(unit2.roots[0].id) && !unit2.refs.some((ref) => !isNode(ref) && !isReadByName(ref, cells) && holdsLocal(ref, cells)) && readUnitsOf(unit2).every((read) => isSharedUnit(read, cells));
|
|
863
898
|
sharedByUnit.set(unit2, shared);
|
|
864
899
|
}
|
|
865
900
|
return shared;
|
|
@@ -884,7 +919,7 @@ var writtenSelectedOf = function (units2, selects) {
|
|
|
884
919
|
}
|
|
885
920
|
return selected;
|
|
886
921
|
};
|
|
887
|
-
var holdsObjectMeta = (node) => Object.values(node.meta).some((v) =>
|
|
922
|
+
var holdsObjectMeta = (node) => Object.values(node.meta).some((v) => hasDomain(v, "object"));
|
|
888
923
|
var holdsDefaults = (node) => node.is("optional") ? !!node.defMorph : node.is("sequence") && !!node.defaultables?.length;
|
|
889
924
|
var declares = (root, predicate) => rootUnitsOf(root).some((unit2) => unit2.declared.some(predicate));
|
|
890
925
|
|
|
@@ -893,7 +928,7 @@ var keysByValue = /* @__PURE__ */ new WeakMap();
|
|
|
893
928
|
var keyOf = function (value) {
|
|
894
929
|
let key = keysByValue.get(value);
|
|
895
930
|
if (!key) {
|
|
896
|
-
keysByValue.set(value, key =
|
|
931
|
+
keysByValue.set(value, key = hasArkKind(value, "root") ? rootKeyOf(value) : encodeKey(value));
|
|
897
932
|
}
|
|
898
933
|
return key;
|
|
899
934
|
};
|
|
@@ -919,7 +954,7 @@ var contentNodesOf = function (root) {
|
|
|
919
954
|
if (isArray(value))
|
|
920
955
|
for (const element of value)
|
|
921
956
|
read(element);
|
|
922
|
-
else if (
|
|
957
|
+
else if (isNode(value) && !nodes.has(value)) {
|
|
923
958
|
nodes.add(value);
|
|
924
959
|
for (const held of Object.values(value.inner))
|
|
925
960
|
read(held);
|
|
@@ -928,7 +963,7 @@ var contentNodesOf = function (root) {
|
|
|
928
963
|
read(root);
|
|
929
964
|
return nodes;
|
|
930
965
|
};
|
|
931
|
-
var contentOf = function (value) { return typeof value === "string" ? JSON.stringify(value) : typeof value === "bigint" ? `${value}n` : Object.is(value, -0) ? "-0" : !
|
|
966
|
+
var contentOf = function (value) { return typeof value === "string" ? JSON.stringify(value) : typeof value === "bigint" ? `${value}n` : Object.is(value, -0) ? "-0" : !hasDomain(value, "object") ? typeof value === "symbol" ? "$" : `${value}` : isNode(value) ? contentKeyOf(value) : isArray(value) ? `[${value.map(contentOf).join()}]` : isDateObject(value) ? `${dateGetTime.call(value)}` : "$" };
|
|
932
967
|
var writeId = (id) => JSON.stringify(id.slice(0, 8));
|
|
933
968
|
var traversalKeyOf = (root) => rootKeyOf(root, false);
|
|
934
969
|
var rootKeyOf = function (root, isScoped = true) {
|
|
@@ -972,32 +1007,32 @@ var encodeKey = function (start, defaultsByMorph, mode = defaultsByMorph ? "valu
|
|
|
972
1007
|
};
|
|
973
1008
|
const at = (path) => path ? ` at \`${path}\`` : "";
|
|
974
1009
|
const write = (value, path, mode2) => {
|
|
975
|
-
if (
|
|
1010
|
+
if (hasDomain(value, "object")) {
|
|
976
1011
|
const index = seen.get(value);
|
|
977
1012
|
if (index !== void 0)
|
|
978
1013
|
return void values.push(`seen ${index}`);
|
|
979
1014
|
seen.set(value, seen.size);
|
|
980
1015
|
}
|
|
981
1016
|
const defaulted = defaultsByMorph?.get(value);
|
|
982
|
-
const runtimeKey =
|
|
1017
|
+
const runtimeKey = hasDomain(value, "object") && runtimeKeyOf(value);
|
|
983
1018
|
if (defaulted) {
|
|
984
1019
|
values.push("default");
|
|
985
1020
|
write(defaulted[2], path, "value");
|
|
986
1021
|
} else if (runtimeKey)
|
|
987
1022
|
values.push(`runtime ${runtimeKey}`);
|
|
988
|
-
else if (
|
|
1023
|
+
else if (isNode(value)) {
|
|
989
1024
|
if (defaultsByMorph || !value.isRoot())
|
|
990
1025
|
values.push("node");
|
|
991
1026
|
else
|
|
992
1027
|
writeKeyOf("Type", value, path);
|
|
993
|
-
} else if (
|
|
1028
|
+
} else if (hasArkKind(value, "module")) {
|
|
994
1029
|
const entries = Object.entries(value);
|
|
995
1030
|
values.push(`Module ${entries.length}`);
|
|
996
1031
|
for (const [k, entry] of entries) {
|
|
997
1032
|
values.push(JSON.stringify(k));
|
|
998
|
-
write(entry,
|
|
1033
|
+
write(entry, appendStringifiedKey(path, k), "definition");
|
|
999
1034
|
}
|
|
1000
|
-
} else if (
|
|
1035
|
+
} else if (hasArkKind(value, "scope")) {
|
|
1001
1036
|
if (value.isBuiltin)
|
|
1002
1037
|
values.push(`Scope ${value.name}`);
|
|
1003
1038
|
else if (value !== start)
|
|
@@ -1012,18 +1047,18 @@ var encodeKey = function (start, defaultsByMorph, mode = defaultsByMorph ? "valu
|
|
|
1012
1047
|
values.push("thunk");
|
|
1013
1048
|
thunks.push([value, k, ""]);
|
|
1014
1049
|
} else
|
|
1015
|
-
write(def,
|
|
1050
|
+
write(def, appendStringifiedKey(path, k), "definition");
|
|
1016
1051
|
}
|
|
1017
1052
|
}
|
|
1018
|
-
} else if (
|
|
1053
|
+
} else if (hasArkKind(value, "generic")) {
|
|
1019
1054
|
values.push("Generic");
|
|
1020
1055
|
write(value.paramDefs, path, "definition");
|
|
1021
1056
|
if (value.hkt) {
|
|
1022
1057
|
refuse(`has an hkt body${at(path)}, whose results decide what it creates`);
|
|
1023
1058
|
} else
|
|
1024
1059
|
write(value.bodyDef, path, "definition");
|
|
1025
|
-
write(value.$,
|
|
1026
|
-
write(value.arg$,
|
|
1060
|
+
write(value.$, appendStringifiedKey(path, "$"), "definition");
|
|
1061
|
+
write(value.arg$, appendStringifiedKey(path, "arg$"), "definition");
|
|
1027
1062
|
} else if (isTypedFn(value)) {
|
|
1028
1063
|
values.push("TypedFn");
|
|
1029
1064
|
write(value.params, path, "value");
|
|
@@ -1034,15 +1069,15 @@ var encodeKey = function (start, defaultsByMorph, mode = defaultsByMorph ? "valu
|
|
|
1034
1069
|
write(value.bodyDef, path, "definition");
|
|
1035
1070
|
} else if (mode2 === "definition" && isThunk(value))
|
|
1036
1071
|
refuse(`holds a thunk${at(path)}, whose result decides what it creates`);
|
|
1037
|
-
else if (
|
|
1038
|
-
const [make, args] =
|
|
1072
|
+
else if (madeMorphs.has(value)) {
|
|
1073
|
+
const [make, args] = madeMorphs.get(value);
|
|
1039
1074
|
values.push(`made ${runtimeKeyOf(make)}`);
|
|
1040
1075
|
write(args, path, "value");
|
|
1041
1076
|
} else if (mode2 === "config" && isHole(value)) {
|
|
1042
1077
|
refuse(`configures \`${path}\` with a function, whose results decide what it creates`);
|
|
1043
1078
|
} else if (isHole(value))
|
|
1044
1079
|
values.push(`hole ${holeIndexOf(value)}`);
|
|
1045
|
-
else if (!
|
|
1080
|
+
else if (!hasDomain(value, "object"))
|
|
1046
1081
|
values.push(printablePrimitive(value));
|
|
1047
1082
|
else if (isDateObject(value))
|
|
1048
1083
|
values.push(`Date ${dateGetTime.call(value)}`);
|
|
@@ -1052,26 +1087,26 @@ var encodeKey = function (start, defaultsByMorph, mode = defaultsByMorph ? "valu
|
|
|
1052
1087
|
values.push(`[${value.length}`);
|
|
1053
1088
|
const definitions = valueTupleHeads.includes(value[0]) ? 0 : valueOperators.includes(value[1]) ? 1 : value.length;
|
|
1054
1089
|
for (let i = 0; i < value.length; i++) {
|
|
1055
|
-
write(value[i],
|
|
1090
|
+
write(value[i], appendStringifiedKey(path, i), mode2 === "definition" && i >= definitions ? "value" : mode2);
|
|
1056
1091
|
}
|
|
1057
1092
|
} else if (isPlainLiteral(value)) {
|
|
1058
1093
|
const keys = Reflect.ownKeys(value);
|
|
1059
1094
|
values.push(`{${keys.length}`);
|
|
1060
1095
|
for (const k of keys) {
|
|
1061
1096
|
write(k, path, "value");
|
|
1062
|
-
write(Reflect.get(value, k), typeof k === "symbol" ? path :
|
|
1097
|
+
write(Reflect.get(value, k), typeof k === "symbol" ? path : appendStringifiedKey(path, k), mode2);
|
|
1063
1098
|
}
|
|
1064
1099
|
} else
|
|
1065
|
-
refuse(`holds ${
|
|
1100
|
+
refuse(`holds ${printable(value)}${at(path)}, which its key can't encode`);
|
|
1066
1101
|
};
|
|
1067
1102
|
write(start, "", mode);
|
|
1068
1103
|
return [hashOf(values.join("\n")), holes, refusal, thunks];
|
|
1069
1104
|
};
|
|
1070
1105
|
var appendPath = (path, rest) => !path ? rest : !rest ? path : rest[0] === "[" ? path + rest : `${path}.${rest}`;
|
|
1071
|
-
var isThunkAlias = (def) => isThunk(def) && !
|
|
1106
|
+
var isThunkAlias = (def) => isThunk(def) && !hasArkKind(def, "generic") && !(def instanceof LazyGenericRoot);
|
|
1072
1107
|
var isTypedFn = (value) => value instanceof InternalTypedFn;
|
|
1073
|
-
var kindNameOf = function (value) { return
|
|
1074
|
-
var printablePrimitive = (value) => Object.is(value, -0) ? "-0" :
|
|
1108
|
+
var kindNameOf = function (value) { return hasArkKind(value, "root") ? "Type" : hasArkKind(value, "module") ? "Module" : hasArkKind(value, "scope") ? "Scope" : hasArkKind(value, "generic") ? "Generic" : "TypedFn" };
|
|
1109
|
+
var printablePrimitive = (value) => Object.is(value, -0) ? "-0" : printable(value);
|
|
1075
1110
|
var valueTupleHeads = ["instanceof", "==="];
|
|
1076
1111
|
var valueOperators = [":", "=>", "=", "@"];
|
|
1077
1112
|
var minComposedLength = 64;
|
|
@@ -1082,7 +1117,7 @@ var partsOf = function (root, kind) {
|
|
|
1082
1117
|
if (!node.isRoot())
|
|
1083
1118
|
continue;
|
|
1084
1119
|
const part = node[kind];
|
|
1085
|
-
if (part.length >= minComposedLength && part !== s && !part.includes(
|
|
1120
|
+
if (part.length >= minComposedLength && part !== s && !part.includes(holeNameMarker))
|
|
1086
1121
|
candidates[part] = node;
|
|
1087
1122
|
}
|
|
1088
1123
|
const taken = [];
|
|
@@ -1111,7 +1146,7 @@ var registeredNameAt = function (hash, i) {
|
|
|
1111
1146
|
const reference = /^\$ark\d*\.([\w$]+)"/.exec(hash.slice(start));
|
|
1112
1147
|
return reference && i > start + reference[0].indexOf(".") ? reference[1] : void 0;
|
|
1113
1148
|
};
|
|
1114
|
-
var holeName = `[\\w$]*${
|
|
1149
|
+
var holeName = `[\\w$]*${holeNameMarker.replace("$", "\\$")}[\\da-z]+`;
|
|
1115
1150
|
var holeNamePattern = new RegExp(holeName, "g");
|
|
1116
1151
|
var printedHoleNamePattern = new RegExp(`\\$ark\\.(${holeName})(?:\\$[1-9]\\d*)?|valid according to (${holeName})|Function\\((${holeName})\\)|(${holeName})`, "g");
|
|
1117
1152
|
|
|
@@ -1130,13 +1165,13 @@ var assertDescribed = function (root) {
|
|
|
1130
1165
|
continue;
|
|
1131
1166
|
const reason = writer !== $ark.cfg[code][k] ? `a scope's configured ${code} ${k}` : raisable === "any" && code === "predicate" ? `a configured ${code} ${k} that a narrow or morph raises` : typeof writer === "function" && k !== "actual" && unwritableCodes.has(code) ? `a configured ${code} ${k} writer, which reads each branch's errors` : void 0;
|
|
1132
1167
|
if (reason)
|
|
1133
|
-
|
|
1168
|
+
throwParseError(writeUnprecompilableMessage(reason));
|
|
1134
1169
|
}
|
|
1135
1170
|
}
|
|
1136
1171
|
for (const node of writtenSelectedOf(rootUnitsOf(root), isUnion)) {
|
|
1137
1172
|
for (const k of describingKeys) {
|
|
1138
1173
|
if (k !== "actual" && typeof node.meta[k] === "function") {
|
|
1139
|
-
|
|
1174
|
+
throwParseError(writeUnprecompilableMessage(`\`${node.expression}\`'s ${k} writer, which reads each branch's errors`));
|
|
1140
1175
|
}
|
|
1141
1176
|
}
|
|
1142
1177
|
}
|
|
@@ -1188,6 +1223,8 @@ var addIssueFeatures = function (features, units2, written) {
|
|
|
1188
1223
|
features.bracketsKeys = true;
|
|
1189
1224
|
features.writesText = true;
|
|
1190
1225
|
features.readsErrors = true;
|
|
1226
|
+
if (node.is("morph"))
|
|
1227
|
+
features.listsUnions = true;
|
|
1191
1228
|
} else if (node.is("union") && node.tfs) {
|
|
1192
1229
|
features.transformsBranches = true;
|
|
1193
1230
|
if (node.hasMorph || node.hasAlias)
|
|
@@ -1247,7 +1284,7 @@ var siteWords = /* @__PURE__ */ new Set([
|
|
|
1247
1284
|
"p",
|
|
1248
1285
|
"m"
|
|
1249
1286
|
]);
|
|
1250
|
-
var isLiteralSite = function (value, emitted) { return
|
|
1287
|
+
var isLiteralSite = function (value, emitted) { return hasDomain(value, "object") && failureSites.has(value) && (withoutStrings(emitted).match(/[$A-Z_a-z][\w$]*/g) ?? []).every((word) => siteWords.has(word)) };
|
|
1251
1288
|
var withoutStrings = (code) => code.replace(/"(?:[^"\\]|\\.)*"/g, '""');
|
|
1252
1289
|
var writeSiteOf = function ({ code, description, message, c }, emit, writer = "siteOf", missing) {
|
|
1253
1290
|
const args = writer === "keySiteOf" ? [code, description, missing === description ? void 0 : missing] : [code, description, message];
|
|
@@ -1276,11 +1313,7 @@ var describerOf = function (writer, readsActual) {
|
|
|
1276
1313
|
return "";
|
|
1277
1314
|
return runtimeKeyOf(writer) ? writer : printKind;
|
|
1278
1315
|
};
|
|
1279
|
-
var unwritableCodes = /* @__PURE__ */ new Set([
|
|
1280
|
-
"union",
|
|
1281
|
-
"discriminant",
|
|
1282
|
-
"intersection"
|
|
1283
|
-
]);
|
|
1316
|
+
var unwritableCodes = /* @__PURE__ */ new Set(["union", "discriminant"]);
|
|
1284
1317
|
var issueContextOf = function (context) {
|
|
1285
1318
|
const { code } = context;
|
|
1286
1319
|
const configured = $ark.cfg[code];
|
|
@@ -1880,10 +1913,10 @@ var unitsByRootOf = function (keyOf2) {
|
|
|
1880
1913
|
};
|
|
1881
1914
|
var variantsOfUnits = /* @__PURE__ */ new WeakMap();
|
|
1882
1915
|
var rootUnitsOf = function (root, variant = 0, keyOf2 = runtimeKeyOf) {
|
|
1883
|
-
const
|
|
1884
|
-
let units2 =
|
|
1916
|
+
const cached2 = unitsByRootOf(keyOf2)[variant];
|
|
1917
|
+
let units2 = cached2.get(root);
|
|
1885
1918
|
if (!units2) {
|
|
1886
|
-
|
|
1919
|
+
cached2.set(root, units2 = precompileRootUnits(root, {
|
|
1887
1920
|
compiler: compilers[variant],
|
|
1888
1921
|
keyOf: keyOf2
|
|
1889
1922
|
}));
|
|
@@ -1970,7 +2003,7 @@ var calleesOf = function (node) {
|
|
|
1970
2003
|
discriminated.otherwise
|
|
1971
2004
|
].filter((branch) => branch !== true && branch !== void 0);
|
|
1972
2005
|
}
|
|
1973
|
-
if (node.discriminant || !
|
|
2006
|
+
if (node.discriminant || !isDecidedByAllows(node) || !unionSiteOf(node))
|
|
1974
2007
|
return;
|
|
1975
2008
|
return [...node.branches];
|
|
1976
2009
|
}
|
|
@@ -1980,9 +2013,9 @@ var morphCalleesOf = function (node) {
|
|
|
1980
2013
|
return;
|
|
1981
2014
|
const callees = [];
|
|
1982
2015
|
for (const [i, step] of node.travMorphs.entries()) {
|
|
1983
|
-
if (
|
|
2016
|
+
if (hasArkKind(step, "root") && !step.hasAlias)
|
|
1984
2017
|
callees.push(step);
|
|
1985
|
-
else if (
|
|
2018
|
+
else if (hasArkKind(step, "root") || !node.contextFree[i])
|
|
1986
2019
|
return;
|
|
1987
2020
|
}
|
|
1988
2021
|
return callees;
|
|
@@ -2047,7 +2080,7 @@ var discriminatedOf = function (node) {
|
|
|
2047
2080
|
if (!areBooleans && !k.startsWith('"'))
|
|
2048
2081
|
return;
|
|
2049
2082
|
const value = JSON.parse(k);
|
|
2050
|
-
if (!areBooleans && (
|
|
2083
|
+
if (!areBooleans && (isWellFormedInteger(value) || value === "__proto__"))
|
|
2051
2084
|
return;
|
|
2052
2085
|
const pruned = discriminant.cases[k];
|
|
2053
2086
|
cases[areBooleans ? k : value] = pruned === true || combines(pruned) ? pruned : unprunedOf(node, (branch) => {
|
|
@@ -2088,7 +2121,7 @@ var unprunedOf = function (node, isCase, pruned) {
|
|
|
2088
2121
|
const matched = node.branches.filter(isCase);
|
|
2089
2122
|
return matched.length === 1 ? matched[0] : pruned;
|
|
2090
2123
|
};
|
|
2091
|
-
var isLiteralKey = (key) => typeof key === "string" && key !== "__proto__" && !
|
|
2124
|
+
var isLiteralKey = (key) => typeof key === "string" && key !== "__proto__" && !isWellFormedInteger(key) && !(key in Object.prototype);
|
|
2092
2125
|
var isLiteralDefault = (prop) => !prop.value.tfs && isPrinted(prop.default);
|
|
2093
2126
|
var writesByValues = (prop) => prop.is("optional") && prop.hasDef() && (prop.defaultsUndefined || !isLiteralDefault(prop));
|
|
2094
2127
|
var removedSiteOf = (structure) => plainContextOf(issueContextOf({
|
|
@@ -2442,7 +2475,7 @@ var writeChecker = function (js, node) {
|
|
|
2442
2475
|
return writeUnionCombinator(js, node);
|
|
2443
2476
|
};
|
|
2444
2477
|
var writeMorph = function (js, node) { return writeCall("morphing", node.head ? readChecker(js, node.head) : "0", `[${node.travMorphs.slice(node.head ? 1 : 0).map((step) => {
|
|
2445
|
-
if (!
|
|
2478
|
+
if (!hasArkKind(step, "root")) {
|
|
2446
2479
|
return isKeyword(step) ? js.ref(step) : `data => ${js.ref(step)}(data)`;
|
|
2447
2480
|
}
|
|
2448
2481
|
js.link.byId[step.id] ??= step;
|
|
@@ -2474,7 +2507,7 @@ var writePredicate = function (js, node) {
|
|
|
2474
2507
|
}
|
|
2475
2508
|
return writeCall(
|
|
2476
2509
|
// passed a ctx of its own, which reports at a site as a check does
|
|
2477
|
-
|
|
2510
|
+
testsOrRejects.has(node.predicate) ? "narrowedRejecting" : returnsReports.has(node.predicate) ? "narrowedWithCtx" : raisesNothing(node.predicate) ? "narrowedBy" : "narrowedInCtx",
|
|
2478
2511
|
`() => ${fn}`,
|
|
2479
2512
|
isNamedByItsFunction(node) ? void 0 : JSON.stringify(predicateSiteOf(node).description)
|
|
2480
2513
|
);
|
|
@@ -2538,9 +2571,10 @@ var defaultMembers = [
|
|
|
2538
2571
|
"assert",
|
|
2539
2572
|
"meta",
|
|
2540
2573
|
"~standard",
|
|
2541
|
-
"methods"
|
|
2574
|
+
"methods",
|
|
2575
|
+
"withContext"
|
|
2542
2576
|
];
|
|
2543
|
-
var bakedRootsOf = (bakes) =>
|
|
2577
|
+
var bakedRootsOf = (bakes) => hasArkKind(bakes, "root") ? [bakes] : Object.values(bakes).flatMap((value) => bakedRootsOf(value));
|
|
2544
2578
|
var wholeReads = {
|
|
2545
2579
|
called: true,
|
|
2546
2580
|
readsAllows: true,
|
|
@@ -2620,7 +2654,7 @@ var compiledInputsOf = function (exports) {
|
|
|
2620
2654
|
const inputs = /* @__PURE__ */ new Set();
|
|
2621
2655
|
for (const value of Object.values(exports)) {
|
|
2622
2656
|
const type2 = arkKindOf(value) !== void 0 ? value : "member" in value || "bakes" in value ? void 0 : value.type;
|
|
2623
|
-
if (
|
|
2657
|
+
if (hasArkKind(type2, "root") && type2._in !== type2 && !combines(type2))
|
|
2624
2658
|
inputs.add(type2._in.hash);
|
|
2625
2659
|
}
|
|
2626
2660
|
return inputs;
|
|
@@ -2628,10 +2662,10 @@ var compiledInputsOf = function (exports) {
|
|
|
2628
2662
|
var bakedByRootOf = function (exports, baked = {}) {
|
|
2629
2663
|
const result = /* @__PURE__ */ new Map();
|
|
2630
2664
|
const add = (value, members) => {
|
|
2631
|
-
if (
|
|
2665
|
+
if (hasArkKind(value, "module"))
|
|
2632
2666
|
for (const entry of Object.values(value))
|
|
2633
2667
|
add(entry, members);
|
|
2634
|
-
if (!
|
|
2668
|
+
if (!hasArkKind(value, "root"))
|
|
2635
2669
|
return;
|
|
2636
2670
|
const prior = result.get(value);
|
|
2637
2671
|
result.set(value, prior ? {
|
|
@@ -2740,7 +2774,7 @@ var writtenAttributesOf = function (writesId, form, attributes, meta, onFail) {
|
|
|
2740
2774
|
) };
|
|
2741
2775
|
var canPipe = (baking, members, unconfigured) => baking.detailsErrors || !unconfigured || members.has("assert");
|
|
2742
2776
|
var preciseFormOf = function (baking, members, unconfigured, reads) {
|
|
2743
|
-
if (members.has("methods") || members.has("~standard") || reads.piped && canPipe(baking, members, unconfigured))
|
|
2777
|
+
if (members.has("methods") || members.has("~standard") || members.has("withContext") || reads.piped && canPipe(baking, members, unconfigured))
|
|
2744
2778
|
return;
|
|
2745
2779
|
if (!reads.called)
|
|
2746
2780
|
return "object";
|
|
@@ -2795,7 +2829,7 @@ var creatorBodyOf = function (baking, form) {
|
|
|
2795
2829
|
const standard = frozen(baking, `{
|
|
2796
2830
|
vendor: "arktype",
|
|
2797
2831
|
version: 1,
|
|
2798
|
-
validate: ${frozen(baking, "input => runtime.
|
|
2832
|
+
validate: ${frozen(baking, "(input, options) => runtime.standardValidated(validator, input, options)")}${members.has("~standard.jsonSchema") ? `,
|
|
2799
2833
|
...attributes["~standard"]` : ""}
|
|
2800
2834
|
}`);
|
|
2801
2835
|
const call = creatorCallOf(baking, form);
|
|
@@ -2808,6 +2842,7 @@ var creatorBodyOf = function (baking, form) {
|
|
|
2808
2842
|
!form.hasAttributes || !isCalled ? "" : holdsOnlyMeta(members) ? "validator.meta = meta" : "runtime.own(validator, attributes)",
|
|
2809
2843
|
reads.readsAllows && isCalled ? `validator.allows = ${form.allowsOf}` : "",
|
|
2810
2844
|
members.has("~standard") ? `validator["~standard"] = ${standard}` : "",
|
|
2845
|
+
members.has("withContext") && isCalled ? `validator.withContext = ${frozen(baking, "context => runtime.withContextOf(validator, context)")}` : "",
|
|
2811
2846
|
baking.holdsIds ? `return runtime.holdHoles(${frozen(baking, "validator")}, id, holes)` : `return ${frozen(baking, "validator")}`
|
|
2812
2847
|
].filter((statement) => statement).map((statement) => ` ${statement}`).join("\n");
|
|
2813
2848
|
};
|
|
@@ -2829,8 +2864,6 @@ var creatorSourceOf = function (baking, form, applier, makes) {
|
|
|
2829
2864
|
};
|
|
2830
2865
|
|
|
2831
2866
|
// out/standalone/fallbacks.js
|
|
2832
|
-
import { foreignTypesByMorph, ToJsonSchema, writeNullableJsonSchema as writeNullableJsonSchema2, writeUnionJsonSchema as writeUnionJsonSchema2 } from "@ark/schema";
|
|
2833
|
-
import { hasDomain as hasDomain5, isArray as isArray2, prototypeOf as prototypeOf2 } from "@ark/util";
|
|
2834
2867
|
var replayRefusal = new Error("refused");
|
|
2835
2868
|
var maxTracedReads = 1 << 24;
|
|
2836
2869
|
var tooDeep = /* @__PURE__ */ new WeakSet();
|
|
@@ -2840,8 +2873,8 @@ var refuseReplay = () => {
|
|
|
2840
2873
|
var stringKeyOf = (key) => typeof key === "string" ? key : refuseReplay();
|
|
2841
2874
|
var isUnreplayable = function (node) { return node.is("index") ? node.signature.branches.some((branch) => branch.is("morph")) : node.is("morph") && foreignTypesByMorph.has(node.piped[0]) };
|
|
2842
2875
|
var writersByName = {
|
|
2843
|
-
union:
|
|
2844
|
-
nullable:
|
|
2876
|
+
union: writeUnionJsonSchema,
|
|
2877
|
+
nullable: writeNullableJsonSchema
|
|
2845
2878
|
};
|
|
2846
2879
|
var defaultCallsOf = (steps) => new Set(steps.flatMap((step) => "code" in step && step.code === "defaultValue" ? [step.call] : []));
|
|
2847
2880
|
var isUnchanged = function (keys, o, keysRead, valuesRead) {
|
|
@@ -2871,7 +2904,7 @@ var traceFallbacks = function (root, write, printsResults) {
|
|
|
2871
2904
|
return { hole };
|
|
2872
2905
|
let id = ids.get(value);
|
|
2873
2906
|
if (id === void 0) {
|
|
2874
|
-
const prototype =
|
|
2907
|
+
const prototype = prototypeOf(value);
|
|
2875
2908
|
if (prototype !== Object.prototype && prototype !== Array.prototype)
|
|
2876
2909
|
return { value };
|
|
2877
2910
|
if (Object.getOwnPropertySymbols(value).length)
|
|
@@ -2961,7 +2994,7 @@ var traceFallbacks = function (root, write, printsResults) {
|
|
|
2961
2994
|
steps.push({ call: hole, code: ctx.code, ctx: object2, changes });
|
|
2962
2995
|
return result;
|
|
2963
2996
|
};
|
|
2964
|
-
const copiesResult = (value) =>
|
|
2997
|
+
const copiesResult = (value) => hasDomain(value, "object") && !holes.has(value) && Object.keys(value).some((key) => markers.has(key));
|
|
2965
2998
|
const writers = Object.fromEntries(Object.entries(writersByName).map(([name, writeArktypes]) => [
|
|
2966
2999
|
name,
|
|
2967
3000
|
(...args) => {
|
|
@@ -2983,7 +3016,7 @@ var traceFallbacks = function (root, write, printsResults) {
|
|
|
2983
3016
|
args: args.map((arg, i) => refOf(
|
|
2984
3017
|
// a union's meta, whose functions, like onFail, no
|
|
2985
3018
|
// schema holds
|
|
2986
|
-
name === "union" && i
|
|
3019
|
+
name === "union" && (i === 2 || i === 3) ? Object.fromEntries(Object.entries(arg).filter(([, v]) => typeof v !== "function")) : arg
|
|
2987
3020
|
)),
|
|
2988
3021
|
changes: changesSinceLastStep()
|
|
2989
3022
|
});
|
|
@@ -2994,7 +3027,7 @@ var traceFallbacks = function (root, write, printsResults) {
|
|
|
2994
3027
|
try {
|
|
2995
3028
|
const result = refOf(write(fallback, writers));
|
|
2996
3029
|
const changes = changesSinceLastStep();
|
|
2997
|
-
trace = { steps, result, changes, states, arrays: objects.map(
|
|
3030
|
+
trace = { steps, result, changes, states, arrays: objects.map(isArray) };
|
|
2998
3031
|
} catch (e) {
|
|
2999
3032
|
if (e === replayRefusal)
|
|
3000
3033
|
return;
|
|
@@ -3056,6 +3089,7 @@ var writeReplay = function (trace, writeValue2, handlerOf, read) {
|
|
|
3056
3089
|
const states = [];
|
|
3057
3090
|
const written = [];
|
|
3058
3091
|
const isDefault = (ref) => "hole" in ref && defaults.has(ref.hole);
|
|
3092
|
+
const hasEmptyBase = (ctx) => ctx.some((entry) => "key" in entry && entry.key === "base" && "object" in entry.ref && !states[entry.ref.object].length);
|
|
3059
3093
|
const expressionOf = (ref) => "hole" in ref ? read(`h${ref.hole}`, true) : "object" in ref ? objectAt(ref.object) : writeValue2(ref.value);
|
|
3060
3094
|
const objectAt = (id) => {
|
|
3061
3095
|
if (inlines[id])
|
|
@@ -3120,7 +3154,7 @@ var writeReplay = function (trace, writeValue2, handlerOf, read) {
|
|
|
3120
3154
|
if ("code" in step) {
|
|
3121
3155
|
const ctx = objectAt(step.ctx);
|
|
3122
3156
|
const fallsBack = `f(${JSON.stringify(step.code)}, ${ctx}${handlerArg(handlerOf(step.code, step.call))})`;
|
|
3123
|
-
const isDate2 = step.code === "date" && states[step.ctx]
|
|
3157
|
+
const isDate2 = step.code === "date" && hasEmptyBase(states[step.ctx]);
|
|
3124
3158
|
statements.push(`const h${step.call} = ${isDate2 ? `${fallsBack} ?? f("proto", { code: "proto", base: {}, proto: ${writeValue2(Date)} }${handlerArg(handlerOf("proto"))})` : fallsBack}`);
|
|
3125
3159
|
} else if ("args" in step) {
|
|
3126
3160
|
const args = step.args.map(expressionOf);
|
|
@@ -3317,20 +3351,20 @@ var createDeclarations = function () { return ({
|
|
|
3317
3351
|
}) };
|
|
3318
3352
|
var writesByBaking = /* @__PURE__ */ new WeakMap();
|
|
3319
3353
|
var holdsObjectInMeta = function ({ meta }) { return Object.entries(meta).some(([k, v]) => (k === "examples" ? v : [v]).some((value) => typeof value === "object" && value !== null && !keywordMetaObjects().has(value))) };
|
|
3320
|
-
var keywordMetaObjects =
|
|
3354
|
+
var keywordMetaObjects = cached(function () {
|
|
3321
3355
|
const objects = /* @__PURE__ */ new Set();
|
|
3322
3356
|
const read = (module) => {
|
|
3323
3357
|
for (const value of Object.values(module)) {
|
|
3324
|
-
if (
|
|
3358
|
+
if (hasArkKind(value, "module"))
|
|
3325
3359
|
read(value);
|
|
3326
|
-
else if (
|
|
3360
|
+
else if (hasArkKind(value, "root")) {
|
|
3327
3361
|
for (const node of value.references)
|
|
3328
3362
|
for (const held of Object.values(node.meta))
|
|
3329
3363
|
objects.add(held);
|
|
3330
3364
|
}
|
|
3331
3365
|
}
|
|
3332
3366
|
};
|
|
3333
|
-
read($
|
|
3367
|
+
read($ark.ambient);
|
|
3334
3368
|
return objects;
|
|
3335
3369
|
});
|
|
3336
3370
|
var bakingKeyOf = ({ write, issues: issues2, sharedWrites, compilesValidators, compiledInputs, members, cells, interned: interned2, scopeNameOf, ...rest }) => JSON.stringify([rest, [...members].sort()]);
|
|
@@ -3351,7 +3385,7 @@ var isDigestible = function (value) {
|
|
|
3351
3385
|
const keys = Reflect.ownKeys(value).filter((k) => !(k === "length" && Array.isArray(value)));
|
|
3352
3386
|
return keys.length >= 4 && keys.every((k) => {
|
|
3353
3387
|
const v = Reflect.get(value, k);
|
|
3354
|
-
return typeof k === "string" && typeof v !== "symbol" && typeof v !== "function" && !
|
|
3388
|
+
return typeof k === "string" && typeof v !== "symbol" && typeof v !== "function" && !hasDomain(v, "object");
|
|
3355
3389
|
});
|
|
3356
3390
|
};
|
|
3357
3391
|
var printedHolesByUnit = /* @__PURE__ */ new WeakMap();
|
|
@@ -3361,7 +3395,7 @@ var printedHoleOf = function (unit2) {
|
|
|
3361
3395
|
if (printed === void 0) {
|
|
3362
3396
|
printed = null;
|
|
3363
3397
|
for (const [, source] of unit2.members) {
|
|
3364
|
-
const match = source.includes(
|
|
3398
|
+
const match = source.includes(holeNameMarker) && source.match(firstHoleName);
|
|
3365
3399
|
if (match) {
|
|
3366
3400
|
printed = match[0];
|
|
3367
3401
|
break;
|
|
@@ -3443,16 +3477,16 @@ var StandaloneArtifact = class {
|
|
|
3443
3477
|
this.sharedModules = sharedModules;
|
|
3444
3478
|
this.imports = imports;
|
|
3445
3479
|
for (const [name, value] of Object.entries(exports)) {
|
|
3446
|
-
const path =
|
|
3480
|
+
const path = appendStringifiedKey("", name);
|
|
3447
3481
|
this.collectExport(value, path);
|
|
3448
3482
|
}
|
|
3449
3483
|
this.exportedRoots = new Set(this.roots);
|
|
3450
3484
|
for (const [node] of this.defaultChecks)
|
|
3451
3485
|
this.collectType(node.in);
|
|
3452
3486
|
this.checkedRoots = new Set(this.roots.filter((root2) => !this.exportedRoots.has(root2)));
|
|
3453
|
-
const locale = $
|
|
3454
|
-
if (locale !== void 0 && locale !== $
|
|
3455
|
-
|
|
3487
|
+
const locale = $ark.config.locale;
|
|
3488
|
+
if (locale !== void 0 && locale !== $ark.defaultConfig.locale)
|
|
3489
|
+
throwParseError(writeUnprecompilableMessage("a configured locale"));
|
|
3456
3490
|
do {
|
|
3457
3491
|
for (const root2 of this.roots) {
|
|
3458
3492
|
if (this.unitRoots.has(root2))
|
|
@@ -3470,8 +3504,8 @@ var StandaloneArtifact = class {
|
|
|
3470
3504
|
} while (this.collectMetaTypes() || this.collectDefaultTypes());
|
|
3471
3505
|
this.comparedRoots = this.roots;
|
|
3472
3506
|
for (const root2 of this.roots) {
|
|
3473
|
-
if (root2.meta.onFail === void 0 && root2.onFail !== $
|
|
3474
|
-
|
|
3507
|
+
if (root2.meta.onFail === void 0 && root2.onFail !== $ark.cfg.onFail)
|
|
3508
|
+
throwParseError(writeUnprecompilableMessage("onFail"));
|
|
3475
3509
|
}
|
|
3476
3510
|
const [root] = this.unitRoots;
|
|
3477
3511
|
const units2 = this.unitRoots.size === 1 ? this.unitsOf(root) : void 0;
|
|
@@ -3577,7 +3611,7 @@ var StandaloneArtifact = class {
|
|
|
3577
3611
|
if (cell.text !== void 0)
|
|
3578
3612
|
return this.readCell(cell);
|
|
3579
3613
|
if (this.writing && !this.defersCellReads) {
|
|
3580
|
-
|
|
3614
|
+
throwInternalError(`Unexpected read of ${cell.name} as a shared module loads`);
|
|
3581
3615
|
}
|
|
3582
3616
|
this.readsCell = true;
|
|
3583
3617
|
return this.readCell(cell);
|
|
@@ -3615,9 +3649,9 @@ var StandaloneArtifact = class {
|
|
|
3615
3649
|
for (const hole of this.holeExpressions.keys()) {
|
|
3616
3650
|
if (typeof hole !== "function")
|
|
3617
3651
|
continue;
|
|
3618
|
-
const name =
|
|
3619
|
-
if (!name.includes(
|
|
3620
|
-
|
|
3652
|
+
const name = functionNameOf(hole);
|
|
3653
|
+
if (!name.includes(holeNameMarker)) {
|
|
3654
|
+
throwInternalError(`Unexpected function ${this.holeLabels.get(hole)} not named by a placeholder`);
|
|
3621
3655
|
}
|
|
3622
3656
|
const first = holesByName[name];
|
|
3623
3657
|
if (first === void 0)
|
|
@@ -3629,20 +3663,20 @@ var StandaloneArtifact = class {
|
|
|
3629
3663
|
for (const unit2 of this.units) {
|
|
3630
3664
|
const printed = printedHoleOf(unit2);
|
|
3631
3665
|
if (printed) {
|
|
3632
|
-
|
|
3666
|
+
throwParseError(writeUnprecompilableMessage(`compiled code printing the name of ${this.holeLabels.get(this.holeNamed(printed)) ?? printed}`));
|
|
3633
3667
|
}
|
|
3634
3668
|
}
|
|
3635
3669
|
for (const node of this.declared) {
|
|
3636
3670
|
const lists = node.is("union") ? node.inner.ordered ? [] : [node.branches] : sortedConstraintKeys.map((k) => node.inner[k]);
|
|
3637
3671
|
for (const list of lists) {
|
|
3638
|
-
if (!
|
|
3672
|
+
if (!isArray(list))
|
|
3639
3673
|
continue;
|
|
3640
3674
|
for (let i = 1; i < list.length; i++)
|
|
3641
3675
|
this.refuseHoleOrdering(list[i - 1], list[i]);
|
|
3642
3676
|
}
|
|
3643
3677
|
}
|
|
3644
3678
|
}
|
|
3645
|
-
holeNamed(name, read =
|
|
3679
|
+
holeNamed(name, read = functionNameOf) {
|
|
3646
3680
|
for (const hole of this.holeLabels.keys())
|
|
3647
3681
|
if (typeof hole === "function" && read(hole) === name)
|
|
3648
3682
|
return hole;
|
|
@@ -3676,10 +3710,10 @@ var StandaloneArtifact = class {
|
|
|
3676
3710
|
}
|
|
3677
3711
|
receiverOf(value, id, label) {
|
|
3678
3712
|
if (!this.isComparedId(id))
|
|
3679
|
-
|
|
3680
|
-
const kind =
|
|
3713
|
+
throwInternalError(`Comparing ${label}, whose id the scan didn't read`);
|
|
3714
|
+
const kind = hasArkKind(value, "root") ? "" : `, "${kindNameOf(value)}"`;
|
|
3681
3715
|
const args = `${writeId(id)}${this.labelArg(label, kind)}`;
|
|
3682
|
-
const name = `${receiverPrefix}${
|
|
3716
|
+
const name = `${receiverPrefix}${hashOf(`runtime.holesOf(holder, ${args})`)}`;
|
|
3683
3717
|
this.importName(this.share(
|
|
3684
3718
|
name,
|
|
3685
3719
|
// a hoisted receiver is declared, so an import cycle can call it early
|
|
@@ -3692,17 +3726,17 @@ var StandaloneArtifact = class {
|
|
|
3692
3726
|
let label = root;
|
|
3693
3727
|
for (const k of path) {
|
|
3694
3728
|
if (typeof k === "symbol") {
|
|
3695
|
-
return
|
|
3729
|
+
return throwParseError(writeUnprecompilableMessage(`the symbol key of \`${label}\``));
|
|
3696
3730
|
}
|
|
3697
3731
|
expression += `[${JSON.stringify(k)}]`;
|
|
3698
|
-
label =
|
|
3732
|
+
label = appendStringifiedKey(label, k);
|
|
3699
3733
|
}
|
|
3700
3734
|
label = `\`${label}\``;
|
|
3701
|
-
if (
|
|
3735
|
+
if (hasArkKind(value, "root") || hasArkKind(value, "module") || hasArkKind(value, "scope") || hasArkKind(value, "generic")) {
|
|
3702
3736
|
const [id, keyed] = keyOf(value);
|
|
3703
3737
|
const allHoles = keyed.filter((hole) => this.cellOf(hole)?.text === void 0);
|
|
3704
3738
|
const holes = this.heldOf(allHoles);
|
|
3705
|
-
const isType =
|
|
3739
|
+
const isType = hasArkKind(value, "root");
|
|
3706
3740
|
const holesName = `holes${this.checks.length}`;
|
|
3707
3741
|
if (holes.length)
|
|
3708
3742
|
this.holesByName.set(holesName, holes);
|
|
@@ -3725,23 +3759,23 @@ var StandaloneArtifact = class {
|
|
|
3725
3759
|
this.checks.push(`runtime.checkFunction(${expression}${this.labelArg(label)})`);
|
|
3726
3760
|
return;
|
|
3727
3761
|
}
|
|
3728
|
-
if (typeof value === "function" &&
|
|
3762
|
+
if (typeof value === "function" && functionNameOf(value).includes(holeNameMarker)) {
|
|
3729
3763
|
if (this.receiveHole(value, expression, label))
|
|
3730
3764
|
checked.push([value, "function", expression]);
|
|
3731
3765
|
return;
|
|
3732
3766
|
}
|
|
3733
|
-
if (!
|
|
3767
|
+
if (!hasDomain(value, "object")) {
|
|
3734
3768
|
if (typeof value === "symbol") {
|
|
3735
|
-
|
|
3769
|
+
throwParseError(writeUnprecompilableMessage(`${printable(value)} read from ${label}`));
|
|
3736
3770
|
}
|
|
3737
3771
|
this.checks.push(`runtime.checkInput(${expression}, ${this.emit(value)}${this.labelArg(label)})`);
|
|
3738
3772
|
return;
|
|
3739
3773
|
}
|
|
3740
3774
|
if (isStandardSchema(value)) {
|
|
3741
|
-
|
|
3775
|
+
throwParseError(writeUnprecompilableMessage(`the Standard Schema ${label}`));
|
|
3742
3776
|
}
|
|
3743
|
-
if (
|
|
3744
|
-
|
|
3777
|
+
if (arkKindOf(value) !== void 0 || !(isPlainLiteral(value) || isDateObject(value) || isRegExpObject(value))) {
|
|
3778
|
+
throwParseError(writeUnprecompilableMessage(`${printable(value)} read from ${label}`));
|
|
3745
3779
|
}
|
|
3746
3780
|
if (!this.baking.checksTypes && isDigestible(value)) {
|
|
3747
3781
|
this.checks.push(`runtime.checkDigest(${expression}, ${JSON.stringify(digestOf(value))}${this.labelArg(label)})`);
|
|
@@ -3751,9 +3785,9 @@ var StandaloneArtifact = class {
|
|
|
3751
3785
|
if (!isPlainLiteral(value))
|
|
3752
3786
|
return;
|
|
3753
3787
|
for (const k of Reflect.ownKeys(value)) {
|
|
3754
|
-
if (
|
|
3788
|
+
if (isArray(value) && k === "length")
|
|
3755
3789
|
continue;
|
|
3756
|
-
const key =
|
|
3790
|
+
const key = isArray(value) ? Number(k) : k;
|
|
3757
3791
|
this.compareInput(param, [...path, key], Reflect.get(value, key), root, checked, isWritable, mayBeUnset);
|
|
3758
3792
|
}
|
|
3759
3793
|
}
|
|
@@ -3764,18 +3798,18 @@ var StandaloneArtifact = class {
|
|
|
3764
3798
|
i++;
|
|
3765
3799
|
const name = (
|
|
3766
3800
|
// past a long hash's prefix, a digest of all of its JSON orders it
|
|
3767
|
-
i >= hashedPrefixLength && !(l.hash.endsWith("}") && r.hash.endsWith("}")) ? holeNameIn(l.json) ?? holeNameIn(r.json) : [l.hash, r.hash].map((hash) => registeredNameAt(hash, i)).find((name2) => name2?.includes(
|
|
3801
|
+
i >= hashedPrefixLength && !(l.hash.endsWith("}") && r.hash.endsWith("}")) ? holeNameIn(l.json) ?? holeNameIn(r.json) : [l.hash, r.hash].map((hash) => registeredNameAt(hash, i)).find((name2) => name2?.includes(holeNameMarker))
|
|
3768
3802
|
);
|
|
3769
3803
|
if (!name)
|
|
3770
3804
|
return;
|
|
3771
3805
|
const hole = this.holeNamed(name, nameOf) ?? name;
|
|
3772
|
-
|
|
3806
|
+
throwParseError(writeUnprecompilableMessage(`an order that depends on the name of ${this.holeLabels.get(hole) ?? hole}`));
|
|
3773
3807
|
}
|
|
3774
3808
|
get roots() {
|
|
3775
3809
|
return [...this.validatorNames.keys()];
|
|
3776
3810
|
}
|
|
3777
3811
|
get readsOnlyAllows() {
|
|
3778
|
-
return !this.baking.called && !this.baking.members.has("assert") && !this.baking.members.has("~standard");
|
|
3812
|
+
return !this.baking.called && !this.baking.members.has("assert") && !this.baking.members.has("~standard") && !this.baking.members.has("withContext");
|
|
3779
3813
|
}
|
|
3780
3814
|
variantOf(root) {
|
|
3781
3815
|
const variant = (writesInPlace(root, this.baking.mutatesInput) ? 1 : this.baking.detailsErrors && this.baking.shortest ? 2 : 0) + 3 * +this.baking.firstIssue + 6 * +this.baking.shortest;
|
|
@@ -3847,18 +3881,18 @@ var StandaloneArtifact = class {
|
|
|
3847
3881
|
];
|
|
3848
3882
|
}
|
|
3849
3883
|
collectExport(value, path) {
|
|
3850
|
-
if (
|
|
3884
|
+
if (hasArkKind(value, "root"))
|
|
3851
3885
|
return this.collectType(value);
|
|
3852
|
-
if (
|
|
3886
|
+
if (hasArkKind(value, "scope") || hasArkKind(value, "generic"))
|
|
3853
3887
|
return;
|
|
3854
3888
|
if (isTypedFn(value)) {
|
|
3855
3889
|
this.collectType(value.params);
|
|
3856
3890
|
return this.collectType(value.returns);
|
|
3857
3891
|
}
|
|
3858
|
-
if (!
|
|
3859
|
-
return
|
|
3892
|
+
if (!hasArkKind(value, "module"))
|
|
3893
|
+
return throwParseError(writeUnprecompilableMessage(`the export ${path}`));
|
|
3860
3894
|
for (const [k, entry] of Object.entries(value))
|
|
3861
|
-
this.collectExport(entry,
|
|
3895
|
+
this.collectExport(entry, appendStringifiedKey(path, k));
|
|
3862
3896
|
}
|
|
3863
3897
|
collectType(root) {
|
|
3864
3898
|
if (this.validatorNames.has(root))
|
|
@@ -3871,10 +3905,10 @@ var StandaloneArtifact = class {
|
|
|
3871
3905
|
const typeCount = this.validatorNames.size;
|
|
3872
3906
|
const visited = /* @__PURE__ */ new Set();
|
|
3873
3907
|
const collect = (value) => {
|
|
3874
|
-
if (!
|
|
3908
|
+
if (!hasDomain(value, "object") || visited.has(value))
|
|
3875
3909
|
return;
|
|
3876
3910
|
visited.add(value);
|
|
3877
|
-
if (
|
|
3911
|
+
if (isNode(value)) {
|
|
3878
3912
|
if (value.isRoot())
|
|
3879
3913
|
this.collectType(value);
|
|
3880
3914
|
} else if (isPlainLiteral(value))
|
|
@@ -3896,10 +3930,11 @@ var StandaloneArtifact = class {
|
|
|
3896
3930
|
};
|
|
3897
3931
|
for (const node of this.writtenSelected(holdsDefaults)) {
|
|
3898
3932
|
if (node.is("optional") && node.defMorph)
|
|
3899
|
-
collect(node.
|
|
3900
|
-
else if (node.is("sequence"))
|
|
3933
|
+
collect(node.requiredValue);
|
|
3934
|
+
else if (node.is("sequence")) {
|
|
3901
3935
|
for (const [value] of node.defaultables ?? [])
|
|
3902
|
-
collect(value);
|
|
3936
|
+
collect(node.requiredOf(value));
|
|
3937
|
+
}
|
|
3903
3938
|
}
|
|
3904
3939
|
return this.validatorNames.size > typeCount;
|
|
3905
3940
|
}
|
|
@@ -3919,7 +3954,7 @@ var StandaloneArtifact = class {
|
|
|
3919
3954
|
if (!this.roots.length || this.baking.defers)
|
|
3920
3955
|
return;
|
|
3921
3956
|
this.writeSharedUnits();
|
|
3922
|
-
const names = Object.values(this.exports).map((value) =>
|
|
3957
|
+
const names = Object.values(this.exports).map((value) => hasArkKind(value, "root") ? this.readValidator(value) : void 0);
|
|
3923
3958
|
this.writeBody();
|
|
3924
3959
|
if (this.writtenValidators.size !== names.length || this.declarations.statements.length || this.sharedWriters.size || this.localUnits.length || this.links.length || this.defaults.length || this.modules.length || this.fills.length)
|
|
3925
3960
|
return;
|
|
@@ -3993,7 +4028,7 @@ return ${attributes}
|
|
|
3993
4028
|
}
|
|
3994
4029
|
get internsAcrossModules() {
|
|
3995
4030
|
const type2 = this.factory.type;
|
|
3996
|
-
return
|
|
4031
|
+
return hasArkKind(type2, "root") && this.heldOf(keyOf(type2)[1]).length > 0 && this.internNameOf(type2) !== void 0;
|
|
3997
4032
|
}
|
|
3998
4033
|
internNameOf(root) {
|
|
3999
4034
|
const { interned: interned2 } = this.baking;
|
|
@@ -4007,7 +4042,7 @@ return ${attributes}
|
|
|
4007
4042
|
if (named === void 0)
|
|
4008
4043
|
return;
|
|
4009
4044
|
const { called, readsAllows, piped: piped2 } = form.reads;
|
|
4010
|
-
return
|
|
4045
|
+
return hashOf(JSON.stringify([
|
|
4011
4046
|
named,
|
|
4012
4047
|
// each module picks what's smallest for what it holds, and each
|
|
4013
4048
|
// site what it's optimized for, and a validator behaves alike
|
|
@@ -4075,9 +4110,9 @@ return ${attributes}
|
|
|
4075
4110
|
const bake = (root, read) => `runtime.bakeInto(${read}, { ${this.emitIntrospection(root, new Set(members)).join(", ")} })`;
|
|
4076
4111
|
const bakeEach = (namespace, read) => Object.entries(namespace).flatMap(([name, value]) => {
|
|
4077
4112
|
const at = `${read}[${JSON.stringify(name)}]`;
|
|
4078
|
-
return
|
|
4113
|
+
return hasArkKind(value, "root") ? [bake(value, at)] : bakeEach(value, at);
|
|
4079
4114
|
});
|
|
4080
|
-
const [param, baked] =
|
|
4115
|
+
const [param, baked] = hasArkKind(bakes, "root") ? ["validator", `return ${bake(bakes, "validator")}`] : [
|
|
4081
4116
|
"namespace",
|
|
4082
4117
|
`// a cycle may load it before the module exporting them
|
|
4083
4118
|
try {
|
|
@@ -4107,7 +4142,7 @@ return namespace`
|
|
|
4107
4142
|
const input = node.in;
|
|
4108
4143
|
const [inputId, inputHoles] = traversalKeyOf(input);
|
|
4109
4144
|
const [valueId, valueHoles] = encodeKey(defaultValue, void 0, "value");
|
|
4110
|
-
const defaultKey = `[${JSON.stringify(
|
|
4145
|
+
const defaultKey = `[${JSON.stringify(hashOf(`${inputId} ${valueId}`))}, [${this.emitAll([...inputHoles, ...valueHoles])}]]`;
|
|
4111
4146
|
return {
|
|
4112
4147
|
check: `runtime.checkDefault(${this.readByRuntime(input)}, ${this.emit(defaultValue)}, ${key === null ? "null" : this.emit(key)}, ${defaultKey})`,
|
|
4113
4148
|
key: defaultKey
|
|
@@ -4150,7 +4185,7 @@ return namespace`
|
|
|
4150
4185
|
unit: unit2,
|
|
4151
4186
|
returned,
|
|
4152
4187
|
read: namesReadBy(unit2, returned),
|
|
4153
|
-
own: unit2.roots.filter((root) => unit2.refs.some((ref) =>
|
|
4188
|
+
own: unit2.roots.filter((root) => unit2.refs.some((ref) => isNode(ref) && unit2.names[ref.id] === unit2.names[root.id])),
|
|
4154
4189
|
params: [],
|
|
4155
4190
|
args: [],
|
|
4156
4191
|
imports: {},
|
|
@@ -4220,7 +4255,7 @@ return namespace`
|
|
|
4220
4255
|
this.defersCellReads = false;
|
|
4221
4256
|
if (this.readsCell) {
|
|
4222
4257
|
if (statements.length !== declared) {
|
|
4223
|
-
|
|
4258
|
+
throwInternalError(`Unexpected declaration of what reads a cell in ${unit2.name}`);
|
|
4224
4259
|
}
|
|
4225
4260
|
writing.cellReads[name] = `(${emitted})`;
|
|
4226
4261
|
this.readsCell = readsCell;
|
|
@@ -4240,7 +4275,7 @@ return namespace`
|
|
|
4240
4275
|
this.importName("arktype/runtime", `${exported} as ${name}`);
|
|
4241
4276
|
return [];
|
|
4242
4277
|
}
|
|
4243
|
-
if (
|
|
4278
|
+
if (hasDomain(value, "object") && isRegExpObject(value) && statements.length === declared + 1) {
|
|
4244
4279
|
statements[declared] = `const ${name}${statements[declared].slice(`const ${emitted}`.length)}`;
|
|
4245
4280
|
this.declarations.namesByValue.set(value, name);
|
|
4246
4281
|
return [];
|
|
@@ -4378,7 +4413,7 @@ return namespace`
|
|
|
4378
4413
|
...descriptions.map((_, i) => `d${i}`)
|
|
4379
4414
|
];
|
|
4380
4415
|
args.push(...descriptions);
|
|
4381
|
-
const name = `template${
|
|
4416
|
+
const name = `template${hashOf(`${named} ${shared}`)}`;
|
|
4382
4417
|
this.importName(this.share(name, writeFunction(this.baking, name, named.join(", "), shared), {}, shared.includes("runtime.")), name);
|
|
4383
4418
|
return `${name}(${args.join(", ")})`;
|
|
4384
4419
|
}
|
|
@@ -4483,7 +4518,7 @@ return namespace`
|
|
|
4483
4518
|
}
|
|
4484
4519
|
// closed over what it's passed, so every Type reading a unit shares its code
|
|
4485
4520
|
shareUnitFunction(params, body) {
|
|
4486
|
-
const name = `local${
|
|
4521
|
+
const name = `local${hashOf(`${params}
|
|
4487
4522
|
${body}`)}`;
|
|
4488
4523
|
this.importName(this.share(name, writeFunction(this.baking, name, params, body, false), {}, body.includes("runtime.")), name);
|
|
4489
4524
|
return name;
|
|
@@ -4712,7 +4747,7 @@ ${closer}`;
|
|
|
4712
4747
|
}
|
|
4713
4748
|
creatorOf(form, applier, makes) {
|
|
4714
4749
|
const [params, body] = creatorSourceOf(this.baking, form, applier, makes);
|
|
4715
|
-
const name = `create${
|
|
4750
|
+
const name = `create${hashOf(`${params}
|
|
4716
4751
|
${body}`)}`;
|
|
4717
4752
|
this.importName(this.share(name, writeFunction(this.baking, name, params, body), this.failureImports(applier?.failure)), name);
|
|
4718
4753
|
return name;
|
|
@@ -4754,9 +4789,10 @@ ${body}`)}`;
|
|
|
4754
4789
|
const standard = bakes("~standard.jsonSchema") ? ["input", "output"].map((io) => supportedJsonSchemaTargets.map((target) => writerOf(() => root["~standard"].jsonSchema[io]({ target })))) : [];
|
|
4755
4790
|
const written = bakes("toJsonSchema") && writerOf(() => root.toJsonSchema());
|
|
4756
4791
|
const bakedTexts = new Set([written || [], ...standard].flat().map(({ text }) => text));
|
|
4792
|
+
const bakesEachTarget = this.baking.members.has("toJsonSchema");
|
|
4757
4793
|
const targets = written ? supportedJsonSchemaTargets.map((target) => {
|
|
4758
|
-
const
|
|
4759
|
-
return bakedTexts.has(text) ?
|
|
4794
|
+
const writer = writerOf(() => root.toJsonSchema({ target }));
|
|
4795
|
+
return bakesEachTarget || bakedTexts.has(writer.text) ? writer : void 0;
|
|
4760
4796
|
}) : [];
|
|
4761
4797
|
const ignoresFallback = written && this.writesWithoutFallback(root);
|
|
4762
4798
|
const replays = written && !ignoresFallback && (bakes("~standard.jsonSchema") || this.baking.members.has("toJsonSchema")) ? this.baked("toJsonSchema", () => [
|
|
@@ -4769,7 +4805,12 @@ ${body}`)}`;
|
|
|
4769
4805
|
if (written) {
|
|
4770
4806
|
this.baked("toJsonSchema", () => {
|
|
4771
4807
|
const writtenName = declare(written);
|
|
4772
|
-
const byTarget = targets.map((
|
|
4808
|
+
const byTarget = targets.map((target) => {
|
|
4809
|
+
if (!target)
|
|
4810
|
+
return 0;
|
|
4811
|
+
const text = writerText(target.text);
|
|
4812
|
+
return this.jsonSchemaNameOf(text) ?? this.declareJsonSchema(text, target.values);
|
|
4813
|
+
});
|
|
4773
4814
|
const replayed = replays.map((replay) => replay ? declare(replay) : 0);
|
|
4774
4815
|
members.push(replayed.some(Boolean) ? `toJsonSchema: runtime.replayedJsonSchema(${writtenName}, [${byTarget.join(", ")}], [${replayed.join(", ")}])` : `toJsonSchema: runtime.bakedJsonSchema(${writtenName}, [${byTarget.join(", ")}]${ignoresFallback ? ", 1" : ""})`);
|
|
4775
4816
|
});
|
|
@@ -4795,7 +4836,7 @@ ${body}`)}`;
|
|
|
4795
4836
|
const lengths = this.bakedLengths;
|
|
4796
4837
|
this.bakedLengths = {};
|
|
4797
4838
|
if (totalBaked(lengths) > this.baking.bakedLimit)
|
|
4798
|
-
|
|
4839
|
+
throwParseError(writeBakedLimitMessage(lengths, this.baking.bakedLimit));
|
|
4799
4840
|
}
|
|
4800
4841
|
countBaked(text) {
|
|
4801
4842
|
if (this.bakingMember === void 0)
|
|
@@ -4861,7 +4902,7 @@ ${body}`)}`;
|
|
|
4861
4902
|
return writer.readIn(name);
|
|
4862
4903
|
}));
|
|
4863
4904
|
return part.module = {
|
|
4864
|
-
name: `${writer.prefix}${
|
|
4905
|
+
name: `${writer.prefix}${hashOf(value)}`,
|
|
4865
4906
|
value,
|
|
4866
4907
|
imports,
|
|
4867
4908
|
held
|
|
@@ -4908,7 +4949,7 @@ ${body}`)}`;
|
|
|
4908
4949
|
}
|
|
4909
4950
|
// a site written once for every unit reading it
|
|
4910
4951
|
readSite(emitted) {
|
|
4911
|
-
const name = `site${
|
|
4952
|
+
const name = `site${hashOf(emitted)}`;
|
|
4912
4953
|
const value = emitted[0] === "{" ? `(${emitted})` : emitted;
|
|
4913
4954
|
this.importName(this.share(name, writeValue(this.baking.hoisted, name, value)), name);
|
|
4914
4955
|
return this.readValue(name);
|
|
@@ -4932,7 +4973,7 @@ ${body}`)}`;
|
|
|
4932
4973
|
assertBakeableJsonSchema(root);
|
|
4933
4974
|
trace = this.baking.write(() => traceFallbacks(root, (fallback, writers) => write({ fallback, [unionJsonSchemaWritersKey]: writers })));
|
|
4934
4975
|
} catch (e) {
|
|
4935
|
-
if (e instanceof
|
|
4976
|
+
if (e instanceof ParseError)
|
|
4936
4977
|
return;
|
|
4937
4978
|
throw e;
|
|
4938
4979
|
}
|
|
@@ -4943,7 +4984,7 @@ ${body}`)}`;
|
|
|
4943
4984
|
try {
|
|
4944
4985
|
replay = this.replayOf(trace, root, write, values, parts);
|
|
4945
4986
|
} catch (e) {
|
|
4946
|
-
if (e instanceof
|
|
4987
|
+
if (e instanceof ParseError)
|
|
4947
4988
|
return;
|
|
4948
4989
|
throw e;
|
|
4949
4990
|
}
|
|
@@ -4957,7 +4998,7 @@ ${body}`)}`;
|
|
|
4957
4998
|
firstCalls.set(step.code, step.call);
|
|
4958
4999
|
}
|
|
4959
5000
|
return writeReplay(trace, (value) => this.writeData(value, { values, parts }), (code, call) => {
|
|
4960
|
-
if (configured[code] !==
|
|
5001
|
+
if (configured[code] !== ToJsonSchema.defaultConfig.fallback[code])
|
|
4961
5002
|
return `runtime.configuredFallbackOf(${JSON.stringify(code)})`;
|
|
4962
5003
|
if (call === void 0 || firstCalls.get(code) !== call)
|
|
4963
5004
|
return;
|
|
@@ -4967,7 +5008,7 @@ ${body}`)}`;
|
|
|
4967
5008
|
[unionJsonSchemaWritersKey]: writers
|
|
4968
5009
|
}), true);
|
|
4969
5010
|
} catch (e) {
|
|
4970
|
-
if (!(e instanceof
|
|
5011
|
+
if (!(e instanceof ToJsonSchema.Error))
|
|
4971
5012
|
throw e;
|
|
4972
5013
|
const header = e.message.slice(0, e.message.indexOf("\n") + 1);
|
|
4973
5014
|
return this.declareJsonSchema(`runtime.fallbackThrower(${JSON.stringify(code)}, ${this.emitString(header)})`, []);
|
|
@@ -5023,30 +5064,30 @@ ${body}`)}`;
|
|
|
5023
5064
|
try {
|
|
5024
5065
|
schema = isRead ? writeOnce() : this.baking.write(writeOnce);
|
|
5025
5066
|
} catch (e) {
|
|
5026
|
-
if (e instanceof
|
|
5067
|
+
if (e instanceof ToJsonSchema.Error)
|
|
5027
5068
|
return `runtime.throwJsonSchemaError(${JSON.stringify(e.code)}, ${this.emitString(e.message)}, ${this.writeData(e.context, { values })})`;
|
|
5028
|
-
if (e === thrown && e instanceof
|
|
5069
|
+
if (e === thrown && e instanceof ParseError)
|
|
5029
5070
|
return `runtime.throwParseError(${this.emitString(e.message)})`;
|
|
5030
|
-
if (e instanceof
|
|
5071
|
+
if (e instanceof ParseError)
|
|
5031
5072
|
throw e;
|
|
5032
|
-
|
|
5073
|
+
throwParseError(`${writeUnprecompilableMessage("a JSON Schema whose writing throws")}: ${String(e)}`);
|
|
5033
5074
|
}
|
|
5034
5075
|
return `(${this.writeData(schema, { parts })})`;
|
|
5035
5076
|
} catch (e) {
|
|
5036
|
-
if (isRead || !(e instanceof
|
|
5077
|
+
if (isRead || !(e instanceof ParseError))
|
|
5037
5078
|
throw e;
|
|
5038
5079
|
return `runtime.throwUnbaked(${JSON.stringify(e.message)})`;
|
|
5039
5080
|
}
|
|
5040
5081
|
}
|
|
5041
5082
|
writeData(value, opts = {}) {
|
|
5042
|
-
if (opts.values && (typeof value === "function" || typeof value === "symbol" || typeof value === "bigint" ||
|
|
5083
|
+
if (opts.values && (typeof value === "function" || typeof value === "symbol" || typeof value === "bigint" || hasDomain(value, "object") && isDateObject(value))) {
|
|
5043
5084
|
opts.values.push(value);
|
|
5044
5085
|
const text2 = this.emit(value);
|
|
5045
5086
|
return opts.parts ? opts.parts.add(text2, void 0, true) : text2;
|
|
5046
5087
|
}
|
|
5047
5088
|
if (typeof value === "string") {
|
|
5048
5089
|
const text2 = this.emitString(value);
|
|
5049
|
-
return opts.parts && value.includes(
|
|
5090
|
+
return opts.parts && value.includes(holeNameMarker) ? opts.parts.add(text2, void 0, true) : text2;
|
|
5050
5091
|
}
|
|
5051
5092
|
if (value === void 0)
|
|
5052
5093
|
return "void 0";
|
|
@@ -5055,10 +5096,10 @@ ${body}`)}`;
|
|
|
5055
5096
|
const written = opts.parts?.writtenAs(value);
|
|
5056
5097
|
if (written)
|
|
5057
5098
|
return written;
|
|
5058
|
-
const prototype =
|
|
5099
|
+
const prototype = hasDomain(value, "object") && prototypeOf(value);
|
|
5059
5100
|
const isPlainArray = prototype === Array.prototype && Array.isArray(value);
|
|
5060
5101
|
if (!isPlainArray && prototype !== Object.prototype && prototype !== null || Object.getOwnPropertySymbols(value).length) {
|
|
5061
|
-
return
|
|
5102
|
+
return throwParseError(writeUnprecompilableMessage(`introspection holding ${prototype ? `an instance of ${constructorNameOf(value) || "an anonymous class"}` : printable(value)}`));
|
|
5062
5103
|
}
|
|
5063
5104
|
let text;
|
|
5064
5105
|
if (isPlainArray)
|
|
@@ -5078,11 +5119,11 @@ ${body}`)}`;
|
|
|
5078
5119
|
const { asValidator, readsAllows, unconfigured, throws } = opts;
|
|
5079
5120
|
const checks = isChecker(root, this.variantOf(root));
|
|
5080
5121
|
const sitesRejections = checks && this.baking.detailsErrors && !root.hasAlias;
|
|
5081
|
-
const callbacks = declares(root, (node) => node.is("morph") || node.is("predicate") && !raisesNothing(node.predicate) && !(sitesRejections &&
|
|
5122
|
+
const callbacks = declares(root, (node) => node.is("morph") || node.is("predicate") && !raisesNothing(node.predicate) && !(sitesRejections && testsOrRejects.has(node.predicate)));
|
|
5082
5123
|
if (!this.baking.detailsErrors) {
|
|
5083
5124
|
return this.emitUndetailedApply(root, callbacks ? "Traversal" : "InternalTraversal", opts);
|
|
5084
5125
|
}
|
|
5085
|
-
const reportsIssues = !root.hasAlias && !root.hasMorph && !callbacks && !declares(root, (node) => node.is("union") && !node.discriminant && !
|
|
5126
|
+
const reportsIssues = !root.hasAlias && !root.hasMorph && !callbacks && !declares(root, (node) => node.is("union") && !node.discriminant && !isDecidedByAllows(node)) && // errors count their issues, and hold no branches
|
|
5086
5127
|
!this.unitsOf(root).some((unit2) => unit2.members.some(([, source]) => source.includes("ctx.errN") || source.includes("ctx.pushBr")));
|
|
5087
5128
|
if (reportsIssues)
|
|
5088
5129
|
assertReportsIssues(this.unitsOf(root));
|
|
@@ -5264,7 +5305,7 @@ ${body}`)}`;
|
|
|
5264
5305
|
return `((${params}) => {
|
|
5265
5306
|
${body}
|
|
5266
5307
|
})`;
|
|
5267
|
-
const name = `apply${
|
|
5308
|
+
const name = `apply${hashOf(`${params}
|
|
5268
5309
|
${body}${this.baking.shortest || args === void 0 ? "" : `
|
|
5269
5310
|
${args}`}`)}`;
|
|
5270
5311
|
return this.read(this.share(name, writeFunction(this.baking, name, params, body), this.failureImports(failure)), name);
|
|
@@ -5305,14 +5346,14 @@ ${args}`}`)}`;
|
|
|
5305
5346
|
}
|
|
5306
5347
|
// shared so a factory's check and the validator use one module
|
|
5307
5348
|
emitExpression(root) {
|
|
5308
|
-
if (root.expression.includes(
|
|
5349
|
+
if (root.expression.includes(holeNameMarker))
|
|
5309
5350
|
return this.emitString(root.expression);
|
|
5310
5351
|
const name = this.stringModuleOf(root, "expression");
|
|
5311
5352
|
return `${this.read(this.specifierOf(name), name)}()`;
|
|
5312
5353
|
}
|
|
5313
5354
|
// composed from referenced roots' modules where possible
|
|
5314
5355
|
emitDescription(root) {
|
|
5315
|
-
if (root.description.includes(
|
|
5356
|
+
if (root.description.includes(holeNameMarker))
|
|
5316
5357
|
return this.emitString(root.description);
|
|
5317
5358
|
const parts = partsOf(root, "description");
|
|
5318
5359
|
if (parts.every((part) => typeof part === "string"))
|
|
@@ -5332,7 +5373,7 @@ ${args}`}`)}`;
|
|
|
5332
5373
|
imports[this.specifierOf(name2)] = [name2];
|
|
5333
5374
|
return `${name2}()`;
|
|
5334
5375
|
}).join(" + ");
|
|
5335
|
-
const name = `${kind}${
|
|
5376
|
+
const name = `${kind}${hashOf(body)}`;
|
|
5336
5377
|
this.share(name, writeFunction(this.baking, name, "", ` return ${body}`), imports, false);
|
|
5337
5378
|
this.stringModules[kind].set(root, name);
|
|
5338
5379
|
return name;
|
|
@@ -5356,7 +5397,7 @@ ${args}`}`)}`;
|
|
|
5356
5397
|
continue;
|
|
5357
5398
|
}
|
|
5358
5399
|
const named = cell ? void 0 : this.holeNamed(placeholder);
|
|
5359
|
-
const hole = cell ? this.emitCell(cell) : this.holeExpressions.get(named) ??
|
|
5400
|
+
const hole = cell ? this.emitCell(cell) : this.holeExpressions.get(named) ?? throwParseError(writeUnprecompilableMessage(`the name of ${placeholder}, which the validator doesn't receive`));
|
|
5360
5401
|
parts.push(
|
|
5361
5402
|
// the registry names a function as arktype's json refers to it
|
|
5362
5403
|
registered ? `"$ark." + runtime.baseNameOf(${hole})` : predicate ? `runtime.describePredicate({ predicate: ${hole} })` : fn ? `"Function(" + runtime.baseNameOf(${hole}) + ")"` : this.classes.has(named) ? `runtime.functionNameOf(${hole})` : `runtime.baseNameOf(${hole})`
|
|
@@ -5369,9 +5410,9 @@ ${args}`}`)}`;
|
|
|
5369
5410
|
}
|
|
5370
5411
|
// resolving or instantiating needs arktype, so an empty object
|
|
5371
5412
|
exportOf(value) {
|
|
5372
|
-
if (
|
|
5413
|
+
if (hasArkKind(value, "root"))
|
|
5373
5414
|
return this.readValidator(value);
|
|
5374
|
-
if (
|
|
5415
|
+
if (hasArkKind(value, "scope") || hasArkKind(value, "generic")) {
|
|
5375
5416
|
const declared2 = this.declarations.namesByValue.get(value);
|
|
5376
5417
|
if (declared2)
|
|
5377
5418
|
return declared2;
|
|
@@ -5386,8 +5427,8 @@ ${args}`}`)}`;
|
|
|
5386
5427
|
this.modules.push(`const ${name2} = runtime.typedFn(${this.emit(value.raw)}, ${this.readByRuntime(value.params)}, ${this.readByRuntime(value.returns)})`);
|
|
5387
5428
|
return name2;
|
|
5388
5429
|
}
|
|
5389
|
-
if (!
|
|
5390
|
-
return
|
|
5430
|
+
if (!hasArkKind(value, "module"))
|
|
5431
|
+
return throwInternalError(`Unexpected export ${printable(value)}`);
|
|
5391
5432
|
const declared = this.moduleNames.get(value);
|
|
5392
5433
|
if (declared)
|
|
5393
5434
|
return declared;
|
|
@@ -5453,14 +5494,14 @@ ${args}`}`)}`;
|
|
|
5453
5494
|
writeShapeFlags(node, unit2) {
|
|
5454
5495
|
const entries = shapeFlags.flatMap((flag) => flag !== "allowsCtx" && node[flag] ? [`${flag}: true`] : []);
|
|
5455
5496
|
if (node.hasAlias) {
|
|
5456
|
-
entries.unshift(`id: ${JSON.stringify(unit2.names[node.id])}`, `trackedId: ${JSON.stringify(unit2.names[node.trackedId] ??
|
|
5497
|
+
entries.unshift(`id: ${JSON.stringify(unit2.names[node.id])}`, `trackedId: ${JSON.stringify(unit2.names[node.trackedId] ?? throwParseError(writeUnprecompilableMessage(`${node.expression}'s cycle`)))}`);
|
|
5457
5498
|
}
|
|
5458
5499
|
return `{ ${entries.join(", ")} }`;
|
|
5459
5500
|
}
|
|
5460
5501
|
writeShape(node, shape, unit2, traversals) {
|
|
5461
5502
|
const ids = node.hasAlias ? `
|
|
5462
5503
|
id: ${JSON.stringify(unit2.names[node.id])},
|
|
5463
|
-
trackedId: ${JSON.stringify(unit2.names[node.trackedId] ??
|
|
5504
|
+
trackedId: ${JSON.stringify(unit2.names[node.trackedId] ?? throwParseError(writeUnprecompilableMessage(`${node.expression}'s cycle`)))},` : "";
|
|
5464
5505
|
const flags = shapeFlags.flatMap((flag) => node[flag] ? [`
|
|
5465
5506
|
${flag}: true,`] : []);
|
|
5466
5507
|
const traverses = node.hasAlias || node.allowsCtx || node.checksCtx;
|
|
@@ -5490,8 +5531,8 @@ ${args}`}`)}`;
|
|
|
5490
5531
|
if (typeof value === "string")
|
|
5491
5532
|
return this.emitString(value);
|
|
5492
5533
|
if (typeof value === "symbol")
|
|
5493
|
-
return
|
|
5494
|
-
if (!
|
|
5534
|
+
return throwParseError(writeUnprecompilableMessage(printable(value)));
|
|
5535
|
+
if (!hasDomain(value, "object"))
|
|
5495
5536
|
return printablePrimitive(value);
|
|
5496
5537
|
const runtimePath = runtimePathsByValue.get(value);
|
|
5497
5538
|
if (runtimePath)
|
|
@@ -5502,19 +5543,19 @@ ${args}`}`)}`;
|
|
|
5502
5543
|
const defaulted = this.defaultsByMorph.get(value);
|
|
5503
5544
|
if (defaulted)
|
|
5504
5545
|
return this.emitDefault(value, ...defaulted);
|
|
5505
|
-
const made =
|
|
5546
|
+
const made = madeMorphs.get(value);
|
|
5506
5547
|
if (made) {
|
|
5507
5548
|
return this.declareConst(value, "made", `${this.emit(made[0])}(${this.emitAll(made[1])})`);
|
|
5508
5549
|
}
|
|
5509
5550
|
if (this.objectUnits.has(value)) {
|
|
5510
|
-
|
|
5551
|
+
throwParseError(writeUnprecompilableMessage(`the unit ${isNode(value) ? String(value) : printable(value)}`));
|
|
5511
5552
|
}
|
|
5512
|
-
if (
|
|
5513
|
-
return value.isRoot() ? this.shapeOf(value) :
|
|
5553
|
+
if (isNode(value)) {
|
|
5554
|
+
return value.isRoot() ? this.shapeOf(value) : throwParseError(writeUnprecompilableMessage(`${value.kind} ${value.expression}`));
|
|
5514
5555
|
}
|
|
5515
5556
|
if (typeof value === "function") {
|
|
5516
|
-
const name =
|
|
5517
|
-
return Reflect.get(globalThis, name) === value ? `globalThis[${JSON.stringify(name)}]` :
|
|
5557
|
+
const name = functionNameOf(value);
|
|
5558
|
+
return Reflect.get(globalThis, name) === value ? `globalThis[${JSON.stringify(name)}]` : throwParseError(writeUnprecompilableMessage(printable(value)));
|
|
5518
5559
|
}
|
|
5519
5560
|
if (failureSites.has(value))
|
|
5520
5561
|
return this.emitSite(value);
|
|
@@ -5523,16 +5564,16 @@ ${args}`}`)}`;
|
|
|
5523
5564
|
return this.declareConst(value, "keys", `runtime.freeze({ __proto__: null, ${keys.join(", ")} })`);
|
|
5524
5565
|
}
|
|
5525
5566
|
if (this.emitting.has(value))
|
|
5526
|
-
return
|
|
5527
|
-
if (
|
|
5567
|
+
return throwParseError(writeUnprecompilableMessage("a cyclic object"));
|
|
5568
|
+
if (isDateObject(value)) {
|
|
5528
5569
|
if (Reflect.ownKeys(value).length) {
|
|
5529
|
-
|
|
5570
|
+
throwParseError(writeUnprecompilableMessage("a Date with its own properties"));
|
|
5530
5571
|
}
|
|
5531
5572
|
return this.declareConst(value, "literal", `new Date(${value.getTime()})`);
|
|
5532
5573
|
}
|
|
5533
|
-
if (
|
|
5574
|
+
if (isRegExpObject(value)) {
|
|
5534
5575
|
if (Reflect.ownKeys(value).some((k) => k !== "lastIndex")) {
|
|
5535
|
-
|
|
5576
|
+
throwParseError(writeUnprecompilableMessage("a RegExp with its own properties"));
|
|
5536
5577
|
}
|
|
5537
5578
|
const regex = `/${value.source}/${value.flags}`;
|
|
5538
5579
|
if (this.patternInstances.has(value))
|
|
@@ -5545,14 +5586,14 @@ ${args}`}`)}`;
|
|
|
5545
5586
|
if (!Reflect.ownKeys(meta).length)
|
|
5546
5587
|
return "runtime.emptyMeta";
|
|
5547
5588
|
const literal = this.writeSharedLiteral(meta);
|
|
5548
|
-
return literal && this.readConstant(`meta${
|
|
5589
|
+
return literal && this.readConstant(`meta${hashOf(literal)}`, literal);
|
|
5549
5590
|
}
|
|
5550
5591
|
writeSharedLiteral(value) {
|
|
5551
5592
|
if (typeof value === "string")
|
|
5552
|
-
return value.includes(
|
|
5553
|
-
if (!
|
|
5593
|
+
return value.includes(holeNameMarker) ? void 0 : JSON.stringify(value);
|
|
5594
|
+
if (!hasDomain(value, "object"))
|
|
5554
5595
|
return typeof value === "symbol" ? void 0 : printablePrimitive(value);
|
|
5555
|
-
if (typeof value === "function" ||
|
|
5596
|
+
if (typeof value === "function" || isNode(value) || isDateObject(value) || isRegExpObject(value) || this.objectUnits.has(value) || this.emitting.has(value))
|
|
5556
5597
|
return;
|
|
5557
5598
|
let isShared = true;
|
|
5558
5599
|
const [literal] = this.writeLiteral(value, (element) => this.writeSharedLiteral(element) ?? (isShared = false, ""));
|
|
@@ -5569,7 +5610,7 @@ ${args}`}`)}`;
|
|
|
5569
5610
|
name = `default${this.defaults.length}`;
|
|
5570
5611
|
this.defaultNames.set(morph, name);
|
|
5571
5612
|
const flags = defaultedNodeKeys.filter((k) => value[k]).map((k) => `${k}: true`);
|
|
5572
|
-
const isThunkInput = typeof defaultValue === "function" &&
|
|
5613
|
+
const isThunkInput = typeof defaultValue === "function" && isThunk(defaultValue);
|
|
5573
5614
|
const validator = isThunkInput || value.alters || value.hasAlias ? this.readByRuntime(value) : this.readValidator(value);
|
|
5574
5615
|
this.defaults.push(`const ${name} = runtime.computeDefaultValueMorph(${this.emit(key)}, ${validator}, ${this.emit(defaultValue)}, {${flags.length ? ` ${flags.join(", ")} ` : ""}}${typeof defaultValue === "function" ? `, ${isThunkInput}` : ""})`);
|
|
5575
5616
|
return `(data, ctx) => ${name}(data, ctx)`;
|
|
@@ -5618,7 +5659,7 @@ ${args}`}`)}`;
|
|
|
5618
5659
|
${statements.join("\n")}
|
|
5619
5660
|
return ${written}
|
|
5620
5661
|
})()` : written;
|
|
5621
|
-
const name = `${prefix}${
|
|
5662
|
+
const name = `${prefix}${hashOf(expression)}`;
|
|
5622
5663
|
this.importName(this.share(name, writeValue(this.baking.hoisted, name, expression), scope.imports), name);
|
|
5623
5664
|
return this.readValue(name);
|
|
5624
5665
|
}
|
|
@@ -5651,15 +5692,15 @@ return ${written}
|
|
|
5651
5692
|
return writeSiteOf(value, (s) => this.emitString(s), "keySiteOf", missing);
|
|
5652
5693
|
}
|
|
5653
5694
|
}
|
|
5654
|
-
return `{ ${Object.entries(site).map(([k, v]) => `${k}: ${
|
|
5695
|
+
return `{ ${Object.entries(site).map(([k, v]) => `${k}: ${hasDomain(v, "object") ? this.emitSite(v) : this.emit(v)}`).join(", ")} }`;
|
|
5655
5696
|
}
|
|
5656
5697
|
emitLiteral(value) {
|
|
5657
5698
|
const [literal, elements] = this.writeLiteral(value);
|
|
5658
5699
|
if (!elements.some((element) => this.lateNames.has(element)))
|
|
5659
5700
|
return this.declareConst(value, "literal", `runtime.freeze(${literal})`);
|
|
5660
|
-
const prototype =
|
|
5701
|
+
const prototype = prototypeOf(value);
|
|
5661
5702
|
if (prototype === Object.prototype && Object.getOwnPropertyNames(value).includes("__proto__")) {
|
|
5662
|
-
|
|
5703
|
+
throwParseError(writeUnprecompilableMessage("a __proto__ key beside a Type"));
|
|
5663
5704
|
}
|
|
5664
5705
|
const name = this.declareConst(value, "literal", Array.isArray(value) ? "[]" : prototype === null ? "{ __proto__: null }" : "{}");
|
|
5665
5706
|
this.lateNames.add(name);
|
|
@@ -5667,26 +5708,26 @@ return ${written}
|
|
|
5667
5708
|
return name;
|
|
5668
5709
|
}
|
|
5669
5710
|
writeLiteral(value, emitElement = (element) => this.emitElement(element)) {
|
|
5670
|
-
const prototype =
|
|
5711
|
+
const prototype = prototypeOf(value);
|
|
5671
5712
|
const isPlainArray = prototype === Array.prototype && Array.isArray(value);
|
|
5672
5713
|
if (!isPlainArray && prototype !== Object.prototype && prototype !== null) {
|
|
5673
|
-
return
|
|
5714
|
+
return throwParseError(writeUnprecompilableMessage(`an instance of ${constructorNameOf(value) || "an anonymous class"}`));
|
|
5674
5715
|
}
|
|
5675
5716
|
const symbol = Object.getOwnPropertySymbols(value)[0];
|
|
5676
5717
|
if (symbol) {
|
|
5677
|
-
|
|
5718
|
+
throwParseError(writeUnprecompilableMessage(`the symbol key ${printable(symbol)}`));
|
|
5678
5719
|
}
|
|
5679
5720
|
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
5680
5721
|
const keys = Object.getOwnPropertyNames(value).filter((k) => !isPlainArray || k !== "length");
|
|
5681
5722
|
if (isPlainArray && (keys.length !== descriptors.length.value || keys.some((k, i) => k !== `${i}`))) {
|
|
5682
|
-
|
|
5723
|
+
throwParseError(writeUnprecompilableMessage("an array with holes or other properties"));
|
|
5683
5724
|
}
|
|
5684
5725
|
for (const k of keys) {
|
|
5685
5726
|
if (!("value" in descriptors[k])) {
|
|
5686
|
-
|
|
5727
|
+
throwParseError(writeUnprecompilableMessage(`the accessor ${JSON.stringify(k)}`));
|
|
5687
5728
|
}
|
|
5688
5729
|
if (!descriptors[k].enumerable) {
|
|
5689
|
-
|
|
5730
|
+
throwParseError(writeUnprecompilableMessage(`the non-enumerable property ${JSON.stringify(k)}`));
|
|
5690
5731
|
}
|
|
5691
5732
|
}
|
|
5692
5733
|
this.emitting.add(value);
|
|
@@ -5699,7 +5740,7 @@ return ${written}
|
|
|
5699
5740
|
return [literal, elements];
|
|
5700
5741
|
}
|
|
5701
5742
|
emitElement(value) {
|
|
5702
|
-
return
|
|
5743
|
+
return isNode(value) && value.isRoot() && !this.objectUnits.has(value) ? this.readValidator(value) ?? throwInternalError(`Unexpected Type ${value.expression} outside a meta`) : this.emit(value);
|
|
5703
5744
|
}
|
|
5704
5745
|
};
|
|
5705
5746
|
var shapeFlags = [
|
|
@@ -5719,7 +5760,7 @@ var uncountedJsonOf = function (json2) {
|
|
|
5719
5760
|
const uncounted = (json3) => {
|
|
5720
5761
|
if (typeof json3 === "string") {
|
|
5721
5762
|
const id = json3.slice(registryName.length + 1);
|
|
5722
|
-
if (!json3.startsWith(`${registryName}.`) || !$
|
|
5763
|
+
if (!json3.startsWith(`${registryName}.`) || !$ark.nodesById[id])
|
|
5723
5764
|
return json3.replace(countedReference, "$1");
|
|
5724
5765
|
let written = renumbered.get(id);
|
|
5725
5766
|
if (!written) {
|
|
@@ -5729,7 +5770,7 @@ var uncountedJsonOf = function (json2) {
|
|
|
5729
5770
|
}
|
|
5730
5771
|
return written;
|
|
5731
5772
|
}
|
|
5732
|
-
if (!
|
|
5773
|
+
if (!hasDomain(json3, "object"))
|
|
5733
5774
|
return json3;
|
|
5734
5775
|
let result = seen.get(json3);
|
|
5735
5776
|
if (!result) {
|
|
@@ -5798,7 +5839,7 @@ var writeArtifact = function (exports, opts, isModular) {
|
|
|
5798
5839
|
const canFold = (name, factory) => {
|
|
5799
5840
|
if (
|
|
5800
5841
|
// as unknown: narrowing to BaseRoot is too deep for TypeScript
|
|
5801
|
-
!
|
|
5842
|
+
!hasArkKind(factory.type, "root") || factory.defaultChecks?.length || // runtime.rekeyed creates a template's copies with runtime.createValidator
|
|
5802
5843
|
!isCreatedByRuntime(baking.members, baking) && heldOf(factory.type).length
|
|
5803
5844
|
)
|
|
5804
5845
|
return false;
|
|
@@ -5808,14 +5849,14 @@ var writeArtifact = function (exports, opts, isModular) {
|
|
|
5808
5849
|
trial.writeCreateBody(configured);
|
|
5809
5850
|
return !trial.readsCell;
|
|
5810
5851
|
} catch (e) {
|
|
5811
|
-
if (e instanceof
|
|
5852
|
+
if (e instanceof ParseError)
|
|
5812
5853
|
return false;
|
|
5813
5854
|
throw e;
|
|
5814
5855
|
}
|
|
5815
5856
|
};
|
|
5816
5857
|
let index = 0;
|
|
5817
5858
|
for (const [name, value] of Object.entries(exports)) {
|
|
5818
|
-
if (
|
|
5859
|
+
if (arkKindOf(value) !== void 0) {
|
|
5819
5860
|
types[name] = value;
|
|
5820
5861
|
continue;
|
|
5821
5862
|
}
|