@tamagui/static 2.7.7 → 3.0.0-beta.643.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/check-dep-versions.cjs +355 -0
- package/dist/cjs/checkDeps.cjs +302 -0
- package/dist/cjs/compiler.cjs +286 -0
- package/dist/cjs/compilerHost.cjs +1695 -0
- package/dist/cjs/constants.cjs +33 -0
- package/dist/cjs/domStructuralPass.cjs +112 -0
- package/dist/cjs/exports.cjs +42 -0
- package/dist/cjs/extractor/addLocalExports.cjs +64 -0
- package/dist/cjs/extractor/bundle.cjs +203 -0
- package/dist/cjs/extractor/bundleConfig.cjs +747 -0
- package/dist/cjs/extractor/concatClassName.cjs +117 -0
- package/dist/cjs/extractor/detectModuleFormat.cjs +54 -0
- package/dist/cjs/extractor/esbuildAliasPlugin.cjs +47 -0
- package/dist/cjs/extractor/esbuildTsconfigPaths.cjs +92 -0
- package/dist/cjs/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +38 -0
- package/dist/cjs/extractor/loadTamagui.cjs +344 -0
- package/dist/cjs/extractor/regenerateConfig.cjs +161 -0
- package/dist/cjs/extractor/watchTamaguiConfig.cjs +64 -0
- package/dist/cjs/getPragmaOptions.cjs +67 -0
- package/dist/cjs/helpers/memoize.cjs +42 -0
- package/dist/cjs/helpers/requireTamaguiCore.cjs +40 -0
- package/dist/cjs/index.cjs +34 -0
- package/dist/cjs/registerRequire.cjs +220 -0
- package/dist/cjs/server.cjs +66 -0
- package/dist/cjs/staticEvaluationIgnoredModules.cjs +86 -0
- package/dist/cjs/types.cjs +17 -0
- package/dist/cjs/zero/artifact.cjs +145 -0
- package/dist/cjs/zero/graph.cjs +209 -0
- package/dist/cjs/zero/identity.cjs +61 -0
- package/dist/cjs/zero/index.cjs +26 -0
- package/dist/cjs/zero/islands.cjs +232 -0
- package/dist/cjs/zero/options.cjs +163 -0
- package/dist/cjs/zero/ownership.cjs +79 -0
- package/dist/cjs/zero/theme.cjs +328 -0
- package/dist/cjs/zero/transform.cjs +203 -0
- package/dist/esm/check-dep-versions.mjs +329 -0
- package/dist/esm/check-dep-versions.mjs.map +1 -0
- package/dist/esm/checkDeps.mjs +279 -0
- package/dist/esm/checkDeps.mjs.map +1 -0
- package/dist/esm/compiler.mjs +255 -0
- package/dist/esm/compiler.mjs.map +1 -0
- package/dist/esm/compilerHost.mjs +1675 -0
- package/dist/esm/compilerHost.mjs.map +1 -0
- package/dist/esm/constants.mjs +7 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/domStructuralPass.mjs +92 -0
- package/dist/esm/domStructuralPass.mjs.map +1 -0
- package/dist/esm/exports.mjs +26 -0
- package/dist/esm/extractor/addLocalExports.mjs +44 -0
- package/dist/esm/extractor/addLocalExports.mjs.map +1 -0
- package/dist/esm/extractor/bundle.mjs +173 -0
- package/dist/esm/extractor/bundle.mjs.map +1 -0
- package/dist/esm/extractor/bundleConfig.mjs +706 -0
- package/dist/esm/extractor/bundleConfig.mjs.map +1 -0
- package/dist/esm/extractor/concatClassName.mjs +96 -0
- package/dist/esm/extractor/concatClassName.mjs.map +1 -0
- package/dist/esm/extractor/detectModuleFormat.mjs +31 -0
- package/dist/esm/extractor/detectModuleFormat.mjs.map +1 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs +26 -0
- package/dist/esm/extractor/esbuildAliasPlugin.mjs.map +1 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs +63 -0
- package/dist/esm/extractor/esbuildTsconfigPaths.mjs.map +1 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs +18 -0
- package/dist/esm/extractor/getTamaguiConfigPathFromOptionsConfig.mjs.map +1 -0
- package/dist/esm/extractor/loadTamagui.mjs +306 -0
- package/dist/esm/extractor/loadTamagui.mjs.map +1 -0
- package/dist/esm/extractor/regenerateConfig.mjs +131 -0
- package/dist/esm/extractor/regenerateConfig.mjs.map +1 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs +43 -0
- package/dist/esm/extractor/watchTamaguiConfig.mjs.map +1 -0
- package/dist/esm/getPragmaOptions.mjs +46 -0
- package/dist/esm/getPragmaOptions.mjs.map +1 -0
- package/dist/esm/helpers/memoize.mjs +21 -0
- package/dist/esm/helpers/memoize.mjs.map +1 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs +19 -0
- package/dist/esm/helpers/requireTamaguiCore.mjs.map +1 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/registerRequire.mjs +195 -0
- package/dist/esm/registerRequire.mjs.map +1 -0
- package/dist/esm/server.mjs +40 -0
- package/dist/esm/server.mjs.map +1 -0
- package/dist/esm/setup.mjs +0 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs +61 -0
- package/dist/esm/staticEvaluationIgnoredModules.mjs.map +1 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/zero/artifact.mjs +119 -0
- package/dist/esm/zero/artifact.mjs.map +1 -0
- package/dist/esm/zero/graph.mjs +170 -0
- package/dist/esm/zero/graph.mjs.map +1 -0
- package/dist/esm/zero/identity.mjs +36 -0
- package/dist/esm/zero/identity.mjs.map +1 -0
- package/dist/esm/zero/index.mjs +15 -0
- package/dist/esm/zero/islands.mjs +197 -0
- package/dist/esm/zero/islands.mjs.map +1 -0
- package/dist/esm/zero/options.mjs +129 -0
- package/dist/esm/zero/options.mjs.map +1 -0
- package/dist/esm/zero/ownership.mjs +48 -0
- package/dist/esm/zero/ownership.mjs.map +1 -0
- package/dist/esm/zero/theme.mjs +303 -0
- package/dist/esm/zero/theme.mjs.map +1 -0
- package/dist/esm/zero/transform.mjs +177 -0
- package/dist/esm/zero/transform.mjs.map +1 -0
- package/package.json +33 -43
- package/src/check-dep-versions.ts +2 -2
- package/src/checkDeps.ts +3 -2
- package/src/compiler.ts +425 -0
- package/src/compilerHost.ts +3125 -0
- package/src/constants.ts +0 -5
- package/src/domStructuralPass.ts +170 -0
- package/src/exports.ts +3 -6
- package/src/extractor/addLocalExports.ts +49 -0
- package/src/extractor/bundle.ts +20 -35
- package/src/extractor/bundleConfig.ts +334 -187
- package/src/extractor/concatClassName.ts +13 -20
- package/src/extractor/getTamaguiConfigPathFromOptionsConfig.ts +5 -4
- package/src/extractor/loadTamagui.ts +196 -143
- package/src/extractor/regenerateConfig.ts +65 -13
- package/src/extractor/watchTamaguiConfig.ts +6 -1
- package/src/helpers/requireTamaguiCore.ts +6 -1
- package/src/registerRequire.ts +94 -132
- package/src/staticEvaluationIgnoredModules.ts +74 -0
- package/src/types.ts +2 -107
- package/src/zero/artifact.ts +142 -0
- package/src/zero/graph.ts +359 -0
- package/src/zero/identity.ts +73 -0
- package/src/zero/index.ts +8 -0
- package/src/zero/islands.ts +262 -0
- package/src/zero/options.ts +239 -0
- package/src/zero/ownership.ts +113 -0
- package/src/zero/theme.ts +478 -0
- package/src/zero/transform.ts +320 -0
- package/types/check-dep-versions.d.ts.map +1 -1
- package/types/checkDeps.d.ts.map +1 -1
- package/types/compiler.d.ts +117 -0
- package/types/compiler.d.ts.map +1 -0
- package/types/compilerHost.d.ts +25 -0
- package/types/compilerHost.d.ts.map +1 -0
- package/types/constants.d.ts +0 -1
- package/types/constants.d.ts.map +1 -1
- package/types/domStructuralPass.d.ts +3 -0
- package/types/domStructuralPass.d.ts.map +1 -0
- package/types/exports.d.ts +3 -6
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/addLocalExports.d.ts +3 -0
- package/types/extractor/addLocalExports.d.ts.map +1 -0
- package/types/extractor/bundle.d.ts +66 -65
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +19 -4
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/esbuildAliasPlugin.d.ts.map +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts +1 -1
- package/types/extractor/getTamaguiConfigPathFromOptionsConfig.d.ts.map +1 -1
- package/types/extractor/loadTamagui.d.ts +26 -3
- package/types/extractor/loadTamagui.d.ts.map +1 -1
- package/types/extractor/regenerateConfig.d.ts +1 -1
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/watchTamaguiConfig.d.ts.map +1 -1
- package/types/getPragmaOptions.d.ts +1 -1
- package/types/helpers/memoize.d.ts +1 -1
- package/types/helpers/memoize.d.ts.map +1 -1
- package/types/helpers/requireTamaguiCore.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/registerRequire.d.ts +2 -2
- package/types/registerRequire.d.ts.map +1 -1
- package/types/staticEvaluationIgnoredModules.d.ts +9 -0
- package/types/staticEvaluationIgnoredModules.d.ts.map +1 -0
- package/types/types.d.ts +2 -90
- package/types/types.d.ts.map +1 -1
- package/types/zero/artifact.d.ts +44 -0
- package/types/zero/artifact.d.ts.map +1 -0
- package/types/zero/graph.d.ts +139 -0
- package/types/zero/graph.d.ts.map +1 -0
- package/types/zero/identity.d.ts +33 -0
- package/types/zero/identity.d.ts.map +1 -0
- package/types/zero/index.d.ts +9 -0
- package/types/zero/index.d.ts.map +1 -0
- package/types/zero/islands.d.ts +56 -0
- package/types/zero/islands.d.ts.map +1 -0
- package/types/zero/options.d.ts +58 -0
- package/types/zero/options.d.ts.map +1 -0
- package/types/zero/ownership.d.ts +51 -0
- package/types/zero/ownership.d.ts.map +1 -0
- package/types/zero/theme.d.ts +83 -0
- package/types/zero/theme.d.ts.map +1 -0
- package/types/zero/transform.d.ts +53 -0
- package/types/zero/transform.d.ts.map +1 -0
- package/dist/check-dep-versions.cjs +0 -372
- package/dist/checkDeps.cjs +0 -271
- package/dist/constants.cjs +0 -51
- package/dist/exports.cjs +0 -48
- package/dist/extractor/accessSafe.cjs +0 -48
- package/dist/extractor/babelParse.cjs +0 -56
- package/dist/extractor/buildClassName.cjs +0 -86
- package/dist/extractor/bundle.cjs +0 -234
- package/dist/extractor/bundleConfig.cjs +0 -729
- package/dist/extractor/concatClassName.cjs +0 -129
- package/dist/extractor/createEvaluator.cjs +0 -88
- package/dist/extractor/createExtractor.cjs +0 -1968
- package/dist/extractor/createLogger.cjs +0 -50
- package/dist/extractor/detectModuleFormat.cjs +0 -55
- package/dist/extractor/ensureImportingConcat.cjs +0 -54
- package/dist/extractor/errors.cjs +0 -28
- package/dist/extractor/esbuildAliasPlugin.cjs +0 -56
- package/dist/extractor/esbuildTsconfigPaths.cjs +0 -108
- package/dist/extractor/evaluateAstNode.cjs +0 -128
- package/dist/extractor/extractHelpers.cjs +0 -182
- package/dist/extractor/extractMediaStyle.cjs +0 -169
- package/dist/extractor/extractToClassNames.cjs +0 -475
- package/dist/extractor/extractToNative.cjs +0 -369
- package/dist/extractor/findTopmostFunction.cjs +0 -43
- package/dist/extractor/generatedUid.cjs +0 -58
- package/dist/extractor/getPrefixLogs.cjs +0 -31
- package/dist/extractor/getPropValueFromAttributes.cjs +0 -85
- package/dist/extractor/getSourceModule.cjs +0 -100
- package/dist/extractor/getStaticBindingsForScope.cjs +0 -213
- package/dist/extractor/getTamaguiConfigPathFromOptionsConfig.cjs +0 -41
- package/dist/extractor/hasTopLevelAwait.cjs +0 -62
- package/dist/extractor/hoistClassNames.cjs +0 -76
- package/dist/extractor/literalToAst.cjs +0 -109
- package/dist/extractor/loadFile.cjs +0 -17
- package/dist/extractor/loadTamagui.cjs +0 -373
- package/dist/extractor/logLines.cjs +0 -43
- package/dist/extractor/normalizeTernaries.cjs +0 -100
- package/dist/extractor/propsToFontFamilyCache.cjs +0 -42
- package/dist/extractor/regenerateConfig.cjs +0 -178
- package/dist/extractor/removeUnusedHooks.cjs +0 -108
- package/dist/extractor/timer.cjs +0 -52
- package/dist/extractor/validHTMLAttributes.cjs +0 -79
- package/dist/extractor/watchTamaguiConfig.cjs +0 -70
- package/dist/getPragmaOptions.cjs +0 -73
- package/dist/helpers/memoize.cjs +0 -45
- package/dist/helpers/requireTamaguiCore.cjs +0 -40
- package/dist/index.cjs +0 -42
- package/dist/registerRequire.cjs +0 -209
- package/dist/server.cjs +0 -82
- package/dist/types.cjs +0 -18
- package/dist/worker.cjs +0 -111
- package/src/extractor/accessSafe.ts +0 -22
- package/src/extractor/babelParse.ts +0 -38
- package/src/extractor/buildClassName.ts +0 -76
- package/src/extractor/createEvaluator.ts +0 -82
- package/src/extractor/createExtractor.ts +0 -2970
- package/src/extractor/createLogger.ts +0 -41
- package/src/extractor/ensureImportingConcat.ts +0 -36
- package/src/extractor/errors.ts +0 -1
- package/src/extractor/evaluateAstNode.ts +0 -136
- package/src/extractor/extractHelpers.ts +0 -211
- package/src/extractor/extractMediaStyle.ts +0 -194
- package/src/extractor/extractToClassNames.ts +0 -733
- package/src/extractor/extractToNative.ts +0 -506
- package/src/extractor/findTopmostFunction.ts +0 -24
- package/src/extractor/generatedUid.ts +0 -41
- package/src/extractor/getPrefixLogs.ts +0 -9
- package/src/extractor/getPropValueFromAttributes.ts +0 -95
- package/src/extractor/getSourceModule.ts +0 -96
- package/src/extractor/getStaticBindingsForScope.ts +0 -237
- package/src/extractor/hasTopLevelAwait.ts +0 -28
- package/src/extractor/hoistClassNames.ts +0 -52
- package/src/extractor/literalToAst.ts +0 -85
- package/src/extractor/loadFile.ts +0 -17
- package/src/extractor/logLines.ts +0 -16
- package/src/extractor/normalizeTernaries.ts +0 -89
- package/src/extractor/propsToFontFamilyCache.ts +0 -18
- package/src/extractor/removeUnusedHooks.ts +0 -83
- package/src/extractor/timer.ts +0 -25
- package/src/extractor/validHTMLAttributes.ts +0 -52
- package/src/worker.ts +0 -142
- 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/buildClassName.d.ts +0 -7
- package/types/extractor/buildClassName.d.ts.map +0 -1
- package/types/extractor/createEvaluator.d.ts +0 -12
- package/types/extractor/createEvaluator.d.ts.map +0 -1
- package/types/extractor/createExtractor.d.ts +0 -32
- package/types/extractor/createExtractor.d.ts.map +0 -1
- package/types/extractor/createLogger.d.ts +0 -3
- package/types/extractor/createLogger.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/errors.d.ts +0 -3
- package/types/extractor/errors.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/extractHelpers.d.ts +0 -28
- package/types/extractor/extractHelpers.d.ts.map +0 -1
- package/types/extractor/extractMediaStyle.d.ts +0 -11
- package/types/extractor/extractMediaStyle.d.ts.map +0 -1
- package/types/extractor/extractToClassNames.d.ts +0 -25
- package/types/extractor/extractToClassNames.d.ts.map +0 -1
- package/types/extractor/extractToNative.d.ts +0 -13
- package/types/extractor/extractToNative.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/getPrefixLogs.d.ts +0 -3
- package/types/extractor/getPrefixLogs.d.ts.map +0 -1
- package/types/extractor/getPropValueFromAttributes.d.ts +0 -19
- 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 -5
- package/types/extractor/getStaticBindingsForScope.d.ts.map +0 -1
- package/types/extractor/hasTopLevelAwait.d.ts +0 -2
- package/types/extractor/hasTopLevelAwait.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/loadFile.d.ts +0 -1
- package/types/extractor/loadFile.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/normalizeTernaries.d.ts +0 -5
- package/types/extractor/normalizeTernaries.d.ts.map +0 -1
- package/types/extractor/propsToFontFamilyCache.d.ts +0 -4
- package/types/extractor/propsToFontFamilyCache.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 -52
- package/types/extractor/validHTMLAttributes.d.ts.map +0 -1
- package/types/worker.d.ts +0 -46
- package/types/worker.d.ts.map +0 -1
- /package/dist/{setup.cjs → cjs/setup.cjs} +0 -0
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import * as t from '@babel/types'
|
|
2
|
-
|
|
3
|
-
export interface SourceModule {
|
|
4
|
-
sourceModule?: string
|
|
5
|
-
imported?: string
|
|
6
|
-
local?: string
|
|
7
|
-
destructured?: boolean
|
|
8
|
-
usesImportSyntax: boolean
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function getSourceModule(
|
|
12
|
-
itemName: string,
|
|
13
|
-
itemBinding: {
|
|
14
|
-
constant?: boolean
|
|
15
|
-
path: { node: t.Node; parent: any }
|
|
16
|
-
}
|
|
17
|
-
): SourceModule | null {
|
|
18
|
-
// TODO: deal with reassignment
|
|
19
|
-
if (!itemBinding.constant) {
|
|
20
|
-
return null
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let sourceModule: string | undefined
|
|
24
|
-
let imported: string | undefined
|
|
25
|
-
let local: string | undefined
|
|
26
|
-
let destructured: boolean | undefined
|
|
27
|
-
let usesImportSyntax = false
|
|
28
|
-
|
|
29
|
-
const itemNode = itemBinding.path.node
|
|
30
|
-
|
|
31
|
-
if (t.isImportDefaultSpecifier(itemNode) || t.isImportSpecifier(itemNode)) {
|
|
32
|
-
if (t.isImportDeclaration(itemBinding.path.parent)) {
|
|
33
|
-
sourceModule = itemBinding.path.parent.source.value
|
|
34
|
-
local = itemNode.local.name
|
|
35
|
-
usesImportSyntax = true
|
|
36
|
-
if (t.isImportSpecifier(itemNode)) {
|
|
37
|
-
imported = itemNode.imported['name']
|
|
38
|
-
destructured = true
|
|
39
|
-
} else {
|
|
40
|
-
imported = itemNode.local.name
|
|
41
|
-
destructured = false
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
} else if (
|
|
45
|
-
t.isVariableDeclarator(itemNode) &&
|
|
46
|
-
itemNode.init != null &&
|
|
47
|
-
t.isCallExpression(itemNode.init) &&
|
|
48
|
-
t.isIdentifier(itemNode.init.callee) &&
|
|
49
|
-
itemNode.init.callee.name === 'require' &&
|
|
50
|
-
itemNode.init.arguments.length === 1
|
|
51
|
-
) {
|
|
52
|
-
const firstArg = itemNode.init.arguments[0]
|
|
53
|
-
if (!t.isStringLiteral(firstArg)) {
|
|
54
|
-
return null
|
|
55
|
-
}
|
|
56
|
-
sourceModule = firstArg.value
|
|
57
|
-
|
|
58
|
-
if (t.isIdentifier(itemNode.id)) {
|
|
59
|
-
local = itemNode.id.name
|
|
60
|
-
imported = itemNode.id.name
|
|
61
|
-
destructured = false
|
|
62
|
-
} else if (t.isObjectPattern(itemNode.id)) {
|
|
63
|
-
for (const objProp of itemNode.id.properties) {
|
|
64
|
-
if (
|
|
65
|
-
t.isObjectProperty(objProp) &&
|
|
66
|
-
t.isIdentifier(objProp.value) &&
|
|
67
|
-
objProp.value.name === itemName
|
|
68
|
-
) {
|
|
69
|
-
local = objProp.value.name
|
|
70
|
-
// @ts-ignore TODO remove this is only an issue on CI
|
|
71
|
-
imported = objProp.key.name
|
|
72
|
-
destructured = true
|
|
73
|
-
break
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (!local || !imported) {
|
|
78
|
-
console.error('could not find prop with value `%s`', itemName)
|
|
79
|
-
return null
|
|
80
|
-
}
|
|
81
|
-
} else {
|
|
82
|
-
console.error('Unhandled id type: %s', itemNode.id.type)
|
|
83
|
-
return null
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
return null
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
destructured,
|
|
91
|
-
imported,
|
|
92
|
-
local,
|
|
93
|
-
sourceModule,
|
|
94
|
-
usesImportSyntax,
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import type { ChildProcess } from 'node:child_process'
|
|
2
|
-
import { fork } from 'node:child_process'
|
|
3
|
-
import { dirname, extname, join, resolve } from 'node:path'
|
|
4
|
-
|
|
5
|
-
import type { Binding, NodePath } from '@babel/traverse'
|
|
6
|
-
import * as t from '@babel/types'
|
|
7
|
-
|
|
8
|
-
import { evaluateAstNode } from './evaluateAstNode'
|
|
9
|
-
import { getSourceModule } from './getSourceModule'
|
|
10
|
-
|
|
11
|
-
// import { fileURLToPath } from 'node:url'
|
|
12
|
-
// // @ts-ignore
|
|
13
|
-
// const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
14
|
-
|
|
15
|
-
const isLocalImport = (path: string) => path.startsWith('.') || path.startsWith('/')
|
|
16
|
-
|
|
17
|
-
function resolveImportPath(sourcePath: string, path: string) {
|
|
18
|
-
const sourceDir = dirname(sourcePath)
|
|
19
|
-
if (isLocalImport(path)) {
|
|
20
|
-
if (extname(path) === '') {
|
|
21
|
-
path += ''
|
|
22
|
-
}
|
|
23
|
-
return resolve(sourceDir, path)
|
|
24
|
-
}
|
|
25
|
-
return path
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const cache = new Map()
|
|
29
|
-
const pending = new Map<string, Promise<any>>()
|
|
30
|
-
|
|
31
|
-
const loadCmd = `${join(__dirname, 'loadFile.js')}`
|
|
32
|
-
|
|
33
|
-
let exited = false
|
|
34
|
-
|
|
35
|
-
let child: ChildProcess | null = null
|
|
36
|
-
|
|
37
|
-
function forkChild() {
|
|
38
|
-
child = fork(loadCmd, [], {
|
|
39
|
-
execArgv: ['-r', 'esbuild-register'],
|
|
40
|
-
detached: false,
|
|
41
|
-
stdio: 'ignore',
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function cleanupBeforeExit() {
|
|
46
|
-
if (exited) return
|
|
47
|
-
if (!child) return
|
|
48
|
-
child.removeAllListeners()
|
|
49
|
-
child.unref()
|
|
50
|
-
child.disconnect()
|
|
51
|
-
child.kill()
|
|
52
|
-
exited = true
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
process.once('SIGTERM', cleanupBeforeExit)
|
|
56
|
-
process.once('SIGINT', cleanupBeforeExit)
|
|
57
|
-
process.once('beforeExit', cleanupBeforeExit)
|
|
58
|
-
|
|
59
|
-
function importModule(path: string) {
|
|
60
|
-
if (!child) {
|
|
61
|
-
forkChild()
|
|
62
|
-
}
|
|
63
|
-
if (pending.has(path)) {
|
|
64
|
-
return pending.get(path)
|
|
65
|
-
}
|
|
66
|
-
const promise = new Promise((res, rej) => {
|
|
67
|
-
if (!child) return
|
|
68
|
-
if (cache.size > 2000) {
|
|
69
|
-
cache.clear()
|
|
70
|
-
}
|
|
71
|
-
if (cache.has(path)) {
|
|
72
|
-
return cache.get(path)
|
|
73
|
-
}
|
|
74
|
-
const listener = (msg: any) => {
|
|
75
|
-
if (!child) return
|
|
76
|
-
if (!msg) return
|
|
77
|
-
if (typeof msg !== 'string') return
|
|
78
|
-
if (msg[0] === '-') {
|
|
79
|
-
rej(new Error(msg.slice(1)))
|
|
80
|
-
return
|
|
81
|
-
}
|
|
82
|
-
child.removeListener('message', listener)
|
|
83
|
-
const val = JSON.parse(msg)
|
|
84
|
-
cache.set(path, val)
|
|
85
|
-
res(val)
|
|
86
|
-
}
|
|
87
|
-
child.once('message', listener)
|
|
88
|
-
child.send(`${path.replace('.js', '')}`)
|
|
89
|
-
}).finally(() => {
|
|
90
|
-
// clean up pending map to prevent memory leak
|
|
91
|
-
pending.delete(path)
|
|
92
|
-
})
|
|
93
|
-
pending.set(path, promise)
|
|
94
|
-
return promise
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export async function getStaticBindingsForScope(
|
|
98
|
-
scope: NodePath<t.JSXElement>['scope'],
|
|
99
|
-
whitelist: string[] = [],
|
|
100
|
-
sourcePath: string,
|
|
101
|
-
bindingCache: Record<string, string | null>,
|
|
102
|
-
shouldPrintDebug: boolean | 'verbose'
|
|
103
|
-
): Promise<Record<string, any>> {
|
|
104
|
-
const bindings: Record<string, Binding> = scope.getAllBindings() as any
|
|
105
|
-
const ret: Record<string, any> = {}
|
|
106
|
-
|
|
107
|
-
if (shouldPrintDebug) {
|
|
108
|
-
// prettier-ignore
|
|
109
|
-
// console.info(' ', Object.keys(bindings).length, 'variables in scope')
|
|
110
|
-
// .map(x => bindings[x].identifier?.name).join(', ')
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// on react native at least it doesnt find some bindings? not sure why
|
|
114
|
-
// lets add in whitelisted imports if they exist
|
|
115
|
-
const program = scope.getProgramParent().block as t.Program
|
|
116
|
-
for (const node of program.body) {
|
|
117
|
-
if (t.isImportDeclaration(node)) {
|
|
118
|
-
const importPath = node.source.value
|
|
119
|
-
if (!node.specifiers.length) continue
|
|
120
|
-
if (!isLocalImport(importPath)) {
|
|
121
|
-
continue
|
|
122
|
-
}
|
|
123
|
-
const moduleName = resolveImportPath(sourcePath, importPath)
|
|
124
|
-
const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))
|
|
125
|
-
if (!isOnWhitelist) continue
|
|
126
|
-
try {
|
|
127
|
-
const src = await importModule(moduleName)
|
|
128
|
-
if (!src) continue
|
|
129
|
-
for (const specifier of node.specifiers) {
|
|
130
|
-
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {
|
|
131
|
-
if (typeof src[specifier.imported.name] !== 'undefined') {
|
|
132
|
-
const val = src[specifier.local.name]
|
|
133
|
-
ret[specifier.local.name] = val
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
} catch (err: any) {
|
|
138
|
-
if (shouldPrintDebug) {
|
|
139
|
-
console.warn(
|
|
140
|
-
` | Skipping partial evaluation of constant file: ${moduleName} (DEBUG=tamagui for more)`
|
|
141
|
-
)
|
|
142
|
-
} else if (process.env.DEBUG?.startsWith('tamagui')) {
|
|
143
|
-
console.info(`Error in partial evaluation`, err.message, err.stack)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (!bindingCache) {
|
|
150
|
-
throw new Error('BindingCache is a required param')
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
for (const k in bindings) {
|
|
154
|
-
const binding = bindings[k]
|
|
155
|
-
|
|
156
|
-
// check to see if the item is a module
|
|
157
|
-
const sourceModule = getSourceModule(k, binding)
|
|
158
|
-
if (sourceModule) {
|
|
159
|
-
if (!sourceModule.sourceModule) {
|
|
160
|
-
continue
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const moduleName = resolveImportPath(sourcePath, sourceModule.sourceModule)
|
|
164
|
-
const isOnWhitelist = whitelist.some((test) => moduleName.endsWith(test))
|
|
165
|
-
|
|
166
|
-
// TODO we could cache this at the file level.. and check if its been touched since
|
|
167
|
-
|
|
168
|
-
if (isOnWhitelist) {
|
|
169
|
-
const src = importModule(moduleName)
|
|
170
|
-
if (!src) {
|
|
171
|
-
console.info(
|
|
172
|
-
` | ⚠️ Missing file ${moduleName} via ${sourcePath} import ${sourceModule.sourceModule}?`
|
|
173
|
-
)
|
|
174
|
-
return {}
|
|
175
|
-
}
|
|
176
|
-
if (sourceModule.destructured) {
|
|
177
|
-
if (sourceModule.imported) {
|
|
178
|
-
ret[k] = src[sourceModule.imported]
|
|
179
|
-
}
|
|
180
|
-
} else {
|
|
181
|
-
ret[k] = src
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
continue
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const { parent } = binding.path
|
|
188
|
-
|
|
189
|
-
if (!t.isVariableDeclaration(parent) || parent.kind !== 'const') {
|
|
190
|
-
continue
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// pick out the right variable declarator
|
|
194
|
-
const dec = parent.declarations.find((d) => t.isIdentifier(d.id) && d.id.name === k)
|
|
195
|
-
|
|
196
|
-
// if init is not set, there's nothing to evaluate
|
|
197
|
-
// TODO: handle spread syntax
|
|
198
|
-
if (!dec || !dec.init) {
|
|
199
|
-
continue
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// missing start/end will break caching
|
|
203
|
-
if (typeof dec.id.start !== 'number' || typeof dec.id.end !== 'number') {
|
|
204
|
-
console.error('dec.id.start/end is not a number')
|
|
205
|
-
continue
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (!t.isIdentifier(dec.id)) {
|
|
209
|
-
console.error('dec is not an identifier')
|
|
210
|
-
continue
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const cacheKey = `${dec.id.name}_${dec.id.start}-${dec.id.end}`
|
|
214
|
-
|
|
215
|
-
// retrieve value from cache
|
|
216
|
-
if (Object.hasOwnProperty.call(bindingCache, cacheKey)) {
|
|
217
|
-
ret[k] = bindingCache[cacheKey]
|
|
218
|
-
continue
|
|
219
|
-
}
|
|
220
|
-
// retrieve value from cache
|
|
221
|
-
if (Object.hasOwnProperty.call(bindingCache, cacheKey)) {
|
|
222
|
-
ret[k] = bindingCache[cacheKey]
|
|
223
|
-
continue
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// evaluate
|
|
227
|
-
try {
|
|
228
|
-
ret[k] = evaluateAstNode(dec.init, undefined, shouldPrintDebug)
|
|
229
|
-
bindingCache[cacheKey] = ret[k]
|
|
230
|
-
continue
|
|
231
|
-
} catch {
|
|
232
|
-
// skip
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
return ret
|
|
237
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import traverse from '@babel/traverse'
|
|
2
|
-
import { babelParse } from './babelParse'
|
|
3
|
-
|
|
4
|
-
export function hasTopLevelAwait(contents: string, fileName?: string) {
|
|
5
|
-
if (!contents.includes('await')) {
|
|
6
|
-
return false
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const ast = babelParse(contents, fileName)
|
|
10
|
-
let found = false
|
|
11
|
-
|
|
12
|
-
traverse(ast, {
|
|
13
|
-
AwaitExpression(path) {
|
|
14
|
-
if (!path.getFunctionParent()) {
|
|
15
|
-
found = true
|
|
16
|
-
path.stop()
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
ForOfStatement(path) {
|
|
20
|
-
if (path.node.await && !path.getFunctionParent()) {
|
|
21
|
-
found = true
|
|
22
|
-
path.stop()
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
return found
|
|
28
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { NodePath } from '@babel/traverse'
|
|
2
|
-
import * as t from '@babel/types'
|
|
3
|
-
|
|
4
|
-
export function hoistClassNames(
|
|
5
|
-
path: NodePath<t.JSXElement>,
|
|
6
|
-
existing: { [key: string]: t.Identifier },
|
|
7
|
-
expr: t.Expression
|
|
8
|
-
) {
|
|
9
|
-
const hoist = hoistClassNames.bind(null, path, existing)
|
|
10
|
-
if (t.isStringLiteral(expr)) {
|
|
11
|
-
if (expr.value.trim() === '') {
|
|
12
|
-
return expr
|
|
13
|
-
}
|
|
14
|
-
if (existing[expr.value]) {
|
|
15
|
-
return existing[expr.value]
|
|
16
|
-
}
|
|
17
|
-
const identifier = replaceStringWithVariable(expr)
|
|
18
|
-
existing[expr.value] = identifier
|
|
19
|
-
return identifier
|
|
20
|
-
}
|
|
21
|
-
if (t.isBinaryExpression(expr)) {
|
|
22
|
-
if (t.isPrivateName(expr.left)) {
|
|
23
|
-
throw new Error(`no private name`)
|
|
24
|
-
}
|
|
25
|
-
return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right))
|
|
26
|
-
}
|
|
27
|
-
if (t.isLogicalExpression(expr)) {
|
|
28
|
-
return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right))
|
|
29
|
-
}
|
|
30
|
-
if (t.isConditionalExpression(expr)) {
|
|
31
|
-
return t.conditionalExpression(
|
|
32
|
-
expr.test,
|
|
33
|
-
hoist(expr.consequent),
|
|
34
|
-
hoist(expr.alternate)
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
return expr
|
|
38
|
-
|
|
39
|
-
function replaceStringWithVariable(str: t.StringLiteral): t.Identifier {
|
|
40
|
-
// hoist outside fn!
|
|
41
|
-
const uid = path.scope.generateUidIdentifier('cn')
|
|
42
|
-
const parent = path.findParent((path) => path.isProgram())
|
|
43
|
-
if (!parent) throw new Error(`no program?`)
|
|
44
|
-
const variable = t.variableDeclaration('const', [
|
|
45
|
-
// adding a space for extra safety
|
|
46
|
-
t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`)),
|
|
47
|
-
])
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
parent.unshiftContainer('body', variable)
|
|
50
|
-
return uid
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import * as t from '@babel/types'
|
|
2
|
-
|
|
3
|
-
export function literalToAst(literal: any): t.Expression {
|
|
4
|
-
if (literal === null) {
|
|
5
|
-
return t.nullLiteral()
|
|
6
|
-
}
|
|
7
|
-
switch (typeof literal) {
|
|
8
|
-
case 'function':
|
|
9
|
-
throw new Error('Unsupported')
|
|
10
|
-
case 'number':
|
|
11
|
-
return t.numericLiteral(literal)
|
|
12
|
-
case 'string':
|
|
13
|
-
return t.stringLiteral(literal)
|
|
14
|
-
case 'boolean':
|
|
15
|
-
return t.booleanLiteral(literal)
|
|
16
|
-
case 'undefined':
|
|
17
|
-
return t.unaryExpression('void', t.numericLiteral(0), true)
|
|
18
|
-
default:
|
|
19
|
-
if (Array.isArray(literal)) {
|
|
20
|
-
return t.arrayExpression(literal.map(literalToAst))
|
|
21
|
-
}
|
|
22
|
-
return t.objectExpression(
|
|
23
|
-
Object.keys(literal)
|
|
24
|
-
.filter((k) => {
|
|
25
|
-
return typeof literal[k] !== 'undefined'
|
|
26
|
-
})
|
|
27
|
-
.map((k) => {
|
|
28
|
-
return t.objectProperty(t.stringLiteral(k), literalToAst(literal[k]))
|
|
29
|
-
})
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const easyPeasies = ['BooleanLiteral', 'StringLiteral', 'NumericLiteral']
|
|
35
|
-
|
|
36
|
-
export function astToLiteral(node: any) {
|
|
37
|
-
if (!node) {
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
if (easyPeasies.includes(node.type)) {
|
|
41
|
-
return node.value
|
|
42
|
-
}
|
|
43
|
-
if (node.name === 'undefined' && !node.value) {
|
|
44
|
-
return undefined
|
|
45
|
-
}
|
|
46
|
-
if (t.isNullLiteral(node)) {
|
|
47
|
-
return null
|
|
48
|
-
}
|
|
49
|
-
if (t.isObjectExpression(node)) {
|
|
50
|
-
return computeProps(node.properties)
|
|
51
|
-
}
|
|
52
|
-
if (t.isArrayExpression(node)) {
|
|
53
|
-
return node.elements.reduce(
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
(acc, element) => [
|
|
56
|
-
...acc,
|
|
57
|
-
...(element?.type === 'SpreadElement'
|
|
58
|
-
? astToLiteral(element.argument)
|
|
59
|
-
: [astToLiteral(element)]),
|
|
60
|
-
],
|
|
61
|
-
[]
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function computeProps(props) {
|
|
67
|
-
return props.reduce((acc, prop) => {
|
|
68
|
-
if (prop.type === 'SpreadElement') {
|
|
69
|
-
return {
|
|
70
|
-
...acc,
|
|
71
|
-
...astToLiteral(prop.argument),
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (prop.type !== 'ObjectMethod') {
|
|
75
|
-
const val = astToLiteral(prop.value)
|
|
76
|
-
if (val !== undefined) {
|
|
77
|
-
return {
|
|
78
|
-
...acc,
|
|
79
|
-
[prop.key.name]: val,
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return acc
|
|
84
|
-
}, {})
|
|
85
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
process.on('message', (path) => {
|
|
2
|
-
if (typeof path !== 'string') {
|
|
3
|
-
throw new Error(`Not a string: ${path}`)
|
|
4
|
-
}
|
|
5
|
-
try {
|
|
6
|
-
const out = require(path)
|
|
7
|
-
process.send?.(JSON.stringify(out))
|
|
8
|
-
} catch (err) {
|
|
9
|
-
if (err instanceof Error) {
|
|
10
|
-
process.send?.(`-${err.message}\n${err.stack}`)
|
|
11
|
-
} else {
|
|
12
|
-
process.send?.(`-${err}`)
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
setInterval(() => {}, 1000)
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const prefix = ' '
|
|
2
|
-
|
|
3
|
-
export const logLines = (str: string, singleLine = false) => {
|
|
4
|
-
if (singleLine) {
|
|
5
|
-
return prefix + str.split(' ').join(`\n${prefix}`)
|
|
6
|
-
}
|
|
7
|
-
const lines: string[] = ['']
|
|
8
|
-
const items = str.split(' ')
|
|
9
|
-
for (const item of items) {
|
|
10
|
-
if (item.length + lines[lines.length - 1].length > 85) {
|
|
11
|
-
lines.push('')
|
|
12
|
-
}
|
|
13
|
-
lines[lines.length - 1] += item + ' '
|
|
14
|
-
}
|
|
15
|
-
return lines.map((line, i) => prefix + (i == 0 ? '' : ' ') + line.trim()).join('\n')
|
|
16
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import generate from '@babel/generator'
|
|
2
|
-
import * as t from '@babel/types'
|
|
3
|
-
import { mergeProps } from '@tamagui/web'
|
|
4
|
-
import invariant from 'invariant'
|
|
5
|
-
import type { Ternary } from '../types'
|
|
6
|
-
import { forwardFontFamilyName } from './propsToFontFamilyCache'
|
|
7
|
-
|
|
8
|
-
export function getTernaryKey(test: t.Node) {
|
|
9
|
-
return generate(test).code
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function normalizeTernaries(ternaries: Ternary[]) {
|
|
13
|
-
invariant(
|
|
14
|
-
Array.isArray(ternaries),
|
|
15
|
-
'extractStaticTernaries expects param 1 to be an array of ternaries'
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
if (ternaries.length === 0) {
|
|
19
|
-
return []
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const ternariesByKey: { [key: string]: Ternary } = {}
|
|
23
|
-
|
|
24
|
-
for (let idx = -1, len = ternaries.length; ++idx < len; ) {
|
|
25
|
-
const { test, consequent, alternate, remove, ...rest } = ternaries[idx]
|
|
26
|
-
|
|
27
|
-
let ternaryTest = test
|
|
28
|
-
|
|
29
|
-
// strip parens
|
|
30
|
-
if (t.isExpressionStatement(test)) {
|
|
31
|
-
ternaryTest = (test as any).expression
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// convert `!thing` to `thing` with swapped consequent and alternate
|
|
35
|
-
let shouldSwap = false
|
|
36
|
-
if (t.isUnaryExpression(test) && test.operator === '!') {
|
|
37
|
-
ternaryTest = test.argument
|
|
38
|
-
shouldSwap = true
|
|
39
|
-
} else if (t.isBinaryExpression(test)) {
|
|
40
|
-
if (test.operator === '!==' || test.operator === '!=') {
|
|
41
|
-
ternaryTest = t.binaryExpression(
|
|
42
|
-
test.operator.replace('!', '=') as any,
|
|
43
|
-
test.left,
|
|
44
|
-
test.right
|
|
45
|
-
)
|
|
46
|
-
shouldSwap = true
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const key = getTernaryKey(ternaryTest)
|
|
51
|
-
|
|
52
|
-
if (!ternariesByKey[key]) {
|
|
53
|
-
ternariesByKey[key] = {
|
|
54
|
-
...rest,
|
|
55
|
-
alternate: {},
|
|
56
|
-
consequent: {},
|
|
57
|
-
test: ternaryTest,
|
|
58
|
-
remove,
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const altStyle = (shouldSwap ? consequent : alternate) ?? {}
|
|
62
|
-
const consStyle = (shouldSwap ? alternate : consequent) ?? {}
|
|
63
|
-
|
|
64
|
-
// a media "ternary" is a breakpoint bucket, not a runtime branch: two of
|
|
65
|
-
// them for the same breakpoint are just two writes to it, and these arrive
|
|
66
|
-
// defaults-first, so a $lg on the JSX has to beat the $lg the styled()
|
|
67
|
-
// frame declared. real ternaries keep merging the other way, which the
|
|
68
|
-
// branch expansion below depends on.
|
|
69
|
-
const mediaLastWins = Boolean(rest.inlineMediaQuery)
|
|
70
|
-
|
|
71
|
-
const nextAlt = ternariesByKey[key].alternate!
|
|
72
|
-
ternariesByKey[key].alternate = mediaLastWins
|
|
73
|
-
? mergeProps(nextAlt, altStyle)
|
|
74
|
-
: mergeProps(altStyle, nextAlt)
|
|
75
|
-
forwardFontFamilyName(altStyle, ternariesByKey[key].alternate)
|
|
76
|
-
|
|
77
|
-
const nextCons = ternariesByKey[key].consequent!
|
|
78
|
-
ternariesByKey[key].consequent = mediaLastWins
|
|
79
|
-
? mergeProps(nextCons, consStyle)
|
|
80
|
-
: mergeProps(consStyle, nextCons)
|
|
81
|
-
forwardFontFamilyName(consStyle, ternariesByKey[key].consequent)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const ternaryExpression = Object.keys(ternariesByKey).map((key) => {
|
|
85
|
-
return ternariesByKey[key]
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
return ternaryExpression
|
|
89
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// weird stuff
|
|
2
|
-
|
|
3
|
-
const cache = new WeakMap<any, string>()
|
|
4
|
-
|
|
5
|
-
export function setPropsToFontFamily(props: any, ff: string) {
|
|
6
|
-
cache.set(props, ff.replace('$', '').trim())
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function getFontFamilyNameFromProps(props: any) {
|
|
10
|
-
return cache.get(props)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function forwardFontFamilyName(prev: any, next: any, fallback?: string) {
|
|
14
|
-
const ff = getFontFamilyNameFromProps(prev) || fallback
|
|
15
|
-
if (ff) {
|
|
16
|
-
setPropsToFontFamily(next, ff)
|
|
17
|
-
}
|
|
18
|
-
}
|