@papyrus-sdk/engine-native 0.1.1 → 0.1.2
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/LICENSE +21 -0
- package/android/build.gradle +40 -40
- package/android/src/main/AndroidManifest.xml +3 -3
- package/android/src/main/java/com/papyrus/engine/PapyrusEngineStore.java +71 -71
- package/android/src/main/java/com/papyrus/engine/PapyrusNativeEngineModule.java +529 -529
- package/android/src/main/java/com/papyrus/engine/PapyrusNativeEngineModule.kt +540 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusOutline.java +20 -20
- package/android/src/main/java/com/papyrus/engine/PapyrusOutlineItem.java +13 -13
- package/android/src/main/java/com/papyrus/engine/PapyrusPackage.java +24 -24
- package/android/src/main/java/com/papyrus/engine/PapyrusPageView.java +86 -86
- package/android/src/main/java/com/papyrus/engine/PapyrusPageViewManager.java +16 -16
- package/android/src/main/java/com/papyrus/engine/PapyrusPageViewModule.kt +12 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextHit.java +15 -15
- package/android/src/main/java/com/papyrus/engine/PapyrusTextSearch.java +20 -20
- package/android/src/main/java/com/papyrus/engine/PapyrusTextSelect.java +20 -20
- package/android/src/main/java/com/papyrus/engine/PapyrusTextSelection.java +11 -11
- package/dist/index.d.mts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +200 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +201 -9
- package/dist/index.mjs.map +1 -1
- package/ios/PapyrusNativeEngine.podspec +1 -1
- package/ios/PapyrusPageViewManager.m +19 -19
- package/package.json +30 -30
- package/react-native.config.js +10 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Papyrus Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/android/build.gradle
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
apply plugin: 'com.android.library'
|
|
2
|
-
|
|
3
|
-
def safeExtGet(prop, fallback) {
|
|
4
|
-
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
android {
|
|
8
|
-
compileSdkVersion safeExtGet('compileSdkVersion', 34)
|
|
9
|
-
namespace 'com.papyrus.engine'
|
|
10
|
-
|
|
11
|
-
defaultConfig {
|
|
12
|
-
minSdkVersion safeExtGet('minSdkVersion', 21)
|
|
13
|
-
targetSdkVersion safeExtGet('targetSdkVersion', 34)
|
|
14
|
-
consumerProguardFiles 'consumer-rules.pro'
|
|
15
|
-
externalNativeBuild {
|
|
16
|
-
cmake {
|
|
17
|
-
cppFlags "-std=c++17"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
sourceSets {
|
|
23
|
-
main {
|
|
24
|
-
java.srcDirs = ['src/main/java']
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
externalNativeBuild {
|
|
29
|
-
cmake {
|
|
30
|
-
path "src/main/cpp/CMakeLists.txt"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
dependencies {
|
|
36
|
-
implementation 'com.facebook.react:react-android'
|
|
37
|
-
implementation('com.github.barteksc:pdfium-android:1.9.0') {
|
|
38
|
-
exclude group: 'com.android.support'
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
def safeExtGet(prop, fallback) {
|
|
4
|
+
return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
android {
|
|
8
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 34)
|
|
9
|
+
namespace 'com.papyrus.engine'
|
|
10
|
+
|
|
11
|
+
defaultConfig {
|
|
12
|
+
minSdkVersion safeExtGet('minSdkVersion', 21)
|
|
13
|
+
targetSdkVersion safeExtGet('targetSdkVersion', 34)
|
|
14
|
+
consumerProguardFiles 'consumer-rules.pro'
|
|
15
|
+
externalNativeBuild {
|
|
16
|
+
cmake {
|
|
17
|
+
cppFlags "-std=c++17"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
sourceSets {
|
|
23
|
+
main {
|
|
24
|
+
java.srcDirs = ['src/main/java']
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
externalNativeBuild {
|
|
29
|
+
cmake {
|
|
30
|
+
path "src/main/cpp/CMakeLists.txt"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
dependencies {
|
|
36
|
+
implementation 'com.facebook.react:react-android'
|
|
37
|
+
implementation('com.github.barteksc:pdfium-android:1.9.0') {
|
|
38
|
+
exclude group: 'com.android.support'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
-
package="com.papyrus.engine">
|
|
3
|
-
</manifest>
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
package="com.papyrus.engine">
|
|
3
|
+
</manifest>
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
package com.papyrus.engine;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.os.ParcelFileDescriptor;
|
|
5
|
-
|
|
6
|
-
import com.shockwave.pdfium.PdfDocument;
|
|
7
|
-
import com.shockwave.pdfium.PdfiumCore;
|
|
8
|
-
|
|
9
|
-
import java.io.File;
|
|
10
|
-
import java.io.IOException;
|
|
11
|
-
import java.util.Map;
|
|
12
|
-
import java.util.UUID;
|
|
13
|
-
import java.util.concurrent.ConcurrentHashMap;
|
|
14
|
-
|
|
15
|
-
final class PapyrusEngineStore {
|
|
16
|
-
static final class EngineState {
|
|
17
|
-
final PdfiumCore pdfium;
|
|
18
|
-
final Object pdfiumLock = new Object();
|
|
19
|
-
volatile boolean isSearching = false;
|
|
20
|
-
PdfDocument document;
|
|
21
|
-
ParcelFileDescriptor fileDescriptor;
|
|
22
|
-
String sourcePath;
|
|
23
|
-
|
|
24
|
-
EngineState(PdfiumCore pdfium) {
|
|
25
|
-
this.pdfium = pdfium;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private static final Map<String, EngineState> ENGINES = new ConcurrentHashMap<>();
|
|
30
|
-
|
|
31
|
-
static String createEngine(Context context) {
|
|
32
|
-
String engineId = UUID.randomUUID().toString();
|
|
33
|
-
ENGINES.put(engineId, new EngineState(new PdfiumCore(context)));
|
|
34
|
-
return engineId;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static EngineState getEngine(String engineId) {
|
|
38
|
-
return ENGINES.get(engineId);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static void destroyEngine(String engineId) {
|
|
42
|
-
EngineState state = ENGINES.remove(engineId);
|
|
43
|
-
if (state == null) return;
|
|
44
|
-
if (state.document != null) {
|
|
45
|
-
state.pdfium.closeDocument(state.document);
|
|
46
|
-
state.document = null;
|
|
47
|
-
}
|
|
48
|
-
if (state.fileDescriptor != null) {
|
|
49
|
-
try {
|
|
50
|
-
state.fileDescriptor.close();
|
|
51
|
-
} catch (IOException ignored) {
|
|
52
|
-
}
|
|
53
|
-
state.fileDescriptor = null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static void setDocument(EngineState state, PdfDocument document, ParcelFileDescriptor fd, String sourcePath) {
|
|
58
|
-
if (state.document != null) {
|
|
59
|
-
state.pdfium.closeDocument(state.document);
|
|
60
|
-
}
|
|
61
|
-
if (state.fileDescriptor != null) {
|
|
62
|
-
try {
|
|
63
|
-
state.fileDescriptor.close();
|
|
64
|
-
} catch (IOException ignored) {
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
state.document = document;
|
|
68
|
-
state.fileDescriptor = fd;
|
|
69
|
-
state.sourcePath = sourcePath;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
1
|
+
package com.papyrus.engine;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.os.ParcelFileDescriptor;
|
|
5
|
+
|
|
6
|
+
import com.shockwave.pdfium.PdfDocument;
|
|
7
|
+
import com.shockwave.pdfium.PdfiumCore;
|
|
8
|
+
|
|
9
|
+
import java.io.File;
|
|
10
|
+
import java.io.IOException;
|
|
11
|
+
import java.util.Map;
|
|
12
|
+
import java.util.UUID;
|
|
13
|
+
import java.util.concurrent.ConcurrentHashMap;
|
|
14
|
+
|
|
15
|
+
final class PapyrusEngineStore {
|
|
16
|
+
static final class EngineState {
|
|
17
|
+
final PdfiumCore pdfium;
|
|
18
|
+
final Object pdfiumLock = new Object();
|
|
19
|
+
volatile boolean isSearching = false;
|
|
20
|
+
PdfDocument document;
|
|
21
|
+
ParcelFileDescriptor fileDescriptor;
|
|
22
|
+
String sourcePath;
|
|
23
|
+
|
|
24
|
+
EngineState(PdfiumCore pdfium) {
|
|
25
|
+
this.pdfium = pdfium;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private static final Map<String, EngineState> ENGINES = new ConcurrentHashMap<>();
|
|
30
|
+
|
|
31
|
+
static String createEngine(Context context) {
|
|
32
|
+
String engineId = UUID.randomUUID().toString();
|
|
33
|
+
ENGINES.put(engineId, new EngineState(new PdfiumCore(context)));
|
|
34
|
+
return engineId;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static EngineState getEngine(String engineId) {
|
|
38
|
+
return ENGINES.get(engineId);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static void destroyEngine(String engineId) {
|
|
42
|
+
EngineState state = ENGINES.remove(engineId);
|
|
43
|
+
if (state == null) return;
|
|
44
|
+
if (state.document != null) {
|
|
45
|
+
state.pdfium.closeDocument(state.document);
|
|
46
|
+
state.document = null;
|
|
47
|
+
}
|
|
48
|
+
if (state.fileDescriptor != null) {
|
|
49
|
+
try {
|
|
50
|
+
state.fileDescriptor.close();
|
|
51
|
+
} catch (IOException ignored) {
|
|
52
|
+
}
|
|
53
|
+
state.fileDescriptor = null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static void setDocument(EngineState state, PdfDocument document, ParcelFileDescriptor fd, String sourcePath) {
|
|
58
|
+
if (state.document != null) {
|
|
59
|
+
state.pdfium.closeDocument(state.document);
|
|
60
|
+
}
|
|
61
|
+
if (state.fileDescriptor != null) {
|
|
62
|
+
try {
|
|
63
|
+
state.fileDescriptor.close();
|
|
64
|
+
} catch (IOException ignored) {
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
state.document = document;
|
|
68
|
+
state.fileDescriptor = fd;
|
|
69
|
+
state.sourcePath = sourcePath;
|
|
70
|
+
}
|
|
71
|
+
}
|