inferred-types 0.55.17 → 0.55.18

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.
@@ -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,6 +5962,88 @@ function startsWith(startingWith) {
5734
5962
  return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
5735
5963
  };
5736
5964
  }
5965
+ function hasHtml(val) {
5966
+ if (typeof val !== "string")
5967
+ return false;
5968
+ const htmlTagRegex = /.*<(\w+)>.*/;
5969
+ return !!htmlTagRegex.test(val);
5970
+ }
5971
+ function hasValidHtml(val) {
5972
+ if (typeof val !== "string")
5973
+ return false;
5974
+ const trimmedVal = val.trim();
5975
+ const tagRegex = /<\/?(\w+)([^>]*)>/g;
5976
+ const stack = [];
5977
+ let match;
5978
+ match = tagRegex.exec(trimmedVal);
5979
+ while (match !== null) {
5980
+ const [, tagName] = match;
5981
+ const isClosingTag = match[0].startsWith("</");
5982
+ const isAtomicTag = HTML_ATOMIC_TAGS2.includes(tagName);
5983
+ if (isAtomicTag) {
5984
+ match = tagRegex.exec(trimmedVal);
5985
+ continue;
5986
+ }
5987
+ if (isClosingTag) {
5988
+ const lastTag = stack.pop();
5989
+ if (lastTag !== tagName) {
5990
+ return false;
5991
+ }
5992
+ } else {
5993
+ if (!HTML_BLOCK_TAGS2.includes(tagName)) {
5994
+ return false;
5995
+ }
5996
+ stack.push(tagName);
5997
+ }
5998
+ match = tagRegex.exec(trimmedVal);
5999
+ }
6000
+ return stack.length === 0 && tagRegex.test(trimmedVal);
6001
+ }
6002
+ function isValidBlockTag(val) {
6003
+ return isString(val) && HTML_BLOCK_TAGS2.includes(val.toLowerCase());
6004
+ }
6005
+ function isValidAtomicTag(val) {
6006
+ return isString(val) && HTML_ATOMIC_TAGS2.includes(val.toLowerCase());
6007
+ }
6008
+ function isHtml(val) {
6009
+ if (typeof val !== "string")
6010
+ return false;
6011
+ const trimmedVal = val.trim();
6012
+ const fullHtmlRegex = /^<(\w+).*<\/\1>$/;
6013
+ return fullHtmlRegex.test(trimmedVal);
6014
+ }
6015
+ function isValidHtml(val) {
6016
+ if (typeof val !== "string")
6017
+ return false;
6018
+ const trimmedVal = val.trim();
6019
+ const tagRegex = /<\/?(\w+)([^>]*)>/g;
6020
+ const stack = [];
6021
+ let match = tagRegex.exec(trimmedVal);
6022
+ while (match !== null) {
6023
+ const [, tagName] = match;
6024
+ const isClosingTag = match[0].startsWith("</");
6025
+ const isAtomicTag = HTML_ATOMIC_TAGS2.includes(tagName);
6026
+ if (isAtomicTag) {
6027
+ match = tagRegex.exec(trimmedVal);
6028
+ continue;
6029
+ }
6030
+ if (isClosingTag) {
6031
+ const lastTag = stack.pop();
6032
+ if (lastTag !== tagName) {
6033
+ return false;
6034
+ }
6035
+ } else {
6036
+ if (!HTML_BLOCK_TAGS2.includes(tagName)) {
6037
+ return false;
6038
+ }
6039
+ stack.push(tagName);
6040
+ }
6041
+ match = tagRegex.exec(trimmedVal);
6042
+ }
6043
+ const isBalanced = stack.length === 0;
6044
+ const validStructureRegex = /^<(\w+)[^>]*>[\s\S]*<\/\1>$/;
6045
+ return isBalanced && validStructureRegex.test(trimmedVal);
6046
+ }
5737
6047
  function isHtmlElement(val) {
5738
6048
  return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
5739
6049
  }
@@ -8009,6 +8319,8 @@ export {
8009
8319
  HASH_TABLE_WIDE,
8010
8320
  HM_DNS,
8011
8321
  HOME_DEPOT_DNS,
8322
+ HTML_ATOMIC_TAGS,
8323
+ HTML_BLOCK_TAGS,
8012
8324
  IKEA_DNS,
8013
8325
  IMAGE_FORMAT_LOOKUP,
8014
8326
  INDIAN_NEWS,
@@ -8235,6 +8547,7 @@ export {
8235
8547
  handleDoneFn,
8236
8548
  hasCountryCode,
8237
8549
  hasDefaultValue,
8550
+ hasHtml,
8238
8551
  hasIndexOf,
8239
8552
  hasKeys,
8240
8553
  hasOverlappingKeys,
@@ -8242,6 +8555,7 @@ export {
8242
8555
  hasProtocolPrefix,
8243
8556
  hasUrlPort,
8244
8557
  hasUrlQueryParameter,
8558
+ hasValidHtml,
8245
8559
  hasWhiteSpace,
8246
8560
  idLiteral,
8247
8561
  idTypeGuard,
@@ -8354,6 +8668,7 @@ export {
8354
8668
  isHexadecimal,
8355
8669
  isHmUrl,
8356
8670
  isHomeDepotUrl,
8671
+ isHtml,
8357
8672
  isHtmlElement,
8358
8673
  isIkeaUrl,
8359
8674
  isIndexable,
@@ -8497,6 +8812,9 @@ export {
8497
8812
  isUsPhoneNumber,
8498
8813
  isUsStateAbbreviation,
8499
8814
  isUsStateName,
8815
+ isValidAtomicTag,
8816
+ isValidBlockTag,
8817
+ isValidHtml,
8500
8818
  isVariable,
8501
8819
  isVisa,
8502
8820
  isVisaMastercard,