@bamboocss/generator 1.58.4 → 1.60.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 +10 -5
- package/dist/index.mjs +10 -5
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -783,7 +783,7 @@ function generateTokenJs(ctx) {
|
|
|
783
783
|
token.value = tokenValue
|
|
784
784
|
`,
|
|
785
785
|
dts: outdent.default`
|
|
786
|
-
${ctx.file.importType("Token, LiteralToken", "./tokens")}
|
|
786
|
+
${ctx.file.importType("Token, LiteralToken, NumericToken", "./tokens")}
|
|
787
787
|
|
|
788
788
|
export declare const token: {
|
|
789
789
|
/**
|
|
@@ -794,16 +794,19 @@ function generateTokenJs(ctx) {
|
|
|
794
794
|
*/
|
|
795
795
|
(path: Token): string
|
|
796
796
|
/**
|
|
797
|
-
* The resolved literal — \`#fca5a5
|
|
798
|
-
* a canvas fill or a
|
|
797
|
+
* The resolved literal — \`#fca5a5\`, or the number for a token holding one: \`zIndex.modal\`
|
|
798
|
+
* is \`1400\`. Use where css variables cannot be resolved, such as a canvas fill or a
|
|
799
|
+
* charting library.
|
|
799
800
|
*
|
|
800
801
|
* Restricted to the tokens that have one. A virtual or conditional token resolves to its
|
|
801
802
|
* \`var()\` because there is no single value to hand back, and a negative token to
|
|
802
803
|
* \`calc(var(--spacing-4) * -1)\` because it has no declaration of its own — so asking for
|
|
803
804
|
* a literal that cannot exist is a type error rather than a reference the caller then
|
|
804
805
|
* hands to a canvas.
|
|
806
|
+
*
|
|
807
|
+
* A path typed as any of them may name either kind, and gets \`string | number\`.
|
|
805
808
|
*/
|
|
806
|
-
value: (path:
|
|
809
|
+
value: <Path extends LiteralToken>(path: Path) => Path extends NumericToken ? number : string
|
|
807
810
|
}
|
|
808
811
|
|
|
809
812
|
${ctx.file.exportTypeStar("./tokens")}
|
|
@@ -1895,6 +1898,7 @@ function generateTokenTypes(ctx) {
|
|
|
1895
1898
|
const set = /* @__PURE__ */ new Set();
|
|
1896
1899
|
const tokenSet = /* @__PURE__ */ new Set();
|
|
1897
1900
|
const literalTokenSet = /* @__PURE__ */ new Set();
|
|
1901
|
+
const numericTokenSet = /* @__PURE__ */ new Set();
|
|
1898
1902
|
const result = new Set(["export type Tokens = {"]);
|
|
1899
1903
|
if (tokens.isEmpty) result.add("[token: string]: string");
|
|
1900
1904
|
else {
|
|
@@ -1913,6 +1917,7 @@ function generateTokenTypes(ctx) {
|
|
|
1913
1917
|
if (resolved === void 0) continue;
|
|
1914
1918
|
if (typeof resolved === "string" && COMPUTED_BY_CSS.test(resolved)) continue;
|
|
1915
1919
|
literalTokenSet.add(`${category}.${prop}`);
|
|
1920
|
+
if (Number.isFinite(resolved)) numericTokenSet.add(`${category}.${prop}`);
|
|
1916
1921
|
}
|
|
1917
1922
|
}
|
|
1918
1923
|
result.add("} & { [token: string]: never }");
|
|
@@ -1922,7 +1927,7 @@ function generateTokenTypes(ctx) {
|
|
|
1922
1927
|
arr.unshift(`export type Token = ${(0, _bamboocss_shared.unionType)(tokenSet, {
|
|
1923
1928
|
stringify: (t) => `\`${t}\``,
|
|
1924
1929
|
fallback: "string"
|
|
1925
|
-
})}`, `export type LiteralToken = ${(0, _bamboocss_shared.unionType)(literalTokenSet, { fallback: tokenSet.size ? "never" : "string" })}`);
|
|
1930
|
+
})}`, `export type LiteralToken = ${(0, _bamboocss_shared.unionType)(literalTokenSet, { fallback: tokenSet.size ? "never" : "string" })}`, `export type NumericToken = ${(0, _bamboocss_shared.unionType)(numericTokenSet, { fallback: "never" })}`);
|
|
1926
1931
|
return outdent.outdent.string(arr.join("\n\n"));
|
|
1927
1932
|
}
|
|
1928
1933
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -757,7 +757,7 @@ function generateTokenJs(ctx) {
|
|
|
757
757
|
token.value = tokenValue
|
|
758
758
|
`,
|
|
759
759
|
dts: outdent$1`
|
|
760
|
-
${ctx.file.importType("Token, LiteralToken", "./tokens")}
|
|
760
|
+
${ctx.file.importType("Token, LiteralToken, NumericToken", "./tokens")}
|
|
761
761
|
|
|
762
762
|
export declare const token: {
|
|
763
763
|
/**
|
|
@@ -768,16 +768,19 @@ function generateTokenJs(ctx) {
|
|
|
768
768
|
*/
|
|
769
769
|
(path: Token): string
|
|
770
770
|
/**
|
|
771
|
-
* The resolved literal — \`#fca5a5
|
|
772
|
-
* a canvas fill or a
|
|
771
|
+
* The resolved literal — \`#fca5a5\`, or the number for a token holding one: \`zIndex.modal\`
|
|
772
|
+
* is \`1400\`. Use where css variables cannot be resolved, such as a canvas fill or a
|
|
773
|
+
* charting library.
|
|
773
774
|
*
|
|
774
775
|
* Restricted to the tokens that have one. A virtual or conditional token resolves to its
|
|
775
776
|
* \`var()\` because there is no single value to hand back, and a negative token to
|
|
776
777
|
* \`calc(var(--spacing-4) * -1)\` because it has no declaration of its own — so asking for
|
|
777
778
|
* a literal that cannot exist is a type error rather than a reference the caller then
|
|
778
779
|
* hands to a canvas.
|
|
780
|
+
*
|
|
781
|
+
* A path typed as any of them may name either kind, and gets \`string | number\`.
|
|
779
782
|
*/
|
|
780
|
-
value: (path:
|
|
783
|
+
value: <Path extends LiteralToken>(path: Path) => Path extends NumericToken ? number : string
|
|
781
784
|
}
|
|
782
785
|
|
|
783
786
|
${ctx.file.exportTypeStar("./tokens")}
|
|
@@ -1869,6 +1872,7 @@ function generateTokenTypes(ctx) {
|
|
|
1869
1872
|
const set = /* @__PURE__ */ new Set();
|
|
1870
1873
|
const tokenSet = /* @__PURE__ */ new Set();
|
|
1871
1874
|
const literalTokenSet = /* @__PURE__ */ new Set();
|
|
1875
|
+
const numericTokenSet = /* @__PURE__ */ new Set();
|
|
1872
1876
|
const result = new Set(["export type Tokens = {"]);
|
|
1873
1877
|
if (tokens.isEmpty) result.add("[token: string]: string");
|
|
1874
1878
|
else {
|
|
@@ -1887,6 +1891,7 @@ function generateTokenTypes(ctx) {
|
|
|
1887
1891
|
if (resolved === void 0) continue;
|
|
1888
1892
|
if (typeof resolved === "string" && COMPUTED_BY_CSS.test(resolved)) continue;
|
|
1889
1893
|
literalTokenSet.add(`${category}.${prop}`);
|
|
1894
|
+
if (Number.isFinite(resolved)) numericTokenSet.add(`${category}.${prop}`);
|
|
1890
1895
|
}
|
|
1891
1896
|
}
|
|
1892
1897
|
result.add("} & { [token: string]: never }");
|
|
@@ -1896,7 +1901,7 @@ function generateTokenTypes(ctx) {
|
|
|
1896
1901
|
arr.unshift(`export type Token = ${unionType(tokenSet, {
|
|
1897
1902
|
stringify: (t) => `\`${t}\``,
|
|
1898
1903
|
fallback: "string"
|
|
1899
|
-
})}`, `export type LiteralToken = ${unionType(literalTokenSet, { fallback: tokenSet.size ? "never" : "string" })}`);
|
|
1904
|
+
})}`, `export type LiteralToken = ${unionType(literalTokenSet, { fallback: tokenSet.size ? "never" : "string" })}`, `export type NumericToken = ${unionType(numericTokenSet, { fallback: "never" })}`);
|
|
1900
1905
|
return outdent.string(arr.join("\n\n"));
|
|
1901
1906
|
}
|
|
1902
1907
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/generator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.60.0",
|
|
4
4
|
"description": "The css generator for css bamboo",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"pluralize": "8.0.0",
|
|
39
39
|
"postcss": "8.5.26",
|
|
40
40
|
"ts-pattern": "5.9.0",
|
|
41
|
-
"@bamboocss/core": "1.
|
|
42
|
-
"@bamboocss/is-valid-prop": "^1.
|
|
43
|
-
"@bamboocss/logger": "1.
|
|
44
|
-
"@bamboocss/shared": "1.
|
|
45
|
-
"@bamboocss/token-dictionary": "1.
|
|
46
|
-
"@bamboocss/types": "1.
|
|
41
|
+
"@bamboocss/core": "1.60.0",
|
|
42
|
+
"@bamboocss/is-valid-prop": "^1.60.0",
|
|
43
|
+
"@bamboocss/logger": "1.60.0",
|
|
44
|
+
"@bamboocss/shared": "1.60.0",
|
|
45
|
+
"@bamboocss/token-dictionary": "1.60.0",
|
|
46
|
+
"@bamboocss/types": "1.60.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/pluralize": "0.0.33"
|