Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
import { serializeStyles } from '@emotion/serialize'
|
|
|
|
// to anyone looking at this, this isn't intended to simplify every single case
|
|
// it's meant to simplify the most common cases so i don't want to make it especially complex
|
|
// also, this will be unnecessary when prepack is ready
|
|
export function simplifyObject(node, t /*: Object */) {
|
|
let finalString = ''
|
|
for (let i = 0; i < node.properties.length; i++) {
|
|
let property = node.properties[i]
|
|
|
|
if (
|
|
!t.isObjectProperty(property) ||
|
|
property.computed ||
|
|
(!t.isIdentifier(property.key) && !t.isStringLiteral(property.key)) ||
|
|
(!t.isStringLiteral(property.value) &&
|
|
!t.isNumericLiteral(property.value) &&
|
|
!t.isObjectExpression(property.value))
|
|
) {
|
|
return node
|
|
}
|
|
|
|
let key = property.key.name || property.key.value
|
|
if (key === 'styles') {
|
|
return node
|
|
}
|
|
if (t.isObjectExpression(property.value)) {
|
|
let simplifiedChild = simplifyObject(property.value, t)
|
|
if (!t.isStringLiteral(simplifiedChild)) {
|
|
return node
|
|
}
|
|
finalString += `${key}{${simplifiedChild.value}}`
|
|
continue
|
|
}
|
|
let value = property.value.value
|
|
|
|
finalString += serializeStyles([{ [key]: value }]).styles
|
|
}
|
|
return t.stringLiteral(finalString)
|
|
}
|