@tamagui/fake-react-native 2.7.7-1788328229285 → 3.0.0-beta.1091.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.
Files changed (3) hide show
  1. package/index.js +57 -1
  2. package/index.mjs +18 -0
  3. package/package.json +2 -1
package/index.js CHANGED
@@ -18,24 +18,68 @@ const emtpyComponent = () => null
18
18
  // Mock usePressability for testing - returns empty event handlers
19
19
  const usePressabilityMock = () => ({})
20
20
 
21
+ // real context: consumers (tamagui's useChildren) call React.useContext on it,
22
+ // the proxyWorm fallback object would break that
23
+ const TextAncestorContext = React.createContext(false)
24
+ const Animated = {
25
+ createAnimatedComponent: (Component) => Component,
26
+ }
27
+ const Keyboard = {
28
+ addListener: () => ({ remove: () => {} }),
29
+ removeAllListeners: () => {},
30
+ dismiss: () => {},
31
+ }
32
+ const useWindowDimensions = () => ({
33
+ width: 1024,
34
+ height: 768,
35
+ scale: 2,
36
+ fontScale: 1,
37
+ })
38
+ const PanResponder = {
39
+ create: (handlers) => ({ panHandlers: handlers }),
40
+ }
41
+ const TurboModuleRegistry = {
42
+ get: () => null,
43
+ }
44
+ const PixelRatio = {
45
+ get: () => 2,
46
+ getFontScale: () => 1,
47
+ getPixelSizeForLayoutSize: (size) => Math.round(size * 2),
48
+ roundToNearestPixel: (size) => Math.round(size * 2) / 2,
49
+ }
50
+ const codegenNativeCommands = () => ({})
51
+ const codegenNativeComponent = (name) => createMockComponent(name)
52
+
21
53
  function proxyWorm() {
22
54
  return new Proxy(
23
55
  {
24
56
  StyleSheet: {
25
57
  create() {},
26
58
  },
59
+ unstable_TextAncestorContext: TextAncestorContext,
27
60
  Platform: {
28
61
  OS: 'web',
62
+ select: (options) => options.web ?? options.default,
29
63
  },
30
64
  Image: emtpyComponent,
31
65
  View: createMockComponent('View'),
32
66
  Text: createMockComponent('Text'),
33
67
  TextInput: createMockComponent('TextInput'),
34
68
  ScrollView: createMockComponent('ScrollView'),
69
+ FlatList: createMockComponent('FlatList'),
70
+ Pressable: createMockComponent('Pressable'),
71
+ Animated,
72
+ NativeModules: {},
73
+ PanResponder,
74
+ TurboModuleRegistry,
75
+ PixelRatio,
76
+ processColor: (color) => color,
35
77
  Dimensions: {
36
- get: () => ({ width: 1024, height: 768 }),
78
+ get: () => ({ width: 1024, height: 768, scale: 2, fontScale: 1 }),
37
79
  addEventListener: () => ({ remove: () => {} }),
38
80
  },
81
+ useWindowDimensions,
82
+ Keyboard,
39
83
  Appearance: {
40
84
  getColorScheme: () => 'light',
41
85
  addChangeListener: () => {},
@@ -73,5 +117,17 @@ module.exports.View = proxy.View
73
117
  module.exports.Text = proxy.Text
74
118
  module.exports.TextInput = proxy.TextInput
75
119
  module.exports.ScrollView = proxy.ScrollView
120
+ module.exports.FlatList = proxy.FlatList
121
+ module.exports.Pressable = proxy.Pressable
122
+ module.exports.Animated = proxy.Animated
123
+ module.exports.NativeModules = proxy.NativeModules
124
+ module.exports.PanResponder = proxy.PanResponder
125
+ module.exports.TurboModuleRegistry = proxy.TurboModuleRegistry
126
+ module.exports.PixelRatio = PixelRatio
127
+ module.exports.processColor = proxy.processColor
76
128
  module.exports.Dimensions = proxy.Dimensions
129
+ module.exports.useWindowDimensions = useWindowDimensions
130
+ module.exports.Keyboard = Keyboard
77
131
  module.exports.Appearance = proxy.Appearance
132
+ module.exports.codegenNativeCommands = codegenNativeCommands
133
+ module.exports.codegenNativeComponent = codegenNativeComponent
package/index.mjs CHANGED
@@ -1,11 +1,18 @@
1
+ import React from 'react'
2
+
1
3
  const emtpyComponent = () => null
2
4
 
5
+ // real context: consumers (tamagui's useChildren) call React.useContext on it,
6
+ // the proxyWorm fallback object would break that
7
+ const TextAncestorContext = React.createContext(false)
8
+
3
9
  function proxyWorm() {
4
10
  return new Proxy(
5
11
  {
6
12
  StyleSheet: {
7
13
  create() {},
8
14
  },
15
+ unstable_TextAncestorContext: TextAncestorContext,
9
16
  Platform: {
10
17
  OS: 'web',
11
18
  },
@@ -15,8 +22,15 @@ function proxyWorm() {
15
22
  TextInput: emtpyComponent,
16
23
  ScrollView: emtpyComponent,
17
24
  Dimensions: {
25
+ get: () => ({ width: 1024, height: 768, scale: 2, fontScale: 1 }),
18
26
  addEventListener(cb) {},
19
27
  },
28
+ PixelRatio: {
29
+ get: () => 2,
30
+ getFontScale: () => 1,
31
+ getPixelSizeForLayoutSize: (size) => Math.round(size * 2),
32
+ roundToNearestPixel: (size) => Math.round(size * 2) / 2,
33
+ },
20
34
  Appearance: {
21
35
  getColorScheme: () => 'light',
22
36
  addChangeListener: () => {},
@@ -46,12 +60,16 @@ export const Text = proxy.Text
46
60
  export const TextInput = proxy.TextInput
47
61
  export const ScrollView = proxy.ScrollView
48
62
  export const Dimensions = proxy.Dimensions
63
+ export const PixelRatio = proxy.PixelRatio
49
64
  export const Pressable = proxy.Pressable
50
65
  export const Animated = proxy.Animated
51
66
  export const Easing = proxy.Easing
52
67
  export const Appearance = proxy.Appearance
53
68
  export const findNodeHandle = proxy.findNodeHandle
54
69
  export const unstable_batchedUpdates = proxy.unstable_batchedUpdates
70
+ export const unstable_TextAncestorContext = proxy.unstable_TextAncestorContext
71
+ export const codegenNativeCommands = () => ({})
72
+ export const codegenNativeComponent = () => emtpyComponent
55
73
 
56
74
  // Default export
57
75
  export default proxy
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@tamagui/fake-react-native",
3
- "version": "2.7.7-1788328229285",
3
+ "version": "3.0.0-beta.1091.1",
4
+ "license": "MIT",
4
5
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
6
  "main": "index.js",
6
7
  "module": "index.mjs",