@bamboocss/generator 1.45.3 → 1.45.5
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 +35 -0
- package/dist/index.mjs +35 -0
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -2637,6 +2637,40 @@ const OS_DARK_QUERY = "@media (prefers-color-scheme: dark)";
|
|
|
2637
2637
|
/** Compare a condition against a known query without tripping over spacing. */
|
|
2638
2638
|
const normalize = (condition) => typeof condition === "string" ? condition.replace(/\s+/g, " ").trim() : void 0;
|
|
2639
2639
|
/**
|
|
2640
|
+
* Does this value carry a comma at the top level?
|
|
2641
|
+
*
|
|
2642
|
+
* `light-dark()` takes exactly two arguments, and CSS offers no way to group a
|
|
2643
|
+
* comma-separated value into one of them — there is no parenthesized form of a shadow list.
|
|
2644
|
+
* So a token whose light or dark arm is itself a list cannot be folded: the arms splat into
|
|
2645
|
+
* three or more arguments, the function is invalid, and the browser drops the whole
|
|
2646
|
+
* declaration. That failure is silent and total — a `--shadows-sm` carrying two shadows
|
|
2647
|
+
* emitted `light-dark(a, b, c)` and every element referencing it rendered with no shadow at
|
|
2648
|
+
* all, while the class naming it looked perfectly correct.
|
|
2649
|
+
*
|
|
2650
|
+
* Multi-part `box-shadow` is the shape that bites, since a realistic elevation token is
|
|
2651
|
+
* almost always two shadows; `transition` and `background` lists are the same story.
|
|
2652
|
+
*
|
|
2653
|
+
* Depth-aware, so `rgb(16, 19, 26)` still folds — its commas are the function's own.
|
|
2654
|
+
* Quote-aware, so a font stack's `"Foo, Bar"` is not mistaken for a separator.
|
|
2655
|
+
*/
|
|
2656
|
+
const hasTopLevelComma = (value) => {
|
|
2657
|
+
let depth = 0;
|
|
2658
|
+
let quote;
|
|
2659
|
+
for (let index = 0; index < value.length; index++) {
|
|
2660
|
+
const char = value[index];
|
|
2661
|
+
if (quote) {
|
|
2662
|
+
if (char === "\\") index++;
|
|
2663
|
+
else if (char === quote) quote = void 0;
|
|
2664
|
+
continue;
|
|
2665
|
+
}
|
|
2666
|
+
if (char === "\"" || char === "'") quote = char;
|
|
2667
|
+
else if (char === "(") depth++;
|
|
2668
|
+
else if (char === ")") depth--;
|
|
2669
|
+
else if (char === "," && depth === 0) return true;
|
|
2670
|
+
}
|
|
2671
|
+
return false;
|
|
2672
|
+
};
|
|
2673
|
+
/**
|
|
2640
2674
|
* Collapse a token's `base`/`_osDark` pair into a single `light-dark()` declaration.
|
|
2641
2675
|
*
|
|
2642
2676
|
* Two declarations and a whole `@media (prefers-color-scheme: dark)` block become one line,
|
|
@@ -2673,6 +2707,7 @@ function foldLightDark(vars, conditions) {
|
|
|
2673
2707
|
for (const [name, darkValue] of osDark) {
|
|
2674
2708
|
const lightValue = base.get(name);
|
|
2675
2709
|
if (lightValue === void 0 || osLight?.has(name)) continue;
|
|
2710
|
+
if (hasTopLevelComma(lightValue) || hasTopLevelComma(darkValue)) continue;
|
|
2676
2711
|
nextBase.set(name, `light-dark(${lightValue}, ${darkValue})`);
|
|
2677
2712
|
nextDark.delete(name);
|
|
2678
2713
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -2611,6 +2611,40 @@ const OS_DARK_QUERY = "@media (prefers-color-scheme: dark)";
|
|
|
2611
2611
|
/** Compare a condition against a known query without tripping over spacing. */
|
|
2612
2612
|
const normalize = (condition) => typeof condition === "string" ? condition.replace(/\s+/g, " ").trim() : void 0;
|
|
2613
2613
|
/**
|
|
2614
|
+
* Does this value carry a comma at the top level?
|
|
2615
|
+
*
|
|
2616
|
+
* `light-dark()` takes exactly two arguments, and CSS offers no way to group a
|
|
2617
|
+
* comma-separated value into one of them — there is no parenthesized form of a shadow list.
|
|
2618
|
+
* So a token whose light or dark arm is itself a list cannot be folded: the arms splat into
|
|
2619
|
+
* three or more arguments, the function is invalid, and the browser drops the whole
|
|
2620
|
+
* declaration. That failure is silent and total — a `--shadows-sm` carrying two shadows
|
|
2621
|
+
* emitted `light-dark(a, b, c)` and every element referencing it rendered with no shadow at
|
|
2622
|
+
* all, while the class naming it looked perfectly correct.
|
|
2623
|
+
*
|
|
2624
|
+
* Multi-part `box-shadow` is the shape that bites, since a realistic elevation token is
|
|
2625
|
+
* almost always two shadows; `transition` and `background` lists are the same story.
|
|
2626
|
+
*
|
|
2627
|
+
* Depth-aware, so `rgb(16, 19, 26)` still folds — its commas are the function's own.
|
|
2628
|
+
* Quote-aware, so a font stack's `"Foo, Bar"` is not mistaken for a separator.
|
|
2629
|
+
*/
|
|
2630
|
+
const hasTopLevelComma = (value) => {
|
|
2631
|
+
let depth = 0;
|
|
2632
|
+
let quote;
|
|
2633
|
+
for (let index = 0; index < value.length; index++) {
|
|
2634
|
+
const char = value[index];
|
|
2635
|
+
if (quote) {
|
|
2636
|
+
if (char === "\\") index++;
|
|
2637
|
+
else if (char === quote) quote = void 0;
|
|
2638
|
+
continue;
|
|
2639
|
+
}
|
|
2640
|
+
if (char === "\"" || char === "'") quote = char;
|
|
2641
|
+
else if (char === "(") depth++;
|
|
2642
|
+
else if (char === ")") depth--;
|
|
2643
|
+
else if (char === "," && depth === 0) return true;
|
|
2644
|
+
}
|
|
2645
|
+
return false;
|
|
2646
|
+
};
|
|
2647
|
+
/**
|
|
2614
2648
|
* Collapse a token's `base`/`_osDark` pair into a single `light-dark()` declaration.
|
|
2615
2649
|
*
|
|
2616
2650
|
* Two declarations and a whole `@media (prefers-color-scheme: dark)` block become one line,
|
|
@@ -2647,6 +2681,7 @@ function foldLightDark(vars, conditions) {
|
|
|
2647
2681
|
for (const [name, darkValue] of osDark) {
|
|
2648
2682
|
const lightValue = base.get(name);
|
|
2649
2683
|
if (lightValue === void 0 || osLight?.has(name)) continue;
|
|
2684
|
+
if (hasTopLevelComma(lightValue) || hasTopLevelComma(darkValue)) continue;
|
|
2650
2685
|
nextBase.set(name, `light-dark(${lightValue}, ${darkValue})`);
|
|
2651
2686
|
nextDark.delete(name);
|
|
2652
2687
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/generator",
|
|
3
|
-
"version": "1.45.
|
|
3
|
+
"version": "1.45.5",
|
|
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.45.
|
|
42
|
-
"@bamboocss/is-valid-prop": "^1.45.
|
|
43
|
-
"@bamboocss/logger": "1.45.
|
|
44
|
-
"@bamboocss/shared": "1.45.
|
|
45
|
-
"@bamboocss/token-dictionary": "1.45.
|
|
46
|
-
"@bamboocss/types": "1.45.
|
|
41
|
+
"@bamboocss/core": "1.45.5",
|
|
42
|
+
"@bamboocss/is-valid-prop": "^1.45.5",
|
|
43
|
+
"@bamboocss/logger": "1.45.5",
|
|
44
|
+
"@bamboocss/shared": "1.45.5",
|
|
45
|
+
"@bamboocss/token-dictionary": "1.45.5",
|
|
46
|
+
"@bamboocss/types": "1.45.5"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/pluralize": "0.0.33"
|