inferred-types 0.55.17 → 0.55.19
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/constants/dist/index.cjs +120 -0
- package/modules/constants/dist/index.cjs.map +1 -1
- package/modules/constants/dist/index.d.ts +10 -1
- package/modules/constants/dist/index.js +118 -0
- package/modules/constants/dist/index.js.map +1 -1
- package/modules/inferred-types/dist/index.cjs +401 -0
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +214 -1
- package/modules/inferred-types/dist/index.js +390 -0
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +293 -0
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +142 -1
- package/modules/runtime/dist/index.js +284 -0
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.d.ts +64 -1
- package/package.json +1 -1
|
@@ -508,6 +508,120 @@ var HASH_TABLE_CHAR = {
|
|
|
508
508
|
...HASH_TABLE_SPECIAL
|
|
509
509
|
};
|
|
510
510
|
var HASH_TABLE_OTHER = "999";
|
|
511
|
+
var HTML_BLOCK_TAGS = [
|
|
512
|
+
"a",
|
|
513
|
+
"abbr",
|
|
514
|
+
"address",
|
|
515
|
+
"article",
|
|
516
|
+
"aside",
|
|
517
|
+
"b",
|
|
518
|
+
"bdi",
|
|
519
|
+
"bdo",
|
|
520
|
+
"blockquote",
|
|
521
|
+
"body",
|
|
522
|
+
"button",
|
|
523
|
+
"canvas",
|
|
524
|
+
"caption",
|
|
525
|
+
"cite",
|
|
526
|
+
"code",
|
|
527
|
+
"colgroup",
|
|
528
|
+
"data",
|
|
529
|
+
"datalist",
|
|
530
|
+
"dd",
|
|
531
|
+
"del",
|
|
532
|
+
"details",
|
|
533
|
+
"dfn",
|
|
534
|
+
"dialog",
|
|
535
|
+
"div",
|
|
536
|
+
"dl",
|
|
537
|
+
"dt",
|
|
538
|
+
"em",
|
|
539
|
+
"fieldset",
|
|
540
|
+
"figcaption",
|
|
541
|
+
"figure",
|
|
542
|
+
"footer",
|
|
543
|
+
"form",
|
|
544
|
+
"h1",
|
|
545
|
+
"h2",
|
|
546
|
+
"h3",
|
|
547
|
+
"h4",
|
|
548
|
+
"h5",
|
|
549
|
+
"h6",
|
|
550
|
+
"head",
|
|
551
|
+
"header",
|
|
552
|
+
"html",
|
|
553
|
+
"i",
|
|
554
|
+
"iframe",
|
|
555
|
+
"ins",
|
|
556
|
+
"kbd",
|
|
557
|
+
"label",
|
|
558
|
+
"legend",
|
|
559
|
+
"li",
|
|
560
|
+
"main",
|
|
561
|
+
"map",
|
|
562
|
+
"mark",
|
|
563
|
+
"menu",
|
|
564
|
+
"meter",
|
|
565
|
+
"nav",
|
|
566
|
+
"noscript",
|
|
567
|
+
"object",
|
|
568
|
+
"ol",
|
|
569
|
+
"optgroup",
|
|
570
|
+
"option",
|
|
571
|
+
"output",
|
|
572
|
+
"p",
|
|
573
|
+
"picture",
|
|
574
|
+
"pre",
|
|
575
|
+
"progress",
|
|
576
|
+
"q",
|
|
577
|
+
"rp",
|
|
578
|
+
"rt",
|
|
579
|
+
"ruby",
|
|
580
|
+
"s",
|
|
581
|
+
"samp",
|
|
582
|
+
"script",
|
|
583
|
+
"section",
|
|
584
|
+
"select",
|
|
585
|
+
"small",
|
|
586
|
+
"span",
|
|
587
|
+
"strong",
|
|
588
|
+
"style",
|
|
589
|
+
"sub",
|
|
590
|
+
"summary",
|
|
591
|
+
"sup",
|
|
592
|
+
"svg",
|
|
593
|
+
"table",
|
|
594
|
+
"tbody",
|
|
595
|
+
"td",
|
|
596
|
+
"template",
|
|
597
|
+
"textarea",
|
|
598
|
+
"tfoot",
|
|
599
|
+
"th",
|
|
600
|
+
"thead",
|
|
601
|
+
"time",
|
|
602
|
+
"title",
|
|
603
|
+
"tr",
|
|
604
|
+
"u",
|
|
605
|
+
"ul",
|
|
606
|
+
"var",
|
|
607
|
+
"video"
|
|
608
|
+
];
|
|
609
|
+
var HTML_ATOMIC_TAGS = [
|
|
610
|
+
"area",
|
|
611
|
+
"base",
|
|
612
|
+
"br",
|
|
613
|
+
"col",
|
|
614
|
+
"embed",
|
|
615
|
+
"hr",
|
|
616
|
+
"img",
|
|
617
|
+
"input",
|
|
618
|
+
"link",
|
|
619
|
+
"meta",
|
|
620
|
+
"param",
|
|
621
|
+
"source",
|
|
622
|
+
"track",
|
|
623
|
+
"wbr"
|
|
624
|
+
];
|
|
511
625
|
var MIME_TYPES = [
|
|
512
626
|
// Application MIME Types
|
|
513
627
|
"application/json",
|
|
@@ -2917,6 +3031,120 @@ var HASH_TABLE_CHAR2 = {
|
|
|
2917
3031
|
...HASH_TABLE_ALPHA_UPPER2,
|
|
2918
3032
|
...HASH_TABLE_SPECIAL2
|
|
2919
3033
|
};
|
|
3034
|
+
var HTML_BLOCK_TAGS2 = [
|
|
3035
|
+
"a",
|
|
3036
|
+
"abbr",
|
|
3037
|
+
"address",
|
|
3038
|
+
"article",
|
|
3039
|
+
"aside",
|
|
3040
|
+
"b",
|
|
3041
|
+
"bdi",
|
|
3042
|
+
"bdo",
|
|
3043
|
+
"blockquote",
|
|
3044
|
+
"body",
|
|
3045
|
+
"button",
|
|
3046
|
+
"canvas",
|
|
3047
|
+
"caption",
|
|
3048
|
+
"cite",
|
|
3049
|
+
"code",
|
|
3050
|
+
"colgroup",
|
|
3051
|
+
"data",
|
|
3052
|
+
"datalist",
|
|
3053
|
+
"dd",
|
|
3054
|
+
"del",
|
|
3055
|
+
"details",
|
|
3056
|
+
"dfn",
|
|
3057
|
+
"dialog",
|
|
3058
|
+
"div",
|
|
3059
|
+
"dl",
|
|
3060
|
+
"dt",
|
|
3061
|
+
"em",
|
|
3062
|
+
"fieldset",
|
|
3063
|
+
"figcaption",
|
|
3064
|
+
"figure",
|
|
3065
|
+
"footer",
|
|
3066
|
+
"form",
|
|
3067
|
+
"h1",
|
|
3068
|
+
"h2",
|
|
3069
|
+
"h3",
|
|
3070
|
+
"h4",
|
|
3071
|
+
"h5",
|
|
3072
|
+
"h6",
|
|
3073
|
+
"head",
|
|
3074
|
+
"header",
|
|
3075
|
+
"html",
|
|
3076
|
+
"i",
|
|
3077
|
+
"iframe",
|
|
3078
|
+
"ins",
|
|
3079
|
+
"kbd",
|
|
3080
|
+
"label",
|
|
3081
|
+
"legend",
|
|
3082
|
+
"li",
|
|
3083
|
+
"main",
|
|
3084
|
+
"map",
|
|
3085
|
+
"mark",
|
|
3086
|
+
"menu",
|
|
3087
|
+
"meter",
|
|
3088
|
+
"nav",
|
|
3089
|
+
"noscript",
|
|
3090
|
+
"object",
|
|
3091
|
+
"ol",
|
|
3092
|
+
"optgroup",
|
|
3093
|
+
"option",
|
|
3094
|
+
"output",
|
|
3095
|
+
"p",
|
|
3096
|
+
"picture",
|
|
3097
|
+
"pre",
|
|
3098
|
+
"progress",
|
|
3099
|
+
"q",
|
|
3100
|
+
"rp",
|
|
3101
|
+
"rt",
|
|
3102
|
+
"ruby",
|
|
3103
|
+
"s",
|
|
3104
|
+
"samp",
|
|
3105
|
+
"script",
|
|
3106
|
+
"section",
|
|
3107
|
+
"select",
|
|
3108
|
+
"small",
|
|
3109
|
+
"span",
|
|
3110
|
+
"strong",
|
|
3111
|
+
"style",
|
|
3112
|
+
"sub",
|
|
3113
|
+
"summary",
|
|
3114
|
+
"sup",
|
|
3115
|
+
"svg",
|
|
3116
|
+
"table",
|
|
3117
|
+
"tbody",
|
|
3118
|
+
"td",
|
|
3119
|
+
"template",
|
|
3120
|
+
"textarea",
|
|
3121
|
+
"tfoot",
|
|
3122
|
+
"th",
|
|
3123
|
+
"thead",
|
|
3124
|
+
"time",
|
|
3125
|
+
"title",
|
|
3126
|
+
"tr",
|
|
3127
|
+
"u",
|
|
3128
|
+
"ul",
|
|
3129
|
+
"var",
|
|
3130
|
+
"video"
|
|
3131
|
+
];
|
|
3132
|
+
var HTML_ATOMIC_TAGS2 = [
|
|
3133
|
+
"area",
|
|
3134
|
+
"base",
|
|
3135
|
+
"br",
|
|
3136
|
+
"col",
|
|
3137
|
+
"embed",
|
|
3138
|
+
"hr",
|
|
3139
|
+
"img",
|
|
3140
|
+
"input",
|
|
3141
|
+
"link",
|
|
3142
|
+
"meta",
|
|
3143
|
+
"param",
|
|
3144
|
+
"source",
|
|
3145
|
+
"track",
|
|
3146
|
+
"wbr"
|
|
3147
|
+
];
|
|
2920
3148
|
var ISO3166_12 = [
|
|
2921
3149
|
{ name: "Afghanistan", alpha2: "AF", countryCode: "004", alpha3: "AFG" },
|
|
2922
3150
|
{ name: "Albania", alpha2: "AL", countryCode: "008", alpha3: "ALB" },
|
|
@@ -5734,9 +5962,160 @@ function startsWith(startingWith) {
|
|
|
5734
5962
|
return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
|
|
5735
5963
|
};
|
|
5736
5964
|
}
|
|
5965
|
+
function isHtmlComponentTag(...names) {
|
|
5966
|
+
return (val) => {
|
|
5967
|
+
if (typeof val !== "string")
|
|
5968
|
+
return false;
|
|
5969
|
+
const trimmedVal = val.trim();
|
|
5970
|
+
const tagRegex = /^<\/?([\w-]+)(.*?)>$/;
|
|
5971
|
+
const match = tagRegex.exec(trimmedVal);
|
|
5972
|
+
if (!match) {
|
|
5973
|
+
return false;
|
|
5974
|
+
}
|
|
5975
|
+
const [, tagName, attributes] = match;
|
|
5976
|
+
const isClosingTag = trimmedVal.startsWith("</");
|
|
5977
|
+
const isKebabCase = /^[a-z][a-z0-9-]*$/.test(tagName);
|
|
5978
|
+
const isPascalCase = /^[A-Z][a-zA-Z0-9]*$/.test(tagName);
|
|
5979
|
+
const normalizedKebabCase = toKebabCase(tagName);
|
|
5980
|
+
const normalizedPascalCase = toPascalCase(tagName);
|
|
5981
|
+
const isValidName = names.some(
|
|
5982
|
+
(name) => isKebabCase && normalizedKebabCase === toKebabCase(name) || isPascalCase && normalizedPascalCase === toPascalCase(name)
|
|
5983
|
+
);
|
|
5984
|
+
if (!isValidName) {
|
|
5985
|
+
return false;
|
|
5986
|
+
}
|
|
5987
|
+
if (isClosingTag) {
|
|
5988
|
+
return attributes.trim() === "";
|
|
5989
|
+
}
|
|
5990
|
+
return validHtmlAttributes(attributes);
|
|
5991
|
+
};
|
|
5992
|
+
}
|
|
5993
|
+
function hasHtml(val) {
|
|
5994
|
+
if (typeof val !== "string")
|
|
5995
|
+
return false;
|
|
5996
|
+
const htmlTagRegex = /.*<(\w+)>.*/;
|
|
5997
|
+
return !!htmlTagRegex.test(val);
|
|
5998
|
+
}
|
|
5999
|
+
function hasValidHtml(val) {
|
|
6000
|
+
if (typeof val !== "string")
|
|
6001
|
+
return false;
|
|
6002
|
+
const trimmedVal = val.trim();
|
|
6003
|
+
const tagRegex = /<\/?(\w+)([^>]*)>/g;
|
|
6004
|
+
const stack = [];
|
|
6005
|
+
let match;
|
|
6006
|
+
match = tagRegex.exec(trimmedVal);
|
|
6007
|
+
while (match !== null) {
|
|
6008
|
+
const [, tagName] = match;
|
|
6009
|
+
const isClosingTag = match[0].startsWith("</");
|
|
6010
|
+
const isAtomicTag = HTML_ATOMIC_TAGS2.includes(tagName);
|
|
6011
|
+
if (isAtomicTag) {
|
|
6012
|
+
match = tagRegex.exec(trimmedVal);
|
|
6013
|
+
continue;
|
|
6014
|
+
}
|
|
6015
|
+
if (isClosingTag) {
|
|
6016
|
+
const lastTag = stack.pop();
|
|
6017
|
+
if (lastTag !== tagName) {
|
|
6018
|
+
return false;
|
|
6019
|
+
}
|
|
6020
|
+
} else {
|
|
6021
|
+
if (!HTML_BLOCK_TAGS2.includes(tagName)) {
|
|
6022
|
+
return false;
|
|
6023
|
+
}
|
|
6024
|
+
stack.push(tagName);
|
|
6025
|
+
}
|
|
6026
|
+
match = tagRegex.exec(trimmedVal);
|
|
6027
|
+
}
|
|
6028
|
+
return stack.length === 0 && tagRegex.test(trimmedVal);
|
|
6029
|
+
}
|
|
6030
|
+
function isValidBlockTag(val) {
|
|
6031
|
+
return isString(val) && HTML_BLOCK_TAGS2.includes(val.toLowerCase());
|
|
6032
|
+
}
|
|
6033
|
+
function isValidAtomicTag(val) {
|
|
6034
|
+
return isString(val) && HTML_ATOMIC_TAGS2.includes(val.toLowerCase());
|
|
6035
|
+
}
|
|
6036
|
+
function isValidHtmlTag(...tags) {
|
|
6037
|
+
return (val) => {
|
|
6038
|
+
if (typeof val !== "string")
|
|
6039
|
+
return false;
|
|
6040
|
+
const trimmedVal = val.trim();
|
|
6041
|
+
const tagRegex = /^<\/?(\w+)(.*?)>$/;
|
|
6042
|
+
const match = tagRegex.exec(trimmedVal);
|
|
6043
|
+
if (!match) {
|
|
6044
|
+
return false;
|
|
6045
|
+
}
|
|
6046
|
+
const [, tagName, attributes] = match;
|
|
6047
|
+
const normalizedTagName = tagName.toLowerCase();
|
|
6048
|
+
const isClosingTag = trimmedVal.startsWith("</");
|
|
6049
|
+
const isAtomicTag = HTML_ATOMIC_TAGS2.includes(normalizedTagName);
|
|
6050
|
+
const isBlockTag = HTML_BLOCK_TAGS2.includes(normalizedTagName);
|
|
6051
|
+
if (
|
|
6052
|
+
// Validate tag name is within the provided `tags` scope
|
|
6053
|
+
!tags.map((t) => t.toLowerCase()).includes(normalizedTagName)
|
|
6054
|
+
) {
|
|
6055
|
+
return false;
|
|
6056
|
+
}
|
|
6057
|
+
if (isClosingTag) {
|
|
6058
|
+
return attributes.trim() === "" && !isAtomicTag;
|
|
6059
|
+
}
|
|
6060
|
+
if (isAtomicTag) {
|
|
6061
|
+
return attributes.trim() === "" || validHtmlAttributes(attributes);
|
|
6062
|
+
}
|
|
6063
|
+
if (isBlockTag) {
|
|
6064
|
+
return validHtmlAttributes(attributes);
|
|
6065
|
+
}
|
|
6066
|
+
return false;
|
|
6067
|
+
};
|
|
6068
|
+
}
|
|
6069
|
+
function isHtml(val) {
|
|
6070
|
+
if (typeof val !== "string")
|
|
6071
|
+
return false;
|
|
6072
|
+
const trimmedVal = val.trim();
|
|
6073
|
+
const fullHtmlRegex = /^<(\w+).*<\/\1>$/;
|
|
6074
|
+
return fullHtmlRegex.test(trimmedVal);
|
|
6075
|
+
}
|
|
6076
|
+
function isValidHtml(val) {
|
|
6077
|
+
if (typeof val !== "string")
|
|
6078
|
+
return false;
|
|
6079
|
+
const trimmedVal = val.trim();
|
|
6080
|
+
const tagRegex = /<\/?(\w+)([^>]*)>/g;
|
|
6081
|
+
const stack = [];
|
|
6082
|
+
let match = tagRegex.exec(trimmedVal);
|
|
6083
|
+
while (match !== null) {
|
|
6084
|
+
const [, tagName] = match;
|
|
6085
|
+
const isClosingTag = match[0].startsWith("</");
|
|
6086
|
+
const isAtomicTag = HTML_ATOMIC_TAGS2.includes(tagName);
|
|
6087
|
+
if (isAtomicTag) {
|
|
6088
|
+
match = tagRegex.exec(trimmedVal);
|
|
6089
|
+
continue;
|
|
6090
|
+
}
|
|
6091
|
+
if (isClosingTag) {
|
|
6092
|
+
const lastTag = stack.pop();
|
|
6093
|
+
if (lastTag !== tagName) {
|
|
6094
|
+
return false;
|
|
6095
|
+
}
|
|
6096
|
+
} else {
|
|
6097
|
+
if (!HTML_BLOCK_TAGS2.includes(tagName)) {
|
|
6098
|
+
return false;
|
|
6099
|
+
}
|
|
6100
|
+
stack.push(tagName);
|
|
6101
|
+
}
|
|
6102
|
+
match = tagRegex.exec(trimmedVal);
|
|
6103
|
+
}
|
|
6104
|
+
const isBalanced = stack.length === 0;
|
|
6105
|
+
const validStructureRegex = /^<(\w+)[^>]*>[\s\S]*<\/\1>$/;
|
|
6106
|
+
return isBalanced && validStructureRegex.test(trimmedVal);
|
|
6107
|
+
}
|
|
5737
6108
|
function isHtmlElement(val) {
|
|
5738
6109
|
return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
|
|
5739
6110
|
}
|
|
6111
|
+
function validHtmlAttributes(val) {
|
|
6112
|
+
if (typeof val !== "string")
|
|
6113
|
+
return false;
|
|
6114
|
+
const quoteRegex = /["']/g;
|
|
6115
|
+
const unmatchedQuotes = (val.match(quoteRegex)?.length || 0) % 2 !== 0;
|
|
6116
|
+
const invalidAssignment = /(\w+=)(?=\s|>|$)/.test(val);
|
|
6117
|
+
return !val.includes(">") && !unmatchedQuotes && !invalidAssignment;
|
|
6118
|
+
}
|
|
5740
6119
|
function isAlpha(value) {
|
|
5741
6120
|
return isString(value) && split(value).every((v) => ALPHA_CHARS2.includes(v));
|
|
5742
6121
|
}
|
|
@@ -8009,6 +8388,8 @@ export {
|
|
|
8009
8388
|
HASH_TABLE_WIDE,
|
|
8010
8389
|
HM_DNS,
|
|
8011
8390
|
HOME_DEPOT_DNS,
|
|
8391
|
+
HTML_ATOMIC_TAGS,
|
|
8392
|
+
HTML_BLOCK_TAGS,
|
|
8012
8393
|
IKEA_DNS,
|
|
8013
8394
|
IMAGE_FORMAT_LOOKUP,
|
|
8014
8395
|
INDIAN_NEWS,
|
|
@@ -8235,6 +8616,7 @@ export {
|
|
|
8235
8616
|
handleDoneFn,
|
|
8236
8617
|
hasCountryCode,
|
|
8237
8618
|
hasDefaultValue,
|
|
8619
|
+
hasHtml,
|
|
8238
8620
|
hasIndexOf,
|
|
8239
8621
|
hasKeys,
|
|
8240
8622
|
hasOverlappingKeys,
|
|
@@ -8242,6 +8624,7 @@ export {
|
|
|
8242
8624
|
hasProtocolPrefix,
|
|
8243
8625
|
hasUrlPort,
|
|
8244
8626
|
hasUrlQueryParameter,
|
|
8627
|
+
hasValidHtml,
|
|
8245
8628
|
hasWhiteSpace,
|
|
8246
8629
|
idLiteral,
|
|
8247
8630
|
idTypeGuard,
|
|
@@ -8354,6 +8737,8 @@ export {
|
|
|
8354
8737
|
isHexadecimal,
|
|
8355
8738
|
isHmUrl,
|
|
8356
8739
|
isHomeDepotUrl,
|
|
8740
|
+
isHtml,
|
|
8741
|
+
isHtmlComponentTag,
|
|
8357
8742
|
isHtmlElement,
|
|
8358
8743
|
isIkeaUrl,
|
|
8359
8744
|
isIndexable,
|
|
@@ -8497,6 +8882,10 @@ export {
|
|
|
8497
8882
|
isUsPhoneNumber,
|
|
8498
8883
|
isUsStateAbbreviation,
|
|
8499
8884
|
isUsStateName,
|
|
8885
|
+
isValidAtomicTag,
|
|
8886
|
+
isValidBlockTag,
|
|
8887
|
+
isValidHtml,
|
|
8888
|
+
isValidHtmlTag,
|
|
8500
8889
|
isVariable,
|
|
8501
8890
|
isVisa,
|
|
8502
8891
|
isVisaMastercard,
|
|
@@ -8623,6 +9012,7 @@ export {
|
|
|
8623
9012
|
unset,
|
|
8624
9013
|
uppercase,
|
|
8625
9014
|
urlMeta,
|
|
9015
|
+
validHtmlAttributes,
|
|
8626
9016
|
valuesOf,
|
|
8627
9017
|
widen,
|
|
8628
9018
|
withDefaults,
|