@tamagui/static 1.0.1-beta.107 → 1.0.1-beta.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants.js +1 -0
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/extractor/accessSafe.js +1 -0
- package/dist/cjs/extractor/accessSafe.js.map +1 -1
- package/dist/cjs/extractor/babelParse.js +1 -0
- package/dist/cjs/extractor/babelParse.js.map +1 -1
- package/dist/cjs/extractor/buildClassName.js +1 -0
- package/dist/cjs/extractor/buildClassName.js.map +1 -1
- package/dist/cjs/extractor/createEvaluator.js +1 -0
- package/dist/cjs/extractor/createEvaluator.js.map +1 -1
- package/dist/cjs/extractor/createExtractor.js +77 -109
- package/dist/cjs/extractor/createExtractor.js.map +1 -1
- package/dist/cjs/extractor/defaultTamaguiConfig.js +5 -15
- package/dist/cjs/extractor/defaultTamaguiConfig.js.map +1 -1
- package/dist/cjs/extractor/ensureImportingConcat.js +1 -0
- package/dist/cjs/extractor/ensureImportingConcat.js.map +1 -1
- package/dist/cjs/extractor/evaluateAstNode.js +1 -0
- package/dist/cjs/extractor/evaluateAstNode.js.map +1 -1
- package/dist/cjs/extractor/extractHelpers.js +1 -0
- package/dist/cjs/extractor/extractHelpers.js.map +1 -1
- package/dist/cjs/extractor/extractMediaStyle.js +13 -25
- package/dist/cjs/extractor/extractMediaStyle.js.map +1 -1
- package/dist/cjs/extractor/extractToClassNames.js +9 -22
- package/dist/cjs/extractor/extractToClassNames.js.map +1 -1
- package/dist/cjs/extractor/findTopmostFunction.js +1 -0
- package/dist/cjs/extractor/findTopmostFunction.js.map +1 -1
- package/dist/cjs/extractor/generatedUid.js +1 -0
- package/dist/cjs/extractor/generatedUid.js.map +1 -1
- package/dist/cjs/extractor/getPrefixLogs.js +1 -0
- package/dist/cjs/extractor/getPrefixLogs.js.map +1 -1
- package/dist/cjs/extractor/getPropValueFromAttributes.js +1 -0
- package/dist/cjs/extractor/getPropValueFromAttributes.js.map +1 -1
- package/dist/cjs/extractor/getSourceModule.js +1 -0
- package/dist/cjs/extractor/getSourceModule.js.map +1 -1
- package/dist/cjs/extractor/getStaticBindingsForScope.js +1 -0
- package/dist/cjs/extractor/getStaticBindingsForScope.js.map +1 -1
- package/dist/cjs/extractor/hoistClassNames.js +1 -0
- package/dist/cjs/extractor/hoistClassNames.js.map +1 -1
- package/dist/cjs/extractor/literalToAst.js +8 -20
- package/dist/cjs/extractor/literalToAst.js.map +1 -1
- package/dist/cjs/extractor/loadTamagui.js +2 -15
- package/dist/cjs/extractor/loadTamagui.js.map +1 -1
- package/dist/cjs/extractor/logLines.js +1 -0
- package/dist/cjs/extractor/logLines.js.map +1 -1
- package/dist/cjs/extractor/normalizeTernaries.js +5 -32
- package/dist/cjs/extractor/normalizeTernaries.js.map +1 -1
- package/dist/cjs/extractor/removeUnusedHooks.js +1 -0
- package/dist/cjs/extractor/removeUnusedHooks.js.map +1 -1
- package/dist/cjs/extractor/timer.js +1 -0
- package/dist/cjs/extractor/timer.js.map +1 -1
- package/dist/cjs/extractor/validHTMLAttributes.js +1 -0
- package/dist/cjs/extractor/validHTMLAttributes.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/require.js +1 -0
- package/dist/cjs/require.js.map +1 -1
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/extractor/createExtractor.js +76 -111
- package/dist/esm/extractor/createExtractor.js.map +1 -1
- package/dist/esm/extractor/defaultTamaguiConfig.js +4 -17
- package/dist/esm/extractor/defaultTamaguiConfig.js.map +1 -1
- package/dist/esm/extractor/extractMediaStyle.js +12 -27
- package/dist/esm/extractor/extractMediaStyle.js.map +1 -1
- package/dist/esm/extractor/extractToClassNames.js +8 -24
- package/dist/esm/extractor/extractToClassNames.js.map +1 -1
- package/dist/esm/extractor/literalToAst.js +7 -22
- package/dist/esm/extractor/literalToAst.js.map +1 -1
- package/dist/esm/extractor/loadTamagui.js +1 -16
- package/dist/esm/extractor/loadTamagui.js.map +1 -1
- package/dist/esm/extractor/normalizeTernaries.js +4 -34
- package/dist/esm/extractor/normalizeTernaries.js.map +1 -1
- package/dist/jsx/extractor/createExtractor.js +13 -12
- package/dist/jsx/extractor/createExtractor.js.map +1 -1
- package/package.json +11 -11
- package/types/constants.d.ts +0 -7
- package/types/constants.d.ts.map +0 -1
- package/types/extractor/accessSafe.d.ts +0 -3
- package/types/extractor/accessSafe.d.ts.map +0 -1
- package/types/extractor/babelParse.d.ts +0 -5
- package/types/extractor/babelParse.d.ts.map +0 -1
- package/types/extractor/ensureImportingConcat.d.ts +0 -4
- package/types/extractor/ensureImportingConcat.d.ts.map +0 -1
- package/types/extractor/evaluateAstNode.d.ts +0 -3
- package/types/extractor/evaluateAstNode.d.ts.map +0 -1
- package/types/extractor/findTopmostFunction.d.ts +0 -4
- package/types/extractor/findTopmostFunction.d.ts.map +0 -1
- package/types/extractor/generatedUid.d.ts +0 -5
- package/types/extractor/generatedUid.d.ts.map +0 -1
- package/types/extractor/getPropValueFromAttributes.d.ts +0 -3
- package/types/extractor/getPropValueFromAttributes.d.ts.map +0 -1
- package/types/extractor/getSourceModule.d.ts +0 -16
- package/types/extractor/getSourceModule.d.ts.map +0 -1
- package/types/extractor/getStaticBindingsForScope.d.ts +0 -4
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
- package/types/extractor/hoistClassNames.d.ts +0 -6
- package/types/extractor/hoistClassNames.d.ts.map +0 -1
- package/types/extractor/literalToAst.d.ts +0 -4
- package/types/extractor/literalToAst.d.ts.map +0 -1
- package/types/extractor/logLines.d.ts +0 -2
- package/types/extractor/logLines.d.ts.map +0 -1
- package/types/extractor/removeUnusedHooks.d.ts +0 -3
- package/types/extractor/removeUnusedHooks.d.ts.map +0 -1
- package/types/extractor/timer.d.ts +0 -5
- package/types/extractor/timer.d.ts.map +0 -1
- package/types/extractor/validHTMLAttributes.d.ts +0 -98
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
package/dist/cjs/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
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'\nexport * from './extractor/loadTamagui'\nexport * from './require'\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA+B;AAC/B,6BAAgC;AAChC,0BAA6B;AAC7B,wBAAc,wBALd;AAMA,wBAAc,4CANd;AAOA,wBAAc,uCAPd;AAQA,wBAAc,+BARd;AASA,wBAAc,oCATd;AAUA,wBAAc,sBAVd;AAAA,QAAQ,IAAI,0BAA0B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/require.js
CHANGED
package/dist/cjs/require.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/require.ts"],
|
|
4
4
|
"sourcesContent": ["import { join } from 'path'\n\nimport type { StaticConfig } from '@tamagui/core-node'\n\nimport { SHOULD_DEBUG } from './constants'\n\nconst nameToPaths = {}\nconst Mod = require('module')\nconst og = Mod.prototype.require\nglobalThis['ogRequire'] = og\n\nexport const getNameToPaths = () => nameToPaths\n\nlet tries = 0\nsetInterval(() => {\n tries = 0\n}, 500)\n\nexport function registerRequire() {\n if (Mod.prototype.require !== globalThis['ogRequire']) {\n console.warn('didnt unregister before re-registering')\n process.exit(1)\n }\n\n const proxyWorm = require('@tamagui/proxy-worm')\n const rnw = require('react-native-web')\n\n Mod.prototype.require = function (path: string) {\n if (SHOULD_DEBUG) {\n console.log('tamagui require', path)\n }\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 // return og('react-native-web')\n }\n try {\n const out = og.apply(this, arguments)\n if (!nameToPaths[path]) {\n if (out && typeof out === 'object') {\n for (const key in out) {\n try {\n const conf = out[key]?.staticConfig as StaticConfig\n if (conf) {\n if (conf.componentName) {\n nameToPaths[conf.componentName] ??= new Set()\n const fullName = path.startsWith('.')\n ? join(`${this.path.replace(/dist(\\/cjs)?/, 'src')}`, path)\n : path\n nameToPaths[conf.componentName].add(fullName)\n } else {\n // console.log('no name component', path)\n }\n }\n } catch {\n // ok\n }\n }\n }\n }\n return out\n } catch (err: any) {\n console.error(\n `Tamagui failed requiring ${path} from your tamagui.config.ts file, ignoring (set DEBUG=tamagui to see stack)\\n`,\n err.message\n )\n if (SHOULD_DEBUG) {\n console.log(err.stack)\n }\n if (++tries > 10) {\n // avoid infinite loops\n process.exit(1)\n }\n }\n }\n}\n\nexport function unregisterRequire() {\n Mod.prototype.require = og\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAIrB,uBAA6B;AAE7B,MAAM,cAAc,CAAC;AACrB,MAAM,MAAM,QAAQ,QAAQ;AAC5B,MAAM,KAAK,IAAI,UAAU;AACzB,WAAW,eAAe;AAEnB,MAAM,iBAAiB,MAAM;AAEpC,IAAI,QAAQ;AACZ,YAAY,MAAM;AAChB,UAAQ;AACV,GAAG,GAAG;AAEC,2BAA2B;AAChC,MAAI,IAAI,UAAU,YAAY,WAAW,cAAc;AACrD,YAAQ,KAAK,wCAAwC;AACrD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,YAAY,QAAQ,qBAAqB;AAC/C,QAAM,MAAM,QAAQ,kBAAkB;AAEtC,MAAI,UAAU,UAAU,SAAU,MAAc;AA3BlD;AA4BI,QAAI,+BAAc;AAChB,cAAQ,IAAI,mBAAmB,IAAI;AAAA,IACrC;AACA,QAAI,KAAK,SAAS,MAAM,GAAG;AACzB,aAAO,CAAC;AAAA,IACV;AACA,QACE,SAAS,0BACT,KAAK,WAAW,yBAAyB,KACzC,SAAS,wBACT;AACA,aAAO;AAAA,IACT;AACA,QACE,KAAK,WAAW,cAAc,KAE9B,CAAC,KAAK,WAAW,mCAAmC,GACpD;AACA,aAAO;AAAA,IAET;AACA,QAAI;AACF,YAAM,MAAM,GAAG,MAAM,MAAM,SAAS;AACpC,UAAI,CAAC,YAAY,OAAO;AACtB,YAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,qBAAW,OAAO,KAAK;AACrB,gBAAI;AACF,oBAAM,OAAO,UAAI,SAAJ,mBAAU;AACvB,kBAAI,MAAM;AACR,oBAAI,KAAK,eAAe;AACtB,mCAAY,KAAK,kBAAjB,mBAAoC,oBAAI,IAAI;AAC5C,wBAAM,WAAW,KAAK,WAAW,GAAG,IAChC,sBAAK,GAAG,KAAK,KAAK,QAAQ,gBAAgB,KAAK,KAAK,IAAI,IACxD;AACJ,8BAAY,KAAK,eAAe,IAAI,QAAQ;AAAA,gBAC9C,OAAO;AAAA,gBAEP;AAAA,cACF;AAAA,YACF,QAAE;AAAA,YAEF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT,SAAS,KAAP;AACA,cAAQ,MACN,4BAA4B;AAAA,GAC5B,IAAI,OACN;AACA,UAAI,+BAAc;AAChB,gBAAQ,IAAI,IAAI,KAAK;AAAA,MACvB;AACA,UAAI,EAAE,QAAQ,IAAI;AAEhB,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACF;AAEO,6BAA6B;AAClC,MAAI,UAAU,UAAU;AAC1B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/types.js
CHANGED
package/dist/cjs/types.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types.ts"],
|
|
4
4
|
"sourcesContent": ["import { NodePath } from '@babel/traverse'\nimport * as t from '@babel/types'\nimport { PseudoStyles } from '@tamagui/core-node'\nimport { StyleObject } from '@tamagui/core-node'\nimport { 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 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}\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": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,34 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
1
|
import { relative } from "path";
|
|
33
2
|
import traverse from "@babel/traverse";
|
|
34
3
|
import * as t from "@babel/types";
|
|
@@ -90,44 +59,26 @@ function createExtractor() {
|
|
|
90
59
|
getTamagui() {
|
|
91
60
|
return loadedTamaguiConfig;
|
|
92
61
|
},
|
|
93
|
-
parse: (fileOrPath,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
"config",
|
|
114
|
-
"importsWhitelist",
|
|
115
|
-
"evaluateVars",
|
|
116
|
-
"shouldPrintDebug",
|
|
117
|
-
"sourcePath",
|
|
118
|
-
"onExtractTag",
|
|
119
|
-
"onStyleRule",
|
|
120
|
-
"getFlattenedNode",
|
|
121
|
-
"disable",
|
|
122
|
-
"disableExtraction",
|
|
123
|
-
"disableExtractInlineMedia",
|
|
124
|
-
"disableExtractVariables",
|
|
125
|
-
"disableDebugAttr",
|
|
126
|
-
"extractStyledDefinitions",
|
|
127
|
-
"prefixLogs",
|
|
128
|
-
"excludeProps",
|
|
129
|
-
"target"
|
|
130
|
-
]);
|
|
62
|
+
parse: (fileOrPath, {
|
|
63
|
+
config = "tamagui.config.ts",
|
|
64
|
+
importsWhitelist = ["constants.js"],
|
|
65
|
+
evaluateVars = true,
|
|
66
|
+
shouldPrintDebug = false,
|
|
67
|
+
sourcePath = "",
|
|
68
|
+
onExtractTag,
|
|
69
|
+
onStyleRule,
|
|
70
|
+
getFlattenedNode,
|
|
71
|
+
disable,
|
|
72
|
+
disableExtraction,
|
|
73
|
+
disableExtractInlineMedia,
|
|
74
|
+
disableExtractVariables,
|
|
75
|
+
disableDebugAttr,
|
|
76
|
+
extractStyledDefinitions = false,
|
|
77
|
+
prefixLogs,
|
|
78
|
+
excludeProps,
|
|
79
|
+
target,
|
|
80
|
+
...props
|
|
81
|
+
}) => {
|
|
131
82
|
if (disable) {
|
|
132
83
|
return null;
|
|
133
84
|
}
|
|
@@ -164,8 +115,8 @@ function createExtractor() {
|
|
|
164
115
|
return isInsideTamagui(sourcePath) && importStr[0] === ".";
|
|
165
116
|
};
|
|
166
117
|
const validComponents = Object.keys(components).filter((key) => {
|
|
167
|
-
var
|
|
168
|
-
return key[0].toUpperCase() === key[0] && !!((
|
|
118
|
+
var _a;
|
|
119
|
+
return key[0].toUpperCase() === key[0] && !!((_a = components[key]) == null ? void 0 : _a.staticConfig);
|
|
169
120
|
}).reduce((obj, name) => {
|
|
170
121
|
obj[name] = components[name];
|
|
171
122
|
return obj;
|
|
@@ -233,7 +184,7 @@ function createExtractor() {
|
|
|
233
184
|
}
|
|
234
185
|
},
|
|
235
186
|
CallExpression(path) {
|
|
236
|
-
var
|
|
187
|
+
var _a;
|
|
237
188
|
if (disable || disableExtraction || extractStyledDefinitions === false) {
|
|
238
189
|
return;
|
|
239
190
|
}
|
|
@@ -272,7 +223,7 @@ function createExtractor() {
|
|
|
272
223
|
});
|
|
273
224
|
const attemptEvalSafe = createSafeEvaluator(attemptEval);
|
|
274
225
|
for (const property of definition.properties) {
|
|
275
|
-
if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || ((
|
|
226
|
+
if (!t.isObjectProperty(property) || !t.isIdentifier(property.key) || !isValidStyleKey(property.key.name, Component.staticConfig) || ((_a = Component.staticConfig.variants) == null ? void 0 : _a[property.key.name]) || componentSkipProps.has(property.key.name)) {
|
|
276
227
|
skipped.push(property);
|
|
277
228
|
continue;
|
|
278
229
|
}
|
|
@@ -291,7 +242,9 @@ function createExtractor() {
|
|
|
291
242
|
pressIn: false,
|
|
292
243
|
resolveVariablesAs: "variable"
|
|
293
244
|
});
|
|
294
|
-
const classNames =
|
|
245
|
+
const classNames = {
|
|
246
|
+
...out.classNames
|
|
247
|
+
};
|
|
295
248
|
const atomics = getStylesAtomic(out.style);
|
|
296
249
|
if (shouldPrintDebug) {
|
|
297
250
|
console.log("Exctacting styled()", styles, out, "to", atomics);
|
|
@@ -320,7 +273,7 @@ function createExtractor() {
|
|
|
320
273
|
}
|
|
321
274
|
},
|
|
322
275
|
JSXElement(traversePath) {
|
|
323
|
-
var
|
|
276
|
+
var _a, _b, _c;
|
|
324
277
|
tm.mark("jsx-element", shouldPrintDebug === "verbose");
|
|
325
278
|
const node = traversePath.node.openingElement;
|
|
326
279
|
const ogAttributes = node.attributes;
|
|
@@ -362,7 +315,7 @@ function createExtractor() {
|
|
|
362
315
|
shouldPrintDebug = debugPropValue;
|
|
363
316
|
}
|
|
364
317
|
try {
|
|
365
|
-
let
|
|
318
|
+
let evaluateAttribute2 = function(path) {
|
|
366
319
|
const attribute = path.node;
|
|
367
320
|
const attr = { type: "attr", value: attribute };
|
|
368
321
|
if (t.isJSXSpreadAttribute(attribute)) {
|
|
@@ -372,15 +325,15 @@ function createExtractor() {
|
|
|
372
325
|
const [test, alt, cons] = conditional;
|
|
373
326
|
if (!test)
|
|
374
327
|
throw new Error(`no test`);
|
|
375
|
-
if ([alt, cons].some((side) => side && !
|
|
328
|
+
if ([alt, cons].some((side) => side && !isExtractable2(side))) {
|
|
376
329
|
if (shouldPrintDebug) {
|
|
377
330
|
console.log("not extractable", alt, cons);
|
|
378
331
|
}
|
|
379
332
|
return attr;
|
|
380
333
|
}
|
|
381
334
|
return [
|
|
382
|
-
...
|
|
383
|
-
...cons &&
|
|
335
|
+
...createTernariesFromObjectProperties2(test, alt) || [],
|
|
336
|
+
...cons && createTernariesFromObjectProperties2(t.unaryExpression("!", test), cons) || []
|
|
384
337
|
].map((ternary) => ({
|
|
385
338
|
type: "ternary",
|
|
386
339
|
value: ternary
|
|
@@ -434,7 +387,7 @@ function createExtractor() {
|
|
|
434
387
|
if (mediaQueryConfig[shortname]) {
|
|
435
388
|
const expression = attribute.value.expression;
|
|
436
389
|
if (!t.isJSXEmptyExpression(expression)) {
|
|
437
|
-
const ternaries2 =
|
|
390
|
+
const ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(shortname), expression, {
|
|
438
391
|
inlineMediaQuery: shortname
|
|
439
392
|
});
|
|
440
393
|
if (ternaries2) {
|
|
@@ -673,7 +626,7 @@ function createExtractor() {
|
|
|
673
626
|
}
|
|
674
627
|
return null;
|
|
675
628
|
}
|
|
676
|
-
},
|
|
629
|
+
}, isExtractable2 = function(obj) {
|
|
677
630
|
return t.isObjectExpression(obj) && obj.properties.every((prop) => {
|
|
678
631
|
if (!t.isObjectProperty(prop)) {
|
|
679
632
|
console.log("not object prop", prop);
|
|
@@ -688,11 +641,11 @@ function createExtractor() {
|
|
|
688
641
|
}
|
|
689
642
|
return true;
|
|
690
643
|
});
|
|
691
|
-
},
|
|
644
|
+
}, createTernariesFromObjectProperties2 = function(test, side, ternaryPartial = {}) {
|
|
692
645
|
if (!side) {
|
|
693
646
|
return null;
|
|
694
647
|
}
|
|
695
|
-
if (!
|
|
648
|
+
if (!isExtractable2(side)) {
|
|
696
649
|
throw new Error("not extractable");
|
|
697
650
|
}
|
|
698
651
|
return side.properties.flatMap((property) => {
|
|
@@ -705,11 +658,13 @@ function createExtractor() {
|
|
|
705
658
|
const isMediaQuery = key[0] === "$" && mediaQueryConfig[mediaQueryKey];
|
|
706
659
|
if (isMediaQuery) {
|
|
707
660
|
if (t.isExpression(property.value)) {
|
|
708
|
-
const ternaries2 =
|
|
661
|
+
const ternaries2 = createTernariesFromObjectProperties2(t.stringLiteral(mediaQueryKey), property.value, {
|
|
709
662
|
inlineMediaQuery: mediaQueryKey
|
|
710
663
|
});
|
|
711
664
|
if (ternaries2) {
|
|
712
|
-
return ternaries2.map((value) =>
|
|
665
|
+
return ternaries2.map((value) => ({
|
|
666
|
+
...ternaryPartial,
|
|
667
|
+
...value,
|
|
713
668
|
test: t.logicalExpression("&&", value.test, test)
|
|
714
669
|
}));
|
|
715
670
|
} else {
|
|
@@ -726,35 +681,36 @@ function createExtractor() {
|
|
|
726
681
|
t.objectExpression([t.objectProperty(property.key, property.value.alternate)])
|
|
727
682
|
].map((x) => attemptEval(x));
|
|
728
683
|
return [
|
|
729
|
-
createTernary(
|
|
684
|
+
createTernary({
|
|
730
685
|
remove() {
|
|
731
|
-
}
|
|
732
|
-
|
|
686
|
+
},
|
|
687
|
+
...ternaryPartial,
|
|
733
688
|
test: t.logicalExpression("&&", test, property.value.test),
|
|
734
689
|
consequent: truthy,
|
|
735
690
|
alternate: null
|
|
736
|
-
})
|
|
737
|
-
createTernary(
|
|
691
|
+
}),
|
|
692
|
+
createTernary({
|
|
693
|
+
...ternaryPartial,
|
|
738
694
|
test: t.logicalExpression("&&", test, t.unaryExpression("!", property.value.test)),
|
|
739
695
|
consequent: falsy,
|
|
740
696
|
alternate: null,
|
|
741
697
|
remove() {
|
|
742
698
|
}
|
|
743
|
-
})
|
|
699
|
+
})
|
|
744
700
|
];
|
|
745
701
|
}
|
|
746
702
|
const obj = t.objectExpression([t.objectProperty(property.key, property.value)]);
|
|
747
703
|
const consequent = attemptEval(obj);
|
|
748
|
-
return createTernary(
|
|
704
|
+
return createTernary({
|
|
749
705
|
remove() {
|
|
750
|
-
}
|
|
751
|
-
|
|
706
|
+
},
|
|
707
|
+
...ternaryPartial,
|
|
752
708
|
test,
|
|
753
709
|
consequent,
|
|
754
710
|
alternate: null
|
|
755
|
-
})
|
|
711
|
+
});
|
|
756
712
|
});
|
|
757
|
-
},
|
|
713
|
+
}, mergeStyles2 = function(prev2, nextIn) {
|
|
758
714
|
const next = expandStyles(nextIn);
|
|
759
715
|
for (const key in next) {
|
|
760
716
|
if (pseudoDescriptors[key]) {
|
|
@@ -770,6 +726,7 @@ function createExtractor() {
|
|
|
770
726
|
}
|
|
771
727
|
}
|
|
772
728
|
};
|
|
729
|
+
var evaluateAttribute = evaluateAttribute2, isExtractable = isExtractable2, createTernariesFromObjectProperties = createTernariesFromObjectProperties2, mergeStyles = mergeStyles2;
|
|
773
730
|
node.attributes.find((n) => t.isJSXAttribute(n) && t.isJSXIdentifier(n.name) && n.name.name === "debug" && n.value === null);
|
|
774
731
|
if (shouldPrintDebug) {
|
|
775
732
|
console.log("\n");
|
|
@@ -882,7 +839,7 @@ function createExtractor() {
|
|
|
882
839
|
const inlineWhenUnflattenedOGVals = {};
|
|
883
840
|
attrs = traversePath.get("openingElement").get("attributes").flatMap((path) => {
|
|
884
841
|
try {
|
|
885
|
-
const res2 =
|
|
842
|
+
const res2 = evaluateAttribute2(path);
|
|
886
843
|
tm.mark("jsx-element-evaluate-attr", shouldPrintDebug === "verbose");
|
|
887
844
|
if (!res2) {
|
|
888
845
|
path.remove();
|
|
@@ -922,14 +879,14 @@ function createExtractor() {
|
|
|
922
879
|
ternaries.push(cur.value);
|
|
923
880
|
}
|
|
924
881
|
if ((!next || next.type !== "ternary") && ternaries.length) {
|
|
925
|
-
const normalized = normalizeTernaries(ternaries).map((
|
|
926
|
-
var _b3 = _a3, { alternate, consequent } = _b3, rest = __objRest(_b3, ["alternate", "consequent"]);
|
|
882
|
+
const normalized = normalizeTernaries(ternaries).map(({ alternate, consequent, ...rest }) => {
|
|
927
883
|
return {
|
|
928
884
|
type: "ternary",
|
|
929
|
-
value:
|
|
885
|
+
value: {
|
|
886
|
+
...rest,
|
|
930
887
|
alternate: alternate || null,
|
|
931
888
|
consequent: consequent || null
|
|
932
|
-
}
|
|
889
|
+
}
|
|
933
890
|
};
|
|
934
891
|
});
|
|
935
892
|
try {
|
|
@@ -952,7 +909,7 @@ function createExtractor() {
|
|
|
952
909
|
const themeVal = inlined.get("theme");
|
|
953
910
|
inlined.delete("theme");
|
|
954
911
|
for (const [key] of [...inlined]) {
|
|
955
|
-
if (INLINE_EXTRACTABLE[key] || ((
|
|
912
|
+
if (INLINE_EXTRACTABLE[key] || ((_a = staticConfig.variants) == null ? void 0 : _a[key])) {
|
|
956
913
|
inlined.delete(key);
|
|
957
914
|
}
|
|
958
915
|
}
|
|
@@ -1015,7 +972,7 @@ function createExtractor() {
|
|
|
1015
972
|
for (const cur of attrs) {
|
|
1016
973
|
if (cur.type === "style") {
|
|
1017
974
|
for (const key in cur.value) {
|
|
1018
|
-
const shouldEnsureOverridden = !!((
|
|
975
|
+
const shouldEnsureOverridden = !!((_b = staticConfig.ensureOverriddenProp) == null ? void 0 : _b[key]);
|
|
1019
976
|
const isSetInAttrsAlready = attrs.some((x) => x.type === "attr" && x.value.type === "JSXAttribute" && x.value.name.name === key);
|
|
1020
977
|
if (!isSetInAttrsAlready) {
|
|
1021
978
|
const isVariant = !!((_c = staticConfig.variants) == null ? void 0 : _c[cur.name || ""]);
|
|
@@ -1043,7 +1000,10 @@ function createExtractor() {
|
|
|
1043
1000
|
for (const key in attrs) {
|
|
1044
1001
|
const cur = attrs[key];
|
|
1045
1002
|
if (cur.type === "style") {
|
|
1046
|
-
foundStaticProps =
|
|
1003
|
+
foundStaticProps = {
|
|
1004
|
+
...foundStaticProps,
|
|
1005
|
+
...expandStyles(cur.value)
|
|
1006
|
+
};
|
|
1047
1007
|
continue;
|
|
1048
1008
|
}
|
|
1049
1009
|
if (cur.type === "attr") {
|
|
@@ -1056,9 +1016,10 @@ function createExtractor() {
|
|
|
1056
1016
|
const key2 = cur.value.name.name;
|
|
1057
1017
|
const value = attemptEvalSafe(cur.value.value || t.booleanLiteral(true));
|
|
1058
1018
|
if (value !== FAILED_EVAL) {
|
|
1059
|
-
foundStaticProps =
|
|
1019
|
+
foundStaticProps = {
|
|
1020
|
+
...foundStaticProps,
|
|
1060
1021
|
[key2]: value
|
|
1061
|
-
}
|
|
1022
|
+
};
|
|
1062
1023
|
}
|
|
1063
1024
|
}
|
|
1064
1025
|
}
|
|
@@ -1082,7 +1043,7 @@ function createExtractor() {
|
|
|
1082
1043
|
return acc;
|
|
1083
1044
|
}
|
|
1084
1045
|
if (variants[name] && variantValues.has(name)) {
|
|
1085
|
-
let out = Object.fromEntries(staticConfig.propMapper(name, variantValues.get(name), defaultTheme, completeProps,
|
|
1046
|
+
let out = Object.fromEntries(staticConfig.propMapper(name, variantValues.get(name), defaultTheme, completeProps, { ...state, resolveVariablesAs: "auto" }, void 0, shouldPrintDebug) || []);
|
|
1086
1047
|
if (out && isTargetingHTML) {
|
|
1087
1048
|
const cn = out.className;
|
|
1088
1049
|
out = createDOMProps(isTextView ? "span" : "div", out);
|
|
@@ -1166,7 +1127,7 @@ function createExtractor() {
|
|
|
1166
1127
|
});
|
|
1167
1128
|
}
|
|
1168
1129
|
if ((prev == null ? void 0 : prev.type) === "style") {
|
|
1169
|
-
|
|
1130
|
+
mergeStyles2(prev.value, cur.value);
|
|
1170
1131
|
return acc;
|
|
1171
1132
|
}
|
|
1172
1133
|
}
|
|
@@ -1196,10 +1157,14 @@ function createExtractor() {
|
|
|
1196
1157
|
}
|
|
1197
1158
|
}
|
|
1198
1159
|
try {
|
|
1199
|
-
const out = getSplitStyles(props2, staticConfig, defaultTheme,
|
|
1160
|
+
const out = getSplitStyles(props2, staticConfig, defaultTheme, {
|
|
1161
|
+
...state,
|
|
1200
1162
|
fallbackProps: completeProps
|
|
1201
|
-
}
|
|
1202
|
-
const outStyle =
|
|
1163
|
+
}, void 0, props2["debug"]);
|
|
1164
|
+
const outStyle = {
|
|
1165
|
+
...out.style,
|
|
1166
|
+
...out.pseudos
|
|
1167
|
+
};
|
|
1203
1168
|
return outStyle;
|
|
1204
1169
|
} catch (err) {
|
|
1205
1170
|
console.log("error", err.message, err.stack);
|