Skip to content

Commit fe5dc66

Browse files
authored
Merge pull request #26 from alpha0010/new-arch
Support new architecture Note: shadow nodes fail for android on RN 0.83.1 react/react-native#55171
2 parents 4ab9640 + eae0ba3 commit fe5dc66

96 files changed

Lines changed: 7514 additions & 16404 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 0 additions & 98 deletions
This file was deleted.

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
*.pbxproj -text
22
# specific for windows script files
3-
*.bat text eol=crlf
3+
*.bat text eol=crlf

.github/workflows/node.js.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
- run: corepack enable
2424
- uses: actions/setup-node@v4
2525
with:
26-
node-version: 20
27-
- run: yarn && yarn example
26+
node-version: 24
27+
- run: yarn
2828
if: steps.cache-node.outputs.cache-hit != 'true'
2929
- run: yarn lint
30-
- run: yarn typescript
30+
- run: yarn typecheck
3131
- run: yarn test --coverage
3232
- run: yarn prepare

.gitignore

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,27 @@ DerivedData
2727
*.hmap
2828
*.ipa
2929
*.xcuserstate
30-
**/.xcode.env.local
3130
project.xcworkspace
31+
**/.xcode.env.local
3232

3333
# Android/IJ
3434
#
35-
.idea
35+
.classpath
36+
.cxx
3637
.gradle
38+
.idea
39+
.project
40+
.settings
3741
local.properties
3842
android.iml
3943

4044
# Cocoapods
4145
#
4246
example/ios/Pods
4347

48+
# Ruby
49+
example/vendor/
50+
4451
# node.js
4552
#
4653
node_modules/
@@ -54,8 +61,26 @@ buck-out/
5461
android/app/libs
5562
android/keystores/debug.keystore
5663

64+
# Yarn
65+
.yarn/*
66+
!.yarn/patches
67+
!.yarn/plugins
68+
!.yarn/releases
69+
!.yarn/sdks
70+
!.yarn/versions
71+
5772
# Expo
58-
.expo/*
73+
.expo/
74+
75+
# Turborepo
76+
.turbo/
5977

6078
# generated by bob
6179
lib/
80+
81+
# React Native Codegen
82+
ios/generated
83+
android/generated
84+
85+
# React Native Nitro Modules
86+
nitrogen/

.yarnrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
nmHoistingLimits: workspaces
12
nodeLinker: node-modules

CONTRIBUTING.md

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,30 @@ We want this community to be friendly and respectful to each other. Please follo
44

55
## Development workflow
66

7-
To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
7+
This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/features/workspaces). It contains the following packages:
8+
9+
- The library package in the root directory.
10+
- An example app in the `example/` directory.
11+
12+
To get started with the project, make sure you have the correct version of [Node.js](https://nodejs.org/) installed. See the [`.nvmrc`](./.nvmrc) file for the version used in this project.
13+
14+
Run `yarn` in the root directory to install the required dependencies for each package:
815

916
```sh
1017
yarn
1118
```
1219

13-
While developing, you can run the [example app](/example/) to test your changes.
20+
> Since the project relies on Yarn workspaces, you cannot use [`npm`](https://github.com/npm/cli) for development without manually migrating.
21+
22+
The [example app](/example/) demonstrates usage of the library. You need to run it to test any changes you make.
23+
24+
It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.
25+
26+
If you want to use Android Studio or Xcode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/PdfLightExample.xcworkspace` in Xcode and find the source files at `Pods > Development Pods > react-native-pdf-light`.
27+
28+
To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-pdf-light` under `Android`.
29+
30+
You can use various commands from the root directory to work with the project.
1431

1532
To start the packager:
1633

@@ -30,10 +47,23 @@ To run the example app on iOS:
3047
yarn example ios
3148
```
3249

33-
Make sure your code passes TypeScript and ESLint. Run the following to verify:
50+
To confirm that the app is running with the new architecture, you can check the Metro logs for a message like this:
51+
52+
```sh
53+
Running "PdfLightExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
54+
```
55+
56+
Note the `"fabric":true` and `"concurrentRoot":true` properties.
57+
58+
Make sure your code passes TypeScript:
59+
60+
```sh
61+
yarn typecheck
62+
```
63+
64+
To check for linting errors, run the following:
3465

3566
```sh
36-
yarn typescript
3767
yarn lint
3868
```
3969

@@ -49,9 +79,6 @@ Remember to add tests for your change if possible. Run the unit tests by:
4979
yarn test
5080
```
5181

52-
To edit the Objective-C files, open `example/ios/PdfViewerExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-pdf-viewer`.
53-
54-
To edit the Kotlin files, open `example/android` in Android studio and find the source files at `reactnativepdfviewer` under `Android`.
5582

5683
### Commit message convention
5784

@@ -66,29 +93,33 @@ We follow the [conventional commits specification](https://www.conventionalcommi
6693

6794
Our pre-commit hooks verify that your commit message matches this format when committing.
6895

69-
### Linting and tests
7096

71-
[ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
97+
### Publishing to npm
98+
99+
We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
100+
101+
To publish new versions, run the following:
72102

73-
We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
103+
```sh
104+
yarn release
105+
```
74106

75-
Our pre-commit hooks verify that the linter and tests pass when committing.
76107

77108
### Scripts
78109

79110
The `package.json` file contains various scripts for common tasks:
80111

81-
- `yarn bootstrap`: setup project by installing all dependencies and pods.
82-
- `yarn typescript`: type-check files with TypeScript.
83-
- `yarn lint`: lint files with ESLint.
84-
- `yarn test`: run unit tests with Jest.
112+
- `yarn`: setup project by installing dependencies.
113+
- `yarn typecheck`: type-check files with TypeScript.
114+
- `yarn lint`: lint files with [ESLint](https://eslint.org/).
115+
- `yarn test`: run unit tests with [Jest](https://jestjs.io/).
85116
- `yarn example start`: start the Metro server for the example app.
86117
- `yarn example android`: run the example app on Android.
87118
- `yarn example ios`: run the example app on iOS.
88119

89120
### Sending a pull request
90121

91-
> **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
122+
> **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).
92123
93124
When you're sending a pull request:
94125

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ npm install react-native-pdf-light
3131
If iOS build fails with `Undefined symbol: __swift_FORCE_LOAD_...`, add an
3232
empty `.swift` file to the xcode project.
3333

34+
### Compatibility
35+
36+
| React Native | react-native-pdf-light |
37+
| ------------ | ---------------------- |
38+
| old arch | 1.x.x, 2.x.x |
39+
| new arch | 3.x.x |
40+
3441
## Usage
3542

3643
```js

Zoom/package.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

android/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
set(CMAKE_VERBOSE_MAKEFILE on)
3+
4+
file(GLOB common_SRCS CONFIGURE_DEPENDS ../cpp/*.cpp)
5+
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS
6+
build/generated/source/codegen/jni/*.cpp
7+
build/generated/source/codegen/jni/react/renderer/components/PdfViewSpec/*.cpp
8+
)
9+
10+
add_library(
11+
react_codegen_PdfViewSpec
12+
OBJECT
13+
${common_SRCS}
14+
${react_codegen_SRCS}
15+
)
16+
17+
target_include_directories(react_codegen_PdfViewSpec PUBLIC ../cpp build/generated/source/codegen/jni)
18+
19+
target_link_libraries(
20+
react_codegen_PdfViewSpec
21+
fbjni
22+
jsi
23+
reactnative
24+
)
25+
26+
target_compile_reactnative_options(react_codegen_PdfViewSpec PRIVATE)

0 commit comments

Comments
 (0)