inferred-types 0.54.7 → 0.54.8
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/modules/inferred-types/dist/index.cjs +23 -25
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +22447 -22373
- package/modules/inferred-types/dist/index.js +23 -25
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +23 -25
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +6894 -6838
- package/modules/runtime/dist/index.js +23 -25
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.d.ts +10074 -10056
- package/package.json +1 -1
|
@@ -6742,26 +6742,23 @@ function ifUppercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
|
6742
6742
|
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
6743
6743
|
}
|
|
6744
6744
|
function parseTemplate(template) {
|
|
6745
|
-
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:as\s+(string|number|boolean)\s*)?\}\}/g;
|
|
6745
|
+
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:(?:extends|as)\s+(string|number|boolean)\s*)?\}\}/g;
|
|
6746
6746
|
let lastIndex = 0;
|
|
6747
6747
|
let match;
|
|
6748
6748
|
const segments = [];
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
if (staticPart) {
|
|
6755
|
-
segments.push({ dynamic: false, text: staticPart });
|
|
6756
|
-
}
|
|
6757
|
-
segments.push({
|
|
6758
|
-
dynamic: true,
|
|
6759
|
-
varName,
|
|
6760
|
-
type: asType2 ? asType2 : "string"
|
|
6761
|
-
});
|
|
6762
|
-
lastIndex = match.index + fullMatch.length;
|
|
6749
|
+
while (match = pattern.exec(template)) {
|
|
6750
|
+
const [fullMatch, varName, asType2] = match;
|
|
6751
|
+
const staticPart = template.slice(lastIndex, match.index);
|
|
6752
|
+
if (staticPart) {
|
|
6753
|
+
segments.push({ dynamic: false, text: staticPart });
|
|
6763
6754
|
}
|
|
6764
|
-
|
|
6755
|
+
segments.push({
|
|
6756
|
+
dynamic: true,
|
|
6757
|
+
varName,
|
|
6758
|
+
type: asType2 ? asType2 : "string"
|
|
6759
|
+
});
|
|
6760
|
+
lastIndex = match.index + fullMatch.length;
|
|
6761
|
+
}
|
|
6765
6762
|
const remainder = template.slice(lastIndex);
|
|
6766
6763
|
if (remainder) {
|
|
6767
6764
|
segments.push({ dynamic: false, text: remainder });
|
|
@@ -6779,19 +6776,19 @@ function buildRegexPattern(segments) {
|
|
|
6779
6776
|
} else {
|
|
6780
6777
|
switch (seg.type) {
|
|
6781
6778
|
case "string":
|
|
6782
|
-
regexStr +=
|
|
6779
|
+
regexStr += "(.*?)";
|
|
6783
6780
|
break;
|
|
6784
6781
|
case "number":
|
|
6785
|
-
regexStr +=
|
|
6782
|
+
regexStr += "(\\d+)";
|
|
6786
6783
|
break;
|
|
6787
6784
|
case "boolean":
|
|
6788
|
-
regexStr +=
|
|
6785
|
+
regexStr += "(true|false)";
|
|
6789
6786
|
break;
|
|
6790
6787
|
}
|
|
6791
6788
|
}
|
|
6792
6789
|
}
|
|
6793
6790
|
regexStr += "$";
|
|
6794
|
-
return new RegExp(regexStr
|
|
6791
|
+
return new RegExp(regexStr);
|
|
6795
6792
|
}
|
|
6796
6793
|
function convertValue(type, value) {
|
|
6797
6794
|
switch (type) {
|
|
@@ -6803,19 +6800,20 @@ function convertValue(type, value) {
|
|
|
6803
6800
|
return value === "true";
|
|
6804
6801
|
}
|
|
6805
6802
|
}
|
|
6806
|
-
function matchTemplate(
|
|
6807
|
-
const segments = parseTemplate(
|
|
6803
|
+
function matchTemplate(template, test) {
|
|
6804
|
+
const segments = parseTemplate(template);
|
|
6808
6805
|
const regex = buildRegexPattern(segments);
|
|
6809
|
-
const match =
|
|
6806
|
+
const match = regex.exec(test);
|
|
6810
6807
|
if (!match)
|
|
6811
6808
|
return false;
|
|
6809
|
+
let captureIndex = 1;
|
|
6812
6810
|
const result2 = {};
|
|
6813
6811
|
for (const seg of segments) {
|
|
6814
6812
|
if (seg.dynamic) {
|
|
6815
|
-
const rawVal = match
|
|
6813
|
+
const rawVal = match[captureIndex++];
|
|
6816
6814
|
if (rawVal === void 0)
|
|
6817
6815
|
return false;
|
|
6818
|
-
result2[seg.varName
|
|
6816
|
+
result2[seg.varName] = convertValue(seg.type, rawVal);
|
|
6819
6817
|
}
|
|
6820
6818
|
}
|
|
6821
6819
|
return result2;
|