@tamagui/static 1.0.1-beta.108 → 1.0.1-beta.109
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 +1 -0
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/extractor/accessSafe.js +1 -0
- package/dist/cjs/extractor/accessSafe.js.map +1 -1
- package/dist/cjs/extractor/babelParse.js +1 -0
- package/dist/cjs/extractor/babelParse.js.map +1 -1
- package/dist/cjs/extractor/buildClassName.js +1 -0
- package/dist/cjs/extractor/buildClassName.js.map +1 -1
- package/dist/cjs/extractor/createEvaluator.js +1 -0
- package/dist/cjs/extractor/createEvaluator.js.map +1 -1
- package/dist/cjs/extractor/createExtractor.js +77 -109
- package/dist/cjs/extractor/createExtractor.js.map +1 -1
- package/dist/cjs/extractor/defaultTamaguiConfig.js +5 -15
- package/dist/cjs/extractor/defaultTamaguiConfig.js.map +1 -1
- package/dist/cjs/extractor/ensureImportingConcat.js +1 -0
- package/dist/cjs/extractor/ensureImportingConcat.js.map +1 -1
- package/dist/cjs/extractor/evaluateAstNode.js +1 -0
- package/dist/cjs/extractor/evaluateAstNode.js.map +1 -1
- package/dist/cjs/extractor/extractHelpers.js +1 -0
- package/dist/cjs/extractor/extractHelpers.js.map +1 -1
- package/dist/cjs/extractor/extractMediaStyle.js +13 -25
- package/dist/cjs/extractor/extractMediaStyle.js.map +1 -1
- package/dist/cjs/extractor/extractToClassNames.js +9 -22
- package/dist/cjs/extractor/extractToClassNames.js.map +1 -1
- package/dist/cjs/extractor/findTopmostFunction.js +1 -0
- package/dist/cjs/extractor/findTopmostFunction.js.map +1 -1
- package/dist/cjs/extractor/generatedUid.js +1 -0
- package/dist/cjs/extractor/generatedUid.js.map +1 -1
- package/dist/cjs/extractor/getPrefixLogs.js +1 -0
- package/dist/cjs/extractor/getPrefixLogs.js.map +1 -1
- package/dist/cjs/extractor/getPropValueFromAttributes.js +1 -0
- package/dist/cjs/extractor/getPropValueFromAttributes.js.map +1 -1
- package/dist/cjs/extractor/getSourceModule.js +1 -0
- package/dist/cjs/extractor/getSourceModule.js.map +1 -1
- package/dist/cjs/extractor/getStaticBindingsForScope.js +1 -0
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +1 -1
- package/dist/cjs/extractor/hoistClassNames.js +1 -0
- package/dist/cjs/extractor/hoistClassNames.js.map +1 -1
- package/dist/cjs/extractor/literalToAst.js +8 -20
- package/dist/cjs/extractor/literalToAst.js.map +1 -1
- package/dist/cjs/extractor/loadTamagui.js +2 -15
- package/dist/cjs/extractor/loadTamagui.js.map +1 -1
- package/dist/cjs/extractor/logLines.js +1 -0
- package/dist/cjs/extractor/logLines.js.map +1 -1
- package/dist/cjs/extractor/normalizeTernaries.js +5 -32
- package/dist/cjs/extractor/normalizeTernaries.js.map +1 -1
- package/dist/cjs/extractor/removeUnusedHooks.js +1 -0
- package/dist/cjs/extractor/removeUnusedHooks.js.map +1 -1
- package/dist/cjs/extractor/timer.js +1 -0
- package/dist/cjs/extractor/timer.js.map +1 -1
- package/dist/cjs/extractor/validHTMLAttributes.js +1 -0
- package/dist/cjs/extractor/validHTMLAttributes.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/require.js +1 -0
- package/dist/cjs/require.js.map +1 -1
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/extractor/createExtractor.js +76 -111
- package/dist/esm/extractor/createExtractor.js.map +1 -1
- package/dist/esm/extractor/defaultTamaguiConfig.js +4 -17
- package/dist/esm/extractor/defaultTamaguiConfig.js.map +1 -1
- package/dist/esm/extractor/extractMediaStyle.js +12 -27
- package/dist/esm/extractor/extractMediaStyle.js.map +1 -1
- package/dist/esm/extractor/extractToClassNames.js +8 -24
- package/dist/esm/extractor/extractToClassNames.js.map +1 -1
- package/dist/esm/extractor/literalToAst.js +7 -22
- package/dist/esm/extractor/literalToAst.js.map +1 -1
- package/dist/esm/extractor/loadTamagui.js +1 -16
- package/dist/esm/extractor/loadTamagui.js.map +1 -1
- package/dist/esm/extractor/normalizeTernaries.js +4 -34
- package/dist/esm/extractor/normalizeTernaries.js.map +1 -1
- package/dist/jsx/extractor/createExtractor.js +13 -12
- package/dist/jsx/extractor/createExtractor.js.map +1 -1
- package/package.json +10 -10
- package/types/constants.d.ts +0 -7
- package/types/constants.d.ts.map +0 -1
- package/types/extractor/accessSafe.d.ts +0 -3
- package/types/extractor/accessSafe.d.ts.map +0 -1
- package/types/extractor/babelParse.d.ts +0 -5
- package/types/extractor/babelParse.d.ts.map +0 -1
- package/types/extractor/ensureImportingConcat.d.ts +0 -4
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
- package/types/extractor/evaluateAstNode.d.ts +0 -3
- package/types/extractor/evaluateAstNode.d.ts.map +0 -1
- package/types/extractor/findTopmostFunction.d.ts +0 -4
- package/types/extractor/findTopmostFunction.d.ts.map +0 -1
- package/types/extractor/generatedUid.d.ts +0 -5
- package/types/extractor/generatedUid.d.ts.map +0 -1
- package/types/extractor/getPropValueFromAttributes.d.ts +0 -3
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
- package/types/extractor/getSourceModule.d.ts +0 -16
- package/types/extractor/getSourceModule.d.ts.map +0 -1
- package/types/extractor/getStaticBindingsForScope.d.ts +0 -4
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
- package/types/extractor/hoistClassNames.d.ts +0 -6
- package/types/extractor/hoistClassNames.d.ts.map +0 -1
- package/types/extractor/literalToAst.d.ts +0 -4
- package/types/extractor/literalToAst.d.ts.map +0 -1
- package/types/extractor/logLines.d.ts +0 -2
- package/types/extractor/logLines.d.ts.map +0 -1
- package/types/extractor/removeUnusedHooks.d.ts +0 -3
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
- package/types/extractor/timer.d.ts +0 -5
- package/types/extractor/timer.d.ts.map +0 -1
- package/types/extractor/validHTMLAttributes.d.ts +0 -98
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
package/dist/cjs/constants.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/constants.ts"],
|
|
4
4
|
"sourcesContent": ["import findCacheDir from 'find-cache-dir'\n\nexport const CSS_FILE_NAME = '__snack.css'\n\n// ENSURE THIS ISNT THE SAME AS THE SEPARATOR USED FOR STYLE KEYS\n// SEE matching one in concatClassName\nexport const MEDIA_SEP = '_'\n\n// ensure cache dir\nexport const cacheDir = findCacheDir({ name: 'tamagui', create: true })\n\nexport const FAILED_EVAL = Symbol('failed_style_eval')\nexport const CONCAT_CLASSNAME_IMPORT = 'concatClassName'\n\nexport const SHOULD_DEBUG = process.env.DEBUG === '*' || process.env.DEBUG?.startsWith('tamagui')\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAyB;AAAzB;AAEO,MAAM,gBAAgB;AAItB,MAAM,YAAY;AAGlB,MAAM,WAAW,mCAAa,EAAE,MAAM,WAAW,QAAQ,KAAK,CAAC;AAE/D,MAAM,cAAc,OAAO,mBAAmB;AAC9C,MAAM,0BAA0B;AAEhC,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,eAAQ,IAAI,UAAZ,mBAAmB,WAAW;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/accessSafe.ts"],
|
|
4
4
|
"sourcesContent": ["import * as t from '@babel/types'\n\n// accessSafe wraps memberExpressions in object/null checks\n// TODO: inject this as a function? this gets pretty repetitive\nexport function accessSafe(obj: t.Expression, member: string): t.LogicalExpression {\n return t.logicalExpression(\n '&&',\n t.logicalExpression(\n '&&',\n // typeof obj === 'object\n t.binaryExpression('===', t.unaryExpression('typeof', obj), t.stringLiteral('object')),\n // obj !== null\n t.binaryExpression('!==', obj, t.nullLiteral())\n ),\n // obj.member\n t.memberExpression(obj, t.identifier(member), false)\n )\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAmB;AAIZ,oBAAoB,KAAmB,QAAqC;AACjF,SAAO,EAAE,kBACP,MACA,EAAE,kBACA,MAEA,EAAE,iBAAiB,OAAO,EAAE,gBAAgB,UAAU,GAAG,GAAG,EAAE,cAAc,QAAQ,CAAC,GAErF,EAAE,iBAAiB,OAAO,KAAK,EAAE,YAAY,CAAC,CAChD,GAEA,EAAE,iBAAiB,KAAK,EAAE,WAAW,MAAM,GAAG,KAAK,CACrD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/babelParse.ts"],
|
|
4
4
|
"sourcesContent": ["import * as babelParser from '@babel/parser'\n\nconst plugins: babelParser.ParserPlugin[] = [\n 'asyncGenerators',\n 'classProperties',\n 'dynamicImport',\n 'functionBind',\n 'jsx',\n 'numericSeparator',\n 'objectRestSpread',\n 'optionalCatchBinding',\n 'decorators-legacy',\n 'typescript',\n 'optionalChaining',\n 'nullishCoalescingOperator',\n]\n\nexport const parserOptions: babelParser.ParserOptions = Object.freeze({\n plugins,\n sourceType: 'module',\n})\n\nconst parser = babelParser.parse.bind(babelParser)\n\nexport function babelParse(code: string | Buffer): any {\n return parser(code.toString(), parserOptions)\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA6B;AAE7B,MAAM,UAAsC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,gBAA2C,OAAO,OAAO;AAAA,EACpE;AAAA,EACA,YAAY;AACd,CAAC;AAED,MAAM,SAAS,YAAY,MAAM,KAAK,WAAW;AAE1C,oBAAoB,MAA4B;AACrD,SAAO,OAAO,KAAK,SAAS,GAAG,aAAa;AAC9C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/buildClassName.ts"],
|
|
4
4
|
"sourcesContent": ["import * as t from '@babel/types'\n\nimport { ClassNameObject } from '../types'\n\nexport function buildClassName(\n classNameObjects: ClassNameObject[]\n): t.Expression | t.StringLiteral | null {\n return classNameObjects.reduce<t.Expression | null>((acc, val) => {\n if (acc == null) {\n if (\n // pass conditional expressions through\n t.isConditionalExpression(val) ||\n // pass non-null literals through\n t.isStringLiteral(val) ||\n t.isNumericLiteral(val)\n ) {\n return val\n }\n return t.logicalExpression('||', val, t.stringLiteral(''))\n }\n\n let inner: t.Expression\n if (t.isStringLiteral(val)) {\n if (t.isStringLiteral(acc)) {\n // join adjacent string literals\n return t.stringLiteral(`${acc.value} ${val.value}`)\n }\n inner = t.stringLiteral(` ${val.value}`)\n } else if (t.isLiteral(val)) {\n inner = t.binaryExpression('+', t.stringLiteral(' '), val)\n } else if (t.isConditionalExpression(val) || t.isBinaryExpression(val)) {\n if (t.isStringLiteral(acc)) {\n return t.binaryExpression('+', t.stringLiteral(`${acc.value} `), val)\n }\n inner = t.binaryExpression('+', t.stringLiteral(' '), val)\n } else if (t.isIdentifier(val) || t.isMemberExpression(val)) {\n // identifiers and member expressions make for reasonable ternaries\n inner = t.conditionalExpression(\n val,\n t.binaryExpression('+', t.stringLiteral(' '), val),\n t.stringLiteral('')\n )\n } else {\n if (t.isStringLiteral(acc)) {\n return t.binaryExpression(\n '+',\n t.stringLiteral(`${acc.value} `),\n t.logicalExpression('||', val, t.stringLiteral(''))\n )\n }\n // use a logical expression for more complex prop values\n inner = t.binaryExpression(\n '+',\n t.stringLiteral(' '),\n t.logicalExpression('||', val, t.stringLiteral(''))\n )\n }\n\n return t.binaryExpression('+', acc, inner)\n }, null)\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAAmB;AAIZ,wBACL,kBACuC;AACvC,SAAO,iBAAiB,OAA4B,CAAC,KAAK,QAAQ;AAChE,QAAI,OAAO,MAAM;AACf,UAEE,EAAE,wBAAwB,GAAG,KAE7B,EAAE,gBAAgB,GAAG,KACrB,EAAE,iBAAiB,GAAG,GACtB;AACA,eAAO;AAAA,MACT;AACA,aAAO,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc,EAAE,CAAC;AAAA,IAC3D;AAEA,QAAI;AACJ,QAAI,EAAE,gBAAgB,GAAG,GAAG;AAC1B,UAAI,EAAE,gBAAgB,GAAG,GAAG;AAE1B,eAAO,EAAE,cAAc,GAAG,IAAI,SAAS,IAAI,OAAO;AAAA,MACpD;AACA,cAAQ,EAAE,cAAc,IAAI,IAAI,OAAO;AAAA,IACzC,WAAW,EAAE,UAAU,GAAG,GAAG;AAC3B,cAAQ,EAAE,iBAAiB,KAAK,EAAE,cAAc,GAAG,GAAG,GAAG;AAAA,IAC3D,WAAW,EAAE,wBAAwB,GAAG,KAAK,EAAE,mBAAmB,GAAG,GAAG;AACtE,UAAI,EAAE,gBAAgB,GAAG,GAAG;AAC1B,eAAO,EAAE,iBAAiB,KAAK,EAAE,cAAc,GAAG,IAAI,QAAQ,GAAG,GAAG;AAAA,MACtE;AACA,cAAQ,EAAE,iBAAiB,KAAK,EAAE,cAAc,GAAG,GAAG,GAAG;AAAA,IAC3D,WAAW,EAAE,aAAa,GAAG,KAAK,EAAE,mBAAmB,GAAG,GAAG;AAE3D,cAAQ,EAAE,sBACR,KACA,EAAE,iBAAiB,KAAK,EAAE,cAAc,GAAG,GAAG,GAAG,GACjD,EAAE,cAAc,EAAE,CACpB;AAAA,IACF,OAAO;AACL,UAAI,EAAE,gBAAgB,GAAG,GAAG;AAC1B,eAAO,EAAE,iBACP,KACA,EAAE,cAAc,GAAG,IAAI,QAAQ,GAC/B,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc,EAAE,CAAC,CACpD;AAAA,MACF;AAEA,cAAQ,EAAE,iBACR,KACA,EAAE,cAAc,GAAG,GACnB,EAAE,kBAAkB,MAAM,KAAK,EAAE,cAAc,EAAE,CAAC,CACpD;AAAA,IACF;AAEA,WAAO,EAAE,iBAAiB,KAAK,KAAK,KAAK;AAAA,EAC3C,GAAG,IAAI;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/createEvaluator.ts"],
|
|
4
4
|
"sourcesContent": ["import vm from 'vm'\n\nimport generate from '@babel/generator'\nimport { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { TamaguiConfig } from '@tamagui/core-node'\nimport { createCSSVariable } from '@tamagui/core-node'\nimport esbuild from 'esbuild'\n\nimport { FAILED_EVAL } from '../constants'\nimport { evaluateAstNode } from './evaluateAstNode'\nimport { isValidThemeHook } from './extractHelpers'\n\nexport function createEvaluator({\n tamaguiConfig,\n staticNamespace,\n sourcePath,\n traversePath,\n shouldPrintDebug,\n}: {\n tamaguiConfig: TamaguiConfig\n staticNamespace: Record<string, any>\n sourcePath: string\n traversePath?: NodePath<t.JSXElement>\n shouldPrintDebug: boolean | 'verbose'\n}) {\n // called when evaluateAstNode encounters a dynamic-looking prop\n const evalFn = (n: t.Node) => {\n // themes\n if (\n t.isMemberExpression(n) &&\n t.isIdentifier(n.property) &&\n traversePath &&\n isValidThemeHook(traversePath, n, sourcePath)\n ) {\n const key = n.property.name\n if (shouldPrintDebug) {\n console.log(' > found theme prop', key)\n }\n console.log('SHOULD FIND THEME (NESTED NOW)', key) // tamaguiConfig.themes)\n // if (!themeKeys.has(key)) {\n // throw new Error(` > accessing non-existent theme key: ${key}`)\n // }\n return createCSSVariable(key)\n }\n // variable\n if (t.isIdentifier(n) && staticNamespace.hasOwnProperty(n.name)) {\n return staticNamespace[n.name]\n }\n const evalContext = vm.createContext(staticNamespace)\n const codeWithTypescriptAnnotations = `(${generate(n as any).code})`\n const code = esbuild\n .transformSync(codeWithTypescriptAnnotations, { loader: 'tsx' })\n .code.replace(/;\\n$/, '')\n\n if (shouldPrintDebug) {\n console.log('evaluating', code)\n }\n return vm.runInContext(code, evalContext)\n }\n\n return (n: t.Node) => {\n return evaluateAstNode(n, evalFn)\n }\n}\n\nexport function createSafeEvaluator(attemptEval: (n: t.Node) => any) {\n return (n: t.Node) => {\n try {\n return attemptEval(n)\n } catch (err) {\n return FAILED_EVAL\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AAEf,uBAAqB;AAErB,QAAmB;AAEnB,uBAAkC;AAClC,qBAAoB;AAEpB,uBAA4B;AAC5B,6BAAgC;AAChC,4BAAiC;AAE1B,yBAAyB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GAOC;AAED,QAAM,SAAS,CAAC,MAAc;AAE5B,QACE,EAAE,mBAAmB,CAAC,KACtB,EAAE,aAAa,EAAE,QAAQ,KACzB,gBACA,4CAAiB,cAAc,GAAG,UAAU,GAC5C;AACA,YAAM,MAAM,EAAE,SAAS;AACvB,UAAI,kBAAkB;AACpB,gBAAQ,IAAI,0BAA0B,GAAG;AAAA,MAC3C;AACA,cAAQ,IAAI,kCAAkC,GAAG;AAIjD,aAAO,wCAAkB,GAAG;AAAA,IAC9B;AAEA,QAAI,EAAE,aAAa,CAAC,KAAK,gBAAgB,eAAe,EAAE,IAAI,GAAG;AAC/D,aAAO,gBAAgB,EAAE;AAAA,IAC3B;AACA,UAAM,cAAc,kBAAG,cAAc,eAAe;AACpD,UAAM,gCAAgC,IAAI,8BAAS,CAAQ,EAAE;AAC7D,UAAM,OAAO,uBACV,cAAc,+BAA+B,EAAE,QAAQ,MAAM,CAAC,EAC9D,KAAK,QAAQ,QAAQ,EAAE;AAE1B,QAAI,kBAAkB;AACpB,cAAQ,IAAI,cAAc,IAAI;AAAA,IAChC;AACA,WAAO,kBAAG,aAAa,MAAM,WAAW;AAAA,EAC1C;AAEA,SAAO,CAAC,MAAc;AACpB,WAAO,4CAAgB,GAAG,MAAM;AAAA,EAClC;AACF;AAEO,6BAA6B,aAAiC;AACnE,SAAO,CAAC,MAAc;AACpB,QAAI;AACF,aAAO,YAAY,CAAC;AAAA,IACtB,SAAS,KAAP;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,38 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __objRest = (source, exclude) => {
|
|
25
|
-
var target = {};
|
|
26
|
-
for (var prop in source)
|
|
27
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
if (source != null && __getOwnPropSymbols)
|
|
30
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
-
target[prop] = source[prop];
|
|
33
|
-
}
|
|
34
|
-
return target;
|
|
35
|
-
};
|
|
36
8
|
var __export = (target, all) => {
|
|
37
9
|
for (var name in all)
|
|
38
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -105,44 +77,26 @@ function createExtractor() {
|
|
|
105
77
|
getTamagui() {
|
|
106
78
|
return loadedTamaguiConfig;
|
|
107
79
|
},
|
|
108
|
-
parse: (fileOrPath,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
"config",
|
|
129
|
-
"importsWhitelist",
|
|
130
|
-
"evaluateVars",
|
|
131
|
-
"shouldPrintDebug",
|
|
132
|
-
"sourcePath",
|
|
133
|
-
"onExtractTag",
|
|
134
|
-
"onStyleRule",
|
|
135
|
-
"getFlattenedNode",
|
|
136
|
-
"disable",
|
|
137
|
-
"disableExtraction",
|
|
138
|
-
"disableExtractInlineMedia",
|
|
139
|
-
"disableExtractVariables",
|
|
140
|
-
"disableDebugAttr",
|
|
141
|
-
"extractStyledDefinitions",
|
|
142
|
-
"prefixLogs",
|
|
143
|
-
"excludeProps",
|
|
144
|
-
"target"
|
|
145
|
-
]);
|
|
80
|
+
parse: (fileOrPath, {
|
|
81
|
+
config = "tamagui.config.ts",
|
|
82
|
+
importsWhitelist = ["constants.js"],
|
|
83
|
+
evaluateVars = true,
|
|
84
|
+
shouldPrintDebug = false,
|
|
85
|
+
sourcePath = "",
|
|
86
|
+
onExtractTag,
|
|
87
|
+
onStyleRule,
|
|
88
|
+
getFlattenedNode,
|
|
89
|
+
disable,
|
|
90
|
+
disableExtraction,
|
|
91
|
+
disableExtractInlineMedia,
|
|
92
|
+
disableExtractVariables,
|
|
93
|
+
disableDebugAttr,
|
|
94
|
+
extractStyledDefinitions = false,
|
|
95
|
+
prefixLogs,
|
|
96
|
+
excludeProps,
|
|
97
|
+
target,
|
|
98
|
+
...props
|
|
99
|
+
}) => {
|
|
146
100
|
if (disable) {
|
|
147
101
|
return null;
|
|
148
102
|
}
|
|
@@ -179,8 +133,8 @@ function createExtractor() {
|
|
|
179
133
|
return (0, import_extractHelpers.isInsideTamagui)(sourcePath) && importStr[0] === ".";
|
|
180
134
|
};
|
|
181
135
|
const validComponents = Object.keys(components).filter((key) => {
|
|
182
|
-
var
|
|
183
|
-
return key[0].toUpperCase() === key[0] && !!((
|
|
136
|
+
var _a;
|
|
137
|
+
return key[0].toUpperCase() === key[0] && !!((_a = components[key]) == null ? void 0 : _a.staticConfig);
|
|
184
138
|
}).reduce((obj, name) => {
|
|
185
139
|
obj[name] = components[name];
|
|
186
140
|
return obj;
|
|
@@ -248,7 +202,7 @@ function createExtractor() {
|
|
|
248
202
|
}
|
|
249
203
|
},
|
|
250
204
|
CallExpression(path) {
|
|
251
|
-
var
|
|
205
|
+
var _a;
|
|
252
206
|
if (disable || disableExtraction || extractStyledDefinitions === false) {
|
|
253
207
|
return;
|
|
254
208
|
}
|
|
@@ -287,7 +241,7 @@ function createExtractor() {
|
|
|
287
241
|
});
|
|
288
242
|
const attemptEvalSafe = (0, import_createEvaluator.createSafeEvaluator)(attemptEval);
|
|
289
243
|
for (const property of definition.properties) {
|
|
290
|
-
if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || ((
|
|
244
|
+
if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || ((_a = Component.staticConfig.variants) == null ? void 0 : _a[property.key.name]) || componentSkipProps.has(property.key.name)) {
|
|
291
245
|
skipped.push(property);
|
|
292
246
|
continue;
|
|
293
247
|
}
|
|
@@ -306,7 +260,9 @@ function createExtractor() {
|
|
|
306
260
|
pressIn: false,
|
|
307
261
|
resolveVariablesAs: "variable"
|
|
308
262
|
});
|
|
309
|
-
const classNames =
|
|
263
|
+
const classNames = {
|
|
264
|
+
...out.classNames
|
|
265
|
+
};
|
|
310
266
|
const atomics = (0, import_core_node.getStylesAtomic)(out.style);
|
|
311
267
|
if (shouldPrintDebug) {
|
|
312
268
|
console.log("Exctacting styled()", styles, out, "to", atomics);
|
|
@@ -335,7 +291,7 @@ function createExtractor() {
|
|
|
335
291
|
}
|
|
336
292
|
},
|
|
337
293
|
JSXElement(traversePath) {
|
|
338
|
-
var
|
|
294
|
+
var _a, _b, _c;
|
|
339
295
|
tm.mark("jsx-element", shouldPrintDebug === "verbose");
|
|
340
296
|
const node = traversePath.node.openingElement;
|
|
341
297
|
const ogAttributes = node.attributes;
|
|
@@ -377,7 +333,7 @@ function createExtractor() {
|
|
|
377
333
|
shouldPrintDebug = debugPropValue;
|
|
378
334
|
}
|
|
379
335
|
try {
|
|
380
|
-
let
|
|
336
|
+
let evaluateAttribute2 = function(path) {
|
|
381
337
|
const attribute = path.node;
|
|
382
338
|
const attr = { type: "attr", value: attribute };
|
|
383
339
|
if (t.isJSXSpreadAttribute(attribute)) {
|
|
@@ -387,15 +343,15 @@ function createExtractor() {
|
|
|
387
343
|
const [test, alt, cons] = conditional;
|
|
388
344
|
if (!test)
|
|
389
345
|
throw new Error(`no test`);
|
|
390
|
-
if ([alt, cons].some((side) => side && !
|
|
346
|
+
if ([alt, cons].some((side) => side && !isExtractable2(side))) {
|
|
391
347
|
if (shouldPrintDebug) {
|
|
392
348
|
console.log("not extractable", alt, cons);
|
|
393
349
|
}
|
|
394
350
|
return attr;
|
|
395
351
|
}
|
|
396
352
|
return [
|
|
397
|
-
...
|
|
398
|
-
...cons &&
|
|
353
|
+
...createTernariesFromObjectProperties2(test, alt) || [],
|
|
354
|
+
...cons && createTernariesFromObjectProperties2(t.unaryExpression("!", test), cons) || []
|
|
399
355
|
].map((ternary) => ({
|
|
400
356
|
type: "ternary",
|
|
401
357
|
value: ternary
|
|
@@ -449,7 +405,7 @@ function createExtractor() {
|
|
|
449
405
|
if (import_core_node.mediaQueryConfig[shortname]) {
|
|
450
406
|
const expression = attribute.value.expression;
|
|
451
407
|
if (!t.isJSXEmptyExpression(expression)) {
|
|
452
|
-
const ternaries2 =
|
|
408
|
+
const ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(shortname), expression, {
|
|
453
409
|
inlineMediaQuery: shortname
|
|
454
410
|
});
|
|
455
411
|
if (ternaries2) {
|
|
@@ -688,7 +644,7 @@ function createExtractor() {
|
|
|
688
644
|
}
|
|
689
645
|
return null;
|
|
690
646
|
}
|
|
691
|
-
},
|
|
647
|
+
}, isExtractable2 = function(obj) {
|
|
692
648
|
return t.isObjectExpression(obj) && obj.properties.every((prop) => {
|
|
693
649
|
if (!t.isObjectProperty(prop)) {
|
|
694
650
|
console.log("not object prop", prop);
|
|
@@ -703,11 +659,11 @@ function createExtractor() {
|
|
|
703
659
|
}
|
|
704
660
|
return true;
|
|
705
661
|
});
|
|
706
|
-
},
|
|
662
|
+
}, createTernariesFromObjectProperties2 = function(test, side, ternaryPartial = {}) {
|
|
707
663
|
if (!side) {
|
|
708
664
|
return null;
|
|
709
665
|
}
|
|
710
|
-
if (!
|
|
666
|
+
if (!isExtractable2(side)) {
|
|
711
667
|
throw new Error("not extractable");
|
|
712
668
|
}
|
|
713
669
|
return side.properties.flatMap((property) => {
|
|
@@ -720,11 +676,13 @@ function createExtractor() {
|
|
|
720
676
|
const isMediaQuery = key[0] === "$" && import_core_node.mediaQueryConfig[mediaQueryKey];
|
|
721
677
|
if (isMediaQuery) {
|
|
722
678
|
if (t.isExpression(property.value)) {
|
|
723
|
-
const ternaries2 =
|
|
679
|
+
const ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(mediaQueryKey), property.value, {
|
|
724
680
|
inlineMediaQuery: mediaQueryKey
|
|
725
681
|
});
|
|
726
682
|
if (ternaries2) {
|
|
727
|
-
return ternaries2.map((value) =>
|
|
683
|
+
return ternaries2.map((value) => ({
|
|
684
|
+
...ternaryPartial,
|
|
685
|
+
...value,
|
|
728
686
|
test: t.logicalExpression("&&", value.test, test)
|
|
729
687
|
}));
|
|
730
688
|
} else {
|
|
@@ -741,35 +699,36 @@ function createExtractor() {
|
|
|
741
699
|
t.objectExpression([t.objectProperty(property.key, property.value.alternate)])
|
|
742
700
|
].map((x) => attemptEval(x));
|
|
743
701
|
return [
|
|
744
|
-
createTernary(
|
|
702
|
+
createTernary({
|
|
745
703
|
remove() {
|
|
746
|
-
}
|
|
747
|
-
|
|
704
|
+
},
|
|
705
|
+
...ternaryPartial,
|
|
748
706
|
test: t.logicalExpression("&&", test, property.value.test),
|
|
749
707
|
consequent: truthy,
|
|
750
708
|
alternate: null
|
|
751
|
-
})
|
|
752
|
-
createTernary(
|
|
709
|
+
}),
|
|
710
|
+
createTernary({
|
|
711
|
+
...ternaryPartial,
|
|
753
712
|
test: t.logicalExpression("&&", test, t.unaryExpression("!", property.value.test)),
|
|
754
713
|
consequent: falsy,
|
|
755
714
|
alternate: null,
|
|
756
715
|
remove() {
|
|
757
716
|
}
|
|
758
|
-
})
|
|
717
|
+
})
|
|
759
718
|
];
|
|
760
719
|
}
|
|
761
720
|
const obj = t.objectExpression([t.objectProperty(property.key, property.value)]);
|
|
762
721
|
const consequent = attemptEval(obj);
|
|
763
|
-
return createTernary(
|
|
722
|
+
return createTernary({
|
|
764
723
|
remove() {
|
|
765
|
-
}
|
|
766
|
-
|
|
724
|
+
},
|
|
725
|
+
...ternaryPartial,
|
|
767
726
|
test,
|
|
768
727
|
consequent,
|
|
769
728
|
alternate: null
|
|
770
|
-
})
|
|
729
|
+
});
|
|
771
730
|
});
|
|
772
|
-
},
|
|
731
|
+
}, mergeStyles2 = function(prev2, nextIn) {
|
|
773
732
|
const next = (0, import_core_node.expandStyles)(nextIn);
|
|
774
733
|
for (const key in next) {
|
|
775
734
|
if (import_core_node.pseudoDescriptors[key]) {
|
|
@@ -785,6 +744,7 @@ function createExtractor() {
|
|
|
785
744
|
}
|
|
786
745
|
}
|
|
787
746
|
};
|
|
747
|
+
var evaluateAttribute = evaluateAttribute2, isExtractable = isExtractable2, createTernariesFromObjectProperties = createTernariesFromObjectProperties2, mergeStyles = mergeStyles2;
|
|
788
748
|
node.attributes.find((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
|
|
789
749
|
if (shouldPrintDebug) {
|
|
790
750
|
console.log("\n");
|
|
@@ -897,7 +857,7 @@ function createExtractor() {
|
|
|
897
857
|
const inlineWhenUnflattenedOGVals = {};
|
|
898
858
|
attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
|
|
899
859
|
try {
|
|
900
|
-
const res2 =
|
|
860
|
+
const res2 = evaluateAttribute2(path);
|
|
901
861
|
tm.mark("jsx-element-evaluate-attr", shouldPrintDebug === "verbose");
|
|
902
862
|
if (!res2) {
|
|
903
863
|
path.remove();
|
|
@@ -937,14 +897,14 @@ function createExtractor() {
|
|
|
937
897
|
ternaries.push(cur.value);
|
|
938
898
|
}
|
|
939
899
|
if ((!next || next.type !== "ternary") && ternaries.length) {
|
|
940
|
-
const normalized = (0, import_normalizeTernaries.normalizeTernaries)(ternaries).map((
|
|
941
|
-
var _b3 = _a3, { alternate, consequent } = _b3, rest = __objRest(_b3, ["alternate", "consequent"]);
|
|
900
|
+
const normalized = (0, import_normalizeTernaries.normalizeTernaries)(ternaries).map(({ alternate, consequent, ...rest }) => {
|
|
942
901
|
return {
|
|
943
902
|
type: "ternary",
|
|
944
|
-
value:
|
|
903
|
+
value: {
|
|
904
|
+
...rest,
|
|
945
905
|
alternate: alternate || null,
|
|
946
906
|
consequent: consequent || null
|
|
947
|
-
}
|
|
907
|
+
}
|
|
948
908
|
};
|
|
949
909
|
});
|
|
950
910
|
try {
|
|
@@ -967,7 +927,7 @@ function createExtractor() {
|
|
|
967
927
|
const themeVal = inlined.get("theme");
|
|
968
928
|
inlined.delete("theme");
|
|
969
929
|
for (const [key] of [...inlined]) {
|
|
970
|
-
if (INLINE_EXTRACTABLE[key] || ((
|
|
930
|
+
if (INLINE_EXTRACTABLE[key] || ((_a = staticConfig.variants) == null ? void 0 : _a[key])) {
|
|
971
931
|
inlined.delete(key);
|
|
972
932
|
}
|
|
973
933
|
}
|
|
@@ -1030,7 +990,7 @@ function createExtractor() {
|
|
|
1030
990
|
for (const cur of attrs) {
|
|
1031
991
|
if (cur.type === "style") {
|
|
1032
992
|
for (const key in cur.value) {
|
|
1033
|
-
const shouldEnsureOverridden = !!((
|
|
993
|
+
const shouldEnsureOverridden = !!((_b = staticConfig.ensureOverriddenProp) == null ? void 0 : _b[key]);
|
|
1034
994
|
const isSetInAttrsAlready = attrs.some((x) => x.type === "attr" && x.value.type === "JSXAttribute" && x.value.name.name === key);
|
|
1035
995
|
if (!isSetInAttrsAlready) {
|
|
1036
996
|
const isVariant = !!((_c = staticConfig.variants) == null ? void 0 : _c[cur.name || ""]);
|
|
@@ -1058,7 +1018,10 @@ function createExtractor() {
|
|
|
1058
1018
|
for (const key in attrs) {
|
|
1059
1019
|
const cur = attrs[key];
|
|
1060
1020
|
if (cur.type === "style") {
|
|
1061
|
-
foundStaticProps =
|
|
1021
|
+
foundStaticProps = {
|
|
1022
|
+
...foundStaticProps,
|
|
1023
|
+
...(0, import_core_node.expandStyles)(cur.value)
|
|
1024
|
+
};
|
|
1062
1025
|
continue;
|
|
1063
1026
|
}
|
|
1064
1027
|
if (cur.type === "attr") {
|
|
@@ -1071,9 +1034,10 @@ function createExtractor() {
|
|
|
1071
1034
|
const key2 = cur.value.name.name;
|
|
1072
1035
|
const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
|
|
1073
1036
|
if (value !== import_constants.FAILED_EVAL) {
|
|
1074
|
-
foundStaticProps =
|
|
1037
|
+
foundStaticProps = {
|
|
1038
|
+
...foundStaticProps,
|
|
1075
1039
|
[key2]: value
|
|
1076
|
-
}
|
|
1040
|
+
};
|
|
1077
1041
|
}
|
|
1078
1042
|
}
|
|
1079
1043
|
}
|
|
@@ -1097,7 +1061,7 @@ function createExtractor() {
|
|
|
1097
1061
|
return acc;
|
|
1098
1062
|
}
|
|
1099
1063
|
if (variants[name] && variantValues.has(name)) {
|
|
1100
|
-
let out = Object.fromEntries(staticConfig.propMapper(name, variantValues.get(name), defaultTheme, completeProps,
|
|
1064
|
+
let out = Object.fromEntries(staticConfig.propMapper(name, variantValues.get(name), defaultTheme, completeProps, { ...state, resolveVariablesAs: "auto" }, void 0, shouldPrintDebug) || []);
|
|
1101
1065
|
if (out && isTargetingHTML) {
|
|
1102
1066
|
const cn = out.className;
|
|
1103
1067
|
out = (0, import_core_node.createDOMProps)(isTextView ? "span" : "div", out);
|
|
@@ -1181,7 +1145,7 @@ function createExtractor() {
|
|
|
1181
1145
|
});
|
|
1182
1146
|
}
|
|
1183
1147
|
if ((prev == null ? void 0 : prev.type) === "style") {
|
|
1184
|
-
|
|
1148
|
+
mergeStyles2(prev.value, cur.value);
|
|
1185
1149
|
return acc;
|
|
1186
1150
|
}
|
|
1187
1151
|
}
|
|
@@ -1211,10 +1175,14 @@ function createExtractor() {
|
|
|
1211
1175
|
}
|
|
1212
1176
|
}
|
|
1213
1177
|
try {
|
|
1214
|
-
const out = (0, import_core_node.getSplitStyles)(props2, staticConfig, defaultTheme,
|
|
1178
|
+
const out = (0, import_core_node.getSplitStyles)(props2, staticConfig, defaultTheme, {
|
|
1179
|
+
...state,
|
|
1215
1180
|
fallbackProps: completeProps
|
|
1216
|
-
}
|
|
1217
|
-
const outStyle =
|
|
1181
|
+
}, void 0, props2["debug"]);
|
|
1182
|
+
const outStyle = {
|
|
1183
|
+
...out.style,
|
|
1184
|
+
...out.pseudos
|
|
1185
|
+
};
|
|
1218
1186
|
return outStyle;
|
|
1219
1187
|
} catch (err) {
|
|
1220
1188
|
console.log("error", err.message, err.stack);
|