UNPKG

2.38 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../src/utils/builder.js"],"names":["placeholders","split","placeholderWhitelist","Set","buildExpressionTemplate","code","template","preludeGenerator","obj","undefined","placeholderPattern","includes","Object","assign","global","memoizeReference","result","expression"],"mappings":";;;;;;;AAWA;;AAGA;;;;AAdA;;;;;;;;AAgBA,MAAMA,eAAe,6BAA6BC,KAA7B,CAAmC,EAAnC,CAArB;AACA,MAAMC,uBAAuB,IAAIC,GAAJ,CAAQ,CAAC,QAAD,EAAW,GAAGH,YAAd,CAAR,CAA7B;;AAEe,SAASI,uBAAT,CAAiCC,IAAjC,EAAwG;AACrH,MAAIC,QAAJ;AACA,SAAQC,gBAAD,IAAgDC,GAAD,IAAmC;AACvF,QAAIF,aAAaG,SAAjB,EAA4BH,WAAW,uBAAcD,IAAd,EAAoB;AAAEK,0BAAoB,KAAtB;AAA6BR;AAA7B,KAApB,CAAX;AAC5B,QAAIK,qBAAqBE,SAArB,IAAkCJ,KAAKM,QAAL,CAAc,QAAd,CAAtC,EACEH,MAAMI,OAAOC,MAAP,CACJ;AACEC,cAAQP,iBAAiBQ,gBAAjB,CAAkC,QAAlC;AADV,KADI,EAIJP,GAJI,CAAN;AAMF,QAAIQ,SAASV,SAASE,GAAT,EAAcS,UAA3B;AACA,4BAAUD,WAAWP,SAArB,EAAgC,4CAA4CJ,IAA5E;AACA,WAAOW,MAAP;AACD,GAZD;AAaD","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport buildTemplate from \"@babel/template\";\nimport type { BabelNodeExpression } from \"@babel/types\";\nimport type { PreludeGenerator } from \"./PreludeGenerator.js\";\nimport invariant from \"../invariant.js\";\n\nconst placeholders = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".split(\"\");\nconst placeholderWhitelist = new Set([\"global\", ...placeholders]);\n\nexport default function buildExpressionTemplate(code: string): (void | PreludeGenerator) => any => BabelNodeExpression {\n let template;\n return (preludeGenerator: void | PreludeGenerator) => (obj: any): BabelNodeExpression => {\n if (template === undefined) template = buildTemplate(code, { placeholderPattern: false, placeholderWhitelist });\n if (preludeGenerator !== undefined && code.includes(\"global\"))\n obj = Object.assign(\n {\n global: preludeGenerator.memoizeReference(\"global\"),\n },\n obj\n );\n let result = template(obj).expression;\n invariant(result !== undefined, \"Code does not represent an expression: \" + code);\n return result;\n };\n}\n"],"file":"builder.js"}
\No newline at end of file