@tamagui/static 3.0.0-beta.901.1 → 3.0.0-beta.917.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/static",
3
- "version": "3.0.0-beta.901.1",
3
+ "version": "3.0.0-beta.917.1",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "license": "MIT",
6
6
  "source": "src/index.ts",
@@ -45,21 +45,21 @@
45
45
  "clean:build": "tamagui-build clean:build"
46
46
  },
47
47
  "dependencies": {
48
- "@tamagui/cli-color": "3.0.0-beta.901.1",
49
- "@tamagui/compiler-core": "3.0.0-beta.901.1",
50
- "@tamagui/config-default": "3.0.0-beta.901.1",
51
- "@tamagui/core": "3.0.0-beta.901.1",
52
- "@tamagui/dom": "3.0.0-beta.901.1",
53
- "@tamagui/fake-react-native": "3.0.0-beta.901.1",
54
- "@tamagui/generate-themes": "3.0.0-beta.901.1",
55
- "@tamagui/helpers": "3.0.0-beta.901.1",
56
- "@tamagui/helpers-node": "3.0.0-beta.901.1",
57
- "@tamagui/react-native-web-internals": "3.0.0-beta.901.1",
58
- "@tamagui/react-native-web-lite": "3.0.0-beta.901.1",
59
- "@tamagui/shorthands": "3.0.0-beta.901.1",
60
- "@tamagui/style-grammar": "3.0.0-beta.901.1",
61
- "@tamagui/types": "3.0.0-beta.901.1",
62
- "@tamagui/web": "3.0.0-beta.901.1",
48
+ "@tamagui/cli-color": "3.0.0-beta.917.1",
49
+ "@tamagui/compiler-core": "3.0.0-beta.917.1",
50
+ "@tamagui/config-default": "3.0.0-beta.917.1",
51
+ "@tamagui/core": "3.0.0-beta.917.1",
52
+ "@tamagui/dom": "3.0.0-beta.917.1",
53
+ "@tamagui/fake-react-native": "3.0.0-beta.917.1",
54
+ "@tamagui/generate-themes": "3.0.0-beta.917.1",
55
+ "@tamagui/helpers": "3.0.0-beta.917.1",
56
+ "@tamagui/helpers-node": "3.0.0-beta.917.1",
57
+ "@tamagui/react-native-web-internals": "3.0.0-beta.917.1",
58
+ "@tamagui/react-native-web-lite": "3.0.0-beta.917.1",
59
+ "@tamagui/shorthands": "3.0.0-beta.917.1",
60
+ "@tamagui/style-grammar": "3.0.0-beta.917.1",
61
+ "@tamagui/types": "3.0.0-beta.917.1",
62
+ "@tamagui/web": "3.0.0-beta.917.1",
63
63
  "browserslist": "^4.28.1",
64
64
  "check-dependency-version-consistency": "^4.1.0",
65
65
  "esbuild": "0.28.1",
@@ -71,7 +71,7 @@
71
71
  "react-native-web": "~0.21.0"
72
72
  },
