Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StyleSheet with styleq runtime #2208

Closed
wants to merge 3 commits into from
Closed

StyleSheet with styleq runtime #2208

wants to merge 3 commits into from

Conversation

necolas
Copy link
Owner

@necolas necolas commented Jan 28, 2022

StyleSheet refactor

Build: npm i react-native-web@0.0.0-b096cd2d

  • Improves React Native compatibility by making StyleSheet.create the identify function.
  • Improves RTL support, correctly styling nested LTR/RTL contexts.
  • Supports React 18 by inserting styles on eval, not render. SSR must extract all styles from the app at build time (i.e., no streaming of styles). This can be done without a compiler by using StyleSheet.getSheet() after evaling all styled components.
  • Supports use with multiple windows (i.e., iframes) and shadow roots.
  • Supports 3rd party compilers and extraction to static CSS.
  • Fixes static and dynamic short/longform deduplication
  • Reduces browser support: Safari 10.1+, Chromium Edge, no IE, no legacy Android browsers.
  • Removes automatic vendor-prefixing of inline styles (for better perf).
  • Removes legacy I18nManager.swapLeftAndRightInRTL() and I18nManager.doLeftAndRightSwapInRTL.
  • Removes focus-visible polyfill as modern browsers no longer show focus rings for mouse interactions.

Fix #2138
Fix #2196
Fix #2210
Fix #2007
Fix #1517

Todo

  • Revisit focus-visible polyfill.
  • Fix SSR and add reliable SSR unit tests
  • Add link style reset to View
  • Revisit RTL polyfill format to better suit build-time compilers.
  • Move multi-root StyleSheet logic to render.
  • Update localization docs.
  • Add deprecation warning to setNativeProps.

@github-actions
Copy link

github-actions bot commented Jan 28, 2022

Size change: -1.53 kB
Total size: 129.12 kB

