@tokenami/config 0.0.95 → 0.0.96--canary.494.27273338809.0
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/dist/index.cjs +17 -3
- package/dist/index.js +17 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -41,9 +41,8 @@ function variantProperty(variant, name) {
|
|
|
41
41
|
function parsedVariantProperty(variant, name) {
|
|
42
42
|
return parseProperty(variantProperty(variant, name));
|
|
43
43
|
}
|
|
44
|
-
var tokenValueRegex = /var\((--([\w-]+)_([\w-]+))\)/;
|
|
45
44
|
var TokenValue = {
|
|
46
|
-
safeParse: (input) =>
|
|
45
|
+
safeParse: (input) => validateTokenValue(input)
|
|
47
46
|
};
|
|
48
47
|
function tokenValue(themeKey, name) {
|
|
49
48
|
return `var(--${themeKey}_${name})`;
|
|
@@ -67,6 +66,18 @@ function validate(regex, input) {
|
|
|
67
66
|
return { success: false };
|
|
68
67
|
}
|
|
69
68
|
}
|
|
69
|
+
function validateTokenValue(input) {
|
|
70
|
+
const value = String(input);
|
|
71
|
+
const prefix = "var(--";
|
|
72
|
+
const suffix = ")";
|
|
73
|
+
const tokenParts = value.slice(prefix.length, -suffix.length);
|
|
74
|
+
const underscoreIndex = tokenParts.indexOf("_");
|
|
75
|
+
const hasSingleInternalUnderscore = underscoreIndex > 0 && underscoreIndex < tokenParts.length - 1 && underscoreIndex === tokenParts.lastIndexOf("_");
|
|
76
|
+
if (value.startsWith(prefix) && value.endsWith(suffix) && hasSingleInternalUnderscore) {
|
|
77
|
+
return { success: true, output: value };
|
|
78
|
+
}
|
|
79
|
+
return { success: false };
|
|
80
|
+
}
|
|
70
81
|
function getTokenPropertyName(property) {
|
|
71
82
|
const propertyPrefix = tokenProperty("");
|
|
72
83
|
return property.replace(propertyPrefix, "");
|
|
@@ -106,7 +117,10 @@ function getArbitrarySelector(selector) {
|
|
|
106
117
|
return arbitrarySelector ? decodeColon(arbitrarySelector) : void 0;
|
|
107
118
|
}
|
|
108
119
|
function getTokenValueParts(tokenValue2) {
|
|
109
|
-
const
|
|
120
|
+
const property = tokenValue2.slice("var(".length, -")".length);
|
|
121
|
+
const separatorIndex = property.indexOf("_");
|
|
122
|
+
const themeKey = property.slice("--".length, separatorIndex);
|
|
123
|
+
const token = property.slice(separatorIndex + 1);
|
|
110
124
|
return { property, themeKey, token };
|
|
111
125
|
}
|
|
112
126
|
function getCSSPropertiesForAlias(alias, aliases) {
|
package/dist/index.js
CHANGED
|
@@ -36,9 +36,8 @@ function variantProperty(variant, name) {
|
|
|
36
36
|
function parsedVariantProperty(variant, name) {
|
|
37
37
|
return parseProperty(variantProperty(variant, name));
|
|
38
38
|
}
|
|
39
|
-
var tokenValueRegex = /var\((--([\w-]+)_([\w-]+))\)/;
|
|
40
39
|
var TokenValue = {
|
|
41
|
-
safeParse: (input) =>
|
|
40
|
+
safeParse: (input) => validateTokenValue(input)
|
|
42
41
|
};
|
|
43
42
|
function tokenValue(themeKey, name) {
|
|
44
43
|
return `var(--${themeKey}_${name})`;
|
|
@@ -62,6 +61,18 @@ function validate(regex, input) {
|
|
|
62
61
|
return { success: false };
|
|
63
62
|
}
|
|
64
63
|
}
|
|
64
|
+
function validateTokenValue(input) {
|
|
65
|
+
const value = String(input);
|
|
66
|
+
const prefix = "var(--";
|
|
67
|
+
const suffix = ")";
|
|
68
|
+
const tokenParts = value.slice(prefix.length, -suffix.length);
|
|
69
|
+
const underscoreIndex = tokenParts.indexOf("_");
|
|
70
|
+
const hasSingleInternalUnderscore = underscoreIndex > 0 && underscoreIndex < tokenParts.length - 1 && underscoreIndex === tokenParts.lastIndexOf("_");
|
|
71
|
+
if (value.startsWith(prefix) && value.endsWith(suffix) && hasSingleInternalUnderscore) {
|
|
72
|
+
return { success: true, output: value };
|
|
73
|
+
}
|
|
74
|
+
return { success: false };
|
|
75
|
+
}
|
|
65
76
|
function getTokenPropertyName(property) {
|
|
66
77
|
const propertyPrefix = tokenProperty("");
|
|
67
78
|
return property.replace(propertyPrefix, "");
|
|
@@ -101,7 +112,10 @@ function getArbitrarySelector(selector) {
|
|
|
101
112
|
return arbitrarySelector ? decodeColon(arbitrarySelector) : void 0;
|
|
102
113
|
}
|
|
103
114
|
function getTokenValueParts(tokenValue2) {
|
|
104
|
-
const
|
|
115
|
+
const property = tokenValue2.slice("var(".length, -")".length);
|
|
116
|
+
const separatorIndex = property.indexOf("_");
|
|
117
|
+
const themeKey = property.slice("--".length, separatorIndex);
|
|
118
|
+
const token = property.slice(separatorIndex + 1);
|
|
105
119
|
return { property, themeKey, token };
|
|
106
120
|
}
|
|
107
121
|
function getCSSPropertiesForAlias(alias, aliases) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenami/config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.96--canary.494.27273338809.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"tsup": "^8.4.0",
|
|
40
40
|
"typescript": "^5.1.3"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "dbe69e1c22dc4ef882d16867a612c81f461c9385"
|
|
43
43
|
}
|