inferred-types 0.55.18 → 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/inferred-types/dist/index.cjs +75 -0
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +126 -10
- package/modules/inferred-types/dist/index.js +72 -0
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +79 -0
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +99 -3
- package/modules/runtime/dist/index.js +76 -0
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.d.ts +26 -6
- package/package.json +1 -1
|
@@ -222,6 +222,7 @@ __export(index_exports, {
|
|
|
222
222
|
isHmUrl: () => isHmUrl,
|
|
223
223
|
isHomeDepotUrl: () => isHomeDepotUrl,
|
|
224
224
|
isHtml: () => isHtml,
|
|
225
|
+
isHtmlComponentTag: () => isHtmlComponentTag,
|
|
225
226
|
isHtmlElement: () => isHtmlElement,
|
|
226
227
|
isIkeaUrl: () => isIkeaUrl,
|
|
227
228
|
isIndexable: () => isIndexable,
|
|
@@ -368,6 +369,7 @@ __export(index_exports, {
|
|
|
368
369
|
isValidAtomicTag: () => isValidAtomicTag,
|
|
369
370
|
isValidBlockTag: () => isValidBlockTag,
|
|
370
371
|
isValidHtml: () => isValidHtml,
|
|
372
|
+
isValidHtmlTag: () => isValidHtmlTag,
|
|
371
373
|
isVariable: () => isVariable,
|
|
372
374
|
isVisa: () => isVisa,
|
|
373
375
|
isVisaMastercard: () => isVisaMastercard,
|
|
@@ -494,6 +496,7 @@ __export(index_exports, {
|
|
|
494
496
|
unset: () => unset,
|
|
495
497
|
uppercase: () => uppercase,
|
|
496
498
|
urlMeta: () => urlMeta,
|
|
499
|
+
validHtmlAttributes: () => validHtmlAttributes,
|
|
497
500
|
valuesOf: () => valuesOf,
|
|
498
501
|
widen: () => widen,
|
|
499
502
|
withDefaults: () => withDefaults,
|
|
@@ -4000,6 +4003,36 @@ function startsWith(startingWith) {
|
|
|
4000
4003
|
};
|
|
4001
4004
|
}
|
|
4002
4005
|
|
|
4006
|
+
// src/type-guards/html/component-tags.ts
|
|
4007
|
+
function isHtmlComponentTag(...names) {
|
|
4008
|
+
return (val) => {
|
|
4009
|
+
if (typeof val !== "string")
|
|
4010
|
+
return false;
|
|
4011
|
+
const trimmedVal = val.trim();
|
|
4012
|
+
const tagRegex = /^<\/?([\w-]+)(.*?)>$/;
|
|
4013
|
+
const match = tagRegex.exec(trimmedVal);
|
|
4014
|
+
if (!match) {
|
|
4015
|
+
return false;
|
|
4016
|
+
}
|
|
4017
|
+
const [, tagName, attributes] = match;
|
|
4018
|
+
const isClosingTag = trimmedVal.startsWith("</");
|
|
4019
|
+
const isKebabCase = /^[a-z][a-z0-9-]*$/.test(tagName);
|
|
4020
|
+
const isPascalCase = /^[A-Z][a-zA-Z0-9]*$/.test(tagName);
|
|
4021
|
+
const normalizedKebabCase = toKebabCase(tagName);
|
|
4022
|
+
const normalizedPascalCase = toPascalCase(tagName);
|
|
4023
|
+
const isValidName = names.some(
|
|
4024
|
+
(name) => isKebabCase && normalizedKebabCase === toKebabCase(name) || isPascalCase && normalizedPascalCase === toPascalCase(name)
|
|
4025
|
+
);
|
|
4026
|
+
if (!isValidName) {
|
|
4027
|
+
return false;
|
|
4028
|
+
}
|
|
4029
|
+
if (isClosingTag) {
|
|
4030
|
+
return attributes.trim() === "";
|
|
4031
|
+
}
|
|
4032
|
+
return validHtmlAttributes(attributes);
|
|
4033
|
+
};
|
|
4034
|
+
}
|
|
4035
|
+
|
|
4003
4036
|
// src/type-guards/html/hasHtml.ts
|
|
4004
4037
|
function hasHtml(val) {
|
|
4005
4038
|
if (typeof val !== "string")
|
|
@@ -4046,6 +4079,39 @@ function isValidBlockTag(val) {
|
|
|
4046
4079
|
function isValidAtomicTag(val) {
|
|
4047
4080
|
return isString(val) && HTML_ATOMIC_TAGS.includes(val.toLowerCase());
|
|
4048
4081
|
}
|
|
4082
|
+
function isValidHtmlTag(...tags) {
|
|
4083
|
+
return (val) => {
|
|
4084
|
+
if (typeof val !== "string")
|
|
4085
|
+
return false;
|
|
4086
|
+
const trimmedVal = val.trim();
|
|
4087
|
+
const tagRegex = /^<\/?(\w+)(.*?)>$/;
|
|
4088
|
+
const match = tagRegex.exec(trimmedVal);
|
|
4089
|
+
if (!match) {
|
|
4090
|
+
return false;
|
|
4091
|
+
}
|
|
4092
|
+
const [, tagName, attributes] = match;
|
|
4093
|
+
const normalizedTagName = tagName.toLowerCase();
|
|
4094
|
+
const isClosingTag = trimmedVal.startsWith("</");
|
|
4095
|
+
const isAtomicTag = HTML_ATOMIC_TAGS.includes(normalizedTagName);
|
|
4096
|
+
const isBlockTag = HTML_BLOCK_TAGS.includes(normalizedTagName);
|
|
4097
|
+
if (
|
|
4098
|
+
// Validate tag name is within the provided `tags` scope
|
|
4099
|
+
!tags.map((t) => t.toLowerCase()).includes(normalizedTagName)
|
|
4100
|
+
) {
|
|
4101
|
+
return false;
|
|
4102
|
+
}
|
|
4103
|
+
if (isClosingTag) {
|
|
4104
|
+
return attributes.trim() === "" && !isAtomicTag;
|
|
4105
|
+
}
|
|
4106
|
+
if (isAtomicTag) {
|
|
4107
|
+
return attributes.trim() === "" || validHtmlAttributes(attributes);
|
|
4108
|
+
}
|
|
4109
|
+
if (isBlockTag) {
|
|
4110
|
+
return validHtmlAttributes(attributes);
|
|
4111
|
+
}
|
|
4112
|
+
return false;
|
|
4113
|
+
};
|
|
4114
|
+
}
|
|
4049
4115
|
|
|
4050
4116
|
// src/type-guards/html/isHtml.ts
|
|
4051
4117
|
function isHtml(val) {
|
|
@@ -4093,6 +4159,16 @@ function isHtmlElement(val) {
|
|
|
4093
4159
|
return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
|
|
4094
4160
|
}
|
|
4095
4161
|
|
|
4162
|
+
// src/type-guards/html/validHtmlAttributes.ts
|
|
4163
|
+
function validHtmlAttributes(val) {
|
|
4164
|
+
if (typeof val !== "string")
|
|
4165
|
+
return false;
|
|
4166
|
+
const quoteRegex = /["']/g;
|
|
4167
|
+
const unmatchedQuotes = (val.match(quoteRegex)?.length || 0) % 2 !== 0;
|
|
4168
|
+
const invalidAssignment = /(\w+=)(?=\s|>|$)/.test(val);
|
|
4169
|
+
return !val.includes(">") && !unmatchedQuotes && !invalidAssignment;
|
|
4170
|
+
}
|
|
4171
|
+
|
|
4096
4172
|
// src/type-guards/isAlpha.ts
|
|
4097
4173
|
function isAlpha(value) {
|
|
4098
4174
|
return isString(value) && split(value).every((v) => ALPHA_CHARS.includes(v));
|
|
@@ -6674,6 +6750,7 @@ function asVueRef(value) {
|
|
|
6674
6750
|
isHmUrl,
|
|
6675
6751
|
isHomeDepotUrl,
|
|
6676
6752
|
isHtml,
|
|
6753
|
+
isHtmlComponentTag,
|
|
6677
6754
|
isHtmlElement,
|
|
6678
6755
|
isIkeaUrl,
|
|
6679
6756
|
isIndexable,
|
|
@@ -6820,6 +6897,7 @@ function asVueRef(value) {
|
|
|
6820
6897
|
isValidAtomicTag,
|
|
6821
6898
|
isValidBlockTag,
|
|
6822
6899
|
isValidHtml,
|
|
6900
|
+
isValidHtmlTag,
|
|
6823
6901
|
isVariable,
|
|
6824
6902
|
isVisa,
|
|
6825
6903
|
isVisaMastercard,
|
|
@@ -6946,6 +7024,7 @@ function asVueRef(value) {
|
|
|
6946
7024
|
unset,
|
|
6947
7025
|
uppercase,
|
|
6948
7026
|
urlMeta,
|
|
7027
|
+
validHtmlAttributes,
|
|
6949
7028
|
valuesOf,
|
|
6950
7029
|
widen,
|
|
6951
7030
|
withDefaults,
|