@tamagui/static 1.0.1-beta.150 → 1.0.1-beta.153
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} +4 -1
- package/dist/{esm/constants.js.map → constants.js.map} +3 -3
- package/dist/{cjs/extractor → extractor}/accessSafe.js +13 -2
- package/dist/{esm/extractor → extractor}/accessSafe.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/babelParse.js +4 -1
- package/dist/{cjs/extractor → extractor}/babelParse.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/buildClassName.js +19 -4
- package/dist/extractor/buildClassName.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/createEvaluator.js +7 -4
- package/dist/extractor/createEvaluator.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/createExtractor.js +186 -64
- package/dist/{esm/extractor → extractor}/createExtractor.js.map +4 -4
- package/dist/{cjs/extractor → extractor}/ensureImportingConcat.js +21 -6
- package/dist/extractor/ensureImportingConcat.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/evaluateAstNode.js +13 -4
- package/dist/{esm/extractor → extractor}/evaluateAstNode.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/extractHelpers.js +8 -3
- package/dist/extractor/extractHelpers.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/extractMediaStyle.js +22 -6
- package/dist/extractor/extractMediaStyle.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/extractToClassNames.js +87 -32
- package/dist/extractor/extractToClassNames.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/findTopmostFunction.js +0 -0
- package/dist/{cjs/extractor → extractor}/findTopmostFunction.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/generatedUid.js +8 -2
- package/dist/{cjs/extractor → extractor}/generatedUid.js.map +3 -3
- package/dist/{cjs/extractor → extractor}/getPrefixLogs.js +0 -0
- package/dist/extractor/getPrefixLogs.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/getPropValueFromAttributes.js +23 -13
- package/dist/extractor/getPropValueFromAttributes.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/getSourceModule.js +4 -1
- package/dist/{esm/extractor → extractor}/getSourceModule.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/getStaticBindingsForScope.js +9 -4
- package/dist/extractor/getStaticBindingsForScope.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/hoistClassNames.js +4 -1
- package/dist/{jsx/extractor → extractor}/hoistClassNames.js.map +3 -3
- package/dist/{cjs/extractor → extractor}/literalToAst.js +18 -10
- package/dist/{jsx/extractor → extractor}/literalToAst.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/loadFile.js +0 -0
- package/dist/{cjs/extractor → extractor}/loadFile.js.map +1 -1
- package/dist/{cjs/extractor → extractor}/loadTamagui.js +34 -7
- package/dist/extractor/loadTamagui.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/logLines.js +0 -0
- package/dist/{cjs/extractor → extractor}/logLines.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/normalizeTernaries.js +8 -2
- package/dist/extractor/normalizeTernaries.js.map +7 -0
- package/dist/{cjs/extractor → extractor}/removeUnusedHooks.js +4 -1
- package/dist/{esm/extractor → extractor}/removeUnusedHooks.js.map +2 -2
- package/dist/{cjs/extractor → extractor}/timer.js +0 -0
- package/dist/{cjs/extractor → extractor}/timer.js.map +1 -1
- package/dist/{cjs/extractor → extractor}/validHTMLAttributes.js +0 -0
- package/dist/{cjs/extractor → extractor}/validHTMLAttributes.js.map +1 -1
- package/dist/{cjs/getPragmaOptions.js → getPragmaOptions.js} +0 -0
- package/dist/{cjs/getPragmaOptions.js.map → getPragmaOptions.js.map} +2 -2
- package/dist/{cjs/index.js → index.js} +9 -9
- package/dist/index.js.map +7 -0
- package/dist/{cjs/require.js → require.js} +10 -4
- package/dist/require.js.map +7 -0
- package/dist/{cjs/types.js → types.js} +0 -0
- package/dist/types.js.map +7 -0
- package/dist/{cjs/webpackPlugin.js → webpackPlugin.js} +0 -0
- package/dist/{cjs/webpackPlugin.js.map → webpackPlugin.js.map} +1 -1
- package/package.json +15 -15
- package/src/extractor/buildClassName.ts +1 -1
- package/src/extractor/createEvaluator.ts +3 -3
- package/src/extractor/createExtractor.ts +21 -15
- package/src/extractor/ensureImportingConcat.ts +1 -1
- package/src/extractor/extractHelpers.ts +4 -3
- package/src/extractor/extractMediaStyle.ts +3 -3
- package/src/extractor/extractToClassNames.ts +12 -12
- package/src/extractor/getPrefixLogs.ts +1 -1
- package/src/extractor/getPropValueFromAttributes.ts +2 -2
- package/src/extractor/getStaticBindingsForScope.ts +2 -2
- package/src/extractor/loadTamagui.ts +27 -5
- package/src/extractor/normalizeTernaries.ts +1 -1
- package/src/index.ts +9 -10
- package/src/require.ts +1 -1
- package/src/types.ts +4 -3
- package/tamagui.tsconfig.json +5 -0
- package/types/extractor/buildClassName.d.ts +1 -1
- package/types/extractor/createExtractor.d.ts +4 -4
- package/types/extractor/extractHelpers.d.ts +1 -1
- package/types/extractor/extractMediaStyle.d.ts +1 -1
- package/types/extractor/extractToClassNames.d.ts +2 -2
- package/types/extractor/getPrefixLogs.d.ts +1 -1
- package/types/extractor/normalizeTernaries.d.ts +1 -1
- package/types/index.d.ts +9 -9
- package/types/types.d.ts +4 -3
- package/dist/cjs/constants.js.map +0 -7
- package/dist/cjs/extractor/accessSafe.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.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.map +0 -7
- package/dist/cjs/extractor/normalizeTernaries.js.map +0 -7
- package/dist/cjs/extractor/removeUnusedHooks.js.map +0 -7
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/require.js.map +0 -7
- package/dist/cjs/types.js.map +0 -7
- package/dist/esm/constants.js +0 -17
- 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 -52
- package/dist/esm/extractor/createEvaluator.js.map +0 -7
- package/dist/esm/extractor/createExtractor.js +0 -1374
- 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/extractHelpers.js +0 -97
- package/dist/esm/extractor/extractHelpers.js.map +0 -7
- package/dist/esm/extractor/extractMediaStyle.js +0 -146
- package/dist/esm/extractor/extractMediaStyle.js.map +0 -7
- package/dist/esm/extractor/extractToClassNames.js +0 -308
- 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 -172
- 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 -75
- package/dist/esm/extractor/literalToAst.js.map +0 -7
- package/dist/esm/extractor/loadFile.js +0 -20
- package/dist/esm/extractor/loadFile.js.map +0 -7
- package/dist/esm/extractor/loadTamagui.js +0 -255
- 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 -49
- package/dist/esm/extractor/normalizeTernaries.js.map +0 -7
- package/dist/esm/extractor/removeUnusedHooks.js +0 -76
- package/dist/esm/extractor/timer.js +0 -29
- 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/getPragmaOptions.js +0 -44
- package/dist/esm/getPragmaOptions.js.map +0 -7
- package/dist/esm/index.js +0 -17
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/require.js +0 -62
- package/dist/esm/require.js.map +0 -7
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -7
- package/dist/esm/webpackPlugin.js +0 -11
- package/dist/esm/webpackPlugin.js.map +0 -7
- package/dist/jsx/constants.js +0 -16
- 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 -52
- package/dist/jsx/extractor/createEvaluator.js.map +0 -7
- package/dist/jsx/extractor/createExtractor.js +0 -1367
- 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 -95
- package/dist/jsx/extractor/extractHelpers.js.map +0 -7
- package/dist/jsx/extractor/extractMediaStyle.js +0 -145
- package/dist/jsx/extractor/extractMediaStyle.js.map +0 -7
- package/dist/jsx/extractor/extractToClassNames.js +0 -307
- 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 -8
- 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 -172
- 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/loadFile.js +0 -19
- package/dist/jsx/extractor/loadFile.js.map +0 -7
- package/dist/jsx/extractor/loadTamagui.js +0 -253
- 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 -49
- package/dist/jsx/extractor/normalizeTernaries.js.map +0 -7
- package/dist/jsx/extractor/removeUnusedHooks.js +0 -75
- package/dist/jsx/extractor/removeUnusedHooks.js.map +0 -7
- package/dist/jsx/extractor/timer.js +0 -29
- package/dist/jsx/extractor/timer.js.map +0 -7
- package/dist/jsx/extractor/validHTMLAttributes.js +0 -102
- package/dist/jsx/extractor/validHTMLAttributes.js.map +0 -7
- package/dist/jsx/getPragmaOptions.js +0 -43
- package/dist/jsx/getPragmaOptions.js.map +0 -7
- package/dist/jsx/index.js +0 -17
- package/dist/jsx/index.js.map +0 -7
- package/dist/jsx/require.js +0 -62
- package/dist/jsx/require.js.map +0 -7
- package/dist/jsx/types.js +0 -1
- package/dist/jsx/types.js.map +0 -7
- package/dist/jsx/webpackPlugin.js +0 -11
- package/dist/jsx/webpackPlugin.js.map +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/require.ts"],
|
|
4
|
+
"sourcesContent": ["import { join, sep } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants.js'\n\nconst nameToPaths = {}\nconst Module = require('module')\nconst og = Module.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\n// just for catching egregious amounts of errors in a tight loop\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 50)\n\nexport function registerRequire() {\n if (Module.prototype.require !== globalThis['ogRequire']) {\n // eslint-disable-next-line no-console\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n // TODO can swap with react-native-web-lite\n const rnw = require('react-native-web')\n const core = require('@tamagui/core-node')\n\n Module.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n // eslint-disable-next-line no-console\n console.log('tamagui:require', path)\n }\n if (path.endsWith('.css') || path.endsWith('.json') || path.endsWith('.ttf')) {\n return {}\n }\n if (\n path === '@gorhom/bottom-sheet' ||\n path.startsWith('react-native-reanimated') ||\n path === 'expo-linear-gradient' ||\n path === '@expo/vector-icons'\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'.replace(/\\//g, sep))\n ) {\n return rnw\n }\n if (path === '@tamagui/core') {\n return core\n }\n try {\n const out = og.apply(this, arguments)\n // only for studio disable for now\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 if (SHOULD_DEBUG) {\n // eslint-disable-next-line no-console\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring\\n`,\n err.message,\n err.stack\n )\n }\n const max = process.env.TAMAGUI_MAX_ERRORS ? +process.env.TAMAGUI_MAX_ERRORS : 200\n if (++tries > max) {\n // eslint-disable-next-line no-console\n console.log(\n `Too many errors loading design system, exiting (set TAMAGUI_MAX_ERRORS to override)..`\n )\n // avoid infinite loops\n process.exit(1)\n }\n // return proxyWorm by default\n return proxyWorm\n }\n }\n\n return Module.prototype.require\n}\n\nexport function unregisterRequire() {\n Module.prototype.require = og\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAI1B,uBAA6B;AAE7B,MAAM,cAAc,CAAC;AACrB,MAAM,SAAS,QAAQ,QAAQ;AAC/B,MAAM,KAAK,OAAO,UAAU;AAC5B,WAAW,eAAe;AAEnB,MAAM,iBAAiB,MAAM;AAGpC,IAAI,QAAQ;AACZ,YAAY,MAAM;AAChB,UAAQ;AACV,GAAG,EAAE;AAEE,SAAS,kBAAkB;AAChC,MAAI,OAAO,UAAU,YAAY,WAAW,cAAc;AAExD,YAAQ,KAAK,wCAAwC;AACrD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,YAAY,QAAQ,qBAAqB;AAE/C,QAAM,MAAM,QAAQ,kBAAkB;AACtC,QAAM,OAAO,QAAQ,oBAAoB;AAEzC,SAAO,UAAU,UAAU,SAAU,MAAc;AACjD,QAAI,+BAAc;AAEhB,cAAQ,IAAI,mBAAmB,IAAI;AAAA,IACrC;AACA,QAAI,KAAK,SAAS,MAAM,KAAK,KAAK,SAAS,OAAO,KAAK,KAAK,SAAS,MAAM,GAAG;AAC5E,aAAO,CAAC;AAAA,IACV;AACA,QACE,SAAS,0BACT,KAAK,WAAW,yBAAyB,KACzC,SAAS,0BACT,SAAS,sBACT;AACA,aAAO;AAAA,IACT;AACA,QACE,KAAK,WAAW,cAAc,KAE9B,CAAC,KAAK,WAAW,oCAAoC,QAAQ,OAAO,eAAG,CAAC,GACxE;AACA,aAAO;AAAA,IACT;AACA,QAAI,SAAS,iBAAiB;AAC5B,aAAO;AAAA,IACT;AACA,QAAI;AACF,YAAM,MAAM,GAAG,MAAM,MAAM,SAAS;AAwBpC,aAAO;AAAA,IACT,SAAS,KAAP;AACA,UAAI,+BAAc;AAEhB,gBAAQ;AAAA,UACN,4BAA4B;AAAA;AAAA,UAC5B,IAAI;AAAA,UACJ,IAAI;AAAA,QACN;AAAA,MACF;AACA,YAAM,MAAM,QAAQ,IAAI,qBAAqB,CAAC,QAAQ,IAAI,qBAAqB;AAC/E,UAAI,EAAE,QAAQ,KAAK;AAEjB,gBAAQ;AAAA,UACN;AAAA,QACF;AAEA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO,OAAO,UAAU;AAC1B;AAEO,SAAS,oBAAoB;AAClC,SAAO,UAAU,UAAU;AAC7B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["import type { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport type { PseudoStyles, StaticConfig } from '@tamagui/core-node'\nimport type { StyleObject } from '@tamagui/helpers'\nimport type { ViewStyle } from 'react-native'\n\nexport type { StyleObject } from '@tamagui/helpers'\n\nexport type ClassNameObject = t.StringLiteral | t.Expression\n\nexport interface CacheObject {\n [key: string]: any\n}\n\nexport interface LogOptions {\n clear?: boolean\n timestamp?: boolean\n error?: Error | null\n}\n\nexport interface Logger {\n info(msg: string, options?: LogOptions): void\n warn(msg: string, options?: LogOptions): void\n error(msg: string, options?: LogOptions): void\n}\n\nexport type ExtractorOptions = {\n logger?: Logger\n}\n\nexport interface TamaguiOptions {\n // module paths you want to compile with tamagui (for example ['tamagui'])\n components: string[]\n // your tamagui.config.ts\n config?: string\n evaluateVars?: boolean\n importsWhitelist?: string[]\n disable?: boolean\n disableExtraction?: boolean\n disableDebugAttr?: boolean\n disableExtractInlineMedia?: boolean\n disableExtractVariables?: boolean\n excludeReactNativeWebExports?: string[]\n exclude?: RegExp\n logTimings?: boolean\n prefixLogs?: string\n\n // probably non user options\n cssPath?: string\n cssData?: any\n deoptProps?: Set<string>\n excludeProps?: Set<string>\n inlineProps?: Set<string>\n forceExtractStyleDefinitions?: boolean\n}\n\nexport type ExtractedAttrAttr = {\n type: 'attr'\n value: t.JSXAttribute | t.JSXSpreadAttribute\n}\n\nexport type ExtractedAttrStyle = {\n type: 'style'\n value: ViewStyle & PseudoStyles\n attr?: t.JSXAttribute | t.JSXSpreadAttribute\n name?: string\n}\n\nexport type ExtractedAttr =\n | ExtractedAttrAttr\n | { type: 'ternary'; value: Ternary }\n | ExtractedAttrStyle\n\nexport type ExtractTagProps = {\n attrs: ExtractedAttr[]\n node: t.JSXOpeningElement\n attemptEval: (exprNode: t.Node, evalFn?: ((node: t.Node) => any) | undefined) => any\n jsxPath: NodePath<t.JSXElement>\n programPath: NodePath<t.Program>\n originalNodeName: string\n lineNumbers: string\n filePath: string\n isFlattened: boolean\n completeProps: Record<string, any>\n staticConfig: StaticConfig\n}\n\nexport type ExtractorParseProps = TamaguiOptions & {\n target: 'native' | 'html'\n sourcePath?: string\n shouldPrintDebug?: boolean | 'verbose'\n onExtractTag: (props: ExtractTagProps) => void\n getFlattenedNode: (props: { isTextView: boolean; tag: string }) => string\n extractStyledDefinitions?: boolean\n // identifer, rule\n onStyleRule?: (identifier: string, rules: string[]) => void\n}\n\nexport interface Ternary {\n test: t.Expression\n // shorthand props that don't use hooks\n inlineMediaQuery?: string\n remove: Function\n consequent: Object | null\n alternate: Object | null\n}\n\nexport type ClassNameToStyleObj = {\n [key: string]: StyleObject\n}\n\nexport interface PluginContext {\n write: (path: string, rules: { [key: string]: string }) => any\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["../src/webpackPlugin.ts"],
|
|
4
4
|
"sourcesContent": ["const pluginName = 'TamaguiWebpackPlugin'\n\nexport class TamaguiWebpackPlugin {\n apply(compiler) {\n compiler.hooks.run.tap(pluginName, (compilation) => {\n // console.log('The webpack build process is starting!');\n })\n }\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,aAAa;AAEZ,MAAM,qBAAqB;AAAA,EAChC,MAAM,UAAU;AACd,aAAS,MAAM,IAAI,IAAI,YAAY,CAAC,gBAAgB;AAAA,IAEpD,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.153",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
|
-
"main": "dist
|
|
7
|
-
"module": "dist/esm",
|
|
8
|
-
"module:jsx": "dist/jsx",
|
|
6
|
+
"main": "dist",
|
|
9
7
|
"files": [
|
|
8
|
+
"tamagui.tsconfig.json",
|
|
10
9
|
"patches",
|
|
11
10
|
"src",
|
|
12
11
|
"types",
|
|
@@ -38,15 +37,16 @@
|
|
|
38
37
|
"@babel/runtime": "^7.18.9",
|
|
39
38
|
"@babel/traverse": "^7.18.11",
|
|
40
39
|
"@expo/match-media": "^0.3.0",
|
|
41
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
42
|
-
"@tamagui/
|
|
43
|
-
"@tamagui/
|
|
44
|
-
"@tamagui/
|
|
45
|
-
"@tamagui/
|
|
46
|
-
"@tamagui/
|
|
47
|
-
"@tamagui/
|
|
48
|
-
"@tamagui/
|
|
49
|
-
"@tamagui/
|
|
40
|
+
"@tamagui/build": "^1.0.1-beta.153",
|
|
41
|
+
"@tamagui/cli-color": "^1.0.1-beta.153",
|
|
42
|
+
"@tamagui/config-default-node": "^1.0.1-beta.153",
|
|
43
|
+
"@tamagui/core-node": "^1.0.1-beta.153",
|
|
44
|
+
"@tamagui/fake-react-native": "^1.0.1-beta.153",
|
|
45
|
+
"@tamagui/helpers": "^1.0.1-beta.153",
|
|
46
|
+
"@tamagui/patch-rnw": "^1.0.1-beta.153",
|
|
47
|
+
"@tamagui/proxy-worm": "^1.0.1-beta.153",
|
|
48
|
+
"@tamagui/react-native-svg": "^1.0.1-beta.153",
|
|
49
|
+
"@tamagui/shorthands": "^1.0.1-beta.153",
|
|
50
50
|
"babel-literal-to-ast": "^2.1.0",
|
|
51
51
|
"esbuild": "^0.14.49",
|
|
52
52
|
"esbuild-register": "^3.3.3",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"fs-extra": "^10.1.0",
|
|
55
55
|
"invariant": "^2.2.4",
|
|
56
56
|
"lodash": "^4.17.21",
|
|
57
|
-
"react-native-web-lite": "^1.0.1-beta.
|
|
58
|
-
"tamagui": "^1.0.1-beta.
|
|
57
|
+
"react-native-web-lite": "^1.0.1-beta.153",
|
|
58
|
+
"tamagui": "^1.0.1-beta.153"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@babel/plugin-syntax-typescript": "^7.18.6",
|
|
@@ -7,9 +7,9 @@ import type { TamaguiConfig } from '@tamagui/core-node'
|
|
|
7
7
|
import { createCSSVariable } from '@tamagui/core-node'
|
|
8
8
|
import esbuild from 'esbuild'
|
|
9
9
|
|
|
10
|
-
import { FAILED_EVAL } from '../constants'
|
|
11
|
-
import { evaluateAstNode } from './evaluateAstNode'
|
|
12
|
-
import { isValidThemeHook } from './extractHelpers'
|
|
10
|
+
import { FAILED_EVAL } from '../constants.js'
|
|
11
|
+
import { evaluateAstNode } from './evaluateAstNode.js'
|
|
12
|
+
import { isValidThemeHook } from './extractHelpers.js'
|
|
13
13
|
|
|
14
14
|
export function createEvaluator({
|
|
15
15
|
tamaguiConfig,
|
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
} from '@tamagui/core-node'
|
|
17
17
|
import type { ViewStyle } from 'react-native'
|
|
18
18
|
|
|
19
|
-
import { FAILED_EVAL } from '../constants'
|
|
20
|
-
import {
|
|
19
|
+
import { FAILED_EVAL } from '../constants.js'
|
|
20
|
+
import type {
|
|
21
21
|
ExtractedAttr,
|
|
22
22
|
ExtractedAttrAttr,
|
|
23
23
|
ExtractedAttrStyle,
|
|
@@ -25,19 +25,25 @@ import {
|
|
|
25
25
|
ExtractorParseProps,
|
|
26
26
|
TamaguiOptions,
|
|
27
27
|
Ternary,
|
|
28
|
-
} from '../types'
|
|
29
|
-
import { createEvaluator, createSafeEvaluator } from './createEvaluator'
|
|
30
|
-
import { evaluateAstNode } from './evaluateAstNode'
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
28
|
+
} from '../types.js'
|
|
29
|
+
import { createEvaluator, createSafeEvaluator } from './createEvaluator.js'
|
|
30
|
+
import { evaluateAstNode } from './evaluateAstNode.js'
|
|
31
|
+
import {
|
|
32
|
+
attrStr,
|
|
33
|
+
findComponentName,
|
|
34
|
+
isInsideTamagui,
|
|
35
|
+
isPresent,
|
|
36
|
+
objToStr,
|
|
37
|
+
} from './extractHelpers.js'
|
|
38
|
+
import { findTopmostFunction } from './findTopmostFunction.js'
|
|
39
|
+
import { cleanupBeforeExit, getStaticBindingsForScope } from './getStaticBindingsForScope.js'
|
|
40
|
+
import { literalToAst } from './literalToAst.js'
|
|
41
|
+
import { TamaguiProjectInfo, loadTamagui, loadTamaguiSync } from './loadTamagui.js'
|
|
42
|
+
import { logLines } from './logLines.js'
|
|
43
|
+
import { normalizeTernaries } from './normalizeTernaries.js'
|
|
44
|
+
import { removeUnusedHooks } from './removeUnusedHooks.js'
|
|
45
|
+
import { timer } from './timer.js'
|
|
46
|
+
import { validHTMLAttributes } from './validHTMLAttributes.js'
|
|
41
47
|
|
|
42
48
|
const UNTOUCHED_PROPS = {
|
|
43
49
|
key: true,
|
|
@@ -2,8 +2,9 @@ import generate from '@babel/generator'
|
|
|
2
2
|
import type { NodePath } from '@babel/traverse'
|
|
3
3
|
import * as t from '@babel/types'
|
|
4
4
|
|
|
5
|
-
import { ExtractedAttr, Ternary } from '../types'
|
|
6
|
-
|
|
5
|
+
import type { ExtractedAttr, Ternary } from '../types.js'
|
|
6
|
+
|
|
7
|
+
// import { astToLiteral } from './literalToAst'
|
|
7
8
|
|
|
8
9
|
export function isPresent<T extends Object>(input: null | void | undefined | T): input is T {
|
|
9
10
|
return input != null
|
|
@@ -68,7 +69,7 @@ export const ternaryStr = (x: Ternary) => {
|
|
|
68
69
|
const isFilledObj = (obj: any) => obj && Object.keys(obj).length
|
|
69
70
|
|
|
70
71
|
export function findComponentName(scope) {
|
|
71
|
-
|
|
72
|
+
const componentName = ''
|
|
72
73
|
let cur = scope.path
|
|
73
74
|
while (cur.parentPath && !t.isProgram(cur.parentPath.parent)) {
|
|
74
75
|
cur = cur.parentPath
|
|
@@ -3,9 +3,9 @@ import * as t from '@babel/types'
|
|
|
3
3
|
import { TamaguiInternalConfig, getStylesAtomic, mediaObjectToString } from '@tamagui/core-node'
|
|
4
4
|
import { ViewStyle } from 'react-native'
|
|
5
5
|
|
|
6
|
-
import { MEDIA_SEP } from '../constants'
|
|
7
|
-
import { StyleObject, Ternary } from '../types'
|
|
8
|
-
import { isInsideTamagui, isPresent } from './extractHelpers'
|
|
6
|
+
import { MEDIA_SEP } from '../constants.js'
|
|
7
|
+
import type { StyleObject, Ternary } from '../types.js'
|
|
8
|
+
import { isInsideTamagui, isPresent } from './extractHelpers.js'
|
|
9
9
|
|
|
10
10
|
export function extractMediaStyle(
|
|
11
11
|
ternary: Ternary,
|
|
@@ -9,18 +9,18 @@ import { concatClassName } from '@tamagui/helpers'
|
|
|
9
9
|
import invariant from 'invariant'
|
|
10
10
|
import { ViewStyle } from 'react-native'
|
|
11
11
|
|
|
12
|
-
import { CONCAT_CLASSNAME_IMPORT } from '../constants'
|
|
13
|
-
import { ClassNameObject, StyleObject, TamaguiOptions, Ternary } from '../types'
|
|
14
|
-
import { babelParse } from './babelParse'
|
|
15
|
-
import { buildClassName } from './buildClassName'
|
|
16
|
-
import { Extractor } from './createExtractor'
|
|
17
|
-
import { ensureImportingConcat } from './ensureImportingConcat'
|
|
18
|
-
import { isSimpleSpread } from './extractHelpers'
|
|
19
|
-
import { extractMediaStyle } from './extractMediaStyle'
|
|
20
|
-
import { getPrefixLogs } from './getPrefixLogs'
|
|
21
|
-
import { hoistClassNames } from './hoistClassNames'
|
|
22
|
-
import { logLines } from './logLines'
|
|
23
|
-
import { timer } from './timer'
|
|
12
|
+
import { CONCAT_CLASSNAME_IMPORT } from '../constants.js'
|
|
13
|
+
import type { ClassNameObject, StyleObject, TamaguiOptions, Ternary } from '../types.js'
|
|
14
|
+
import { babelParse } from './babelParse.js'
|
|
15
|
+
import { buildClassName } from './buildClassName.js'
|
|
16
|
+
import { Extractor } from './createExtractor.js'
|
|
17
|
+
import { ensureImportingConcat } from './ensureImportingConcat.js'
|
|
18
|
+
import { isSimpleSpread } from './extractHelpers.js'
|
|
19
|
+
import { extractMediaStyle } from './extractMediaStyle.js'
|
|
20
|
+
import { getPrefixLogs } from './getPrefixLogs.js'
|
|
21
|
+
import { hoistClassNames } from './hoistClassNames.js'
|
|
22
|
+
import { logLines } from './logLines.js'
|
|
23
|
+
import { timer } from './timer.js'
|
|
24
24
|
|
|
25
25
|
const mergeStyleGroups = {
|
|
26
26
|
shadowOpacity: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import generate from '@babel/generator'
|
|
2
2
|
import * as t from '@babel/types'
|
|
3
3
|
|
|
4
|
-
import { accessSafe } from './accessSafe'
|
|
4
|
+
import { accessSafe } from './accessSafe.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* getPropValueFromAttributes gets a prop by name from a list of attributes and accounts for potential spread operators.
|
|
@@ -23,7 +23,7 @@ export function getPropValueFromAttributes(
|
|
|
23
23
|
propName: string,
|
|
24
24
|
attrs: (t.JSXAttribute | t.JSXSpreadAttribute)[]
|
|
25
25
|
): t.Expression | null {
|
|
26
|
-
let propIndex
|
|
26
|
+
let propIndex = -1
|
|
27
27
|
let jsxAttr: t.JSXAttribute | null = null
|
|
28
28
|
for (let idx = -1, len = attrs.length; ++idx < len; ) {
|
|
29
29
|
const attr = attrs[idx]
|
|
@@ -4,8 +4,8 @@ import { dirname, extname, join, resolve } from 'path'
|
|
|
4
4
|
import { Binding, NodePath } from '@babel/traverse'
|
|
5
5
|
import * as t from '@babel/types'
|
|
6
6
|
|
|
7
|
-
import { evaluateAstNode } from './evaluateAstNode'
|
|
8
|
-
import { getSourceModule } from './getSourceModule'
|
|
7
|
+
import { evaluateAstNode } from './evaluateAstNode.js'
|
|
8
|
+
import { getSourceModule } from './getSourceModule.js'
|
|
9
9
|
|
|
10
10
|
const isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')
|
|
11
11
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { basename, dirname, join, sep } from 'path'
|
|
3
3
|
|
|
4
|
+
import { Color, colorLog } from '@tamagui/cli-color'
|
|
4
5
|
import { getDefaultTamaguiConfig } from '@tamagui/config-default-node'
|
|
5
6
|
import type { StaticConfig, TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core-node'
|
|
6
7
|
import { createTamagui } from '@tamagui/core-node'
|
|
7
8
|
import esbuild from 'esbuild'
|
|
8
|
-
import { ensureDir, pathExists,
|
|
9
|
+
import { ensureDir, pathExists, stat, writeFile } from 'fs-extra'
|
|
9
10
|
|
|
10
|
-
import { SHOULD_DEBUG } from '../constants'
|
|
11
|
-
import { getNameToPaths, registerRequire, unregisterRequire } from '../require'
|
|
11
|
+
import { SHOULD_DEBUG } from '../constants.js'
|
|
12
|
+
import { getNameToPaths, registerRequire, unregisterRequire } from '../require.js'
|
|
12
13
|
|
|
13
14
|
type NameToPaths = {
|
|
14
15
|
[key: string]: Set<string>
|
|
@@ -68,6 +69,19 @@ export async function loadTamagui(props: Props): Promise<TamaguiProjectInfo> {
|
|
|
68
69
|
//
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
colorLog(
|
|
73
|
+
Color.FgYellow,
|
|
74
|
+
`
|
|
75
|
+
Building your tamagui.config.ts and componets into node-friendly bundles for usage during compulation:`
|
|
76
|
+
)
|
|
77
|
+
colorLog(
|
|
78
|
+
Color.Dim,
|
|
79
|
+
`
|
|
80
|
+
- Config: ${configOutPath}
|
|
81
|
+
- Components: ${componentOutPaths.join(', ')}
|
|
82
|
+
`
|
|
83
|
+
)
|
|
84
|
+
|
|
71
85
|
await Promise.all([
|
|
72
86
|
props.config
|
|
73
87
|
? buildTamaguiConfig(props, {
|
|
@@ -141,21 +155,29 @@ async function buildTamaguiConfig(
|
|
|
141
155
|
}
|
|
142
156
|
}
|
|
143
157
|
}
|
|
144
|
-
|
|
158
|
+
|
|
159
|
+
void writeFile(lockFile, '')
|
|
160
|
+
|
|
145
161
|
if (process.env.DEBUG?.startsWith('tamagui')) {
|
|
146
162
|
console.log(`Building`, options.entryPoints)
|
|
147
163
|
}
|
|
164
|
+
|
|
165
|
+
const tsconfig = join(__dirname, '..', '..', 'tamagui.tsconfig.json')
|
|
166
|
+
|
|
148
167
|
return esbuild.build({
|
|
149
168
|
bundle: true,
|
|
150
169
|
...options,
|
|
151
170
|
format: 'cjs',
|
|
152
171
|
target: 'node18',
|
|
172
|
+
jsx: 'transform',
|
|
173
|
+
jsxFactory: 'react',
|
|
174
|
+
allowOverwrite: true,
|
|
153
175
|
keepNames: true,
|
|
154
176
|
platform: 'node',
|
|
177
|
+
tsconfig,
|
|
155
178
|
loader: {
|
|
156
179
|
'.js': 'jsx',
|
|
157
180
|
},
|
|
158
|
-
allowOverwrite: true,
|
|
159
181
|
logLevel: 'warning',
|
|
160
182
|
plugins: [
|
|
161
183
|
{
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
process.env.TAMAGUI_COMPILE_PROCESS = '1'
|
|
2
2
|
|
|
3
|
-
export { TamaguiOptions } from './types'
|
|
4
|
-
export { createExtractor } from './extractor/createExtractor'
|
|
5
|
-
export { literalToAst } from './extractor/literalToAst'
|
|
6
|
-
export * from './constants'
|
|
7
|
-
export * from './extractor/extractToClassNames'
|
|
8
|
-
export * from './extractor/extractHelpers'
|
|
3
|
+
export { TamaguiOptions } from './types.js'
|
|
4
|
+
export { createExtractor } from './extractor/createExtractor.js'
|
|
5
|
+
export { literalToAst } from './extractor/literalToAst.js'
|
|
6
|
+
export * from './constants.js'
|
|
7
|
+
export * from './extractor/extractToClassNames.js'
|
|
8
|
+
export * from './extractor/extractHelpers.js'
|
|
9
9
|
export * from '@tamagui/patch-rnw'
|
|
10
|
-
export * from './extractor/loadTamagui'
|
|
11
|
-
export * from './require'
|
|
12
|
-
export * from './getPragmaOptions'
|
|
13
|
-
// export * from './webpackPlugin'
|
|
10
|
+
export * from './extractor/loadTamagui.js'
|
|
11
|
+
export * from './require.js'
|
|
12
|
+
export * from './getPragmaOptions.js'
|
package/src/require.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { NodePath } from '@babel/traverse'
|
|
1
|
+
import type { NodePath } from '@babel/traverse'
|
|
2
2
|
import * as t from '@babel/types'
|
|
3
|
-
import type { PseudoStyles, StaticConfig
|
|
4
|
-
import {
|
|
3
|
+
import type { PseudoStyles, StaticConfig } from '@tamagui/core-node'
|
|
4
|
+
import type { StyleObject } from '@tamagui/helpers'
|
|
5
|
+
import type { ViewStyle } from 'react-native'
|
|
5
6
|
|
|
6
7
|
export type { StyleObject } from '@tamagui/helpers'
|
|
7
8
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as t from '@babel/types';
|
|
2
|
-
import { ClassNameObject } from '../types';
|
|
2
|
+
import type { ClassNameObject } from '../types.js';
|
|
3
3
|
export declare function buildClassName(classNameObjects: ClassNameObject[]): t.Expression | t.StringLiteral | null;
|
|
4
4
|
//# sourceMappingURL=buildClassName.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { NodePath } from '@babel/traverse';
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
|
-
import { ExtractorOptions, ExtractorParseProps, TamaguiOptions } from '../types';
|
|
4
|
-
import { cleanupBeforeExit } from './getStaticBindingsForScope';
|
|
5
|
-
import { TamaguiProjectInfo } from './loadTamagui';
|
|
3
|
+
import type { ExtractorOptions, ExtractorParseProps, TamaguiOptions } from '../types.js';
|
|
4
|
+
import { cleanupBeforeExit } from './getStaticBindingsForScope.js';
|
|
5
|
+
import { TamaguiProjectInfo } from './loadTamagui.js';
|
|
6
6
|
export declare type Extractor = ReturnType<typeof createExtractor>;
|
|
7
7
|
declare type FileOrPath = NodePath<t.Program> | t.File;
|
|
8
8
|
export declare function createExtractor({ logger }?: ExtractorOptions): {
|
|
9
9
|
options: {
|
|
10
|
-
logger: import("../types").Logger;
|
|
10
|
+
logger: import("../types.js").Logger;
|
|
11
11
|
};
|
|
12
12
|
cleanupBeforeExit: typeof cleanupBeforeExit;
|
|
13
13
|
loadTamagui: (props: TamaguiOptions) => Promise<TamaguiProjectInfo>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NodePath } from '@babel/traverse';
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
|
-
import { ExtractedAttr, Ternary } from '../types';
|
|
3
|
+
import type { ExtractedAttr, Ternary } from '../types.js';
|
|
4
4
|
export declare function isPresent<T extends Object>(input: null | void | undefined | T): input is T;
|
|
5
5
|
export declare function isSimpleSpread(node: t.JSXSpreadAttribute): boolean;
|
|
6
6
|
export declare const attrStr: (attr?: ExtractedAttr) => string | t.JSXIdentifier;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NodePath } from '@babel/traverse';
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
3
|
import { TamaguiInternalConfig } from '@tamagui/core-node';
|
|
4
|
-
import {
|
|
4
|
+
import type { Ternary } from '../types.js';
|
|
5
5
|
export declare function extractMediaStyle(ternary: Ternary, jsxPath: NodePath<t.JSXElement>, tamaguiConfig: TamaguiInternalConfig, sourcePath: string, importance?: number, shouldPrintDebug?: boolean | 'verbose'): {
|
|
6
6
|
mediaStyles: StyleObject[];
|
|
7
7
|
ternaryWithoutMedia: Ternary | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
|
-
import { TamaguiOptions } from '../types';
|
|
4
|
-
import { Extractor } from './createExtractor';
|
|
3
|
+
import type { TamaguiOptions } from '../types.js';
|
|
4
|
+
import { Extractor } from './createExtractor.js';
|
|
5
5
|
export declare type ExtractedResponse = {
|
|
6
6
|
js: string | Buffer;
|
|
7
7
|
styles: string;
|
package/types/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { TamaguiOptions } from './types';
|
|
2
|
-
export { createExtractor } from './extractor/createExtractor';
|
|
3
|
-
export { literalToAst } from './extractor/literalToAst';
|
|
4
|
-
export * from './constants';
|
|
5
|
-
export * from './extractor/extractToClassNames';
|
|
6
|
-
export * from './extractor/extractHelpers';
|
|
1
|
+
export { TamaguiOptions } from './types.js';
|
|
2
|
+
export { createExtractor } from './extractor/createExtractor.js';
|
|
3
|
+
export { literalToAst } from './extractor/literalToAst.js';
|
|
4
|
+
export * from './constants.js';
|
|
5
|
+
export * from './extractor/extractToClassNames.js';
|
|
6
|
+
export * from './extractor/extractHelpers.js';
|
|
7
7
|
export * from '@tamagui/patch-rnw';
|
|
8
|
-
export * from './extractor/loadTamagui';
|
|
9
|
-
export * from './require';
|
|
10
|
-
export * from './getPragmaOptions';
|
|
8
|
+
export * from './extractor/loadTamagui.js';
|
|
9
|
+
export * from './require.js';
|
|
10
|
+
export * from './getPragmaOptions.js';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/types/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { NodePath } from '@babel/traverse';
|
|
1
|
+
import type { NodePath } from '@babel/traverse';
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
|
-
import type { PseudoStyles, StaticConfig
|
|
4
|
-
import {
|
|
3
|
+
import type { PseudoStyles, StaticConfig } from '@tamagui/core-node';
|
|
4
|
+
import type { StyleObject } from '@tamagui/helpers';
|
|
5
|
+
import type { ViewStyle } from 'react-native';
|
|
5
6
|
export type { StyleObject } from '@tamagui/helpers';
|
|
6
7
|
export declare type ClassNameObject = t.StringLiteral | t.Expression;
|
|
7
8
|
export interface CacheObject {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/constants.ts"],
|
|
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": ";;;;;;;;;;;;;;;;;;;;;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
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/extractor/accessSafe.ts"],
|
|
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": ";;;;;;;;;;;;;;;;;;;;;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
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/extractor/buildClassName.ts"],
|
|
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": ";;;;;;;;;;;;;;;;;;;;;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
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/extractor/createEvaluator.ts"],
|
|
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 // eslint-disable-next-line no-console\n console.log(' > found theme prop', 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 // eslint-disable-next-line no-console\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": ";;;;;;;;;;;;;;;;;;;;;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;AAEpB,gBAAQ,IAAI,0BAA0B,GAAG;AAAA,MAC3C;AACA,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;AAEpB,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
|
-
"names": []
|
|
7
|
-
}
|