From 792de6f5ff643ec65604bdcb378fd26662b73db5 Mon Sep 17 00:00:00 2001 From: Miki Leib <38354019+M-i-k-e-l@users.noreply.github.com> Date: Tue, 31 Dec 2024 14:23:52 +0200 Subject: [PATCH] Separate uilib-native (#3395) * Separate uilib-native * Fixes --- android/app/build.gradle | 1 - .../main/java/com/rnuilib/MainApplication.kt | 2 +- android/settings.gradle | 5 ----- ios/Podfile | 2 -- ios/rnuilib.xcodeproj/project.pbxproj | 6 +++-- jestSetup/jest-setup.js | 2 +- lib/package.json | 4 ++-- lib/react-native.config.js | 22 +++++++++++++++++++ package.json | 3 ++- react-native.config.js | 2 +- .../buildPackages/buildCustomPackages.js | 2 +- src/components/featureHighlight/index.tsx | 3 +-- src/index.ts | 2 +- src/nativeComponents/index.js | 2 -- yarn.lock | 16 +++++++++++++- 15 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 lib/react-native.config.js delete mode 100644 src/nativeComponents/index.js diff --git a/android/app/build.gradle b/android/app/build.gradle index b02c3246c3..b16e3ae4c0 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -125,7 +125,6 @@ dependencies { implementation("com.facebook.react:flipper-integration:0.73.9") implementation project(':react-native-navigation') - implementation project(':react-native-ui-lib') implementation 'com.facebook.fresco:fresco:2.5.0' implementation 'com.facebook.fresco:animated-gif:2.5.0' diff --git a/android/app/src/main/java/com/rnuilib/MainApplication.kt b/android/app/src/main/java/com/rnuilib/MainApplication.kt index 5369dcbf91..0b70765855 100644 --- a/android/app/src/main/java/com/rnuilib/MainApplication.kt +++ b/android/app/src/main/java/com/rnuilib/MainApplication.kt @@ -22,7 +22,7 @@ class MainApplication : NavigationApplication() { PackageList(this).packages.apply { // Packages that cannot be autolinked yet can be added manually here, for example: // add(UiLibPackageList(MainApplication.this).getPackageList()) - addAll(UiLibPackageList(this@MainApplication).getPackageList()) +// addAll(UiLibPackageList(this@MainApplication).getPackageList()) // add(MyReactNativePackage()) } diff --git a/android/settings.gradle b/android/settings.gradle index cab4468485..b7ef19cd04 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,11 +1,6 @@ - pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") } plugins { id("com.facebook.react.settings") } extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() } rootProject.name = 'rnuilib' -// apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' includeBuild('../node_modules/@react-native/gradle-plugin') - -include ':react-native-ui-lib' -project(':react-native-ui-lib').projectDir = new File(rootProject.projectDir, '../lib/android') diff --git a/ios/Podfile b/ios/Podfile index d46e120329..62316a52eb 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -25,8 +25,6 @@ if linkage != nil end target 'rnuilib' do - pod 'ReactNativeUiLib', :path => "../lib/ReactNativeUiLib.podspec" - config = use_native_modules! use_react_native!( diff --git a/ios/rnuilib.xcodeproj/project.pbxproj b/ios/rnuilib.xcodeproj/project.pbxproj index e35560c401..3412ab5cf0 100644 --- a/ios/rnuilib.xcodeproj/project.pbxproj +++ b/ios/rnuilib.xcodeproj/project.pbxproj @@ -878,7 +878,8 @@ OTHER_CPLUSPLUSFLAGS = "$(inherited)"; OTHER_LDFLAGS = ( "$(inherited)", - " ", + "-Wl", + "-ld_classic", ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; @@ -939,7 +940,8 @@ OTHER_CPLUSPLUSFLAGS = "$(inherited)"; OTHER_LDFLAGS = ( "$(inherited)", - " ", + "-Wl", + "-ld_classic", ); REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; diff --git a/jestSetup/jest-setup.js b/jestSetup/jest-setup.js index 7643b6969b..177b6f4721 100644 --- a/jestSetup/jest-setup.js +++ b/jestSetup/jest-setup.js @@ -1,4 +1,4 @@ -import {NativeModules, AccessibilityInfo, Animated} from 'react-native'; +import {AccessibilityInfo, Animated} from 'react-native'; // ========= Mock Object.defineProperty to always allow overriding ========= const originalDefineProperty = Object.defineProperty; Object.defineProperty = (obj, prop, desc) => { diff --git a/lib/package.json b/lib/package.json index 8c72d23d3e..50f61e5fdb 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,9 +1,9 @@ { "name": "uilib-native", - "version": "4.3.2", + "version": "4.4.0", "homepage": "https://github.com/wix/react-native-ui-lib", "description": "uilib native components (separated from js components)", - "main": "components/index.js", + "main": "components/index", "scripts": { "releaseNative": "node ./scripts/releaseNative.js" }, diff --git a/lib/react-native.config.js b/lib/react-native.config.js new file mode 100644 index 0000000000..d5fe52adda --- /dev/null +++ b/lib/react-native.config.js @@ -0,0 +1,22 @@ +module.exports = { + dependency: { + platforms: { + /* TODO: Once we upgrade to RN69 we should try using podspecPath again, for now I copied ReactNativeUiLib.podspec file to the root - it seems to work + I copied it, because we need it for both the main uilib and the uilib-native package */ + // ios: { + // podspecPath: './lib/ReactNativeUiLib.podspec' + // }, + android: { + sourceDir: './android/', + packageImportPath: `import com.wix.reactnativeuilib.dynamicfont.DynamicFontPackage; +import com.wix.reactnativeuilib.highlighterview.HighlighterViewPackage; +import com.wix.reactnativeuilib.keyboardinput.KeyboardInputPackage; +import com.wix.reactnativeuilib.textinput.TextInputDelKeyHandlerPackage;`, + packageInstance: `new DynamicFontPackage(), + new HighlighterViewPackage(), + new TextInputDelKeyHandlerPackage(), + new KeyboardInputPackage(getApplication())` + } + } + } +}; diff --git a/package.json b/package.json index f1d335291a..3c3c4a553a 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "react-native-redash": "^12.0.3", "semver": "^5.5.0", "tinycolor2": "^1.4.2", + "uilib-native": "^4.3.2", "url-parse": "^1.2.0", "wix-react-native-text-size": "1.0.9" }, @@ -137,7 +138,7 @@ "jest": { "preset": "react-native", "transformIgnorePatterns": [ - "node_modules/(?!(@react-native|react-native|react-native-reanimated|react-native-redash)/)" + "node_modules/(?!(@react-native|react-native|react-native-reanimated|react-native-redash|uilib-native)/)" ], "testPathIgnorePatterns": [ "/e2e/", diff --git a/react-native.config.js b/react-native.config.js index 819a3a376e..ef376f5f64 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -7,7 +7,7 @@ module.exports = { // podspecPath: './lib/ReactNativeUiLib.podspec' // }, android: { - sourceDir: './lib/android/', + sourceDir: '../uilib-native/android/', packageImportPath: `import com.wix.reactnativeuilib.dynamicfont.DynamicFontPackage; import com.wix.reactnativeuilib.highlighterview.HighlighterViewPackage; import com.wix.reactnativeuilib.keyboardinput.KeyboardInputPackage; diff --git a/scripts/build/buildPackages/buildCustomPackages.js b/scripts/build/buildPackages/buildCustomPackages.js index b14e2fc17f..f0f3c71bb6 100644 --- a/scripts/build/buildPackages/buildCustomPackages.js +++ b/scripts/build/buildPackages/buildCustomPackages.js @@ -4,7 +4,7 @@ const _ = require('lodash'); const packages = [ { filename: 'keyboard.js', - content: `module.exports = require('./lib/components/Keyboard').default;\n` + content: `module.exports = require('uilib-native').Keyboard;\n` }, { filename: 'assets.js', diff --git a/src/components/featureHighlight/index.tsx b/src/components/featureHighlight/index.tsx index 4f74accb84..cdb38afe25 100644 --- a/src/components/featureHighlight/index.tsx +++ b/src/components/featureHighlight/index.tsx @@ -10,14 +10,13 @@ import { TouchableWithoutFeedbackProps, LayoutChangeEvent } from 'react-native'; +import {HighlighterOverlayView} from 'uilib-native'; import {Colors, Typography} from '../../style'; import {Constants, asBaseComponent} from '../../commons/new'; import View from '../view'; import Text from '../text'; import Button, {ButtonProps, ButtonSize} from '../button'; import PageControl, {PageControlProps} from '../pageControl'; -//@ts-expect-error -import {HighlighterOverlayView} from '../../nativeComponents'; const defaultOverlayColor = Colors.rgba(Colors.black, 0.82); const defaultTextColor = Colors.white; diff --git a/src/index.ts b/src/index.ts index 92c27a0ac7..db833aea08 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ export {default as Assets} from './assets'; export type {emojis as EmojisAssetsType} from './assets/emojis'; export * from './style'; export * from './services'; -export * from '../lib/components'; +export * from 'uilib-native'; export { asBaseComponent, Config, diff --git a/src/nativeComponents/index.js b/src/nativeComponents/index.js deleted file mode 100644 index 648de9b04b..0000000000 --- a/src/nativeComponents/index.js +++ /dev/null @@ -1,2 +0,0 @@ -// TODO: remove this and use directly from ../../lib/components -module.exports = require('../../lib/components/index'); diff --git a/yarn.lock b/yarn.lock index ec92e9358e..3e37a8820e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8412,7 +8412,7 @@ __metadata: languageName: node linkType: hard -"lodash@npm:4.17.x, lodash@npm:4.x.x, lodash@npm:^4, lodash@npm:^4.17.10, lodash@npm:^4.17.21": +"lodash@npm:4.17.x, lodash@npm:4.x.x, lodash@npm:^4, lodash@npm:^4.0.0, lodash@npm:^4.17.10, lodash@npm:^4.17.21": version: 4.17.21 resolution: "lodash@npm:4.17.21" checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7 @@ -10367,6 +10367,7 @@ __metadata: shell-utils: ^1.0.10 tinycolor2: ^1.4.2 typescript: 5.0.4 + uilib-native: ^4.3.2 url-parse: ^1.2.0 wix-react-native-text-size: 1.0.9 peerDependencies: @@ -12037,6 +12038,19 @@ __metadata: languageName: node linkType: hard +"uilib-native@npm:^4.3.2": + version: 4.3.2 + resolution: "uilib-native@npm:4.3.2" + dependencies: + lodash: ^4.0.0 + prop-types: ^15.5.10 + peerDependencies: + react: ^16.0.0 + react-native: ^0.51.0 + checksum: 051fbba7a351f5ab098c8471a8b35f05c1b61df55b94b0fbb56d594e2fb856bc4ed1bc0575aedaa0659da5f14c4a0d2b4e6b4d48e5bce6eefab0067b5352b95f + languageName: node + linkType: hard + "unbox-primitive@npm:^1.0.2": version: 1.0.2 resolution: "unbox-primitive@npm:1.0.2"