{"version":3,"names":["types","t","name","visitor","Identifier","path","node","LOCALS_NAME","isReferencedIdentifier","scope","hasBinding","vars","Object","keys","getAllBindings","map","label","objectProperty","identifier","undefined","replaceWith","objectExpression","setters","execute"],"sources":["babel-plugin-locals.js"],"sourcesContent":["const LOCALS_NAME = \"locals\";\n\nexport default function({ types: t }) {\n    return {\n        name: 'locals',\n        visitor: {\n            Identifier(path) {\n                // The identifier should have the expected name\n                if (path.node.name !== LOCALS_NAME) { return; }\n                // The identifier should not be part of a declaration\n                if (!path.isReferencedIdentifier()) { return; }\n                // The identifier should not reference a variable in current scope\n                if (path.scope.hasBinding(LOCALS_NAME)) { return; }\n\n                // console.log('locals expanded to', Object.keys(path.scope.getAllBindings()));\n\n\n                let vars = Object.keys(path.scope.getAllBindings())\n                        .map(label => t.objectProperty(\n                        t.identifier(label), // key\n                        t.identifier(label), // value\n                        undefined, // computed?\n                        true, // shorthand?\n                        undefined // decorators array\n                    ));\n\n                path.replaceWith(\n                    t.objectExpression(vars)\n                );\n            }\n        }\n    };\n}"],"mappings":";;;;qBAEe,UAAS;IAAEA,KAAK,EAAEC;EAAE,CAAC,EAAE;IAClC,OAAO;MACHC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE;QACLC,UAAUA,CAACC,IAAI,EAAE;UACb;UACA,IAAIA,IAAI,CAACC,IAAI,CAACJ,IAAI,KAAKK,WAAW,EAAE;YAAE;UAAQ;UAC9C;UACA,IAAI,CAACF,IAAI,CAACG,sBAAsB,CAAC,CAAC,EAAE;YAAE;UAAQ;UAC9C;UACA,IAAIH,IAAI,CAACI,KAAK,CAACC,UAAU,CAACH,WAAW,CAAC,EAAE;YAAE;UAAQ;;UAElD;;UAGA,IAAII,IAAI,GAAGC,MAAM,CAACC,IAAI,CAACR,IAAI,CAACI,KAAK,CAACK,cAAc,CAAC,CAAC,CAAC,CAC1CC,GAAG,CAACC,KAAK,IAAIf,CAAC,CAACgB,cAAc,CAC9BhB,CAAC,CAACiB,UAAU,CAACF,KAAK,CAAC;UAAE;UACrBf,CAAC,CAACiB,UAAU,CAACF,KAAK,CAAC;UAAE;UACrBG,SAAS;UAAE;UACX,IAAI;UAAE;UACNA,SAAS,CAAC;UACd,CAAC,CAAC;;UAENd,IAAI,CAACe,WAAW,CACZnB,CAAC,CAACoB,gBAAgB,CAACV,IAAI,CAC3B,CAAC;QACL;MACJ;IACJ,CAAC;EACL,CAAC;EAAA;IAAAW,OAAA;IAAAC,OAAA,WAAAA,CAAA;MAhCKhB,WAAW,GAAG,QAAQ;IAAA;EAAA;AAAA"}