react-native-pdf-jsi 4.2.2 → 4.3.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/README.md +69 -0
- package/android/src/main/java/org/wonday/pdf/PdfManager.java +2 -1
- package/android/src/main/java/org/wonday/pdf/PdfView.java +12 -0
- package/app.plugin.js +2 -0
- package/package.json +16 -3
- package/plugin/build/index.d.ts +3 -0
- package/plugin/build/index.js +26 -0
- package/plugin/build/withPdfJsiAndroid.d.ts +8 -0
- package/plugin/build/withPdfJsiAndroid.js +55 -0
- package/plugin/build/withPdfJsiIos.d.ts +11 -0
- package/plugin/build/withPdfJsiIos.js +34 -0
- package/plugin/src/index.ts +31 -0
- package/plugin/src/withPdfJsiAndroid.ts +67 -0
- package/plugin/src/withPdfJsiIos.ts +40 -0
- package/plugin/tsconfig.json +14 -0
package/README.md
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
[](https://www.npmjs.com/package/react-native-pdf-jsi)
|
|
12
|
+
[](https://expo.dev)
|
|
12
13
|
[](https://www.npmjs.com/package/react-native-pdf-jsi)
|
|
13
14
|
[](https://www.npmjs.com/package/react-native-pdf-jsi)
|
|
15
|
+
[](https://www.npmjs.com/package/react-native-pdf-jsi)
|
|
14
16
|
[](https://github.com/126punith/react-native-pdf-jsi)
|
|
15
17
|
[](https://github.com/126punith/react-native-pdf-jsi/blob/main/LICENSE)
|
|
16
18
|
|
|
@@ -111,6 +113,51 @@ react-native link react-native-blob-util
|
|
|
111
113
|
react-native link react-native-pdf-jsi
|
|
112
114
|
```
|
|
113
115
|
|
|
116
|
+
### Expo Installation
|
|
117
|
+
|
|
118
|
+
This package works with **Expo development builds** (not Expo Go, as it requires native code).
|
|
119
|
+
|
|
120
|
+
**1. Install the package and peer dependencies:**
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npx expo install react-native-pdf-jsi react-native-blob-util @react-native-async-storage/async-storage
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**2. Add the config plugin to your `app.json` or `app.config.js`:**
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"expo": {
|
|
131
|
+
"plugins": ["react-native-pdf-jsi"]
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**3. Rebuild your development build:**
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Generate native projects
|
|
140
|
+
npx expo prebuild
|
|
141
|
+
|
|
142
|
+
# Run on iOS
|
|
143
|
+
npx expo run:ios
|
|
144
|
+
|
|
145
|
+
# Run on Android
|
|
146
|
+
npx expo run:android
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
> **Note:** The config plugin automatically configures:
|
|
150
|
+
> - Android: Adds Jitpack repository for PDF rendering dependencies
|
|
151
|
+
> - iOS: Ensures PDFKit framework is properly linked
|
|
152
|
+
|
|
153
|
+
**For EAS Build users:**
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Build development client
|
|
157
|
+
eas build --profile development --platform ios
|
|
158
|
+
eas build --profile development --platform android
|
|
159
|
+
```
|
|
160
|
+
|
|
114
161
|
### Windows Installation
|
|
115
162
|
|
|
116
163
|
1. Open your solution in Visual Studio 2019 (e.g., `windows\yourapp.sln`)
|
|
@@ -410,6 +457,28 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
410
457
|
|
|
411
458
|
## Recent Fixes
|
|
412
459
|
|
|
460
|
+
### Android PDF Preserved on Navigation (v4.3.1)
|
|
461
|
+
Fixed issue where the PDF instance was destroyed on Android when navigating away and returning to the screen ([#20](https://github.com/126punith/react-native-pdf-jsi/issues/20)). The PDF is now preserved in memory during navigation (matching iOS behavior) and only recycled when the component unmounts.
|
|
462
|
+
|
|
463
|
+
### Expo Support (v4.3.0)
|
|
464
|
+
Added Expo config plugin for seamless integration with Expo development builds. The package now works with `npx expo prebuild` and `npx expo run:ios/android`.
|
|
465
|
+
|
|
466
|
+
**Installation:**
|
|
467
|
+
```bash
|
|
468
|
+
npx expo install react-native-pdf-jsi react-native-blob-util @react-native-async-storage/async-storage
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
**Configuration (app.json):**
|
|
472
|
+
```json
|
|
473
|
+
{
|
|
474
|
+
"expo": {
|
|
475
|
+
"plugins": ["react-native-pdf-jsi"]
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
**Note:** Expo Go is NOT supported (requires native code). Use Expo development builds.
|
|
481
|
+
|
|
413
482
|
### PDFCompressor Module Fix (v4.2.2)
|
|
414
483
|
Fixed "Unable to resolve module react-native-pdf-jsi/src/PDFCompressor" error ([#17](https://github.com/126punith/react-native-pdf-jsi/issues/17)). The PDFCompressor module is now properly exported and accessible. Also fixed iOS compilation error for missing `RCTLogInfo` import. The compression feature now works correctly with accurate size estimates (~15-18% compression using native zlib deflate).
|
|
415
484
|
|
|
@@ -349,6 +349,18 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
|
|
|
349
349
|
this.drawPdf();
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
+
/**
|
|
353
|
+
* Override to prevent barteksc PDFView's recycle() on navigation.
|
|
354
|
+
* The parent class calls recycle() in onDetachedFromWindow, which destroys the PDF
|
|
355
|
+
* when the view is temporarily detached (e.g., navigating to another screen).
|
|
356
|
+
* We only recycle when PdfManager.onDropViewInstance is called (component unmount).
|
|
357
|
+
*/
|
|
358
|
+
@Override
|
|
359
|
+
protected void onDetachedFromWindow() {
|
|
360
|
+
// Intentionally skip super to prevent barteksc PDFView's recycle() which destroys
|
|
361
|
+
// the PDF on navigation. We only recycle when PdfManager.onDropViewInstance is called.
|
|
362
|
+
}
|
|
363
|
+
|
|
352
364
|
public void drawPdf() {
|
|
353
365
|
|
|
354
366
|
// FIX: Check if we actually need to reload the document
|
package/app.plugin.js
ADDED
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-pdf-jsi",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"summary": "High-performance React Native PDF viewer with JSI acceleration - up to 80x faster than traditional bridge",
|
|
5
5
|
"description": "🚀 Ultra-fast React Native PDF viewer with JSI (JavaScript Interface) integration for maximum performance. Features lazy loading, smart caching, progressive loading, and zero-bridge overhead operations. Perfect for large PDF files with 30-day persistent cache and advanced memory optimization. Google Play 16KB page size compliant for Android 15+. Supports iOS, Android, and Windows platforms.",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"typings": "./index.d.ts",
|
|
8
|
+
"app": {
|
|
9
|
+
"plugin": "./plugin/build"
|
|
10
|
+
},
|
|
8
11
|
"repository": {
|
|
9
12
|
"type": "git",
|
|
10
13
|
"url": "git+https://github.com/126punith/react-native-pdf-jsi.git"
|
|
@@ -50,7 +53,9 @@
|
|
|
50
53
|
"optimization",
|
|
51
54
|
"caching",
|
|
52
55
|
"persistent-cache",
|
|
53
|
-
"react-native-pdf-jsi-enhanced"
|
|
56
|
+
"react-native-pdf-jsi-enhanced",
|
|
57
|
+
"expo",
|
|
58
|
+
"expo-plugin"
|
|
54
59
|
],
|
|
55
60
|
"author": {
|
|
56
61
|
"name": "Punith M",
|
|
@@ -69,7 +74,13 @@
|
|
|
69
74
|
"devDependencies": {
|
|
70
75
|
"@babel/core": "^7.20.2",
|
|
71
76
|
"@babel/runtime": "^7.20.1",
|
|
72
|
-
"
|
|
77
|
+
"@expo/config-plugins": "^9.0.0",
|
|
78
|
+
"prop-types": "^15.7.2",
|
|
79
|
+
"typescript": "^5.0.0"
|
|
80
|
+
},
|
|
81
|
+
"scripts": {
|
|
82
|
+
"build:plugin": "tsc -p plugin/tsconfig.json",
|
|
83
|
+
"prepublishOnly": "npm run build:plugin"
|
|
73
84
|
},
|
|
74
85
|
"peerDependencies": {
|
|
75
86
|
"@react-native-async-storage/async-storage": ">=1.17.0",
|
|
@@ -82,6 +93,8 @@
|
|
|
82
93
|
"ios/",
|
|
83
94
|
"windows/",
|
|
84
95
|
"src/",
|
|
96
|
+
"plugin/",
|
|
97
|
+
"app.plugin.js",
|
|
85
98
|
"DoubleTapView.js",
|
|
86
99
|
"index.d.ts",
|
|
87
100
|
"index.js",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
4
|
+
const withPdfJsiAndroid_1 = require("./withPdfJsiAndroid");
|
|
5
|
+
const withPdfJsiIos_1 = require("./withPdfJsiIos");
|
|
6
|
+
const pkg = require('../../package.json');
|
|
7
|
+
/**
|
|
8
|
+
* Expo config plugin for react-native-pdf-jsi
|
|
9
|
+
*
|
|
10
|
+
* This plugin configures the native projects for Expo development builds.
|
|
11
|
+
* It handles:
|
|
12
|
+
* - Android: Jitpack repository for AndroidPdfViewer, NDK configuration
|
|
13
|
+
* - iOS: PDFKit framework linking
|
|
14
|
+
*
|
|
15
|
+
* Note: This package requires development builds and won't work with Expo Go.
|
|
16
|
+
*/
|
|
17
|
+
const withPdfJsi = (config) => {
|
|
18
|
+
// Warn about peer dependencies
|
|
19
|
+
console.log('[react-native-pdf-jsi] Remember to install peer dependencies:\n' +
|
|
20
|
+
' - react-native-blob-util\n' +
|
|
21
|
+
' - @react-native-async-storage/async-storage');
|
|
22
|
+
config = (0, withPdfJsiAndroid_1.withPdfJsiAndroid)(config);
|
|
23
|
+
config = (0, withPdfJsiIos_1.withPdfJsiIos)(config);
|
|
24
|
+
return config;
|
|
25
|
+
};
|
|
26
|
+
exports.default = (0, config_plugins_1.createRunOncePlugin)(withPdfJsi, pkg.name, pkg.version);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
/**
|
|
3
|
+
* Android config plugin for react-native-pdf-jsi
|
|
4
|
+
*
|
|
5
|
+
* Configures the Android project to support the PDF library:
|
|
6
|
+
* - Adds Jitpack repository for AndroidPdfViewer dependency
|
|
7
|
+
*/
|
|
8
|
+
export declare const withPdfJsiAndroid: ConfigPlugin;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withPdfJsiAndroid = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
/**
|
|
6
|
+
* Android config plugin for react-native-pdf-jsi
|
|
7
|
+
*
|
|
8
|
+
* Configures the Android project to support the PDF library:
|
|
9
|
+
* - Adds Jitpack repository for AndroidPdfViewer dependency
|
|
10
|
+
*/
|
|
11
|
+
const withPdfJsiAndroid = (config) => {
|
|
12
|
+
return (0, config_plugins_1.withProjectBuildGradle)(config, (config) => {
|
|
13
|
+
if (config.modResults.language === 'groovy') {
|
|
14
|
+
config.modResults.contents = addJitpackRepository(config.modResults.contents);
|
|
15
|
+
}
|
|
16
|
+
return config;
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
exports.withPdfJsiAndroid = withPdfJsiAndroid;
|
|
20
|
+
/**
|
|
21
|
+
* Add Jitpack repository to the project's build.gradle if not already present.
|
|
22
|
+
* This is required for the AndroidPdfViewer dependency.
|
|
23
|
+
*/
|
|
24
|
+
function addJitpackRepository(buildGradle) {
|
|
25
|
+
const jitpackUrl = "maven { url 'https://jitpack.io' }";
|
|
26
|
+
// Check if Jitpack is already added
|
|
27
|
+
if (buildGradle.includes('jitpack.io')) {
|
|
28
|
+
return buildGradle;
|
|
29
|
+
}
|
|
30
|
+
// Find the allprojects { repositories { ... } } block and add Jitpack
|
|
31
|
+
const allProjectsPattern = /allprojects\s*\{[\s\S]*?repositories\s*\{/;
|
|
32
|
+
const match = buildGradle.match(allProjectsPattern);
|
|
33
|
+
if (match) {
|
|
34
|
+
// Add Jitpack after the opening of repositories block
|
|
35
|
+
const insertPosition = match.index + match[0].length;
|
|
36
|
+
return (buildGradle.slice(0, insertPosition) +
|
|
37
|
+
`\n ${jitpackUrl}` +
|
|
38
|
+
buildGradle.slice(insertPosition));
|
|
39
|
+
}
|
|
40
|
+
// If allprojects block exists but repositories block doesn't have the expected format,
|
|
41
|
+
// try to add it in a different way
|
|
42
|
+
if (buildGradle.includes('allprojects')) {
|
|
43
|
+
// Look for maven { url pattern in allprojects section
|
|
44
|
+
const mavenCentralPattern = /(allprojects\s*\{[\s\S]*?repositories\s*\{[\s\S]*?)(mavenCentral\(\)|google\(\))/;
|
|
45
|
+
const mavenMatch = buildGradle.match(mavenCentralPattern);
|
|
46
|
+
if (mavenMatch) {
|
|
47
|
+
return buildGradle.replace(mavenCentralPattern, `$1$2\n ${jitpackUrl}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// If we couldn't find a good place, add a comment for manual addition
|
|
51
|
+
console.warn('[react-native-pdf-jsi] Could not automatically add Jitpack repository.\n' +
|
|
52
|
+
'Please manually add the following to your android/build.gradle:\n' +
|
|
53
|
+
"maven { url 'https://jitpack.io' }");
|
|
54
|
+
return buildGradle;
|
|
55
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
/**
|
|
3
|
+
* iOS config plugin for react-native-pdf-jsi
|
|
4
|
+
*
|
|
5
|
+
* Configures the iOS project to support the PDF library:
|
|
6
|
+
* - Ensures PDFKit framework is properly linked (handled automatically by CocoaPods)
|
|
7
|
+
*
|
|
8
|
+
* Note: Most iOS configuration is handled by the podspec file.
|
|
9
|
+
* This plugin exists for any additional Xcode project modifications if needed.
|
|
10
|
+
*/
|
|
11
|
+
export declare const withPdfJsiIos: ConfigPlugin;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withPdfJsiIos = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
/**
|
|
6
|
+
* iOS config plugin for react-native-pdf-jsi
|
|
7
|
+
*
|
|
8
|
+
* Configures the iOS project to support the PDF library:
|
|
9
|
+
* - Ensures PDFKit framework is properly linked (handled automatically by CocoaPods)
|
|
10
|
+
*
|
|
11
|
+
* Note: Most iOS configuration is handled by the podspec file.
|
|
12
|
+
* This plugin exists for any additional Xcode project modifications if needed.
|
|
13
|
+
*/
|
|
14
|
+
const withPdfJsiIos = (config) => {
|
|
15
|
+
return (0, config_plugins_1.withXcodeProject)(config, async (config) => {
|
|
16
|
+
const xcodeProject = config.modResults;
|
|
17
|
+
// PDFKit framework is automatically linked through the podspec's s.framework = "PDFKit"
|
|
18
|
+
// This plugin hook is here for any future iOS-specific configurations
|
|
19
|
+
// Ensure the project has the PDFKit framework if needed
|
|
20
|
+
// (This is typically handled by CocoaPods, but we can add it explicitly if necessary)
|
|
21
|
+
const frameworks = xcodeProject.pbxFrameworksBuildPhaseObj(xcodeProject.getFirstTarget().uuid);
|
|
22
|
+
if (frameworks) {
|
|
23
|
+
// Check if PDFKit is already linked
|
|
24
|
+
const pdfKitLinked = Object.values(frameworks.files || {}).some((file) => { var _a; return (_a = file === null || file === void 0 ? void 0 : file.comment) === null || _a === void 0 ? void 0 : _a.includes('PDFKit'); });
|
|
25
|
+
if (!pdfKitLinked) {
|
|
26
|
+
// PDFKit is a system framework, it will be linked via the podspec
|
|
27
|
+
// No manual linking required in most cases
|
|
28
|
+
console.log('[react-native-pdf-jsi] iOS: PDFKit will be linked via CocoaPods');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return config;
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
exports.withPdfJsiIos = withPdfJsiIos;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ConfigPlugin, createRunOncePlugin } from '@expo/config-plugins';
|
|
2
|
+
import { withPdfJsiAndroid } from './withPdfJsiAndroid';
|
|
3
|
+
import { withPdfJsiIos } from './withPdfJsiIos';
|
|
4
|
+
|
|
5
|
+
const pkg = require('../../package.json');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Expo config plugin for react-native-pdf-jsi
|
|
9
|
+
*
|
|
10
|
+
* This plugin configures the native projects for Expo development builds.
|
|
11
|
+
* It handles:
|
|
12
|
+
* - Android: Jitpack repository for AndroidPdfViewer, NDK configuration
|
|
13
|
+
* - iOS: PDFKit framework linking
|
|
14
|
+
*
|
|
15
|
+
* Note: This package requires development builds and won't work with Expo Go.
|
|
16
|
+
*/
|
|
17
|
+
const withPdfJsi: ConfigPlugin = (config) => {
|
|
18
|
+
// Warn about peer dependencies
|
|
19
|
+
console.log(
|
|
20
|
+
'[react-native-pdf-jsi] Remember to install peer dependencies:\n' +
|
|
21
|
+
' - react-native-blob-util\n' +
|
|
22
|
+
' - @react-native-async-storage/async-storage'
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
config = withPdfJsiAndroid(config);
|
|
26
|
+
config = withPdfJsiIos(config);
|
|
27
|
+
|
|
28
|
+
return config;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default createRunOncePlugin(withPdfJsi, pkg.name, pkg.version);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ConfigPlugin, withProjectBuildGradle } from '@expo/config-plugins';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Android config plugin for react-native-pdf-jsi
|
|
5
|
+
*
|
|
6
|
+
* Configures the Android project to support the PDF library:
|
|
7
|
+
* - Adds Jitpack repository for AndroidPdfViewer dependency
|
|
8
|
+
*/
|
|
9
|
+
export const withPdfJsiAndroid: ConfigPlugin = (config) => {
|
|
10
|
+
return withProjectBuildGradle(config, (config) => {
|
|
11
|
+
if (config.modResults.language === 'groovy') {
|
|
12
|
+
config.modResults.contents = addJitpackRepository(config.modResults.contents);
|
|
13
|
+
}
|
|
14
|
+
return config;
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Add Jitpack repository to the project's build.gradle if not already present.
|
|
20
|
+
* This is required for the AndroidPdfViewer dependency.
|
|
21
|
+
*/
|
|
22
|
+
function addJitpackRepository(buildGradle: string): string {
|
|
23
|
+
const jitpackUrl = "maven { url 'https://jitpack.io' }";
|
|
24
|
+
|
|
25
|
+
// Check if Jitpack is already added
|
|
26
|
+
if (buildGradle.includes('jitpack.io')) {
|
|
27
|
+
return buildGradle;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Find the allprojects { repositories { ... } } block and add Jitpack
|
|
31
|
+
const allProjectsPattern = /allprojects\s*\{[\s\S]*?repositories\s*\{/;
|
|
32
|
+
const match = buildGradle.match(allProjectsPattern);
|
|
33
|
+
|
|
34
|
+
if (match) {
|
|
35
|
+
// Add Jitpack after the opening of repositories block
|
|
36
|
+
const insertPosition = match.index! + match[0].length;
|
|
37
|
+
return (
|
|
38
|
+
buildGradle.slice(0, insertPosition) +
|
|
39
|
+
`\n ${jitpackUrl}` +
|
|
40
|
+
buildGradle.slice(insertPosition)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// If allprojects block exists but repositories block doesn't have the expected format,
|
|
45
|
+
// try to add it in a different way
|
|
46
|
+
if (buildGradle.includes('allprojects')) {
|
|
47
|
+
// Look for maven { url pattern in allprojects section
|
|
48
|
+
const mavenCentralPattern = /(allprojects\s*\{[\s\S]*?repositories\s*\{[\s\S]*?)(mavenCentral\(\)|google\(\))/;
|
|
49
|
+
const mavenMatch = buildGradle.match(mavenCentralPattern);
|
|
50
|
+
|
|
51
|
+
if (mavenMatch) {
|
|
52
|
+
return buildGradle.replace(
|
|
53
|
+
mavenCentralPattern,
|
|
54
|
+
`$1$2\n ${jitpackUrl}`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// If we couldn't find a good place, add a comment for manual addition
|
|
60
|
+
console.warn(
|
|
61
|
+
'[react-native-pdf-jsi] Could not automatically add Jitpack repository.\n' +
|
|
62
|
+
'Please manually add the following to your android/build.gradle:\n' +
|
|
63
|
+
"maven { url 'https://jitpack.io' }"
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return buildGradle;
|
|
67
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* iOS config plugin for react-native-pdf-jsi
|
|
5
|
+
*
|
|
6
|
+
* Configures the iOS project to support the PDF library:
|
|
7
|
+
* - Ensures PDFKit framework is properly linked (handled automatically by CocoaPods)
|
|
8
|
+
*
|
|
9
|
+
* Note: Most iOS configuration is handled by the podspec file.
|
|
10
|
+
* This plugin exists for any additional Xcode project modifications if needed.
|
|
11
|
+
*/
|
|
12
|
+
export const withPdfJsiIos: ConfigPlugin = (config) => {
|
|
13
|
+
return withXcodeProject(config, async (config) => {
|
|
14
|
+
const xcodeProject = config.modResults;
|
|
15
|
+
|
|
16
|
+
// PDFKit framework is automatically linked through the podspec's s.framework = "PDFKit"
|
|
17
|
+
// This plugin hook is here for any future iOS-specific configurations
|
|
18
|
+
|
|
19
|
+
// Ensure the project has the PDFKit framework if needed
|
|
20
|
+
// (This is typically handled by CocoaPods, but we can add it explicitly if necessary)
|
|
21
|
+
const frameworks = xcodeProject.pbxFrameworksBuildPhaseObj(
|
|
22
|
+
xcodeProject.getFirstTarget().uuid
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (frameworks) {
|
|
26
|
+
// Check if PDFKit is already linked
|
|
27
|
+
const pdfKitLinked = Object.values(frameworks.files || {}).some(
|
|
28
|
+
(file: any) => file?.comment?.includes('PDFKit')
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
if (!pdfKitLinked) {
|
|
32
|
+
// PDFKit is a system framework, it will be linked via the podspec
|
|
33
|
+
// No manual linking required in most cases
|
|
34
|
+
console.log('[react-native-pdf-jsi] iOS: PDFKit will be linked via CocoaPods');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return config;
|
|
39
|
+
});
|
|
40
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./build",
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"target": "ES2019",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"resolveJsonModule": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"]
|
|
14
|
+
}
|