arktype 1.0.27-alpha → 1.1.0-dev-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/dist/main.d.ts +1018 -0
- package/dist/main.js +1450 -0
- package/package.json +36 -108
- package/LICENSE +0 -7
- package/README.md +0 -351
- package/dist/cjs/main.js +0 -38
- package/dist/cjs/nodes/branch.js +0 -140
- package/dist/cjs/nodes/compose.js +0 -163
- package/dist/cjs/nodes/discriminate.js +0 -265
- package/dist/cjs/nodes/node.js +0 -139
- package/dist/cjs/nodes/predicate.js +0 -86
- package/dist/cjs/nodes/rules/class.js +0 -25
- package/dist/cjs/nodes/rules/collapsibleSet.js +0 -48
- package/dist/cjs/nodes/rules/divisor.js +0 -29
- package/dist/cjs/nodes/rules/props.js +0 -167
- package/dist/cjs/nodes/rules/range.js +0 -105
- package/dist/cjs/nodes/rules/regex.js +0 -26
- package/dist/cjs/nodes/rules/rules.js +0 -123
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/parse/ast/ast.js +0 -4
- package/dist/cjs/parse/ast/bound.js +0 -16
- package/dist/cjs/parse/ast/config.js +0 -13
- package/dist/cjs/parse/ast/distributableFunction.js +0 -48
- package/dist/cjs/parse/ast/divisor.js +0 -9
- package/dist/cjs/parse/ast/intersection.js +0 -30
- package/dist/cjs/parse/ast/keyof.js +0 -111
- package/dist/cjs/parse/ast/morph.js +0 -58
- package/dist/cjs/parse/ast/narrow.js +0 -22
- package/dist/cjs/parse/ast/node.js +0 -4
- package/dist/cjs/parse/ast/tuple.js +0 -94
- package/dist/cjs/parse/ast/union.js +0 -9
- package/dist/cjs/parse/ast/utils.js +0 -4
- package/dist/cjs/parse/definition.js +0 -61
- package/dist/cjs/parse/record.js +0 -37
- package/dist/cjs/parse/string/reduce/dynamic.js +0 -167
- package/dist/cjs/parse/string/reduce/shared.js +0 -23
- package/dist/cjs/parse/string/reduce/static.js +0 -4
- package/dist/cjs/parse/string/shift/operand/enclosed.js +0 -54
- package/dist/cjs/parse/string/shift/operand/operand.js +0 -11
- package/dist/cjs/parse/string/shift/operand/unenclosed.js +0 -53
- package/dist/cjs/parse/string/shift/operator/bounds.js +0 -87
- package/dist/cjs/parse/string/shift/operator/divisor.js +0 -35
- package/dist/cjs/parse/string/shift/operator/operator.js +0 -26
- package/dist/cjs/parse/string/shift/scanner.js +0 -114
- package/dist/cjs/parse/string/string.js +0 -43
- package/dist/cjs/scopes/ark.js +0 -45
- package/dist/cjs/scopes/cache.js +0 -52
- package/dist/cjs/scopes/expressions.js +0 -29
- package/dist/cjs/scopes/jsObjects.js +0 -93
- package/dist/cjs/scopes/scope.js +0 -323
- package/dist/cjs/scopes/tsKeywords.js +0 -113
- package/dist/cjs/scopes/type.js +0 -50
- package/dist/cjs/scopes/validation/creditCard.js +0 -47
- package/dist/cjs/scopes/validation/date.js +0 -62
- package/dist/cjs/scopes/validation/validation.js +0 -108
- package/dist/cjs/traverse/problems.js +0 -281
- package/dist/cjs/traverse/traverse.js +0 -390
- package/dist/cjs/utils/chainableNoOpProxy.js +0 -23
- package/dist/cjs/utils/data.js +0 -53
- package/dist/cjs/utils/domains.js +0 -30
- package/dist/cjs/utils/errors.js +0 -26
- package/dist/cjs/utils/freeze.js +0 -15
- package/dist/cjs/utils/generics.js +0 -63
- package/dist/cjs/utils/numericLiterals.js +0 -75
- package/dist/cjs/utils/objectKinds.js +0 -69
- package/dist/cjs/utils/paths.js +0 -32
- package/dist/cjs/utils/serialize.js +0 -74
- package/dist/cjs/utils/unionToTuple.js +0 -4
- package/dist/mjs/main.js +0 -8
- package/dist/mjs/nodes/branch.js +0 -123
- package/dist/mjs/nodes/compose.js +0 -141
- package/dist/mjs/nodes/discriminate.js +0 -250
- package/dist/mjs/nodes/node.js +0 -117
- package/dist/mjs/nodes/predicate.js +0 -69
- package/dist/mjs/nodes/rules/class.js +0 -11
- package/dist/mjs/nodes/rules/collapsibleSet.js +0 -34
- package/dist/mjs/nodes/rules/divisor.js +0 -15
- package/dist/mjs/nodes/rules/props.js +0 -149
- package/dist/mjs/nodes/rules/range.js +0 -86
- package/dist/mjs/nodes/rules/regex.js +0 -11
- package/dist/mjs/nodes/rules/rules.js +0 -106
- package/dist/mjs/package.json +0 -3
- package/dist/mjs/parse/ast/ast.js +0 -1
- package/dist/mjs/parse/ast/bound.js +0 -2
- package/dist/mjs/parse/ast/config.js +0 -9
- package/dist/mjs/parse/ast/distributableFunction.js +0 -34
- package/dist/mjs/parse/ast/divisor.js +0 -1
- package/dist/mjs/parse/ast/intersection.js +0 -16
- package/dist/mjs/parse/ast/keyof.js +0 -103
- package/dist/mjs/parse/ast/morph.js +0 -44
- package/dist/mjs/parse/ast/narrow.js +0 -14
- package/dist/mjs/parse/ast/node.js +0 -1
- package/dist/mjs/parse/ast/tuple.js +0 -80
- package/dist/mjs/parse/ast/union.js +0 -1
- package/dist/mjs/parse/ast/utils.js +0 -1
- package/dist/mjs/parse/definition.js +0 -46
- package/dist/mjs/parse/record.js +0 -29
- package/dist/mjs/parse/string/reduce/dynamic.js +0 -159
- package/dist/mjs/parse/string/reduce/shared.js +0 -6
- package/dist/mjs/parse/string/reduce/static.js +0 -1
- package/dist/mjs/parse/string/shift/operand/enclosed.js +0 -39
- package/dist/mjs/parse/string/shift/operand/operand.js +0 -3
- package/dist/mjs/parse/string/shift/operand/unenclosed.js +0 -36
- package/dist/mjs/parse/string/shift/operator/bounds.js +0 -70
- package/dist/mjs/parse/string/shift/operator/divisor.js +0 -21
- package/dist/mjs/parse/string/shift/operator/operator.js +0 -13
- package/dist/mjs/parse/string/shift/scanner.js +0 -106
- package/dist/mjs/parse/string/string.js +0 -28
- package/dist/mjs/scopes/ark.js +0 -28
- package/dist/mjs/scopes/cache.js +0 -38
- package/dist/mjs/scopes/expressions.js +0 -89
- package/dist/mjs/scopes/jsObjects.js +0 -82
- package/dist/mjs/scopes/scope.js +0 -303
- package/dist/mjs/scopes/tsKeywords.js +0 -116
- package/dist/mjs/scopes/type.js +0 -35
- package/dist/mjs/scopes/validation/creditCard.js +0 -34
- package/dist/mjs/scopes/validation/date.js +0 -48
- package/dist/mjs/scopes/validation/validation.js +0 -112
- package/dist/mjs/traverse/problems.js +0 -260
- package/dist/mjs/traverse/traverse.js +0 -373
- package/dist/mjs/utils/chainableNoOpProxy.js +0 -15
- package/dist/mjs/utils/data.js +0 -38
- package/dist/mjs/utils/domains.js +0 -15
- package/dist/mjs/utils/errors.js +0 -10
- package/dist/mjs/utils/freeze.js +0 -7
- package/dist/mjs/utils/generics.js +0 -38
- package/dist/mjs/utils/numericLiterals.js +0 -72
- package/dist/mjs/utils/objectKinds.js +0 -55
- package/dist/mjs/utils/paths.js +0 -18
- package/dist/mjs/utils/serialize.js +0 -58
- package/dist/mjs/utils/unionToTuple.js +0 -1
- package/dist/tsconfig.temp.tsbuildinfo +0 -1
- package/dist/types/main.d.ts +0 -15
- package/dist/types/nodes/branch.d.ts +0 -29
- package/dist/types/nodes/compose.d.ts +0 -98
- package/dist/types/nodes/discriminate.d.ts +0 -26
- package/dist/types/nodes/node.d.ts +0 -69
- package/dist/types/nodes/predicate.d.ts +0 -18
- package/dist/types/nodes/rules/class.d.ts +0 -4
- package/dist/types/nodes/rules/collapsibleSet.d.ts +0 -4
- package/dist/types/nodes/rules/divisor.d.ts +0 -3
- package/dist/types/nodes/rules/props.d.ts +0 -43
- package/dist/types/nodes/rules/range.d.ts +0 -34
- package/dist/types/nodes/rules/regex.d.ts +0 -5
- package/dist/types/nodes/rules/rules.d.ts +0 -33
- package/dist/types/parse/ast/ast.d.ts +0 -24
- package/dist/types/parse/ast/bound.d.ts +0 -27
- package/dist/types/parse/ast/config.d.ts +0 -15
- package/dist/types/parse/ast/distributableFunction.d.ts +0 -18
- package/dist/types/parse/ast/divisor.d.ts +0 -13
- package/dist/types/parse/ast/intersection.d.ts +0 -31
- package/dist/types/parse/ast/keyof.d.ts +0 -10
- package/dist/types/parse/ast/morph.d.ts +0 -17
- package/dist/types/parse/ast/narrow.d.ts +0 -21
- package/dist/types/parse/ast/node.d.ts +0 -35
- package/dist/types/parse/ast/tuple.d.ts +0 -41
- package/dist/types/parse/ast/union.d.ts +0 -17
- package/dist/types/parse/ast/utils.d.ts +0 -7
- package/dist/types/parse/definition.d.ts +0 -30
- package/dist/types/parse/record.d.ts +0 -26
- package/dist/types/parse/string/reduce/dynamic.d.ts +0 -34
- package/dist/types/parse/string/reduce/shared.d.ts +0 -25
- package/dist/types/parse/string/reduce/static.d.ts +0 -130
- package/dist/types/parse/string/shift/operand/enclosed.d.ts +0 -28
- package/dist/types/parse/string/shift/operand/operand.d.ts +0 -9
- package/dist/types/parse/string/shift/operand/unenclosed.d.ts +0 -18
- package/dist/types/parse/string/shift/operator/bounds.d.ts +0 -21
- package/dist/types/parse/string/shift/operator/divisor.d.ts +0 -13
- package/dist/types/parse/string/shift/operator/operator.d.ts +0 -13
- package/dist/types/parse/string/shift/scanner.d.ts +0 -89
- package/dist/types/parse/string/string.d.ts +0 -25
- package/dist/types/scopes/ark.d.ts +0 -208
- package/dist/types/scopes/cache.d.ts +0 -14
- package/dist/types/scopes/expressions.d.ts +0 -136
- package/dist/types/scopes/jsObjects.d.ts +0 -26
- package/dist/types/scopes/scope.d.ts +0 -99
- package/dist/types/scopes/tsKeywords.d.ts +0 -50
- package/dist/types/scopes/type.d.ts +0 -67
- package/dist/types/scopes/validation/creditCard.d.ts +0 -2
- package/dist/types/scopes/validation/date.d.ts +0 -23
- package/dist/types/scopes/validation/validation.d.ts +0 -49
- package/dist/types/traverse/problems.d.ts +0 -88
- package/dist/types/traverse/traverse.d.ts +0 -55
- package/dist/types/utils/chainableNoOpProxy.d.ts +0 -14
- package/dist/types/utils/data.d.ts +0 -13
- package/dist/types/utils/domains.d.ts +0 -32
- package/dist/types/utils/errors.d.ts +0 -6
- package/dist/types/utils/freeze.d.ts +0 -2
- package/dist/types/utils/generics.d.ts +0 -125
- package/dist/types/utils/numericLiterals.d.ts +0 -46
- package/dist/types/utils/objectKinds.d.ts +0 -84
- package/dist/types/utils/paths.d.ts +0 -9
- package/dist/types/utils/serialize.d.ts +0 -37
- package/dist/types/utils/unionToTuple.d.ts +0 -11
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
parseUnenclosed: ()=>parseUnenclosed,
|
|
13
|
-
writeUnresolvableMessage: ()=>writeUnresolvableMessage,
|
|
14
|
-
writeMissingOperandMessage: ()=>writeMissingOperandMessage,
|
|
15
|
-
writeMissingRightOperandMessage: ()=>writeMissingRightOperandMessage,
|
|
16
|
-
writeExpressionExpectedMessage: ()=>writeExpressionExpectedMessage
|
|
17
|
-
});
|
|
18
|
-
const _numericLiteralsJs = require("../../../../utils/numericLiterals.js");
|
|
19
|
-
const parseUnenclosed = (s)=>{
|
|
20
|
-
const token = s.scanner.shiftUntilNextTerminator();
|
|
21
|
-
s.setRoot(unenclosedToNode(s, token));
|
|
22
|
-
};
|
|
23
|
-
const unenclosedToNode = (s, token)=>{
|
|
24
|
-
if (s.ctx.type.scope.addParsedReferenceIfResolvable(token, s.ctx)) {
|
|
25
|
-
return token;
|
|
26
|
-
}
|
|
27
|
-
return maybeParseUnenclosedLiteral(token) ?? s.error(token === "" ? writeMissingOperandMessage(s) : writeUnresolvableMessage(token));
|
|
28
|
-
};
|
|
29
|
-
const maybeParseUnenclosedLiteral = (token)=>{
|
|
30
|
-
const maybeNumber = (0, _numericLiteralsJs.tryParseWellFormedNumber)(token);
|
|
31
|
-
if (maybeNumber !== undefined) {
|
|
32
|
-
return {
|
|
33
|
-
number: {
|
|
34
|
-
value: maybeNumber
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const maybeBigint = (0, _numericLiteralsJs.tryParseWellFormedBigint)(token);
|
|
39
|
-
if (maybeBigint !== undefined) {
|
|
40
|
-
return {
|
|
41
|
-
bigint: {
|
|
42
|
-
value: maybeBigint
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const writeUnresolvableMessage = (token)=>`'${token}' is unresolvable`;
|
|
48
|
-
const writeMissingOperandMessage = (s)=>{
|
|
49
|
-
const operator = s.previousOperator();
|
|
50
|
-
return operator ? writeMissingRightOperandMessage(operator, s.scanner.unscanned) : writeExpressionExpectedMessage(s.scanner.unscanned);
|
|
51
|
-
};
|
|
52
|
-
const writeMissingRightOperandMessage = (token, unscanned)=>`Token '${token}' requires a right operand${unscanned ? ` before '${unscanned}'` : ""}`;
|
|
53
|
-
const writeExpressionExpectedMessage = (unscanned)=>`Expected an expression${unscanned ? ` before '${unscanned}'` : ""}`;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
parseBound: ()=>parseBound,
|
|
13
|
-
singleEqualsMessage: ()=>singleEqualsMessage,
|
|
14
|
-
parseRightBound: ()=>parseRightBound,
|
|
15
|
-
writeInvalidLimitMessage: ()=>writeInvalidLimitMessage,
|
|
16
|
-
writeEmptyRangeMessage: ()=>writeEmptyRangeMessage
|
|
17
|
-
});
|
|
18
|
-
const _composeJs = require("../../../../nodes/compose.js");
|
|
19
|
-
const _rangeJs = require("../../../../nodes/rules/range.js");
|
|
20
|
-
const _errorsJs = require("../../../../utils/errors.js");
|
|
21
|
-
const _genericsJs = require("../../../../utils/generics.js");
|
|
22
|
-
const _numericLiteralsJs = require("../../../../utils/numericLiterals.js");
|
|
23
|
-
const _boundJs = require("../../../ast/bound.js");
|
|
24
|
-
const _sharedJs = require("../../reduce/shared.js");
|
|
25
|
-
const _scannerJs = require("../scanner.js");
|
|
26
|
-
const parseBound = (s, start)=>{
|
|
27
|
-
const comparator = shiftComparator(s, start);
|
|
28
|
-
const maybeMin = s.ejectRootIfLimit();
|
|
29
|
-
return maybeMin === undefined ? parseRightBound(s, comparator) : s.reduceLeftBound(maybeMin, comparator);
|
|
30
|
-
};
|
|
31
|
-
const shiftComparator = (s, start)=>s.scanner.lookaheadIs("=") ? `${start}${s.scanner.shift()}` : (0, _genericsJs.isKeyOf)(start, _scannerJs.Scanner.oneCharComparators) ? start : s.error(singleEqualsMessage);
|
|
32
|
-
const singleEqualsMessage = `= is not a valid comparator. Use == to check for equality`;
|
|
33
|
-
const parseRightBound = (s, comparator)=>{
|
|
34
|
-
const limitToken = s.scanner.shiftUntilNextTerminator();
|
|
35
|
-
const limit = (0, _numericLiteralsJs.tryParseWellFormedNumber)(limitToken, writeInvalidLimitMessage(comparator, limitToken + s.scanner.unscanned));
|
|
36
|
-
const openRange = s.ejectRangeIfOpen();
|
|
37
|
-
const rightBound = {
|
|
38
|
-
comparator,
|
|
39
|
-
limit
|
|
40
|
-
};
|
|
41
|
-
const range = openRange ? !hasComparatorIn(rightBound, _rangeJs.maxComparators) ? s.error((0, _sharedJs.writeUnpairableComparatorMessage)(comparator)) : (0, _rangeJs.compareStrictness)("min", openRange, rightBound) === "l" ? s.error(writeEmptyRangeMessage({
|
|
42
|
-
min: openRange,
|
|
43
|
-
max: rightBound
|
|
44
|
-
})) : {
|
|
45
|
-
min: openRange,
|
|
46
|
-
max: rightBound
|
|
47
|
-
} : hasComparator(rightBound, "==") ? rightBound : hasComparatorIn(rightBound, _rangeJs.minComparators) ? {
|
|
48
|
-
min: rightBound
|
|
49
|
-
} : hasComparatorIn(rightBound, _rangeJs.maxComparators) ? {
|
|
50
|
-
max: rightBound
|
|
51
|
-
} : (0, _errorsJs.throwInternalError)(`Unexpected comparator '${rightBound.comparator}'`);
|
|
52
|
-
s.intersect(distributeRange(range, s));
|
|
53
|
-
};
|
|
54
|
-
const distributeRange = (range, s)=>{
|
|
55
|
-
const resolution = s.resolveRoot();
|
|
56
|
-
const domains = (0, _genericsJs.objectKeysOf)(resolution);
|
|
57
|
-
const distributedRange = {};
|
|
58
|
-
const rangePredicate = {
|
|
59
|
-
range
|
|
60
|
-
};
|
|
61
|
-
const isBoundable = domains.every((domain)=>{
|
|
62
|
-
switch(domain){
|
|
63
|
-
case "string":
|
|
64
|
-
distributedRange.string = rangePredicate;
|
|
65
|
-
return true;
|
|
66
|
-
case "number":
|
|
67
|
-
distributedRange.number = rangePredicate;
|
|
68
|
-
return true;
|
|
69
|
-
case "object":
|
|
70
|
-
distributedRange.object = rangePredicate;
|
|
71
|
-
if (resolution.object === true) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
return (0, _genericsJs.listFrom)(resolution.object).every((branch)=>"class" in branch && branch.class === Array);
|
|
75
|
-
default:
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
if (!isBoundable) {
|
|
80
|
-
s.error((0, _boundJs.writeUnboundableMessage)(s.rootToString()));
|
|
81
|
-
}
|
|
82
|
-
return distributedRange;
|
|
83
|
-
};
|
|
84
|
-
const hasComparator = (bound, comparator)=>bound.comparator === comparator;
|
|
85
|
-
const hasComparatorIn = (bound, comparators)=>bound.comparator in comparators;
|
|
86
|
-
const writeInvalidLimitMessage = (comparator, limit)=>`Comparator ${comparator} must be followed by a number literal (was '${limit}')`;
|
|
87
|
-
const writeEmptyRangeMessage = (range)=>`${(0, _composeJs.stringifyRange)(range)} is empty`;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
parseDivisor: ()=>parseDivisor,
|
|
13
|
-
writeInvalidDivisorMessage: ()=>writeInvalidDivisorMessage
|
|
14
|
-
});
|
|
15
|
-
const _genericsJs = require("../../../../utils/generics.js");
|
|
16
|
-
const _numericLiteralsJs = require("../../../../utils/numericLiterals.js");
|
|
17
|
-
const _divisorJs = require("../../../ast/divisor.js");
|
|
18
|
-
const parseDivisor = (s)=>{
|
|
19
|
-
const divisorToken = s.scanner.shiftUntilNextTerminator();
|
|
20
|
-
const divisor = (0, _numericLiteralsJs.tryParseWellFormedInteger)(divisorToken, writeInvalidDivisorMessage(divisorToken));
|
|
21
|
-
if (divisor === 0) {
|
|
22
|
-
s.error(writeInvalidDivisorMessage(0));
|
|
23
|
-
}
|
|
24
|
-
const rootDomains = (0, _genericsJs.objectKeysOf)(s.resolveRoot());
|
|
25
|
-
if (rootDomains.length === 1 && rootDomains[0] === "number") {
|
|
26
|
-
s.intersect({
|
|
27
|
-
number: {
|
|
28
|
-
divisor
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
} else {
|
|
32
|
-
s.error((0, _divisorJs.writeIndivisibleMessage)(s.rootToString()));
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const writeInvalidDivisorMessage = (divisor)=>`% operator must be followed by a non-zero integer literal (was ${divisor})`;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
parseOperator: ()=>parseOperator,
|
|
13
|
-
writeUnexpectedCharacterMessage: ()=>writeUnexpectedCharacterMessage,
|
|
14
|
-
incompleteArrayTokenMessage: ()=>incompleteArrayTokenMessage
|
|
15
|
-
});
|
|
16
|
-
const _errorsJs = require("../../../../utils/errors.js");
|
|
17
|
-
const _genericsJs = require("../../../../utils/generics.js");
|
|
18
|
-
const _scannerJs = require("../scanner.js");
|
|
19
|
-
const _boundsJs = require("./bounds.js");
|
|
20
|
-
const _divisorJs = require("./divisor.js");
|
|
21
|
-
const parseOperator = (s)=>{
|
|
22
|
-
const lookahead = s.scanner.shift();
|
|
23
|
-
return lookahead === "" ? s.finalize() : lookahead === "[" ? s.scanner.shift() === "]" ? s.rootToArray() : s.error(incompleteArrayTokenMessage) : (0, _genericsJs.isKeyOf)(lookahead, _scannerJs.Scanner.branchTokens) ? s.pushRootToBranch(lookahead) : lookahead === ")" ? s.finalizeGroup() : (0, _genericsJs.isKeyOf)(lookahead, _scannerJs.Scanner.comparatorStartChars) ? (0, _boundsJs.parseBound)(s, lookahead) : lookahead === "%" ? (0, _divisorJs.parseDivisor)(s) : lookahead === " " ? parseOperator(s) : (0, _errorsJs.throwInternalError)(writeUnexpectedCharacterMessage(lookahead));
|
|
24
|
-
};
|
|
25
|
-
const writeUnexpectedCharacterMessage = (char)=>`Unexpected character '${char}'`;
|
|
26
|
-
const incompleteArrayTokenMessage = `Missing expected ']'`;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "Scanner", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: ()=>Scanner
|
|
8
|
-
});
|
|
9
|
-
function _defineProperty(obj, key, value) {
|
|
10
|
-
if (key in obj) {
|
|
11
|
-
Object.defineProperty(obj, key, {
|
|
12
|
-
value: value,
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true
|
|
16
|
-
});
|
|
17
|
-
} else {
|
|
18
|
-
obj[key] = value;
|
|
19
|
-
}
|
|
20
|
-
return obj;
|
|
21
|
-
}
|
|
22
|
-
class Scanner {
|
|
23
|
-
/** Get lookahead and advance scanner by one */ shift() {
|
|
24
|
-
return this.chars[this.i++] ?? "";
|
|
25
|
-
}
|
|
26
|
-
get lookahead() {
|
|
27
|
-
return this.chars[this.i] ?? "";
|
|
28
|
-
}
|
|
29
|
-
shiftUntil(condition) {
|
|
30
|
-
let shifted = "";
|
|
31
|
-
while(this.lookahead){
|
|
32
|
-
if (condition(this, shifted)) {
|
|
33
|
-
if (shifted[shifted.length - 1] === Scanner.escapeToken) {
|
|
34
|
-
shifted = shifted.slice(0, -1);
|
|
35
|
-
} else {
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
shifted += this.shift();
|
|
40
|
-
}
|
|
41
|
-
return shifted;
|
|
42
|
-
}
|
|
43
|
-
shiftUntilNextTerminator() {
|
|
44
|
-
this.shiftUntil(Scanner.lookaheadIsNotWhitespace);
|
|
45
|
-
return this.shiftUntil(Scanner.lookaheadIsTerminator);
|
|
46
|
-
}
|
|
47
|
-
get unscanned() {
|
|
48
|
-
return this.chars.slice(this.i, this.chars.length).join("");
|
|
49
|
-
}
|
|
50
|
-
lookaheadIs(char) {
|
|
51
|
-
return this.lookahead === char;
|
|
52
|
-
}
|
|
53
|
-
lookaheadIsIn(tokens) {
|
|
54
|
-
return this.lookahead in tokens;
|
|
55
|
-
}
|
|
56
|
-
constructor(def){
|
|
57
|
-
_defineProperty(this, "chars", void 0);
|
|
58
|
-
_defineProperty(this, "i", void 0);
|
|
59
|
-
_defineProperty(this, "finalized", false);
|
|
60
|
-
this.chars = [
|
|
61
|
-
...def
|
|
62
|
-
];
|
|
63
|
-
this.i = 0;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
(function(Scanner) {
|
|
67
|
-
var lookaheadIsTerminator = Scanner.lookaheadIsTerminator = (scanner)=>scanner.lookahead in terminatingChars;
|
|
68
|
-
var lookaheadIsNotWhitespace = Scanner.lookaheadIsNotWhitespace = (scanner)=>scanner.lookahead !== whiteSpaceToken;
|
|
69
|
-
var comparatorStartChars = Scanner.comparatorStartChars = {
|
|
70
|
-
"<": true,
|
|
71
|
-
">": true,
|
|
72
|
-
"=": true
|
|
73
|
-
};
|
|
74
|
-
var terminatingChars = Scanner.terminatingChars = {
|
|
75
|
-
...comparatorStartChars,
|
|
76
|
-
"|": true,
|
|
77
|
-
"&": true,
|
|
78
|
-
")": true,
|
|
79
|
-
"[": true,
|
|
80
|
-
"%": true,
|
|
81
|
-
" ": true
|
|
82
|
-
};
|
|
83
|
-
var comparators = Scanner.comparators = {
|
|
84
|
-
"<": true,
|
|
85
|
-
">": true,
|
|
86
|
-
"<=": true,
|
|
87
|
-
">=": true,
|
|
88
|
-
"==": true
|
|
89
|
-
};
|
|
90
|
-
var oneCharComparators = Scanner.oneCharComparators = {
|
|
91
|
-
"<": true,
|
|
92
|
-
">": true
|
|
93
|
-
};
|
|
94
|
-
var comparatorDescriptions = Scanner.comparatorDescriptions = {
|
|
95
|
-
"<": "less than",
|
|
96
|
-
">": "more than",
|
|
97
|
-
"<=": "at most",
|
|
98
|
-
">=": "at least",
|
|
99
|
-
"==": "exactly"
|
|
100
|
-
};
|
|
101
|
-
var invertedComparators = Scanner.invertedComparators = {
|
|
102
|
-
"<": ">",
|
|
103
|
-
">": "<",
|
|
104
|
-
"<=": ">=",
|
|
105
|
-
">=": "<=",
|
|
106
|
-
"==": "=="
|
|
107
|
-
};
|
|
108
|
-
var branchTokens = Scanner.branchTokens = {
|
|
109
|
-
"|": true,
|
|
110
|
-
"&": true
|
|
111
|
-
};
|
|
112
|
-
var escapeToken = Scanner.escapeToken = "\\";
|
|
113
|
-
var whiteSpaceToken = Scanner.whiteSpaceToken = " ";
|
|
114
|
-
})(Scanner || (Scanner = {}));
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
parseString: ()=>parseString,
|
|
13
|
-
maybeNaiveParse: ()=>maybeNaiveParse,
|
|
14
|
-
fullStringParse: ()=>fullStringParse
|
|
15
|
-
});
|
|
16
|
-
const _nodeJs = require("../../nodes/node.js");
|
|
17
|
-
const _dynamicJs = require("./reduce/dynamic.js");
|
|
18
|
-
const _operandJs = require("./shift/operand/operand.js");
|
|
19
|
-
const _operatorJs = require("./shift/operator/operator.js");
|
|
20
|
-
const parseString = (def, ctx)=>ctx.type.scope.parseCache.get(def) ?? ctx.type.scope.parseCache.set(def, maybeNaiveParse(def, ctx) ?? fullStringParse(def, ctx));
|
|
21
|
-
const maybeNaiveParse = (def, ctx)=>{
|
|
22
|
-
if (ctx.type.scope.addParsedReferenceIfResolvable(def, ctx)) {
|
|
23
|
-
return def;
|
|
24
|
-
}
|
|
25
|
-
if (def.endsWith("[]")) {
|
|
26
|
-
const elementDef = def.slice(0, -2);
|
|
27
|
-
if (ctx.type.scope.addParsedReferenceIfResolvable(def, ctx)) {
|
|
28
|
-
return (0, _nodeJs.toArrayNode)(elementDef);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const fullStringParse = (def, ctx)=>{
|
|
33
|
-
const s = new _dynamicJs.DynamicState(def, ctx);
|
|
34
|
-
(0, _operandJs.parseOperand)(s);
|
|
35
|
-
return loop(s);
|
|
36
|
-
};
|
|
37
|
-
const loop = (s)=>{
|
|
38
|
-
while(!s.scanner.finalized){
|
|
39
|
-
next(s);
|
|
40
|
-
}
|
|
41
|
-
return s.ejectFinalizedRoot();
|
|
42
|
-
};
|
|
43
|
-
const next = (s)=>s.hasRoot() ? (0, _operatorJs.parseOperator)(s) : (0, _operandJs.parseOperand)(s);
|
package/dist/cjs/scopes/ark.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
arkScope: ()=>arkScope,
|
|
13
|
-
ark: ()=>ark,
|
|
14
|
-
scopes: ()=>scopes,
|
|
15
|
-
spaces: ()=>spaces,
|
|
16
|
-
type: ()=>type
|
|
17
|
-
});
|
|
18
|
-
const _jsObjectsJs = require("./jsObjects.js");
|
|
19
|
-
const _scopeJs = require("./scope.js");
|
|
20
|
-
const _tsKeywordsJs = require("./tsKeywords.js");
|
|
21
|
-
const _validationJs = require("./validation/validation.js");
|
|
22
|
-
const arkScope = (0, _scopeJs.scope)({}, {
|
|
23
|
-
name: "standard",
|
|
24
|
-
includes: [
|
|
25
|
-
_tsKeywordsJs.tsKeywords,
|
|
26
|
-
_jsObjectsJs.jsObjects,
|
|
27
|
-
_validationJs.validation
|
|
28
|
-
],
|
|
29
|
-
standard: false
|
|
30
|
-
});
|
|
31
|
-
const ark = arkScope.compile();
|
|
32
|
-
const scopes = {
|
|
33
|
-
root: _scopeJs.rootScope,
|
|
34
|
-
tsKeywords: _tsKeywordsJs.tsKeywordsScope,
|
|
35
|
-
jsObjects: _jsObjectsJs.jsObjectsScope,
|
|
36
|
-
validation: _validationJs.validationScope,
|
|
37
|
-
ark: arkScope
|
|
38
|
-
};
|
|
39
|
-
const spaces = {
|
|
40
|
-
tsKeywords: _tsKeywordsJs.tsKeywords,
|
|
41
|
-
jsObjects: _jsObjectsJs.jsObjects,
|
|
42
|
-
validation: _validationJs.validation,
|
|
43
|
-
ark
|
|
44
|
-
};
|
|
45
|
-
const type = arkScope.type;
|
package/dist/cjs/scopes/cache.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
Cache: ()=>Cache,
|
|
13
|
-
FreezingCache: ()=>FreezingCache
|
|
14
|
-
});
|
|
15
|
-
const _freezeJs = require("../utils/freeze.js");
|
|
16
|
-
function _defineProperty(obj, key, value) {
|
|
17
|
-
if (key in obj) {
|
|
18
|
-
Object.defineProperty(obj, key, {
|
|
19
|
-
value: value,
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true
|
|
23
|
-
});
|
|
24
|
-
} else {
|
|
25
|
-
obj[key] = value;
|
|
26
|
-
}
|
|
27
|
-
return obj;
|
|
28
|
-
}
|
|
29
|
-
class Cache {
|
|
30
|
-
get root() {
|
|
31
|
-
return this.cache;
|
|
32
|
-
}
|
|
33
|
-
has(name) {
|
|
34
|
-
return name in this.cache;
|
|
35
|
-
}
|
|
36
|
-
get(name) {
|
|
37
|
-
return this.cache[name];
|
|
38
|
-
}
|
|
39
|
-
set(name, item) {
|
|
40
|
-
this.cache[name] = item;
|
|
41
|
-
return item;
|
|
42
|
-
}
|
|
43
|
-
constructor(){
|
|
44
|
-
_defineProperty(this, "cache", {});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
class FreezingCache extends Cache {
|
|
48
|
-
set(name, item) {
|
|
49
|
-
this.cache[name] = (0, _freezeJs.deepFreeze)(item);
|
|
50
|
-
return item;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
intersection: ()=>intersection,
|
|
13
|
-
union: ()=>union,
|
|
14
|
-
arrayOf: ()=>arrayOf,
|
|
15
|
-
keyOf: ()=>keyOf,
|
|
16
|
-
instanceOf: ()=>instanceOf,
|
|
17
|
-
valueOf: ()=>valueOf,
|
|
18
|
-
narrow: ()=>narrow,
|
|
19
|
-
morph: ()=>morph
|
|
20
|
-
});
|
|
21
|
-
const _arkJs = require("./ark.js");
|
|
22
|
-
const intersection = _arkJs.scopes.ark.intersection;
|
|
23
|
-
const union = _arkJs.scopes.ark.union;
|
|
24
|
-
const arrayOf = _arkJs.scopes.ark.arrayOf;
|
|
25
|
-
const keyOf = _arkJs.scopes.ark.keyOf;
|
|
26
|
-
const instanceOf = _arkJs.scopes.ark.instanceOf;
|
|
27
|
-
const valueOf = _arkJs.scopes.ark.valueOf;
|
|
28
|
-
const narrow = _arkJs.scopes.ark.narrow;
|
|
29
|
-
const morph = _arkJs.scopes.ark.morph;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
jsObjectsScope: ()=>jsObjectsScope,
|
|
13
|
-
jsObjects: ()=>jsObjects
|
|
14
|
-
});
|
|
15
|
-
const _scopeJs = require("./scope.js");
|
|
16
|
-
const jsObjectsScope = (0, _scopeJs.scope)({
|
|
17
|
-
Function: [
|
|
18
|
-
"node",
|
|
19
|
-
{
|
|
20
|
-
object: {
|
|
21
|
-
class: Function
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
Date: [
|
|
26
|
-
"node",
|
|
27
|
-
{
|
|
28
|
-
object: {
|
|
29
|
-
class: Date
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
],
|
|
33
|
-
Error: [
|
|
34
|
-
"node",
|
|
35
|
-
{
|
|
36
|
-
object: {
|
|
37
|
-
class: Error
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
Map: [
|
|
42
|
-
"node",
|
|
43
|
-
{
|
|
44
|
-
object: {
|
|
45
|
-
class: Map
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
RegExp: [
|
|
50
|
-
"node",
|
|
51
|
-
{
|
|
52
|
-
object: {
|
|
53
|
-
class: RegExp
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
Set: [
|
|
58
|
-
"node",
|
|
59
|
-
{
|
|
60
|
-
object: {
|
|
61
|
-
class: Set
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
],
|
|
65
|
-
WeakMap: [
|
|
66
|
-
"node",
|
|
67
|
-
{
|
|
68
|
-
object: {
|
|
69
|
-
class: WeakMap
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
WeakSet: [
|
|
74
|
-
"node",
|
|
75
|
-
{
|
|
76
|
-
object: {
|
|
77
|
-
class: WeakSet
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
],
|
|
81
|
-
Promise: [
|
|
82
|
-
"node",
|
|
83
|
-
{
|
|
84
|
-
object: {
|
|
85
|
-
class: Promise
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
]
|
|
89
|
-
}, {
|
|
90
|
-
name: "jsObjects",
|
|
91
|
-
standard: false
|
|
92
|
-
});
|
|
93
|
-
const jsObjects = jsObjectsScope.compile();
|