@bamboocss/vite 1.28.0 → 1.29.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 +34 -6
- package/dist/index.mjs +34 -6
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -1130,6 +1130,9 @@ const createRuntimeCss = (ctx) => {
|
|
|
1130
1130
|
* every module in the build — not once per `foldSource`, which would price a whole token
|
|
1131
1131
|
* table into each of the overwhelming majority of modules that call `token()` zero times.
|
|
1132
1132
|
* Keyed weakly so a context that goes out of scope takes its table with it.
|
|
1133
|
+
*
|
|
1134
|
+
* Both halves of the generated entry are stored, because `token()` and `token.var()` read
|
|
1135
|
+
* different ones and building a second table would pay the same per-project cost twice.
|
|
1133
1136
|
*/
|
|
1134
1137
|
const tokenValues = /* @__PURE__ */ new WeakMap();
|
|
1135
1138
|
const tokenValuesFor = (ctx) => {
|
|
@@ -1138,16 +1141,29 @@ const tokenValuesFor = (ctx) => {
|
|
|
1138
1141
|
values = /* @__PURE__ */ new Map();
|
|
1139
1142
|
for (const token of ctx.tokens.allTokens) {
|
|
1140
1143
|
const { varRef, isVirtual, condition } = token.extensions;
|
|
1141
|
-
values.set(token.name,
|
|
1144
|
+
values.set(token.name, {
|
|
1145
|
+
value: ctx.tokens.view.get(token.name) ?? (isVirtual || condition !== "base" ? varRef : token.value),
|
|
1146
|
+
variable: ctx.tokens.view.getVar(token.name) ?? varRef
|
|
1147
|
+
});
|
|
1142
1148
|
}
|
|
1143
1149
|
tokenValues.set(ctx, values);
|
|
1144
1150
|
return values;
|
|
1145
1151
|
};
|
|
1146
|
-
const
|
|
1147
|
-
const value = tokenValuesFor(ctx).get(path);
|
|
1152
|
+
const createRuntimeTokenValue = (ctx) => (path) => {
|
|
1153
|
+
const value = tokenValuesFor(ctx).get(path)?.value;
|
|
1148
1154
|
return typeof value === "string" ? value : void 0;
|
|
1149
1155
|
};
|
|
1150
1156
|
/**
|
|
1157
|
+
* The generated runtime's `token()`, rebuilt in-process.
|
|
1158
|
+
*
|
|
1159
|
+
* Reads the `variable` half of the same entry `token.value()` reads the `value` half of.
|
|
1160
|
+
* That half is `varRef` for every token regardless of condition, so unlike
|
|
1161
|
+
* `createRuntimeTokenValue` there is no split to get wrong and no non-string case to
|
|
1162
|
+
* decline: a `var()` reference is a string or the token does not exist. Which is what makes
|
|
1163
|
+
* the default form the trivially foldable one.
|
|
1164
|
+
*/
|
|
1165
|
+
const createRuntimeToken = (ctx) => (path) => tokenValuesFor(ctx).get(path)?.variable || void 0;
|
|
1166
|
+
/**
|
|
1151
1167
|
* Whether a slot's class is independent of the variant props.
|
|
1152
1168
|
*
|
|
1153
1169
|
* A scoped slot recipe delivers variants through `@scope` rules anchored on an enclosing
|
|
@@ -1612,6 +1628,7 @@ const foldSource = (options) => {
|
|
|
1612
1628
|
const runtimeRecipe = createRuntimeRecipe(ctx);
|
|
1613
1629
|
const isConstantSlot = createConstantSlotCheck(ctx);
|
|
1614
1630
|
const runtimeToken = createRuntimeToken(ctx);
|
|
1631
|
+
const runtimeTokenValue = createRuntimeTokenValue(ctx);
|
|
1615
1632
|
/**
|
|
1616
1633
|
* Does this specifier name a module that exports the css API, exactly?
|
|
1617
1634
|
*
|
|
@@ -1800,7 +1817,7 @@ const foldSource = (options) => {
|
|
|
1800
1817
|
const name = item.name ?? type;
|
|
1801
1818
|
if (!item.box) continue;
|
|
1802
1819
|
const call = findCallExpression(item.box);
|
|
1803
|
-
if (type === "token") {
|
|
1820
|
+
if (type === "token" || type === "tokenValue") {
|
|
1804
1821
|
if (!call) {
|
|
1805
1822
|
skipped.push({
|
|
1806
1823
|
name,
|
|
@@ -1835,7 +1852,18 @@ const foldSource = (options) => {
|
|
|
1835
1852
|
continue;
|
|
1836
1853
|
}
|
|
1837
1854
|
const callee = ts_morph.Node.isCallExpression(call) ? call.getExpression() : void 0;
|
|
1838
|
-
|
|
1855
|
+
const propertyName = ts_morph.Node.isPropertyAccessExpression(callee) ? callee.getNameNode().getText() : void 0;
|
|
1856
|
+
const wantsValue = type === "tokenValue";
|
|
1857
|
+
if (wantsValue !== (propertyName === "value")) {
|
|
1858
|
+
skipped.push({
|
|
1859
|
+
name,
|
|
1860
|
+
reason: "unsupported-kind",
|
|
1861
|
+
start,
|
|
1862
|
+
end
|
|
1863
|
+
});
|
|
1864
|
+
continue;
|
|
1865
|
+
}
|
|
1866
|
+
if (!wantsValue && propertyName !== void 0 && propertyName !== "var" && !ctx.imports.matchers.tokens.match(propertyName)) {
|
|
1839
1867
|
skipped.push({
|
|
1840
1868
|
name,
|
|
1841
1869
|
reason: "unsupported-kind",
|
|
@@ -1872,7 +1900,7 @@ const foldSource = (options) => {
|
|
|
1872
1900
|
});
|
|
1873
1901
|
continue;
|
|
1874
1902
|
}
|
|
1875
|
-
const value = runtimeToken(path);
|
|
1903
|
+
const value = wantsValue ? runtimeTokenValue(path) : runtimeToken(path);
|
|
1876
1904
|
if (!value) {
|
|
1877
1905
|
skipped.push({
|
|
1878
1906
|
name,
|
package/dist/index.mjs
CHANGED
|
@@ -1103,6 +1103,9 @@ const createRuntimeCss = (ctx) => {
|
|
|
1103
1103
|
* every module in the build — not once per `foldSource`, which would price a whole token
|
|
1104
1104
|
* table into each of the overwhelming majority of modules that call `token()` zero times.
|
|
1105
1105
|
* Keyed weakly so a context that goes out of scope takes its table with it.
|
|
1106
|
+
*
|
|
1107
|
+
* Both halves of the generated entry are stored, because `token()` and `token.var()` read
|
|
1108
|
+
* different ones and building a second table would pay the same per-project cost twice.
|
|
1106
1109
|
*/
|
|
1107
1110
|
const tokenValues = /* @__PURE__ */ new WeakMap();
|
|
1108
1111
|
const tokenValuesFor = (ctx) => {
|
|
@@ -1111,16 +1114,29 @@ const tokenValuesFor = (ctx) => {
|
|
|
1111
1114
|
values = /* @__PURE__ */ new Map();
|
|
1112
1115
|
for (const token of ctx.tokens.allTokens) {
|
|
1113
1116
|
const { varRef, isVirtual, condition } = token.extensions;
|
|
1114
|
-
values.set(token.name,
|
|
1117
|
+
values.set(token.name, {
|
|
1118
|
+
value: ctx.tokens.view.get(token.name) ?? (isVirtual || condition !== "base" ? varRef : token.value),
|
|
1119
|
+
variable: ctx.tokens.view.getVar(token.name) ?? varRef
|
|
1120
|
+
});
|
|
1115
1121
|
}
|
|
1116
1122
|
tokenValues.set(ctx, values);
|
|
1117
1123
|
return values;
|
|
1118
1124
|
};
|
|
1119
|
-
const
|
|
1120
|
-
const value = tokenValuesFor(ctx).get(path);
|
|
1125
|
+
const createRuntimeTokenValue = (ctx) => (path) => {
|
|
1126
|
+
const value = tokenValuesFor(ctx).get(path)?.value;
|
|
1121
1127
|
return typeof value === "string" ? value : void 0;
|
|
1122
1128
|
};
|
|
1123
1129
|
/**
|
|
1130
|
+
* The generated runtime's `token()`, rebuilt in-process.
|
|
1131
|
+
*
|
|
1132
|
+
* Reads the `variable` half of the same entry `token.value()` reads the `value` half of.
|
|
1133
|
+
* That half is `varRef` for every token regardless of condition, so unlike
|
|
1134
|
+
* `createRuntimeTokenValue` there is no split to get wrong and no non-string case to
|
|
1135
|
+
* decline: a `var()` reference is a string or the token does not exist. Which is what makes
|
|
1136
|
+
* the default form the trivially foldable one.
|
|
1137
|
+
*/
|
|
1138
|
+
const createRuntimeToken = (ctx) => (path) => tokenValuesFor(ctx).get(path)?.variable || void 0;
|
|
1139
|
+
/**
|
|
1124
1140
|
* Whether a slot's class is independent of the variant props.
|
|
1125
1141
|
*
|
|
1126
1142
|
* A scoped slot recipe delivers variants through `@scope` rules anchored on an enclosing
|
|
@@ -1585,6 +1601,7 @@ const foldSource = (options) => {
|
|
|
1585
1601
|
const runtimeRecipe = createRuntimeRecipe(ctx);
|
|
1586
1602
|
const isConstantSlot = createConstantSlotCheck(ctx);
|
|
1587
1603
|
const runtimeToken = createRuntimeToken(ctx);
|
|
1604
|
+
const runtimeTokenValue = createRuntimeTokenValue(ctx);
|
|
1588
1605
|
/**
|
|
1589
1606
|
* Does this specifier name a module that exports the css API, exactly?
|
|
1590
1607
|
*
|
|
@@ -1773,7 +1790,7 @@ const foldSource = (options) => {
|
|
|
1773
1790
|
const name = item.name ?? type;
|
|
1774
1791
|
if (!item.box) continue;
|
|
1775
1792
|
const call = findCallExpression(item.box);
|
|
1776
|
-
if (type === "token") {
|
|
1793
|
+
if (type === "token" || type === "tokenValue") {
|
|
1777
1794
|
if (!call) {
|
|
1778
1795
|
skipped.push({
|
|
1779
1796
|
name,
|
|
@@ -1808,7 +1825,18 @@ const foldSource = (options) => {
|
|
|
1808
1825
|
continue;
|
|
1809
1826
|
}
|
|
1810
1827
|
const callee = Node.isCallExpression(call) ? call.getExpression() : void 0;
|
|
1811
|
-
|
|
1828
|
+
const propertyName = Node.isPropertyAccessExpression(callee) ? callee.getNameNode().getText() : void 0;
|
|
1829
|
+
const wantsValue = type === "tokenValue";
|
|
1830
|
+
if (wantsValue !== (propertyName === "value")) {
|
|
1831
|
+
skipped.push({
|
|
1832
|
+
name,
|
|
1833
|
+
reason: "unsupported-kind",
|
|
1834
|
+
start,
|
|
1835
|
+
end
|
|
1836
|
+
});
|
|
1837
|
+
continue;
|
|
1838
|
+
}
|
|
1839
|
+
if (!wantsValue && propertyName !== void 0 && propertyName !== "var" && !ctx.imports.matchers.tokens.match(propertyName)) {
|
|
1812
1840
|
skipped.push({
|
|
1813
1841
|
name,
|
|
1814
1842
|
reason: "unsupported-kind",
|
|
@@ -1845,7 +1873,7 @@ const foldSource = (options) => {
|
|
|
1845
1873
|
});
|
|
1846
1874
|
continue;
|
|
1847
1875
|
}
|
|
1848
|
-
const value = runtimeToken(path);
|
|
1876
|
+
const value = wantsValue ? runtimeTokenValue(path) : runtimeToken(path);
|
|
1849
1877
|
if (!value) {
|
|
1850
1878
|
skipped.push({
|
|
1851
1879
|
name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/vite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
4
4
|
"description": "Vite integration for Bamboo CSS",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"magic-string": "0.30.21",
|
|
39
39
|
"ts-morph": "28.0.0",
|
|
40
|
-
"@bamboocss/
|
|
41
|
-
"@bamboocss/
|
|
42
|
-
"@bamboocss/
|
|
43
|
-
"@bamboocss/
|
|
44
|
-
"@bamboocss/
|
|
45
|
-
"@bamboocss/
|
|
46
|
-
"@bamboocss/
|
|
40
|
+
"@bamboocss/config": "1.29.0",
|
|
41
|
+
"@bamboocss/core": "1.29.0",
|
|
42
|
+
"@bamboocss/extractor": "1.29.0",
|
|
43
|
+
"@bamboocss/logger": "1.29.0",
|
|
44
|
+
"@bamboocss/node": "1.29.0",
|
|
45
|
+
"@bamboocss/types": "1.29.0",
|
|
46
|
+
"@bamboocss/shared": "1.29.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
50
50
|
"vite": "7.2.6",
|
|
51
|
-
"@bamboocss/fixture": "1.
|
|
51
|
+
"@bamboocss/fixture": "1.29.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"vite": ">=5"
|