@tamagui/static 3.0.0-beta.1479.1 → 3.0.0-beta.1540.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/compilerHost.cjs +159 -36
- package/dist/esm/compilerHost.mjs +159 -36
- package/dist/esm/compilerHost.mjs.map +1 -1
- package/package.json +18 -18
- package/src/compilerHost.ts +224 -79
- package/types/compilerHost.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/static",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.1540.1",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -45,22 +45,22 @@
|
|
|
45
45
|
"clean:build": "tamagui-build clean:build"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@tamagui/animation-helpers": "3.0.0-beta.
|
|
49
|
-
"@tamagui/cli-color": "3.0.0-beta.
|
|
50
|
-
"@tamagui/compiler-core": "3.0.0-beta.
|
|
51
|
-
"@tamagui/config-default": "3.0.0-beta.
|
|
52
|
-
"@tamagui/core": "3.0.0-beta.
|
|
53
|
-
"@tamagui/dom": "3.0.0-beta.
|
|
54
|
-
"@tamagui/fake-react-native": "3.0.0-beta.
|
|
55
|
-
"@tamagui/generate-themes": "3.0.0-beta.
|
|
56
|
-
"@tamagui/helpers": "3.0.0-beta.
|
|
57
|
-
"@tamagui/helpers-node": "3.0.0-beta.
|
|
58
|
-
"@tamagui/react-native-web-internals": "3.0.0-beta.
|
|
59
|
-
"@tamagui/react-native-web-lite": "3.0.0-beta.
|
|
60
|
-
"@tamagui/shorthands": "3.0.0-beta.
|
|
61
|
-
"@tamagui/style-grammar": "3.0.0-beta.
|
|
62
|
-
"@tamagui/types": "3.0.0-beta.
|
|
63
|
-
"@tamagui/web": "3.0.0-beta.
|
|
48
|
+
"@tamagui/animation-helpers": "3.0.0-beta.1540.1",
|
|
49
|
+
"@tamagui/cli-color": "3.0.0-beta.1540.1",
|
|
50
|
+
"@tamagui/compiler-core": "3.0.0-beta.1540.1",
|
|
51
|
+
"@tamagui/config-default": "3.0.0-beta.1540.1",
|
|
52
|
+
"@tamagui/core": "3.0.0-beta.1540.1",
|
|
53
|
+
"@tamagui/dom": "3.0.0-beta.1540.1",
|
|
54
|
+
"@tamagui/fake-react-native": "3.0.0-beta.1540.1",
|
|
55
|
+
"@tamagui/generate-themes": "3.0.0-beta.1540.1",
|
|
56
|
+
"@tamagui/helpers": "3.0.0-beta.1540.1",
|
|
57
|
+
"@tamagui/helpers-node": "3.0.0-beta.1540.1",
|
|
58
|
+
"@tamagui/react-native-web-internals": "3.0.0-beta.1540.1",
|
|
59
|
+
"@tamagui/react-native-web-lite": "3.0.0-beta.1540.1",
|
|
60
|
+
"@tamagui/shorthands": "3.0.0-beta.1540.1",
|
|
61
|
+
"@tamagui/style-grammar": "3.0.0-beta.1540.1",
|
|
62
|
+
"@tamagui/types": "3.0.0-beta.1540.1",
|
|
63
|
+
"@tamagui/web": "3.0.0-beta.1540.1",
|
|
64
64
|
"browserslist": "^4.28.1",
|
|
65
65
|
"check-dependency-version-consistency": "^4.1.0",
|
|
66
66
|
"esbuild": "0.28.1",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"react-native-web": "~0.21.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@tamagui/build": "3.0.0-beta.
|
|
76
|
+
"@tamagui/build": "3.0.0-beta.1540.1",
|
|
77
77
|
"@types/find-root": "^1.1.2",
|
|
78
78
|
"@types/node": "^22.1.0",
|
|
79
79
|
"@types/webpack": "^4.41.26",
|
package/src/compilerHost.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
BranchDecisionNode,
|
|
3
3
|
CompilerLoweringHost,
|
|
4
4
|
CompilerTarget,
|
|
5
|
+
DynamicEvaluation,
|
|
5
6
|
LoweringCandidateInput,
|
|
6
7
|
LoweringCandidateResult,
|
|
7
8
|
LoweringComponent,
|
|
@@ -686,6 +687,61 @@ const nativePointerEventProps = new Set([
|
|
|
686
687
|
'onPointerUp',
|
|
687
688
|
])
|
|
688
689
|
|
|
690
|
+
// expandStyle writes every shorthand as four longhands, and fabric pays per prop
|
|
691
|
+
// on mount (200 views: 8.8ms as longhands, 5.7ms as shorthands). when a hoisted
|
|
692
|
+
// static style holds all four sides equal and no other key of that family, the
|
|
693
|
+
// shorthand resolves identically in yoga, and any longhand in a later style
|
|
694
|
+
// object still overrides it
|
|
695
|
+
const nativeShorthandFamilies: [string, string[], RegExp][] = [
|
|
696
|
+
['padding', ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'], /^padding/],
|
|
697
|
+
['margin', ['marginTop', 'marginRight', 'marginBottom', 'marginLeft'], /^margin/],
|
|
698
|
+
[
|
|
699
|
+
'borderWidth',
|
|
700
|
+
['borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth'],
|
|
701
|
+
/^border.*Width$/,
|
|
702
|
+
],
|
|
703
|
+
[
|
|
704
|
+
'borderColor',
|
|
705
|
+
['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor'],
|
|
706
|
+
/^border.*Color$/,
|
|
707
|
+
],
|
|
708
|
+
[
|
|
709
|
+
'borderRadius',
|
|
710
|
+
[
|
|
711
|
+
'borderTopLeftRadius',
|
|
712
|
+
'borderTopRightRadius',
|
|
713
|
+
'borderBottomRightRadius',
|
|
714
|
+
'borderBottomLeftRadius',
|
|
715
|
+
],
|
|
716
|
+
/^border.*Radius$/,
|
|
717
|
+
],
|
|
718
|
+
]
|
|
719
|
+
|
|
720
|
+
function collapseNativeShorthands(style: unknown) {
|
|
721
|
+
if (!staticObject(style)) return style
|
|
722
|
+
const keys = Object.keys(style)
|
|
723
|
+
const collapsed = new Map<string, string>()
|
|
724
|
+
for (const [shorthand, sides, family] of nativeShorthandFamilies) {
|
|
725
|
+
const value = style[sides[0]]
|
|
726
|
+
if (
|
|
727
|
+
value !== undefined &&
|
|
728
|
+
!(shorthand in style) &&
|
|
729
|
+
sides.every((side) => style[side] === value) &&
|
|
730
|
+
keys.filter((key) => family.test(key)).length === sides.length
|
|
731
|
+
) {
|
|
732
|
+
for (const side of sides) collapsed.set(side, shorthand)
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
if (!collapsed.size) return style
|
|
736
|
+
const out: Record<string, unknown> = {}
|
|
737
|
+
for (const key of keys) {
|
|
738
|
+
const shorthand = collapsed.get(key)
|
|
739
|
+
if (!shorthand) out[key] = style[key]
|
|
740
|
+
else if (!(shorthand in out)) out[shorthand] = style[key]
|
|
741
|
+
}
|
|
742
|
+
return out
|
|
743
|
+
}
|
|
744
|
+
|
|
689
745
|
function isSerializableNativeStyle(value: unknown): boolean {
|
|
690
746
|
if (value == null || typeof value === 'number' || typeof value === 'boolean') {
|
|
691
747
|
return true
|
|
@@ -1395,6 +1451,21 @@ export function createTamaguiCompilerHost(
|
|
|
1395
1451
|
if (dynamic?.type !== 'string' || !dynamic.values?.length) return null
|
|
1396
1452
|
return dynamic.values.map(String)
|
|
1397
1453
|
}
|
|
1454
|
+
// an opaque native value the compiler can still lower: a finite domain
|
|
1455
|
+
// (a static array member, a template over one) resolves each value like a
|
|
1456
|
+
// conditional branch and selects it by the runtime value; an unbounded
|
|
1457
|
+
// number passes straight into the style key once probing proves the prop
|
|
1458
|
+
// maps numbers to that one key unchanged
|
|
1459
|
+
const nativeDynamicShape = (
|
|
1460
|
+
name: string,
|
|
1461
|
+
component: LoweringComponent,
|
|
1462
|
+
dynamic: DynamicEvaluation | null | undefined
|
|
1463
|
+
): 'domain' | 'number' | null => {
|
|
1464
|
+
if (!dynamic || !canLowerConditionalStyleProp(name, component)) return null
|
|
1465
|
+
if (dynamic.values?.length) return 'domain'
|
|
1466
|
+
if (dynamic.type === 'number' && directStyleName(name, component)) return 'number'
|
|
1467
|
+
return null
|
|
1468
|
+
}
|
|
1398
1469
|
type DynamicStyleEntry = Extract<
|
|
1399
1470
|
MaterializedElement['entries'][number],
|
|
1400
1471
|
{ kind: 'prop' }
|
|
@@ -1658,7 +1729,7 @@ export function createTamaguiCompilerHost(
|
|
|
1658
1729
|
return {
|
|
1659
1730
|
resolveComponent: resolve,
|
|
1660
1731
|
isStyleProp,
|
|
1661
|
-
canLowerDynamicStyleProp(name, component, valueKind) {
|
|
1732
|
+
canLowerDynamicStyleProp(name, component, valueKind, dynamic) {
|
|
1662
1733
|
// a conditional with static branches lowers per-branch on both
|
|
1663
1734
|
// platforms: each side resolves at compile time, only the test survives
|
|
1664
1735
|
if (
|
|
@@ -1684,7 +1755,10 @@ export function createTamaguiCompilerHost(
|
|
|
1684
1755
|
return (
|
|
1685
1756
|
!options.disablePartialExtraction &&
|
|
1686
1757
|
((platform === 'web' && !!directStyleName(name, component)) ||
|
|
1687
|
-
(platform === 'native' &&
|
|
1758
|
+
(platform === 'native' &&
|
|
1759
|
+
(directStyleName(name, component) === 'opacity' ||
|
|
1760
|
+
(valueKind === 'bailout' &&
|
|
1761
|
+
nativeDynamicShape(name, component, dynamic) !== null))))
|
|
1688
1762
|
)
|
|
1689
1763
|
},
|
|
1690
1764
|
developmentDebugInstrumentation,
|
|
@@ -2331,7 +2405,9 @@ export function createTamaguiCompilerHost(
|
|
|
2331
2405
|
entry.kind === 'prop' &&
|
|
2332
2406
|
(directStyleName(entry.name, component) === 'opacity' ||
|
|
2333
2407
|
(entry.value.kind === 'conditional' &&
|
|
2334
|
-
canLowerConditionalStyleProp(entry.name, component))
|
|
2408
|
+
canLowerConditionalStyleProp(entry.name, component)) ||
|
|
2409
|
+
(entry.value.kind === 'bailout' &&
|
|
2410
|
+
nativeDynamicShape(entry.name, component, entry.value.dynamic) !== null))
|
|
2335
2411
|
)
|
|
2336
2412
|
if (
|
|
2337
2413
|
dynamicStyleEntries.length > 0 &&
|
|
@@ -2743,9 +2819,15 @@ export function createTamaguiCompilerHost(
|
|
|
2743
2819
|
input.source,
|
|
2744
2820
|
`__TamaguiNativeStyle${input.element.span.start}`
|
|
2745
2821
|
)
|
|
2822
|
+
// the native style engine pushes the runtime's exact keys, so its base keeps them
|
|
2823
|
+
const usesNativeFastPath =
|
|
2824
|
+
!!themedStyleKeys &&
|
|
2825
|
+
!!options.experimentalNativeFastPath &&
|
|
2826
|
+
dynamicStyleEntries.length === 0 &&
|
|
2827
|
+
!input.element.entries.some((entry) => entry.kind === 'spread')
|
|
2746
2828
|
const nativeStyleImports = [
|
|
2747
2829
|
{
|
|
2748
|
-
content: `\nfunction ${nativeStyleLocal}() { return ${nativeStyleLocal}._ ?? (${nativeStyleLocal}._ = ${JSON.stringify(nativeStyle ?? {})}); } ${nativeStyleLocal}();`,
|
|
2830
|
+
content: `\nfunction ${nativeStyleLocal}() { return ${nativeStyleLocal}._ ?? (${nativeStyleLocal}._ = ${JSON.stringify((usesNativeFastPath ? nativeStyle : collapseNativeShorthands(nativeStyle)) ?? {})}); } ${nativeStyleLocal}();`,
|
|
2749
2831
|
origin: input.element.component.span,
|
|
2750
2832
|
},
|
|
2751
2833
|
]
|
|
@@ -2756,12 +2838,7 @@ export function createTamaguiCompilerHost(
|
|
|
2756
2838
|
mappingLocal: string
|
|
2757
2839
|
}
|
|
2758
2840
|
| undefined
|
|
2759
|
-
if (
|
|
2760
|
-
themedStyleKeys &&
|
|
2761
|
-
options.experimentalNativeFastPath &&
|
|
2762
|
-
dynamicStyleEntries.length === 0 &&
|
|
2763
|
-
!input.element.entries.some((entry) => entry.kind === 'spread')
|
|
2764
|
-
) {
|
|
2841
|
+
if (usesNativeFastPath) {
|
|
2765
2842
|
const mappingLocal = unusedIdentifier(
|
|
2766
2843
|
input.source,
|
|
2767
2844
|
`__TamaguiNativeMapping${input.element.span.start}`
|
|
@@ -3137,7 +3214,77 @@ export function createTamaguiCompilerHost(
|
|
|
3137
3214
|
const baseStyleForDiff = staticObject(nativeStyleResolved)
|
|
3138
3215
|
? nativeStyleResolved
|
|
3139
3216
|
: {}
|
|
3217
|
+
// resolves the element with one value in place of the dynamic prop
|
|
3218
|
+
// and returns what that value adds over the static style
|
|
3219
|
+
const valueDiff = (
|
|
3220
|
+
entry: DynamicStyleEntry,
|
|
3221
|
+
value: unknown,
|
|
3222
|
+
what: string
|
|
3223
|
+
): Record<string, unknown> | string => {
|
|
3224
|
+
const { branchCompleteProps } = propsForConditional(entry, value)
|
|
3225
|
+
const branchSplit = resolveSplitStyles(
|
|
3226
|
+
branchCompleteProps,
|
|
3227
|
+
component.staticConfig,
|
|
3228
|
+
cssAnimationDriver,
|
|
3229
|
+
component.displayName
|
|
3230
|
+
)
|
|
3231
|
+
const branchStyle = branchSplit?.viewProps?.style ?? {}
|
|
3232
|
+
if (!staticObject(branchStyle)) {
|
|
3233
|
+
return `${what} did not resolve to a static native style`
|
|
3234
|
+
}
|
|
3235
|
+
// a value (e.g. through a variant) may change viewProps beyond
|
|
3236
|
+
// style; the style array cannot express those, so any non-style
|
|
3237
|
+
// difference sends the element to the runtime path
|
|
3238
|
+
for (const viewPropsKey of new Set([
|
|
3239
|
+
...Object.keys(branchSplit?.viewProps ?? {}),
|
|
3240
|
+
...Object.keys(split.viewProps ?? {}),
|
|
3241
|
+
])) {
|
|
3242
|
+
if (viewPropsKey === 'style') continue
|
|
3243
|
+
if (
|
|
3244
|
+
JSON.stringify(branchSplit?.viewProps?.[viewPropsKey]) !==
|
|
3245
|
+
JSON.stringify((split.viewProps as any)?.[viewPropsKey])
|
|
3246
|
+
) {
|
|
3247
|
+
return `${what} changes ${viewPropsKey}, which the compiled style array cannot express`
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
for (const key of Object.keys(baseStyleForDiff)) {
|
|
3251
|
+
if (!(key in branchStyle)) {
|
|
3252
|
+
return `${what} removes ${key}, which an additive style array cannot express`
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
const diff: Record<string, unknown> = {}
|
|
3256
|
+
for (const [key, value] of Object.entries(branchStyle)) {
|
|
3257
|
+
if (
|
|
3258
|
+
JSON.stringify((baseStyleForDiff as any)[key]) !== JSON.stringify(value)
|
|
3259
|
+
) {
|
|
3260
|
+
diff[key] = value
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
if (!isSerializableNativeStyle(diff) || core.containsThemeRef(diff)) {
|
|
3264
|
+
return `${what} style is not statically representable`
|
|
3265
|
+
}
|
|
3266
|
+
return diff
|
|
3267
|
+
}
|
|
3268
|
+
// each dynamic prop owns the keys it contributes; two props writing
|
|
3269
|
+
// one key would need their source order resolved at runtime
|
|
3270
|
+
const claimKeys = (entry: DynamicStyleEntry, keys: Iterable<string>) => {
|
|
3271
|
+
for (const key of keys) {
|
|
3272
|
+
if (conditionalKeys.has(key)) {
|
|
3273
|
+
return bailout(
|
|
3274
|
+
input,
|
|
3275
|
+
'local/dynamic-style-value',
|
|
3276
|
+
`Multiple dynamic props contribute ${key}; their interaction cannot be resolved at compile time`,
|
|
3277
|
+
entry.value.span
|
|
3278
|
+
)
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
return null
|
|
3282
|
+
}
|
|
3140
3283
|
for (const entry of dynamicStyleEntries) {
|
|
3284
|
+
const shape =
|
|
3285
|
+
entry.value.kind === 'bailout'
|
|
3286
|
+
? nativeDynamicShape(entry.name, component, entry.value.dynamic)
|
|
3287
|
+
: null
|
|
3141
3288
|
// opacity keeps the leaner inline-expression form even for
|
|
3142
3289
|
// ternaries; per-branch lowering is for props that form cannot carry
|
|
3143
3290
|
if (
|
|
@@ -3151,79 +3298,21 @@ export function createTamaguiCompilerHost(
|
|
|
3151
3298
|
Record<string, unknown>
|
|
3152
3299
|
>()
|
|
3153
3300
|
for (const leaf of leaves) {
|
|
3154
|
-
const
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
cssAnimationDriver,
|
|
3159
|
-
component.displayName
|
|
3301
|
+
const diff = valueDiff(
|
|
3302
|
+
entry,
|
|
3303
|
+
leaf.value,
|
|
3304
|
+
`Conditional ${entry.name} branch`
|
|
3160
3305
|
)
|
|
3161
|
-
|
|
3162
|
-
if (!staticObject(branchStyle)) {
|
|
3306
|
+
if (typeof diff === 'string') {
|
|
3163
3307
|
return bailout(
|
|
3164
3308
|
input,
|
|
3165
3309
|
'local/dynamic-style-value',
|
|
3166
|
-
|
|
3310
|
+
diff,
|
|
3167
3311
|
entry.value.span
|
|
3168
3312
|
)
|
|
3169
3313
|
}
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
// non-style difference sends the element to the runtime path
|
|
3173
|
-
for (const viewPropsKey of new Set([
|
|
3174
|
-
...Object.keys(branchSplit?.viewProps ?? {}),
|
|
3175
|
-
...Object.keys(split.viewProps ?? {}),
|
|
3176
|
-
])) {
|
|
3177
|
-
if (viewPropsKey === 'style') continue
|
|
3178
|
-
if (
|
|
3179
|
-
JSON.stringify(branchSplit?.viewProps?.[viewPropsKey]) !==
|
|
3180
|
-
JSON.stringify((split.viewProps as any)?.[viewPropsKey])
|
|
3181
|
-
) {
|
|
3182
|
-
return bailout(
|
|
3183
|
-
input,
|
|
3184
|
-
'local/dynamic-style-value',
|
|
3185
|
-
`Conditional ${entry.name} branch changes ${viewPropsKey}, which the compiled style array cannot express`,
|
|
3186
|
-
entry.value.span
|
|
3187
|
-
)
|
|
3188
|
-
}
|
|
3189
|
-
}
|
|
3190
|
-
for (const key of Object.keys(baseStyleForDiff)) {
|
|
3191
|
-
if (!(key in branchStyle)) {
|
|
3192
|
-
return bailout(
|
|
3193
|
-
input,
|
|
3194
|
-
'local/dynamic-style-value',
|
|
3195
|
-
`Conditional ${entry.name} branch removes ${key}, which an additive style array cannot express`,
|
|
3196
|
-
entry.value.span
|
|
3197
|
-
)
|
|
3198
|
-
}
|
|
3199
|
-
}
|
|
3200
|
-
const diff: Record<string, unknown> = {}
|
|
3201
|
-
for (const [key, value] of Object.entries(branchStyle)) {
|
|
3202
|
-
if (
|
|
3203
|
-
JSON.stringify((baseStyleForDiff as any)[key]) !==
|
|
3204
|
-
JSON.stringify(value)
|
|
3205
|
-
) {
|
|
3206
|
-
diff[key] = value
|
|
3207
|
-
}
|
|
3208
|
-
}
|
|
3209
|
-
if (!isSerializableNativeStyle(diff) || core.containsThemeRef(diff)) {
|
|
3210
|
-
return bailout(
|
|
3211
|
-
input,
|
|
3212
|
-
'local/dynamic-style-value',
|
|
3213
|
-
`Conditional ${entry.name} branch style is not statically representable`,
|
|
3214
|
-
entry.value.span
|
|
3215
|
-
)
|
|
3216
|
-
}
|
|
3217
|
-
for (const key of Object.keys(diff)) {
|
|
3218
|
-
if (conditionalKeys.has(key)) {
|
|
3219
|
-
return bailout(
|
|
3220
|
-
input,
|
|
3221
|
-
'local/dynamic-style-value',
|
|
3222
|
-
`Multiple conditionals contribute ${key}; their interaction cannot be resolved per-branch`,
|
|
3223
|
-
entry.value.span
|
|
3224
|
-
)
|
|
3225
|
-
}
|
|
3226
|
-
}
|
|
3314
|
+
const conflict = claimKeys(entry, Object.keys(diff))
|
|
3315
|
+
if (conflict) return conflict
|
|
3227
3316
|
leafDiffs.set(leaf, diff)
|
|
3228
3317
|
}
|
|
3229
3318
|
for (const diff of leafDiffs.values()) {
|
|
@@ -3241,14 +3330,70 @@ export function createTamaguiCompilerHost(
|
|
|
3241
3330
|
}
|
|
3242
3331
|
|
|
3243
3332
|
conditionalParts.push(serializeNativeTree(tree))
|
|
3244
|
-
} else {
|
|
3333
|
+
} else if (shape === 'domain' && entry.value.kind === 'bailout') {
|
|
3334
|
+
// a finite domain is a lookup from each runtime value to its diff
|
|
3335
|
+
const lookup: string[] = []
|
|
3336
|
+
const keys = new Set<string>()
|
|
3337
|
+
for (const value of entry.value.dynamic!.values!) {
|
|
3338
|
+
const diff = valueDiff(
|
|
3339
|
+
entry,
|
|
3340
|
+
value,
|
|
3341
|
+
`${entry.name} value ${JSON.stringify(value)}`
|
|
3342
|
+
)
|
|
3343
|
+
if (typeof diff === 'string') {
|
|
3344
|
+
return bailout(
|
|
3345
|
+
input,
|
|
3346
|
+
'local/dynamic-style-value',
|
|
3347
|
+
diff,
|
|
3348
|
+
entry.value.span
|
|
3349
|
+
)
|
|
3350
|
+
}
|
|
3351
|
+
for (const key of Object.keys(diff)) keys.add(key)
|
|
3352
|
+
lookup.push(`${JSON.stringify(String(value))}: ${JSON.stringify(diff)}`)
|
|
3353
|
+
}
|
|
3354
|
+
const conflict = claimKeys(entry, keys)
|
|
3355
|
+
if (conflict) return conflict
|
|
3356
|
+
for (const key of keys) conditionalKeys.add(key)
|
|
3245
3357
|
const index = expressions.length
|
|
3246
3358
|
expressions.push(
|
|
3247
3359
|
input.source.slice(entry.value.span.start, entry.value.span.end)
|
|
3248
3360
|
)
|
|
3249
|
-
|
|
3250
|
-
|
|
3361
|
+
conditionalParts.push(`({ ${lookup.join(', ')} })[expressions[${index}]]`)
|
|
3362
|
+
} else {
|
|
3363
|
+
const key = directStyleName(entry.name, component)!
|
|
3364
|
+
if (shape === 'number') {
|
|
3365
|
+
// two probes prove a number lands unchanged in exactly this key
|
|
3366
|
+
for (const probe of [7.25, 1031]) {
|
|
3367
|
+
const diff = valueDiff(entry, probe, `${entry.name} number`)
|
|
3368
|
+
if (
|
|
3369
|
+
typeof diff === 'string' ||
|
|
3370
|
+
JSON.stringify(diff) !== JSON.stringify({ [key]: probe })
|
|
3371
|
+
) {
|
|
3372
|
+
return bailout(
|
|
3373
|
+
input,
|
|
3374
|
+
'local/dynamic-style-value',
|
|
3375
|
+
`Style prop ${entry.name} transforms numbers on native, so its runtime value cannot pass through`,
|
|
3376
|
+
entry.value.span
|
|
3377
|
+
)
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
if (key in baseStyleForDiff) {
|
|
3381
|
+
return bailout(
|
|
3382
|
+
input,
|
|
3383
|
+
'local/dynamic-style-value',
|
|
3384
|
+
`Style prop ${entry.name} overlaps a static ${key}`,
|
|
3385
|
+
entry.value.span
|
|
3386
|
+
)
|
|
3387
|
+
}
|
|
3388
|
+
const conflict = claimKeys(entry, [key])
|
|
3389
|
+
if (conflict) return conflict
|
|
3390
|
+
conditionalKeys.add(key)
|
|
3391
|
+
}
|
|
3392
|
+
const index = expressions.length
|
|
3393
|
+
expressions.push(
|
|
3394
|
+
input.source.slice(entry.value.span.start, entry.value.span.end)
|
|
3251
3395
|
)
|
|
3396
|
+
plainDynamicParts.push(`${JSON.stringify(key)}: expressions[${index}]`)
|
|
3252
3397
|
}
|
|
3253
3398
|
}
|
|
3254
3399
|
const dynamicStyle = plainDynamicParts.join(', ')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compilerHost.d.ts","sourceRoot":"","sources":["../src/compilerHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,cAAc,
|
|
1
|
+
{"version":3,"file":"compilerHost.d.ts","sourceRoot":"","sources":["../src/compilerHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,cAAc,EASf,MAAM,wBAAwB,CAAA;AAoC/B,OAAO,KAAK,EAAiC,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAExF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAIhE,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;CAClD;AAED,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,SAAS,gBAAgB,EAAE,EACvC,gBAAgB,EAAE,SAAS,uBAAuB,EAAE,GACnD,yBAAyB,CAS3B;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,cAAc,CAAA;IACtB,aAAa,EAAE,qBAAqB,CAAA;IACpC,UAAU,EAAE,gBAAgB,EAAE,CAAA;IAC9B,gBAAgB,EAAE,uBAAuB,EAAE,CAAA;IAC3C,qFAAqF;IACrF,QAAQ,CAAC,EAAE,yBAAyB,CAAA;IACpC,wEAAwE;IACxE,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,mEAAmE;IACnE,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AA88BD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,oBAAoB,CAq1FtB"}
|