typesea 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +45 -11
- package/dist/aot/index.d.ts +1 -1
- package/dist/aot/index.d.ts.map +1 -1
- package/dist/aot/index.js +22 -3
- package/dist/builders/composite.d.ts +6 -3
- package/dist/builders/composite.d.ts.map +1 -1
- package/dist/builders/composite.js +22 -13
- package/dist/builders/index.d.ts +6 -5
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +5 -4
- package/dist/builders/modifier.d.ts +6 -0
- package/dist/builders/modifier.d.ts.map +1 -1
- package/dist/builders/modifier.js +14 -0
- package/dist/builders/object/guard.d.ts +54 -2
- package/dist/builders/object/guard.d.ts.map +1 -1
- package/dist/builders/object/guard.js +117 -7
- package/dist/builders/object/index.d.ts +2 -2
- package/dist/builders/object/index.d.ts.map +1 -1
- package/dist/builders/object/index.js +1 -1
- package/dist/builders/object/schema.d.ts +33 -2
- package/dist/builders/object/schema.d.ts.map +1 -1
- package/dist/builders/object/schema.js +198 -8
- package/dist/builders/object/types.d.ts +15 -0
- package/dist/builders/object/types.d.ts.map +1 -1
- package/dist/builders/runtime.d.ts +40 -0
- package/dist/builders/runtime.d.ts.map +1 -0
- package/dist/builders/runtime.js +150 -0
- package/dist/builders/scalar.d.ts +20 -1
- package/dist/builders/scalar.d.ts.map +1 -1
- package/dist/builders/scalar.js +54 -1
- package/dist/builders/table.d.ts +31 -5
- package/dist/builders/table.d.ts.map +1 -1
- package/dist/builders/table.js +31 -5
- package/dist/builders/types.d.ts +6 -0
- package/dist/builders/types.d.ts.map +1 -1
- package/dist/compile/check-composite.d.ts +3 -1
- package/dist/compile/check-composite.d.ts.map +1 -1
- package/dist/compile/check-composite.js +143 -11
- package/dist/compile/check-scalar.d.ts +10 -0
- package/dist/compile/check-scalar.d.ts.map +1 -1
- package/dist/compile/check-scalar.js +138 -2
- package/dist/compile/check.d.ts.map +1 -1
- package/dist/compile/check.js +25 -3
- package/dist/compile/context.d.ts.map +1 -1
- package/dist/compile/context.js +2 -0
- package/dist/compile/first.d.ts +26 -0
- package/dist/compile/first.d.ts.map +1 -0
- package/dist/compile/first.js +850 -0
- package/dist/compile/graph-predicate.d.ts.map +1 -1
- package/dist/compile/graph-predicate.js +389 -18
- package/dist/compile/guard.d.ts +2 -1
- package/dist/compile/guard.d.ts.map +1 -1
- package/dist/compile/guard.js +54 -8
- package/dist/compile/predicate.d.ts.map +1 -1
- package/dist/compile/predicate.js +156 -5
- package/dist/compile/runtime.d.ts +20 -1
- package/dist/compile/runtime.d.ts.map +1 -1
- package/dist/compile/runtime.js +31 -0
- package/dist/compile/source.d.ts.map +1 -1
- package/dist/compile/source.js +27 -3
- package/dist/compile/types.d.ts +2 -0
- package/dist/compile/types.d.ts.map +1 -1
- package/dist/decoder/index.d.ts +60 -0
- package/dist/decoder/index.d.ts.map +1 -1
- package/dist/decoder/index.js +164 -1
- package/dist/evaluate/check-composite.d.ts +52 -2
- package/dist/evaluate/check-composite.d.ts.map +1 -1
- package/dist/evaluate/check-composite.js +193 -6
- package/dist/evaluate/check-scalar.d.ts +9 -0
- package/dist/evaluate/check-scalar.d.ts.map +1 -1
- package/dist/evaluate/check-scalar.js +92 -3
- package/dist/evaluate/check.d.ts.map +1 -1
- package/dist/evaluate/check.js +19 -4
- package/dist/evaluate/shared.d.ts +19 -0
- package/dist/evaluate/shared.d.ts.map +1 -1
- package/dist/evaluate/shared.js +35 -0
- package/dist/guard/array.d.ts +48 -0
- package/dist/guard/array.d.ts.map +1 -0
- package/dist/guard/array.js +84 -0
- package/dist/guard/base.d.ts +32 -2
- package/dist/guard/base.d.ts.map +1 -1
- package/dist/guard/base.js +74 -3
- package/dist/guard/date.d.ts +34 -0
- package/dist/guard/date.d.ts.map +1 -0
- package/dist/guard/date.js +60 -0
- package/dist/guard/index.d.ts +2 -0
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -0
- package/dist/guard/number.d.ts +60 -0
- package/dist/guard/number.d.ts.map +1 -1
- package/dist/guard/number.js +129 -0
- package/dist/guard/read.d.ts +53 -1
- package/dist/guard/read.d.ts.map +1 -1
- package/dist/guard/read.js +102 -0
- package/dist/guard/string.d.ts +82 -0
- package/dist/guard/string.d.ts.map +1 -1
- package/dist/guard/string.js +213 -0
- package/dist/guard/types.d.ts +18 -0
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/ir/builder.d.ts +3 -3
- package/dist/ir/builder.d.ts.map +1 -1
- package/dist/ir/builder.js +5 -2
- package/dist/ir/freeze.js +7 -0
- package/dist/ir/types.d.ts +4 -1
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/ir/validate.d.ts.map +1 -1
- package/dist/ir/validate.js +35 -1
- package/dist/issue/index.d.ts +1 -1
- package/dist/issue/index.d.ts.map +1 -1
- package/dist/issue/index.js +4 -0
- package/dist/json-schema/emit-composite.d.ts +6 -2
- package/dist/json-schema/emit-composite.d.ts.map +1 -1
- package/dist/json-schema/emit-composite.js +66 -12
- package/dist/json-schema/emit-scalar.d.ts.map +1 -1
- package/dist/json-schema/emit-scalar.js +54 -1
- package/dist/json-schema/emit.d.ts.map +1 -1
- package/dist/json-schema/emit.js +11 -2
- package/dist/json-schema/types.d.ts +7 -1
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/kind/index.d.ts +25 -0
- package/dist/kind/index.d.ts.map +1 -1
- package/dist/kind/index.js +26 -3
- package/dist/lower/index.d.ts.map +1 -1
- package/dist/lower/index.js +52 -3
- package/dist/message/index.d.ts +18 -0
- package/dist/message/index.d.ts.map +1 -1
- package/dist/message/index.js +67 -0
- package/dist/optimize/domain.js +6 -2
- package/dist/optimize/map-node.d.ts.map +1 -1
- package/dist/optimize/map-node.js +3 -0
- package/dist/plan/cache.js +13 -1
- package/dist/plan/predicate.d.ts.map +1 -1
- package/dist/plan/predicate.js +33 -3
- package/dist/plan/schema-predicate.d.ts.map +1 -1
- package/dist/plan/schema-predicate.js +267 -8
- package/dist/schema/freeze.js +22 -0
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +1 -1
- package/dist/schema/types.d.ts +89 -4
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +8 -1
- package/dist/schema/undefined.d.ts.map +1 -1
- package/dist/schema/undefined.js +5 -0
- package/dist/schema/validate.d.ts.map +1 -1
- package/dist/schema/validate.js +111 -4
- package/docs/api.md +71 -8
- package/docs/engine-notes.md +4 -0
- package/docs/index.html +1340 -722
- package/docs/ko/api.md +375 -0
- package/docs/ko/engine-notes.md +156 -0
- package/docs/ko/readme.md +378 -0
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-predicate.d.ts","sourceRoot":"","sources":["../../src/compile/graph-predicate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"graph-predicate.d.ts","sourceRoot":"","sources":["../../src/compile/graph-predicate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH,OAAO,EAIH,KAAK,MAAM,EACd,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAC;AA8G9D;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,aAAa,CAAC,EAAE,MAAM,GACvB,MAAM,CAoBR;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAS/D"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
5
5
|
* stable across runtime and AOT emission.
|
|
6
6
|
*/
|
|
7
|
-
import { NodeTag, ObjectModeTag, PresenceTag, SchemaTag } from "../kind/index.js";
|
|
7
|
+
import { ArrayCheckTag, NodeTag, ObjectModeTag, PresenceTag, SchemaTag } from "../kind/index.js";
|
|
8
8
|
import { makeValidationPlan } from "../plan/index.js";
|
|
9
9
|
import { schemaCanAcceptUndefined } from "../schema/index.js";
|
|
10
10
|
import { pushKeyset, pushLiteral, pushRegex, pushSchema, stringRef } from "./context.js";
|
|
@@ -271,7 +271,7 @@ function emitFalseCheck(graph, id, value, context, state) {
|
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
273
273
|
if (node?.tag === NodeTag.ArrayEvery) {
|
|
274
|
-
emitArrayEveryCheck(graph, node.value, node.item, node.itemGraph, value, context, state);
|
|
274
|
+
emitArrayEveryCheck(graph, node.value, node.item, node.checks, node.itemGraph, value, context, state);
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
277
277
|
if (node?.tag === NodeTag.TupleItems) {
|
|
@@ -279,7 +279,7 @@ function emitFalseCheck(graph, id, value, context, state) {
|
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
281
|
if (node?.tag === NodeTag.RecordEvery) {
|
|
282
|
-
emitRecordEveryCheck(graph, node.value, node.itemGraph, value, context, state);
|
|
282
|
+
emitRecordEveryCheck(graph, node.value, node.item, node.itemGraph, value, context, state);
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
285
|
if (node?.tag === NodeTag.PrimitiveUnion) {
|
|
@@ -329,9 +329,9 @@ function emitFalseCheck(graph, id, value, context, state) {
|
|
|
329
329
|
* @param state Mutable graph emitter state.
|
|
330
330
|
* @post Appends branch code to `state.chunks`.
|
|
331
331
|
*/
|
|
332
|
-
function emitArrayEveryCheck(graph, valueId, item, itemGraph, value, context, state) {
|
|
332
|
+
function emitArrayEveryCheck(graph, valueId, item, checks, itemGraph, value, context, state) {
|
|
333
333
|
if (isUnsafeMode(context)) {
|
|
334
|
-
emitUnsafeArrayEveryCheck(graph, valueId, itemGraph, value, context, state);
|
|
334
|
+
emitUnsafeArrayEveryCheck(graph, valueId, checks, itemGraph, value, context, state);
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
337
|
const arrayExpression = emitGraphExpression(graph, valueId, value, context, state);
|
|
@@ -342,6 +342,7 @@ function emitArrayEveryCheck(graph, valueId, item, itemGraph, value, context, st
|
|
|
342
342
|
const allowsUndefined = schemaCanAcceptUndefined(item);
|
|
343
343
|
const itemConstant = readGraphResultBoolean(itemGraph);
|
|
344
344
|
emitArrayGuard(arrayExpression, state);
|
|
345
|
+
emitArrayLengthChecks(arrayExpression, checks, state);
|
|
345
346
|
if (itemConstant === false) {
|
|
346
347
|
/*
|
|
347
348
|
* If the item graph is impossible, only an empty array can pass. This
|
|
@@ -358,7 +359,7 @@ function emitArrayEveryCheck(graph, valueId, item, itemGraph, value, context, st
|
|
|
358
359
|
emitPresentArrayEveryCheck(itemGraph, itemConstant, arrayExpression, context, state);
|
|
359
360
|
return;
|
|
360
361
|
}
|
|
361
|
-
state.chunks.push(`for(let ${index}=0;${index}<${arrayExpression}.length;${index}+=1){`, `const ${descriptor}=gp(${arrayExpression},${index});`, `if(${descriptor}===undefined
|
|
362
|
+
state.chunks.push(`for(let ${index}=0;${index}<${arrayExpression}.length;${index}+=1){`, `const ${descriptor}=gp(${arrayExpression},${index});`, `if(${descriptor}===undefined)${failStatement(state)}`);
|
|
362
363
|
if (itemConstant !== true) {
|
|
363
364
|
const itemValue = `v${String(state.temp)}`;
|
|
364
365
|
state.temp += 1;
|
|
@@ -410,12 +411,13 @@ function emitPresentArrayEveryCheck(itemGraph, itemConstant, arrayExpression, co
|
|
|
410
411
|
* @brief Execute emit unsafe array every check.
|
|
411
412
|
* @details Code generation helpers keep emitted JavaScript shape stable across runtime and AOT paths.
|
|
412
413
|
*/
|
|
413
|
-
function emitUnsafeArrayEveryCheck(graph, valueId, itemGraph, value, context, state) {
|
|
414
|
+
function emitUnsafeArrayEveryCheck(graph, valueId, checks, itemGraph, value, context, state) {
|
|
414
415
|
const arrayExpression = emitGraphExpression(graph, valueId, value, context, state);
|
|
415
416
|
const index = `i${String(state.temp)}`;
|
|
416
417
|
state.temp += 1;
|
|
417
418
|
const itemConstant = readGraphResultBoolean(itemGraph);
|
|
418
419
|
emitArrayGuard(arrayExpression, state);
|
|
420
|
+
emitArrayLengthChecks(arrayExpression, checks, state);
|
|
419
421
|
if (itemConstant === false) {
|
|
420
422
|
state.chunks.push(`if(${arrayExpression}.length!==0)${failStatement(state)}`);
|
|
421
423
|
return;
|
|
@@ -429,6 +431,30 @@ function emitUnsafeArrayEveryCheck(graph, valueId, itemGraph, value, context, st
|
|
|
429
431
|
emitFalseCheck(itemGraph, itemGraph.result, itemValue, context, state);
|
|
430
432
|
state.chunks.push("}");
|
|
431
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* @brief Emit array length failure branches.
|
|
436
|
+
* @param arrayExpression Generated expression already proven to be an array.
|
|
437
|
+
* @param checks Normalized array length checks.
|
|
438
|
+
* @param state Mutable graph emitter state.
|
|
439
|
+
* @post Appends no code when the schema has no length checks.
|
|
440
|
+
*/
|
|
441
|
+
function emitArrayLengthChecks(arrayExpression, checks, state) {
|
|
442
|
+
for (let index = 0; index < checks.length; index += 1) {
|
|
443
|
+
const check = checks[index];
|
|
444
|
+
if (check === undefined) {
|
|
445
|
+
state.chunks.push(failStatement(state));
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
switch (check.tag) {
|
|
449
|
+
case ArrayCheckTag.Min:
|
|
450
|
+
state.chunks.push(`if(${arrayExpression}.length<${String(check.value)})${failStatement(state)}`);
|
|
451
|
+
break;
|
|
452
|
+
case ArrayCheckTag.Max:
|
|
453
|
+
state.chunks.push(`if(${arrayExpression}.length>${String(check.value)})${failStatement(state)}`);
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
432
458
|
/**
|
|
433
459
|
* @brief emit tuple items check.
|
|
434
460
|
* @details Emission is isolated here so optimized graph nodes lower to stable JavaScript shapes across safe, unsafe, and unchecked modes.
|
|
@@ -465,7 +491,7 @@ function emitTupleItemsCheck(graph, valueId, items, itemGraphs, value, context,
|
|
|
465
491
|
state.chunks.push(`if(${descriptor}!==undefined&&!h.call(${descriptor},"value"))${failStatement(state)}`);
|
|
466
492
|
}
|
|
467
493
|
else {
|
|
468
|
-
state.chunks.push(`if(${descriptor}===undefined
|
|
494
|
+
state.chunks.push(`if(${descriptor}===undefined)${failStatement(state)}`);
|
|
469
495
|
}
|
|
470
496
|
if (itemConstant !== true) {
|
|
471
497
|
const itemValue = `v${String(state.temp)}`;
|
|
@@ -508,7 +534,7 @@ function emitUnsafeTupleItemsCheck(graph, valueId, itemGraphs, value, context, s
|
|
|
508
534
|
* @brief emit record every check.
|
|
509
535
|
* @details Emission is isolated here so optimized graph nodes lower to stable JavaScript shapes across safe, unsafe, and unchecked modes.
|
|
510
536
|
*/
|
|
511
|
-
function emitRecordEveryCheck(graph, valueId, itemGraph, value, context, state) {
|
|
537
|
+
function emitRecordEveryCheck(graph, valueId, item, itemGraph, value, context, state) {
|
|
512
538
|
if (isUnsafeMode(context)) {
|
|
513
539
|
emitUnsafeRecordEveryCheck(graph, valueId, itemGraph, value, context, state);
|
|
514
540
|
return;
|
|
@@ -519,12 +545,15 @@ function emitRecordEveryCheck(graph, valueId, itemGraph, value, context, state)
|
|
|
519
545
|
const descriptor = `d${String(state.temp)}`;
|
|
520
546
|
state.temp += 1;
|
|
521
547
|
const itemConstant = readGraphResultBoolean(itemGraph);
|
|
548
|
+
const rejectsUndefined = !schemaCanAcceptUndefined(item);
|
|
522
549
|
emitObjectGuard(recordExpression, state);
|
|
523
550
|
if (itemConstant === false) {
|
|
524
551
|
state.chunks.push(`for(const ${key} in ${recordExpression}){`, `if(h.call(${recordExpression},${key}))${failStatement(state)}`, "}");
|
|
525
552
|
return;
|
|
526
553
|
}
|
|
527
|
-
state.chunks.push(`for(const ${key} in ${recordExpression}){`, `if(!h.call(${recordExpression},${key}))continue;`, `const ${descriptor}=gp(${recordExpression},${key});`,
|
|
554
|
+
state.chunks.push(`for(const ${key} in ${recordExpression}){`, `if(!h.call(${recordExpression},${key}))continue;`, `const ${descriptor}=gp(${recordExpression},${key});`, rejectsUndefined
|
|
555
|
+
? `if(${descriptor}===undefined)${failStatement(state)}`
|
|
556
|
+
: `if(${descriptor}===undefined||!h.call(${descriptor},"value"))${failStatement(state)}`);
|
|
528
557
|
if (itemConstant !== true) {
|
|
529
558
|
const itemValue = `v${String(state.temp)}`;
|
|
530
559
|
state.temp += 1;
|
|
@@ -618,7 +647,7 @@ function emitDiscriminantDispatchReturn(graph, node, value, context, state) {
|
|
|
618
647
|
}
|
|
619
648
|
const descriptor = `d${String(state.temp)}`;
|
|
620
649
|
state.temp += 1;
|
|
621
|
-
state.chunks.push(objectGuardStatement(objectExpression, state), `const ${descriptor}=gp(${objectExpression},${stringRef(context, node.key)});`, `if(${descriptor}===undefined
|
|
650
|
+
state.chunks.push(objectGuardStatement(objectExpression, state), `const ${descriptor}=gp(${objectExpression},${stringRef(context, node.key)});`, `if(${descriptor}===undefined||typeof ${descriptor}.value!=="string")${failStatement(state)}`, `switch(${descriptor}.value){`);
|
|
622
651
|
markKnownObject(objectExpression, state);
|
|
623
652
|
for (let index = 0; index < node.graphs.length; index += 1) {
|
|
624
653
|
const childGraph = node.graphs[index];
|
|
@@ -1279,9 +1308,7 @@ function emitGraphExpression(graph, id, value, context, state) {
|
|
|
1279
1308
|
* Expression-mode code uses compact helpers. `eu` is the present-key
|
|
1280
1309
|
* variant; `ea` is the dense logical-slot variant.
|
|
1281
1310
|
*/
|
|
1282
|
-
return
|
|
1283
|
-
? `eu(${emitGraphExpression(graph, node.value, value, context, state)},${emitGraphChildFunction(node.itemGraph, context)})`
|
|
1284
|
-
: `ea(${emitGraphExpression(graph, node.value, value, context, state)},${emitGraphChildFunction(node.itemGraph, context)})`;
|
|
1311
|
+
return emitArrayEveryExpression(emitGraphExpression(graph, node.value, value, context, state), node, context);
|
|
1285
1312
|
case NodeTag.TupleItems:
|
|
1286
1313
|
return emitTupleItemsExpression(emitGraphExpression(graph, node.value, value, context, state), node.itemGraphs, context);
|
|
1287
1314
|
case NodeTag.RecordEvery:
|
|
@@ -1327,6 +1354,7 @@ function emitObjectShapeBody(node, value, context) {
|
|
|
1327
1354
|
emitObjectGuard(value, state);
|
|
1328
1355
|
const emittedStrictKeyCount = emitEarlyStrictKeyCount(node, value, context, state);
|
|
1329
1356
|
emitObjectShapeEntries(node, value, context, state);
|
|
1357
|
+
emitObjectShapeCatchall(node, value, context, state);
|
|
1330
1358
|
if (!emittedStrictKeyCount) {
|
|
1331
1359
|
emitObjectShapeStrictKeys(node, value, context, state);
|
|
1332
1360
|
}
|
|
@@ -1342,6 +1370,7 @@ function emitObjectShapeCheck(graph, node, value, context, state) {
|
|
|
1342
1370
|
emitObjectGuard(objectExpression, state);
|
|
1343
1371
|
const emittedStrictKeyCount = emitEarlyStrictKeyCount(node, objectExpression, context, state);
|
|
1344
1372
|
emitObjectShapeEntries(node, objectExpression, context, state);
|
|
1373
|
+
emitObjectShapeCatchall(node, objectExpression, context, state);
|
|
1345
1374
|
if (!emittedStrictKeyCount) {
|
|
1346
1375
|
emitObjectShapeStrictKeys(node, objectExpression, context, state);
|
|
1347
1376
|
}
|
|
@@ -1352,6 +1381,7 @@ function emitObjectShapeCheck(graph, node, value, context, state) {
|
|
|
1352
1381
|
*/
|
|
1353
1382
|
function emitEarlyStrictKeyCount(node, objectExpression, context, state) {
|
|
1354
1383
|
if (node.mode !== ObjectModeTag.Strict ||
|
|
1384
|
+
node.catchall !== undefined ||
|
|
1355
1385
|
!node.allRequired ||
|
|
1356
1386
|
isUnsafeMode(context)) {
|
|
1357
1387
|
return false;
|
|
@@ -1359,6 +1389,62 @@ function emitEarlyStrictKeyCount(node, objectExpression, context, state) {
|
|
|
1359
1389
|
state.chunks.push(`if(Object.getOwnPropertyNames(${objectExpression}).length!==${String(node.entries.length)}||Object.getOwnPropertySymbols(${objectExpression}).length!==0)${failStatement(state)}`);
|
|
1360
1390
|
return true;
|
|
1361
1391
|
}
|
|
1392
|
+
/**
|
|
1393
|
+
* @brief Emit catchall validation for undeclared own object keys.
|
|
1394
|
+
* @param node Object shape node with optional catchall graph.
|
|
1395
|
+
* @param objectExpression JavaScript object expression already proven object.
|
|
1396
|
+
* @param context Shared emission context.
|
|
1397
|
+
* @param state Mutable graph emitter state.
|
|
1398
|
+
*/
|
|
1399
|
+
function emitObjectShapeCatchall(node, objectExpression, context, state) {
|
|
1400
|
+
if (node.catchallGraph === undefined) {
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
if (isUnsafeMode(context)) {
|
|
1404
|
+
emitUnsafeObjectShapeCatchall(node, objectExpression, context, state);
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1407
|
+
const keys = `xs${String(state.temp)}`;
|
|
1408
|
+
state.temp += 1;
|
|
1409
|
+
const length = `n${String(state.temp)}`;
|
|
1410
|
+
state.temp += 1;
|
|
1411
|
+
const index = `i${String(state.temp)}`;
|
|
1412
|
+
state.temp += 1;
|
|
1413
|
+
const key = `key${String(state.temp)}`;
|
|
1414
|
+
state.temp += 1;
|
|
1415
|
+
const descriptor = `d${String(state.temp)}`;
|
|
1416
|
+
state.temp += 1;
|
|
1417
|
+
const itemValue = `v${String(state.temp)}`;
|
|
1418
|
+
state.temp += 1;
|
|
1419
|
+
state.chunks.push(`const ${keys}=Reflect.ownKeys(${objectExpression});`, `const ${length}=${keys}.length;`, `for(let ${index}=0;${index}<${length};${index}+=1){`, `const ${key}=${keys}[${index}];`, `if(typeof ${key}==="string"&&${keyMembershipExpression(key, node.keys, context)})continue;`, `const ${descriptor}=gp(${objectExpression},${key});`, `if(${descriptor}===undefined||!h.call(${descriptor},"value"))${failStatement(state)}`, `const ${itemValue}=${descriptor}.value;`);
|
|
1420
|
+
emitFalseCheck(node.catchallGraph, node.catchallGraph.result, itemValue, context, state);
|
|
1421
|
+
state.chunks.push("}");
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* @brief Emit unsafe catchall validation for undeclared own object keys.
|
|
1425
|
+
* @param node Object shape node with catchall graph.
|
|
1426
|
+
* @param objectExpression JavaScript object expression already proven object.
|
|
1427
|
+
* @param context Shared emission context.
|
|
1428
|
+
* @param state Mutable graph emitter state.
|
|
1429
|
+
*/
|
|
1430
|
+
function emitUnsafeObjectShapeCatchall(node, objectExpression, context, state) {
|
|
1431
|
+
if (node.catchallGraph === undefined) {
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
const keys = `xs${String(state.temp)}`;
|
|
1435
|
+
state.temp += 1;
|
|
1436
|
+
const length = `n${String(state.temp)}`;
|
|
1437
|
+
state.temp += 1;
|
|
1438
|
+
const index = `i${String(state.temp)}`;
|
|
1439
|
+
state.temp += 1;
|
|
1440
|
+
const key = `key${String(state.temp)}`;
|
|
1441
|
+
state.temp += 1;
|
|
1442
|
+
const itemValue = `v${String(state.temp)}`;
|
|
1443
|
+
state.temp += 1;
|
|
1444
|
+
state.chunks.push(`const ${keys}=Reflect.ownKeys(${objectExpression});`, `const ${length}=${keys}.length;`, `for(let ${index}=0;${index}<${length};${index}+=1){`, `const ${key}=${keys}[${index}];`, `if(typeof ${key}==="string"&&${unsafeKeyMembershipExpression(key, node.keys)})continue;`, `const ${itemValue}=${objectExpression}[${key}];`);
|
|
1445
|
+
emitFalseCheck(node.catchallGraph, node.catchallGraph.result, itemValue, context, state);
|
|
1446
|
+
state.chunks.push("}");
|
|
1447
|
+
}
|
|
1362
1448
|
/**
|
|
1363
1449
|
* @brief emit object shape entries.
|
|
1364
1450
|
* @details Emission is isolated here so optimized graph nodes lower to stable JavaScript shapes across safe, unsafe, and unchecked modes.
|
|
@@ -1368,8 +1454,9 @@ function emitObjectShapeEntries(node, objectExpression, context, state) {
|
|
|
1368
1454
|
emitUnsafeObjectShapeEntries(node, objectExpression, context, state);
|
|
1369
1455
|
return;
|
|
1370
1456
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1457
|
+
const entries = scheduleObjectShapeEntries(node.entries);
|
|
1458
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
1459
|
+
const entry = entries[index];
|
|
1373
1460
|
if (entry === undefined) {
|
|
1374
1461
|
state.chunks.push(failStatement(state));
|
|
1375
1462
|
continue;
|
|
@@ -1377,7 +1464,11 @@ function emitObjectShapeEntries(node, objectExpression, context, state) {
|
|
|
1377
1464
|
const cacheKey = dataSlotKey(node.value, entry.key, objectExpression);
|
|
1378
1465
|
const slot = emitDataSlotForExpression(node.value, entry.key, objectExpression, context, state);
|
|
1379
1466
|
if (entry.presence === PresenceTag.Optional) {
|
|
1380
|
-
|
|
1467
|
+
const rejectsUndefined = !schemaCanAcceptUndefined(entry.schema);
|
|
1468
|
+
state.chunks.push(`if(${slot.descriptor}!==undefined){`);
|
|
1469
|
+
if (!rejectsUndefined) {
|
|
1470
|
+
state.chunks.push(`if(!h.call(${slot.descriptor},"value"))${failStatement(state)}`);
|
|
1471
|
+
}
|
|
1381
1472
|
state.dataGuards.add(cacheKey);
|
|
1382
1473
|
const itemValue = emitDataSlotValue(cacheKey, slot, state);
|
|
1383
1474
|
emitFalseCheck(entry.graph, entry.graph.result, itemValue, context, state);
|
|
@@ -1385,7 +1476,10 @@ function emitObjectShapeEntries(node, objectExpression, context, state) {
|
|
|
1385
1476
|
}
|
|
1386
1477
|
else {
|
|
1387
1478
|
if (!state.dataGuards.has(cacheKey)) {
|
|
1388
|
-
|
|
1479
|
+
const rejectsUndefined = !schemaCanAcceptUndefined(entry.schema);
|
|
1480
|
+
state.chunks.push(rejectsUndefined
|
|
1481
|
+
? `if(${slot.descriptor}===undefined)${failStatement(state)}`
|
|
1482
|
+
: `if(${slot.descriptor}===undefined||!h.call(${slot.descriptor},"value"))${failStatement(state)}`);
|
|
1389
1483
|
state.dataGuards.add(cacheKey);
|
|
1390
1484
|
}
|
|
1391
1485
|
if (isKnownLiteralDataSlot(entry.schema, cacheKey, state)) {
|
|
@@ -1396,6 +1490,235 @@ function emitObjectShapeEntries(node, objectExpression, context, state) {
|
|
|
1396
1490
|
}
|
|
1397
1491
|
}
|
|
1398
1492
|
}
|
|
1493
|
+
/**
|
|
1494
|
+
* @brief Schedule pure object fields for predicate-only fast failure.
|
|
1495
|
+
* @details SchemaCheck nodes can run user code through refine or lazy fallback,
|
|
1496
|
+
* so they act as barriers. Pure fields between barriers may be reordered because
|
|
1497
|
+
* boolean validation has no diagnostic ordering contract.
|
|
1498
|
+
* @param entries Object shape entries in schema order.
|
|
1499
|
+
* @returns Entry view ordered for V8-friendly predicate emission.
|
|
1500
|
+
*/
|
|
1501
|
+
function scheduleObjectShapeEntries(entries) {
|
|
1502
|
+
if (entries.length < 2) {
|
|
1503
|
+
return entries;
|
|
1504
|
+
}
|
|
1505
|
+
const scheduled = [];
|
|
1506
|
+
let index = 0;
|
|
1507
|
+
while (index < entries.length) {
|
|
1508
|
+
const entry = entries[index];
|
|
1509
|
+
if (entry === undefined) {
|
|
1510
|
+
index += 1;
|
|
1511
|
+
continue;
|
|
1512
|
+
}
|
|
1513
|
+
if (!isSchedulableObjectShapeEntry(entry)) {
|
|
1514
|
+
scheduled.push(entry);
|
|
1515
|
+
index += 1;
|
|
1516
|
+
continue;
|
|
1517
|
+
}
|
|
1518
|
+
const run = [];
|
|
1519
|
+
while (index < entries.length) {
|
|
1520
|
+
const candidate = entries[index];
|
|
1521
|
+
if (candidate === undefined || !isSchedulableObjectShapeEntry(candidate)) {
|
|
1522
|
+
break;
|
|
1523
|
+
}
|
|
1524
|
+
run.push({
|
|
1525
|
+
entry: candidate,
|
|
1526
|
+
order: index
|
|
1527
|
+
});
|
|
1528
|
+
index += 1;
|
|
1529
|
+
}
|
|
1530
|
+
run.sort(compareScheduledObjectShapeEntries);
|
|
1531
|
+
for (let runIndex = 0; runIndex < run.length; runIndex += 1) {
|
|
1532
|
+
const scheduledEntry = run[runIndex];
|
|
1533
|
+
if (scheduledEntry !== undefined) {
|
|
1534
|
+
scheduled.push(scheduledEntry.entry);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
return scheduled;
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* @brief Compare two object entries for predicate emission.
|
|
1542
|
+
* @details Required fields can fail on absence and are therefore tested before
|
|
1543
|
+
* optional fields. Within the same presence class, cheaper child graphs run
|
|
1544
|
+
* first so invalid objects fail before arrays, records, or regex-heavy checks.
|
|
1545
|
+
* @param left Left scheduled entry.
|
|
1546
|
+
* @param right Right scheduled entry.
|
|
1547
|
+
* @returns Negative when left should be emitted before right.
|
|
1548
|
+
*/
|
|
1549
|
+
function compareScheduledObjectShapeEntries(left, right) {
|
|
1550
|
+
const leftPresence = objectShapePresenceCost(left.entry);
|
|
1551
|
+
const rightPresence = objectShapePresenceCost(right.entry);
|
|
1552
|
+
if (leftPresence !== rightPresence) {
|
|
1553
|
+
return leftPresence - rightPresence;
|
|
1554
|
+
}
|
|
1555
|
+
const leftCost = estimateGraphCost(left.entry.graph);
|
|
1556
|
+
const rightCost = estimateGraphCost(right.entry.graph);
|
|
1557
|
+
if (leftCost !== rightCost) {
|
|
1558
|
+
return leftCost - rightCost;
|
|
1559
|
+
}
|
|
1560
|
+
return left.order - right.order;
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* @brief Return whether an object entry may move within its pure run.
|
|
1564
|
+
* @details SchemaCheck is the IR boundary for user predicates and lazy
|
|
1565
|
+
* resolution. Keeping those entries fixed preserves observable user-code order.
|
|
1566
|
+
* @param entry Object shape entry under consideration.
|
|
1567
|
+
* @returns True when the entry graph has no opaque runtime callback.
|
|
1568
|
+
*/
|
|
1569
|
+
function isSchedulableObjectShapeEntry(entry) {
|
|
1570
|
+
return !graphContainsSchemaCheck(entry.graph);
|
|
1571
|
+
}
|
|
1572
|
+
/**
|
|
1573
|
+
* @brief Estimate object field presence cost.
|
|
1574
|
+
* @details Required fields receive the lower rank because missing required keys
|
|
1575
|
+
* are common fast-fail cases and optional absence usually succeeds.
|
|
1576
|
+
* @param entry Object shape entry.
|
|
1577
|
+
* @returns Numeric rank used before graph cost.
|
|
1578
|
+
*/
|
|
1579
|
+
function objectShapePresenceCost(entry) {
|
|
1580
|
+
return entry.presence === PresenceTag.Optional ? 1_000 : 0;
|
|
1581
|
+
}
|
|
1582
|
+
/**
|
|
1583
|
+
* @brief Estimate predicate cost for one child graph.
|
|
1584
|
+
* @details The values are intentionally coarse. The scheduler only needs stable
|
|
1585
|
+
* buckets that keep scalar checks before regexes and bounded loops.
|
|
1586
|
+
* @param graph Child graph emitted for one object field.
|
|
1587
|
+
* @returns Relative cost used by Tide scheduling.
|
|
1588
|
+
*/
|
|
1589
|
+
function estimateGraphCost(graph) {
|
|
1590
|
+
let cost = 0;
|
|
1591
|
+
for (let index = 0; index < graph.nodes.length; index += 1) {
|
|
1592
|
+
const node = graph.nodes[index];
|
|
1593
|
+
if (node !== undefined) {
|
|
1594
|
+
cost += estimateNodeCost(node);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
return cost;
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* @brief Estimate one node's predicate cost.
|
|
1601
|
+
* @details Compile-time scheduling only needs relative ordering, so the weights
|
|
1602
|
+
* favor V8-friendly scalar branches and push bounded or dynamic loops later.
|
|
1603
|
+
* @param node Graph node inspected by the scheduler.
|
|
1604
|
+
* @returns Relative node cost.
|
|
1605
|
+
*/
|
|
1606
|
+
function estimateNodeCost(node) {
|
|
1607
|
+
switch (node.tag) {
|
|
1608
|
+
case NodeTag.Start:
|
|
1609
|
+
case NodeTag.Param:
|
|
1610
|
+
case NodeTag.Const:
|
|
1611
|
+
case NodeTag.Return:
|
|
1612
|
+
return 0;
|
|
1613
|
+
case NodeTag.IsString:
|
|
1614
|
+
case NodeTag.IsNumber:
|
|
1615
|
+
case NodeTag.IsBoolean:
|
|
1616
|
+
case NodeTag.IsBigInt:
|
|
1617
|
+
case NodeTag.IsSymbol:
|
|
1618
|
+
case NodeTag.IsObject:
|
|
1619
|
+
case NodeTag.IsArray:
|
|
1620
|
+
case NodeTag.IsUndefined:
|
|
1621
|
+
case NodeTag.IsNull:
|
|
1622
|
+
case NodeTag.IsInteger:
|
|
1623
|
+
case NodeTag.StringMin:
|
|
1624
|
+
case NodeTag.StringMax:
|
|
1625
|
+
case NodeTag.Gte:
|
|
1626
|
+
case NodeTag.Lte:
|
|
1627
|
+
case NodeTag.Equals:
|
|
1628
|
+
return 1;
|
|
1629
|
+
case NodeTag.Regex:
|
|
1630
|
+
return 8;
|
|
1631
|
+
case NodeTag.PrimitiveUnion:
|
|
1632
|
+
case NodeTag.UnionDispatch:
|
|
1633
|
+
case NodeTag.DiscriminantDispatch:
|
|
1634
|
+
case NodeTag.ObjectShape:
|
|
1635
|
+
case NodeTag.TupleItems:
|
|
1636
|
+
return 16;
|
|
1637
|
+
case NodeTag.ArrayEvery:
|
|
1638
|
+
case NodeTag.RecordEvery:
|
|
1639
|
+
return 64;
|
|
1640
|
+
case NodeTag.SchemaCheck:
|
|
1641
|
+
return 128;
|
|
1642
|
+
default:
|
|
1643
|
+
return 2;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
/**
|
|
1647
|
+
* @brief Check whether a graph can enter user-controlled runtime logic.
|
|
1648
|
+
* @details Refine and lazy schemas lower to SchemaCheck nodes. Treating them as
|
|
1649
|
+
* scheduling barriers prevents pure field reordering from hiding side effects.
|
|
1650
|
+
* @param graph Child graph scanned for opaque checks.
|
|
1651
|
+
* @returns True when the graph contains a SchemaCheck node at some depth.
|
|
1652
|
+
*/
|
|
1653
|
+
function graphContainsSchemaCheck(graph) {
|
|
1654
|
+
for (let index = 0; index < graph.nodes.length; index += 1) {
|
|
1655
|
+
const node = graph.nodes[index];
|
|
1656
|
+
if (node === undefined) {
|
|
1657
|
+
continue;
|
|
1658
|
+
}
|
|
1659
|
+
if (node.tag === NodeTag.SchemaCheck) {
|
|
1660
|
+
return true;
|
|
1661
|
+
}
|
|
1662
|
+
if (nodeContainsSchemaCheck(node)) {
|
|
1663
|
+
return true;
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
return false;
|
|
1667
|
+
}
|
|
1668
|
+
/**
|
|
1669
|
+
* @brief Scan nested graphs owned by one node.
|
|
1670
|
+
* @details Composite IR nodes store child graphs by value, so barrier discovery
|
|
1671
|
+
* must recurse through those embedded validation graphs.
|
|
1672
|
+
* @param node Node whose embedded graphs are inspected.
|
|
1673
|
+
* @returns True when a nested graph contains SchemaCheck.
|
|
1674
|
+
*/
|
|
1675
|
+
function nodeContainsSchemaCheck(node) {
|
|
1676
|
+
switch (node.tag) {
|
|
1677
|
+
case NodeTag.ArrayEvery:
|
|
1678
|
+
case NodeTag.RecordEvery:
|
|
1679
|
+
return graphContainsSchemaCheck(node.itemGraph);
|
|
1680
|
+
case NodeTag.TupleItems:
|
|
1681
|
+
return graphArrayContainsSchemaCheck(node.itemGraphs);
|
|
1682
|
+
case NodeTag.ObjectShape:
|
|
1683
|
+
return objectEntriesContainSchemaCheck(node.entries);
|
|
1684
|
+
case NodeTag.DiscriminantDispatch:
|
|
1685
|
+
case NodeTag.UnionDispatch:
|
|
1686
|
+
case NodeTag.PrimitiveUnion:
|
|
1687
|
+
return graphArrayContainsSchemaCheck(node.graphs);
|
|
1688
|
+
default:
|
|
1689
|
+
return false;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
/**
|
|
1693
|
+
* @brief Scan a graph vector for SchemaCheck.
|
|
1694
|
+
* @details Undefined holes are ignored because they carry no executable graph.
|
|
1695
|
+
* @param graphs Child graph vector.
|
|
1696
|
+
* @returns True when a present graph contains SchemaCheck.
|
|
1697
|
+
*/
|
|
1698
|
+
function graphArrayContainsSchemaCheck(graphs) {
|
|
1699
|
+
for (let index = 0; index < graphs.length; index += 1) {
|
|
1700
|
+
const graph = graphs[index];
|
|
1701
|
+
if (graph !== undefined && graphContainsSchemaCheck(graph)) {
|
|
1702
|
+
return true;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
return false;
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* @brief Scan object entries for SchemaCheck.
|
|
1709
|
+
* @details Nested object shapes may appear inside scheduled parent fields.
|
|
1710
|
+
* @param entries Nested object shape entries.
|
|
1711
|
+
* @returns True when an entry graph contains an opaque check.
|
|
1712
|
+
*/
|
|
1713
|
+
function objectEntriesContainSchemaCheck(entries) {
|
|
1714
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
1715
|
+
const entry = entries[index];
|
|
1716
|
+
if (entry !== undefined && graphContainsSchemaCheck(entry.graph)) {
|
|
1717
|
+
return true;
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
return false;
|
|
1721
|
+
}
|
|
1399
1722
|
/**
|
|
1400
1723
|
* @brief Execute emit unsafe object shape entries.
|
|
1401
1724
|
* @details Code generation helpers keep emitted JavaScript shape stable across runtime and AOT paths.
|
|
@@ -1441,6 +1764,9 @@ function emitObjectShapeStrictKeys(node, objectExpression, context, state) {
|
|
|
1441
1764
|
if (node.mode !== ObjectModeTag.Strict) {
|
|
1442
1765
|
return;
|
|
1443
1766
|
}
|
|
1767
|
+
if (node.catchall !== undefined) {
|
|
1768
|
+
return;
|
|
1769
|
+
}
|
|
1444
1770
|
if (isUncheckedMode(context)) {
|
|
1445
1771
|
return;
|
|
1446
1772
|
}
|
|
@@ -2140,6 +2466,51 @@ function regexExpression(value, regex, context) {
|
|
|
2140
2466
|
function regexNeedsLastIndexReset(regex) {
|
|
2141
2467
|
return regex.global || regex.sticky;
|
|
2142
2468
|
}
|
|
2469
|
+
/**
|
|
2470
|
+
* @brief Emit compact expression-mode array iteration.
|
|
2471
|
+
* @param value Generated expression for the candidate array.
|
|
2472
|
+
* @param node ArrayEvery node with sparse-slot and length metadata.
|
|
2473
|
+
* @param context Shared code-generation context.
|
|
2474
|
+
* @returns Boolean JavaScript expression for array iteration.
|
|
2475
|
+
*/
|
|
2476
|
+
function emitArrayEveryExpression(value, node, context) {
|
|
2477
|
+
const loop = schemaCanAcceptUndefined(node.item)
|
|
2478
|
+
? `eu(${value},${emitGraphChildFunction(node.itemGraph, context)})`
|
|
2479
|
+
: `ea(${value},${emitGraphChildFunction(node.itemGraph, context)})`;
|
|
2480
|
+
const lengthParts = arrayLengthPredicateParts(value, node.checks);
|
|
2481
|
+
if (lengthParts.length === 0) {
|
|
2482
|
+
return loop;
|
|
2483
|
+
}
|
|
2484
|
+
return `(${lengthParts.join("&&")}&&${loop})`;
|
|
2485
|
+
}
|
|
2486
|
+
/**
|
|
2487
|
+
* @brief Build expression-mode array length predicates.
|
|
2488
|
+
* @param value Generated expression for the candidate array.
|
|
2489
|
+
* @param checks Normalized length check vector.
|
|
2490
|
+
* @returns Predicate fragments guarding safe `.length` access.
|
|
2491
|
+
*/
|
|
2492
|
+
function arrayLengthPredicateParts(value, checks) {
|
|
2493
|
+
if (checks.length === 0) {
|
|
2494
|
+
return [];
|
|
2495
|
+
}
|
|
2496
|
+
const parts = [`Array.isArray(${value})`];
|
|
2497
|
+
for (let index = 0; index < checks.length; index += 1) {
|
|
2498
|
+
const check = checks[index];
|
|
2499
|
+
if (check === undefined) {
|
|
2500
|
+
parts.push("false");
|
|
2501
|
+
continue;
|
|
2502
|
+
}
|
|
2503
|
+
switch (check.tag) {
|
|
2504
|
+
case ArrayCheckTag.Min:
|
|
2505
|
+
parts.push(`${value}.length>=${String(check.value)}`);
|
|
2506
|
+
break;
|
|
2507
|
+
case ArrayCheckTag.Max:
|
|
2508
|
+
parts.push(`${value}.length<=${String(check.value)}`);
|
|
2509
|
+
break;
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
return parts;
|
|
2513
|
+
}
|
|
2143
2514
|
/**
|
|
2144
2515
|
* @brief emit tuple items expression.
|
|
2145
2516
|
* @details Expression helpers centralize escaping, side-table references, and JavaScript corner cases so runtime and AOT output stay byte-for-byte consistent.
|
package/dist/compile/guard.d.ts
CHANGED
|
@@ -18,9 +18,10 @@ import type { CompileOptions, CompiledGuard } from "./types.js";
|
|
|
18
18
|
export declare class CompiledBaseGuard<TValue, TPresence extends Presence = "required"> extends BaseGuard<TValue, TPresence> implements CompiledGuard<TValue, TPresence> {
|
|
19
19
|
#private;
|
|
20
20
|
readonly source: string;
|
|
21
|
-
constructor(schema: Schema, test: BooleanPredicate, collect: IssueCollectorRoot, source: string, trustedCollector?: boolean, checkResult?: CheckResultRoot);
|
|
21
|
+
constructor(schema: Schema, test: BooleanPredicate, collect: IssueCollectorRoot, source: string, trustedCollector?: boolean, checkResult?: CheckResultRoot, checkFirstResult?: CheckResultRoot);
|
|
22
22
|
is(this: CompiledBaseGuard<TValue, TPresence>, value: unknown): value is RuntimeValue<TValue, TPresence>;
|
|
23
23
|
check(this: CompiledBaseGuard<TValue, TPresence>, value: unknown): CheckResult<RuntimeValue<TValue, TPresence>>;
|
|
24
|
+
checkFirst(this: CompiledBaseGuard<TValue, TPresence>, value: unknown): CheckResult<RuntimeValue<TValue, TPresence>>;
|
|
24
25
|
assert(this: CompiledBaseGuard<TValue, TPresence>, value: unknown): asserts value is RuntimeValue<TValue, TPresence>;
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/compile/guard.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACH,SAAS,EAET,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,YAAY,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAGH,KAAK,MAAM,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/compile/guard.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACH,SAAS,EAET,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,YAAY,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAGH,KAAK,MAAM,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAKH,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAER,cAAc,EACd,aAAa,EAChB,MAAM,YAAY,CAAC;AAMpB;;;;;GAKG;AACH,qBAAa,iBAAiB,CAC1B,MAAM,EACN,SAAS,SAAS,QAAQ,GAAG,UAAU,CACzC,SAAQ,SAAS,CAAC,MAAM,EAAE,SAAS,CAAE,YAAW,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC;;IAO9E,SAAwB,MAAM,EAAE,MAAM,CAAC;gBAGnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,MAAM,EACd,gBAAgB,UAAQ,EACxB,WAAW,CAAC,EAAE,eAAe,EAC7B,gBAAgB,CAAC,EAAE,eAAe;IAqCtB,EAAE,CACd,IAAI,EAAE,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,EAC1C,KAAK,EAAE,OAAO,GACf,KAAK,IAAI,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC;IAI3B,KAAK,CACjB,IAAI,EAAE,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,EAC1C,KAAK,EAAE,OAAO,GACf,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAW/B,UAAU,CACtB,IAAI,EAAE,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,EAC1C,KAAK,EAAE,OAAO,GACf,WAAW,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAW/B,MAAM,CAClB,IAAI,EAAE,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,EAC1C,KAAK,EAAE,OAAO,GACf,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC;CAYtD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,SAAS,QAAQ,EACtD,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,EAC/B,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAClC,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,CA2CtC"}
|