inferred-types 0.54.3 → 0.54.5
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 +349 -332
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +192 -15
- package/modules/inferred-types/dist/index.js +347 -332
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +396 -375
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +40 -8
- package/modules/runtime/dist/index.js +394 -375
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.d.ts +153 -8
- package/package.json +1 -1
|
@@ -273,6 +273,7 @@ __export(src_exports, {
|
|
|
273
273
|
getToday: () => getToday,
|
|
274
274
|
getTokenKind: () => getTokenKind,
|
|
275
275
|
getTomorrow: () => getTomorrow,
|
|
276
|
+
getTypeSubtype: () => getTypeSubtype,
|
|
276
277
|
getUrlPath: () => getUrlPath,
|
|
277
278
|
getUrlPort: () => getUrlPort,
|
|
278
279
|
getUrlProtocol: () => getUrlProtocol,
|
|
@@ -513,6 +514,7 @@ __export(src_exports, {
|
|
|
513
514
|
isTupleToken: () => isTupleToken,
|
|
514
515
|
isTurkishNewsUrl: () => isTurkishNewsUrl,
|
|
515
516
|
isTypeOf: () => isTypeOf,
|
|
517
|
+
isTypeSubtype: () => isTypeSubtype,
|
|
516
518
|
isTypeToken: () => isTypeToken,
|
|
517
519
|
isTypeTokenKind: () => isTypeTokenKind,
|
|
518
520
|
isTypeTuple: () => isTypeTuple,
|
|
@@ -5446,201 +5448,6 @@ function ensureTrailing(content, ensure) {
|
|
|
5446
5448
|
content.endsWith(ensure) ? content : `${content}${ensure}`
|
|
5447
5449
|
);
|
|
5448
5450
|
}
|
|
5449
|
-
function identity(...values) {
|
|
5450
|
-
return values.length === 1 ? values[0] : values.length === 0 ? void 0 : values;
|
|
5451
|
-
}
|
|
5452
|
-
function ifLowercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
5453
|
-
if (ch.length !== 1) {
|
|
5454
|
-
throw new Error(`call to ifUppercaseChar received ${ch.length} characters but is only valid when one character is passed in!`);
|
|
5455
|
-
}
|
|
5456
|
-
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
5457
|
-
}
|
|
5458
|
-
function ifUppercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
5459
|
-
if (ch.length !== 1) {
|
|
5460
|
-
throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
|
|
5461
|
-
}
|
|
5462
|
-
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
5463
|
-
}
|
|
5464
|
-
function parseTemplate(template) {
|
|
5465
|
-
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:as\s+(string|number|boolean)\s*)?\}\}/g;
|
|
5466
|
-
let lastIndex = 0;
|
|
5467
|
-
let match;
|
|
5468
|
-
const segments = [];
|
|
5469
|
-
do {
|
|
5470
|
-
match = pattern.exec(template);
|
|
5471
|
-
if (match) {
|
|
5472
|
-
const [fullMatch, varName, asType2] = match;
|
|
5473
|
-
const staticPart = template.slice(lastIndex, match.index);
|
|
5474
|
-
if (staticPart) {
|
|
5475
|
-
segments.push({ dynamic: false, text: staticPart });
|
|
5476
|
-
}
|
|
5477
|
-
segments.push({
|
|
5478
|
-
dynamic: true,
|
|
5479
|
-
varName,
|
|
5480
|
-
type: asType2 ? asType2 : "string"
|
|
5481
|
-
});
|
|
5482
|
-
lastIndex = match.index + fullMatch.length;
|
|
5483
|
-
}
|
|
5484
|
-
} while (match);
|
|
5485
|
-
const remainder = template.slice(lastIndex);
|
|
5486
|
-
if (remainder) {
|
|
5487
|
-
segments.push({ dynamic: false, text: remainder });
|
|
5488
|
-
}
|
|
5489
|
-
return segments;
|
|
5490
|
-
}
|
|
5491
|
-
function escapeRegex(str) {
|
|
5492
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5493
|
-
}
|
|
5494
|
-
function buildRegexPattern(segments) {
|
|
5495
|
-
let regexStr = "^";
|
|
5496
|
-
for (const seg of segments) {
|
|
5497
|
-
if (!seg.dynamic) {
|
|
5498
|
-
regexStr += escapeRegex(seg.text);
|
|
5499
|
-
} else {
|
|
5500
|
-
switch (seg.type) {
|
|
5501
|
-
case "string":
|
|
5502
|
-
regexStr += `(?<${seg.varName}>.*?)`;
|
|
5503
|
-
break;
|
|
5504
|
-
case "number":
|
|
5505
|
-
regexStr += `(?<${seg.varName}>\\d+)`;
|
|
5506
|
-
break;
|
|
5507
|
-
case "boolean":
|
|
5508
|
-
regexStr += `(?<${seg.varName}>(?:true|false))`;
|
|
5509
|
-
break;
|
|
5510
|
-
}
|
|
5511
|
-
}
|
|
5512
|
-
}
|
|
5513
|
-
regexStr += "$";
|
|
5514
|
-
return new RegExp(regexStr, "s");
|
|
5515
|
-
}
|
|
5516
|
-
function convertValue(type, value) {
|
|
5517
|
-
switch (type) {
|
|
5518
|
-
case "string":
|
|
5519
|
-
return value;
|
|
5520
|
-
case "number":
|
|
5521
|
-
return Number(value);
|
|
5522
|
-
case "boolean":
|
|
5523
|
-
return value === "true";
|
|
5524
|
-
}
|
|
5525
|
-
}
|
|
5526
|
-
function matchTemplate(inference, test) {
|
|
5527
|
-
const segments = parseTemplate(inference);
|
|
5528
|
-
const regex = buildRegexPattern(segments);
|
|
5529
|
-
const match = test.match(regex);
|
|
5530
|
-
if (!match)
|
|
5531
|
-
return false;
|
|
5532
|
-
const result2 = {};
|
|
5533
|
-
for (const seg of segments) {
|
|
5534
|
-
if (seg.dynamic) {
|
|
5535
|
-
const rawVal = match.groups?.[seg.varName];
|
|
5536
|
-
if (rawVal === void 0)
|
|
5537
|
-
return false;
|
|
5538
|
-
result2[seg.varName.toLowerCase()] = convertValue(seg.type, rawVal);
|
|
5539
|
-
}
|
|
5540
|
-
}
|
|
5541
|
-
return result2;
|
|
5542
|
-
}
|
|
5543
|
-
function infer(inference) {
|
|
5544
|
-
return (test) => {
|
|
5545
|
-
return matchTemplate(inference, test);
|
|
5546
|
-
};
|
|
5547
|
-
}
|
|
5548
|
-
function idLiteral(o) {
|
|
5549
|
-
return { ...o, id: o.id };
|
|
5550
|
-
}
|
|
5551
|
-
function nameLiteral(o) {
|
|
5552
|
-
return o;
|
|
5553
|
-
}
|
|
5554
|
-
function kindLiteral(o) {
|
|
5555
|
-
return o;
|
|
5556
|
-
}
|
|
5557
|
-
function idTypeGuard(_o) {
|
|
5558
|
-
return true;
|
|
5559
|
-
}
|
|
5560
|
-
function literal(obj) {
|
|
5561
|
-
return obj;
|
|
5562
|
-
}
|
|
5563
|
-
function lowercase(str) {
|
|
5564
|
-
return str.toLowerCase();
|
|
5565
|
-
}
|
|
5566
|
-
function narrow(...values) {
|
|
5567
|
-
return values.length === 1 ? values[0] : values;
|
|
5568
|
-
}
|
|
5569
|
-
function pathJoin(...segments) {
|
|
5570
|
-
const clean_path = segments.map((i) => stripTrailing(stripLeading(i, "/"), "/")).join("/");
|
|
5571
|
-
const original_path = segments.join("/");
|
|
5572
|
-
const pre = original_path.startsWith("/") ? "/" : "";
|
|
5573
|
-
const post = original_path.endsWith("/") ? "/" : "";
|
|
5574
|
-
return `${pre}${clean_path}${post}`;
|
|
5575
|
-
}
|
|
5576
|
-
var asPhoneFormat = () => `NOT IMPLEMENTED`;
|
|
5577
|
-
function getPhoneCountryCode(phone) {
|
|
5578
|
-
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
5579
|
-
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
5580
|
-
...NUMERIC_CHAR2
|
|
5581
|
-
) : "";
|
|
5582
|
-
}
|
|
5583
|
-
function removePhoneCountryCode(phone) {
|
|
5584
|
-
const countryCode = getPhoneCountryCode(phone);
|
|
5585
|
-
return countryCode !== "" ? stripLeading(stripLeading(
|
|
5586
|
-
phone.trim(),
|
|
5587
|
-
"+",
|
|
5588
|
-
"00"
|
|
5589
|
-
), countryCode).trim() : phone.trim();
|
|
5590
|
-
}
|
|
5591
|
-
var isException = (word) => Object.keys(PLURAL_EXCEPTIONS2).includes(word);
|
|
5592
|
-
function endingIn(word, postfix) {
|
|
5593
|
-
switch (postfix) {
|
|
5594
|
-
case "is":
|
|
5595
|
-
return word.endsWith(postfix) ? `${word}es` : void 0;
|
|
5596
|
-
case "singular-noun":
|
|
5597
|
-
return SINGULAR_NOUN_ENDINGS2.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS2].includes(i)) ? `${word}es` : void 0 : void 0;
|
|
5598
|
-
case "f":
|
|
5599
|
-
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
5600
|
-
case "y":
|
|
5601
|
-
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
5602
|
-
default:
|
|
5603
|
-
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
5604
|
-
}
|
|
5605
|
-
}
|
|
5606
|
-
function pluralize(word) {
|
|
5607
|
-
const right = rightWhitespace(word);
|
|
5608
|
-
const w = word.trimEnd();
|
|
5609
|
-
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
5610
|
-
return `${result2}${right}`;
|
|
5611
|
-
}
|
|
5612
|
-
function retainAfter(content, ...find2) {
|
|
5613
|
-
const idx = Math.min(
|
|
5614
|
-
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
5615
|
-
);
|
|
5616
|
-
const min = Math.min(...find2.map((i) => i.length));
|
|
5617
|
-
let len = Math.max(...find2.map((i) => i.length));
|
|
5618
|
-
if (min !== len) {
|
|
5619
|
-
if (!find2.includes(content.slice(idx, len))) {
|
|
5620
|
-
len = min;
|
|
5621
|
-
}
|
|
5622
|
-
}
|
|
5623
|
-
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
5624
|
-
}
|
|
5625
|
-
function retainAfterInclusive(content, ...find2) {
|
|
5626
|
-
const minFound = Math.min(
|
|
5627
|
-
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
5628
|
-
);
|
|
5629
|
-
return minFound > 0 ? content.slice(minFound) : "";
|
|
5630
|
-
}
|
|
5631
|
-
function asChars(str) {
|
|
5632
|
-
return str.split("");
|
|
5633
|
-
}
|
|
5634
|
-
function retainChars(content, ...retain2) {
|
|
5635
|
-
const chars = asChars(content);
|
|
5636
|
-
return chars.filter((c) => retain2.includes(c)).join("");
|
|
5637
|
-
}
|
|
5638
|
-
function asRecord(obj) {
|
|
5639
|
-
return obj;
|
|
5640
|
-
}
|
|
5641
|
-
function asString(value) {
|
|
5642
|
-
return isString(value) ? value : isNumber(value) ? `${value}` : isBoolean(value) ? `${value}` : isArray(value) ? value.join("") : String(value);
|
|
5643
|
-
}
|
|
5644
5451
|
function isFunction(value) {
|
|
5645
5452
|
return typeof value === "function";
|
|
5646
5453
|
}
|
|
@@ -5922,46 +5729,190 @@ function hasKeys(...props) {
|
|
|
5922
5729
|
return !!((isFunction(val) || isObject(val)) && keys.every((k) => k in val));
|
|
5923
5730
|
};
|
|
5924
5731
|
}
|
|
5925
|
-
function
|
|
5926
|
-
return
|
|
5732
|
+
function asChars(str) {
|
|
5733
|
+
return str.split("");
|
|
5927
5734
|
}
|
|
5928
|
-
function
|
|
5929
|
-
return
|
|
5930
|
-
return isString(val) ? !!val.endsWith(endingIn2) : isNumber(val) ? !!String(val).endsWith(endingIn2) : false;
|
|
5931
|
-
};
|
|
5735
|
+
function asRecord(obj) {
|
|
5736
|
+
return obj;
|
|
5932
5737
|
}
|
|
5933
|
-
function
|
|
5934
|
-
return (value)
|
|
5738
|
+
function asString(value) {
|
|
5739
|
+
return isString(value) ? value : isNumber(value) ? `${value}` : isBoolean(value) ? `${value}` : isArray(value) ? value.join("") : String(value);
|
|
5935
5740
|
}
|
|
5936
|
-
function
|
|
5937
|
-
|
|
5741
|
+
function csv(csv2, format = `string-numeric-tuple`) {
|
|
5742
|
+
const tuple3 = [];
|
|
5743
|
+
csv2.split(/,\s?/).forEach((v) => {
|
|
5744
|
+
tuple3.push(
|
|
5745
|
+
format === "string-numeric-tuple" ? isNumberLike(v) ? Number(v) : v : format === "json-tuple" ? isNumberLike(v) ? Number(v) : v === "true" ? true : v === "false" ? false : `"${v}"` : format === "string-tuple" ? `${v}` : Never2
|
|
5746
|
+
);
|
|
5747
|
+
});
|
|
5748
|
+
return tuple3;
|
|
5938
5749
|
}
|
|
5939
|
-
function
|
|
5940
|
-
return
|
|
5941
|
-
return typeof base === typeof compare;
|
|
5942
|
-
};
|
|
5750
|
+
function intersect(value, _intersectedWith) {
|
|
5751
|
+
return value;
|
|
5943
5752
|
}
|
|
5944
|
-
function
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5753
|
+
function stripTrailing(content, ...strip2) {
|
|
5754
|
+
let output = String(content);
|
|
5755
|
+
for (const s of strip2) {
|
|
5756
|
+
if (output.endsWith(String(s))) {
|
|
5757
|
+
output = output.slice(0, -1 * String(s).length);
|
|
5758
|
+
}
|
|
5759
|
+
}
|
|
5760
|
+
return isNumber(content) ? Number(output) : output;
|
|
5949
5761
|
}
|
|
5950
|
-
function
|
|
5951
|
-
return (
|
|
5952
|
-
return typeof value === type;
|
|
5953
|
-
};
|
|
5762
|
+
function ip6GroupExpansion(ip) {
|
|
5763
|
+
return stripTrailing(ip.replaceAll("::", ":0000:"), ":");
|
|
5954
5764
|
}
|
|
5955
|
-
function
|
|
5956
|
-
return (val)
|
|
5957
|
-
return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
|
|
5958
|
-
};
|
|
5765
|
+
function jsonValue(val) {
|
|
5766
|
+
return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
|
|
5959
5767
|
}
|
|
5960
|
-
function
|
|
5961
|
-
return
|
|
5768
|
+
function jsonValues(...val) {
|
|
5769
|
+
return val.map((i) => jsonValue(i));
|
|
5962
5770
|
}
|
|
5963
|
-
function
|
|
5964
|
-
|
|
5771
|
+
function lookupAlpha2Code(code, prop) {
|
|
5772
|
+
const found = ISO3166_12.find((i) => i.alpha2 === code);
|
|
5773
|
+
return found ? found[prop] : void 0;
|
|
5774
|
+
}
|
|
5775
|
+
function lookupAlpha3Code(code, prop) {
|
|
5776
|
+
const found = ISO3166_12.find((i) => i.alpha3 === code);
|
|
5777
|
+
return found ? found[prop] : void 0;
|
|
5778
|
+
}
|
|
5779
|
+
function lookupName(name, prop) {
|
|
5780
|
+
const found = ISO3166_12.find((i) => i.name === name);
|
|
5781
|
+
return found ? found[prop] : void 0;
|
|
5782
|
+
}
|
|
5783
|
+
function lookupNumericCode(code, prop) {
|
|
5784
|
+
let num = isNumber(code) ? `${code}` : code;
|
|
5785
|
+
if (num.length === 1) {
|
|
5786
|
+
num = `00${num}`;
|
|
5787
|
+
} else if (num.length === 2) {
|
|
5788
|
+
num = `0${num}`;
|
|
5789
|
+
}
|
|
5790
|
+
const found = ISO3166_12.find((i) => i.countryCode === num);
|
|
5791
|
+
return found ? found[prop] : void 0;
|
|
5792
|
+
}
|
|
5793
|
+
function lookupCountryName(code) {
|
|
5794
|
+
const uc = uppercase(code);
|
|
5795
|
+
return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
|
|
5796
|
+
}
|
|
5797
|
+
function lookupCountryAlpha2(code) {
|
|
5798
|
+
const uc = uppercase(code);
|
|
5799
|
+
return isNumberLike(code) ? lookupNumericCode(code, "alpha2") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha2") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha2") : isIso3166CountryName(code) ? lookupName(code, "alpha2") : void 0;
|
|
5800
|
+
}
|
|
5801
|
+
function lookupCountryAlpha3(token) {
|
|
5802
|
+
const uc = uppercase(token);
|
|
5803
|
+
return isNumberLike(token) ? lookupNumericCode(token, "alpha3") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha3") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha3") : isIso3166CountryName(token) ? lookupName(token, "alpha3") : void 0;
|
|
5804
|
+
}
|
|
5805
|
+
function lookupCountryCode(token) {
|
|
5806
|
+
const uc = uppercase(token);
|
|
5807
|
+
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
5808
|
+
}
|
|
5809
|
+
function mergeObjects(defVal, override) {
|
|
5810
|
+
const intersectingKeys = sharedKeys(defVal, override);
|
|
5811
|
+
const defUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
5812
|
+
const overrideUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
5813
|
+
const merged = {
|
|
5814
|
+
...intersectingKeys.reduce(
|
|
5815
|
+
(acc, key) => typeof override[key] === "undefined" ? { ...acc, [key]: defVal[key] } : { ...acc, [key]: override[key] },
|
|
5816
|
+
{}
|
|
5817
|
+
),
|
|
5818
|
+
...defUnique,
|
|
5819
|
+
...overrideUnique
|
|
5820
|
+
};
|
|
5821
|
+
return merged;
|
|
5822
|
+
}
|
|
5823
|
+
function isUndefined(value) {
|
|
5824
|
+
return typeof value === "undefined";
|
|
5825
|
+
}
|
|
5826
|
+
function mergeScalars(a, b) {
|
|
5827
|
+
return isUndefined(b) ? a : b;
|
|
5828
|
+
}
|
|
5829
|
+
function mergeTuples(a, b) {
|
|
5830
|
+
return b.length > a.length ? b.map((v, idx) => v !== void 0 ? v : a[idx]) : [...b, ...a.slice(b.length)].map((v, idx) => v !== void 0 ? v : a[idx]);
|
|
5831
|
+
}
|
|
5832
|
+
function never(val) {
|
|
5833
|
+
return val;
|
|
5834
|
+
}
|
|
5835
|
+
function optional(value) {
|
|
5836
|
+
return value;
|
|
5837
|
+
}
|
|
5838
|
+
function orNull(value) {
|
|
5839
|
+
return value;
|
|
5840
|
+
}
|
|
5841
|
+
function optionalOrNull(value) {
|
|
5842
|
+
return value;
|
|
5843
|
+
}
|
|
5844
|
+
function stripParenthesis(val) {
|
|
5845
|
+
return stripTrailing(stripLeading(val.trim(), "("), ")").trim();
|
|
5846
|
+
}
|
|
5847
|
+
function convertScalar(val) {
|
|
5848
|
+
switch (typeof val) {
|
|
5849
|
+
case "number":
|
|
5850
|
+
return val;
|
|
5851
|
+
case "string":
|
|
5852
|
+
return Number(val);
|
|
5853
|
+
case "boolean":
|
|
5854
|
+
return val ? 1 : 0;
|
|
5855
|
+
default:
|
|
5856
|
+
throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
|
|
5857
|
+
}
|
|
5858
|
+
}
|
|
5859
|
+
var convertList = (val) => val.map((i) => convertScalar(i));
|
|
5860
|
+
function toNumber(value) {
|
|
5861
|
+
return Array.isArray(value) ? convertList(value) : convertScalar(value);
|
|
5862
|
+
}
|
|
5863
|
+
var MODS = TW_MODIFIERS2.map((i) => `${i}:`);
|
|
5864
|
+
function removeTailwindModifiers(val) {
|
|
5865
|
+
return MODS.some((i) => val.startsWith(i)) ? removeTailwindModifiers(val.replace(MODS.find((i) => val.startsWith(i)), "")) : val;
|
|
5866
|
+
}
|
|
5867
|
+
function getTailwindModifiers(val) {
|
|
5868
|
+
return val.split(":").filter((i) => isTailwindModifier(i));
|
|
5869
|
+
}
|
|
5870
|
+
function union(..._options) {
|
|
5871
|
+
return (value) => value;
|
|
5872
|
+
}
|
|
5873
|
+
function unionize(value, _inUnionWith) {
|
|
5874
|
+
return value;
|
|
5875
|
+
}
|
|
5876
|
+
function hasWhiteSpace(val) {
|
|
5877
|
+
return isString(val) && asChars(val).some((c) => WHITESPACE_CHARS2.includes(c));
|
|
5878
|
+
}
|
|
5879
|
+
function endsWith(endingIn2) {
|
|
5880
|
+
return (val) => {
|
|
5881
|
+
return isString(val) ? !!val.endsWith(endingIn2) : isNumber(val) ? !!String(val).endsWith(endingIn2) : false;
|
|
5882
|
+
};
|
|
5883
|
+
}
|
|
5884
|
+
function isEqual(base) {
|
|
5885
|
+
return (value) => isSameTypeOf(base)(value) ? value === base : false;
|
|
5886
|
+
}
|
|
5887
|
+
function isLength(value, len) {
|
|
5888
|
+
return isArray(value) ? !!isEqual(value.length)(len) : isString(value) ? !!isEqual(value.length)(len) : isObject(value) ? !!isEqual(keysOf(value))(len) : false;
|
|
5889
|
+
}
|
|
5890
|
+
function isSameTypeOf(base) {
|
|
5891
|
+
return (compare) => {
|
|
5892
|
+
return typeof base === typeof compare;
|
|
5893
|
+
};
|
|
5894
|
+
}
|
|
5895
|
+
function isTuple(...tuple3) {
|
|
5896
|
+
const results = tuple3.map((i) => i(ShapeApiImplementation)).map((i) => isDoneFn(i) ? i.done() : i);
|
|
5897
|
+
return (v) => {
|
|
5898
|
+
return isArray(v) && v.length === results.length && results.every(isShape) && v.every((item, idx) => isSameTypeOf(results[idx])(item));
|
|
5899
|
+
};
|
|
5900
|
+
}
|
|
5901
|
+
function isTypeOf(type) {
|
|
5902
|
+
return (value) => {
|
|
5903
|
+
return typeof value === type;
|
|
5904
|
+
};
|
|
5905
|
+
}
|
|
5906
|
+
function startsWith(startingWith) {
|
|
5907
|
+
return (val) => {
|
|
5908
|
+
return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
|
|
5909
|
+
};
|
|
5910
|
+
}
|
|
5911
|
+
function isHtmlElement(val) {
|
|
5912
|
+
return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
|
|
5913
|
+
}
|
|
5914
|
+
function isAlpha(value) {
|
|
5915
|
+
return isString(value) && split(value).every((v) => ALPHA_CHARS2.includes(v));
|
|
5965
5916
|
}
|
|
5966
5917
|
function isArray(value) {
|
|
5967
5918
|
return Array.isArray(value) === true;
|
|
@@ -6091,12 +6042,12 @@ function isTrue(value) {
|
|
|
6091
6042
|
function isTruthy(val) {
|
|
6092
6043
|
return !FALSY_VALUES2.includes(val);
|
|
6093
6044
|
}
|
|
6045
|
+
function isTypeSubtype(val) {
|
|
6046
|
+
return isString(val) && val.split("/").length === 2;
|
|
6047
|
+
}
|
|
6094
6048
|
function isTypeTuple(value) {
|
|
6095
6049
|
return Array.isArray(value) && value.length === 3 && typeof value[1] === "function";
|
|
6096
6050
|
}
|
|
6097
|
-
function isUndefined(value) {
|
|
6098
|
-
return typeof value === "undefined";
|
|
6099
|
-
}
|
|
6100
6051
|
function isUnset(val) {
|
|
6101
6052
|
return isObject(val) && val.kind === "Unset";
|
|
6102
6053
|
}
|
|
@@ -6656,137 +6607,201 @@ function isYouTubeCreatorUrl(url) {
|
|
|
6656
6607
|
function isYouTubeVideosInPlaylist(val) {
|
|
6657
6608
|
return isString(val) && (val.startsWith(`https://www.youtube.com/playlist?`) || val.startsWith(`https://youtube.com/playlist?`)) && hasUrlQueryParameter(val, "list");
|
|
6658
6609
|
}
|
|
6659
|
-
function
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
);
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
}
|
|
6668
|
-
function intersect(value, _intersectedWith) {
|
|
6669
|
-
return value;
|
|
6670
|
-
}
|
|
6671
|
-
function stripTrailing(content, ...strip2) {
|
|
6672
|
-
let output = String(content);
|
|
6673
|
-
for (const s of strip2) {
|
|
6674
|
-
if (output.endsWith(String(s))) {
|
|
6675
|
-
output = output.slice(0, -1 * String(s).length);
|
|
6676
|
-
}
|
|
6610
|
+
function getTypeSubtype(str) {
|
|
6611
|
+
if (isTypeSubtype(str)) {
|
|
6612
|
+
const [t, st] = str.split("/");
|
|
6613
|
+
return [t, st];
|
|
6614
|
+
} else {
|
|
6615
|
+
const err = new Error(`An invalid Type/Subtype was passed into getTypeSubtype(${str})`);
|
|
6616
|
+
err.name = "InvalidTypeSubtype";
|
|
6617
|
+
throw err;
|
|
6677
6618
|
}
|
|
6678
|
-
return isNumber(content) ? Number(output) : output;
|
|
6679
6619
|
}
|
|
6680
|
-
function
|
|
6681
|
-
return
|
|
6620
|
+
function identity(...values) {
|
|
6621
|
+
return values.length === 1 ? values[0] : values.length === 0 ? void 0 : values;
|
|
6682
6622
|
}
|
|
6683
|
-
function
|
|
6684
|
-
|
|
6623
|
+
function ifLowercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
6624
|
+
if (ch.length !== 1) {
|
|
6625
|
+
throw new Error(`call to ifUppercaseChar received ${ch.length} characters but is only valid when one character is passed in!`);
|
|
6626
|
+
}
|
|
6627
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
6685
6628
|
}
|
|
6686
|
-
function
|
|
6687
|
-
|
|
6629
|
+
function ifUppercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
6630
|
+
if (ch.length !== 1) {
|
|
6631
|
+
throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
|
|
6632
|
+
}
|
|
6633
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
6688
6634
|
}
|
|
6689
|
-
function
|
|
6690
|
-
const
|
|
6691
|
-
|
|
6635
|
+
function parseTemplate(template) {
|
|
6636
|
+
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:as\s+(string|number|boolean)\s*)?\}\}/g;
|
|
6637
|
+
let lastIndex = 0;
|
|
6638
|
+
let match;
|
|
6639
|
+
const segments = [];
|
|
6640
|
+
do {
|
|
6641
|
+
match = pattern.exec(template);
|
|
6642
|
+
if (match) {
|
|
6643
|
+
const [fullMatch, varName, asType2] = match;
|
|
6644
|
+
const staticPart = template.slice(lastIndex, match.index);
|
|
6645
|
+
if (staticPart) {
|
|
6646
|
+
segments.push({ dynamic: false, text: staticPart });
|
|
6647
|
+
}
|
|
6648
|
+
segments.push({
|
|
6649
|
+
dynamic: true,
|
|
6650
|
+
varName,
|
|
6651
|
+
type: asType2 ? asType2 : "string"
|
|
6652
|
+
});
|
|
6653
|
+
lastIndex = match.index + fullMatch.length;
|
|
6654
|
+
}
|
|
6655
|
+
} while (match);
|
|
6656
|
+
const remainder = template.slice(lastIndex);
|
|
6657
|
+
if (remainder) {
|
|
6658
|
+
segments.push({ dynamic: false, text: remainder });
|
|
6659
|
+
}
|
|
6660
|
+
return segments;
|
|
6692
6661
|
}
|
|
6693
|
-
function
|
|
6694
|
-
|
|
6695
|
-
return found ? found[prop] : void 0;
|
|
6662
|
+
function escapeRegex(str) {
|
|
6663
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6696
6664
|
}
|
|
6697
|
-
function
|
|
6698
|
-
|
|
6699
|
-
|
|
6665
|
+
function buildRegexPattern(segments) {
|
|
6666
|
+
let regexStr = "^";
|
|
6667
|
+
for (const seg of segments) {
|
|
6668
|
+
if (!seg.dynamic) {
|
|
6669
|
+
regexStr += escapeRegex(seg.text);
|
|
6670
|
+
} else {
|
|
6671
|
+
switch (seg.type) {
|
|
6672
|
+
case "string":
|
|
6673
|
+
regexStr += `(?<${seg.varName}>.*?)`;
|
|
6674
|
+
break;
|
|
6675
|
+
case "number":
|
|
6676
|
+
regexStr += `(?<${seg.varName}>\\d+)`;
|
|
6677
|
+
break;
|
|
6678
|
+
case "boolean":
|
|
6679
|
+
regexStr += `(?<${seg.varName}>(?:true|false))`;
|
|
6680
|
+
break;
|
|
6681
|
+
}
|
|
6682
|
+
}
|
|
6683
|
+
}
|
|
6684
|
+
regexStr += "$";
|
|
6685
|
+
return new RegExp(regexStr, "s");
|
|
6700
6686
|
}
|
|
6701
|
-
function
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6687
|
+
function convertValue(type, value) {
|
|
6688
|
+
switch (type) {
|
|
6689
|
+
case "string":
|
|
6690
|
+
return value;
|
|
6691
|
+
case "number":
|
|
6692
|
+
return Number(value);
|
|
6693
|
+
case "boolean":
|
|
6694
|
+
return value === "true";
|
|
6707
6695
|
}
|
|
6708
|
-
const found = ISO3166_12.find((i) => i.countryCode === num);
|
|
6709
|
-
return found ? found[prop] : void 0;
|
|
6710
6696
|
}
|
|
6711
|
-
function
|
|
6712
|
-
const
|
|
6713
|
-
|
|
6697
|
+
function matchTemplate(inference, test) {
|
|
6698
|
+
const segments = parseTemplate(inference);
|
|
6699
|
+
const regex = buildRegexPattern(segments);
|
|
6700
|
+
const match = test.match(regex);
|
|
6701
|
+
if (!match)
|
|
6702
|
+
return false;
|
|
6703
|
+
const result2 = {};
|
|
6704
|
+
for (const seg of segments) {
|
|
6705
|
+
if (seg.dynamic) {
|
|
6706
|
+
const rawVal = match.groups?.[seg.varName];
|
|
6707
|
+
if (rawVal === void 0)
|
|
6708
|
+
return false;
|
|
6709
|
+
result2[seg.varName.toLowerCase()] = convertValue(seg.type, rawVal);
|
|
6710
|
+
}
|
|
6711
|
+
}
|
|
6712
|
+
return result2;
|
|
6714
6713
|
}
|
|
6715
|
-
function
|
|
6716
|
-
|
|
6717
|
-
|
|
6714
|
+
function infer(inference) {
|
|
6715
|
+
return (test) => {
|
|
6716
|
+
return matchTemplate(inference, test);
|
|
6717
|
+
};
|
|
6718
6718
|
}
|
|
6719
|
-
function
|
|
6720
|
-
|
|
6721
|
-
return isNumberLike(token) ? lookupNumericCode(token, "alpha3") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha3") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha3") : isIso3166CountryName(token) ? lookupName(token, "alpha3") : void 0;
|
|
6719
|
+
function idLiteral(o) {
|
|
6720
|
+
return { ...o, id: o.id };
|
|
6722
6721
|
}
|
|
6723
|
-
function
|
|
6724
|
-
|
|
6725
|
-
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
6722
|
+
function nameLiteral(o) {
|
|
6723
|
+
return o;
|
|
6726
6724
|
}
|
|
6727
|
-
function
|
|
6728
|
-
|
|
6729
|
-
const defUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
6730
|
-
const overrideUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
6731
|
-
const merged = {
|
|
6732
|
-
...intersectingKeys.reduce(
|
|
6733
|
-
(acc, key) => typeof override[key] === "undefined" ? { ...acc, [key]: defVal[key] } : { ...acc, [key]: override[key] },
|
|
6734
|
-
{}
|
|
6735
|
-
),
|
|
6736
|
-
...defUnique,
|
|
6737
|
-
...overrideUnique
|
|
6738
|
-
};
|
|
6739
|
-
return merged;
|
|
6725
|
+
function kindLiteral(o) {
|
|
6726
|
+
return o;
|
|
6740
6727
|
}
|
|
6741
|
-
function
|
|
6742
|
-
return
|
|
6728
|
+
function idTypeGuard(_o) {
|
|
6729
|
+
return true;
|
|
6743
6730
|
}
|
|
6744
|
-
function
|
|
6745
|
-
return
|
|
6731
|
+
function literal(obj) {
|
|
6732
|
+
return obj;
|
|
6746
6733
|
}
|
|
6747
|
-
function
|
|
6748
|
-
return
|
|
6734
|
+
function lowercase(str) {
|
|
6735
|
+
return str.toLowerCase();
|
|
6749
6736
|
}
|
|
6750
|
-
function
|
|
6751
|
-
return
|
|
6737
|
+
function narrow(...values) {
|
|
6738
|
+
return values.length === 1 ? values[0] : values;
|
|
6752
6739
|
}
|
|
6753
|
-
function
|
|
6754
|
-
|
|
6740
|
+
function pathJoin(...segments) {
|
|
6741
|
+
const clean_path = segments.map((i) => stripTrailing(stripLeading(i, "/"), "/")).join("/");
|
|
6742
|
+
const original_path = segments.join("/");
|
|
6743
|
+
const pre = original_path.startsWith("/") ? "/" : "";
|
|
6744
|
+
const post = original_path.endsWith("/") ? "/" : "";
|
|
6745
|
+
return `${pre}${clean_path}${post}`;
|
|
6755
6746
|
}
|
|
6756
|
-
|
|
6757
|
-
|
|
6747
|
+
var asPhoneFormat = () => `NOT IMPLEMENTED`;
|
|
6748
|
+
function getPhoneCountryCode(phone) {
|
|
6749
|
+
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
6750
|
+
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
6751
|
+
...NUMERIC_CHAR2
|
|
6752
|
+
) : "";
|
|
6758
6753
|
}
|
|
6759
|
-
function
|
|
6760
|
-
|
|
6754
|
+
function removePhoneCountryCode(phone) {
|
|
6755
|
+
const countryCode = getPhoneCountryCode(phone);
|
|
6756
|
+
return countryCode !== "" ? stripLeading(stripLeading(
|
|
6757
|
+
phone.trim(),
|
|
6758
|
+
"+",
|
|
6759
|
+
"00"
|
|
6760
|
+
), countryCode).trim() : phone.trim();
|
|
6761
6761
|
}
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6762
|
+
var isException = (word) => Object.keys(PLURAL_EXCEPTIONS2).includes(word);
|
|
6763
|
+
function endingIn(word, postfix) {
|
|
6764
|
+
switch (postfix) {
|
|
6765
|
+
case "is":
|
|
6766
|
+
return word.endsWith(postfix) ? `${word}es` : void 0;
|
|
6767
|
+
case "singular-noun":
|
|
6768
|
+
return SINGULAR_NOUN_ENDINGS2.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS2].includes(i)) ? `${word}es` : void 0 : void 0;
|
|
6769
|
+
case "f":
|
|
6770
|
+
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
6771
|
+
case "y":
|
|
6772
|
+
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
6770
6773
|
default:
|
|
6771
|
-
throw new Error(
|
|
6774
|
+
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
6772
6775
|
}
|
|
6773
6776
|
}
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
}
|
|
6778
|
-
|
|
6779
|
-
function removeTailwindModifiers(val) {
|
|
6780
|
-
return MODS.some((i) => val.startsWith(i)) ? removeTailwindModifiers(val.replace(MODS.find((i) => val.startsWith(i)), "")) : val;
|
|
6777
|
+
function pluralize(word) {
|
|
6778
|
+
const right = rightWhitespace(word);
|
|
6779
|
+
const w = word.trimEnd();
|
|
6780
|
+
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
6781
|
+
return `${result2}${right}`;
|
|
6781
6782
|
}
|
|
6782
|
-
function
|
|
6783
|
-
|
|
6783
|
+
function retainAfter(content, ...find2) {
|
|
6784
|
+
const idx = Math.min(
|
|
6785
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
6786
|
+
);
|
|
6787
|
+
const min = Math.min(...find2.map((i) => i.length));
|
|
6788
|
+
let len = Math.max(...find2.map((i) => i.length));
|
|
6789
|
+
if (min !== len) {
|
|
6790
|
+
if (!find2.includes(content.slice(idx, len))) {
|
|
6791
|
+
len = min;
|
|
6792
|
+
}
|
|
6793
|
+
}
|
|
6794
|
+
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
6784
6795
|
}
|
|
6785
|
-
function
|
|
6786
|
-
|
|
6796
|
+
function retainAfterInclusive(content, ...find2) {
|
|
6797
|
+
const minFound = Math.min(
|
|
6798
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
6799
|
+
);
|
|
6800
|
+
return minFound > 0 ? content.slice(minFound) : "";
|
|
6787
6801
|
}
|
|
6788
|
-
function
|
|
6789
|
-
|
|
6802
|
+
function retainChars(content, ...retain2) {
|
|
6803
|
+
const chars = asChars(content);
|
|
6804
|
+
return chars.filter((c) => retain2.includes(c)).join("");
|
|
6790
6805
|
}
|
|
6791
6806
|
function retainUntil(content, ...find2) {
|
|
6792
6807
|
const chars = asChars(content);
|
|
@@ -7864,6 +7879,7 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
|
|
|
7864
7879
|
getToday,
|
|
7865
7880
|
getTokenKind,
|
|
7866
7881
|
getTomorrow,
|
|
7882
|
+
getTypeSubtype,
|
|
7867
7883
|
getUrlPath,
|
|
7868
7884
|
getUrlPort,
|
|
7869
7885
|
getUrlProtocol,
|
|
@@ -8104,6 +8120,7 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
|
|
|
8104
8120
|
isTupleToken,
|
|
8105
8121
|
isTurkishNewsUrl,
|
|
8106
8122
|
isTypeOf,
|
|
8123
|
+
isTypeSubtype,
|
|
8107
8124
|
isTypeToken,
|
|
8108
8125
|
isTypeTokenKind,
|
|
8109
8126
|
isTypeTuple,
|