@tamagui/static 1.0.1-beta.99 → 1.0.1-rc.0.1
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/{cjs/constants.js → constants.js} +9 -4
- package/dist/constants.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/accessSafe.js +14 -2
- package/dist/{esm/extractor → extractor}/accessSafe.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/babelParse.js +5 -1
- package/dist/extractor/babelParse.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/buildClassName.js +40 -9
- package/dist/extractor/buildClassName.js.map +7 -0
- package/dist/extractor/bundle.js +117 -0
- package/dist/extractor/bundle.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/createEvaluator.js +11 -8
- package/dist/extractor/createEvaluator.js.map +7 -0
- package/dist/extractor/createExtractor.js +1623 -0
- package/dist/extractor/createExtractor.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/ensureImportingConcat.js +18 -6
- package/dist/extractor/ensureImportingConcat.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/evaluateAstNode.js +14 -4
- package/dist/extractor/evaluateAstNode.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/extractHelpers.js +83 -12
- package/dist/extractor/extractHelpers.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/extractMediaStyle.js +46 -42
- package/dist/extractor/extractMediaStyle.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/extractToClassNames.js +144 -73
- package/dist/extractor/extractToClassNames.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/findTopmostFunction.js +1 -0
- package/dist/{cjs/extractor → extractor}/findTopmostFunction.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/generatedUid.js +9 -2
- package/dist/{cjs/extractor → extractor}/generatedUid.js.map +3 -3
- package/dist/{cjs/extractor → extractor}/getPrefixLogs.js +1 -0
- package/dist/extractor/getPrefixLogs.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/getPropValueFromAttributes.js +24 -13
- package/dist/extractor/getPropValueFromAttributes.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/getSourceModule.js +5 -1
- package/dist/{esm/extractor → extractor}/getSourceModule.js.map +3 -3
- package/dist/{cjs/extractor → extractor}/getStaticBindingsForScope.js +89 -35
- package/dist/extractor/getStaticBindingsForScope.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/hoistClassNames.js +5 -1
- package/dist/{jsx/extractor → extractor}/hoistClassNames.js.map +3 -3
- package/dist/{cjs/extractor → extractor}/literalToAst.js +26 -30
- package/dist/{jsx/extractor → extractor}/literalToAst.js.map +2 -2
- package/dist/extractor/loadFile.js +21 -0
- package/dist/extractor/loadFile.js.map +7 -0
- package/dist/extractor/loadTamagui.js +427 -0
- package/dist/extractor/loadTamagui.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/logLines.js +2 -1
- package/dist/extractor/logLines.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/normalizeTernaries.js +13 -34
- package/dist/extractor/normalizeTernaries.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/removeUnusedHooks.js +5 -1
- package/dist/extractor/removeUnusedHooks.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/timer.js +9 -1
- package/dist/extractor/timer.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/validHTMLAttributes.js +1 -0
- package/dist/{jsx/extractor → extractor}/validHTMLAttributes.js.map +2 -2
- package/dist/getPragmaOptions.js +68 -0
- package/dist/getPragmaOptions.js.map +7 -0
- package/dist/helpers/memoize.js +46 -0
- package/dist/helpers/memoize.js.map +7 -0
- package/dist/{cjs/index.js → index.js} +10 -8
- package/dist/index.js.map +7 -0
- package/dist/require.js +86 -0
- package/dist/require.js.map +7 -0
- package/dist/{cjs/types.js → types.js} +1 -0
- package/dist/types.js.map +7 -0
- package/dist/webpackPlugin.js +35 -0
- package/dist/webpackPlugin.js.map +7 -0
- package/package.json +40 -36
- package/src/constants.ts +2 -1
- package/src/extractor/babelParse.ts +3 -2
- package/src/extractor/buildClassName.ts +21 -5
- package/src/extractor/bundle.ts +110 -0
- package/src/extractor/createEvaluator.ts +10 -12
- package/src/extractor/createExtractor.ts +1702 -1523
- package/src/extractor/ensureImportingConcat.ts +4 -11
- package/src/extractor/evaluateAstNode.ts +1 -1
- package/src/extractor/extractHelpers.ts +93 -10
- package/src/extractor/extractMediaStyle.ts +18 -11
- package/src/extractor/extractToClassNames.ts +104 -47
- package/src/extractor/getPrefixLogs.ts +1 -1
- package/src/extractor/getPropValueFromAttributes.ts +4 -3
- package/src/extractor/getSourceModule.ts +2 -0
- package/src/extractor/getStaticBindingsForScope.ts +90 -46
- package/src/extractor/loadFile.ts +17 -0
- package/src/extractor/loadTamagui.ts +448 -103
- package/src/extractor/logLines.ts +1 -1
- package/src/extractor/normalizeTernaries.ts +2 -2
- package/src/extractor/removeUnusedHooks.ts +2 -0
- package/src/extractor/timer.ts +12 -1
- package/src/getPragmaOptions.ts +53 -0
- package/src/helpers/memoize.ts +21 -0
- package/src/index.ts +9 -8
- package/src/require.ts +103 -0
- package/src/types.ts +33 -31
- package/src/webpackPlugin.ts +9 -0
- package/tamagui.tsconfig.json +5 -0
- package/types/constants.d.ts +6 -0
- package/types/extractor/accessSafe.d.ts +3 -0
- package/types/extractor/babelParse.d.ts +6 -0
- package/types/extractor/buildClassName.d.ts +5 -2
- package/types/extractor/bundle.d.ts +13 -0
- package/types/extractor/createEvaluator.d.ts +3 -3
- package/types/extractor/createExtractor.d.ts +25 -9
- package/types/extractor/ensureImportingConcat.d.ts +4 -0
- package/types/extractor/evaluateAstNode.d.ts +3 -0
- package/types/extractor/extractHelpers.d.ts +15 -3
- package/types/extractor/extractMediaStyle.d.ts +3 -3
- package/types/extractor/extractToClassNames.d.ts +5 -4
- package/types/extractor/findTopmostFunction.d.ts +4 -0
- package/types/extractor/generatedUid.d.ts +5 -0
- package/types/extractor/getPrefixLogs.d.ts +1 -1
- package/types/extractor/getPropValueFromAttributes.d.ts +19 -0
- package/types/extractor/getSourceModule.d.ts +16 -0
- package/types/extractor/getStaticBindingsForScope.d.ts +5 -0
- package/types/extractor/hoistClassNames.d.ts +6 -0
- package/types/extractor/literalToAst.d.ts +4 -0
- package/types/extractor/loadFile.d.ts +1 -0
- package/types/extractor/loadTamagui.d.ts +15 -5
- package/types/extractor/logLines.d.ts +2 -0
- package/types/extractor/normalizeTernaries.d.ts +1 -1
- package/types/extractor/removeUnusedHooks.d.ts +3 -0
- package/types/extractor/timer.d.ts +5 -0
- package/types/extractor/validHTMLAttributes.d.ts +98 -0
- package/types/getPragmaOptions.d.ts +9 -0
- package/types/helpers/memoize.d.ts +8 -0
- package/types/index.d.ts +9 -8
- package/types/require.d.ts +4 -0
- package/types/types.d.ts +28 -27
- package/types/webpackPlugin.d.ts +4 -0
- package/dist/cjs/constants.js.map +0 -7
- package/dist/cjs/extractor/accessSafe.js.map +0 -7
- package/dist/cjs/extractor/babelParse.js.map +0 -7
- package/dist/cjs/extractor/buildClassName.js.map +0 -7
- package/dist/cjs/extractor/createEvaluator.js.map +0 -7
- package/dist/cjs/extractor/createExtractor.js +0 -1394
- package/dist/cjs/extractor/createExtractor.js.map +0 -7
- package/dist/cjs/extractor/ensureImportingConcat.js.map +0 -7
- package/dist/cjs/extractor/evaluateAstNode.js.map +0 -7
- package/dist/cjs/extractor/extractHelpers.js.map +0 -7
- package/dist/cjs/extractor/extractMediaStyle.js.map +0 -7
- package/dist/cjs/extractor/extractToClassNames.js.map +0 -7
- package/dist/cjs/extractor/getPrefixLogs.js.map +0 -7
- package/dist/cjs/extractor/getPropValueFromAttributes.js.map +0 -7
- package/dist/cjs/extractor/getSourceModule.js.map +0 -7
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +0 -7
- package/dist/cjs/extractor/hoistClassNames.js.map +0 -7
- package/dist/cjs/extractor/literalToAst.js.map +0 -7
- package/dist/cjs/extractor/loadTamagui.js +0 -139
- package/dist/cjs/extractor/loadTamagui.js.map +0 -7
- package/dist/cjs/extractor/logLines.js.map +0 -7
- package/dist/cjs/extractor/normalizeTernaries.js.map +0 -7
- package/dist/cjs/extractor/removeUnusedHooks.js.map +0 -7
- package/dist/cjs/extractor/timer.js.map +0 -7
- package/dist/cjs/extractor/validHTMLAttributes.js.map +0 -7
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/types.js.map +0 -7
- package/dist/esm/constants.js +0 -14
- package/dist/esm/constants.js.map +0 -7
- package/dist/esm/extractor/accessSafe.js +0 -8
- package/dist/esm/extractor/babelParse.js +0 -28
- package/dist/esm/extractor/babelParse.js.map +0 -7
- package/dist/esm/extractor/buildClassName.js +0 -37
- package/dist/esm/extractor/buildClassName.js.map +0 -7
- package/dist/esm/extractor/createEvaluator.js +0 -53
- package/dist/esm/extractor/createEvaluator.js.map +0 -7
- package/dist/esm/extractor/createExtractor.js +0 -1379
- package/dist/esm/extractor/createExtractor.js.map +0 -7
- package/dist/esm/extractor/ensureImportingConcat.js +0 -21
- package/dist/esm/extractor/ensureImportingConcat.js.map +0 -7
- package/dist/esm/extractor/evaluateAstNode.js +0 -91
- package/dist/esm/extractor/evaluateAstNode.js.map +0 -7
- package/dist/esm/extractor/extractHelpers.js +0 -97
- package/dist/esm/extractor/extractHelpers.js.map +0 -7
- package/dist/esm/extractor/extractMediaStyle.js +0 -161
- package/dist/esm/extractor/extractMediaStyle.js.map +0 -7
- package/dist/esm/extractor/extractToClassNames.js +0 -294
- package/dist/esm/extractor/extractToClassNames.js.map +0 -7
- package/dist/esm/extractor/findTopmostFunction.js +0 -20
- package/dist/esm/extractor/findTopmostFunction.js.map +0 -7
- package/dist/esm/extractor/generatedUid.js +0 -25
- package/dist/esm/extractor/generatedUid.js.map +0 -7
- package/dist/esm/extractor/getPrefixLogs.js +0 -8
- package/dist/esm/extractor/getPrefixLogs.js.map +0 -7
- package/dist/esm/extractor/getPropValueFromAttributes.js +0 -46
- package/dist/esm/extractor/getPropValueFromAttributes.js.map +0 -7
- package/dist/esm/extractor/getSourceModule.js +0 -66
- package/dist/esm/extractor/getStaticBindingsForScope.js +0 -132
- package/dist/esm/extractor/getStaticBindingsForScope.js.map +0 -7
- package/dist/esm/extractor/hoistClassNames.js +0 -40
- package/dist/esm/extractor/hoistClassNames.js.map +0 -7
- package/dist/esm/extractor/literalToAst.js +0 -90
- package/dist/esm/extractor/literalToAst.js.map +0 -7
- package/dist/esm/extractor/loadTamagui.js +0 -117
- package/dist/esm/extractor/loadTamagui.js.map +0 -7
- package/dist/esm/extractor/logLines.js +0 -20
- package/dist/esm/extractor/logLines.js.map +0 -7
- package/dist/esm/extractor/normalizeTernaries.js +0 -79
- package/dist/esm/extractor/normalizeTernaries.js.map +0 -7
- package/dist/esm/extractor/removeUnusedHooks.js +0 -76
- package/dist/esm/extractor/removeUnusedHooks.js.map +0 -7
- package/dist/esm/extractor/timer.js +0 -22
- package/dist/esm/extractor/timer.js.map +0 -7
- package/dist/esm/extractor/validHTMLAttributes.js +0 -102
- package/dist/esm/extractor/validHTMLAttributes.js.map +0 -7
- package/dist/esm/index.js +0 -15
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -7
- package/dist/jsx/constants.js +0 -14
- package/dist/jsx/constants.js.map +0 -7
- package/dist/jsx/extractor/accessSafe.js +0 -8
- package/dist/jsx/extractor/accessSafe.js.map +0 -7
- package/dist/jsx/extractor/babelParse.js +0 -28
- package/dist/jsx/extractor/babelParse.js.map +0 -7
- package/dist/jsx/extractor/buildClassName.js +0 -37
- package/dist/jsx/extractor/buildClassName.js.map +0 -7
- package/dist/jsx/extractor/createEvaluator.js +0 -53
- package/dist/jsx/extractor/createEvaluator.js.map +0 -7
- package/dist/jsx/extractor/createExtractor.js +0 -1343
- package/dist/jsx/extractor/createExtractor.js.map +0 -7
- package/dist/jsx/extractor/ensureImportingConcat.js +0 -21
- package/dist/jsx/extractor/ensureImportingConcat.js.map +0 -7
- package/dist/jsx/extractor/evaluateAstNode.js +0 -91
- package/dist/jsx/extractor/evaluateAstNode.js.map +0 -7
- package/dist/jsx/extractor/extractHelpers.js +0 -97
- package/dist/jsx/extractor/extractHelpers.js.map +0 -7
- package/dist/jsx/extractor/extractMediaStyle.js +0 -146
- package/dist/jsx/extractor/extractMediaStyle.js.map +0 -7
- package/dist/jsx/extractor/extractToClassNames.js +0 -280
- package/dist/jsx/extractor/extractToClassNames.js.map +0 -7
- package/dist/jsx/extractor/findTopmostFunction.js +0 -20
- package/dist/jsx/extractor/findTopmostFunction.js.map +0 -7
- package/dist/jsx/extractor/generatedUid.js +0 -25
- package/dist/jsx/extractor/generatedUid.js.map +0 -7
- package/dist/jsx/extractor/getPrefixLogs.js +0 -9
- package/dist/jsx/extractor/getPrefixLogs.js.map +0 -7
- package/dist/jsx/extractor/getPropValueFromAttributes.js +0 -46
- package/dist/jsx/extractor/getPropValueFromAttributes.js.map +0 -7
- package/dist/jsx/extractor/getSourceModule.js +0 -66
- package/dist/jsx/extractor/getSourceModule.js.map +0 -7
- package/dist/jsx/extractor/getStaticBindingsForScope.js +0 -132
- package/dist/jsx/extractor/getStaticBindingsForScope.js.map +0 -7
- package/dist/jsx/extractor/hoistClassNames.js +0 -40
- package/dist/jsx/extractor/literalToAst.js +0 -75
- package/dist/jsx/extractor/loadTamagui.js +0 -102
- package/dist/jsx/extractor/loadTamagui.js.map +0 -7
- package/dist/jsx/extractor/logLines.js +0 -20
- package/dist/jsx/extractor/logLines.js.map +0 -7
- package/dist/jsx/extractor/normalizeTernaries.js +0 -50
- package/dist/jsx/extractor/normalizeTernaries.js.map +0 -7
- package/dist/jsx/extractor/removeUnusedHooks.js +0 -77
- package/dist/jsx/extractor/removeUnusedHooks.js.map +0 -7
- package/dist/jsx/extractor/timer.js +0 -22
- package/dist/jsx/extractor/timer.js.map +0 -7
- package/dist/jsx/extractor/validHTMLAttributes.js +0 -102
- package/dist/jsx/index.js +0 -15
- package/dist/jsx/index.js.map +0 -7
- package/dist/jsx/types.js +0 -1
- package/dist/jsx/types.js.map +0 -7
- package/types/extractor/buildClassName.d.ts.map +0 -1
- package/types/extractor/createEvaluator.d.ts.map +0 -1
- package/types/extractor/createExtractor.d.ts.map +0 -1
- package/types/extractor/extractHelpers.d.ts.map +0 -1
- package/types/extractor/extractMediaStyle.d.ts.map +0 -1
- package/types/extractor/extractToClassNames.d.ts.map +0 -1
- package/types/extractor/getPrefixLogs.d.ts.map +0 -1
- package/types/extractor/loadTamagui.d.ts.map +0 -1
- package/types/extractor/normalizeTernaries.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/types.d.ts.map +0 -1
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/extractor/getPropValueFromAttributes.ts"],
|
|
4
|
-
"sourcesContent": ["import generate from '@babel/generator'\nimport * as t from '@babel/types'\n\nimport { accessSafe } from './accessSafe'\n\n/**\n * getPropValueFromAttributes gets a prop by name from a list of attributes and accounts for potential spread operators.\n * Here's an example. Given this component:\n * ```\n * <Block coolProp=\"wow\" {...spread1} neatProp=\"ok\" {...spread2} />```\n * getPropValueFromAttributes will return the following:\n * - for propName `coolProp`:\n * ```\n * accessSafe(spread1, 'coolProp') || accessSafe(spread2, 'coolProp') || 'wow'```\n * - for propName `neatProp`:\n * ```\n * accessSafe(spread2, 'neatProp') || 'ok'```\n * - for propName `notPresent`: `null`\n *\n * The returned value should (obviously) be placed after spread operators.\n */\nexport function getPropValueFromAttributes(\n propName: string,\n attrs: (t.JSXAttribute | t.JSXSpreadAttribute)[]\n): t.Expression | null {\n let propIndex: number = -1\n let jsxAttr: t.JSXAttribute | null = null\n for (let idx = -1, len = attrs.length; ++idx < len; ) {\n const attr = attrs[idx]\n if (t.isJSXAttribute(attr) && attr.name && attr.name.name === propName) {\n propIndex = idx\n jsxAttr = attr\n break\n }\n }\n\n if (!jsxAttr || jsxAttr.value == null) {\n return null\n }\n\n let propValue:\n | t.JSXElement\n | t.JSXFragment\n | t.StringLiteral\n | t.JSXExpressionContainer\n | t.JSXEmptyExpression\n | t.Expression = jsxAttr.value\n\n if (t.isJSXExpressionContainer(propValue)) {\n propValue = propValue.expression\n }\n\n // TODO how to handle this??\n if (t.isJSXEmptyExpression(propValue)) {\n console.error('encountered JSXEmptyExpression')\n return null\n }\n\n // filter out spread props that occur before propValue\n const applicableSpreads = attrs\n .filter(\n // 1. idx is greater than propValue prop index\n // 2. attr is a spread operator\n (attr, idx): attr is t.JSXSpreadAttribute => {\n if (t.isJSXSpreadAttribute(attr)) {\n if (t.isIdentifier(attr.argument) || t.isMemberExpression(attr.argument)) {\n return idx > propIndex\n }\n if (t.isLogicalExpression(attr.argument)) {\n return false\n }\n throw new Error(\n `unsupported spread of type \"${attr.argument.type}\": ${generate(attr).code}`\n )\n }\n return false\n }\n )\n .map((attr) => attr.argument)\n\n // if spread operators occur after propValue, create a binary expression for each operator\n // i.e. before1.propValue || before2.propValue || propValue\n // TODO: figure out how to do this without all the extra parens\n if (applicableSpreads.length > 0) {\n propValue = applicableSpreads.reduce<t.Expression>(\n (acc, val) => t.logicalExpression('||', accessSafe(val, propName), acc),\n propValue\n )\n }\n\n return propValue\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AACA;AAEA;AAkBO,oCACL,UACA,OACqB;AACrB,MAAI,YAAoB;AACxB,MAAI,UAAiC;AACrC,WAAS,MAAM,IAAI,MAAM,MAAM,QAAQ,EAAE,MAAM,OAAO;AACpD,UAAM,OAAO,MAAM;AACnB,QAAI,EAAE,eAAe,IAAI,KAAK,KAAK,QAAQ,KAAK,KAAK,SAAS,UAAU;AACtE,kBAAY;AACZ,gBAAU;AACV;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,WAAW,QAAQ,SAAS,MAAM;AACrC,WAAO;AAAA,EACT;AAEA,MAAI,YAMe,QAAQ;AAE3B,MAAI,EAAE,yBAAyB,SAAS,GAAG;AACzC,gBAAY,UAAU;AAAA,EACxB;AAGA,MAAI,EAAE,qBAAqB,SAAS,GAAG;AACrC,YAAQ,MAAM,gCAAgC;AAC9C,WAAO;AAAA,EACT;AAGA,QAAM,oBAAoB,MACvB,OAGC,CAAC,MAAM,QAAsC;AAC3C,QAAI,EAAE,qBAAqB,IAAI,GAAG;AAChC,UAAI,EAAE,aAAa,KAAK,QAAQ,KAAK,EAAE,mBAAmB,KAAK,QAAQ,GAAG;AACxE,eAAO,MAAM;AAAA,MACf;AACA,UAAI,EAAE,oBAAoB,KAAK,QAAQ,GAAG;AACxC,eAAO;AAAA,MACT;AACA,YAAM,IAAI,MACR,+BAA+B,KAAK,SAAS,UAAU,SAAS,IAAI,EAAE,MACxE;AAAA,IACF;AACA,WAAO;AAAA,EACT,CACF,EACC,IAAI,CAAC,SAAS,KAAK,QAAQ;AAK9B,MAAI,kBAAkB,SAAS,GAAG;AAChC,gBAAY,kBAAkB,OAC5B,CAAC,KAAK,QAAQ,EAAE,kBAAkB,MAAM,WAAW,KAAK,QAAQ,GAAG,GAAG,GACtE,SACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import * as t from "@babel/types";
|
|
2
|
-
function getSourceModule(itemName, itemBinding) {
|
|
3
|
-
if (!itemBinding.constant) {
|
|
4
|
-
return null;
|
|
5
|
-
}
|
|
6
|
-
let sourceModule;
|
|
7
|
-
let imported;
|
|
8
|
-
let local;
|
|
9
|
-
let destructured;
|
|
10
|
-
let usesImportSyntax = false;
|
|
11
|
-
const itemNode = itemBinding.path.node;
|
|
12
|
-
if (t.isImportDefaultSpecifier(itemNode) || t.isImportSpecifier(itemNode)) {
|
|
13
|
-
if (t.isImportDeclaration(itemBinding.path.parent)) {
|
|
14
|
-
sourceModule = itemBinding.path.parent.source.value;
|
|
15
|
-
local = itemNode.local.name;
|
|
16
|
-
usesImportSyntax = true;
|
|
17
|
-
if (t.isImportSpecifier(itemNode)) {
|
|
18
|
-
imported = itemNode.imported["name"];
|
|
19
|
-
destructured = true;
|
|
20
|
-
} else {
|
|
21
|
-
imported = itemNode.local.name;
|
|
22
|
-
destructured = false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
} else if (t.isVariableDeclarator(itemNode) && itemNode.init != null && t.isCallExpression(itemNode.init) && t.isIdentifier(itemNode.init.callee) && itemNode.init.callee.name === "require" && itemNode.init.arguments.length === 1) {
|
|
26
|
-
const firstArg = itemNode.init.arguments[0];
|
|
27
|
-
if (!t.isStringLiteral(firstArg)) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
sourceModule = firstArg.value;
|
|
31
|
-
if (t.isIdentifier(itemNode.id)) {
|
|
32
|
-
local = itemNode.id.name;
|
|
33
|
-
imported = itemNode.id.name;
|
|
34
|
-
destructured = false;
|
|
35
|
-
} else if (t.isObjectPattern(itemNode.id)) {
|
|
36
|
-
for (const objProp of itemNode.id.properties) {
|
|
37
|
-
if (t.isObjectProperty(objProp) && t.isIdentifier(objProp.value) && objProp.value.name === itemName) {
|
|
38
|
-
local = objProp.value.name;
|
|
39
|
-
imported = objProp.key.name;
|
|
40
|
-
destructured = true;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (!local || !imported) {
|
|
45
|
-
console.error("could not find prop with value `%s`", itemName);
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
console.error("Unhandled id type: %s", itemNode.id.type);
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
destructured,
|
|
57
|
-
imported,
|
|
58
|
-
local,
|
|
59
|
-
sourceModule,
|
|
60
|
-
usesImportSyntax
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export {
|
|
64
|
-
getSourceModule
|
|
65
|
-
};
|
|
66
|
-
//# sourceMappingURL=getSourceModule.js.map
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { dirname, extname, resolve } from "path";
|
|
2
|
-
import * as t from "@babel/types";
|
|
3
|
-
import { existsSync } from "fs-extra";
|
|
4
|
-
import { evaluateAstNode } from "./evaluateAstNode";
|
|
5
|
-
import { getSourceModule } from "./getSourceModule";
|
|
6
|
-
const isLocalImport = (path) => path.startsWith(".") || path.startsWith("/");
|
|
7
|
-
function resolveImportPath(sourcePath, path) {
|
|
8
|
-
const sourceDir = dirname(sourcePath);
|
|
9
|
-
if (isLocalImport(path)) {
|
|
10
|
-
if (extname(path) === "") {
|
|
11
|
-
path += ".js";
|
|
12
|
-
}
|
|
13
|
-
return resolve(sourceDir, path);
|
|
14
|
-
}
|
|
15
|
-
return path;
|
|
16
|
-
}
|
|
17
|
-
function importModule(path) {
|
|
18
|
-
const filenames = [path.replace(".js", ".tsx"), path.replace(".js", ".ts"), path];
|
|
19
|
-
for (const file of filenames) {
|
|
20
|
-
if (existsSync(file)) {
|
|
21
|
-
const { unregister } = require("esbuild-register/dist/node").register({
|
|
22
|
-
target: "es2019",
|
|
23
|
-
format: "cjs"
|
|
24
|
-
});
|
|
25
|
-
try {
|
|
26
|
-
return require(file);
|
|
27
|
-
} catch {
|
|
28
|
-
} finally {
|
|
29
|
-
unregister();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bindingCache, shouldPrintDebug) {
|
|
36
|
-
const bindings = scope.getAllBindings();
|
|
37
|
-
const ret = {};
|
|
38
|
-
if (shouldPrintDebug) {
|
|
39
|
-
console.log(" ", Object.keys(bindings).length, "variables in scope");
|
|
40
|
-
}
|
|
41
|
-
const program = scope.getProgramParent().block;
|
|
42
|
-
for (const node of program.body) {
|
|
43
|
-
if (t.isImportDeclaration(node)) {
|
|
44
|
-
const importPath = node.source.value;
|
|
45
|
-
if (!node.specifiers.length)
|
|
46
|
-
continue;
|
|
47
|
-
if (!isLocalImport(importPath)) {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
const moduleName = resolveImportPath(sourcePath, importPath);
|
|
51
|
-
const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test));
|
|
52
|
-
if (!isOnWhitelist)
|
|
53
|
-
continue;
|
|
54
|
-
const src = importModule(moduleName);
|
|
55
|
-
if (!src)
|
|
56
|
-
continue;
|
|
57
|
-
for (const specifier of node.specifiers) {
|
|
58
|
-
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {
|
|
59
|
-
if (typeof src[specifier.imported.name] !== "undefined") {
|
|
60
|
-
const val = src[specifier.local.name];
|
|
61
|
-
ret[specifier.local.name] = val;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (!bindingCache) {
|
|
68
|
-
throw new Error("bindingCache is a required param");
|
|
69
|
-
}
|
|
70
|
-
for (const k in bindings) {
|
|
71
|
-
const binding = bindings[k];
|
|
72
|
-
const sourceModule = getSourceModule(k, binding);
|
|
73
|
-
if (sourceModule) {
|
|
74
|
-
if (!sourceModule.sourceModule) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule);
|
|
78
|
-
const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test));
|
|
79
|
-
if (isOnWhitelist) {
|
|
80
|
-
const src = importModule(moduleName);
|
|
81
|
-
if (!src) {
|
|
82
|
-
console.log(`\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`);
|
|
83
|
-
return {};
|
|
84
|
-
}
|
|
85
|
-
if (sourceModule.destructured) {
|
|
86
|
-
if (sourceModule.imported) {
|
|
87
|
-
ret[k] = src[sourceModule.imported];
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
ret[k] = src;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
const { parent, parentPath } = binding.path;
|
|
96
|
-
if (!t.isVariableDeclaration(parent) || parent.kind !== "const") {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k);
|
|
100
|
-
if (!dec || !dec.init) {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
if (typeof dec.id.start !== "number" || typeof dec.id.end !== "number") {
|
|
104
|
-
console.error("dec.id.start/end is not a number");
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
if (!t.isIdentifier(dec.id)) {
|
|
108
|
-
console.error("dec is not an identifier");
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`;
|
|
112
|
-
if (bindingCache.hasOwnProperty(cacheKey)) {
|
|
113
|
-
ret[k] = bindingCache[cacheKey];
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
if (bindingCache.hasOwnProperty(cacheKey)) {
|
|
117
|
-
ret[k] = bindingCache[cacheKey];
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
ret[k] = evaluateAstNode(dec.init, void 0, shouldPrintDebug);
|
|
122
|
-
bindingCache[cacheKey] = ret[k];
|
|
123
|
-
continue;
|
|
124
|
-
} catch (e) {
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return ret;
|
|
128
|
-
}
|
|
129
|
-
export {
|
|
130
|
-
getStaticBindingsForScope
|
|
131
|
-
};
|
|
132
|
-
//# sourceMappingURL=getStaticBindingsForScope.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/extractor/getStaticBindingsForScope.ts"],
|
|
4
|
-
"sourcesContent": ["import { dirname, extname, resolve } from 'path'\n\nimport { Binding, NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { existsSync } from 'fs-extra'\n\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { getSourceModule } from './getSourceModule'\n\nconst isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')\n\nfunction resolveImportPath(sourcePath: string, path: string) {\n const sourceDir = dirname(sourcePath)\n if (isLocalImport(path)) {\n if (extname(path) === '') {\n path += '.js'\n }\n return resolve(sourceDir, path)\n }\n return path\n}\n\nfunction importModule(path: string) {\n const filenames = [path.replace('.js', '.tsx'), path.replace('.js', '.ts'), path]\n for (const file of filenames) {\n if (existsSync(file)) {\n const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n try {\n // TODO we can clear this when we see updates on it later on\n return require(file)\n } catch {\n // doesn't exists\n } finally {\n unregister()\n }\n }\n }\n return null\n}\n\nexport function getStaticBindingsForScope(\n scope: NodePath<t.JSXElement>['scope'],\n whitelist: string[] = [],\n sourcePath: string,\n bindingCache: Record<string, string | null>,\n shouldPrintDebug: boolean | 'verbose'\n): Record<string, any> {\n const bindings: Record<string, Binding> = scope.getAllBindings() as any\n const ret: Record<string, any> = {}\n\n if (shouldPrintDebug) {\n // prettier-ignore\n console.log(' ', Object.keys(bindings).length, 'variables in scope')\n // .map(x => bindings[x].identifier?.name).join(', ')\n }\n\n // on react native at least it doesnt find some bindings? not sure why\n // lets add in whitelisted imports if they exist\n const program = scope.getProgramParent().block as t.Program\n for (const node of program.body) {\n if (t.isImportDeclaration(node)) {\n const importPath = node.source.value\n if (!node.specifiers.length) continue\n if (!isLocalImport(importPath)) {\n continue\n }\n const moduleName = resolveImportPath(sourcePath, importPath)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n if (!isOnWhitelist) continue\n const src = importModule(moduleName)\n if (!src) continue\n for (const specifier of node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {\n if (typeof src[specifier.imported.name] !== 'undefined') {\n const val = src[specifier.local.name]\n ret[specifier.local.name] = val\n }\n }\n }\n }\n }\n\n if (!bindingCache) {\n throw new Error('bindingCache is a required param')\n }\n\n for (const k in bindings) {\n const binding = bindings[k]\n\n // check to see if the item is a module\n const sourceModule = getSourceModule(k, binding)\n if (sourceModule) {\n if (!sourceModule.sourceModule) {\n continue\n }\n\n const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule)\n const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))\n\n // TODO we could cache this at the file level.. and check if its been touched since\n\n if (isOnWhitelist) {\n const src = importModule(moduleName)\n if (!src) {\n console.log(\n `\u26A0\uFE0F missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`\n )\n return {}\n }\n if (sourceModule.destructured) {\n if (sourceModule.imported) {\n ret[k] = src[sourceModule.imported]\n }\n } else {\n // crude esmodule check\n // TODO: make sure this actually works\n // if (src && src.__esModule) {\n // ret[k] = src.default\n // } else {\n ret[k] = src\n // }\n }\n }\n continue\n }\n\n const { parent, parentPath } = binding.path\n\n if (!t.isVariableDeclaration(parent) || parent.kind !== 'const') {\n continue\n }\n\n // pick out the right variable declarator\n const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k)\n\n // if init is not set, there's nothing to evaluate\n // TODO: handle spread syntax\n if (!dec || !dec.init) {\n continue\n }\n\n // missing start/end will break caching\n if (typeof dec.id.start !== 'number' || typeof dec.id.end !== 'number') {\n console.error('dec.id.start/end is not a number')\n continue\n }\n\n if (!t.isIdentifier(dec.id)) {\n console.error('dec is not an identifier')\n continue\n }\n\n const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`\n\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n // retrieve value from cache\n if (bindingCache.hasOwnProperty(cacheKey)) {\n ret[k] = bindingCache[cacheKey]\n continue\n }\n\n // evaluate\n try {\n ret[k] = evaluateAstNode(dec.init, undefined, shouldPrintDebug)\n bindingCache[cacheKey] = ret[k]\n continue\n } catch (e) {\n // skip\n // if (shouldPrintDebug) {\n // console.error('[\uD83D\uDC07] cant eval, skipping', cacheKey) //, e.message)\n // }\n }\n }\n\n return ret\n}\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as t from "@babel/types";
|
|
2
|
-
function hoistClassNames(path, existing, expr) {
|
|
3
|
-
const hoist = hoistClassNames.bind(null, path, existing);
|
|
4
|
-
if (t.isStringLiteral(expr)) {
|
|
5
|
-
if (expr.value.trim() === "") {
|
|
6
|
-
return expr;
|
|
7
|
-
}
|
|
8
|
-
if (existing[expr.value]) {
|
|
9
|
-
return existing[expr.value];
|
|
10
|
-
}
|
|
11
|
-
const identifier = replaceStringWithVariable(expr);
|
|
12
|
-
existing[expr.value] = identifier;
|
|
13
|
-
return identifier;
|
|
14
|
-
}
|
|
15
|
-
if (t.isBinaryExpression(expr)) {
|
|
16
|
-
return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right));
|
|
17
|
-
}
|
|
18
|
-
if (t.isLogicalExpression(expr)) {
|
|
19
|
-
return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right));
|
|
20
|
-
}
|
|
21
|
-
if (t.isConditionalExpression(expr)) {
|
|
22
|
-
return t.conditionalExpression(expr.test, hoist(expr.consequent), hoist(expr.alternate));
|
|
23
|
-
}
|
|
24
|
-
return expr;
|
|
25
|
-
function replaceStringWithVariable(str) {
|
|
26
|
-
const uid = path.scope.generateUidIdentifier("cn");
|
|
27
|
-
const parent = path.findParent((path2) => path2.isProgram());
|
|
28
|
-
if (!parent)
|
|
29
|
-
throw new Error(`no program?`);
|
|
30
|
-
const variable = t.variableDeclaration("const", [
|
|
31
|
-
t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`))
|
|
32
|
-
]);
|
|
33
|
-
parent.unshiftContainer("body", variable);
|
|
34
|
-
return uid;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export {
|
|
38
|
-
hoistClassNames
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=hoistClassNames.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/extractor/hoistClassNames.ts"],
|
|
4
|
-
"sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\n\nexport function hoistClassNames(\n path: NodePath<t.JSXElement>,\n existing: { [key: string]: t.Identifier },\n expr: t.Expression\n) {\n const hoist = hoistClassNames.bind(null, path, existing)\n if (t.isStringLiteral(expr)) {\n if (expr.value.trim() === '') {\n return expr\n }\n if (existing[expr.value]) {\n return existing[expr.value]\n }\n const identifier = replaceStringWithVariable(expr)\n existing[expr.value] = identifier\n return identifier\n }\n if (t.isBinaryExpression(expr)) {\n return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right))\n }\n if (t.isLogicalExpression(expr)) {\n return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right))\n }\n if (t.isConditionalExpression(expr)) {\n return t.conditionalExpression(expr.test, hoist(expr.consequent), hoist(expr.alternate))\n }\n return expr\n\n function replaceStringWithVariable(str: t.StringLiteral): t.Identifier {\n // hoist outside fn!\n const uid = path.scope.generateUidIdentifier('cn')\n const parent = path.findParent((path) => path.isProgram())\n if (!parent) throw new Error(`no program?`)\n const variable = t.variableDeclaration('const', [\n // adding a space for extra safety\n t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`)),\n ])\n // @ts-ignore\n parent.unshiftContainer('body', variable)\n return uid\n }\n}\n"],
|
|
5
|
-
"mappings": "AACA;AAEO,yBACL,MACA,UACA,MACA;AACA,QAAM,QAAQ,gBAAgB,KAAK,MAAM,MAAM,QAAQ;AACvD,MAAI,EAAE,gBAAgB,IAAI,GAAG;AAC3B,QAAI,KAAK,MAAM,KAAK,MAAM,IAAI;AAC5B,aAAO;AAAA,IACT;AACA,QAAI,SAAS,KAAK,QAAQ;AACxB,aAAO,SAAS,KAAK;AAAA,IACvB;AACA,UAAM,aAAa,0BAA0B,IAAI;AACjD,aAAS,KAAK,SAAS;AACvB,WAAO;AAAA,EACT;AACA,MAAI,EAAE,mBAAmB,IAAI,GAAG;AAC9B,WAAO,EAAE,iBAAiB,KAAK,UAAU,MAAM,KAAK,IAAI,GAAG,MAAM,KAAK,KAAK,CAAC;AAAA,EAC9E;AACA,MAAI,EAAE,oBAAoB,IAAI,GAAG;AAC/B,WAAO,EAAE,kBAAkB,KAAK,UAAU,MAAM,KAAK,IAAI,GAAG,MAAM,KAAK,KAAK,CAAC;AAAA,EAC/E;AACA,MAAI,EAAE,wBAAwB,IAAI,GAAG;AACnC,WAAO,EAAE,sBAAsB,KAAK,MAAM,MAAM,KAAK,UAAU,GAAG,MAAM,KAAK,SAAS,CAAC;AAAA,EACzF;AACA,SAAO;AAEP,qCAAmC,KAAoC;AAErE,UAAM,MAAM,KAAK,MAAM,sBAAsB,IAAI;AACjD,UAAM,SAAS,KAAK,WAAW,CAAC,UAAS,MAAK,UAAU,CAAC;AACzD,QAAI,CAAC;AAAQ,YAAM,IAAI,MAAM,aAAa;AAC1C,UAAM,WAAW,EAAE,oBAAoB,SAAS;AAAA,MAE9C,EAAE,mBAAmB,KAAK,EAAE,cAAc,IAAI,IAAI,OAAO,CAAC;AAAA,IAC5D,CAAC;AAED,WAAO,iBAAiB,QAAQ,QAAQ;AACxC,WAAO;AAAA,EACT;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import * as t from "@babel/types";
|
|
21
|
-
function literalToAst(literal) {
|
|
22
|
-
if (literal === null) {
|
|
23
|
-
return t.nullLiteral();
|
|
24
|
-
}
|
|
25
|
-
switch (typeof literal) {
|
|
26
|
-
case "function":
|
|
27
|
-
throw new Error("Unsupported");
|
|
28
|
-
case "number":
|
|
29
|
-
return t.numericLiteral(literal);
|
|
30
|
-
case "string":
|
|
31
|
-
return t.stringLiteral(literal);
|
|
32
|
-
case "boolean":
|
|
33
|
-
return t.booleanLiteral(literal);
|
|
34
|
-
case "undefined":
|
|
35
|
-
return t.unaryExpression("void", t.numericLiteral(0), true);
|
|
36
|
-
default:
|
|
37
|
-
if (Array.isArray(literal)) {
|
|
38
|
-
return t.arrayExpression(literal.map(literalToAst));
|
|
39
|
-
}
|
|
40
|
-
return t.objectExpression(Object.keys(literal).filter((k) => {
|
|
41
|
-
return typeof literal[k] !== "undefined";
|
|
42
|
-
}).map((k) => {
|
|
43
|
-
return t.objectProperty(t.stringLiteral(k), literalToAst(literal[k]));
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const easyPeasies = ["BooleanLiteral", "StringLiteral", "NumericLiteral"];
|
|
48
|
-
function astToLiteral(node) {
|
|
49
|
-
if (!node) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (easyPeasies.includes(node.type)) {
|
|
53
|
-
return node.value;
|
|
54
|
-
}
|
|
55
|
-
if (node.name === "undefined" && !node.value) {
|
|
56
|
-
return void 0;
|
|
57
|
-
}
|
|
58
|
-
if (t.isNullLiteral(node)) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
if (t.isObjectExpression(node)) {
|
|
62
|
-
return computeProps(node.properties);
|
|
63
|
-
}
|
|
64
|
-
if (t.isArrayExpression(node)) {
|
|
65
|
-
return node.elements.reduce((acc, element) => [
|
|
66
|
-
...acc,
|
|
67
|
-
...(element == null ? void 0 : element.type) === "SpreadElement" ? astToLiteral(element.argument) : [astToLiteral(element)]
|
|
68
|
-
], []);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function computeProps(props) {
|
|
72
|
-
return props.reduce((acc, prop) => {
|
|
73
|
-
if (prop.type === "SpreadElement") {
|
|
74
|
-
return __spreadValues(__spreadValues({}, acc), astToLiteral(prop.argument));
|
|
75
|
-
} else if (prop.type !== "ObjectMethod") {
|
|
76
|
-
const val = astToLiteral(prop.value);
|
|
77
|
-
if (val !== void 0) {
|
|
78
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
79
|
-
[prop.key.name]: val
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return acc;
|
|
84
|
-
}, {});
|
|
85
|
-
}
|
|
86
|
-
export {
|
|
87
|
-
astToLiteral,
|
|
88
|
-
literalToAst
|
|
89
|
-
};
|
|
90
|
-
//# sourceMappingURL=literalToAst.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/extractor/literalToAst.ts"],
|
|
4
|
-
"sourcesContent": ["import * as t from '@babel/types'\n\nexport function literalToAst(literal: any): t.Expression {\n if (literal === null) {\n return t.nullLiteral()\n }\n switch (typeof literal) {\n case 'function':\n throw new Error('Unsupported')\n case 'number':\n return t.numericLiteral(literal)\n case 'string':\n return t.stringLiteral(literal)\n case 'boolean':\n return t.booleanLiteral(literal)\n case 'undefined':\n return t.unaryExpression('void', t.numericLiteral(0), true)\n default:\n if (Array.isArray(literal)) {\n return t.arrayExpression(literal.map(literalToAst))\n }\n return t.objectExpression(\n Object.keys(literal)\n .filter((k) => {\n return typeof literal[k] !== 'undefined'\n })\n .map((k) => {\n return t.objectProperty(t.stringLiteral(k), literalToAst(literal[k]))\n })\n )\n }\n}\n\nconst easyPeasies = ['BooleanLiteral', 'StringLiteral', 'NumericLiteral']\n\nexport function astToLiteral(node: any) {\n if (!node) {\n return\n }\n if (easyPeasies.includes(node.type)) {\n return node.value\n }\n if (node.name === 'undefined' && !node.value) {\n return undefined\n }\n if (t.isNullLiteral(node)) {\n return null\n }\n if (t.isObjectExpression(node)) {\n return computeProps(node.properties)\n }\n if (t.isArrayExpression(node)) {\n return node.elements.reduce(\n // @ts-ignore\n (acc, element) => [\n ...acc,\n ...(element?.type === 'SpreadElement'\n ? astToLiteral(element.argument)\n : [astToLiteral(element)]),\n ],\n []\n )\n }\n}\n\nfunction computeProps(props) {\n return props.reduce((acc, prop) => {\n if (prop.type === 'SpreadElement') {\n return {\n ...acc,\n ...astToLiteral(prop.argument),\n }\n } else if (prop.type !== 'ObjectMethod') {\n const val = astToLiteral(prop.value)\n if (val !== undefined) {\n return {\n ...acc,\n [prop.key.name]: val,\n }\n }\n }\n return acc\n }, {})\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAEO,sBAAsB,SAA4B;AACvD,MAAI,YAAY,MAAM;AACpB,WAAO,EAAE,YAAY;AAAA,EACvB;AACA,UAAQ,OAAO;AAAA,SACR;AACH,YAAM,IAAI,MAAM,aAAa;AAAA,SAC1B;AACH,aAAO,EAAE,eAAe,OAAO;AAAA,SAC5B;AACH,aAAO,EAAE,cAAc,OAAO;AAAA,SAC3B;AACH,aAAO,EAAE,eAAe,OAAO;AAAA,SAC5B;AACH,aAAO,EAAE,gBAAgB,QAAQ,EAAE,eAAe,CAAC,GAAG,IAAI;AAAA;AAE1D,UAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,eAAO,EAAE,gBAAgB,QAAQ,IAAI,YAAY,CAAC;AAAA,MACpD;AACA,aAAO,EAAE,iBACP,OAAO,KAAK,OAAO,EAChB,OAAO,CAAC,MAAM;AACb,eAAO,OAAO,QAAQ,OAAO;AAAA,MAC/B,CAAC,EACA,IAAI,CAAC,MAAM;AACV,eAAO,EAAE,eAAe,EAAE,cAAc,CAAC,GAAG,aAAa,QAAQ,EAAE,CAAC;AAAA,MACtE,CAAC,CACL;AAAA;AAEN;AAEA,MAAM,cAAc,CAAC,kBAAkB,iBAAiB,gBAAgB;AAEjE,sBAAsB,MAAW;AACtC,MAAI,CAAC,MAAM;AACT;AAAA,EACF;AACA,MAAI,YAAY,SAAS,KAAK,IAAI,GAAG;AACnC,WAAO,KAAK;AAAA,EACd;AACA,MAAI,KAAK,SAAS,eAAe,CAAC,KAAK,OAAO;AAC5C,WAAO;AAAA,EACT;AACA,MAAI,EAAE,cAAc,IAAI,GAAG;AACzB,WAAO;AAAA,EACT;AACA,MAAI,EAAE,mBAAmB,IAAI,GAAG;AAC9B,WAAO,aAAa,KAAK,UAAU;AAAA,EACrC;AACA,MAAI,EAAE,kBAAkB,IAAI,GAAG;AAC7B,WAAO,KAAK,SAAS,OAEnB,CAAC,KAAK,YAAY;AAAA,MAChB,GAAG;AAAA,MACH,GAAI,oCAAS,UAAS,kBAClB,aAAa,QAAQ,QAAQ,IAC7B,CAAC,aAAa,OAAO,CAAC;AAAA,IAC5B,GACA,CAAC,CACH;AAAA,EACF;AACF;AAEA,sBAAsB,OAAO;AAC3B,SAAO,MAAM,OAAO,CAAC,KAAK,SAAS;AACjC,QAAI,KAAK,SAAS,iBAAiB;AACjC,aAAO,kCACF,MACA,aAAa,KAAK,QAAQ;AAAA,IAEjC,WAAW,KAAK,SAAS,gBAAgB;AACvC,YAAM,MAAM,aAAa,KAAK,KAAK;AACnC,UAAI,QAAQ,QAAW;AACrB,eAAO,iCACF,MADE;AAAA,UAEL,CAAC,KAAK,IAAI,OAAO;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AACP;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
4
|
-
var __objRest = (source, exclude) => {
|
|
5
|
-
var target = {};
|
|
6
|
-
for (var prop in source)
|
|
7
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8
|
-
target[prop] = source[prop];
|
|
9
|
-
if (source != null && __getOwnPropSymbols)
|
|
10
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
11
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
12
|
-
target[prop] = source[prop];
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
import { join } from "path";
|
|
17
|
-
import { createTamagui } from "@tamagui/core-node";
|
|
18
|
-
let loadedTamagui = null;
|
|
19
|
-
function loadTamagui(props) {
|
|
20
|
-
if (loadedTamagui) {
|
|
21
|
-
return loadedTamagui;
|
|
22
|
-
}
|
|
23
|
-
const configPath = join(process.cwd(), props.config);
|
|
24
|
-
const { unregister } = require("esbuild-register/dist/node").register({
|
|
25
|
-
target: "es2019",
|
|
26
|
-
format: "cjs"
|
|
27
|
-
});
|
|
28
|
-
try {
|
|
29
|
-
process.env.IS_STATIC = "is_static";
|
|
30
|
-
if (typeof globalThis["__DEV__"] === "undefined") {
|
|
31
|
-
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
32
|
-
}
|
|
33
|
-
const proxyWorm = require("@tamagui/proxy-worm");
|
|
34
|
-
const rnw = require("react-native-web");
|
|
35
|
-
const Mod = require("module");
|
|
36
|
-
const og = Mod.prototype.require;
|
|
37
|
-
const nameToPaths = {};
|
|
38
|
-
Mod.prototype.require = function(path) {
|
|
39
|
-
var _a2;
|
|
40
|
-
if (path.endsWith(".css")) {
|
|
41
|
-
return {};
|
|
42
|
-
}
|
|
43
|
-
if (path === "@gorhom/bottom-sheet" || path.startsWith("react-native-reanimated") || path === "expo-linear-gradient") {
|
|
44
|
-
return proxyWorm;
|
|
45
|
-
}
|
|
46
|
-
if (path.startsWith("react-native") && !path.startsWith("react-native-web/dist/cjs/exports")) {
|
|
47
|
-
return rnw;
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
const out = og.apply(this, arguments);
|
|
51
|
-
if (!nameToPaths[path]) {
|
|
52
|
-
if (out && typeof out === "object") {
|
|
53
|
-
for (const key in out) {
|
|
54
|
-
try {
|
|
55
|
-
const conf = (_a2 = out[key]) == null ? void 0 : _a2.staticConfig;
|
|
56
|
-
if (conf) {
|
|
57
|
-
if (conf.componentName) {
|
|
58
|
-
nameToPaths[conf.componentName] ??= /* @__PURE__ */ new Set();
|
|
59
|
-
const fullName = path.startsWith(".") ? join(`${this.path.replace(/dist(\/cjs)?/, "src")}`, path) : path;
|
|
60
|
-
nameToPaths[conf.componentName].add(fullName);
|
|
61
|
-
} else {
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
} catch {
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return out;
|
|
70
|
-
} catch (err) {
|
|
71
|
-
console.error("Tamagui error loading file:\n", path, err.message, "\n", err.stack);
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const exp = require(configPath);
|
|
76
|
-
const tamaguiConfig = exp["default"] || exp;
|
|
77
|
-
if (!tamaguiConfig || !tamaguiConfig.parsed) {
|
|
78
|
-
try {
|
|
79
|
-
const confPath = require.resolve(configPath);
|
|
80
|
-
console.log(`Received:`, tamaguiConfig);
|
|
81
|
-
throw new Error(`Can't find valid config in ${confPath}`);
|
|
82
|
-
} catch (err) {
|
|
83
|
-
throw err;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const components = {};
|
|
87
|
-
for (const moduleName of props.components) {
|
|
88
|
-
const exported = require(moduleName);
|
|
89
|
-
for (const Name in exported) {
|
|
90
|
-
const val = exported[Name];
|
|
91
|
-
const staticConfig = val == null ? void 0 : val.staticConfig;
|
|
92
|
-
if (staticConfig) {
|
|
93
|
-
const _a = staticConfig, { Component, reactNativeWebComponent } = _a, sc = __objRest(_a, ["Component", "reactNativeWebComponent"]);
|
|
94
|
-
Object.assign(components, { [Name]: { staticConfig: sc } });
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
process.env.IS_STATIC = void 0;
|
|
99
|
-
Mod.prototype.require = og;
|
|
100
|
-
createTamagui(tamaguiConfig);
|
|
101
|
-
loadedTamagui = {
|
|
102
|
-
components,
|
|
103
|
-
tamaguiConfig,
|
|
104
|
-
nameToPaths
|
|
105
|
-
};
|
|
106
|
-
return loadedTamagui;
|
|
107
|
-
} catch (err) {
|
|
108
|
-
console.log("Error loading Tamagui", err);
|
|
109
|
-
throw err;
|
|
110
|
-
} finally {
|
|
111
|
-
unregister();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
export {
|
|
115
|
-
loadTamagui
|
|
116
|
-
};
|
|
117
|
-
//# sourceMappingURL=loadTamagui.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/extractor/loadTamagui.ts"],
|
|
4
|
-
"sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig, TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core'\nimport { createTamagui } from '@tamagui/core-node'\n\nlet loadedTamagui: any = null\n\ntype NameToPaths = {\n [key: string]: Set<string>\n}\n\nexport type TamaguiProjectInfo = {\n components: Record<string, TamaguiComponent>\n tamaguiConfig: TamaguiInternalConfig\n nameToPaths: NameToPaths\n}\n\nexport function loadTamagui(props: { components: string[]; config: string }): TamaguiProjectInfo {\n if (loadedTamagui) {\n return loadedTamagui\n }\n\n const configPath = join(process.cwd(), props.config)\n\n const { unregister } = require('esbuild-register/dist/node').register({\n target: 'es2019',\n format: 'cjs',\n })\n\n try {\n // lets shim require and avoid importing react-native + react-native-web\n // we just need to read the config around them\n process.env.IS_STATIC = 'is_static'\n // @ts-ignore\n if (typeof globalThis['__DEV__'] === 'undefined') {\n // @ts-ignore\n globalThis['__DEV__'] = process.env.NODE_ENV === 'development'\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n const Mod = require('module')\n const og = Mod.prototype.require\n const nameToPaths: NameToPaths = {}\n\n Mod.prototype.require = function (path: string) {\n if (path.endsWith('.css')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient'\n ) {\n return proxyWorm\n }\n if (\n path.startsWith('react-native') &&\n // allow our rnw.tsx imports through\n !path.startsWith('react-native-web/dist/cjs/exports')\n ) {\n return rnw\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n console.error('Tamagui error loading file:\\n', path, err.message, '\\n', err.stack)\n // avoid infinite loops\n process.exit(1)\n }\n }\n\n // import config\n const exp = require(configPath)\n const tamaguiConfig = (exp['default'] || exp) as TamaguiInternalConfig\n\n if (!tamaguiConfig || !tamaguiConfig.parsed) {\n try {\n const confPath = require.resolve(configPath)\n console.log(`Received:`, tamaguiConfig)\n throw new Error(`Can't find valid config in ${confPath}`)\n } catch (err) {\n throw err\n }\n }\n\n // import components\n const components = {}\n for (const moduleName of props.components) {\n const exported = require(moduleName)\n for (const Name in exported) {\n const val = exported[Name]\n const staticConfig = val?.staticConfig as StaticConfig | undefined\n if (staticConfig) {\n // remove non-stringifyable\n const { Component, reactNativeWebComponent, ...sc } = staticConfig\n Object.assign(components, { [Name]: { staticConfig: sc } })\n }\n }\n }\n\n // undo shims\n process.env.IS_STATIC = undefined\n Mod.prototype.require = og\n\n // set up core-node\n createTamagui(tamaguiConfig as any)\n\n loadedTamagui = {\n components,\n tamaguiConfig,\n nameToPaths,\n }\n\n return loadedTamagui\n } catch (err) {\n console.log('Error loading Tamagui', err)\n throw err\n } finally {\n unregister()\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAGA;AAEA,IAAI,gBAAqB;AAYlB,qBAAqB,OAAqE;AAC/F,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,KAAK,QAAQ,IAAI,GAAG,MAAM,MAAM;AAEnD,QAAM,EAAE,eAAe,QAAQ,4BAA4B,EAAE,SAAS;AAAA,IACpE,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV,CAAC;AAED,MAAI;AAGF,YAAQ,IAAI,YAAY;AAExB,QAAI,OAAO,WAAW,eAAe,aAAa;AAEhD,iBAAW,aAAa,QAAQ,IAAI,aAAa;AAAA,IACnD;AAEA,UAAM,YAAY,QAAQ,qBAAqB;AAC/C,UAAM,MAAM,QAAQ,kBAAkB;AACtC,UAAM,MAAM,QAAQ,QAAQ;AAC5B,UAAM,KAAK,IAAI,UAAU;AACzB,UAAM,cAA2B,CAAC;AAElC,QAAI,UAAU,UAAU,SAAU,MAAc;AA7CpD;AA8CM,UAAI,KAAK,SAAS,MAAM,GAAG;AACzB,eAAO,CAAC;AAAA,MACV;AACA,UACE,SAAS,0BACT,KAAK,WAAW,yBAAyB,KACzC,SAAS,wBACT;AACA,eAAO;AAAA,MACT;AACA,UACE,KAAK,WAAW,cAAc,KAE9B,CAAC,KAAK,WAAW,mCAAmC,GACpD;AACA,eAAO;AAAA,MACT;AACA,UAAI;AACF,cAAM,MAAM,GAAG,MAAM,MAAM,SAAS;AACpC,YAAI,CAAC,YAAY,OAAO;AACtB,cAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,uBAAW,OAAO,KAAK;AACrB,kBAAI;AACF,sBAAM,OAAO,WAAI,SAAJ,oBAAU;AACvB,oBAAI,MAAM;AACR,sBAAI,KAAK,eAAe;AACtB,gCAAY,KAAK,mBAAmB,oBAAI,IAAI;AAC5C,0BAAM,WAAW,KAAK,WAAW,GAAG,IAChC,KAAK,GAAG,KAAK,KAAK,QAAQ,gBAAgB,KAAK,KAAK,IAAI,IACxD;AACJ,gCAAY,KAAK,eAAe,IAAI,QAAQ;AAAA,kBAC9C,OAAO;AAAA,kBAEP;AAAA,gBACF;AAAA,cACF,QAAE;AAAA,cAEF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AACA,eAAO;AAAA,MACT,SAAS,KAAP;AACA,gBAAQ,MAAM,iCAAiC,MAAM,IAAI,SAAS,MAAM,IAAI,KAAK;AAEjF,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAGA,UAAM,MAAM,QAAQ,UAAU;AAC9B,UAAM,gBAAiB,IAAI,cAAc;AAEzC,QAAI,CAAC,iBAAiB,CAAC,cAAc,QAAQ;AAC3C,UAAI;AACF,cAAM,WAA2B,AAAhB,QAAQ,QAAQ;AACjC,gBAAQ,IAAI,aAAa,aAAa;AACtC,cAAM,IAAI,MAAM,8BAA8B,UAAU;AAAA,MAC1D,SAAS,KAAP;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAGA,UAAM,aAAa,CAAC;AACpB,eAAW,cAAc,MAAM,YAAY;AACzC,YAAM,WAAW,QAAQ,UAAU;AACnC,iBAAW,QAAQ,UAAU;AAC3B,cAAM,MAAM,SAAS;AACrB,cAAM,eAAe,2BAAK;AAC1B,YAAI,cAAc;AAEhB,gBAAsD,mBAA9C,aAAW,4BAAmC,IAAP,eAAO,IAAP,CAAvC,aAAW;AACnB,iBAAO,OAAO,YAAY,EAAE,CAAC,OAAO,EAAE,cAAc,GAAG,EAAE,CAAC;AAAA,QAC5D;AAAA,MACF;AAAA,IACF;AAGA,YAAQ,IAAI,YAAY;AACxB,QAAI,UAAU,UAAU;AAGxB,kBAAc,aAAoB;AAElC,oBAAgB;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,WAAO;AAAA,EACT,SAAS,KAAP;AACA,YAAQ,IAAI,yBAAyB,GAAG;AACxC,UAAM;AAAA,EACR,UAAE;AACA,eAAW;AAAA,EACb;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const prefix = " ";
|
|
2
|
-
const logLines = (str, singleLine = false) => {
|
|
3
|
-
if (singleLine) {
|
|
4
|
-
return prefix + str.split(" ").join(`
|
|
5
|
-
${prefix}`);
|
|
6
|
-
}
|
|
7
|
-
let lines = [""];
|
|
8
|
-
const items = str.split(" ");
|
|
9
|
-
for (const item of items) {
|
|
10
|
-
if (item.length + lines[lines.length - 1].length > 85) {
|
|
11
|
-
lines.push("");
|
|
12
|
-
}
|
|
13
|
-
lines[lines.length - 1] += item + " ";
|
|
14
|
-
}
|
|
15
|
-
return lines.map((line, i) => prefix + (i == 0 ? "" : " ") + line.trim()).join("\n");
|
|
16
|
-
};
|
|
17
|
-
export {
|
|
18
|
-
logLines
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=logLines.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/extractor/logLines.ts"],
|
|
4
|
-
"sourcesContent": ["const prefix = ' '\n\nexport const logLines = (str: string, singleLine = false) => {\n if (singleLine) {\n return prefix + str.split(' ').join(`\\n${prefix}`)\n }\n let lines: string[] = ['']\n const items = str.split(' ')\n for (const item of items) {\n if (item.length + lines[lines.length - 1].length > 85) {\n lines.push('')\n }\n lines[lines.length - 1] += item + ' '\n }\n return lines.map((line, i) => prefix + (i == 0 ? '' : ' ') + line.trim()).join('\\n')\n}\n"],
|
|
5
|
-
"mappings": "AAAA,MAAM,SAAS;AAER,MAAM,WAAW,CAAC,KAAa,aAAa,UAAU;AAC3D,MAAI,YAAY;AACd,WAAO,SAAS,IAAI,MAAM,GAAG,EAAE,KAAK;AAAA,EAAK,QAAQ;AAAA,EACnD;AACA,MAAI,QAAkB,CAAC,EAAE;AACzB,QAAM,QAAQ,IAAI,MAAM,GAAG;AAC3B,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK,SAAS,MAAM,MAAM,SAAS,GAAG,SAAS,IAAI;AACrD,YAAM,KAAK,EAAE;AAAA,IACf;AACA,UAAM,MAAM,SAAS,MAAM,OAAO;AAAA,EACpC;AACA,SAAO,MAAM,IAAI,CAAC,MAAM,MAAM,SAAU,MAAK,IAAI,KAAK,OAAO,KAAK,KAAK,CAAC,EAAE,KAAK,IAAI;AACrF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
import generate from "@babel/generator";
|
|
33
|
-
import * as t from "@babel/types";
|
|
34
|
-
import invariant from "invariant";
|
|
35
|
-
function normalizeTernaries(ternaries) {
|
|
36
|
-
invariant(Array.isArray(ternaries), "extractStaticTernaries expects param 1 to be an array of ternaries");
|
|
37
|
-
if (ternaries.length === 0) {
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
const ternariesByKey = {};
|
|
41
|
-
for (let idx = -1, len = ternaries.length; ++idx < len; ) {
|
|
42
|
-
const _a = ternaries[idx], { test, consequent, alternate, remove } = _a, rest = __objRest(_a, ["test", "consequent", "alternate", "remove"]);
|
|
43
|
-
let ternaryTest = test;
|
|
44
|
-
if (t.isExpressionStatement(test)) {
|
|
45
|
-
ternaryTest = test.expression;
|
|
46
|
-
}
|
|
47
|
-
let shouldSwap = false;
|
|
48
|
-
if (t.isUnaryExpression(test) && test.operator === "!") {
|
|
49
|
-
ternaryTest = test.argument;
|
|
50
|
-
shouldSwap = true;
|
|
51
|
-
} else if (t.isBinaryExpression(test)) {
|
|
52
|
-
if (test.operator === "!==" || test.operator === "!=") {
|
|
53
|
-
ternaryTest = t.binaryExpression(test.operator, test.left, test.right);
|
|
54
|
-
shouldSwap = true;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const key = generate(ternaryTest).code;
|
|
58
|
-
if (!ternariesByKey[key]) {
|
|
59
|
-
ternariesByKey[key] = __spreadProps(__spreadValues({}, rest), {
|
|
60
|
-
alternate: {},
|
|
61
|
-
consequent: {},
|
|
62
|
-
test: ternaryTest,
|
|
63
|
-
remove
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
const altStyle = (shouldSwap ? consequent : alternate) ?? {};
|
|
67
|
-
const consStyle = (shouldSwap ? alternate : consequent) ?? {};
|
|
68
|
-
Object.assign(ternariesByKey[key].alternate, altStyle);
|
|
69
|
-
Object.assign(ternariesByKey[key].consequent, consStyle);
|
|
70
|
-
}
|
|
71
|
-
const ternaryExpression = Object.keys(ternariesByKey).map((key) => {
|
|
72
|
-
return ternariesByKey[key];
|
|
73
|
-
});
|
|
74
|
-
return ternaryExpression;
|
|
75
|
-
}
|
|
76
|
-
export {
|
|
77
|
-
normalizeTernaries
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=normalizeTernaries.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/extractor/normalizeTernaries.ts"],
|
|
4
|
-
"sourcesContent": ["import generate from '@babel/generator'\nimport * as t from '@babel/types'\nimport invariant from 'invariant'\n\nimport { Ternary } from '../types'\n\nexport function normalizeTernaries(ternaries: Ternary[]) {\n invariant(\n Array.isArray(ternaries),\n 'extractStaticTernaries expects param 1 to be an array of ternaries'\n )\n\n if (ternaries.length === 0) {\n return []\n }\n\n const ternariesByKey: { [key: string]: Ternary } = {}\n\n for (let idx = -1, len = ternaries.length; ++idx < len; ) {\n const { test, consequent, alternate, remove, ...rest } = ternaries[idx]\n\n let ternaryTest = test\n\n // strip parens\n if (t.isExpressionStatement(test)) {\n ternaryTest = (test as any).expression\n }\n\n // convert `!thing` to `thing` with swapped consequent and alternate\n let shouldSwap = false\n if (t.isUnaryExpression(test) && test.operator === '!') {\n ternaryTest = test.argument\n shouldSwap = true\n } else if (t.isBinaryExpression(test)) {\n if (test.operator === '!==' || test.operator === '!=') {\n ternaryTest = t.binaryExpression(test.operator, test.left, test.right)\n shouldSwap = true\n }\n }\n\n const key = generate(ternaryTest).code\n\n if (!ternariesByKey[key]) {\n ternariesByKey[key] = {\n ...rest,\n alternate: {},\n consequent: {},\n test: ternaryTest,\n remove,\n }\n }\n const altStyle = (shouldSwap ? consequent : alternate) ?? {}\n const consStyle = (shouldSwap ? alternate : consequent) ?? {}\n Object.assign(ternariesByKey[key].alternate!, altStyle)\n Object.assign(ternariesByKey[key].consequent!, consStyle)\n }\n\n const ternaryExpression = Object.keys(ternariesByKey).map((key) => {\n return ternariesByKey[key]\n })\n\n return ternaryExpression\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAIO,4BAA4B,WAAsB;AACvD,YACE,MAAM,QAAQ,SAAS,GACvB,oEACF;AAEA,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,iBAA6C,CAAC;AAEpD,WAAS,MAAM,IAAI,MAAM,UAAU,QAAQ,EAAE,MAAM,OAAO;AACxD,UAAyD,eAAU,MAA3D,QAAM,YAAY,WAAW,WAAoB,IAAT,iBAAS,IAAT,CAAxC,QAAM,cAAY,aAAW;AAErC,QAAI,cAAc;AAGlB,QAAI,EAAE,sBAAsB,IAAI,GAAG;AACjC,oBAAe,KAAa;AAAA,IAC9B;AAGA,QAAI,aAAa;AACjB,QAAI,EAAE,kBAAkB,IAAI,KAAK,KAAK,aAAa,KAAK;AACtD,oBAAc,KAAK;AACnB,mBAAa;AAAA,IACf,WAAW,EAAE,mBAAmB,IAAI,GAAG;AACrC,UAAI,KAAK,aAAa,SAAS,KAAK,aAAa,MAAM;AACrD,sBAAc,EAAE,iBAAiB,KAAK,UAAU,KAAK,MAAM,KAAK,KAAK;AACrE,qBAAa;AAAA,MACf;AAAA,IACF;AAEA,UAAM,MAAM,SAAS,WAAW,EAAE;AAElC,QAAI,CAAC,eAAe,MAAM;AACxB,qBAAe,OAAO,iCACjB,OADiB;AAAA,QAEpB,WAAW,CAAC;AAAA,QACZ,YAAY,CAAC;AAAA,QACb,MAAM;AAAA,QACN;AAAA,MACF;AAAA,IACF;AACA,UAAM,WAAY,cAAa,aAAa,cAAc,CAAC;AAC3D,UAAM,YAAa,cAAa,YAAY,eAAe,CAAC;AAC5D,WAAO,OAAO,eAAe,KAAK,WAAY,QAAQ;AACtD,WAAO,OAAO,eAAe,KAAK,YAAa,SAAS;AAAA,EAC1D;AAEA,QAAM,oBAAoB,OAAO,KAAK,cAAc,EAAE,IAAI,CAAC,QAAQ;AACjE,WAAO,eAAe;AAAA,EACxB,CAAC;AAED,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|