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.
@@ -76,6 +76,8 @@ __export(index_exports, {
76
76
  HASH_TABLE_WIDE: () => HASH_TABLE_WIDE,
77
77
  HM_DNS: () => HM_DNS,
78
78
  HOME_DEPOT_DNS: () => HOME_DEPOT_DNS,
79
+ HTML_ATOMIC_TAGS: () => HTML_ATOMIC_TAGS,
80
+ HTML_BLOCK_TAGS: () => HTML_BLOCK_TAGS,
79
81
  IKEA_DNS: () => IKEA_DNS,
80
82
  IMAGE_FORMAT_LOOKUP: () => IMAGE_FORMAT_LOOKUP,
81
83
  INDIAN_NEWS: () => INDIAN_NEWS,
@@ -302,6 +304,7 @@ __export(index_exports, {
302
304
  handleDoneFn: () => handleDoneFn,
303
305
  hasCountryCode: () => hasCountryCode,
304
306
  hasDefaultValue: () => hasDefaultValue,
307
+ hasHtml: () => hasHtml,
305
308
  hasIndexOf: () => hasIndexOf,
306
309
  hasKeys: () => hasKeys,
307
310
  hasOverlappingKeys: () => hasOverlappingKeys,
@@ -309,6 +312,7 @@ __export(index_exports, {
309
312
  hasProtocolPrefix: () => hasProtocolPrefix,
310
313
  hasUrlPort: () => hasUrlPort,
311
314
  hasUrlQueryParameter: () => hasUrlQueryParameter,
315
+ hasValidHtml: () => hasValidHtml,
312
316
  hasWhiteSpace: () => hasWhiteSpace,
313
317
  idLiteral: () => idLiteral,
314
318
  idTypeGuard: () => idTypeGuard,
@@ -421,6 +425,8 @@ __export(index_exports, {
421
425
  isHexadecimal: () => isHexadecimal,
422
426
  isHmUrl: () => isHmUrl,
423
427
  isHomeDepotUrl: () => isHomeDepotUrl,
428
+ isHtml: () => isHtml,
429
+ isHtmlComponentTag: () => isHtmlComponentTag,
424
430
  isHtmlElement: () => isHtmlElement,
425
431
  isIkeaUrl: () => isIkeaUrl,
426
432
  isIndexable: () => isIndexable,
@@ -564,6 +570,10 @@ __export(index_exports, {
564
570
  isUsPhoneNumber: () => isUsPhoneNumber,
565
571
  isUsStateAbbreviation: () => isUsStateAbbreviation,
566
572
  isUsStateName: () => isUsStateName,
573
+ isValidAtomicTag: () => isValidAtomicTag,
574
+ isValidBlockTag: () => isValidBlockTag,
575
+ isValidHtml: () => isValidHtml,
576
+ isValidHtmlTag: () => isValidHtmlTag,
567
577
  isVariable: () => isVariable,
568
578
  isVisa: () => isVisa,
569
579
  isVisaMastercard: () => isVisaMastercard,
@@ -690,6 +700,7 @@ __export(index_exports, {
690
700
  unset: () => unset,
691
701
  uppercase: () => uppercase,
692
702
  urlMeta: () => urlMeta,
703
+ validHtmlAttributes: () => validHtmlAttributes,
693
704
  valuesOf: () => valuesOf,
694
705
  widen: () => widen,
695
706
  withDefaults: () => withDefaults,
@@ -1213,6 +1224,120 @@ var HASH_TABLE_CHAR = {
1213
1224
  ...HASH_TABLE_SPECIAL
1214
1225
  };
1215
1226
  var HASH_TABLE_OTHER = "999";
1227
+ var HTML_BLOCK_TAGS = [
1228
+ "a",
1229
+ "abbr",
1230
+ "address",
1231
+ "article",
1232
+ "aside",
1233
+ "b",
1234
+ "bdi",
1235
+ "bdo",
1236
+ "blockquote",
1237
+ "body",
1238
+ "button",
1239
+ "canvas",
1240
+ "caption",
1241
+ "cite",
1242
+ "code",
1243
+ "colgroup",
1244
+ "data",
1245
+ "datalist",
1246
+ "dd",
1247
+ "del",
1248
+ "details",
1249
+ "dfn",
1250
+ "dialog",
1251
+ "div",
1252
+ "dl",
1253
+ "dt",
1254
+ "em",
1255
+ "fieldset",
1256
+ "figcaption",
1257
+ "figure",
1258
+ "footer",
1259
+ "form",
1260
+ "h1",
1261
+ "h2",
1262
+ "h3",
1263
+ "h4",
1264
+ "h5",
1265
+ "h6",
1266
+ "head",
1267
+ "header",
1268
+ "html",
1269
+ "i",
1270
+ "iframe",
1271
+ "ins",
1272
+ "kbd",
1273
+ "label",
1274
+ "legend",
1275
+ "li",
1276
+ "main",
1277
+ "map",
1278
+ "mark",
1279
+ "menu",
1280
+ "meter",
1281
+ "nav",
1282
+ "noscript",
1283
+ "object",
1284
+ "ol",
1285
+ "optgroup",
1286
+ "option",
1287
+ "output",
1288
+ "p",
1289
+ "picture",
1290
+ "pre",
1291
+ "progress",
1292
+ "q",
1293
+ "rp",
1294
+ "rt",
1295
+ "ruby",
1296
+ "s",
1297
+ "samp",
1298
+ "script",
1299
+ "section",
1300
+ "select",
1301
+ "small",
1302
+ "span",
1303
+ "strong",
1304
+ "style",
1305
+ "sub",
1306
+ "summary",
1307
+ "sup",
1308
+ "svg",
1309
+ "table",
1310
+ "tbody",
1311
+ "td",
1312
+ "template",
1313
+ "textarea",
1314
+ "tfoot",
1315
+ "th",
1316
+ "thead",
1317
+ "time",
1318
+ "title",
1319
+ "tr",
1320
+ "u",
1321
+ "ul",
1322
+ "var",
1323
+ "video"
1324
+ ];
1325
+ var HTML_ATOMIC_TAGS = [
1326
+ "area",
1327
+ "base",
1328
+ "br",
1329
+ "col",
1330
+ "embed",
1331
+ "hr",
1332
+ "img",
1333
+ "input",
1334
+ "link",
1335
+ "meta",
1336
+ "param",
1337
+ "source",
1338
+ "track",
1339
+ "wbr"
1340
+ ];
1216
1341
  var MIME_TYPES = [
1217
1342
  // Application MIME Types
1218
1343
  "application/json",
@@ -3622,6 +3747,120 @@ var HASH_TABLE_CHAR2 = {
3622
3747
  ...HASH_TABLE_ALPHA_UPPER2,
3623
3748
  ...HASH_TABLE_SPECIAL2
3624
3749
  };
3750
+ var HTML_BLOCK_TAGS2 = [
3751
+ "a",
3752
+ "abbr",
3753
+ "address",
3754
+ "article",
3755
+ "aside",
3756
+ "b",
3757
+ "bdi",
3758
+ "bdo",
3759
+ "blockquote",
3760
+ "body",
3761
+ "button",
3762
+ "canvas",
3763
+ "caption",
3764
+ "cite",
3765
+ "code",
3766
+ "colgroup",
3767
+ "data",
3768
+ "datalist",
3769
+ "dd",
3770
+ "del",
3771
+ "details",
3772
+ "dfn",
3773
+ "dialog",
3774
+ "div",
3775
+ "dl",
3776
+ "dt",
3777
+ "em",
3778
+ "fieldset",
3779
+ "figcaption",
3780
+ "figure",
3781
+ "footer",
3782
+ "form",
3783
+ "h1",
3784
+ "h2",
3785
+ "h3",
3786
+ "h4",
3787
+ "h5",
3788
+ "h6",
3789
+ "head",
3790
+ "header",
3791
+ "html",
3792
+ "i",
3793
+ "iframe",
3794
+ "ins",
3795
+ "kbd",
3796
+ "label",
3797
+ "legend",
3798
+ "li",
3799
+ "main",
3800
+ "map",
3801
+ "mark",
3802
+ "menu",
3803
+ "meter",
3804
+ "nav",
3805
+ "noscript",
3806
+ "object",
3807
+ "ol",
3808
+ "optgroup",
3809
+ "option",
3810
+ "output",
3811
+ "p",
3812
+ "picture",
3813
+ "pre",
3814
+ "progress",
3815
+ "q",
3816
+ "rp",
3817
+ "rt",
3818
+ "ruby",
3819
+ "s",
3820
+ "samp",
3821
+ "script",
3822
+ "section",
3823
+ "select",
3824
+ "small",
3825
+ "span",
3826
+ "strong",
3827
+ "style",
3828
+ "sub",
3829
+ "summary",
3830
+ "sup",
3831
+ "svg",
3832
+ "table",
3833
+ "tbody",
3834
+ "td",
3835
+ "template",
3836
+ "textarea",
3837
+ "tfoot",
3838
+ "th",
3839
+ "thead",
3840
+ "time",
3841
+ "title",
3842
+ "tr",
3843
+ "u",
3844
+ "ul",
3845
+ "var",
3846
+ "video"
3847
+ ];
3848
+ var HTML_ATOMIC_TAGS2 = [
3849
+ "area",
3850
+ "base",
3851
+ "br",
3852
+ "col",
3853
+ "embed",
3854
+ "hr",
3855
+ "img",
3856
+ "input",
3857
+ "link",
3858
+ "meta",
3859
+ "param",
3860
+ "source",
3861
+ "track",
3862
+ "wbr"
3863
+ ];
3625
3864
  var ISO3166_12 = [
3626
3865
  { name: "Afghanistan", alpha2: "AF", countryCode: "004", alpha3: "AFG" },
3627
3866
  { name: "Albania", alpha2: "AL", countryCode: "008", alpha3: "ALB" },
@@ -6439,9 +6678,160 @@ function startsWith(startingWith) {
6439
6678
  return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
6440
6679
  };
6441
6680
  }
6681
+ function isHtmlComponentTag(...names) {
6682
+ return (val) => {
6683
+ if (typeof val !== "string")
6684
+ return false;
6685
+ const trimmedVal = val.trim();
6686
+ const tagRegex = /^<\/?([\w-]+)(.*?)>$/;
6687
+ const match = tagRegex.exec(trimmedVal);
6688
+ if (!match) {
6689
+ return false;
6690
+ }
6691
+ const [, tagName, attributes] = match;
6692
+ const isClosingTag = trimmedVal.startsWith("</");
6693
+ const isKebabCase = /^[a-z][a-z0-9-]*$/.test(tagName);
6694
+ const isPascalCase = /^[A-Z][a-zA-Z0-9]*$/.test(tagName);
6695
+ const normalizedKebabCase = toKebabCase(tagName);
6696
+ const normalizedPascalCase = toPascalCase(tagName);
6697
+ const isValidName = names.some(
6698
+ (name) => isKebabCase && normalizedKebabCase === toKebabCase(name) || isPascalCase && normalizedPascalCase === toPascalCase(name)
6699
+ );
6700
+ if (!isValidName) {
6701
+ return false;
6702
+ }
6703
+ if (isClosingTag) {
6704
+ return attributes.trim() === "";
6705
+ }
6706
+ return validHtmlAttributes(attributes);
6707
+ };
6708
+ }
6709
+ function hasHtml(val) {
6710
+ if (typeof val !== "string")
6711
+ return false;
6712
+ const htmlTagRegex = /.*<(\w+)>.*/;
6713
+ return !!htmlTagRegex.test(val);
6714
+ }
6715
+ function hasValidHtml(val) {
6716
+ if (typeof val !== "string")
6717
+ return false;
6718
+ const trimmedVal = val.trim();
6719
+ const tagRegex = /<\/?(\w+)([^>]*)>/g;
6720
+ const stack = [];
6721
+ let match;
6722
+ match = tagRegex.exec(trimmedVal);
6723
+ while (match !== null) {
6724
+ const [, tagName] = match;
6725
+ const isClosingTag = match[0].startsWith("</");
6726
+ const isAtomicTag = HTML_ATOMIC_TAGS2.includes(tagName);
6727
+ if (isAtomicTag) {
6728
+ match = tagRegex.exec(trimmedVal);
6729
+ continue;
6730
+ }
6731
+ if (isClosingTag) {
6732
+ const lastTag = stack.pop();
6733
+ if (lastTag !== tagName) {
6734
+ return false;
6735
+ }
6736
+ } else {
6737
+ if (!HTML_BLOCK_TAGS2.includes(tagName)) {
6738
+ return false;
6739
+ }
6740
+ stack.push(tagName);
6741
+ }
6742
+ match = tagRegex.exec(trimmedVal);
6743
+ }
6744
+ return stack.length === 0 && tagRegex.test(trimmedVal);
6745
+ }
6746
+ function isValidBlockTag(val) {
6747
+ return isString(val) && HTML_BLOCK_TAGS2.includes(val.toLowerCase());
6748
+ }
6749
+ function isValidAtomicTag(val) {
6750
+ return isString(val) && HTML_ATOMIC_TAGS2.includes(val.toLowerCase());
6751
+ }
6752
+ function isValidHtmlTag(...tags) {
6753
+ return (val) => {
6754
+ if (typeof val !== "string")
6755
+ return false;
6756
+ const trimmedVal = val.trim();
6757
+ const tagRegex = /^<\/?(\w+)(.*?)>$/;
6758
+ const match = tagRegex.exec(trimmedVal);
6759
+ if (!match) {
6760
+ return false;
6761
+ }
6762
+ const [, tagName, attributes] = match;
6763
+ const normalizedTagName = tagName.toLowerCase();
6764
+ const isClosingTag = trimmedVal.startsWith("</");
6765
+ const isAtomicTag = HTML_ATOMIC_TAGS2.includes(normalizedTagName);
6766
+ const isBlockTag = HTML_BLOCK_TAGS2.includes(normalizedTagName);
6767
+ if (
6768
+ // Validate tag name is within the provided `tags` scope
6769
+ !tags.map((t) => t.toLowerCase()).includes(normalizedTagName)
6770
+ ) {
6771
+ return false;
6772
+ }
6773
+ if (isClosingTag) {
6774
+ return attributes.trim() === "" && !isAtomicTag;
6775
+ }
6776
+ if (isAtomicTag) {
6777
+ return attributes.trim() === "" || validHtmlAttributes(attributes);
6778
+ }
6779
+ if (isBlockTag) {
6780
+ return validHtmlAttributes(attributes);
6781
+ }
6782
+ return false;
6783
+ };
6784
+ }
6785
+ function isHtml(val) {
6786
+ if (typeof val !== "string")
6787
+ return false;
6788
+ const trimmedVal = val.trim();
6789
+ const fullHtmlRegex = /^<(\w+).*<\/\1>$/;
6790
+ return fullHtmlRegex.test(trimmedVal);
6791
+ }
6792
+ function isValidHtml(val) {
6793
+ if (typeof val !== "string")
6794
+ return false;
6795
+ const trimmedVal = val.trim();
6796
+ const tagRegex = /<\/?(\w+)([^>]*)>/g;
6797
+ const stack = [];
6798
+ let match = tagRegex.exec(trimmedVal);
6799
+ while (match !== null) {
6800
+ const [, tagName] = match;
6801
+ const isClosingTag = match[0].startsWith("</");
6802
+ const isAtomicTag = HTML_ATOMIC_TAGS2.includes(tagName);
6803
+ if (isAtomicTag) {
6804
+ match = tagRegex.exec(trimmedVal);
6805
+ continue;
6806
+ }
6807
+ if (isClosingTag) {
6808
+ const lastTag = stack.pop();
6809
+ if (lastTag !== tagName) {
6810
+ return false;
6811
+ }
6812
+ } else {
6813
+ if (!HTML_BLOCK_TAGS2.includes(tagName)) {
6814
+ return false;
6815
+ }
6816
+ stack.push(tagName);
6817
+ }
6818
+ match = tagRegex.exec(trimmedVal);
6819
+ }
6820
+ const isBalanced = stack.length === 0;
6821
+ const validStructureRegex = /^<(\w+)[^>]*>[\s\S]*<\/\1>$/;
6822
+ return isBalanced && validStructureRegex.test(trimmedVal);
6823
+ }
6442
6824
  function isHtmlElement(val) {
6443
6825
  return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
6444
6826
  }
6827
+ function validHtmlAttributes(val) {
6828
+ if (typeof val !== "string")
6829
+ return false;
6830
+ const quoteRegex = /["']/g;
6831
+ const unmatchedQuotes = (val.match(quoteRegex)?.length || 0) % 2 !== 0;
6832
+ const invalidAssignment = /(\w+=)(?=\s|>|$)/.test(val);
6833
+ return !val.includes(">") && !unmatchedQuotes && !invalidAssignment;
6834
+ }
6445
6835
  function isAlpha(value) {
6446
6836
  return isString(value) && split(value).every((v) => ALPHA_CHARS2.includes(v));
6447
6837
  }
@@ -8715,6 +9105,8 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
8715
9105
  HASH_TABLE_WIDE,
8716
9106
  HM_DNS,
8717
9107
  HOME_DEPOT_DNS,
9108
+ HTML_ATOMIC_TAGS,
9109
+ HTML_BLOCK_TAGS,
8718
9110
  IKEA_DNS,
8719
9111
  IMAGE_FORMAT_LOOKUP,
8720
9112
  INDIAN_NEWS,
@@ -8941,6 +9333,7 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
8941
9333
  handleDoneFn,
8942
9334
  hasCountryCode,
8943
9335
  hasDefaultValue,
9336
+ hasHtml,
8944
9337
  hasIndexOf,
8945
9338
  hasKeys,
8946
9339
  hasOverlappingKeys,
@@ -8948,6 +9341,7 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
8948
9341
  hasProtocolPrefix,
8949
9342
  hasUrlPort,
8950
9343
  hasUrlQueryParameter,
9344
+ hasValidHtml,
8951
9345
  hasWhiteSpace,
8952
9346
  idLiteral,
8953
9347
  idTypeGuard,
@@ -9060,6 +9454,8 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
9060
9454
  isHexadecimal,
9061
9455
  isHmUrl,
9062
9456
  isHomeDepotUrl,
9457
+ isHtml,
9458
+ isHtmlComponentTag,
9063
9459
  isHtmlElement,
9064
9460
  isIkeaUrl,
9065
9461
  isIndexable,
@@ -9203,6 +9599,10 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
9203
9599
  isUsPhoneNumber,
9204
9600
  isUsStateAbbreviation,
9205
9601
  isUsStateName,
9602
+ isValidAtomicTag,
9603
+ isValidBlockTag,
9604
+ isValidHtml,
9605
+ isValidHtmlTag,
9206
9606
  isVariable,
9207
9607
  isVisa,
9208
9608
  isVisaMastercard,
@@ -9329,6 +9729,7 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
9329
9729
  unset,
9330
9730
  uppercase,
9331
9731
  urlMeta,
9732
+ validHtmlAttributes,
9332
9733
  valuesOf,
9333
9734
  widen,
9334
9735
  withDefaults,