arktype 3.0.0-beta.0 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -10
- package/out/attributes.d.ts +4 -2
- package/out/checkers.d.ts +37 -2
- package/out/{chunk-Z4F45ZTE.js → chunk-2U2AWCI3.js} +3 -3
- package/out/{chunk-5NJWD7CO.js → chunk-5U2ZMDNI.js} +215 -140
- package/out/{chunk-KJ3C5GTL.js → chunk-DLWCO4RV.js} +1 -1
- package/out/{chunk-H4VRNKMB.js → chunk-E3DZXEZK.js} +1 -1
- package/out/{chunk-EJZJUYPI.js → chunk-EVCML554.js} +2 -2
- package/out/{chunk-KI2MOYNT.js → chunk-GPNK5353.js} +184 -32
- package/out/{chunk-LUXERINN.js → chunk-RAZ3TXOE.js} +40 -38
- package/out/chunk-SWOOCAHN.js +4 -0
- package/out/{chunk-ARTS74PX.js → chunk-UETB6YE2.js} +1 -1
- package/out/{chunk-JHDPSG5Y.js → chunk-UK5UGFOX.js} +6 -6
- package/out/{chunk-WEPQK3AY.js → chunk-VV6YDN2D.js} +441 -145
- package/out/codecs.js +5 -5
- package/out/config.d.ts +6 -3
- package/out/i18n.d.ts +1 -1
- package/out/i18n.js +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +5 -5
- package/out/internal.d.ts +1 -0
- package/out/internal.js +11 -11
- package/out/island.js +2 -2
- package/out/islandDependency.js +11 -11
- package/out/keywords/functions.d.ts +24 -24
- package/out/keywords/keywords.d.ts +2 -2
- package/out/keywords/phrases.d.ts +23 -23
- package/out/keywords/ts.js +2 -2
- package/out/locale.d.ts +1 -1
- package/out/locales/de.js +1 -1
- package/out/locales/en.js +3 -3
- package/out/match.d.ts +5 -3
- package/out/mutatesInput.js +2 -2
- package/out/parser/definition.d.ts +54 -3
- package/out/parser/shift/operand/unenclosed.d.ts +3 -1
- package/out/parser/shift/operand/unresolvable.d.ts +68 -0
- package/out/parser/shift/operator/bounds.d.ts +4 -1
- package/out/runtime.d.ts +34 -25
- package/out/runtime.js +2 -2
- package/out/runtimeDevelopment.js +63 -4
- package/out/scope.d.ts +4 -4
- package/out/standalone/artifact.d.ts +4 -0
- package/out/standalone/baking.d.ts +8 -1
- package/out/standalone/sites.d.ts +6 -3
- package/out/standalone/values.d.ts +2 -0
- package/out/type.d.ts +42 -5
- package/package.json +49 -6
- package/skills/arktype/SKILL.md +211 -92
- package/skills/arktype/references/migrating.md +990 -255
- package/skills/arktype/references/precompile.md +8 -5
- package/out/chunk-EDEN5UWG.js +0 -4
|
@@ -8,8 +8,6 @@ import {
|
|
|
8
8
|
TransformErrors,
|
|
9
9
|
Traversal,
|
|
10
10
|
TraversalError,
|
|
11
|
-
UnreadArkErrors,
|
|
12
|
-
UnreadFirstIssues,
|
|
13
11
|
Validator,
|
|
14
12
|
addErrors,
|
|
15
13
|
addMorphErrs,
|
|
@@ -47,7 +45,9 @@ import {
|
|
|
47
45
|
callingRootApply,
|
|
48
46
|
canParseUrl,
|
|
49
47
|
check,
|
|
48
|
+
checkArity,
|
|
50
49
|
checkDefault,
|
|
50
|
+
checkDigest,
|
|
51
51
|
checkFacts,
|
|
52
52
|
checkFunction,
|
|
53
53
|
checkHeld,
|
|
@@ -57,6 +57,8 @@ import {
|
|
|
57
57
|
checkProgress,
|
|
58
58
|
checkerNode,
|
|
59
59
|
closedProps,
|
|
60
|
+
codeSiteOf,
|
|
61
|
+
codedIssue,
|
|
60
62
|
compiled,
|
|
61
63
|
computeDefaultValueMorph,
|
|
62
64
|
configure,
|
|
@@ -71,9 +73,11 @@ import {
|
|
|
71
73
|
deferred,
|
|
72
74
|
deletingProps,
|
|
73
75
|
describeCollapsibleDate,
|
|
76
|
+
describeDomains,
|
|
74
77
|
describePredicate,
|
|
75
78
|
describeShape,
|
|
76
79
|
describeValues,
|
|
80
|
+
digestOf,
|
|
77
81
|
disallowed,
|
|
78
82
|
discriminate,
|
|
79
83
|
discriminateOr,
|
|
@@ -97,11 +101,17 @@ import {
|
|
|
97
101
|
failingElementsOf,
|
|
98
102
|
failingProps,
|
|
99
103
|
failsAt,
|
|
104
|
+
failsAtKey,
|
|
100
105
|
failsAtPath,
|
|
101
106
|
failsBranches,
|
|
102
107
|
failsIn,
|
|
103
108
|
failsInBranches,
|
|
109
|
+
failsKey,
|
|
110
|
+
failsKeySite,
|
|
111
|
+
failsKeyWith,
|
|
104
112
|
failsListed,
|
|
113
|
+
failsSite,
|
|
114
|
+
failsWith,
|
|
105
115
|
fallbackThrower,
|
|
106
116
|
firstIssue,
|
|
107
117
|
fixConfig,
|
|
@@ -117,6 +127,7 @@ import {
|
|
|
117
127
|
integerCheck,
|
|
118
128
|
integerRange,
|
|
119
129
|
intern,
|
|
130
|
+
internIn,
|
|
120
131
|
internTable,
|
|
121
132
|
interned,
|
|
122
133
|
internedTable,
|
|
@@ -133,7 +144,6 @@ import {
|
|
|
133
144
|
jsTypeOfDescriptions,
|
|
134
145
|
keepOwn,
|
|
135
146
|
keySiteOf,
|
|
136
|
-
lacks,
|
|
137
147
|
lessThan,
|
|
138
148
|
liftArray,
|
|
139
149
|
listedIssue,
|
|
@@ -143,6 +153,7 @@ import {
|
|
|
143
153
|
mergeTransformed,
|
|
144
154
|
min,
|
|
145
155
|
minLength,
|
|
156
|
+
missingTextOf,
|
|
146
157
|
moreThan,
|
|
147
158
|
morphing,
|
|
148
159
|
narrowed,
|
|
@@ -150,6 +161,7 @@ import {
|
|
|
150
161
|
narrowedBy,
|
|
151
162
|
narrowedByEach,
|
|
152
163
|
narrowedInCtx,
|
|
164
|
+
narrowedRejecting,
|
|
153
165
|
narrowedWithCtx,
|
|
154
166
|
nullable,
|
|
155
167
|
nullableDescriptionOf,
|
|
@@ -167,17 +179,19 @@ import {
|
|
|
167
179
|
pipeTransformed,
|
|
168
180
|
piped,
|
|
169
181
|
pipedIntoUndetailed,
|
|
170
|
-
|
|
182
|
+
precompiledForArktype_3_0_0_beta_1,
|
|
171
183
|
printKind,
|
|
172
184
|
printable,
|
|
173
|
-
problemSiteOf,
|
|
174
185
|
props,
|
|
175
186
|
raisingTraversalOf,
|
|
176
187
|
readingCtx,
|
|
188
|
+
readingCtxNode,
|
|
177
189
|
receiverOf,
|
|
178
190
|
recordOf,
|
|
179
191
|
rejected,
|
|
192
|
+
rejecting,
|
|
180
193
|
rejects,
|
|
194
|
+
rejectsWith,
|
|
181
195
|
rekeyed,
|
|
182
196
|
replacingUndefined,
|
|
183
197
|
replayedJsonSchema,
|
|
@@ -185,10 +199,13 @@ import {
|
|
|
185
199
|
requiredSiteOf,
|
|
186
200
|
runtimeConfig,
|
|
187
201
|
runtimeScope,
|
|
202
|
+
saying,
|
|
203
|
+
sayingMissing,
|
|
188
204
|
setPrototypeOf,
|
|
189
205
|
silentCtx,
|
|
190
206
|
siteOf,
|
|
191
207
|
sited,
|
|
208
|
+
sitedProps,
|
|
192
209
|
standardResultOf,
|
|
193
210
|
stringCheck,
|
|
194
211
|
stringRange,
|
|
@@ -205,6 +222,7 @@ import {
|
|
|
205
222
|
transformedInApply,
|
|
206
223
|
transformingClosedProps,
|
|
207
224
|
transformingElementsOf,
|
|
225
|
+
transformingNarrowedAfter,
|
|
208
226
|
transformingProps,
|
|
209
227
|
transformsBranches,
|
|
210
228
|
transformsValid,
|
|
@@ -214,27 +232,29 @@ import {
|
|
|
214
232
|
union,
|
|
215
233
|
unit,
|
|
216
234
|
units,
|
|
235
|
+
unnamed,
|
|
217
236
|
unreadCallErrors,
|
|
218
237
|
unreadElements,
|
|
219
238
|
unreadErrors,
|
|
220
239
|
writeCreationMismatchMessage,
|
|
240
|
+
writeDigestMismatchMessage,
|
|
221
241
|
writeDomainActual,
|
|
222
242
|
writeIdentityMismatchMessage,
|
|
223
243
|
writeLengthActual,
|
|
244
|
+
writeMessage,
|
|
224
245
|
writeNotEqualActual,
|
|
225
246
|
writeNullableJsonSchema,
|
|
226
|
-
writeProblem,
|
|
227
247
|
writeProtoActual,
|
|
228
248
|
writeUnbakedMessage,
|
|
229
249
|
writeUnionJsonSchema,
|
|
230
250
|
writeUnitActual,
|
|
231
|
-
|
|
251
|
+
writeUnitMessage,
|
|
232
252
|
writtenBy,
|
|
233
253
|
writtenSiteOf
|
|
234
|
-
} from "./chunk-
|
|
254
|
+
} from "./chunk-5U2ZMDNI.js";
|
|
235
255
|
import {
|
|
236
256
|
keywords
|
|
237
|
-
} from "./chunk-
|
|
257
|
+
} from "./chunk-2U2AWCI3.js";
|
|
238
258
|
import {
|
|
239
259
|
InternalTypedFn
|
|
240
260
|
} from "./chunk-G45P2CLE.js";
|
|
@@ -267,9 +287,9 @@ import {
|
|
|
267
287
|
uppercaseString,
|
|
268
288
|
writeEpoch,
|
|
269
289
|
writeIsoDate,
|
|
270
|
-
|
|
290
|
+
writeJsonSyntaxErrorMessage,
|
|
271
291
|
writeUrl
|
|
272
|
-
} from "./chunk-
|
|
292
|
+
} from "./chunk-UK5UGFOX.js";
|
|
273
293
|
import {
|
|
274
294
|
__export
|
|
275
295
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -295,8 +315,6 @@ __export(runtimeExports_exports, {
|
|
|
295
315
|
TransformErrors: () => TransformErrors,
|
|
296
316
|
Traversal: () => Traversal,
|
|
297
317
|
TraversalError: () => TraversalError,
|
|
298
|
-
UnreadArkErrors: () => UnreadArkErrors,
|
|
299
|
-
UnreadFirstIssues: () => UnreadFirstIssues,
|
|
300
318
|
Validator: () => Validator,
|
|
301
319
|
addErrors: () => addErrors,
|
|
302
320
|
addMorphErrs: () => addMorphErrs,
|
|
@@ -335,7 +353,9 @@ __export(runtimeExports_exports, {
|
|
|
335
353
|
canParseUrl: () => canParseUrl,
|
|
336
354
|
capitalizeString: () => capitalizeString,
|
|
337
355
|
check: () => check,
|
|
356
|
+
checkArity: () => checkArity,
|
|
338
357
|
checkDefault: () => checkDefault,
|
|
358
|
+
checkDigest: () => checkDigest,
|
|
339
359
|
checkFacts: () => checkFacts,
|
|
340
360
|
checkFunction: () => checkFunction,
|
|
341
361
|
checkHeld: () => checkHeld,
|
|
@@ -345,6 +365,8 @@ __export(runtimeExports_exports, {
|
|
|
345
365
|
checkProgress: () => checkProgress,
|
|
346
366
|
checkerNode: () => checkerNode,
|
|
347
367
|
closedProps: () => closedProps,
|
|
368
|
+
codeSiteOf: () => codeSiteOf,
|
|
369
|
+
codedIssue: () => codedIssue,
|
|
348
370
|
compiled: () => compiled,
|
|
349
371
|
computeDefaultValueMorph: () => computeDefaultValueMorph,
|
|
350
372
|
configure: () => configure,
|
|
@@ -359,9 +381,11 @@ __export(runtimeExports_exports, {
|
|
|
359
381
|
deferred: () => deferred,
|
|
360
382
|
deletingProps: () => deletingProps,
|
|
361
383
|
describeCollapsibleDate: () => describeCollapsibleDate,
|
|
384
|
+
describeDomains: () => describeDomains,
|
|
362
385
|
describePredicate: () => describePredicate,
|
|
363
386
|
describeShape: () => describeShape,
|
|
364
387
|
describeValues: () => describeValues,
|
|
388
|
+
digestOf: () => digestOf,
|
|
365
389
|
disallowed: () => disallowed,
|
|
366
390
|
discriminate: () => discriminate,
|
|
367
391
|
discriminateOr: () => discriminateOr,
|
|
@@ -387,11 +411,17 @@ __export(runtimeExports_exports, {
|
|
|
387
411
|
failingElementsOf: () => failingElementsOf,
|
|
388
412
|
failingProps: () => failingProps,
|
|
389
413
|
failsAt: () => failsAt,
|
|
414
|
+
failsAtKey: () => failsAtKey,
|
|
390
415
|
failsAtPath: () => failsAtPath,
|
|
391
416
|
failsBranches: () => failsBranches,
|
|
392
417
|
failsIn: () => failsIn,
|
|
393
418
|
failsInBranches: () => failsInBranches,
|
|
419
|
+
failsKey: () => failsKey,
|
|
420
|
+
failsKeySite: () => failsKeySite,
|
|
421
|
+
failsKeyWith: () => failsKeyWith,
|
|
394
422
|
failsListed: () => failsListed,
|
|
423
|
+
failsSite: () => failsSite,
|
|
424
|
+
failsWith: () => failsWith,
|
|
395
425
|
fallbackThrower: () => fallbackThrower,
|
|
396
426
|
firstIssue: () => firstIssue,
|
|
397
427
|
fixConfig: () => fixConfig,
|
|
@@ -407,6 +437,7 @@ __export(runtimeExports_exports, {
|
|
|
407
437
|
integerCheck: () => integerCheck,
|
|
408
438
|
integerRange: () => integerRange,
|
|
409
439
|
intern: () => intern,
|
|
440
|
+
internIn: () => internIn,
|
|
410
441
|
internTable: () => internTable,
|
|
411
442
|
interned: () => interned,
|
|
412
443
|
internedTable: () => internedTable,
|
|
@@ -430,7 +461,6 @@ __export(runtimeExports_exports, {
|
|
|
430
461
|
keepFormatted: () => keepFormatted,
|
|
431
462
|
keepOwn: () => keepOwn,
|
|
432
463
|
keySiteOf: () => keySiteOf,
|
|
433
|
-
lacks: () => lacks,
|
|
434
464
|
lessThan: () => lessThan,
|
|
435
465
|
liftArray: () => liftArray,
|
|
436
466
|
listedIssue: () => listedIssue,
|
|
@@ -442,6 +472,7 @@ __export(runtimeExports_exports, {
|
|
|
442
472
|
mergeTransformed: () => mergeTransformed,
|
|
443
473
|
min: () => min,
|
|
444
474
|
minLength: () => minLength,
|
|
475
|
+
missingTextOf: () => missingTextOf,
|
|
445
476
|
moreThan: () => moreThan,
|
|
446
477
|
morphing: () => morphing,
|
|
447
478
|
narrowed: () => narrowed,
|
|
@@ -449,6 +480,7 @@ __export(runtimeExports_exports, {
|
|
|
449
480
|
narrowedBy: () => narrowedBy,
|
|
450
481
|
narrowedByEach: () => narrowedByEach,
|
|
451
482
|
narrowedInCtx: () => narrowedInCtx,
|
|
483
|
+
narrowedRejecting: () => narrowedRejecting,
|
|
452
484
|
narrowedWithCtx: () => narrowedWithCtx,
|
|
453
485
|
normalizationsByForm: () => normalizationsByForm,
|
|
454
486
|
nullable: () => nullable,
|
|
@@ -476,18 +508,20 @@ __export(runtimeExports_exports, {
|
|
|
476
508
|
pipeTransformed: () => pipeTransformed,
|
|
477
509
|
piped: () => piped,
|
|
478
510
|
pipedIntoUndetailed: () => pipedIntoUndetailed,
|
|
479
|
-
|
|
511
|
+
precompiledForArktype_3_0_0_beta_1: () => precompiledForArktype_3_0_0_beta_1,
|
|
480
512
|
printKind: () => printKind,
|
|
481
513
|
printable: () => printable,
|
|
482
|
-
problemSiteOf: () => problemSiteOf,
|
|
483
514
|
props: () => props,
|
|
484
515
|
raisedErrorPhrases: () => raisedErrorPhrases,
|
|
485
516
|
raisingTraversalOf: () => raisingTraversalOf,
|
|
486
517
|
readingCtx: () => readingCtx,
|
|
518
|
+
readingCtxNode: () => readingCtxNode,
|
|
487
519
|
receiverOf: () => receiverOf,
|
|
488
520
|
recordOf: () => recordOf,
|
|
489
521
|
rejected: () => rejected,
|
|
522
|
+
rejecting: () => rejecting,
|
|
490
523
|
rejects: () => rejects,
|
|
524
|
+
rejectsWith: () => rejectsWith,
|
|
491
525
|
rekeyed: () => rekeyed,
|
|
492
526
|
replacingUndefined: () => replacingUndefined,
|
|
493
527
|
replayedJsonSchema: () => replayedJsonSchema,
|
|
@@ -495,10 +529,13 @@ __export(runtimeExports_exports, {
|
|
|
495
529
|
requiredSiteOf: () => requiredSiteOf,
|
|
496
530
|
runtimeConfig: () => runtimeConfig,
|
|
497
531
|
runtimeScope: () => runtimeScope,
|
|
532
|
+
saying: () => saying,
|
|
533
|
+
sayingMissing: () => sayingMissing,
|
|
498
534
|
setPrototypeOf: () => setPrototypeOf,
|
|
499
535
|
silentCtx: () => silentCtx,
|
|
500
536
|
siteOf: () => siteOf,
|
|
501
537
|
sited: () => sited,
|
|
538
|
+
sitedProps: () => sitedProps,
|
|
502
539
|
standardResultOf: () => standardResultOf,
|
|
503
540
|
stringCheck: () => stringCheck,
|
|
504
541
|
stringRange: () => stringRange,
|
|
@@ -516,6 +553,7 @@ __export(runtimeExports_exports, {
|
|
|
516
553
|
transformedInApply: () => transformedInApply,
|
|
517
554
|
transformingClosedProps: () => transformingClosedProps,
|
|
518
555
|
transformingElementsOf: () => transformingElementsOf,
|
|
556
|
+
transformingNarrowedAfter: () => transformingNarrowedAfter,
|
|
519
557
|
transformingProps: () => transformingProps,
|
|
520
558
|
transformsBranches: () => transformsBranches,
|
|
521
559
|
transformsValid: () => transformsValid,
|
|
@@ -526,25 +564,27 @@ __export(runtimeExports_exports, {
|
|
|
526
564
|
union: () => union,
|
|
527
565
|
unit: () => unit,
|
|
528
566
|
units: () => units,
|
|
567
|
+
unnamed: () => unnamed,
|
|
529
568
|
unreadCallErrors: () => unreadCallErrors,
|
|
530
569
|
unreadElements: () => unreadElements,
|
|
531
570
|
unreadErrors: () => unreadErrors,
|
|
532
571
|
uppercaseString: () => uppercaseString,
|
|
533
572
|
writeCreationMismatchMessage: () => writeCreationMismatchMessage,
|
|
573
|
+
writeDigestMismatchMessage: () => writeDigestMismatchMessage,
|
|
534
574
|
writeDomainActual: () => writeDomainActual,
|
|
535
575
|
writeEpoch: () => writeEpoch,
|
|
536
576
|
writeIdentityMismatchMessage: () => writeIdentityMismatchMessage,
|
|
537
577
|
writeIsoDate: () => writeIsoDate,
|
|
538
|
-
|
|
578
|
+
writeJsonSyntaxErrorMessage: () => writeJsonSyntaxErrorMessage,
|
|
539
579
|
writeLengthActual: () => writeLengthActual,
|
|
580
|
+
writeMessage: () => writeMessage,
|
|
540
581
|
writeNotEqualActual: () => writeNotEqualActual,
|
|
541
582
|
writeNullableJsonSchema: () => writeNullableJsonSchema,
|
|
542
|
-
writeProblem: () => writeProblem,
|
|
543
583
|
writeProtoActual: () => writeProtoActual,
|
|
544
584
|
writeUnbakedMessage: () => writeUnbakedMessage,
|
|
545
585
|
writeUnionJsonSchema: () => writeUnionJsonSchema,
|
|
546
586
|
writeUnitActual: () => writeUnitActual,
|
|
547
|
-
|
|
587
|
+
writeUnitMessage: () => writeUnitMessage,
|
|
548
588
|
writeUrl: () => writeUrl,
|
|
549
589
|
writtenBy: () => writtenBy,
|
|
550
590
|
writtenSiteOf: () => writtenSiteOf
|
|
@@ -554,7 +594,7 @@ __export(runtimeExports_exports, {
|
|
|
554
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";
|
|
555
595
|
import { rootApplyRuntime, rootApplyParts } from "@ark/schema/internal";
|
|
556
596
|
import { writesInPlace } from "@ark/schema/mutatesInput";
|
|
557
|
-
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, throwInternalError as throwInternalError2, throwParseError as throwParseError4, unset } from "@ark/util";
|
|
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";
|
|
558
598
|
|
|
559
599
|
// out/standalone/baking.js
|
|
560
600
|
import { hasArkKind as hasArkKind4 } from "@ark/schema";
|
|
@@ -562,7 +602,7 @@ import { arkKindOf } from "@ark/util";
|
|
|
562
602
|
|
|
563
603
|
// out/standalone/combinators.js
|
|
564
604
|
import { hasArkKind as hasArkKind3, isDecidedByAllows as isDecidedByAllows2 } from "@ark/schema";
|
|
565
|
-
import { domainOf, isWellFormedInteger as isWellFormedInteger2, returnsReports } from "@ark/util";
|
|
605
|
+
import { domainOf, isWellFormedInteger as isWellFormedInteger2, returnsReports, testsOrRejects as testsOrRejects2 } from "@ark/util";
|
|
566
606
|
|
|
567
607
|
// out/standalone/compilers.js
|
|
568
608
|
import { compileDomainOf, describeBranches, describeCases, isDecidedByAllows, precompileRootUnits, TraversalCompiler } from "@ark/schema";
|
|
@@ -571,7 +611,7 @@ import { throwInternalError } from "@ark/util";
|
|
|
571
611
|
// out/standalone/sites.js
|
|
572
612
|
import { $ark } from "@ark/schema";
|
|
573
613
|
import { describesData, errorWriters, errorWritersByCode } from "@ark/schema/internal";
|
|
574
|
-
import { hasDomain as hasDomain4, isDotAccessible, readsOnlyData, throwParseError as throwParseError3 } from "@ark/util";
|
|
614
|
+
import { hasDomain as hasDomain4, isDotAccessible, readsOnlyData, testsOrRejects, throwParseError as throwParseError3 } from "@ark/util";
|
|
575
615
|
|
|
576
616
|
// out/standalone/keys.js
|
|
577
617
|
import { hasArkKind as hasArkKind2, holeNameMarker as holeNameMarker2, isNode as isNode3, LazyGenericRoot, madeMorphs as madeMorphs2 } from "@ark/schema";
|
|
@@ -1076,7 +1116,7 @@ var holeNamePattern = new RegExp(holeName, "g");
|
|
|
1076
1116
|
var printedHoleNamePattern = new RegExp(`\\$ark\\.(${holeName})(?:\\$[1-9]\\d*)?|valid according to (${holeName})|Function\\((${holeName})\\)|(${holeName})`, "g");
|
|
1077
1117
|
|
|
1078
1118
|
// out/standalone/sites.js
|
|
1079
|
-
var describingKeys = ["expected", "actual", "
|
|
1119
|
+
var describingKeys = ["expected", "actual", "message"];
|
|
1080
1120
|
var assertDescribed = function (root) {
|
|
1081
1121
|
const config = root.$.cfg;
|
|
1082
1122
|
const raisable = raisableCodesOf(root);
|
|
@@ -1136,13 +1176,14 @@ var readRaisableCodes = function (root) {
|
|
|
1136
1176
|
return codes;
|
|
1137
1177
|
};
|
|
1138
1178
|
var addIssueFeatures = function (features, units2, written) {
|
|
1179
|
+
const compiled2 = new Set(units2.flatMap((unit2) => unit2.roots.every((root) => isCheckerIn(unit2, root)) ? [] : unit2.declared));
|
|
1139
1180
|
for (const node of written) {
|
|
1140
1181
|
if (node.is("sequence"))
|
|
1141
1182
|
features.reportsIndices = true;
|
|
1142
1183
|
else if (node.is("structure")) {
|
|
1143
1184
|
if (node.index || node.undeclared === "reject" || node.props.some((prop) => typeof prop.key === "symbol" || !isDotAccessible(prop.key)))
|
|
1144
1185
|
features.bracketsKeys = true;
|
|
1145
|
-
} else if (node.is("morph") || node.is("predicate") && !raisesNothing(node.predicate)) {
|
|
1186
|
+
} else if (node.is("morph") || node.is("predicate") && !raisesNothing(node.predicate) && (compiled2.has(node) || !testsOrRejects.has(node.predicate))) {
|
|
1146
1187
|
features.reportsIndices = true;
|
|
1147
1188
|
features.bracketsKeys = true;
|
|
1148
1189
|
features.writesText = true;
|
|
@@ -1157,6 +1198,10 @@ var addIssueFeatures = function (features, units2, written) {
|
|
|
1157
1198
|
for (const [, source] of unit2.members) {
|
|
1158
1199
|
if (addsUnionIssue.test(source))
|
|
1159
1200
|
features.listsUnions = true;
|
|
1201
|
+
if (saysMessage.test(source))
|
|
1202
|
+
features.writesText = true;
|
|
1203
|
+
if (callsTextIn.test(source))
|
|
1204
|
+
features.callsSiteText = true;
|
|
1160
1205
|
if (appliesValue.test(source))
|
|
1161
1206
|
features.appliesValues = true;
|
|
1162
1207
|
if (discriminatesBoolean.test(source))
|
|
@@ -1166,11 +1211,11 @@ var addIssueFeatures = function (features, units2, written) {
|
|
|
1166
1211
|
if (!failureSites.has(ref))
|
|
1167
1212
|
continue;
|
|
1168
1213
|
const site = ref;
|
|
1169
|
-
if (site.v)
|
|
1170
|
-
features.readsKeySites = true;
|
|
1171
1214
|
const contexts = [site, site.v, site.m];
|
|
1172
1215
|
if (contexts.some(writesText))
|
|
1173
1216
|
features.writesText = true;
|
|
1217
|
+
if (contexts.some(callsText))
|
|
1218
|
+
features.callsSiteText = true;
|
|
1174
1219
|
}
|
|
1175
1220
|
}
|
|
1176
1221
|
};
|
|
@@ -1178,21 +1223,24 @@ var isUnion = (node) => node.is("union");
|
|
|
1178
1223
|
var appliesValue = /runtime\.(?:morphing|readingCtx|holdingAlias|aliasedValue|aliasedMember)\(/;
|
|
1179
1224
|
var discriminatesBoolean = /runtime\.discriminate\("(?:[^"\\]|\\.)*", { (?:true|false): /;
|
|
1180
1225
|
var addsUnionIssue = /runtime\.(?:failsBranches|failsListed|union|discriminateOr)\(/;
|
|
1181
|
-
var
|
|
1226
|
+
var saysMessage = /runtime\.(?:saying(?:Missing)?|narrowedRejecting)\(/;
|
|
1227
|
+
var writesText = (context) => !!context?.c || !!context?.written;
|
|
1228
|
+
var callsText = (context) => context?.c === 2 || !!context?.written;
|
|
1229
|
+
var callsTextIn = /runtime\.(?:codeSiteOf|writtenSiteOf|codedIssue)\b/;
|
|
1182
1230
|
var failureSites = /* @__PURE__ */ new WeakSet();
|
|
1183
1231
|
var issueSite = (site) => {
|
|
1184
1232
|
failureSites.add(site);
|
|
1185
1233
|
return site;
|
|
1186
1234
|
};
|
|
1187
1235
|
var isInlineSite = function (site) {
|
|
1188
|
-
const { written, description, message
|
|
1189
|
-
return "code" in site && !written && ![description, message
|
|
1236
|
+
const { written, description, message } = site;
|
|
1237
|
+
return "code" in site && !written && ![description, message].some((text) => text?.match(printedHoleNamePattern));
|
|
1190
1238
|
};
|
|
1191
1239
|
var siteWords = /* @__PURE__ */ new Set([
|
|
1192
1240
|
"runtime",
|
|
1193
1241
|
"void",
|
|
1194
1242
|
"siteOf",
|
|
1195
|
-
"
|
|
1243
|
+
"codeSiteOf",
|
|
1196
1244
|
"keySiteOf",
|
|
1197
1245
|
"requiredSiteOf",
|
|
1198
1246
|
"v",
|
|
@@ -1201,11 +1249,11 @@ var siteWords = /* @__PURE__ */ new Set([
|
|
|
1201
1249
|
]);
|
|
1202
1250
|
var isLiteralSite = function (value, emitted) { return hasDomain4(value, "object") && failureSites.has(value) && (withoutStrings(emitted).match(/[$A-Z_a-z][\w$]*/g) ?? []).every((word) => siteWords.has(word)) };
|
|
1203
1251
|
var withoutStrings = (code) => code.replace(/"(?:[^"\\]|\\.)*"/g, '""');
|
|
1204
|
-
var writeSiteOf = function ({ code, description, message,
|
|
1205
|
-
const args = writer === "keySiteOf" ? [code, description, missing === description ? void 0 : missing] : [code, description, message
|
|
1252
|
+
var writeSiteOf = function ({ code, description, message, c }, emit, writer = "siteOf", missing) {
|
|
1253
|
+
const args = writer === "keySiteOf" ? [code, description, missing === description ? void 0 : missing] : [code, description, message];
|
|
1206
1254
|
while (args[args.length - 1] === void 0)
|
|
1207
1255
|
args.pop();
|
|
1208
|
-
return `runtime.${writer === "
|
|
1256
|
+
return `runtime.${writer === "siteOf" && c === 2 ? "codeSiteOf" : writer}(${args.map((arg) => arg === void 0 ? "void 0" : emit(arg)).join(", ")})`;
|
|
1209
1257
|
};
|
|
1210
1258
|
var missingDescriptionOf = function (site) {
|
|
1211
1259
|
const { m: missing } = site;
|
|
@@ -1220,7 +1268,7 @@ var ConfiguredWriter = class {
|
|
|
1220
1268
|
this.k = k;
|
|
1221
1269
|
}
|
|
1222
1270
|
};
|
|
1223
|
-
var keepsOf = (
|
|
1271
|
+
var keepsOf = (takesExpected, c, describes) => +takesExpected | (c === 2 ? 2 : 0) | +describes << 2;
|
|
1224
1272
|
var describerOf = function (writer, readsActual) {
|
|
1225
1273
|
if (!describesData(writer))
|
|
1226
1274
|
return;
|
|
@@ -1244,14 +1292,17 @@ var issueContextOf = function (context) {
|
|
|
1244
1292
|
if (writer !== defaults[k])
|
|
1245
1293
|
custom[k] = writer;
|
|
1246
1294
|
}
|
|
1295
|
+
const ofValue = code === "required" && meta.message === void 0 ? context.valueMeta?.message : void 0;
|
|
1296
|
+
if (typeof ofValue === "string")
|
|
1297
|
+
custom.message = ofValue;
|
|
1298
|
+
const c = custom.message === void 0 ? void 0 : meta.message !== void 0 || custom.message === ofValue ? 1 : 2;
|
|
1247
1299
|
const locale = $ark.cfg.locale;
|
|
1248
1300
|
const issueContext = {
|
|
1249
1301
|
code,
|
|
1250
1302
|
description: typeof custom.expected === "string" ? custom.expected : context.description !== void 0 ? context.description : context.missingValueDescription
|
|
1251
1303
|
};
|
|
1252
1304
|
if (!unwritableCodes.has(code) && Object.values(custom).some((writer) => typeof writer === "function")) {
|
|
1253
|
-
const
|
|
1254
|
-
const describer = custom.actual === void 0 ? describerOf(defaults.actual, readsActual) : void 0;
|
|
1305
|
+
const describer = custom.actual === void 0 ? describerOf(defaults.actual, typeof custom.message === "function") : void 0;
|
|
1255
1306
|
const writerOf = (k) => {
|
|
1256
1307
|
if (k === "actual" && describer !== void 0)
|
|
1257
1308
|
return describer;
|
|
@@ -1265,40 +1316,29 @@ var issueContextOf = function (context) {
|
|
|
1265
1316
|
return writer(context, locale);
|
|
1266
1317
|
if (runtimeKeyOf(writer))
|
|
1267
1318
|
return writer;
|
|
1268
|
-
if (k === "
|
|
1269
|
-
return
|
|
1319
|
+
if (k === "message")
|
|
1320
|
+
return writeMessage;
|
|
1270
1321
|
return writer(void 0, context, locale);
|
|
1271
1322
|
};
|
|
1272
1323
|
issueContext.written = {
|
|
1273
1324
|
context,
|
|
1274
|
-
writers:
|
|
1275
|
-
|
|
1276
|
-
writerOf("actual"),
|
|
1277
|
-
writerOf("problem"),
|
|
1278
|
-
custom.message === void 0 ? void 0 : writerOf("message")
|
|
1279
|
-
],
|
|
1280
|
-
keeps: keepsOf((k) => custom[k] !== void 0, !!describer)
|
|
1325
|
+
writers: describingKeys.map(writerOf),
|
|
1326
|
+
keeps: keepsOf(custom.expected !== void 0, c, !!describer)
|
|
1281
1327
|
};
|
|
1282
1328
|
return issueContext;
|
|
1283
1329
|
}
|
|
1284
|
-
if (code === "union" && (meta.description === void 0 || meta.keyword !== void 0)) {
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
if (
|
|
1288
|
-
issueContext.
|
|
1289
|
-
|
|
1290
|
-
issueContext.description = void 0;
|
|
1291
|
-
if (typeof problem === "string")
|
|
1292
|
-
issueContext.problem = problem;
|
|
1293
|
-
return issueContext;
|
|
1294
|
-
}
|
|
1330
|
+
if (code === "union" && (meta.description === void 0 || meta.keyword !== void 0) && typeof custom.message === "string") {
|
|
1331
|
+
issueContext.message = custom.message;
|
|
1332
|
+
issueContext.c = c;
|
|
1333
|
+
if (custom.expected === void 0)
|
|
1334
|
+
issueContext.description = void 0;
|
|
1335
|
+
return issueContext;
|
|
1295
1336
|
}
|
|
1296
|
-
if (typeof custom.message === "string")
|
|
1337
|
+
if (typeof custom.message === "string") {
|
|
1297
1338
|
issueContext.message = custom.message;
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
issueContext.problem = errorWriters.problem({ expected: issueContext.description, actual: custom.actual }, locale);
|
|
1339
|
+
issueContext.c = c;
|
|
1340
|
+
} else if (typeof custom.actual === "string" && custom.actual && custom.message === void 0 && configured.message === errorWriters.message) {
|
|
1341
|
+
issueContext.message = errorWriters.message({ expected: issueContext.description, actual: custom.actual }, locale);
|
|
1302
1342
|
}
|
|
1303
1343
|
return issueContext;
|
|
1304
1344
|
};
|
|
@@ -1315,7 +1355,7 @@ var raisedWritersByCode = function () {
|
|
|
1315
1355
|
const isCustom = (k) => configured[k] !== defaults[k];
|
|
1316
1356
|
if (!describingKeys.some(isCustom))
|
|
1317
1357
|
continue;
|
|
1318
|
-
const describer = isCustom("actual") ? void 0 : describerOf(defaults.actual, isCustom("
|
|
1358
|
+
const describer = isCustom("actual") ? void 0 : describerOf(defaults.actual, isCustom("message") && typeof configured.message === "function");
|
|
1319
1359
|
const writerOf = (k) => {
|
|
1320
1360
|
if (k === "actual" && describer !== void 0)
|
|
1321
1361
|
return describer;
|
|
@@ -1323,23 +1363,24 @@ var raisedWritersByCode = function () {
|
|
|
1323
1363
|
if (isCustom(k)) {
|
|
1324
1364
|
return typeof writer === "function" ? new ConfiguredWriter(code, k) : writer;
|
|
1325
1365
|
}
|
|
1326
|
-
if (k === "expected"
|
|
1366
|
+
if (k === "expected")
|
|
1327
1367
|
return;
|
|
1328
1368
|
if (typeof writer !== "function" || runtimeKeyOf(writer))
|
|
1329
1369
|
return writer;
|
|
1330
|
-
if (k === "
|
|
1331
|
-
return
|
|
1370
|
+
if (k === "message")
|
|
1371
|
+
return writeMessage;
|
|
1332
1372
|
return writer(void 0, { code }, locale);
|
|
1333
1373
|
};
|
|
1334
1374
|
written.push([
|
|
1335
1375
|
code,
|
|
1336
1376
|
describingKeys.map(writerOf),
|
|
1337
|
-
|
|
1377
|
+
// a message configured for a code is its code's, wherever it's raised
|
|
1378
|
+
keepsOf(isCustom("expected"), isCustom("message") ? 2 : void 0, !!describer)
|
|
1338
1379
|
]);
|
|
1339
1380
|
}
|
|
1340
1381
|
return written;
|
|
1341
1382
|
};
|
|
1342
|
-
var isDescribed = (context) => context.message === void 0 &&
|
|
1383
|
+
var isDescribed = (context) => context.message === void 0 && !context.written;
|
|
1343
1384
|
var issueSiteOf = function (site) {
|
|
1344
1385
|
const { v: value, m: missing } = site;
|
|
1345
1386
|
const missingContext = missing && issueContextOf(missing);
|
|
@@ -1374,10 +1415,72 @@ var domainChecks = new Map([
|
|
|
1374
1415
|
'(typeof data === "object" ? data !== null : typeof data === "function")'
|
|
1375
1416
|
]
|
|
1376
1417
|
]);
|
|
1418
|
+
var inlineSites = /* @__PURE__ */ new Map();
|
|
1419
|
+
var inlined = function (written) {
|
|
1420
|
+
if (!inlineSites.has(written)) {
|
|
1421
|
+
const open = written.indexOf("(");
|
|
1422
|
+
inlineSites.set(written, [
|
|
1423
|
+
written.slice("runtime.".length, open),
|
|
1424
|
+
written.slice(open + 1, -1)
|
|
1425
|
+
]);
|
|
1426
|
+
}
|
|
1427
|
+
return written;
|
|
1428
|
+
};
|
|
1377
1429
|
var StandaloneCompiler = class extends TraversalCompiler {
|
|
1378
1430
|
reportsFirst = false;
|
|
1431
|
+
// a validator's errors read the value they apply at a key: passed, it's
|
|
1432
|
+
// `, data.key` at every key of every validator a bundle holds
|
|
1433
|
+
readsApplied = true;
|
|
1379
1434
|
// named for its content as compiled, before the size forms that follow from it
|
|
1380
1435
|
naming = this.link.unit === void 0;
|
|
1436
|
+
// A site written from literals fails as them: its code, what it expects
|
|
1437
|
+
// and its message, passed to the ctx where it fails, so a bundle holds no
|
|
1438
|
+
// function building a site and none is built at a failure. At a key, a
|
|
1439
|
+
// key's site is entered by the runtime's failsKey, which a bundler drops
|
|
1440
|
+
// from a program failing at none, where every bundle holds its errors' _e.
|
|
1441
|
+
// A site held as an object, as one whose text a function writes is, fails
|
|
1442
|
+
// through the runtime
|
|
1443
|
+
failsSite(site, data, key) {
|
|
1444
|
+
const keyed = key === void 0 ? void 0 : this.keyFailureOf(site);
|
|
1445
|
+
if (keyed !== void 0)
|
|
1446
|
+
return `runtime.failsKey(ctx, ${data}, ${key}, ${keyed})`;
|
|
1447
|
+
const failure = this.failureOf(site);
|
|
1448
|
+
if (failure === void 0) {
|
|
1449
|
+
return key === void 0 ? `runtime.failsSite(ctx, ${site}, ${data})` : `runtime.failsKeySite(ctx, ${site}, ${data}, ${key})`;
|
|
1450
|
+
}
|
|
1451
|
+
return key === void 0 ? `ctx._e(${data}, ${failure})` : `ctx._k((data, ctx) => !ctx._e(data, ${failure}), ${data}, ${key})`;
|
|
1452
|
+
}
|
|
1453
|
+
// what a ctx is passed after data for a site written from literals that's
|
|
1454
|
+
// a context: its code, what it expects and its message, and what notes on
|
|
1455
|
+
// its issue a message configured for its code
|
|
1456
|
+
failureOf(site) {
|
|
1457
|
+
const inline = inlineSites.get(site);
|
|
1458
|
+
return inline?.[0] === "siteOf" ? inline[1] : inline?.[0] === "codeSiteOf" ? `${inline[1]}, runtime.codedIssue` : void 0;
|
|
1459
|
+
}
|
|
1460
|
+
// what failsKey is passed after the key for a key's site written from
|
|
1461
|
+
// literals: its value's code and what it expects, then what the missing
|
|
1462
|
+
// key does where that's something else. A site of only what a missing key
|
|
1463
|
+
// expects is failed where data lacks the key, which failsKey fails as
|
|
1464
|
+
// required with what it's passed
|
|
1465
|
+
keyFailureOf(site) {
|
|
1466
|
+
const inline = inlineSites.get(site);
|
|
1467
|
+
return inline?.[0] === "keySiteOf" ? inline[1] : inline?.[0] === "requiredSiteOf" ? `"required", ${inline[1]}` : void 0;
|
|
1468
|
+
}
|
|
1469
|
+
// a validator's ctx enters a key by a name of its own
|
|
1470
|
+
failsIn(args) {
|
|
1471
|
+
return `ctx._k(${args})`;
|
|
1472
|
+
}
|
|
1473
|
+
failsEither(condition, site, otherwise, data, key) {
|
|
1474
|
+
return `(${condition} ? ${this.failsSite(site, data, key)} : ${this.failsSite(otherwise, data, key)})`;
|
|
1475
|
+
}
|
|
1476
|
+
// what a missing key says, as _k takes it after the key: what it expects
|
|
1477
|
+
// where its site is written from that alone
|
|
1478
|
+
applied(key, value, missing) {
|
|
1479
|
+
if (missing === void 0)
|
|
1480
|
+
return key;
|
|
1481
|
+
const inline = inlineSites.get(missing);
|
|
1482
|
+
return inline?.[0] === "requiredSiteOf" ? `${key}, ${inline[1]}` : `${key}, ...runtime.missingTextOf(${missing}.m)`;
|
|
1483
|
+
}
|
|
1381
1484
|
unifies(node) {
|
|
1382
1485
|
return unifies(node);
|
|
1383
1486
|
}
|
|
@@ -1426,14 +1529,14 @@ var StandaloneCompiler = class extends TraversalCompiler {
|
|
|
1426
1529
|
siteRef(site) {
|
|
1427
1530
|
const ref = this.ref(site);
|
|
1428
1531
|
if (isInlineSite(site))
|
|
1429
|
-
return writeSiteOf(site, JSON.stringify);
|
|
1532
|
+
return inlined(writeSiteOf(site, JSON.stringify));
|
|
1430
1533
|
const { v: value } = site;
|
|
1431
1534
|
const missing = missingDescriptionOf(site);
|
|
1432
1535
|
if (missing === void 0)
|
|
1433
1536
|
return ref;
|
|
1434
1537
|
if (!value)
|
|
1435
|
-
return `runtime.requiredSiteOf(${JSON.stringify(missing)})
|
|
1436
|
-
return isInlineSite(value) && isDescribed(value) ? writeSiteOf(value, JSON.stringify, "keySiteOf", missing) : ref;
|
|
1538
|
+
return inlined(`runtime.requiredSiteOf(${JSON.stringify(missing)})`);
|
|
1539
|
+
return isInlineSite(value) && isDescribed(value) ? inlined(writeSiteOf(value, JSON.stringify, "keySiteOf", missing)) : ref;
|
|
1437
1540
|
}
|
|
1438
1541
|
// a keyword check adds no issues itself, so its Apply needn't count them
|
|
1439
1542
|
addsNoIssues(predicate) {
|
|
@@ -1462,7 +1565,7 @@ var StandaloneCompiler = class extends TraversalCompiler {
|
|
|
1462
1565
|
missedFails(node) {
|
|
1463
1566
|
const path = node.missPath;
|
|
1464
1567
|
const site = this.siteRef(issueSite(discriminantContextOf(node)));
|
|
1465
|
-
return path.length > 1 ? `!${this.ref(failsAtPath)}(ctx, ${site}, data, [${path.map((k) => this.serialize(k)).join(", ")}])` :
|
|
1568
|
+
return path.length > 1 ? `!${this.ref(failsAtPath)}(ctx, ${site}, data, [${path.map((k) => this.serialize(k)).join(", ")}])` : path.length ? `!${this.failsSite(site, "data", this.serialize(path[0]))}` : `!${this.failsSite(site, "data")}`;
|
|
1466
1569
|
}
|
|
1467
1570
|
ifReadable(node, fails, unreadable = (fails2) => fails2) {
|
|
1468
1571
|
const [k, ...deeper] = node.discriminant.path;
|
|
@@ -1494,7 +1597,7 @@ var StandaloneCompiler = class extends TraversalCompiler {
|
|
|
1494
1597
|
unreadableFails(node) {
|
|
1495
1598
|
const [k] = node.discriminant.path;
|
|
1496
1599
|
const bases = basesOf(node);
|
|
1497
|
-
return bases?.nodes.every((basis) => typeof k === "number" ? basis.is("proto") && basis.proto === Array : basis.domain === "object") ? `!${this.
|
|
1600
|
+
return bases?.nodes.every((basis) => typeof k === "number" ? basis.is("proto") && basis.proto === Array : basis.domain === "object") ? `!${this.failsSite(this.siteRef(bases.site), "data")}` : this.unionFails(node);
|
|
1498
1601
|
}
|
|
1499
1602
|
undeclaredFails(node) {
|
|
1500
1603
|
const site = issueSite(issueContextOf({
|
|
@@ -1502,13 +1605,16 @@ var StandaloneCompiler = class extends TraversalCompiler {
|
|
|
1502
1605
|
description: "removed",
|
|
1503
1606
|
meta: node.meta
|
|
1504
1607
|
}));
|
|
1505
|
-
return this.
|
|
1608
|
+
return this.failsSite(this.siteRef(site), "data", "k");
|
|
1506
1609
|
}
|
|
1507
1610
|
// a rejected union value reports the union's issue at its key, not its Apply
|
|
1508
1611
|
failingSiteOf(prop) {
|
|
1509
1612
|
const { value, errorCtx } = prop;
|
|
1510
1613
|
if (reportsItself(value) && expectsItsBases(value))
|
|
1511
1614
|
return this.siteRef(unionKeySiteOf(value.failSite, errorCtx));
|
|
1615
|
+
if (onlyMisses(value)) {
|
|
1616
|
+
return this.siteRef(issueSiteOf({ v: discriminantTextOf(value), m: errorCtx }));
|
|
1617
|
+
}
|
|
1512
1618
|
}
|
|
1513
1619
|
// unless its issue reads its branches'
|
|
1514
1620
|
failingApplyOf(value) {
|
|
@@ -1517,11 +1623,21 @@ var StandaloneCompiler = class extends TraversalCompiler {
|
|
|
1517
1623
|
}
|
|
1518
1624
|
};
|
|
1519
1625
|
var isDecidedByKeywords = function (node) { return !node.hasMorph && !node.hasAlias && !node.allowsCtx && Object.values(node.byId).every((reference) => !reference.is("predicate") || isKeyword(reference.predicate)) };
|
|
1520
|
-
var
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1626
|
+
var discriminantTexts = /* @__PURE__ */ new WeakMap();
|
|
1627
|
+
var discriminantTextOf = function (node) {
|
|
1628
|
+
let text = discriminantTexts.get(node);
|
|
1629
|
+
if (!text) {
|
|
1630
|
+
text = {
|
|
1631
|
+
code: "discriminant",
|
|
1632
|
+
description: node.discDesc,
|
|
1633
|
+
meta: node.discMeta
|
|
1634
|
+
};
|
|
1635
|
+
discriminantTexts.set(node, text);
|
|
1636
|
+
}
|
|
1637
|
+
return text;
|
|
1638
|
+
};
|
|
1639
|
+
var discriminantContextOf = (node) => issueContextOf(discriminantTextOf(node));
|
|
1640
|
+
var onlyMisses = function (value) { return value.is("union") && !!value.discriminant && value.discriminant.path.length === 0 && !value.missLists && !value.hasAlias && Object.values(value.discriminant.cases).every((c) => c === true) };
|
|
1525
1641
|
var listsBranches = function (node) {
|
|
1526
1642
|
const { description, keyword } = node.meta;
|
|
1527
1643
|
const site = issueSiteOf(node.failSite);
|
|
@@ -1652,9 +1768,18 @@ var UnifiedCompiler = class extends StandaloneCompiler {
|
|
|
1652
1768
|
}
|
|
1653
1769
|
failingApplyOf() {
|
|
1654
1770
|
}
|
|
1655
|
-
// read where it fails, as a site is, so a unit needn't receive it
|
|
1656
|
-
|
|
1657
|
-
|
|
1771
|
+
// read where it fails, as a site is, so a unit needn't receive it. Each
|
|
1772
|
+
// stops where it's passed no ctx, as failsAtKey does at a key
|
|
1773
|
+
failsSite(site, data, key) {
|
|
1774
|
+
if (key === void 0) {
|
|
1775
|
+
const failure = this.failureOf(site);
|
|
1776
|
+
return failure === void 0 ? `runtime.failsAt(ctx, ${site}, ${data})` : `runtime.failsWith(ctx, ${data}, ${failure})`;
|
|
1777
|
+
}
|
|
1778
|
+
const keyed = this.keyFailureOf(site);
|
|
1779
|
+
return keyed === void 0 ? `runtime.failsAtKey(ctx, ${site}, ${data}, ${key})` : `runtime.failsKeyWith(ctx, ${data}, ${key}, ${keyed})`;
|
|
1780
|
+
}
|
|
1781
|
+
failsIn(args) {
|
|
1782
|
+
return `runtime.failsIn(ctx, ${args})`;
|
|
1658
1783
|
}
|
|
1659
1784
|
};
|
|
1660
1785
|
var unifiedMembers = /* @__PURE__ */ new WeakMap();
|
|
@@ -1781,11 +1906,23 @@ var combines = function (node) {
|
|
|
1781
1906
|
let combinable = combinableByNode.get(node);
|
|
1782
1907
|
if (combinable === void 0) {
|
|
1783
1908
|
combinableByNode.set(node, false);
|
|
1784
|
-
combinable = node.isRoot() && !isInCycle(node) && calleesOf(node)?.every(isCallable) === true;
|
|
1909
|
+
combinable = node.isRoot() && !isInCycle(node) && (says(node) || calleesOf(node)?.every(isCallable) === true);
|
|
1785
1910
|
combinableByNode.set(node, combinable);
|
|
1786
1911
|
}
|
|
1787
1912
|
return combinable;
|
|
1788
1913
|
};
|
|
1914
|
+
var saidByNode = /* @__PURE__ */ new WeakMap();
|
|
1915
|
+
var says = function (node) {
|
|
1916
|
+
const { message } = node.meta;
|
|
1917
|
+
if (typeof message !== "string" || !node.references.every((reference) => saysAt(reference, message)))
|
|
1918
|
+
return false;
|
|
1919
|
+
const plain = node.configure(({ message: _, ...meta }) => meta, "shallow");
|
|
1920
|
+
if (!combines(plain) || !plain.references.every((reference) => reference.meta.message === void 0))
|
|
1921
|
+
return false;
|
|
1922
|
+
saidByNode.set(node, { message, plain });
|
|
1923
|
+
return true;
|
|
1924
|
+
};
|
|
1925
|
+
var saysAt = function (node, message) { return node.meta.message === message && (node.is("predicate") ? raisesNothing(node.predicate) : node.is("union") ? node.discriminant?.path.length === 0 : !node.is("alias") && !node.is("morph") && !node.is("structure") && !node.is("required") && !node.is("optional") && !node.is("index") && !node.is("sequence")) };
|
|
1789
1926
|
var isCallable = (node) => combines(node) || unifies(node) || node.hasAlias;
|
|
1790
1927
|
var inCycleByNode = /* @__PURE__ */ new WeakMap();
|
|
1791
1928
|
var isInCycle = function (node) {
|
|
@@ -1799,7 +1936,7 @@ var isInCycle = function (node) {
|
|
|
1799
1936
|
return false;
|
|
1800
1937
|
seen.add(reference);
|
|
1801
1938
|
const { resolution } = reference;
|
|
1802
|
-
return resolution.references.
|
|
1939
|
+
return resolution.references.some((reached) => reached.id === node.id) || reaches(resolution);
|
|
1803
1940
|
});
|
|
1804
1941
|
inCycle = reaches(node);
|
|
1805
1942
|
inCycleByNode.set(node, inCycle);
|
|
@@ -1854,7 +1991,12 @@ var plainContextOf = (context) => isInlineSite(context) && isDescribed(context)
|
|
|
1854
1991
|
var plainSiteOf = (node) => plainContextOf(issueSiteOf(node.failSite));
|
|
1855
1992
|
var unionSiteOf = (node) => plainContextOf(issueContextOf({ ...node.failSite, code: "union" }));
|
|
1856
1993
|
var discriminantSiteOf = (node) => plainContextOf(discriminantContextOf(node));
|
|
1857
|
-
var checkOf = (node)
|
|
1994
|
+
var checkOf = function (node) {
|
|
1995
|
+
if (!node.jsCond)
|
|
1996
|
+
return;
|
|
1997
|
+
const site = issueSiteOf(node.failSite);
|
|
1998
|
+
return isInlineSite(site) && (isDescribed(site) || site.c === 1) ? site : void 0;
|
|
1999
|
+
};
|
|
1858
2000
|
var predicateSiteOf = function (node) {
|
|
1859
2001
|
if (!node.is("predicate"))
|
|
1860
2002
|
return;
|
|
@@ -1975,10 +2117,17 @@ var structureCalleesOf = function (structure) {
|
|
|
1975
2117
|
]) ?? []
|
|
1976
2118
|
];
|
|
1977
2119
|
};
|
|
1978
|
-
var
|
|
2120
|
+
var missingOf = function (prop) {
|
|
2121
|
+
const { m: missing } = issueSiteOf(prop.failSite);
|
|
2122
|
+
return missing && missing.code === "required" && isInlineSite(missing) && (isDescribed(missing) || missing.c) ? missing : void 0;
|
|
2123
|
+
};
|
|
2124
|
+
var missesAsRequired = (prop) => missingOf(prop) !== void 0;
|
|
1979
2125
|
var checkerDescriptionOf = function (node) {
|
|
1980
2126
|
if (!combines(node))
|
|
1981
2127
|
return;
|
|
2128
|
+
const said = saidByNode.get(node);
|
|
2129
|
+
if (said)
|
|
2130
|
+
return checkerDescriptionOf(said.plain);
|
|
1982
2131
|
if (node.is("domain") || node.is("proto"))
|
|
1983
2132
|
return checkOf(node).description;
|
|
1984
2133
|
if (node.is("unit"))
|
|
@@ -2026,9 +2175,14 @@ var ruleFactories = [
|
|
|
2026
2175
|
];
|
|
2027
2176
|
var isObjectCheck = function (node) {
|
|
2028
2177
|
const site = checkOf(node);
|
|
2029
|
-
return node.is("domain") && node.domain === "object" && site.code === objectCheck.code && site.description === objectCheck.description;
|
|
2178
|
+
return node.is("domain") && node.domain === "object" && site.message === void 0 && site.code === objectCheck.code && site.description === objectCheck.description;
|
|
2030
2179
|
};
|
|
2031
2180
|
var writeCheck = function (js, node) {
|
|
2181
|
+
const { message } = checkOf(node);
|
|
2182
|
+
const check2 = writeDescribedCheck(js, node);
|
|
2183
|
+
return message === void 0 ? check2 : writeCall("saying", check2, JSON.stringify(message));
|
|
2184
|
+
};
|
|
2185
|
+
var writeDescribedCheck = function (js, node) {
|
|
2032
2186
|
const site = checkOf(node);
|
|
2033
2187
|
const condition = node.jsCond(js, "data");
|
|
2034
2188
|
const constant = constantChecks[condition];
|
|
@@ -2125,6 +2279,24 @@ var writeSitedKeep = function (js, structure, failing) {
|
|
|
2125
2279
|
}
|
|
2126
2280
|
return `(data, checkers, values, copy) => { let out = data, v; ${transforms.join(" ")} ${defaults.length ? `if (!values.failed()) { ${defaults.join(" ")} }` : ""} return out; }`;
|
|
2127
2281
|
};
|
|
2282
|
+
var writeRequired = function (prop, checker) {
|
|
2283
|
+
const { description, message, c } = missingOf(prop);
|
|
2284
|
+
const held = checkerDescriptionOf(prop.value);
|
|
2285
|
+
const said = combines(prop.value) ? saidByNode.get(prop.value) : void 0;
|
|
2286
|
+
if (message === void 0) {
|
|
2287
|
+
return held === description && !said ? checker : writeCall("required", checker, JSON.stringify(description));
|
|
2288
|
+
}
|
|
2289
|
+
if (held === description && said?.message === message && c === 1)
|
|
2290
|
+
return checker;
|
|
2291
|
+
return writeCall(
|
|
2292
|
+
"sayingMissing",
|
|
2293
|
+
checker,
|
|
2294
|
+
JSON.stringify(message),
|
|
2295
|
+
// a message configured for the code is noted on the missing key's issue
|
|
2296
|
+
c === 1 ? void 0 : "runtime.codedIssue",
|
|
2297
|
+
held === description ? void 0 : JSON.stringify(description)
|
|
2298
|
+
);
|
|
2299
|
+
};
|
|
2128
2300
|
var writeStructure = function (js, structure) {
|
|
2129
2301
|
const ref = (node) => readValue(js, node);
|
|
2130
2302
|
if (structure.sequence) {
|
|
@@ -2134,8 +2306,7 @@ var writeStructure = function (js, structure) {
|
|
|
2134
2306
|
const refs = structure.inOrder.map((prop) => ref(prop.value));
|
|
2135
2307
|
const entries = structure.inOrder.map((prop, i) => {
|
|
2136
2308
|
const checker = refs[i];
|
|
2137
|
-
|
|
2138
|
-
return `${writeKey(prop.key)}: ${prop.is("optional") ? !prop.hasDef() ? writeCall("optional", checker) : isLiteralDefault(prop) ? writeCall(prop.defaultsUndefined ? "replacingUndefined" : "optional", checker, writeLiteral(js, prop.default)) : writeCall("writtenBy", checker, prop.defMorph.length === 2 ? `(data, ctx) => ${js.ref(prop.defMorph)}(data, ctx)` : `data => ${js.ref(prop.defMorph)}(data)`, prop.defaultsUndefined ? "1" : void 0) : checkerDescriptionOf(prop.value) === missing ? checker : writeCall("required", checker, JSON.stringify(missing))}`;
|
|
2309
|
+
return `${writeKey(prop.key)}: ${prop.is("optional") ? !prop.hasDef() ? writeCall("optional", checker) : isLiteralDefault(prop) ? writeCall(prop.defaultsUndefined ? "replacingUndefined" : "optional", checker, writeLiteral(js, prop.default)) : writeCall("writtenBy", checker, prop.defMorph.length === 2 ? `(data, ctx) => ${js.ref(prop.defMorph)}(data, ctx)` : `data => ${js.ref(prop.defMorph)}(data)`, prop.defaultsUndefined ? "1" : void 0) : writeRequired(prop, checker)}`;
|
|
2139
2310
|
});
|
|
2140
2311
|
const declared = writeObject(entries);
|
|
2141
2312
|
if (structure.index) {
|
|
@@ -2147,6 +2318,9 @@ var writeStructure = function (js, structure) {
|
|
|
2147
2318
|
const withCtx = structure.hasAlias ? "1" : void 0;
|
|
2148
2319
|
const failing = structure.hasAlias || structure.hasMorph || structure.props.some(writesByValues);
|
|
2149
2320
|
if (failing || (structure.optional?.length ?? 0) >= minSitedKeys) {
|
|
2321
|
+
if (!failing && !structure.handlesUndeclared) {
|
|
2322
|
+
return writeCall("sitedProps", writeSitedAllows(structure, refs), declared, structure.tfs ? writeSitedKeep(js, structure, false) : void 0);
|
|
2323
|
+
}
|
|
2150
2324
|
const deletes = structure.handlesUndeclared === "delete";
|
|
2151
2325
|
return writeCall("sited", writeSitedAllows(structure, refs), declared, deletes ? writeSitedWrite(js, structure, failing) : structure.tfs ? writeSitedKeep(js, structure, failing) : "0", !structure.tfs ? "0" : `${(deletes ? 2 : 0) + (failing ? 2 : 1)}`, structure.handlesUndeclared && !deletes ? JSON.stringify(removedSiteOf(structure).description) : void 0, withCtx);
|
|
2152
2326
|
}
|
|
@@ -2161,19 +2335,19 @@ var writeStructure = function (js, structure) {
|
|
|
2161
2335
|
};
|
|
2162
2336
|
var ownNodesOf = (node) => node.children.flatMap((child) => child.isRoot() && !isInlined(child) ? [] : [child, ...ownNodesOf(child)]);
|
|
2163
2337
|
var declaresRef = function (node) { return node.is("morph") || node.is("pattern") || node.is("predicate") || node.is("proto") && node.proto !== Array || node.is("union") && !!discriminatedOf(node) };
|
|
2164
|
-
var maxInlinedNodes =
|
|
2338
|
+
var maxInlinedNodes = 4;
|
|
2165
2339
|
var maxInlinedObjectNodes = 24;
|
|
2166
2340
|
var inlinedByNode = /* @__PURE__ */ new WeakMap();
|
|
2167
2341
|
var isInlined = function (node) {
|
|
2168
|
-
let
|
|
2169
|
-
if (
|
|
2342
|
+
let inlined2 = inlinedByNode.get(node);
|
|
2343
|
+
if (inlined2 === void 0) {
|
|
2170
2344
|
inlinedByNode.set(node, false);
|
|
2171
2345
|
const own2 = combines(node) && !node.isCyclic && ownNodesOf(node);
|
|
2172
|
-
|
|
2346
|
+
inlined2 = !!own2 && !declaresRef(node) && !own2.some(declaresRef) && (own2.length <= maxInlinedNodes || // an object reading no other's checker is likely anonymous
|
|
2173
2347
|
own2.length <= maxInlinedObjectNodes && own2.every((child) => !child.is("structure") || child.props.every((prop) => isInlined(prop.value))));
|
|
2174
|
-
inlinedByNode.set(node,
|
|
2348
|
+
inlinedByNode.set(node, inlined2);
|
|
2175
2349
|
}
|
|
2176
|
-
return
|
|
2350
|
+
return inlined2;
|
|
2177
2351
|
};
|
|
2178
2352
|
var ruleCheckOf = (kind, rule) => kind === "divisor" && rule === 1 ? integerCheck : runtimeExports_exports[kind](rule);
|
|
2179
2353
|
var rulesOf = function (refinements, kinds) {
|
|
@@ -2186,7 +2360,7 @@ var rulesOf = function (refinements, kinds) {
|
|
|
2186
2360
|
return;
|
|
2187
2361
|
const { rule, exclusive } = node.inner;
|
|
2188
2362
|
const site = checkOf(node);
|
|
2189
|
-
if (typeof rule !== "number" || exclusive || !site || site.code !== kinds[i] || site.description !== ruleCheckOf(kinds[i], rule).description)
|
|
2363
|
+
if (typeof rule !== "number" || exclusive || !site || site.message !== void 0 || site.code !== kinds[i] || site.description !== ruleCheckOf(kinds[i], rule).description)
|
|
2190
2364
|
return;
|
|
2191
2365
|
rules[i++] = rule;
|
|
2192
2366
|
}
|
|
@@ -2220,9 +2394,36 @@ var writeShape = function (js, node) {
|
|
|
2220
2394
|
var readChecker = function (js, node) { return isInlined(node) ? writeCombinator(js, node) : node.hasAlias && !combines(node) ? writeCall("compiled", js.ref(node), node.tfs ? "1" : void 0) : js.refToId(node.id, { kind: node.allowsCtx ? "Apply" : "Allows" }) };
|
|
2221
2395
|
var readValue = function (js, node) { return node.hasAlias ? writeCall("aliasedValue", readChecker(js, node), js.ref(node), `${(node.entersAlias ? 1 : 0) | (node.tfsById ? 2 : 0)}`) : readChecker(js, node) };
|
|
2222
2396
|
var readCase = function (js, node, member) { return member?.hasAlias ? writeCall("aliasedMember", readChecker(js, node), JSON.stringify(js.nameOf(member.id))) : readChecker(js, node) };
|
|
2397
|
+
var reachRootsOf = function (js, root) {
|
|
2398
|
+
for (const reference of root.references)
|
|
2399
|
+
if (reference.isRoot())
|
|
2400
|
+
js.link.byId[reference.id] ??= reference;
|
|
2401
|
+
};
|
|
2402
|
+
var unnarrowedByNode = /* @__PURE__ */ new WeakMap();
|
|
2403
|
+
var unnarrowedOf = function (node) {
|
|
2404
|
+
let unnarrowed = unnarrowedByNode.get(node);
|
|
2405
|
+
if (unnarrowed === void 0) {
|
|
2406
|
+
unnarrowed = null;
|
|
2407
|
+
if (node.basis && !node.structure && node.inner.predicate?.some(({ predicate }) => !isKeyword(predicate))) {
|
|
2408
|
+
const { predicate: _, ...inner } = node.inner;
|
|
2409
|
+
const checks = [node.basis, ...node.preStruct];
|
|
2410
|
+
const { message } = node.basis.meta;
|
|
2411
|
+
const root = node.$.node("intersection", typeof message === "string" && checks.every((check2) => check2.references.every((reference) => reference.meta.message === message)) ? { ...inner, meta: { message } } : inner);
|
|
2412
|
+
if (combines(root) && checkerDescriptionOf(root) === node.brief)
|
|
2413
|
+
unnarrowed = root;
|
|
2414
|
+
}
|
|
2415
|
+
unnarrowedByNode.set(node, unnarrowed);
|
|
2416
|
+
}
|
|
2417
|
+
return unnarrowed ?? void 0;
|
|
2418
|
+
};
|
|
2223
2419
|
var writeCombinator = function (js, node) {
|
|
2224
2420
|
if (!combines(node))
|
|
2225
2421
|
return;
|
|
2422
|
+
const said = saidByNode.get(node);
|
|
2423
|
+
if (said) {
|
|
2424
|
+
reachRootsOf(js, said.plain);
|
|
2425
|
+
return writeCall("saying", readChecker(js, said.plain), JSON.stringify(said.message));
|
|
2426
|
+
}
|
|
2226
2427
|
if (node.checksCtx)
|
|
2227
2428
|
return writeCall("readingCtx", writeChecker(js, node));
|
|
2228
2429
|
return writeChecker(js, node);
|
|
@@ -2247,15 +2448,21 @@ var writeMorph = function (js, node) { return writeCall("morphing", node.head ?
|
|
|
2247
2448
|
js.link.byId[step.id] ??= step;
|
|
2248
2449
|
return writeCall("piped", readChecker(js, step), step.reportsPred ? "1" : void 0);
|
|
2249
2450
|
}).join(", ")}]`) };
|
|
2451
|
+
var narrowedAfterOf = (node) => node.tfs ? "transformingNarrowedAfter" : "narrowedAfter";
|
|
2250
2452
|
var writeIntersectionCombinator = function (js, node) {
|
|
2251
2453
|
const shape = js.shapes && writeShape(js, node);
|
|
2252
2454
|
if (shape)
|
|
2253
2455
|
return shape;
|
|
2254
|
-
const refinements = node.preStruct.map((child) => writeCheck(js, child));
|
|
2255
|
-
const structure = node.structure && writeStructure(js, node.structure);
|
|
2256
2456
|
const predicates = node.inner.predicate?.map((predicate) => writePredicate(js, predicate));
|
|
2257
2457
|
const narrowed2 = predicates?.length === 1 ? predicates[0] : predicates && writeCall("narrowedByEach", `[${predicates.join(", ")}]`);
|
|
2258
|
-
const
|
|
2458
|
+
const unnarrowed = narrowed2 && unnarrowedOf(node);
|
|
2459
|
+
if (unnarrowed) {
|
|
2460
|
+
reachRootsOf(js, unnarrowed);
|
|
2461
|
+
return writeCall(narrowedAfterOf(unnarrowed), readChecker(js, unnarrowed), narrowed2);
|
|
2462
|
+
}
|
|
2463
|
+
const refinements = node.preStruct.map((child) => writeCheck(js, child));
|
|
2464
|
+
const structure = node.structure && writeStructure(js, node.structure);
|
|
2465
|
+
const within = structure && narrowed2 ? writeCall(narrowedAfterOf(node.structure), node.structure.hasAlias && node.structure.tfs && !node.structure.checksCtx ? writeCall("holdingAlias", structure) : structure, narrowed2) : structure ?? narrowed2;
|
|
2259
2466
|
if (within && !refinements.length && (!node.basis || (node.structure?.props.length || node.structure?.index) && isObjectCheck(node.basis)))
|
|
2260
2467
|
return within;
|
|
2261
2468
|
return writeCall("intersection", node.basis ? writeCheck(js, node.basis) : "0", `[${refinements.join(", ")}]`, within, node.basis && node.brief !== checkOf(node.basis).description ? JSON.stringify(node.brief) : void 0);
|
|
@@ -2265,7 +2472,12 @@ var writePredicate = function (js, node) {
|
|
|
2265
2472
|
if (isKeyword(node.predicate)) {
|
|
2266
2473
|
return writeCall("check", '"predicate"', JSON.stringify(predicateSiteOf(node).description), fn);
|
|
2267
2474
|
}
|
|
2268
|
-
return writeCall(
|
|
2475
|
+
return writeCall(
|
|
2476
|
+
// passed a ctx of its own, which reports at a site as a check does
|
|
2477
|
+
testsOrRejects2.has(node.predicate) ? "narrowedRejecting" : returnsReports.has(node.predicate) ? "narrowedWithCtx" : raisesNothing(node.predicate) ? "narrowedBy" : "narrowedInCtx",
|
|
2478
|
+
`() => ${fn}`,
|
|
2479
|
+
isNamedByItsFunction(node) ? void 0 : JSON.stringify(predicateSiteOf(node).description)
|
|
2480
|
+
);
|
|
2269
2481
|
};
|
|
2270
2482
|
var caseMember = (node, k) => node.discriminant.members?.[k];
|
|
2271
2483
|
var writeUnionCombinator = function (js, node) {
|
|
@@ -2293,7 +2505,11 @@ var writeUnionCombinator = function (js, node) {
|
|
|
2293
2505
|
return writeCall("nullable", checker, domain === "string" ? void 0 : JSON.stringify(domain));
|
|
2294
2506
|
}
|
|
2295
2507
|
}
|
|
2296
|
-
|
|
2508
|
+
const described = Object.entries(domains2).map(([domain2, branch], i) => [
|
|
2509
|
+
domain2,
|
|
2510
|
+
cases[i][1] === "1" ? 1 : { description: checkerDescriptionOf(branch) }
|
|
2511
|
+
]);
|
|
2512
|
+
return writeCall("domains", writeObject(cases.map(([domain2, branch]) => `${domain2}: ${branch}`)), described.every(([, branch]) => branch === 1 || branch.description !== void 0) && describeDomains(Object.fromEntries(described)) === description ? void 0 : JSON.stringify(description), fails);
|
|
2297
2513
|
}
|
|
2298
2514
|
const discriminated = discriminatedOf(node);
|
|
2299
2515
|
if (discriminated) {
|
|
@@ -2345,6 +2561,7 @@ var isCreatedByRuntime = function (members, baking) { return (
|
|
|
2345
2561
|
baking.detailsErrors && baking.freezes && baking.readsConfig && baking.holdsIds && defaultMembers.every((member) => members.has(member))
|
|
2346
2562
|
) };
|
|
2347
2563
|
var writeLazyRead = (name, initial) => `(${name} === undefined ? (${name} = ${initial}) : ${name})`;
|
|
2564
|
+
var internsByHolder = (baking) => baking.shortest && !baking.hoisted;
|
|
2348
2565
|
var writeValue = function (hoisted, name, expression, isPure) { return hoisted ? `var ${name}Value
|
|
2349
2566
|
function ${name}() {
|
|
2350
2567
|
return ${writeLazyRead(`${name}Value`, expression)}
|
|
@@ -2385,16 +2602,19 @@ var noIssueFeatures = {
|
|
|
2385
2602
|
reportsIndices: false,
|
|
2386
2603
|
bracketsKeys: false,
|
|
2387
2604
|
writesText: false,
|
|
2605
|
+
callsSiteText: false,
|
|
2388
2606
|
listsUnions: false,
|
|
2389
2607
|
rewritesUnions: false,
|
|
2390
2608
|
traversesUnions: false,
|
|
2391
|
-
readsKeySites: false,
|
|
2392
2609
|
appliesValues: false,
|
|
2393
2610
|
transformsBranches: false,
|
|
2394
2611
|
failsInBranches: false,
|
|
2395
2612
|
discriminatesBooleans: false,
|
|
2396
2613
|
readsSummary: false,
|
|
2397
|
-
readsErrors: false
|
|
2614
|
+
readsErrors: false,
|
|
2615
|
+
holdsExpression: false,
|
|
2616
|
+
namesTraversalError: false,
|
|
2617
|
+
findsOnRead: false
|
|
2398
2618
|
};
|
|
2399
2619
|
var compiledInputsOf = function (exports) {
|
|
2400
2620
|
const inputs = /* @__PURE__ */ new Set();
|
|
@@ -2453,12 +2673,13 @@ var bakingOf = function (exports, opts, isModular) {
|
|
|
2453
2673
|
jsonInput: opts.jsonInput === true,
|
|
2454
2674
|
hoisted: opts.hoisted === true,
|
|
2455
2675
|
shortest: opts.optimize === "size",
|
|
2676
|
+
strategy: opts.strategy ?? "",
|
|
2456
2677
|
defers: opts.defers === true && opts.lazy !== false && opts.optimize !== "size",
|
|
2457
2678
|
flattens: opts.optimize === "size" && opts.hoisted !== true && isModular,
|
|
2458
2679
|
combines: opts.combines !== false,
|
|
2459
2680
|
shapes: opts.shapes === true,
|
|
2460
2681
|
compiledInputs: opts.optimize === "size" ? compiledInputsOf(exports) : /* @__PURE__ */ new Set(),
|
|
2461
|
-
defersIssues: opts.optimize !== "size" && opts.called !== false,
|
|
2682
|
+
defersIssues: opts.defersIssues !== false && opts.optimize !== "size" && opts.called !== false,
|
|
2462
2683
|
bakedLimit: opts.bakedLimit ?? defaultBakedLimit,
|
|
2463
2684
|
called: opts.called !== false,
|
|
2464
2685
|
readsAllows: opts.readsAllows !== false,
|
|
@@ -2531,10 +2752,10 @@ var creatorFormOf = function (baking, form, applier, makes) {
|
|
|
2531
2752
|
const { members, ownsValidator, unconfigured, reads } = form;
|
|
2532
2753
|
const piped2 = reads.piped && form.pipes;
|
|
2533
2754
|
const failing = !piped2 ? "onFail" : baking.detailsErrors ? "(pipedFromCtx ? errors => pipedFromCtx.piped(errors) : onFail)" : void 0;
|
|
2534
|
-
const
|
|
2755
|
+
const inlined2 = failing && applier?.apply.startsWith(appliedSignature) && applier.apply.split(/\bonFail\b/).length <= 3 ? applier.apply.slice(appliedSignature.length).replace(/\bonFail\b/, failing) : void 0;
|
|
2535
2756
|
const precise = ownsValidator ? void 0 : preciseFormOf(baking, members, unconfigured, reads);
|
|
2536
2757
|
const isCalled = precise !== "object";
|
|
2537
|
-
const assertion = !isCalled ? `data => ${
|
|
2758
|
+
const assertion = !isCalled ? `data => ${inlined2 ? inlined2.replace(/\bonFail\b/, "runtime.throwOnDefault") : "rootApply(data, runtime.throwOnDefault)"}` : piped2 ? "(data, pipedFromCtx) => validator(data, pipedFromCtx, runtime.throwOnDefault)" : "data => validator(data, undefined, runtime.throwOnDefault)";
|
|
2538
2759
|
return {
|
|
2539
2760
|
...form,
|
|
2540
2761
|
applier,
|
|
@@ -2544,7 +2765,7 @@ var creatorFormOf = function (baking, form, applier, makes) {
|
|
|
2544
2765
|
hasAttributes: members.has("meta") || introspectionMembers.some((member) => members.has(member)),
|
|
2545
2766
|
piped: piped2,
|
|
2546
2767
|
failing,
|
|
2547
|
-
inlined,
|
|
2768
|
+
inlined: inlined2,
|
|
2548
2769
|
isCalled,
|
|
2549
2770
|
isApply: precise === "apply",
|
|
2550
2771
|
assertion,
|
|
@@ -2574,8 +2795,8 @@ var creatorBodyOf = function (baking, form) {
|
|
|
2574
2795
|
const standard = frozen(baking, `{
|
|
2575
2796
|
vendor: "arktype",
|
|
2576
2797
|
version: 1,
|
|
2577
|
-
validate: ${frozen(baking, "input => runtime.standardResultOf(validator(input))")}
|
|
2578
|
-
|
|
2798
|
+
validate: ${frozen(baking, "input => runtime.standardResultOf(validator(input))")}${members.has("~standard.jsonSchema") ? `,
|
|
2799
|
+
...attributes["~standard"]` : ""}
|
|
2579
2800
|
}`);
|
|
2580
2801
|
const call = creatorCallOf(baking, form);
|
|
2581
2802
|
return [
|
|
@@ -3124,6 +3345,15 @@ var sharedWritesOf = function (baking) {
|
|
|
3124
3345
|
}
|
|
3125
3346
|
return writes;
|
|
3126
3347
|
};
|
|
3348
|
+
var isDigestible = function (value) {
|
|
3349
|
+
if (!isPlainLiteral(value))
|
|
3350
|
+
return false;
|
|
3351
|
+
const keys = Reflect.ownKeys(value).filter((k) => !(k === "length" && Array.isArray(value)));
|
|
3352
|
+
return keys.length >= 4 && keys.every((k) => {
|
|
3353
|
+
const v = Reflect.get(value, k);
|
|
3354
|
+
return typeof k === "string" && typeof v !== "symbol" && typeof v !== "function" && !hasDomain6(v, "object");
|
|
3355
|
+
});
|
|
3356
|
+
};
|
|
3127
3357
|
var printedHolesByUnit = /* @__PURE__ */ new WeakMap();
|
|
3128
3358
|
var firstHoleName = new RegExp(holeNamePattern.source);
|
|
3129
3359
|
var printedHoleOf = function (unit2) {
|
|
@@ -3313,9 +3543,13 @@ var StandaloneArtifact = class {
|
|
|
3313
3543
|
cellModuleOf(cell) {
|
|
3314
3544
|
const specifier = cellSpecifierOf(cell);
|
|
3315
3545
|
const module = cell.text !== void 0 ? {
|
|
3316
|
-
readsRuntime:
|
|
3317
|
-
imports: {},
|
|
3318
|
-
|
|
3546
|
+
readsRuntime: true,
|
|
3547
|
+
imports: cell.imports ?? {},
|
|
3548
|
+
// through a call, as declared itself it would be named for the
|
|
3549
|
+
// variable, which a narrow with no description is described by
|
|
3550
|
+
declarations: [
|
|
3551
|
+
`var ${cell.name} = ${cell.rejects === void 0 ? `/* @__PURE__ */ runtime.unnamed(${cell.text})` : cell.text}`
|
|
3552
|
+
],
|
|
3319
3553
|
exports: [cell.name]
|
|
3320
3554
|
} : {
|
|
3321
3555
|
readsRuntime: false,
|
|
@@ -3370,7 +3604,8 @@ var StandaloneArtifact = class {
|
|
|
3370
3604
|
const classesArg = `, { ${Object.entries(classesOf((hole) => this.holeExpressions.get(hole))).map(([label, expression]) => `${JSON.stringify(label)}: ${expression}`).join(", ")} }`;
|
|
3371
3605
|
for (const [hole, kind, expression] of checked) {
|
|
3372
3606
|
const expected = factOfHole(hole, kind, classesOf((hole2) => hole2));
|
|
3373
|
-
|
|
3607
|
+
const label = this.labelArg(this.holeLabels.get(hole));
|
|
3608
|
+
this.checks.push(kind === "function" && typeof expected === "number" ? `runtime.checkArity(${expression}, ${expected}${label})` : `runtime.checkFacts(runtime.factOfHole(${expression}${kind === "function" ? "" : `, "${kind}"`}${kind === "class" ? classesArg : ""}), ${JSON.stringify(expected)}${label})`);
|
|
3374
3609
|
}
|
|
3375
3610
|
}
|
|
3376
3611
|
// a printed hole name resolves at creation; code can't depend on it
|
|
@@ -3388,7 +3623,7 @@ var StandaloneArtifact = class {
|
|
|
3388
3623
|
if (first === void 0)
|
|
3389
3624
|
holesByName[name] = hole;
|
|
3390
3625
|
else if (this.holeExpressions.get(hole) !== this.holeExpressions.get(first)) {
|
|
3391
|
-
this.checks.push(`runtime.checkFacts(${printedNameOf(hole)}, ${printedNameOf(first)}
|
|
3626
|
+
this.checks.push(`runtime.checkFacts(${printedNameOf(hole)}, ${printedNameOf(first)}${this.labelArg(this.holeLabels.get(hole))})`);
|
|
3392
3627
|
}
|
|
3393
3628
|
}
|
|
3394
3629
|
for (const unit2 of this.units) {
|
|
@@ -3412,11 +3647,17 @@ var StandaloneArtifact = class {
|
|
|
3412
3647
|
if (typeof hole === "function" && read(hole) === name)
|
|
3413
3648
|
return hole;
|
|
3414
3649
|
}
|
|
3650
|
+
// what names a value where a check of it throws, written after the check's
|
|
3651
|
+
// other arguments. A build written for size leaves it out: its checks
|
|
3652
|
+
// throw as often, saying "A value a validator reads" for what another names
|
|
3653
|
+
labelArg(label, after = "") {
|
|
3654
|
+
return this.baking.shortest ? after && `, undefined${after}` : `, ${JSON.stringify(label)}${after}`;
|
|
3655
|
+
}
|
|
3415
3656
|
// a hole received twice is checked by identity
|
|
3416
3657
|
receiveHole(hole, expression, label) {
|
|
3417
3658
|
const received = this.holeExpressions.get(hole);
|
|
3418
3659
|
if (received) {
|
|
3419
|
-
this.checks.push(`runtime.checkIdentity(${expression}, ${received}
|
|
3660
|
+
this.checks.push(`runtime.checkIdentity(${expression}, ${received}${this.labelArg(label, this.labelArg(this.holeLabels.get(hole)))})`);
|
|
3420
3661
|
return false;
|
|
3421
3662
|
}
|
|
3422
3663
|
this.holeExpressions.set(hole, this.heldFrom(expression));
|
|
@@ -3437,7 +3678,7 @@ var StandaloneArtifact = class {
|
|
|
3437
3678
|
if (!this.isComparedId(id))
|
|
3438
3679
|
throwInternalError2(`Comparing ${label}, whose id the scan didn't read`);
|
|
3439
3680
|
const kind = hasArkKind5(value, "root") ? "" : `, "${kindNameOf(value)}"`;
|
|
3440
|
-
const args = `${writeId(id)}
|
|
3681
|
+
const args = `${writeId(id)}${this.labelArg(label, kind)}`;
|
|
3441
3682
|
const name = `${receiverPrefix}${hashOf2(`runtime.holesOf(holder, ${args})`)}`;
|
|
3442
3683
|
this.importName(this.share(
|
|
3443
3684
|
name,
|
|
@@ -3468,7 +3709,7 @@ var StandaloneArtifact = class {
|
|
|
3468
3709
|
if (this.baking.checksTypes || holes.length || isWritable) {
|
|
3469
3710
|
this.checks.push(`${holes.length ? `const ${holesName} = ` : ""}${this.receiverOf(value, id, label)}(${expression})`);
|
|
3470
3711
|
} else if (keyed.length && mayBeUnset) {
|
|
3471
|
-
this.checks.push(`runtime.checkHeld(${expression}
|
|
3712
|
+
this.checks.push(`runtime.checkHeld(${expression}${this.labelArg(label, isType ? "" : `, "${kindNameOf(value)}"`)})`);
|
|
3472
3713
|
} else if (allHoles.length)
|
|
3473
3714
|
this.heldReads.push(`runtime.checkHeld(${expression})`);
|
|
3474
3715
|
const related = isType ? [value, ...value.references] : this.writtenNodes;
|
|
@@ -3481,7 +3722,7 @@ var StandaloneArtifact = class {
|
|
|
3481
3722
|
return;
|
|
3482
3723
|
}
|
|
3483
3724
|
if (!path.length && typeof value === "function") {
|
|
3484
|
-
this.checks.push(`runtime.checkFunction(${expression}
|
|
3725
|
+
this.checks.push(`runtime.checkFunction(${expression}${this.labelArg(label)})`);
|
|
3485
3726
|
return;
|
|
3486
3727
|
}
|
|
3487
3728
|
if (typeof value === "function" && functionNameOf3(value).includes(holeNameMarker3)) {
|
|
@@ -3493,7 +3734,7 @@ var StandaloneArtifact = class {
|
|
|
3493
3734
|
if (typeof value === "symbol") {
|
|
3494
3735
|
throwParseError4(writeUnprecompilableMessage(`${printable3(value)} read from ${label}`));
|
|
3495
3736
|
}
|
|
3496
|
-
this.checks.push(`runtime.checkInput(${expression}, ${this.emit(value)}
|
|
3737
|
+
this.checks.push(`runtime.checkInput(${expression}, ${this.emit(value)}${this.labelArg(label)})`);
|
|
3497
3738
|
return;
|
|
3498
3739
|
}
|
|
3499
3740
|
if (isStandardSchema(value)) {
|
|
@@ -3502,7 +3743,11 @@ var StandaloneArtifact = class {
|
|
|
3502
3743
|
if (arkKindOf2(value) !== void 0 || !(isPlainLiteral(value) || isDateObject2(value) || isRegExpObject2(value))) {
|
|
3503
3744
|
throwParseError4(writeUnprecompilableMessage(`${printable3(value)} read from ${label}`));
|
|
3504
3745
|
}
|
|
3505
|
-
this.
|
|
3746
|
+
if (!this.baking.checksTypes && isDigestible(value)) {
|
|
3747
|
+
this.checks.push(`runtime.checkDigest(${expression}, ${JSON.stringify(digestOf(value))}${this.labelArg(label)})`);
|
|
3748
|
+
return;
|
|
3749
|
+
}
|
|
3750
|
+
this.checks.push(`runtime.checkFacts(runtime.describeShape(${expression}), ${JSON.stringify(describeShape(value))}${this.labelArg(label)})`);
|
|
3506
3751
|
if (!isPlainLiteral(value))
|
|
3507
3752
|
return;
|
|
3508
3753
|
for (const k of Reflect.ownKeys(value)) {
|
|
@@ -3706,7 +3951,7 @@ var StandaloneArtifact = class {
|
|
|
3706
3951
|
const defaultKeys = defaults.length ? `, [${defaults.map(({ key }) => key).join(", ")}]` : "";
|
|
3707
3952
|
if (!holes)
|
|
3708
3953
|
return this.writeFactoryFunction(index, params, configured, body);
|
|
3709
|
-
const interned2 = `runtime.intern(${this.internTableOf(internedBy)}, [${holes.join(", ")}], ${this.baking.defers ? "function ()" : "() =>"} {
|
|
3954
|
+
const interned2 = `runtime.${this.internsByHolder ? "internIn" : "intern"}(${this.internTableOf(internedBy)}, [${holes.join(", ")}], ${this.baking.defers ? "function ()" : "() =>"} {
|
|
3710
3955
|
${body.filter((statement) => statement).join("\n\n")}
|
|
3711
3956
|
}${defaultKeys})`;
|
|
3712
3957
|
const bakedAfter = this.internsAcrossModules && this.validatorFormOf(type2).bakedAfter;
|
|
@@ -3737,7 +3982,14 @@ return ${attributes}
|
|
|
3737
3982
|
// created each; a validator holding none is interned where it's written
|
|
3738
3983
|
internTableOf(internedBy) {
|
|
3739
3984
|
const type2 = this.factory.type;
|
|
3740
|
-
return this.internsAcrossModules ? `runtime.internedTable(${JSON.stringify(this.internKeyOf(type2, this.validatorFormOf(type2)))})` : writeLazyRead(`interned${internedBy}`, "runtime.internTable()");
|
|
3985
|
+
return this.internsAcrossModules ? `runtime.internedTable(${JSON.stringify(this.internKeyOf(type2, this.validatorFormOf(type2)))})` : this.internsByHolder ? `interned${internedBy}` : writeLazyRead(`interned${internedBy}`, "runtime.internTable()");
|
|
3986
|
+
}
|
|
3987
|
+
// whether a factory's table is what an object its module declares keys in
|
|
3988
|
+
// the runtime, as a build written for size reads it: a factory it writes
|
|
3989
|
+
// is a const, which nothing reaches before its module declared the object,
|
|
3990
|
+
// so the table needn't be created by whichever call comes first
|
|
3991
|
+
get internsByHolder() {
|
|
3992
|
+
return internsByHolder(this.baking) && !this.internsAcrossModules;
|
|
3741
3993
|
}
|
|
3742
3994
|
get internsAcrossModules() {
|
|
3743
3995
|
const type2 = this.factory.type;
|
|
@@ -3757,9 +4009,18 @@ return ${attributes}
|
|
|
3757
4009
|
const { called, readsAllows, piped: piped2 } = form.reads;
|
|
3758
4010
|
return hashOf2(JSON.stringify([
|
|
3759
4011
|
named,
|
|
3760
|
-
// each module picks what's smallest for what it holds, and
|
|
3761
|
-
//
|
|
3762
|
-
|
|
4012
|
+
// each module picks what's smallest for what it holds, and each
|
|
4013
|
+
// site what it's optimized for, and a validator behaves alike
|
|
4014
|
+
// however it's written
|
|
4015
|
+
bakingKeyOf({
|
|
4016
|
+
...this.baking,
|
|
4017
|
+
combines: false,
|
|
4018
|
+
shapes: false,
|
|
4019
|
+
shortest: false,
|
|
4020
|
+
flattens: false,
|
|
4021
|
+
defersIssues: false,
|
|
4022
|
+
strategy: ""
|
|
4023
|
+
}),
|
|
3763
4024
|
[...form.members].sort(),
|
|
3764
4025
|
form.isTemplate,
|
|
3765
4026
|
called,
|
|
@@ -3862,7 +4123,7 @@ return namespace`
|
|
|
3862
4123
|
this.writeShared(unit2);
|
|
3863
4124
|
}
|
|
3864
4125
|
specifierOf(name) {
|
|
3865
|
-
return `~arktype/${this.baking.defers ? "deferred/" : ""}${this.baking.hoisted ? "hoisted/" : ""}${name}`;
|
|
4126
|
+
return `~arktype/${this.baking.strategy && `${this.baking.strategy}/`}${this.baking.defers ? "deferred/" : ""}${this.baking.hoisted ? "hoisted/" : ""}${name}`;
|
|
3866
4127
|
}
|
|
3867
4128
|
readValue(name) {
|
|
3868
4129
|
return this.baking.hoisted ? `${name}()` : name;
|
|
@@ -3907,7 +4168,7 @@ return namespace`
|
|
|
3907
4168
|
const links = writing.own.map((root) => {
|
|
3908
4169
|
const shape = writing.shapesByName[unit2.names[root.id]];
|
|
3909
4170
|
returned.push(shape);
|
|
3910
|
-
return
|
|
4171
|
+
return this.writeFilledShape(root, shape, unit2, this.traversalsOf(root, unit2));
|
|
3911
4172
|
});
|
|
3912
4173
|
const [moduleDeclarations, scope] = this.baking.flattens ? [this.writeFlatUnit(writing, refs, links)] : this.writeScopedUnit(writing, refs, links);
|
|
3913
4174
|
moduleDeclarations.push(...this.writeUnitNodes(writing));
|
|
@@ -4055,12 +4316,20 @@ return namespace`
|
|
|
4055
4316
|
const shape = writing.shapesByName[name];
|
|
4056
4317
|
const isChecker2 = this.isCheckerNode(root, unit2);
|
|
4057
4318
|
const readsCtx = this.writesCheckerNodes && root.allowsCtx;
|
|
4058
|
-
return writeValue(this.baking.hoisted, `${name}Node`, shape ? `${this.readValue(unit2.name)}[${returned.indexOf(shape)}]` : isChecker2 ? `runtime.checkerNode(${this.traversalsOf(root, unit2)[0]}${root.reportsPred ? ", true" : ""})` : readsCtx ? `runtime.
|
|
4059
|
-
this.writeShapeFlags(root, unit2),
|
|
4060
|
-
...this.traversalsOf(root, unit2)
|
|
4061
|
-
].join(", ")})` : `runtime.freeze(${this.writeShape(root, this.readValue(`${name}Node`), unit2, this.traversalsOf(root, unit2).map((traversal) => `${this.readValue(unit2.name)}[${returned.indexOf(traversal)}]`))})`, !shape && (isChecker2 || readsCtx));
|
|
4319
|
+
return writeValue(this.baking.hoisted, `${name}Node`, shape ? `${this.readValue(unit2.name)}[${returned.indexOf(shape)}]` : isChecker2 ? `runtime.checkerNode(${this.traversalsOf(root, unit2)[0]}${root.reportsPred ? ", true" : ""})` : readsCtx ? this.writeCtxNode(root, unit2) : `runtime.freeze(${this.writeShape(root, this.readValue(`${name}Node`), unit2, this.traversalsOf(root, unit2).map((traversal) => `${this.readValue(unit2.name)}[${returned.indexOf(traversal)}]`))})`, !shape && (isChecker2 || readsCtx));
|
|
4062
4320
|
});
|
|
4063
4321
|
}
|
|
4322
|
+
// a node reading its ctx, from its flags and traversals. Nearly each is of
|
|
4323
|
+
// a checker that only checks, whose Allows is declared from its Apply, so
|
|
4324
|
+
// the runtime creates that one's node from its Apply alone, and the Allows
|
|
4325
|
+
// is declared only for what else reads it
|
|
4326
|
+
writeCtxNode(root, unit2) {
|
|
4327
|
+
const flags = this.writeShapeFlags(root, unit2);
|
|
4328
|
+
const traversals = this.traversalsOf(root, unit2);
|
|
4329
|
+
const [allows, apply] = traversals;
|
|
4330
|
+
const reportsPred = flags === "{ checksCtx: true, reportsPred: true }";
|
|
4331
|
+
return traversals.length === 2 && (reportsPred || flags === "{ checksCtx: true }") && unit2.members.some(([name, source]) => name === allows && source === `/* @__PURE__ */ runtime.allowsReadingCtx(${apply})`) ? `runtime.readingCtxNode(${apply}${reportsPred ? ", true" : ""})` : `runtime.ctxNode(${[flags, ...traversals].join(", ")})`;
|
|
4332
|
+
}
|
|
4064
4333
|
// whether a node may be written as the checker declared beside it
|
|
4065
4334
|
get writesCheckerNodes() {
|
|
4066
4335
|
return this.baking.flattens && this.baking.detailsErrors && this.baking.combines;
|
|
@@ -4099,7 +4368,7 @@ return namespace`
|
|
|
4099
4368
|
if (/\bliteral\d+\b/.test(body))
|
|
4100
4369
|
return;
|
|
4101
4370
|
const descriptions = [];
|
|
4102
|
-
const shared = body.replace(/(
|
|
4371
|
+
const shared = body.replace(/(ctx\._e\(\w+, "(?:[^"\\]|\\.)*", |ctx\._k\((?:\w+, ){2}"(?:[^"\\]|\\.)*", |runtime\.failsKey\(ctx, \w+(?:, "(?:[^"\\]|\\.)*"){2}, )("(?:[^"\\]|\\.)*")\)/g, (_, call, description) => {
|
|
4103
4372
|
if (!descriptions.includes(description))
|
|
4104
4373
|
descriptions.push(description);
|
|
4105
4374
|
return `${call}d${descriptions.indexOf(description)})`;
|
|
@@ -4149,15 +4418,26 @@ return namespace`
|
|
|
4149
4418
|
return declarations;
|
|
4150
4419
|
}
|
|
4151
4420
|
// a ref read as its code runs, once the site holding the cell has, or a
|
|
4152
|
-
// cell holding its function's text, which a checker holds itself
|
|
4421
|
+
// cell holding its function's text, which a checker holds itself where the
|
|
4422
|
+
// function reads only its argument, or only tests it and rejects with a
|
|
4423
|
+
// message, importing what the text reads of other modules
|
|
4153
4424
|
readsCells(fn) {
|
|
4154
4425
|
if (!this.writing)
|
|
4155
4426
|
return fn;
|
|
4156
4427
|
const { cellReads, narrowedBy: narrowedBy2 } = this.writing;
|
|
4157
4428
|
const refs = [...Object.keys(cellReads), ...Object.keys(narrowedBy2)];
|
|
4158
|
-
return refs.length ? fn.replace(new RegExp(`(runtime\\.
|
|
4429
|
+
return refs.length ? fn.replace(new RegExp(`(runtime\\.narrowed(By|WithCtx|Rejecting)\\(\\(\\) => )?\\b(${refs.join("|")})\\b`, "g"), (_, narrows, kind, ref) => {
|
|
4159
4430
|
const cell = narrowedBy2[ref];
|
|
4160
|
-
|
|
4431
|
+
if (!cell)
|
|
4432
|
+
return `${narrows ?? ""}${cellReads[ref]}`;
|
|
4433
|
+
const held = kind === "By" ? cell.rejects === void 0 && `runtime.narrowed(${cell.text}` : kind && cell.rejects !== void 0 && `runtime.rejectsWith(${cell.rejects}`;
|
|
4434
|
+
if (!held)
|
|
4435
|
+
return `${narrows ?? ""}${this.readCell(cell)}`;
|
|
4436
|
+
for (const specifier in cell.imports) {
|
|
4437
|
+
for (const name of cell.imports[specifier])
|
|
4438
|
+
this.importName(specifier, name);
|
|
4439
|
+
}
|
|
4440
|
+
return held;
|
|
4161
4441
|
}) : fn;
|
|
4162
4442
|
}
|
|
4163
4443
|
// a module's only validator compiles as it loads, others at their first call
|
|
@@ -4452,8 +4732,10 @@ ${body}`)}`;
|
|
|
4452
4732
|
bakedMembersOf(root, baked) {
|
|
4453
4733
|
const members = [];
|
|
4454
4734
|
const bakes = (member) => baked.has(member);
|
|
4455
|
-
if (bakes("expression"))
|
|
4735
|
+
if (bakes("expression")) {
|
|
4736
|
+
this.baking.issues.holdsExpression = true;
|
|
4456
4737
|
members.push(`expression: ${this.emitExpression(root)}`);
|
|
4738
|
+
}
|
|
4457
4739
|
if (bakes("description"))
|
|
4458
4740
|
members.push(`description: ${this.emitDescription(root)}`);
|
|
4459
4741
|
if (bakes("json") || bakes("toJSON")) {
|
|
@@ -4794,7 +5076,9 @@ ${body}`)}`;
|
|
|
4794
5076
|
}
|
|
4795
5077
|
emitRootApply(root, opts) {
|
|
4796
5078
|
const { asValidator, readsAllows, unconfigured, throws } = opts;
|
|
4797
|
-
const
|
|
5079
|
+
const checks = isChecker(root, this.variantOf(root));
|
|
5080
|
+
const sitesRejections = checks && this.baking.detailsErrors && !root.hasAlias;
|
|
5081
|
+
const callbacks = declares(root, (node) => node.is("morph") || node.is("predicate") && !raisesNothing(node.predicate) && !(sitesRejections && testsOrRejects3.has(node.predicate)));
|
|
4798
5082
|
if (!this.baking.detailsErrors) {
|
|
4799
5083
|
return this.emitUndetailedApply(root, callbacks ? "Traversal" : "InternalTraversal", opts);
|
|
4800
5084
|
}
|
|
@@ -4809,13 +5093,15 @@ ${body}`)}`;
|
|
|
4809
5093
|
const [callErrors, elementErrors] = unreads ? ["runtime.unreadCallErrors", "runtime.unreadElements"] : ["runtime.applyCallErrors", "runtime.applyElements"];
|
|
4810
5094
|
const refOf = (param) => param === "Traversal" ? ctx === "Traversal" || ctx === "FirstIssueTraversal" ? this.emitRaisingTraversal(ctx) : `runtime.${ctx}` : param === "config" ? "runtime.runtimeConfig" : param === "TransformErrors" ? param : param === "applyRejected" ? appliesErrors ? "runtime.applyNodeErrors" : "runtime.applyRejected" : this.emit(rootApplyRuntime[param]);
|
|
4811
5095
|
const strategy = root.applyMode;
|
|
4812
|
-
const checks = isChecker(root, this.variantOf(root));
|
|
4813
5096
|
const isArrow = !root.hasAlias && (strategy === "allows" || strategy === "transform" && !root.hasMorph && (checks || !(root.is("union") && !root.discriminant)));
|
|
4814
5097
|
const tfs = strategy === "transform" && !checks;
|
|
4815
5098
|
const [flat, traversals] = isArrow && appliesErrors && !root.allowsCtx ? this.compactPartsOf(root, tfs ? [0, 1, 2] : [0, 1], asValidator) : [];
|
|
4816
5099
|
if (traversals) {
|
|
4817
|
-
|
|
5100
|
+
if (unreads)
|
|
5101
|
+
this.baking.issues.findsOnRead = true;
|
|
5102
|
+
const Ctx = refOf("Traversal");
|
|
4818
5103
|
const local = !Ctx.startsWith("runtime.");
|
|
5104
|
+
const passedCtx = unreads && Ctx === "runtime.ArkErrors" ? "" : `, ${Ctx}`;
|
|
4819
5105
|
const apply2 = this.appliedIndexOf(root) ? "apply" : "allows";
|
|
4820
5106
|
const pattern2 = flat ? [
|
|
4821
5107
|
...new Set(flat.map((_, i) => ["allows", apply2, "transform"][i]))
|
|
@@ -4833,9 +5119,9 @@ ${body}`)}`;
|
|
|
4833
5119
|
for (let i = 0; i < data.length; i++) if (!allowsElement(data[i])) return i
|
|
4834
5120
|
}`,
|
|
4835
5121
|
apply: `(data, ...args) => {
|
|
4836
|
-
if (!Array.isArray(data)) return ${callErrors}(apply, data, args, onFail
|
|
5122
|
+
if (!Array.isArray(data)) return ${callErrors}(apply, data, args, onFail${passedCtx})
|
|
4837
5123
|
const i = rejectedIn(data)
|
|
4838
|
-
return i === undefined ? data : ${elementErrors}(allowsElement, applyElement, i, data, args, onFail
|
|
5124
|
+
return i === undefined ? data : ${elementErrors}(allowsElement, applyElement, i, data, args, onFail${passedCtx})
|
|
4839
5125
|
}`,
|
|
4840
5126
|
args,
|
|
4841
5127
|
local
|
|
@@ -4849,7 +5135,7 @@ ${body}`)}`;
|
|
|
4849
5135
|
this.emitApplier({
|
|
4850
5136
|
readsAllows,
|
|
4851
5137
|
params: `${pattern2}${unconfigured ? "" : ", onFail"}`,
|
|
4852
|
-
apply: `(data, ...args) => allows(data) ? ${valid} : ${callErrors}(${apply2}, data, args
|
|
5138
|
+
apply: `(data, ...args) => allows(data) ? ${valid} : ${callErrors}(${apply2}, data, args${unconfigured ? passedCtx && ", null" : ", onFail"}${passedCtx})`,
|
|
4853
5139
|
args: parts,
|
|
4854
5140
|
local
|
|
4855
5141
|
}),
|
|
@@ -4860,7 +5146,7 @@ ${body}`)}`;
|
|
|
4860
5146
|
return [
|
|
4861
5147
|
{
|
|
4862
5148
|
params: pattern2,
|
|
4863
|
-
apply: `(data, onFail) => allows(data) ? ${valid} : ${unreads ? `runtime.unreadErrors(${apply2}, data, onFail
|
|
5149
|
+
apply: `(data, onFail) => allows(data) ? ${valid} : ${unreads ? `runtime.unreadErrors(${apply2}, data, onFail${passedCtx})` : !reportsIssues ? `runtime.applyErrors(${apply2}, data, ${refOf("config")}, onFail, ${Ctx})` : throws && !runsNarrow && !this.baking.shortest && Ctx === "runtime.ArkErrors" ? `runtime.throwIssues(${apply2}, data)` : `runtime.${runsNarrow ? "applyIssues" : "foundErrors"}(${apply2}, data, onFail${this.baking.firstIssue ? `, ${Ctx}` : ""})`}`,
|
|
4864
5150
|
args: parts,
|
|
4865
5151
|
local
|
|
4866
5152
|
},
|
|
@@ -5152,9 +5438,17 @@ ${args}`}`)}`;
|
|
|
5152
5438
|
return declared;
|
|
5153
5439
|
const shape = this.declareConst(node, "shape", "{}");
|
|
5154
5440
|
const traversals = unit2.traversals.flat();
|
|
5155
|
-
this.links.push(
|
|
5441
|
+
this.links.push(this.writeFilledShape(node, shape, unit2, this.traversalsOf(node, unit2).map((traversal) => `${this.localNamesByUnit.get(unit2)}[${traversals.indexOf(traversal)}]`)));
|
|
5156
5442
|
return shape;
|
|
5157
5443
|
}
|
|
5444
|
+
// a shape declared before the traversals that read it, filled once they're
|
|
5445
|
+
// declared. A size build has the runtime fill one reading its ctx, as each
|
|
5446
|
+
// would otherwise write the same members and the function answering allows
|
|
5447
|
+
writeFilledShape(node, shape, unit2, traversals) {
|
|
5448
|
+
if (this.baking.shortest && this.baking.detailsErrors && node.allowsCtx && traversals[1])
|
|
5449
|
+
return `runtime.ctxNode(${this.writeShapeFlags(node, unit2)}, ${traversals[0]}, ${traversals[1]}, ${traversals[2] ?? "void 0"}, ${shape})`;
|
|
5450
|
+
return `runtime.freeze(runtime.assign(${shape}, ${this.writeShape(node, shape, unit2, traversals)}))`;
|
|
5451
|
+
}
|
|
5158
5452
|
// what a node reading its ctx is told apart by
|
|
5159
5453
|
writeShapeFlags(node, unit2) {
|
|
5160
5454
|
const entries = shapeFlags.flatMap((flag) => flag !== "allowsCtx" && node[flag] ? [`${flag}: true`] : []);
|
|
@@ -5611,8 +5905,9 @@ ${writeExport(name, index2)}`;
|
|
|
5611
5905
|
const sections = [
|
|
5612
5906
|
...creations,
|
|
5613
5907
|
called.length ? `export { ${called.join(", ")} }` : "",
|
|
5614
|
-
// an import cycle can reach a factory before this
|
|
5615
|
-
|
|
5908
|
+
// an import cycle can reach a factory a function declares before this
|
|
5909
|
+
// runs, so only one written as a const reads a table by what's declared
|
|
5910
|
+
[...tables].map((table) => internsByHolder(baking) ? `const interned${table} = {}` : `var interned${table}`).join("\n"),
|
|
5616
5911
|
...factories.map((factory) => typeof factory === "string" ? factory : factory())
|
|
5617
5912
|
];
|
|
5618
5913
|
for (const [name, artifact] of artifactsByName)
|
|
@@ -5789,6 +6084,7 @@ export {
|
|
|
5789
6084
|
holdsOnlyMeta,
|
|
5790
6085
|
isCreatedByRuntime,
|
|
5791
6086
|
writeLazyRead,
|
|
6087
|
+
internsByHolder,
|
|
5792
6088
|
writeValue,
|
|
5793
6089
|
invalidErrorsOf,
|
|
5794
6090
|
appliedSignature,
|