@bamboocss/generator 1.48.4 → 1.49.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 -4
- package/dist/index.mjs +17 -4
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -471,11 +471,24 @@ function generateCx(ctx) {
|
|
|
471
471
|
js: outdent.default`
|
|
472
472
|
${ctx.file.import("splitProps", "../helpers")}
|
|
473
473
|
|
|
474
|
-
function cx(
|
|
475
|
-
|
|
474
|
+
function cx(a, b) {
|
|
475
|
+
const n = arguments.length
|
|
476
|
+
|
|
477
|
+
// \`cx(<compiled class literal>, className)\` is what the transform emits at nearly every
|
|
478
|
+
// call site it cannot fold, so it is the shape that actually runs per render — a wrapper
|
|
479
|
+
// forwarding a className down. Answering it here skips the rest-array allocation and the
|
|
480
|
+
// loop below. \`b\` covers the whole non-string tail \`cx\` ignores (null/undefined/booleans),
|
|
481
|
+
// which is the \`cond && cls\` idiom when the condition is false.
|
|
482
|
+
if (n === 2 && typeof a === 'string') {
|
|
483
|
+
if (typeof b === 'string') return a ? (b ? a + ' ' + b : a) : b
|
|
484
|
+
if (b == null || b === false || b === true) return a
|
|
485
|
+
}
|
|
476
486
|
|
|
477
|
-
|
|
478
|
-
|
|
487
|
+
let str = ''
|
|
488
|
+
// \`arguments\` rather than a rest parameter: this is the variadic tail, and allocating an
|
|
489
|
+
// array per call to iterate it once is the cost the fast path above exists to avoid.
|
|
490
|
+
for (let i = 0; i < n; i++) {
|
|
491
|
+
const arg = arguments[i]
|
|
479
492
|
if (!arg) continue
|
|
480
493
|
// Arrays are part of the declared type, so this branch has to handle them.
|
|
481
494
|
// Returning '' for \`cx(['a', 'b'])\` would be a lie.
|
package/dist/index.mjs
CHANGED
|
@@ -445,11 +445,24 @@ function generateCx(ctx) {
|
|
|
445
445
|
js: outdent$1`
|
|
446
446
|
${ctx.file.import("splitProps", "../helpers")}
|
|
447
447
|
|
|
448
|
-
function cx(
|
|
449
|
-
|
|
448
|
+
function cx(a, b) {
|
|
449
|
+
const n = arguments.length
|
|
450
|
+
|
|
451
|
+
// \`cx(<compiled class literal>, className)\` is what the transform emits at nearly every
|
|
452
|
+
// call site it cannot fold, so it is the shape that actually runs per render — a wrapper
|
|
453
|
+
// forwarding a className down. Answering it here skips the rest-array allocation and the
|
|
454
|
+
// loop below. \`b\` covers the whole non-string tail \`cx\` ignores (null/undefined/booleans),
|
|
455
|
+
// which is the \`cond && cls\` idiom when the condition is false.
|
|
456
|
+
if (n === 2 && typeof a === 'string') {
|
|
457
|
+
if (typeof b === 'string') return a ? (b ? a + ' ' + b : a) : b
|
|
458
|
+
if (b == null || b === false || b === true) return a
|
|
459
|
+
}
|
|
450
460
|
|
|
451
|
-
|
|
452
|
-
|
|
461
|
+
let str = ''
|
|
462
|
+
// \`arguments\` rather than a rest parameter: this is the variadic tail, and allocating an
|
|
463
|
+
// array per call to iterate it once is the cost the fast path above exists to avoid.
|
|
464
|
+
for (let i = 0; i < n; i++) {
|
|
465
|
+
const arg = arguments[i]
|
|
453
466
|
if (!arg) continue
|
|
454
467
|
// Arrays are part of the declared type, so this branch has to handle them.
|
|
455
468
|
// Returning '' for \`cx(['a', 'b'])\` would be a lie.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/generator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.49.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.49.0",
|
|
42
|
+
"@bamboocss/is-valid-prop": "^1.49.0",
|
|
43
|
+
"@bamboocss/logger": "1.49.0",
|
|
44
|
+
"@bamboocss/shared": "1.49.0",
|
|
45
|
+
"@bamboocss/token-dictionary": "1.49.0",
|
|
46
|
+
"@bamboocss/types": "1.49.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/pluralize": "0.0.33"
|