73
73
  "devDependencies": {
74
- "@tamagui/build": "3.0.0-beta.901.1",
74
+ "@tamagui/build": "3.0.0-beta.917.1",
75
75
  "@types/find-root": "^1.1.2",
76
76
  "@types/node": "^22.1.0",
77
77
  "@types/webpack": "^4.41.26",
@@ -3443,6 +3443,13 @@ export function createTamaguiCompilerHost(
3443
3443
  const webConditionalCSS: string[] = []
3444
3444
  const webConditionalKeys = new Set<string>()
3445
3445
  const webConditionalEntries = supportsWebConditionalClasses ? webClassEntries : []
3446
+ // inline style from conditional branches: a value every branch shares
3447
+ // hoists into the element's style, and a value that differs becomes one
3448
+ // conditional inline property. the css driver keeps transitioned
3449
+ // properties inline, so this is how a conditional className carrying
3450
+ // `transition-*` classes lowers
3451
+ let webInlineStyle: Record<string, unknown> | null = inlineStyle
3452
+ const conditionalInlineProperties: string[] = []
3446
3453
  for (const entry of webConditionalEntries) {
3447
3454
  const tree = entry.value.kind === 'conditional' ? entry.value.tree : null
3448
3455
  const domain = frontendClassDomain(entry, component)
@@ -3454,6 +3461,7 @@ export function createTamaguiCompilerHost(
3454
3461
  (typeof leaves)[number],
3455
3462
  { classes: string[]; css: string[] }
3456
3463
  >()
3464
+ const leafStyles = new Map<(typeof leaves)[number], Record<string, unknown>>()
3457
3465
  const entryConditionalKeys = new Set<string>()
3458
3466
 
3459
3467
  for (const leaf of leaves) {
@@ -3479,7 +3487,7 @@ export function createTamaguiCompilerHost(
3479
3487
  ...Object.keys(branchSplit.viewProps ?? {}),
3480
3488
  ...Object.keys(split.viewProps ?? {}),
3481
3489
  ])) {
3482
- if (viewPropsKey === 'className') continue
3490
+ if (viewPropsKey === 'className' || viewPropsKey === 'style') continue
3483
3491
  if (
3484
3492
  JSON.stringify(branchSplit.viewProps?.[viewPropsKey]) !==
3485
3493
  JSON.stringify((split.viewProps as any)?.[viewPropsKey])
@@ -3492,6 +3500,19 @@ export function createTamaguiCompilerHost(
3492
3500
  )
3493
3501
  }
3494
3502
  }
3503
+ const branchInline = branchSplit.viewProps?.style
3504
+ if (branchInline !== undefined && !staticObject(branchInline)) {
3505
+ return bailout(
3506
+ input,
3507
+ 'local/dynamic-style-value',
3508
+ `Conditional ${entry.name} branch style is not a static object`,
3509
+ entry.value.span
3510
+ )
3511
+ }
3512
+ leafStyles.set(
3513
+ leaf,
3514
+ staticObject(branchInline) ? (branchInline as Record<string, unknown>) : {}
3515
+ )
3495
3516
  const changedKeys = new Set<string>()
3496
3517
  for (const key of new Set([
3497
3518
  ...Object.keys(branchSplit.classNames ?? {}),
@@ -3553,6 +3574,41 @@ export function createTamaguiCompilerHost(
3553
3574
  }
3554
3575
  for (const key of entryConditionalKeys) webConditionalKeys.add(key)
3555
3576
 
3577
+ const styleKeys = new Set<string>(Object.keys(webInlineStyle ?? {}))
3578
+ for (const leaf of leaves) {
3579
+ for (const key of Object.keys(leafStyles.get(leaf) ?? {})) styleKeys.add(key)
3580
+ }
3581
+ for (const key of styleKeys) {
3582
+ const serialized = leaves.map((leaf) =>
3583
+ JSON.stringify(leafStyles.get(leaf)?.[key])
3584
+ )
3585
+ if (serialized.every((value) => value === serialized[0])) {
3586
+ if (serialized[0] === JSON.stringify(webInlineStyle?.[key])) continue
3587
+ const next = { ...webInlineStyle }
3588
+ if (serialized[0] === undefined) delete next[key]
3589
+ else next[key] = leafStyles.get(leaves[0]!)![key]
3590
+ webInlineStyle = Object.keys(next).length > 0 ? next : null
3591
+ continue
3592
+ }
3593
+ if (!tree) {
3594
+ return bailout(
3595
+ input,
3596
+ 'local/dynamic-style-value',
3597
+ `Conditional ${entry.name} branch changes style, which a class table cannot express`,
3598
+ entry.value.span
3599
+ )
3600
+ }
3601
+ const serializeValue = (node: BranchDecisionNode): string => {
3602
+ if (node.kind === 'leaf')
3603
+ return String(JSON.stringify(leafStyles.get(node)?.[key]))
3604
+ const test = input.source.slice(node.test.start, node.test.end)
3605
+ return `(${test}) ? ${serializeValue(node.whenTrue)} : ${serializeValue(node.whenFalse)}`
3606
+ }
3607
+ conditionalInlineProperties.push(
3608
+ `${JSON.stringify(key)}: (${serializeValue(tree)})`
3609
+ )
3610
+ }
3611
+
3556
3612
  for (const artifacts of leafArtifactsMap.values()) {
3557
3613
  webConditionalCSS.push(...artifacts.css)
3558
3614
  }
@@ -3585,7 +3641,10 @@ export function createTamaguiCompilerHost(
3585
3641
  return `(${test}) ? ${truePart} : ${falsePart}`
3586
3642
  }
3587
3643
 
3588
- if (tree) {
3644
+ if (leaves.every((leaf) => leafClasses(leaf) === '')) {
3645
+ // every branch's classes hoisted, or the branches differ only in
3646
+ // inline style
3647
+ } else if (tree) {
3589
3648
  programClassSources.push(serializeWebTree(tree))
3590
3649
  } else {
3591
3650
  // the runtime string picks its resolved classes; a string outside the
@@ -3602,10 +3661,11 @@ export function createTamaguiCompilerHost(
3602
3661
  const classNameExpression = hasStyleProgram
3603
3662
  ? `[${[JSON.stringify(webClassName), ...programClassSources].join(', ')}].filter(Boolean).join(" ")`
3604
3663
  : null
3605
- const serializedInlineStyle = serializedStyle(
3606
- inlineStyle,
3607
- dynamicHostStyleProperties ?? []
3608
- )
3664
+ const webInlineProperties = [
3665
+ ...(dynamicHostStyleProperties ?? []),
3666
+ ...conditionalInlineProperties,
3667
+ ]
3668
+ const serializedInlineStyle = serializedStyle(webInlineStyle, webInlineProperties)
3609
3669
  const jsxWebStyle = classNameExpression
3610
3670
  ? [
3611
3671
  `className={${classNameExpression}}`,
@@ -3613,7 +3673,7 @@ export function createTamaguiCompilerHost(
3613
3673
  ]
3614
3674
  .filter(Boolean)
3615
3675
  .join(' ')
3616
- : jsxStyleAttributes(webClassName, inlineStyle, dynamicHostStyleProperties ?? [])
3676
+ : jsxStyleAttributes(webClassName, webInlineStyle, webInlineProperties)
3617
3677
  const objectWebStyle = classNameExpression
3618
3678
  ? [
3619
3679
  `className: ${classNameExpression}`,
@@ -3621,11 +3681,7 @@ export function createTamaguiCompilerHost(
3621
3681
  ]
3622
3682
  .filter(Boolean)
3623
3683
  .join(', ')
3624
- : objectStyleProperties(
3625
- webClassName,
3626
- inlineStyle,
3627
- dynamicHostStyleProperties ?? []
3628
- )
3684
+ : objectStyleProperties(webClassName, webInlineStyle, webInlineProperties)
3629
3685
  const webCSS = [...new Set([...artifacts.css, ...programCSS, ...webConditionalCSS])]
3630
3686
  const webExtraProps = serializedProps(input.element.form, webDOMResult.additions)
3631
3687
  if (input.element.form !== 'jsx') {
@@ -1 +1 @@
1
- {"version":3,"file":"compilerHost.d.ts","sourceRoot":"","sources":["../src/compilerHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,cAAc,EAQf,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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