@tamagui/static 1.0.1-beta.70 → 1.0.1-beta.73
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/extractor/accessSafe.js +0 -2
- package/dist/cjs/extractor/accessSafe.js.map +1 -1
- package/dist/cjs/extractor/babelParse.js +0 -2
- package/dist/cjs/extractor/babelParse.js.map +1 -1
- package/dist/cjs/extractor/buildClassName.js +0 -2
- package/dist/cjs/extractor/buildClassName.js.map +1 -1
- package/dist/cjs/extractor/createEvaluator.js +2 -5
- package/dist/cjs/extractor/createEvaluator.js.map +1 -1
- package/dist/cjs/extractor/createExtractor.js +10 -21
- package/dist/cjs/extractor/createExtractor.js.map +1 -1
- package/dist/cjs/extractor/ensureImportingConcat.js +0 -2
- package/dist/cjs/extractor/ensureImportingConcat.js.map +1 -1
- package/dist/cjs/extractor/evaluateAstNode.js +0 -2
- package/dist/cjs/extractor/evaluateAstNode.js.map +1 -1
- package/dist/cjs/extractor/extractHelpers.js +11 -16
- package/dist/cjs/extractor/extractHelpers.js.map +1 -1
- package/dist/cjs/extractor/extractMediaStyle.js +2 -7
- package/dist/cjs/extractor/extractMediaStyle.js.map +1 -1
- package/dist/cjs/extractor/extractToClassNames.js +5 -18
- package/dist/cjs/extractor/extractToClassNames.js.map +2 -2
- package/dist/cjs/extractor/findTopmostFunction.js +1 -3
- package/dist/cjs/extractor/findTopmostFunction.js.map +1 -1
- package/dist/cjs/extractor/generatedUid.js +0 -2
- package/dist/cjs/extractor/generatedUid.js.map +1 -1
- package/dist/cjs/extractor/getPrefixLogs.js +0 -2
- package/dist/cjs/extractor/getPrefixLogs.js.map +1 -1
- package/dist/cjs/extractor/getPropValueFromAttributes.js +0 -2
- package/dist/cjs/extractor/getPropValueFromAttributes.js.map +1 -1
- package/dist/cjs/extractor/getSourceModule.js +0 -2
- package/dist/cjs/extractor/getSourceModule.js.map +1 -1
- package/dist/cjs/extractor/getStaticBindingsForScope.js +1 -5
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +1 -1
- package/dist/cjs/extractor/hoistClassNames.js +0 -3
- package/dist/cjs/extractor/hoistClassNames.js.map +1 -1
- package/dist/cjs/extractor/literalToAst.js +0 -4
- package/dist/cjs/extractor/literalToAst.js.map +1 -1
- package/dist/cjs/extractor/loadTamagui.js +0 -2
- package/dist/cjs/extractor/loadTamagui.js.map +1 -1
- package/dist/cjs/extractor/logLines.js +2 -3
- package/dist/cjs/extractor/logLines.js.map +1 -1
- package/dist/cjs/extractor/normalizeTernaries.js +0 -2
- package/dist/cjs/extractor/normalizeTernaries.js.map +1 -1
- package/dist/cjs/extractor/removeUnusedHooks.js +2 -4
- package/dist/cjs/extractor/removeUnusedHooks.js.map +1 -1
- package/dist/cjs/extractor/timer.js +2 -3
- package/dist/cjs/extractor/timer.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/extractor/accessSafe.js +0 -3
- package/dist/esm/extractor/accessSafe.js.map +1 -1
- package/dist/esm/extractor/babelParse.js +0 -3
- package/dist/esm/extractor/babelParse.js.map +1 -1
- package/dist/esm/extractor/buildClassName.js +0 -3
- package/dist/esm/extractor/buildClassName.js.map +1 -1
- package/dist/esm/extractor/createEvaluator.js +2 -6
- package/dist/esm/extractor/createEvaluator.js.map +1 -1
- package/dist/esm/extractor/createExtractor.js +10 -22
- package/dist/esm/extractor/createExtractor.js.map +1 -1
- package/dist/esm/extractor/ensureImportingConcat.js +0 -3
- package/dist/esm/extractor/ensureImportingConcat.js.map +1 -1
- package/dist/esm/extractor/evaluateAstNode.js +0 -3
- package/dist/esm/extractor/evaluateAstNode.js.map +1 -1
- package/dist/esm/extractor/extractHelpers.js +11 -17
- package/dist/esm/extractor/extractHelpers.js.map +1 -1
- package/dist/esm/extractor/extractMediaStyle.js +2 -8
- package/dist/esm/extractor/extractMediaStyle.js.map +1 -1
- package/dist/esm/extractor/extractToClassNames.js +5 -19
- package/dist/esm/extractor/extractToClassNames.js.map +2 -2
- package/dist/esm/extractor/findTopmostFunction.js +1 -4
- package/dist/esm/extractor/findTopmostFunction.js.map +1 -1
- package/dist/esm/extractor/generatedUid.js +0 -3
- package/dist/esm/extractor/generatedUid.js.map +1 -1
- package/dist/esm/extractor/getPrefixLogs.js +0 -3
- package/dist/esm/extractor/getPrefixLogs.js.map +1 -1
- package/dist/esm/extractor/getPropValueFromAttributes.js +0 -3
- package/dist/esm/extractor/getPropValueFromAttributes.js.map +1 -1
- package/dist/esm/extractor/getSourceModule.js +0 -3
- package/dist/esm/extractor/getSourceModule.js.map +1 -1
- package/dist/esm/extractor/getStaticBindingsForScope.js +1 -6
- package/dist/esm/extractor/getStaticBindingsForScope.js.map +1 -1
- package/dist/esm/extractor/hoistClassNames.js +0 -4
- package/dist/esm/extractor/hoistClassNames.js.map +1 -1
- package/dist/esm/extractor/literalToAst.js +0 -5
- package/dist/esm/extractor/literalToAst.js.map +1 -1
- package/dist/esm/extractor/loadTamagui.js +0 -3
- package/dist/esm/extractor/loadTamagui.js.map +1 -1
- package/dist/esm/extractor/logLines.js +2 -4
- package/dist/esm/extractor/logLines.js.map +1 -1
- package/dist/esm/extractor/normalizeTernaries.js +0 -3
- package/dist/esm/extractor/normalizeTernaries.js.map +1 -1
- package/dist/esm/extractor/removeUnusedHooks.js +2 -5
- package/dist/esm/extractor/removeUnusedHooks.js.map +1 -1
- package/dist/esm/extractor/timer.js +2 -4
- package/dist/esm/extractor/timer.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/jsx/extractor/accessSafe.js +0 -3
- package/dist/jsx/extractor/babelParse.js +0 -3
- package/dist/jsx/extractor/buildClassName.js +0 -3
- package/dist/jsx/extractor/createEvaluator.js +2 -6
- package/dist/jsx/extractor/createExtractor.js +10 -22
- package/dist/jsx/extractor/ensureImportingConcat.js +0 -3
- package/dist/jsx/extractor/evaluateAstNode.js +0 -3
- package/dist/jsx/extractor/extractHelpers.js +11 -17
- package/dist/jsx/extractor/extractMediaStyle.js +2 -8
- package/dist/jsx/extractor/extractToClassNames.js +5 -19
- package/dist/jsx/extractor/findTopmostFunction.js +1 -4
- package/dist/jsx/extractor/generatedUid.js +0 -3
- package/dist/jsx/extractor/getPrefixLogs.js +0 -3
- package/dist/jsx/extractor/getPropValueFromAttributes.js +0 -3
- package/dist/jsx/extractor/getSourceModule.js +0 -3
- package/dist/jsx/extractor/getStaticBindingsForScope.js +1 -6
- package/dist/jsx/extractor/hoistClassNames.js +0 -4
- package/dist/jsx/extractor/literalToAst.js +0 -5
- package/dist/jsx/extractor/loadTamagui.js +0 -3
- package/dist/jsx/extractor/logLines.js +2 -4
- package/dist/jsx/extractor/normalizeTernaries.js +0 -3
- package/dist/jsx/extractor/removeUnusedHooks.js +2 -5
- package/dist/jsx/extractor/timer.js +2 -4
- package/dist/jsx/index.js +1 -1
- package/package.json +10 -9
- package/src/extractor/extractToClassNames.ts +0 -19
- package/src/index.ts +1 -1
- package/types/constants.d.ts +0 -0
- package/types/constants.d.ts.map +0 -0
- package/types/extractor/accessSafe.d.ts +0 -0
- package/types/extractor/accessSafe.d.ts.map +0 -0
- package/types/extractor/babelParse.d.ts +0 -0
- package/types/extractor/babelParse.d.ts.map +0 -0
- package/types/extractor/buildClassName.d.ts +0 -0
- package/types/extractor/buildClassName.d.ts.map +0 -0
- package/types/extractor/createEvaluator.d.ts +0 -0
- package/types/extractor/createEvaluator.d.ts.map +0 -0
- package/types/extractor/createExtractor.d.ts +0 -0
- package/types/extractor/createExtractor.d.ts.map +0 -0
- package/types/extractor/ensureImportingConcat.d.ts +0 -0
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -0
- package/types/extractor/evaluateAstNode.d.ts +0 -0
- package/types/extractor/evaluateAstNode.d.ts.map +0 -0
- package/types/extractor/extractHelpers.d.ts +0 -0
- package/types/extractor/extractHelpers.d.ts.map +0 -0
- package/types/extractor/extractMediaStyle.d.ts +0 -0
- package/types/extractor/extractMediaStyle.d.ts.map +0 -0
- package/types/extractor/extractToClassNames.d.ts +1 -6
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/findTopmostFunction.d.ts +0 -0
- package/types/extractor/findTopmostFunction.d.ts.map +0 -0
- package/types/extractor/generatedUid.d.ts +0 -0
- package/types/extractor/generatedUid.d.ts.map +0 -0
- package/types/extractor/getPrefixLogs.d.ts +0 -0
- package/types/extractor/getPrefixLogs.d.ts.map +0 -0
- package/types/extractor/getPropValueFromAttributes.d.ts +0 -0
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -0
- package/types/extractor/getSourceModule.d.ts +0 -0
- package/types/extractor/getSourceModule.d.ts.map +0 -0
- package/types/extractor/getStaticBindingsForScope.d.ts +0 -0
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -0
- package/types/extractor/hoistClassNames.d.ts +0 -0
- package/types/extractor/hoistClassNames.d.ts.map +0 -0
- package/types/extractor/literalToAst.d.ts +0 -0
- package/types/extractor/literalToAst.d.ts.map +0 -0
- package/types/extractor/loadTamagui.d.ts +0 -0
- package/types/extractor/loadTamagui.d.ts.map +0 -0
- package/types/extractor/logLines.d.ts +0 -0
- package/types/extractor/logLines.d.ts.map +0 -0
- package/types/extractor/normalizeTernaries.d.ts +0 -0
- package/types/extractor/normalizeTernaries.d.ts.map +0 -0
- package/types/extractor/removeUnusedHooks.d.ts +0 -0
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -0
- package/types/extractor/timer.d.ts +0 -0
- package/types/extractor/timer.d.ts.map +0 -0
- package/types/extractor/validHTMLAttributes.d.ts +0 -0
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -0
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +0 -0
- package/types/types.d.ts.map +0 -0
- package/dist/cjs/patchReactNativeWeb.js +0 -107
- package/dist/cjs/patchReactNativeWeb.js.map +0 -7
- package/dist/esm/patchReactNativeWeb.js +0 -82
- package/dist/esm/patchReactNativeWeb.js.map +0 -7
- package/dist/jsx/patchReactNativeWeb.js +0 -81
- package/patches/18/createDOMProps.cjs.js +0 -385
- package/patches/18/createDOMProps.js +0 -379
- package/src/patchReactNativeWeb.ts +0 -116
- package/types/patchReactNativeWeb.d.ts +0 -2
- package/types/patchReactNativeWeb.d.ts.map +0 -1
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/loadTamagui.ts"],
|
|
4
4
|
"sourcesContent": ["import { join } from 'path'\n\nimport type { TamaguiComponent, TamaguiInternalConfig } from '@tamagui/core'\nimport { createTamagui } from '@tamagui/core-node'\n\nlet loadedTamagui: any = null\n\nexport function loadTamagui(props: { components: string[]; config: string }): {\n components: Record<string, TamaguiComponent>\n tamaguiConfig: TamaguiInternalConfig\n} {\n if (loadedTamagui) {\n return loadedTamagui\n }\n\n const configPath = join(process.cwd(), props.config)\n\n // threaded caching avoiding 1s loading of large configs every save\n // const cachePath = join(cacheDir, 'tamagui-conf-cached.json')\n // const confStat = statSync(configPath)\n\n // // TODO may want to disable, its pretty optimistic at caching...\n // try {\n // const confCache = readFileSync(cachePath, 'utf-8')\n // const confParsed = JSON.parse(confCache)\n // if (confParsed && confParsed.mtime === confStat.mtime) {\n // return confParsed.value\n // }\n // } catch {\n // // ok, no cache\n // }\n\n const x = Math.random()\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 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 return og.apply(this, arguments)\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\n if (staticConfig) {\n Object.assign(components, { [Name]: { staticConfig } })\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 }\n\n // save cache\n // try {\n // writeFileSync(\n // cachePath,\n // JSON.stringify({\n // value: loadedTamagui,\n // mtime: confStat.mtime,\n // })\n // )\n // } catch (err: any) {\n // console.log(`Error: tamagui config not stringifiable, caching disabled \"${err.message}\"`)\n // }\n\n return loadedTamagui\n } catch (err) {\n console.log('err', err)\n throw err\n } finally {\n unregister()\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAA;AAGA;AAEA,IAAI,gBAAqB;AAElB,qBAAqB,OAG1B;AACA,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,aAAa,KAAK,QAAQ,IAAI,GAAG,MAAM,MAAM;AAiBnD,QAAM,IAAI,KAAK,OAAO;AACtB,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,QAAI,UAAU,UAAU,SAAU,MAAc;AAC9C,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,eAAO,GAAG,MAAM,MAAM,SAAS;AAAA,MACjC,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;AAChB,iBAAO,OAAO,YAAY,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,CAAC;AAAA,QACxD;AAAA,MACF;AAAA,IACF;AAGA,YAAQ,IAAI,YAAY;AACxB,QAAI,UAAU,UAAU;AAGxB,kBAAc,aAAoB;AAElC,oBAAgB;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAeA,WAAO;AAAA,EACT,SAAS,KAAP;AACA,YAAQ,IAAI,OAAO,GAAG;AACtB,UAAM;AAAA,EACR,UAAE;AACA,eAAW;AAAA,EACb;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
const prefix = " ";
|
|
4
|
-
const logLines =
|
|
2
|
+
const logLines = (str, singleLine = false) => {
|
|
5
3
|
if (singleLine) {
|
|
6
4
|
return prefix + str.split(" ").join(`
|
|
7
5
|
${prefix}`);
|
|
@@ -15,7 +13,7 @@ ${prefix}`);
|
|
|
15
13
|
lines[lines.length - 1] += item + " ";
|
|
16
14
|
}
|
|
17
15
|
return lines.map((line, i) => prefix + (i == 0 ? "" : " ") + line.trim()).join("\n");
|
|
18
|
-
}
|
|
16
|
+
};
|
|
19
17
|
export {
|
|
20
18
|
logLines
|
|
21
19
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/logLines.ts"],
|
|
4
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": "
|
|
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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import generate from "@babel/generator";
|
|
4
2
|
import * as t from "@babel/types";
|
|
5
3
|
import invariant from "invariant";
|
|
@@ -46,7 +44,6 @@ function normalizeTernaries(ternaries) {
|
|
|
46
44
|
});
|
|
47
45
|
return ternaryExpression;
|
|
48
46
|
}
|
|
49
|
-
__name(normalizeTernaries, "normalizeTernaries");
|
|
50
47
|
export {
|
|
51
48
|
normalizeTernaries
|
|
52
49
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/normalizeTernaries.ts"],
|
|
4
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": "
|
|
5
|
+
"mappings": "AAAA;AACA;AACA;AAIO,4BAA4B,WAAsB;AANzD;AAOE,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,UAAM,EAAE,MAAM,YAAY,WAAW,WAAW,SAAS,UAAU;AAEnE,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;AAAA,QACpB,GAAG;AAAA,QACH,WAAW,CAAC;AAAA,QACZ,YAAY,CAAC;AAAA,QACb,MAAM;AAAA,QACN;AAAA,MACF;AAAA,IACF;AACA,UAAM,WAAY,mBAAa,aAAa,cAA1B,YAAwC,CAAC;AAC3D,UAAM,YAAa,mBAAa,YAAY,eAAzB,YAAwC,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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import * as t from "@babel/types";
|
|
4
2
|
const hooks = {
|
|
5
3
|
useMedia: true,
|
|
@@ -32,10 +30,10 @@ function removeUnusedHooks(compFn, shouldPrintDebug) {
|
|
|
32
30
|
if (!Array.isArray(declarations)) {
|
|
33
31
|
continue;
|
|
34
32
|
}
|
|
35
|
-
const isBindingReferenced =
|
|
33
|
+
const isBindingReferenced = (name) => {
|
|
36
34
|
var _a2;
|
|
37
35
|
return !!((_a2 = statement.scope.getBinding(name)) == null ? void 0 : _a2.referenced);
|
|
38
|
-
}
|
|
36
|
+
};
|
|
39
37
|
for (const declarator of declarations) {
|
|
40
38
|
const id = declarator.get("id");
|
|
41
39
|
const init = declarator.node.init;
|
|
@@ -73,7 +71,6 @@ function removeUnusedHooks(compFn, shouldPrintDebug) {
|
|
|
73
71
|
}
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
|
-
__name(removeUnusedHooks, "removeUnusedHooks");
|
|
77
74
|
export {
|
|
78
75
|
removeUnusedHooks
|
|
79
76
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/removeUnusedHooks.ts"],
|
|
4
4
|
"sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\n\nconst hooks = {\n useMedia: true,\n useTheme: true,\n}\n\nexport function removeUnusedHooks(compFn: NodePath<any>, shouldPrintDebug: boolean | 'verbose') {\n compFn.scope.crawl()\n // check the top level statements\n let bodyStatements = compFn?.get('body')\n if (!bodyStatements) {\n console.log('no body statemnts?', compFn)\n return\n }\n if (!Array.isArray(bodyStatements)) {\n if (bodyStatements.isFunctionExpression()) {\n bodyStatements = bodyStatements.scope.path.get('body')\n } else {\n bodyStatements = bodyStatements.get('body')\n }\n }\n if (!bodyStatements || !Array.isArray(bodyStatements)) {\n return\n }\n const statements = bodyStatements as NodePath<any>[]\n for (const statement of statements) {\n if (!statement.isVariableDeclaration()) {\n continue\n }\n const declarations = statement.get('declarations')\n if (!Array.isArray(declarations)) {\n continue\n }\n const isBindingReferenced = (name: string) => {\n return !!statement.scope.getBinding(name)?.referenced\n }\n for (const declarator of declarations) {\n const id = declarator.get('id')\n const init = declarator.node.init\n if (Array.isArray(id) || Array.isArray(init)) {\n continue\n }\n const shouldRemove = (() => {\n const isHook =\n t.isCallExpression(init) && t.isIdentifier(init.callee) && hooks[init.callee.name]\n if (!isHook) {\n return false\n }\n if (t.isIdentifier(id.node)) {\n // remove \"const media = useMedia()\"\n const name = id.node.name\n return !isBindingReferenced(name)\n } else if (t.isObjectPattern(id.node)) {\n // remove \"const { sm } = useMedia()\"\n const propPaths = id.get('properties') as NodePath<any>[]\n return propPaths.every((prop) => {\n if (!prop.isObjectProperty()) return false\n const value = prop.get('value')\n if (Array.isArray(value) || !value.isIdentifier()) return false\n const name = value.node.name\n return !isBindingReferenced(name)\n })\n }\n return false\n })()\n if (shouldRemove) {\n declarator.remove()\n if (shouldPrintDebug) {\n console.log(` [\uD83E\uDE9D] removed ${id.node['name'] ?? ''}`)\n }\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AACA;AAEA,MAAM,QAAQ;AAAA,EACZ,UAAU;AAAA,EACV,UAAU;AACZ;AAEO,2BAA2B,QAAuB,kBAAuC;AARhG;AASE,SAAO,MAAM,MAAM;AAEnB,MAAI,iBAAiB,iCAAQ,IAAI;AACjC,MAAI,CAAC,gBAAgB;AACnB,YAAQ,IAAI,sBAAsB,MAAM;AACxC;AAAA,EACF;AACA,MAAI,CAAC,MAAM,QAAQ,cAAc,GAAG;AAClC,QAAI,eAAe,qBAAqB,GAAG;AACzC,uBAAiB,eAAe,MAAM,KAAK,IAAI,MAAM;AAAA,IACvD,OAAO;AACL,uBAAiB,eAAe,IAAI,MAAM;AAAA,IAC5C;AAAA,EACF;AACA,MAAI,CAAC,kBAAkB,CAAC,MAAM,QAAQ,cAAc,GAAG;AACrD;AAAA,EACF;AACA,QAAM,aAAa;AACnB,aAAW,aAAa,YAAY;AAClC,QAAI,CAAC,UAAU,sBAAsB,GAAG;AACtC;AAAA,IACF;AACA,UAAM,eAAe,UAAU,IAAI,cAAc;AACjD,QAAI,CAAC,MAAM,QAAQ,YAAY,GAAG;AAChC;AAAA,IACF;AACA,UAAM,sBAAsB,CAAC,SAAiB;AAnClD;AAoCM,aAAO,CAAC,CAAC,kBAAU,MAAM,WAAW,IAAI,MAA/B,oBAAkC;AAAA,IAC7C;AACA,eAAW,cAAc,cAAc;AACrC,YAAM,KAAK,WAAW,IAAI,IAAI;AAC9B,YAAM,OAAO,WAAW,KAAK;AAC7B,UAAI,MAAM,QAAQ,EAAE,KAAK,MAAM,QAAQ,IAAI,GAAG;AAC5C;AAAA,MACF;AACA,YAAM,eAAgB,OAAM;AAC1B,cAAM,SACJ,EAAE,iBAAiB,IAAI,KAAK,EAAE,aAAa,KAAK,MAAM,KAAK,MAAM,KAAK,OAAO;AAC/E,YAAI,CAAC,QAAQ;AACX,iBAAO;AAAA,QACT;AACA,YAAI,EAAE,aAAa,GAAG,IAAI,GAAG;AAE3B,gBAAM,OAAO,GAAG,KAAK;AACrB,iBAAO,CAAC,oBAAoB,IAAI;AAAA,QAClC,WAAW,EAAE,gBAAgB,GAAG,IAAI,GAAG;AAErC,gBAAM,YAAY,GAAG,IAAI,YAAY;AACrC,iBAAO,UAAU,MAAM,CAAC,SAAS;AAC/B,gBAAI,CAAC,KAAK,iBAAiB;AAAG,qBAAO;AACrC,kBAAM,QAAQ,KAAK,IAAI,OAAO;AAC9B,gBAAI,MAAM,QAAQ,KAAK,KAAK,CAAC,MAAM,aAAa;AAAG,qBAAO;AAC1D,kBAAM,OAAO,MAAM,KAAK;AACxB,mBAAO,CAAC,oBAAoB,IAAI;AAAA,UAClC,CAAC;AAAA,QACH;AACA,eAAO;AAAA,MACT,GAAG;AACH,UAAI,cAAc;AAChB,mBAAW,OAAO;AAClB,YAAI,kBAAkB;AACpB,kBAAQ,IAAI,yBAAkB,SAAG,KAAK,YAAR,YAAmB,IAAI;AAAA,QACvD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
const timer = /* @__PURE__ */ __name(() => {
|
|
1
|
+
const timer = () => {
|
|
4
2
|
const start = Date.now();
|
|
5
3
|
let last = start;
|
|
6
4
|
return {
|
|
@@ -17,7 +15,7 @@ const timer = /* @__PURE__ */ __name(() => {
|
|
|
17
15
|
}
|
|
18
16
|
}
|
|
19
17
|
};
|
|
20
|
-
}
|
|
18
|
+
};
|
|
21
19
|
export {
|
|
22
20
|
timer
|
|
23
21
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/extractor/timer.ts"],
|
|
4
4
|
"sourcesContent": ["export const timer = () => {\n const start = Date.now()\n let last = start\n return {\n mark: (name: string, print = false) => {\n if (print) {\n const took = Date.now() - last\n last = Date.now()\n console.log(`Time ${name}: ${took}ms`)\n }\n },\n done: (print = false) => {\n if (print) {\n console.log(`Total time: ${Date.now() - start}ms`)\n }\n },\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "AAAO,MAAM,QAAQ,MAAM;AACzB,QAAM,QAAQ,KAAK,IAAI;AACvB,MAAI,OAAO;AACX,SAAO;AAAA,IACL,MAAM,CAAC,MAAc,QAAQ,UAAU;AACrC,UAAI,OAAO;AACT,cAAM,OAAO,KAAK,IAAI,IAAI;AAC1B,eAAO,KAAK,IAAI;AAChB,gBAAQ,IAAI,QAAQ,SAAS,QAAQ;AAAA,MACvC;AAAA,IACF;AAAA,IACA,MAAM,CAAC,QAAQ,UAAU;AACvB,UAAI,OAAO;AACT,gBAAQ,IAAI,eAAe,KAAK,IAAI,IAAI,SAAS;AAAA,MACnD;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { literalToAst } from "./extractor/literalToAst";
|
|
|
5
5
|
export * from "./constants";
|
|
6
6
|
export * from "./extractor/extractToClassNames";
|
|
7
7
|
export * from "./extractor/extractHelpers";
|
|
8
|
-
export * from "
|
|
8
|
+
export * from "@tamagui/patch-rnw";
|
|
9
9
|
export {
|
|
10
10
|
TamaguiOptions,
|
|
11
11
|
createExtractor,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["process.env.TAMAGUI_COMPILE_PROCESS = '1'\n\nexport { TamaguiOptions } from './types'\nexport { createExtractor } from './extractor/createExtractor'\nexport { literalToAst } from './extractor/literalToAst'\nexport * from './constants'\nexport * from './extractor/extractToClassNames'\nexport * from './extractor/extractHelpers'\nexport * from '
|
|
4
|
+
"sourcesContent": ["process.env.TAMAGUI_COMPILE_PROCESS = '1'\n\nexport { TamaguiOptions } from './types'\nexport { createExtractor } from './extractor/createExtractor'\nexport { literalToAst } from './extractor/literalToAst'\nexport * from './constants'\nexport * from './extractor/extractToClassNames'\nexport * from './extractor/extractHelpers'\nexport * from '@tamagui/patch-rnw'\n"],
|
|
5
5
|
"mappings": "AAAA,QAAQ,IAAI,0BAA0B;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import * as t from "@babel/types";
|
|
4
2
|
function accessSafe(obj, member) {
|
|
5
3
|
return t.logicalExpression("&&", t.logicalExpression("&&", t.binaryExpression("===", t.unaryExpression("typeof", obj), t.stringLiteral("object")), t.binaryExpression("!==", obj, t.nullLiteral())), t.memberExpression(obj, t.identifier(member), false));
|
|
6
4
|
}
|
|
7
|
-
__name(accessSafe, "accessSafe");
|
|
8
5
|
export {
|
|
9
6
|
accessSafe
|
|
10
7
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import * as babelParser from "@babel/parser";
|
|
4
2
|
const plugins = [
|
|
5
3
|
"asyncGenerators",
|
|
@@ -23,7 +21,6 @@ const parser = babelParser.parse.bind(babelParser);
|
|
|
23
21
|
function babelParse(code) {
|
|
24
22
|
return parser(code.toString(), parserOptions);
|
|
25
23
|
}
|
|
26
|
-
__name(babelParse, "babelParse");
|
|
27
24
|
export {
|
|
28
25
|
babelParse,
|
|
29
26
|
parserOptions
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import * as t from "@babel/types";
|
|
4
2
|
function buildClassName(classNameObjects) {
|
|
5
3
|
return classNameObjects.reduce((acc, val) => {
|
|
@@ -33,7 +31,6 @@ function buildClassName(classNameObjects) {
|
|
|
33
31
|
return t.binaryExpression("+", acc, inner);
|
|
34
32
|
}, null);
|
|
35
33
|
}
|
|
36
|
-
__name(buildClassName, "buildClassName");
|
|
37
34
|
export {
|
|
38
35
|
buildClassName
|
|
39
36
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import vm from "vm";
|
|
4
2
|
import generate from "@babel/generator";
|
|
5
3
|
import * as t from "@babel/types";
|
|
@@ -15,7 +13,7 @@ function createEvaluator({
|
|
|
15
13
|
traversePath,
|
|
16
14
|
shouldPrintDebug
|
|
17
15
|
}) {
|
|
18
|
-
const evalFn =
|
|
16
|
+
const evalFn = (n) => {
|
|
19
17
|
if (t.isMemberExpression(n) && t.isIdentifier(n.property) && traversePath && isValidThemeHook(traversePath, n, sourcePath)) {
|
|
20
18
|
const key = n.property.name;
|
|
21
19
|
if (shouldPrintDebug) {
|
|
@@ -34,12 +32,11 @@ function createEvaluator({
|
|
|
34
32
|
console.log("evaluating", code);
|
|
35
33
|
}
|
|
36
34
|
return vm.runInContext(code, evalContext);
|
|
37
|
-
}
|
|
35
|
+
};
|
|
38
36
|
return (n) => {
|
|
39
37
|
return evaluateAstNode(n, evalFn);
|
|
40
38
|
};
|
|
41
39
|
}
|
|
42
|
-
__name(createEvaluator, "createEvaluator");
|
|
43
40
|
function createSafeEvaluator(attemptEval) {
|
|
44
41
|
return (n) => {
|
|
45
42
|
try {
|
|
@@ -49,7 +46,6 @@ function createSafeEvaluator(attemptEval) {
|
|
|
49
46
|
}
|
|
50
47
|
};
|
|
51
48
|
}
|
|
52
|
-
__name(createSafeEvaluator, "createSafeEvaluator");
|
|
53
49
|
export {
|
|
54
50
|
createEvaluator,
|
|
55
51
|
createSafeEvaluator
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import { relative } from "path";
|
|
4
2
|
import traverse from "@babel/traverse";
|
|
5
3
|
import * as t from "@babel/types";
|
|
@@ -42,12 +40,12 @@ const INLINE_EXTRACTABLE = {
|
|
|
42
40
|
onPressIn: "onMouseDown",
|
|
43
41
|
onPressOut: "onMouseUp"
|
|
44
42
|
};
|
|
45
|
-
const isAttr =
|
|
43
|
+
const isAttr = (x) => x.type === "attr";
|
|
46
44
|
const validHooks = {
|
|
47
45
|
useMedia: true,
|
|
48
46
|
useTheme: true
|
|
49
47
|
};
|
|
50
|
-
const createTernary =
|
|
48
|
+
const createTernary = (x) => x;
|
|
51
49
|
function createExtractor() {
|
|
52
50
|
if (!process.env.TAMAGUI_TARGET) {
|
|
53
51
|
console.log('\u26A0\uFE0F Please set process.env.TAMAGUI_TARGET to either "web" or "native"');
|
|
@@ -60,7 +58,6 @@ function createExtractor() {
|
|
|
60
58
|
var _a;
|
|
61
59
|
return !!(!!((_a = staticConfig.validStyles) == null ? void 0 : _a[name]) || !!pseudos[name] || loadedTamaguiConfig.shorthands[name] || (name[0] === "$" ? !!mediaQueryConfig[name.slice(1)] : false));
|
|
62
60
|
}
|
|
63
|
-
__name(isValidStyleKey, "isValidStyleKey");
|
|
64
61
|
return {
|
|
65
62
|
getTamagui() {
|
|
66
63
|
return loadedTamaguiConfig;
|
|
@@ -117,9 +114,9 @@ function createExtractor() {
|
|
|
117
114
|
}
|
|
118
115
|
});
|
|
119
116
|
const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
|
|
120
|
-
const isInternalImport =
|
|
117
|
+
const isInternalImport = (importStr) => {
|
|
121
118
|
return isInsideTamagui(sourcePath) && importStr[0] === ".";
|
|
122
|
-
}
|
|
119
|
+
};
|
|
123
120
|
const validComponents = Object.keys(components).filter((key) => {
|
|
124
121
|
var _a;
|
|
125
122
|
return key[0].toUpperCase() === key[0] && !!((_a = components[key]) == null ? void 0 : _a.staticConfig);
|
|
@@ -172,9 +169,9 @@ function createExtractor() {
|
|
|
172
169
|
let couldntParse = false;
|
|
173
170
|
const modifiedComponents = /* @__PURE__ */ new Set();
|
|
174
171
|
const bindingCache = {};
|
|
175
|
-
const callTraverse =
|
|
172
|
+
const callTraverse = (a) => {
|
|
176
173
|
return fileOrPath.type === "File" ? traverse(fileOrPath, a) : fileOrPath.traverse(a);
|
|
177
|
-
}
|
|
174
|
+
};
|
|
178
175
|
let programPath;
|
|
179
176
|
const res = {
|
|
180
177
|
styled: 0,
|
|
@@ -405,9 +402,9 @@ function createExtractor() {
|
|
|
405
402
|
return [attribute.value, path.get("value")];
|
|
406
403
|
}
|
|
407
404
|
})();
|
|
408
|
-
const remove =
|
|
405
|
+
const remove = () => {
|
|
409
406
|
Array.isArray(valuePath) ? valuePath.map((p) => p.remove()) : valuePath.remove();
|
|
410
|
-
}
|
|
407
|
+
};
|
|
411
408
|
if (name === "ref") {
|
|
412
409
|
if (shouldPrintDebug) {
|
|
413
410
|
console.log(" ! inlining, ref", name);
|
|
@@ -579,7 +576,6 @@ function createExtractor() {
|
|
|
579
576
|
}
|
|
580
577
|
return null;
|
|
581
578
|
}
|
|
582
|
-
__name(addBinaryConditional, "addBinaryConditional");
|
|
583
579
|
function getStaticConditional(value2) {
|
|
584
580
|
if (t.isConditionalExpression(value2)) {
|
|
585
581
|
try {
|
|
@@ -603,7 +599,6 @@ function createExtractor() {
|
|
|
603
599
|
}
|
|
604
600
|
return null;
|
|
605
601
|
}
|
|
606
|
-
__name(getStaticConditional, "getStaticConditional");
|
|
607
602
|
function getStaticLogical(value2) {
|
|
608
603
|
if (t.isLogicalExpression(value2)) {
|
|
609
604
|
if (value2.operator === "&&") {
|
|
@@ -627,7 +622,6 @@ function createExtractor() {
|
|
|
627
622
|
}
|
|
628
623
|
return null;
|
|
629
624
|
}
|
|
630
|
-
__name(getStaticLogical, "getStaticLogical");
|
|
631
625
|
}, isExtractable = function(obj) {
|
|
632
626
|
return t.isObjectExpression(obj) && obj.properties.every((prop) => {
|
|
633
627
|
if (!t.isObjectProperty(prop)) {
|
|
@@ -738,11 +732,6 @@ function createExtractor() {
|
|
|
738
732
|
}
|
|
739
733
|
}
|
|
740
734
|
};
|
|
741
|
-
__name(evaluateAttribute, "evaluateAttribute");
|
|
742
|
-
__name(isExtractable, "isExtractable");
|
|
743
|
-
__name(createTernariesFromObjectProperties, "createTernariesFromObjectProperties");
|
|
744
|
-
__name(mergeStyles, "mergeStyles");
|
|
745
|
-
__name(omitInvalidStyles, "omitInvalidStyles");
|
|
746
735
|
node.attributes.find((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
|
|
747
736
|
if (shouldPrintDebug) {
|
|
748
737
|
console.log("\n");
|
|
@@ -1158,7 +1147,7 @@ function createExtractor() {
|
|
|
1158
1147
|
console.log(" - foundStaticProps: \n", logLines(objToStr(foundStaticProps)));
|
|
1159
1148
|
console.log(" - completeProps: \n", logLines(objToStr(completeProps)));
|
|
1160
1149
|
}
|
|
1161
|
-
const getStyles =
|
|
1150
|
+
const getStyles = (props2, debugName = "") => {
|
|
1162
1151
|
if (!props2 || !Object.keys(props2).length) {
|
|
1163
1152
|
if (shouldPrintDebug)
|
|
1164
1153
|
console.log(" getStyles() no props");
|
|
@@ -1187,7 +1176,7 @@ function createExtractor() {
|
|
|
1187
1176
|
console.log("error", err.message, err.stack);
|
|
1188
1177
|
return {};
|
|
1189
1178
|
}
|
|
1190
|
-
}
|
|
1179
|
+
};
|
|
1191
1180
|
const completeStyles = getStyles(completeProps, "completeStyles");
|
|
1192
1181
|
if (!completeStyles) {
|
|
1193
1182
|
throw new Error(`Impossible, no styles`);
|
|
@@ -1343,7 +1332,6 @@ function createExtractor() {
|
|
|
1343
1332
|
}
|
|
1344
1333
|
};
|
|
1345
1334
|
}
|
|
1346
|
-
__name(createExtractor, "createExtractor");
|
|
1347
1335
|
export {
|
|
1348
1336
|
createExtractor
|
|
1349
1337
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import * as t from "@babel/types";
|
|
4
2
|
import { CONCAT_CLASSNAME_IMPORT } from "../constants";
|
|
5
3
|
const importConcatPkg = "@tamagui/helpers";
|
|
@@ -17,7 +15,6 @@ function ensureImportingConcat(path) {
|
|
|
17
15
|
specifiers.push(t.importSpecifier(t.identifier(CONCAT_CLASSNAME_IMPORT), t.identifier(CONCAT_CLASSNAME_IMPORT)));
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
|
-
__name(ensureImportingConcat, "ensureImportingConcat");
|
|
21
18
|
export {
|
|
22
19
|
ensureImportingConcat
|
|
23
20
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import * as t from "@babel/types";
|
|
4
2
|
function evaluateAstNode(exprNode, evalFn, shouldPrintDebug) {
|
|
5
3
|
if (exprNode === void 0) {
|
|
@@ -87,7 +85,6 @@ function evaluateAstNode(exprNode, evalFn, shouldPrintDebug) {
|
|
|
87
85
|
}
|
|
88
86
|
return evalFn(exprNode);
|
|
89
87
|
}
|
|
90
|
-
__name(evaluateAstNode, "evaluateAstNode");
|
|
91
88
|
export {
|
|
92
89
|
evaluateAstNode
|
|
93
90
|
};
|
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import generate from "@babel/generator";
|
|
4
2
|
import * as t from "@babel/types";
|
|
5
3
|
function isPresent(input) {
|
|
6
4
|
return input != null;
|
|
7
5
|
}
|
|
8
|
-
__name(isPresent, "isPresent");
|
|
9
6
|
function isSimpleSpread(node) {
|
|
10
7
|
return t.isIdentifier(node.argument) || t.isMemberExpression(node.argument);
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
const attrStr = /* @__PURE__ */ __name((attr) => {
|
|
9
|
+
const attrStr = (attr) => {
|
|
14
10
|
return !attr ? "" : attr.type === "attr" ? getNameAttr(attr.value) : attr.type === "ternary" ? `...${ternaryStr(attr.value)}` : `${attr.type}(${objToStr(attr.value)})`;
|
|
15
|
-
}
|
|
16
|
-
const objToStr =
|
|
11
|
+
};
|
|
12
|
+
const objToStr = (obj, spacer = ", ") => {
|
|
17
13
|
if (!obj) {
|
|
18
14
|
return `${obj}`;
|
|
19
15
|
}
|
|
20
16
|
return `{${Object.entries(obj).map(([k, v]) => `${k}:${Array.isArray(v) ? `[...]` : v && typeof v === "object" ? `${objToStr(v, ",")}` : JSON.stringify(v)}`).join(spacer)}}`;
|
|
21
|
-
}
|
|
22
|
-
const getNameAttr =
|
|
17
|
+
};
|
|
18
|
+
const getNameAttr = (attr) => {
|
|
23
19
|
if (t.isJSXSpreadAttribute(attr)) {
|
|
24
20
|
return `...${attr.argument["name"]}`;
|
|
25
21
|
}
|
|
26
22
|
return "name" in attr ? attr.name.name : `unknown-${attr["type"]}`;
|
|
27
|
-
}
|
|
28
|
-
const ternaryStr =
|
|
23
|
+
};
|
|
24
|
+
const ternaryStr = (x) => {
|
|
29
25
|
const conditional = t.isIdentifier(x.test) ? x.test.name : t.isMemberExpression(x.test) ? [x.test.object["name"], x.test.property["name"]] : generate(x.test).code;
|
|
30
26
|
return [
|
|
31
27
|
"ternary(",
|
|
@@ -34,8 +30,8 @@ const ternaryStr = /* @__PURE__ */ __name((x) => {
|
|
|
34
30
|
isFilledObj(x.alternate) ? ` : ${objToStr(x.alternate)}` : " : \u{1F6AB}",
|
|
35
31
|
")"
|
|
36
32
|
].flat().join("");
|
|
37
|
-
}
|
|
38
|
-
const isFilledObj =
|
|
33
|
+
};
|
|
34
|
+
const isFilledObj = (obj) => obj && Object.keys(obj).length;
|
|
39
35
|
function findComponentName(scope) {
|
|
40
36
|
var _a;
|
|
41
37
|
let componentName = "";
|
|
@@ -58,7 +54,6 @@ function findComponentName(scope) {
|
|
|
58
54
|
}
|
|
59
55
|
return componentName;
|
|
60
56
|
}
|
|
61
|
-
__name(findComponentName, "findComponentName");
|
|
62
57
|
function isValidThemeHook(jsxPath, n, sourcePath) {
|
|
63
58
|
var _a;
|
|
64
59
|
if (!t.isIdentifier(n.object) || !t.isIdentifier(n.property))
|
|
@@ -86,10 +81,9 @@ function isValidThemeHook(jsxPath, n, sourcePath) {
|
|
|
86
81
|
}
|
|
87
82
|
return true;
|
|
88
83
|
}
|
|
89
|
-
|
|
90
|
-
const isInsideTamagui = /* @__PURE__ */ __name((srcName) => {
|
|
84
|
+
const isInsideTamagui = (srcName) => {
|
|
91
85
|
return srcName.includes("/dist/jsx") || srcName.includes("/core/src");
|
|
92
|
-
}
|
|
86
|
+
};
|
|
93
87
|
export {
|
|
94
88
|
attrStr,
|
|
95
89
|
findComponentName,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import * as t from "@babel/types";
|
|
4
2
|
import { getStylesAtomic, mediaObjectToString } from "@tamagui/core-node";
|
|
5
3
|
import { MEDIA_SEP } from "../constants";
|
|
@@ -15,9 +13,9 @@ function extractMediaStyle(ternary, jsxPath, tamaguiConfig, sourcePath, importan
|
|
|
15
13
|
console.error(`Media query "${key}" not found: ${Object.keys(tamaguiConfig.media)}`);
|
|
16
14
|
return null;
|
|
17
15
|
}
|
|
18
|
-
const getStyleObj =
|
|
16
|
+
const getStyleObj = (styleObj, negate = false) => {
|
|
19
17
|
return styleObj ? { styleObj, negate } : null;
|
|
20
|
-
}
|
|
18
|
+
};
|
|
21
19
|
const styleOpts = [
|
|
22
20
|
getStyleObj(ternary.consequent, false),
|
|
23
21
|
getStyleObj(ternary.alternate, true)
|
|
@@ -65,7 +63,6 @@ function extractMediaStyle(ternary, jsxPath, tamaguiConfig, sourcePath, importan
|
|
|
65
63
|
ternary.remove();
|
|
66
64
|
return { mediaStyles, ternaryWithoutMedia: mt.ternaryWithoutMedia };
|
|
67
65
|
}
|
|
68
|
-
__name(extractMediaStyle, "extractMediaStyle");
|
|
69
66
|
function getMediaQueryTernary(ternary, jsxPath, sourcePath) {
|
|
70
67
|
if (t.isLogicalExpression(ternary.test) && ternary.test.operator === "&&") {
|
|
71
68
|
const mediaLeft = getMediaInfoFromExpression(ternary.test.left, jsxPath, sourcePath, ternary.inlineMediaQuery);
|
|
@@ -88,7 +85,6 @@ function getMediaQueryTernary(ternary, jsxPath, sourcePath) {
|
|
|
88
85
|
}
|
|
89
86
|
return null;
|
|
90
87
|
}
|
|
91
|
-
__name(getMediaQueryTernary, "getMediaQueryTernary");
|
|
92
88
|
function getMediaInfoFromExpression(test, jsxPath, sourcePath, inlineMediaQuery) {
|
|
93
89
|
var _a, _b, _c;
|
|
94
90
|
if (inlineMediaQuery) {
|
|
@@ -122,7 +118,6 @@ function getMediaInfoFromExpression(test, jsxPath, sourcePath, inlineMediaQuery)
|
|
|
122
118
|
}
|
|
123
119
|
return null;
|
|
124
120
|
}
|
|
125
|
-
__name(getMediaInfoFromExpression, "getMediaInfoFromExpression");
|
|
126
121
|
function isValidMediaCall(jsxPath, init, sourcePath) {
|
|
127
122
|
if (!t.isCallExpression(init))
|
|
128
123
|
return false;
|
|
@@ -144,7 +139,6 @@ function isValidMediaCall(jsxPath, init, sourcePath) {
|
|
|
144
139
|
}
|
|
145
140
|
return true;
|
|
146
141
|
}
|
|
147
|
-
__name(isValidMediaCall, "isValidMediaCall");
|
|
148
142
|
export {
|
|
149
143
|
extractMediaStyle,
|
|
150
144
|
isValidMediaCall
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import * as path from "path";
|
|
4
2
|
import { basename } from "path";
|
|
5
3
|
import * as util from "util";
|
|
@@ -25,15 +23,11 @@ const mergeStyleGroups = {
|
|
|
25
23
|
shadowOffset: true
|
|
26
24
|
};
|
|
27
25
|
function extractToClassNames({
|
|
28
|
-
loader,
|
|
29
26
|
extractor,
|
|
30
27
|
source,
|
|
31
28
|
sourcePath,
|
|
32
29
|
options,
|
|
33
|
-
shouldPrintDebug
|
|
34
|
-
cssLoaderPath,
|
|
35
|
-
threaded,
|
|
36
|
-
cssPath
|
|
30
|
+
shouldPrintDebug
|
|
37
31
|
}) {
|
|
38
32
|
var _a;
|
|
39
33
|
const tm = timer();
|
|
@@ -94,7 +88,7 @@ function extractToClassNames({
|
|
|
94
88
|
};
|
|
95
89
|
}
|
|
96
90
|
}
|
|
97
|
-
const ensureNeededPrevStyle =
|
|
91
|
+
const ensureNeededPrevStyle = (style) => {
|
|
98
92
|
var _a3;
|
|
99
93
|
const keys = Object.keys(style);
|
|
100
94
|
if (!keys.some((key) => mergeStyleGroups[key])) {
|
|
@@ -106,8 +100,8 @@ function extractToClassNames({
|
|
|
106
100
|
}
|
|
107
101
|
}
|
|
108
102
|
return style;
|
|
109
|
-
}
|
|
110
|
-
const addStyles =
|
|
103
|
+
};
|
|
104
|
+
const addStyles = (style) => {
|
|
111
105
|
if (!style)
|
|
112
106
|
return [];
|
|
113
107
|
const styleWithPrev = ensureNeededPrevStyle(style);
|
|
@@ -116,7 +110,7 @@ function extractToClassNames({
|
|
|
116
110
|
finalStyles = [...finalStyles, ...res2];
|
|
117
111
|
}
|
|
118
112
|
return res2;
|
|
119
|
-
}
|
|
113
|
+
};
|
|
120
114
|
let lastMediaImportance = 1;
|
|
121
115
|
for (const attr of attrs) {
|
|
122
116
|
switch (attr.type) {
|
|
@@ -196,7 +190,6 @@ function extractToClassNames({
|
|
|
196
190
|
finalClassNames.push(t.conditionalExpression(ternary.test, t.stringLiteral(" " + cCN), t.stringLiteral(" " + aCN)));
|
|
197
191
|
}
|
|
198
192
|
}
|
|
199
|
-
__name(addTernaryStyle, "addTernaryStyle");
|
|
200
193
|
if (shouldPrintDebug) {
|
|
201
194
|
console.log(" finalClassNames\n", logLines(finalClassNames.map((x) => x["value"]).join(" ")));
|
|
202
195
|
}
|
|
@@ -250,12 +243,6 @@ function extractToClassNames({
|
|
|
250
243
|
return null;
|
|
251
244
|
}
|
|
252
245
|
const styles = Array.from(cssMap.values()).map((x) => x.css).join("\n").trim();
|
|
253
|
-
if (styles) {
|
|
254
|
-
const cssQuery = threaded ? `cssData=${Buffer.from(styles).toString("base64")}` : `cssPath=${cssPath}`;
|
|
255
|
-
const remReq = loader.remainingRequest;
|
|
256
|
-
const importPath = `${cssPath}!=!${cssLoaderPath}?${cssQuery}!${remReq}`;
|
|
257
|
-
ast.program.body.unshift(t.importDeclaration([], t.stringLiteral(importPath)));
|
|
258
|
-
}
|
|
259
246
|
const result = generate(ast, {
|
|
260
247
|
concise: false,
|
|
261
248
|
filename: sourcePath,
|
|
@@ -289,7 +276,6 @@ function extractToClassNames({
|
|
|
289
276
|
map: result.map
|
|
290
277
|
};
|
|
291
278
|
}
|
|
292
|
-
__name(extractToClassNames, "extractToClassNames");
|
|
293
279
|
export {
|
|
294
280
|
extractToClassNames
|
|
295
281
|
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
function findTopmostFunction(jsxPath) {
|
|
4
|
-
const isFunction =
|
|
2
|
+
const isFunction = (path) => path.isArrowFunctionExpression() || path.isFunctionDeclaration() || path.isFunctionExpression();
|
|
5
3
|
let compFn = jsxPath.findParent(isFunction);
|
|
6
4
|
while (compFn) {
|
|
7
5
|
const parent = compFn.findParent(isFunction);
|
|
@@ -16,7 +14,6 @@ function findTopmostFunction(jsxPath) {
|
|
|
16
14
|
}
|
|
17
15
|
return compFn;
|
|
18
16
|
}
|
|
19
|
-
__name(findTopmostFunction, "findTopmostFunction");
|
|
20
17
|
export {
|
|
21
18
|
findTopmostFunction
|
|
22
19
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
1
|
import * as t from "@babel/types";
|
|
4
2
|
import invariant from "invariant";
|
|
5
3
|
function generateUid(scope, name) {
|
|
@@ -21,7 +19,6 @@ function generateUid(scope, name) {
|
|
|
21
19
|
program.uids[uid] = true;
|
|
22
20
|
return uid;
|
|
23
21
|
}
|
|
24
|
-
__name(generateUid, "generateUid");
|
|
25
22
|
export {
|
|
26
23
|
generateUid
|
|
27
24
|
};
|