@plumeria/utils 21.1.1 → 21.1.2
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/parser.js +2 -0
- package/dist/transform.js +19 -0
- package/package.json +1 -1
package/dist/parser.js
CHANGED
|
@@ -2200,6 +2200,8 @@ function runScan(scanCwd, styleProp) {
|
|
|
2200
2200
|
return;
|
|
2201
2201
|
if (node.elements.some((element) => element?.spread))
|
|
2202
2202
|
throw new Error('[plumeria] Spread elements in a style array are not supported. List each style explicitly.');
|
|
2203
|
+
if (propName === styleProp)
|
|
2204
|
+
return;
|
|
2203
2205
|
throw new Error('[plumeria] A style prop array contains an unsupported style expression. Use defined styles, null, false, undefined, or conditional branches of defined styles.');
|
|
2204
2206
|
}
|
|
2205
2207
|
if (!containsStyleReference(node))
|
package/dist/transform.js
CHANGED
|
@@ -2456,6 +2456,11 @@ const transformSource = async (env) => {
|
|
|
2456
2456
|
}
|
|
2457
2457
|
if (!node.value || node.value.type !== 'JSXExpressionContainer')
|
|
2458
2458
|
return;
|
|
2459
|
+
const appliedBefore = receivesStyleProp
|
|
2460
|
+
? new Set(appliedStyleProps)
|
|
2461
|
+
: null;
|
|
2462
|
+
if (appliedBefore)
|
|
2463
|
+
appliedStyleProps.clear();
|
|
2459
2464
|
const expr = node.value.expression;
|
|
2460
2465
|
const args = expr.type === 'ArrayExpression'
|
|
2461
2466
|
? expr.elements
|
|
@@ -2543,6 +2548,20 @@ const transformSource = async (env) => {
|
|
|
2543
2548
|
content: `${keptClass}${styleAttr}`,
|
|
2544
2549
|
});
|
|
2545
2550
|
}
|
|
2551
|
+
if (appliedBefore) {
|
|
2552
|
+
const referenced = new Set(appliedStyleProps);
|
|
2553
|
+
for (const key of referenced) {
|
|
2554
|
+
const [owner, propName] = key.split(':');
|
|
2555
|
+
if (scannedTables.componentPropsTable?.[`${resourcePath}-${owner}`]?.[propName]) {
|
|
2556
|
+
throwCompilationError(`[plumeria] "${propName}" is a style received through a prop and cannot be passed on ` +
|
|
2557
|
+
`to a component that declares ${styleProp}. Apply it on an element this component renders.`, node);
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
for (const applied of appliedBefore)
|
|
2561
|
+
appliedStyleProps.add(applied);
|
|
2562
|
+
for (const applied of referenced)
|
|
2563
|
+
appliedStyleProps.add(applied);
|
|
2564
|
+
}
|
|
2546
2565
|
},
|
|
2547
2566
|
CallExpression({ node }) {
|
|
2548
2567
|
const callee = node.callee;
|