Filename: gzip (minify) kB size kB change % change
./packages/react-native-web/dist/exports/ActivityIndicator/index.js 0.98 (1.97) -0.01 (-0.02) -0.6% (-1.2%) 🟢
./packages/react-native-web/dist/exports/AppRegistry/renderApplication.js 0.52 (1.05) +0.01 (+0.03) +1.2% (+3.3%)
./packages/react-native-web/dist/exports/Image/index.js 2.70 (6.54) -0.01 (-0.07) -0.6% (-1.1%) 🟢
./packages/react-native-web/dist/exports/ImageBackground/index.js 0.56 (1.04) -0.00 (0.00) -0.2% (0.0%)
./packages/react-native-web/dist/exports/ProgressBar/index.js 0.87 (1.69) +0.00 (+0.03) +0.2% (+2.0%)
./packages/react-native-web/dist/exports/StyleSheet/compile.js 0.00 (0.00) -1.62 (-4.41) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/constants.js 0.00 (0.00) -0.54 (-1.35) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/createCompileableStyle.js 0.00 (0.00) -0.54 (-1.29) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/createCSSStyleSheet.js 0.00 (0.00) -0.23 (-0.32) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/createOrderedCSSStyleSheet.js 0.00 (0.00) -0.69 (-1.40) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/createReactDOMStyle.js 0.00 (0.00) -0.90 (-1.96) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/createStyleResolver.js 0.00 (0.00) -1.33 (-3.33) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/css.js 0.00 (0.00) -0.12 (-0.13) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/flattenStyle.js 0.00 (0.00) -0.31 (-0.49) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/i18nStyle.js 0.00 (0.00) -0.84 (-2.62) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/index.js 1.28 (3.16) +1.10 (+2.92) +627.3% (+1215.8%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/initialRules.js 0.00 (0.00) -0.22 (-0.40) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/modality.js 0.00 (0.00) -0.85 (-2.52) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/normalizeValueWithProperty.js 0.00 (0.00) -0.27 (-0.49) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/ReactNativePropRegistry.js 0.00 (0.00) -0.31 (-0.50) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/resolveShadowValue.js 0.00 (0.00) -0.28 (-0.54) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/styleResolver.js 0.00 (0.00) -0.09 (-0.12) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/StyleSheet.js 0.00 (0.00) -0.47 (-0.91) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/exports/StyleSheet/validate.js 0.62 (1.21) +0.14 (+0.39) +30.1% (+48.0%) 🔴
./packages/react-native-web/dist/exports/Text/index.js 1.82 (5.17) +0.26 (+0.96) +16.6% (+22.9%) 🔴
./packages/react-native-web/dist/exports/TextInput/index.js 2.44 (6.66) +0.05 (+0.19) +2.2% (+2.9%) 🔴
./packages/react-native-web/dist/exports/View/index.js 1.63 (4.63) +0.23 (+0.80) +16.4% (+20.9%) 🔴
./packages/react-native-web/dist/modules/createDOMProps/index.js 1.92 (5.86) -0.35 (-0.99) -15.6% (-14.4%) 🟢
./packages/react-native-web/dist/modules/flattenArray/index.js 0.00 (0.00) -0.15 (-0.18) -100.0% (-100.0%) 🟢
./packages/react-native-web/dist/modules/forwardedProps/index.js 0.58 (1.88) -0.01 (-0.06) -1.4% (-3.0%) 🟢
./packages/react-native-web/dist/modules/pick/index.js 0.12 (0.11) -0.02 (-0.03) -11.7% (-19.0%) 🟢
./packages/react-native-web/dist/modules/prefixStyles/index.js 0.12 (0.17) -0.10 (-0.16) -44.2% (-48.8%) 🟢
./packages/react-native-web/dist/modules/prefixStyles/static.js 0.56 (1.64) -0.40 (-1.34) -41.4% (-45.0%) 🟢
./packages/react-native-web/dist/modules/usePlatformMethods/index.js 0.70 (1.75) -0.03 (-0.07) -4.2% (-3.9%) 🟢
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedStyle.js 0.96 (2.89) +0.01 (+0.02) +0.5% (+0.6%)
./packages/react-native-web/dist/exports/StyleSheet/compiler/createReactDOMStyle.js 1.23 (2.97) +1.23 (+2.97) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/compiler/hash.js 0.30 (0.71) +0.30 (+0.71) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/compiler/hyphenateStyleName.js 0.20 (0.29) +0.20 (+0.29) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/compiler/index.js 1.68 (4.42) +1.68 (+4.42) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/compiler/normalizeColor.js 0.24 (0.37) +0.24 (+0.37) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/compiler/normalizeValueWithProperty.js 0.26 (0.46) +0.26 (+0.46) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/compiler/preprocess.js 1.02 (3.42) +1.02 (+3.42) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/compiler/resolveShadowValue.js 0.27 (0.52) +0.27 (+0.52) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/compiler/unitlessNumbers.js 0.46 (0.95) +0.46 (+0.95) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/dom/createCSSStyleSheet.js 0.30 (0.43) +0.30 (+0.43) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js 0.72 (1.49) +0.72 (+1.49) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/exports/StyleSheet/dom/index.js 0.58 (1.43) +0.58 (+1.43) +100.0% (+100.0%) 🔴
./packages/react-native-web/dist/modules/RTLContext/index.js 0.08 (0.09) +0.08 (+0.09) +100.0% (+100.0%) 🔴
View unchanged
Filename: gzip (minify) kB size kB change % change
./packages/react-native-web/dist/exports/AccessibilityInfo/index.js 0.48 (1.49) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Alert/index.js 0.08 (0.09) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Animated/index.js 0.08 (0.09) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Appearance/index.js 0.33 (0.64) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/AppRegistry/AppContainer.js 0.29 (0.56) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/AppRegistry/index.js 1.04 (2.98) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/AppState/index.js 0.80 (1.79) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/BackHandler/index.js 0.13 (0.18) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Button/index.js 0.46 (0.86) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/CheckBox/index.js 1.80 (3.71) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Clipboard/index.js 0.40 (0.78) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/createElement/index.js 0.28 (0.46) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/DeviceEventEmitter/index.js 0.10 (0.14) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/DeviceInfo/index.js 0.32 (0.67) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Dimensions/index.js 0.55 (1.32) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/DrawerLayoutAndroid/index.js 0.08 (0.10) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Easing/index.js 0.09 (0.08) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/findNodeHandle/index.js 0.13 (0.14) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/FlatList/index.js 0.08 (0.08) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/I18nManager/index.js 0.34 (0.81) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Image/types.js 0.02 (0.00) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/InputAccessoryView/index.js 0.08 (0.10) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/InteractionManager/index.js 0.32 (0.64) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Keyboard/index.js 0.15 (0.25) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/KeyboardAvoidingView/index.js 0.71 (1.48) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/LayoutAnimation/index.js 0.09 (0.10) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Linking/index.js 0.60 (1.24) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/LogBox/index.js 0.09 (0.13) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Modal/index.js 0.62 (1.61) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Modal/ModalAnimation.js 0.73 (1.87) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Modal/ModalContent.js 0.53 (0.98) 0.00 (+0.01) 0.0% (+0.6%)
./packages/react-native-web/dist/exports/Modal/ModalFocusTrap.js 0.72 (1.96) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Modal/ModalPortal.js 0.29 (0.54) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/NativeEventEmitter/index.js 0.09 (0.11) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/NativeModules/index.js 0.09 (0.10) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/PanResponder/Alternative.js 0.94 (3.41) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/PanResponder/index.js 0.09 (0.09) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/PermissionsAndroid/index.js 0.15 (0.22) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Picker/index.js 0.85 (1.90) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Picker/PickerItem.js 0.16 (0.20) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/PixelRatio/index.js 0.21 (0.40) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Platform/index.js 0.14 (0.15) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Pressable/index.js 1.19 (2.71) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/processColor/index.js 0.15 (0.19) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/RefreshControl/index.js 0.35 (0.61) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/render/index.js 0.07 (0.08) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/SafeAreaView/index.js 0.59 (1.17) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/ScrollView/index.js 2.45 (7.20) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/ScrollView/ScrollViewBase.js 1.01 (2.32) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/SectionList/index.js 0.09 (0.09) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Settings/index.js 0.04 (0.02) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Share/index.js 0.55 (1.10) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/StatusBar/index.js 0.17 (0.30) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Switch/index.js 1.55 (3.73) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Systrace/index.js 0.04 (0.02) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Text/TextAncestorContext.js 0.09 (0.11) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Text/types.js 0.02 (0.00) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/TextInput/types.js 0.02 (0.00) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/ToastAndroid/index.js 0.08 (0.10) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Touchable/BoundingDimensions.js 0.25 (0.48) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Touchable/ensurePositiveDelayProps.js 0.18 (0.26) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Touchable/index.js 3.45 (14.00) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Touchable/Position.js 0.19 (0.31) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/TouchableHighlight/index.js 1.16 (2.59) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/TouchableNativeFeedback/index.js 0.08 (0.10) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/TouchableOpacity/index.js 1.04 (2.25) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/TouchableWithoutFeedback/index.js 0.62 (1.40) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/TVEventHandler/index.js 0.04 (0.02) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/UIManager/index.js 0.67 (1.40) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/unmountComponentAtNode/index.js 0.08 (0.08) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/useColorScheme/index.js 0.20 (0.34) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/useWindowDimensions/index.js 0.24 (0.42) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/Vibration/index.js 0.15 (0.20) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/View/types.js 0.02 (0.00) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/VirtualizedList/index.js 0.09 (0.10) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/exports/YellowBox/index.js 0.16 (0.22) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/index.js 0.82 (4.02) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/AccessibilityUtil/index.js 0.14 (0.33) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/AccessibilityUtil/isDisabled.js 0.13 (0.16) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/AccessibilityUtil/propsToAccessibilityComponent.js 0.38 (0.66) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/AccessibilityUtil/propsToAriaRole.js 0.24 (0.37) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/AssetRegistry/index.js 0.10 (0.12) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/createEventHandle/index.js 0.52 (1.12) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/dismissKeyboard/index.js 0.14 (0.18) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/getBoundingClientRect/index.js 0.13 (0.18) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/ImageLoader/index.js 0.76 (1.69) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/isSelectionValid/index.js 0.17 (0.23) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/isWebColor/index.js 0.12 (0.14) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/mergeRefs/index.js 0.26 (0.35) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/modality/index.js 1.21 (4.40) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/multiplyStyleLengthValue/index.js 0.24 (0.34) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/normalizeColor/index.js 0.23 (0.36) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/requestIdleCallback/index.js 0.28 (0.55) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/ScrollResponder/index.js 1.48 (5.23) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/setValueForStyles/dangerousStyleValue.js 0.19 (0.27) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/setValueForStyles/index.js 0.20 (0.29) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/TextInputState/index.js 0.22 (0.51) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/UnimplementedView/index.js 0.40 (0.75) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/unitlessNumbers/index.js 0.46 (0.95) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useElementLayout/index.js 0.68 (1.37) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useEvent/index.js 0.25 (0.48) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useHover/index.js 0.71 (1.67) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useLayoutEffect/index.js 0.14 (0.19) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useMergeRefs/index.js 0.19 (0.26) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/usePressEvents/index.js 0.24 (0.39) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/usePressEvents/PressResponder.js 2.01 (7.44) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useResponderEvents/createResponderEvent.js 0.77 (1.92) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useResponderEvents/index.js 0.44 (1.10) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useResponderEvents/ResponderEventTypes.js 0.34 (0.88) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useResponderEvents/ResponderSystem.js 1.89 (6.04) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useResponderEvents/ResponderTouchHistoryStore.js 1.06 (3.46) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useResponderEvents/utils.js 0.68 (1.43) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/modules/useStable/index.js 0.19 (0.26) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/types/index.js 0.02 (0.00) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/types/styles.js 0.02 (0.00) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/hash/index.js 0.30 (0.71) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/Animated.js 0.53 (1.41) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/AnimatedEvent.js 1.15 (3.27) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/AnimatedImplementation.js 1.83 (6.67) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/AnimatedMock.js 0.85 (2.69) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/animations/Animation.js 0.41 (0.98) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/animations/DecayAnimation.js 0.67 (1.69) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/animations/SpringAnimation.js 1.66 (5.03) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/animations/TimingAnimation.js 0.93 (2.48) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/bezier.js 0.69 (1.43) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/components/AnimatedFlatList.js 0.33 (0.58) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/components/AnimatedImage.js 0.13 (0.20) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/components/AnimatedScrollView.js 0.34 (0.61) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/components/AnimatedSectionList.js 0.34 (0.59) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/components/AnimatedText.js 0.13 (0.20) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/components/AnimatedView.js 0.13 (0.20) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/createAnimatedComponent.js 2.12 (6.28) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/Easing.js 0.48 (1.20) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/NativeAnimatedHelper.js 1.70 (7.96) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/NativeAnimatedModule.js 0.10 (0.13) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/NativeAnimatedTurboModule.js 0.10 (0.14) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedAddition.js 0.47 (1.28) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedDiffClamp.js 0.50 (1.24) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedDivision.js 0.60 (1.62) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedInterpolation.js 1.89 (5.23) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedModulo.js 0.43 (1.10) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedMultiplication.js 0.48 (1.29) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedNode.js 0.87 (2.85) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedProps.js 1.10 (3.58) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedSubtraction.js 0.48 (1.29) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedTracking.js 0.86 (2.38) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedTransform.js 0.59 (1.81) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedValue.js 0.95 (3.05) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedValueXY.js 0.72 (2.02) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/nodes/AnimatedWithChildren.js 1.05 (2.62) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Animated/SpringConfig.js 0.41 (0.92) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Batchinator/index.js 0.32 (0.62) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/deepDiffer/index.js 0.28 (0.54) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/emitter/_EmitterSubscription.js 0.29 (0.58) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/emitter/_EventEmitter.js 0.60 (1.42) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/emitter/_EventSubscription.js 0.14 (0.20) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/emitter/_EventSubscriptionVendor.js 0.34 (0.80) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/emitter/EventEmitter.js 0.08 (0.08) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/emitter/EventSubscription.js 0.03 (0.01) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/FillRateHelper/index.js 1.44 (4.24) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/FlatList/index.js 2.15 (6.68) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/infoLog/index.js 0.11 (0.10) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/JSEventLoopWatchdog/index.js 0.49 (1.15) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/LayoutAnimation/index.js 0.53 (1.24) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/NativeEventEmitter/index.js 0.51 (1.27) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/NativeEventEmitter/RCTDeviceEventEmitter.js 0.07 (0.08) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/PanResponder/index.js 1.07 (4.20) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/PooledClass/index.js 0.32 (0.62) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/SectionList/index.js 0.97 (2.81) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/StaticContainer/index.js 0.32 (0.61) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/StaticRenderer/index.js 0.29 (0.56) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/TouchHistoryMath/index.js 0.39 (1.16) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/TurboModule/RCTExport.js 0.03 (0.01) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/TurboModule/TurboModuleRegistry.js 0.22 (0.30) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Types/CoreEventTypes.js 0.03 (0.01) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/Utilities/setAndForwardRef.js 0.17 (0.22) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/ViewabilityHelper/index.js 1.77 (4.21) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/VirtualizedList/index.js 8.50 (29.32) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/VirtualizedList/VirtualizedListContext.js 0.74 (2.18) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/VirtualizedSectionList/index.js 2.98 (9.37) 0.00 (0.00) 0.0% (0.0%)
./packages/react-native-web/dist/vendor/react-native/VirtualizeUtils/index.js 0.89 (1.72) 0.00 (0.00) 0.0% (0.0%)

compressed-size-action

@natew
Copy link
Contributor

natew commented Jan 31, 2022

Just a small piece of input (and not sure if it's already there) but having the object => stylesheet logic in a separate npm package would be nice to have, for tamagui at least.

Reading over it perhaps the entirety of StyleSheet would be the better boundary, not sure.

@necolas
Copy link
Owner Author

necolas commented Jan 31, 2022

having the object => stylesheet logic in a separate npm package would be nice to have

What's the "object => stylesheet logic"? And why would it be helpful in a separate package?

import { styleq } from 'styleq';

const Dot = ({ size, x, y, children, color }) => {
const [className, inlineStyle] = styleq([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically is the function that would be useful. Tamagui at build time would use this to pre-generate the style object or className, so would want access to it.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's on npm. But StyleSheet wraps this function, so you could call StyleSheet(styles) to get basically the same result plus logic for RTL polyfill. The output of the RNW compiler could be adjusted to match what a build-time compiler would be able to produce for RTL polyfilling, but I don't know if you're supporting that.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RN API is not great for extensions, but it could be useful to have something like StyleSheet/runtime that only exports the code needed to merge the "css" objects (assuming a compiler doesn't leave StyleSheet.flatten() calls in the bundle)

@paularmstrong
Copy link
Contributor

Supports React 18 by inserting styles on eval, not render.

Is this going to be a requirement with React 18?

@necolas
Copy link
Owner Author

necolas commented Feb 1, 2022

Is this going to be a requirement with React 18?

Inserting during render can be problematic for initial renders because React 18 will yield back to the browser many times before updating the DOM. If styles are inserted during a render call, the browser might be forced to update layout during the pause. The useInsertionEffect hook is meant to mitigate this, but it's only available in React 18 and complicates the styling API significantly – essentially, the styling API either needs to be turned into a hook or needs to return a function to be called by the insertion hook. Instead, I'm hoping we can just insert everything during eval to avoid the render perf issue caused by React 18. Eval insertions are basically batched and lazy-loaded evals shouldn't be taking place during perf-sensitive user actions either. Ultimately, the "insert on create" approach plays better with build-time extraction strategies too, which is what React 18 wants. The React Native API design makes it very difficult to extract all styles, due to the existence of StyleSheet.flatten() and its use in Animated. But a web-first app could ban these APIs, allowing all styles to be extracted to a stylesheet

@paularmstrong
Copy link
Contributor

At quick glance, this will fully break runtime theming like react-native-stylex and similar approaches (eg, Twitter), since the theme comes through React context and needs to be built at runtime.

Are you imagining that the only supported way to do theming will be to apply theme-based style values via the style attribute on View & Text?

@necolas
Copy link
Owner Author

necolas commented Feb 1, 2022

AFAIK, Twitter's runtime theming works like this to create new objects when the global theme changes. Each render the object getter returns the theme-specific style object. So that should still work fine for runtime, and isn't a regression in terms of ability to extract styles. But future approaches to theming would be better off relying on CSS variables for runtime value changes, rather than creating new style objects.

@paularmstrong
Copy link
Contributor

paularmstrong commented Feb 2, 2022

Mostly looking good, except SSR.

SSR must extract all styles from the app at build time (i.e., no streaming of styles). This can be done without a compiler by using StyleSheet.getSheet() after evaling all styled components.

Do you have an example of using StyleSheet.getSheet()? I've run it after eval but it seems to just return an empty content: { id: 'react-native-stylesheet', textContent: '' }

Alternatively, are you leaving it up to the community to figure out how to deal with this at build time?

Will this be deprecating (or removing?) getStyleElement() returned from AppRegistry.getApplication()?

@necolas
Copy link
Owner Author

necolas commented Feb 2, 2022

New build 0.0.0-88ea3411 should fix SSR. I've added dedicated node tests to more reliably test SRR features of StyleSheet and AppRegistry. LMK if still having problems.

Will this be deprecating (or removing?) getStyleElement() returned from AppRegistry.getApplication()?

I was thinking we'll keep AppRegistry.getApplication() as is to make upgrading easy. It just won't return the styles that are a function of rendering the App, instead it should return all the styles from eval-ed modules.

@paularmstrong
Copy link
Contributor

All appears to be working except for an issue with box-shadows:

It seems that possibly it's the shadowOffset and shadowOpacity are not being applied.

@necolas
Copy link
Owner Author

necolas commented Feb 2, 2022

All appears to be working except for an issue with box-shadows

Good spot. There's a bug producing a different box shadow for each of the RN properties and it isn't caught by the existing unit tests.

@necolas
Copy link
Owner Author

necolas commented Feb 3, 2022

@paularmstrong Should be fixed in 0.0.0-b096cd2d: https://codesandbox.io/s/epic-pascal-t86z3

@CooCooCaCha
Copy link

This is exciting! Does this styling system also work for react-native?

@gut4
Copy link

gut4 commented Feb 8, 2022

Is it possible to extract styles from StyleSheet into *.css file(s)?
It will be useful with REMIX: https://remix.run/docs/en/v1/guides/styling

@jgornick
Copy link

Supports 3rd party compilers and extraction to static CSS.

@necolas (or someone else), can you expand on this, specifically extraction to static CSS? What makes these changes easier to extract StyleSheet usage to CSS?

Thank you!

@necolas necolas added this to the 0.18: StyleSheet milestone Mar 1, 2022
necolas added a commit that referenced this pull request Mar 2, 2022
* Improves React Native compatibility by making StyleSheet.create the identify function.
* Improves React 18 support by inserting styles on eval.
* Supports use with multiple windows (i.e., iframes) and shadow roots.
* Supports nested LTR/RTL layouts.
* Supports 3rd party compilers and extraction to static CSS.
* Fixes static and dynamic short/longform deduplication.
* Reduces browser support: Safari 10.1+, Chromium Edge, no IE, no legacy Android browsers.
* Removes automatic vendor-prefixing of inline styles (for better perf).
* Removes focus-visible polyfill as modern browsers no longer show focus rings for mouse interactions.

Close #2208
Fix #2138
Fix #2196
Fix #2007
Fix #1517
@necolas
Copy link
Owner Author

necolas commented Mar 2, 2022

See #2248 for the 0.18 integration branch

@necolas necolas closed this Mar 2, 2022
necolas added a commit that referenced this pull request Mar 2, 2022
* Improves React Native compatibility by making StyleSheet.create the identify function.
* Improves React 18 support by inserting styles on eval.
* Supports use with multiple windows (i.e., iframes) and shadow roots.
* Supports nested LTR/RTL layouts.
* Supports 3rd party compilers and extraction to static CSS.
* Fixes static and dynamic short/longform deduplication.
* Reduces browser support: Safari 10.1+, Chromium Edge, no IE, no legacy Android browsers.
* Removes automatic vendor-prefixing of inline styles (for better perf).
* Removes focus-visible polyfill as modern browsers no longer show focus rings for mouse interactions.

Close #2208
Fix #2138
Fix #2196
Fix #2007
Fix #1517
@necolas necolas deleted the styleq-stylesheet branch March 23, 2022 21:13
rnike pushed a commit to VeryBuy/react-native-web that referenced this pull request Sep 13, 2022
* Improves React Native compatibility by making StyleSheet.create the identify function.
* Improves React 18 support by inserting styles on eval.
* Supports use with multiple windows (i.e., iframes) and shadow roots.
* Supports nested LTR/RTL layouts.
* Supports 3rd party compilers and extraction to static CSS.
* Fixes static and dynamic short/longform deduplication.
* Reduces browser support: Safari 10.1+, Chromium Edge, no IE, no legacy Android browsers.
* Removes automatic vendor-prefixing of inline styles (for better perf).
* Removes focus-visible polyfill as modern browsers no longer show focus rings for mouse interactions.

Close necolas#2208
Fix necolas#2138
Fix necolas#2196
Fix necolas#2007
Fix necolas#1517
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants