Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/domains/rentals.picotech.app/public_html/node_modules/goober/macro/ drwxr-xr-x | |
| Viewing file: Select action/file-type: const { createMacro, MacroError } = require('babel-plugin-macros');
const { addNamed } = require('@babel/helper-module-imports');
module.exports = createMacro(gooberMacro);
function gooberMacro({ references, babel, state }) {
const program = state.file.path;
if (references.default) {
throw new MacroError('goober.macro does not support default import');
}
// Inject import {...} from 'goober'
Object.keys(references).forEach((refName) => {
const id = addNamed(program, refName, 'goober');
references[refName].forEach((referencePath) => {
referencePath.node.name = id.name;
});
});
const t = babel.types;
const styledReferences = references.styled || [];
styledReferences.forEach((referencePath) => {
const type = referencePath.parentPath.type;
if (type === 'MemberExpression') {
const node = referencePath.parentPath.node;
const functionName = node.object.name;
let elementName = node.property.name;
// Support custom elements
if (/[A-Z]/.test(elementName)) {
elementName = elementName.replace(/[A-Z]/g, '-$&').toLowerCase();
}
referencePath.parentPath.replaceWith(
t.callExpression(t.identifier(functionName), [t.stringLiteral(elementName)])
);
}
});
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0055 ]-- |