@reekon-tools/react-native-pdf-canvas 0.1.0

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.
Files changed (161) hide show
  1. package/PdfCanvas.podspec +80 -0
  2. package/README.md +1391 -0
  3. package/android/build.gradle +175 -0
  4. package/android/consumer-rules.pro +3 -0
  5. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  6. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  7. package/android/gradle.properties +2 -0
  8. package/android/gradlew +248 -0
  9. package/android/gradlew.bat +98 -0
  10. package/android/settings.gradle +34 -0
  11. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasCancellationTest.java +226 -0
  12. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasConcurrencyTest.java +239 -0
  13. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasDeviceTimingTest.java +251 -0
  14. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasFailureTest.java +221 -0
  15. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasJsiTransportTest.java +783 -0
  16. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasPhaseTimingTest.java +1388 -0
  17. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasPoisonGuardTest.java +98 -0
  18. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasQuirksTest.java +324 -0
  19. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasRasterizerTest.java +775 -0
  20. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PoisonsTheProcess.java +20 -0
  21. package/android/src/androidTest/java/tools/reekon/pdfcanvas/TestPdfs.java +558 -0
  22. package/android/src/jsi/cpp/CMakeLists.txt +33 -0
  23. package/android/src/jsi/cpp/pdfcanvas-jsi.cpp +469 -0
  24. package/android/src/jsi/java/tools/reekon/pdfcanvas/jsi/PdfCanvasPixelBridge.java +140 -0
  25. package/android/src/main/AndroidManifest.xml +7 -0
  26. package/android/src/main/java/tools/reekon/pdfcanvas/PageGeometry.java +45 -0
  27. package/android/src/main/java/tools/reekon/pdfcanvas/PdfCanvasRasterizer.java +564 -0
  28. package/android/src/main/java/tools/reekon/pdfcanvas/PdfErrorCode.java +33 -0
  29. package/android/src/main/java/tools/reekon/pdfcanvas/PdfPlatformQuirks.java +277 -0
  30. package/android/src/main/java/tools/reekon/pdfcanvas/PdfPreflight.java +214 -0
  31. package/android/src/main/java/tools/reekon/pdfcanvas/PdfRasterException.java +30 -0
  32. package/android/src/main/java/tools/reekon/pdfcanvas/PdfRendererPool.java +234 -0
  33. package/android/src/main/java/tools/reekon/pdfcanvas/RasterCancellation.java +47 -0
  34. package/android/src/main/java/tools/reekon/pdfcanvas/RasterPixels.java +143 -0
  35. package/android/src/main/java/tools/reekon/pdfcanvas/RasterRequest.java +95 -0
  36. package/android/src/reactnative/java/tools/reekon/pdfcanvas/rn/PdfCanvasModule.java +626 -0
  37. package/android/src/reactnative/java/tools/reekon/pdfcanvas/rn/PdfCanvasPackage.java +33 -0
  38. package/android/tools/compile-gate.sh +289 -0
  39. package/dist/cache.d.ts +161 -0
  40. package/dist/cache.js +389 -0
  41. package/dist/clock.d.ts +21 -0
  42. package/dist/clock.js +31 -0
  43. package/dist/controller.d.ts +131 -0
  44. package/dist/controller.js +1002 -0
  45. package/dist/geometry.d.ts +96 -0
  46. package/dist/geometry.js +248 -0
  47. package/dist/index.d.ts +52 -0
  48. package/dist/index.js +50 -0
  49. package/dist/index.native.d.ts +21 -0
  50. package/dist/index.native.js +23 -0
  51. package/dist/index.web.d.ts +24 -0
  52. package/dist/index.web.js +26 -0
  53. package/dist/layout.d.ts +78 -0
  54. package/dist/layout.js +152 -0
  55. package/dist/peer-check.d.ts +83 -0
  56. package/dist/peer-check.js +183 -0
  57. package/dist/planner.d.ts +35 -0
  58. package/dist/planner.js +530 -0
  59. package/dist/policy.d.ts +14 -0
  60. package/dist/policy.js +168 -0
  61. package/dist/rasterizer/android.d.ts +121 -0
  62. package/dist/rasterizer/android.js +126 -0
  63. package/dist/rasterizer/buffer.d.ts +18 -0
  64. package/dist/rasterizer/buffer.js +18 -0
  65. package/dist/rasterizer/fake.d.ts +92 -0
  66. package/dist/rasterizer/fake.js +433 -0
  67. package/dist/rasterizer/index.d.ts +38 -0
  68. package/dist/rasterizer/index.js +69 -0
  69. package/dist/rasterizer/index.native.d.ts +19 -0
  70. package/dist/rasterizer/index.native.js +80 -0
  71. package/dist/rasterizer/index.web.d.ts +63 -0
  72. package/dist/rasterizer/index.web.js +75 -0
  73. package/dist/rasterizer/ingest.d.ts +180 -0
  74. package/dist/rasterizer/ingest.js +307 -0
  75. package/dist/rasterizer/ios.d.ts +84 -0
  76. package/dist/rasterizer/ios.js +155 -0
  77. package/dist/rasterizer/native-bridge.d.ts +261 -0
  78. package/dist/rasterizer/native-bridge.js +413 -0
  79. package/dist/rasterizer/web/client.d.ts +84 -0
  80. package/dist/rasterizer/web/client.js +359 -0
  81. package/dist/rasterizer/web/engine.d.ts +69 -0
  82. package/dist/rasterizer/web/engine.js +308 -0
  83. package/dist/rasterizer/web/index.d.ts +26 -0
  84. package/dist/rasterizer/web/index.js +21 -0
  85. package/dist/rasterizer/web/pdfium.d.ts +213 -0
  86. package/dist/rasterizer/web/pdfium.js +170 -0
  87. package/dist/rasterizer/web/protocol.d.ts +138 -0
  88. package/dist/rasterizer/web/protocol.js +37 -0
  89. package/dist/rasterizer/web/session.d.ts +106 -0
  90. package/dist/rasterizer/web/session.js +413 -0
  91. package/dist/rasterizer/web/worker.d.ts +44 -0
  92. package/dist/rasterizer/web/worker.js +76 -0
  93. package/dist/react/PdfContentView.d.ts +98 -0
  94. package/dist/react/PdfContentView.js +189 -0
  95. package/dist/react/index.d.ts +6 -0
  96. package/dist/react/index.js +3 -0
  97. package/dist/react/usePdfDocument.d.ts +134 -0
  98. package/dist/react/usePdfDocument.js +275 -0
  99. package/dist/react/usePdfLayer.d.ts +94 -0
  100. package/dist/react/usePdfLayer.js +388 -0
  101. package/dist/skia/index.d.ts +26 -0
  102. package/dist/skia/index.js +25 -0
  103. package/dist/skia/index.native.d.ts +14 -0
  104. package/dist/skia/index.native.js +16 -0
  105. package/dist/skia/index.web.d.ts +12 -0
  106. package/dist/skia/index.web.js +14 -0
  107. package/dist/skia/resolve.native.d.ts +18 -0
  108. package/dist/skia/resolve.native.js +22 -0
  109. package/dist/skia/resolve.web.d.ts +41 -0
  110. package/dist/skia/resolve.web.js +62 -0
  111. package/dist/skia/skia-api.d.ts +94 -0
  112. package/dist/skia/skia-api.js +113 -0
  113. package/dist/testing/index.d.ts +27 -0
  114. package/dist/testing/index.js +28 -0
  115. package/dist/testing/scenes.d.ts +100 -0
  116. package/dist/testing/scenes.js +267 -0
  117. package/dist/types.d.ts +611 -0
  118. package/dist/types.js +21 -0
  119. package/dist/web-init.d.ts +68 -0
  120. package/dist/web-init.js +64 -0
  121. package/ios/Package.swift +58 -0
  122. package/ios/Sources/PdfCanvasBridge/PdfCanvasModule.mm +743 -0
  123. package/ios/Sources/PdfCanvasBridge/include/PdfCanvasModule.h +36 -0
  124. package/ios/Sources/PdfCanvasCore/PdfCanvasCancellation.m +38 -0
  125. package/ios/Sources/PdfCanvasCore/PdfCanvasDocumentPool.m +389 -0
  126. package/ios/Sources/PdfCanvasCore/PdfCanvasErrorCode.m +57 -0
  127. package/ios/Sources/PdfCanvasCore/PdfCanvasPageGeometry.m +44 -0
  128. package/ios/Sources/PdfCanvasCore/PdfCanvasPageTransform.m +82 -0
  129. package/ios/Sources/PdfCanvasCore/PdfCanvasPixelSink.m +37 -0
  130. package/ios/Sources/PdfCanvasCore/PdfCanvasPreflight.m +158 -0
  131. package/ios/Sources/PdfCanvasCore/PdfCanvasRasterPixels.m +80 -0
  132. package/ios/Sources/PdfCanvasCore/PdfCanvasRasterRequest.m +65 -0
  133. package/ios/Sources/PdfCanvasCore/PdfCanvasRasterizer.m +548 -0
  134. package/ios/Sources/PdfCanvasCore/include/PdfCanvasCancellation.h +48 -0
  135. package/ios/Sources/PdfCanvasCore/include/PdfCanvasCore.h +26 -0
  136. package/ios/Sources/PdfCanvasCore/include/PdfCanvasDocumentPool.h +122 -0
  137. package/ios/Sources/PdfCanvasCore/include/PdfCanvasErrorCode.h +80 -0
  138. package/ios/Sources/PdfCanvasCore/include/PdfCanvasPageGeometry.h +79 -0
  139. package/ios/Sources/PdfCanvasCore/include/PdfCanvasPageTransform.h +129 -0
  140. package/ios/Sources/PdfCanvasCore/include/PdfCanvasPixelSink.h +100 -0
  141. package/ios/Sources/PdfCanvasCore/include/PdfCanvasPreflight.h +65 -0
  142. package/ios/Sources/PdfCanvasCore/include/PdfCanvasRasterPixels.h +111 -0
  143. package/ios/Sources/PdfCanvasCore/include/PdfCanvasRasterRequest.h +85 -0
  144. package/ios/Sources/PdfCanvasCore/include/PdfCanvasRasterizer.h +163 -0
  145. package/ios/Sources/PdfCanvasSlots/PdfCanvasSlots.mm +297 -0
  146. package/ios/Sources/PdfCanvasSlots/include/PdfCanvasSlots.h +140 -0
  147. package/ios/Tests/PdfCanvasCoreTests/ConcurrencyTests.swift +358 -0
  148. package/ios/Tests/PdfCanvasCoreTests/FailureTests.swift +262 -0
  149. package/ios/Tests/PdfCanvasCoreTests/GeometryTests.swift +173 -0
  150. package/ios/Tests/PdfCanvasCoreTests/PreviewTests.swift +114 -0
  151. package/ios/Tests/PdfCanvasCoreTests/RasterAssertions.swift +158 -0
  152. package/ios/Tests/PdfCanvasCoreTests/RasterizerTests.swift +544 -0
  153. package/ios/Tests/PdfCanvasCoreTests/SinkTests.swift +287 -0
  154. package/ios/Tests/PdfCanvasCoreTests/SlotsTests.swift +396 -0
  155. package/ios/Tests/PdfCanvasCoreTests/TestPdfs.swift +639 -0
  156. package/ios/Tests/PdfCanvasCoreTests/TimingTests.swift +179 -0
  157. package/ios/Tests/PdfCanvasCoreTests/TransformTests.swift +283 -0
  158. package/package.json +144 -0
  159. package/react-native.config.js +40 -0
  160. package/scripts/check-skia-peer.mjs +86 -0
  161. package/scripts/skia-peer-check.mjs +363 -0
@@ -0,0 +1,175 @@
1
+ /*
2
+ * The Android half of @reekon-tools/react-native-pdf-canvas.
3
+ *
4
+ * TWO BUILDS, ONE FILE.
5
+ *
6
+ * standalone — `cd android && ./gradlew connectedDebugAndroidTest`. Compiles
7
+ * `src/main` (the rasterizer core) and `src/androidTest`. There
8
+ * is no React Native on the classpath and nothing here asks for
9
+ * one. This is the build that PROVES the backend.
10
+ *
11
+ * autolinked — a React Native app pulls this directory in. `src/reactnative`
12
+ * joins the source set and the React dependency is added.
13
+ *
14
+ * The split is not cosmetic. `src/main` is the half that can be tested today on
15
+ * a bare emulator; the moment a React import lands in it, that stops being true
16
+ * and the only way to run the rasterizer is to build a whole app around it.
17
+ *
18
+ * `src/jsi` is a THIRD source set and it joins BOTH builds. It holds the raster
19
+ * transport — a JNI slot store whose contents become a JS ArrayBuffer with no
20
+ * base64 in between. It is React-free like `src/main`, but native, so it is
21
+ * compiled twice with different capabilities: the autolinked build passes
22
+ * `-DPDFCANVAS_WITH_JSI=ON` and links ReactAndroid's prefab `jsi` target, while
23
+ * the standalone build compiles the same file with the JSI half `#ifdef`'d out.
24
+ * That is deliberate rather than a convenience: it is what lets the instrumented
25
+ * suite prove ON DEVICE that the bytes entering the transport are byte-identical
26
+ * to the ones the base64 path produced, with no app anywhere in the picture.
27
+ */
28
+
29
+ buildscript {
30
+ repositories {
31
+ google()
32
+ mavenCentral()
33
+ }
34
+ dependencies {
35
+ // Only needed when this file is the build root. In an autolinked build the
36
+ // app's own buildscript has already put AGP on the classpath, and a second
37
+ // (possibly different) version here would conflict — hence the guard.
38
+ if (gradle.ext.has('pdfCanvasStandalone')) {
39
+ classpath 'com.android.tools.build:gradle:8.8.2'
40
+ }
41
+ }
42
+ }
43
+
44
+ apply plugin: 'com.android.library'
45
+
46
+ // See settings.gradle: this flag exists only on the standalone path, because a
47
+ // settings script is evaluated only for the build it is the root of.
48
+ def standalone = gradle.ext.has('pdfCanvasStandalone')
49
+
50
+ /**
51
+ * Which ABIs the transport's .so is built for.
52
+ *
53
+ * Autolinked: whatever the app asked for, so the library never ships an ABI the
54
+ * app does not — a missing .so is a silent fall back to base64 on that device,
55
+ * which is the one failure this list can cause.
56
+ *
57
+ * Standalone: the two the instrumented suite can actually run on. Building four
58
+ * to run one is a minute of NDK time per test cycle for nothing.
59
+ */
60
+ def transportAbis() {
61
+ if (!gradle.ext.has('pdfCanvasStandalone')) {
62
+ def requested = rootProject.properties.get('reactNativeArchitectures')
63
+ if (requested) {
64
+ return requested.split(',').collect { it.trim() }.findAll { it }
65
+ }
66
+ return ['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64']
67
+ }
68
+ return ['arm64-v8a', 'x86_64']
69
+ }
70
+
71
+ android {
72
+ namespace 'tools.reekon.pdfcanvas'
73
+ compileSdk 34
74
+
75
+ if (!standalone && rootProject.hasProperty('ndkVersion')) {
76
+ // Mirrors what every other autolinked native module does: take the app's
77
+ // pinned NDK when it has one, and let AGP pick its default when it does not.
78
+ // Pinning a version here that the machine has not installed is a build
79
+ // failure in somebody else's project.
80
+ ndkVersion rootProject.ext.ndkVersion
81
+ }
82
+
83
+ buildFeatures {
84
+ // Needed for `find_package(ReactAndroid CONFIG)` — the jsi headers and
85
+ // libjsi.so come out of the react-android AAR's prefab package. Off on the
86
+ // standalone path, where there is no AAR to read.
87
+ prefab !standalone
88
+ }
89
+
90
+ defaultConfig {
91
+ // 24 is the floor spike S1 measured against. PdfRenderer itself is API 21+,
92
+ // but 24 is the package's declared minimum and S1 confirmed the off-page
93
+ // -origin transform is honoured identically there.
94
+ minSdk 24
95
+ testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
96
+ // One test deliberately triggers the API 24 PDFium poisoning (see
97
+ // PdfCanvasPoisonGuardTest). Once it has, every test scheduled after it in
98
+ // the same process dies — so it is excluded here and run on its own. The
99
+ // exclusion is by annotation rather than by class name so that moving the
100
+ // test cannot silently re-admit it.
101
+ testInstrumentationRunnerArguments notAnnotation: 'tools.reekon.pdfcanvas.PoisonsTheProcess'
102
+ consumerProguardFiles 'consumer-rules.pro'
103
+
104
+ externalNativeBuild {
105
+ cmake {
106
+ // -frtti and -fexceptions are not optional: jsi.h uses both, and a
107
+ // host function reports failure by throwing jsi::JSError.
108
+ cppFlags '-O2', '-frtti', '-fexceptions', '-Wall', '-std=c++17'
109
+ arguments "-DANDROID_STL=c++_shared",
110
+ "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
111
+ "-DPDFCANVAS_WITH_JSI=${standalone ? 'OFF' : 'ON'}".toString()
112
+ abiFilters(*transportAbis())
113
+ }
114
+ }
115
+ }
116
+
117
+ compileOptions {
118
+ sourceCompatibility JavaVersion.VERSION_17
119
+ targetCompatibility JavaVersion.VERSION_17
120
+ }
121
+
122
+ externalNativeBuild {
123
+ cmake {
124
+ path 'src/jsi/cpp/CMakeLists.txt'
125
+ }
126
+ }
127
+
128
+ sourceSets {
129
+ main {
130
+ // The transport is React-free and joins BOTH builds — the standalone one
131
+ // compiles it with the JSI half switched off and exercises the slot store
132
+ // directly from androidTest.
133
+ java.srcDirs += 'src/jsi/java'
134
+ // The React binding is additive. On the standalone path it is not
135
+ // compiled at all, which is what keeps `src/main` provably React-free:
136
+ // if a core file ever imports com.facebook.*, this build stops compiling.
137
+ if (!standalone) {
138
+ java.srcDirs += 'src/reactnative/java'
139
+ }
140
+ }
141
+ }
142
+
143
+ if (!standalone) {
144
+ packagingOptions {
145
+ // Everything below is already in the app, shipped by React Native itself.
146
+ // Packaging a second copy out of this AAR is at best duplicate-file noise
147
+ // and at worst two libjsi.so with different ABIs in one process.
148
+ //
149
+ // ONLY on the autolinked path. `-DANDROID_STL=c++_shared` means
150
+ // libpdfcanvasjsi.so has a hard dependency on libc++_shared.so, and the
151
+ // standalone test APK has no React Native to supply it — excluding it
152
+ // there makes `System.loadLibrary` fail, `isLoaded()` return false, and
153
+ // the whole transport silently degrade. Which is precisely the failure
154
+ // `nativeTransportLibraryIsPresent` exists to catch, and did.
155
+ excludes += ['**/libjsi.so', '**/libc++_shared.so', '**/libreactnative.so']
156
+ }
157
+ }
158
+
159
+ lint {
160
+ abortOnError false
161
+ }
162
+ }
163
+
164
+ dependencies {
165
+ if (!standalone) {
166
+ // Supplied by the consuming app's React Native version. Never pinned here:
167
+ // a version mismatch against the app's own ReactAndroid is a link error at
168
+ // best and a silently wrong JSI ABI at worst.
169
+ //noinspection GradleDynamicVersion
170
+ implementation 'com.facebook.react:react-android'
171
+ }
172
+
173
+ androidTestImplementation 'androidx.test.ext:junit:1.1.5'
174
+ androidTestImplementation 'androidx.test:runner:1.5.2'
175
+ }
@@ -0,0 +1,3 @@
1
+ # The React binding is reached reflectively by React Native's module registry,
2
+ # so R8 cannot see the call site and would strip it from a release build.
3
+ -keep class tools.reekon.pdfcanvas.rn.** { *; }
@@ -0,0 +1,7 @@
1
+ distributionBase=GRADLE_USER_HOME
2
+ distributionPath=wrapper/dists
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
4
+ networkTimeout=10000
5
+ validateDistributionUrl=true
6
+ zipStoreBase=GRADLE_USER_HOME
7
+ zipStorePath=wrapper/dists
@@ -0,0 +1,2 @@
1
+ org.gradle.jvmargs=-Xmx2048m
2
+ android.useAndroidX=true
@@ -0,0 +1,248 @@
1
+ #!/bin/sh
2
+
3
+ #
4
+ # Copyright © 2015 the original authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ # SPDX-License-Identifier: Apache-2.0
19
+ #
20
+
21
+ ##############################################################################
22
+ #
23
+ # Gradle start up script for POSIX generated by Gradle.
24
+ #
25
+ # Important for running:
26
+ #
27
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28
+ # noncompliant, but you have some other compliant shell such as ksh or
29
+ # bash, then to run this script, type that shell name before the whole
30
+ # command line, like:
31
+ #
32
+ # ksh Gradle
33
+ #
34
+ # Busybox and similar reduced shells will NOT work, because this script
35
+ # requires all of these POSIX shell features:
36
+ # * functions;
37
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39
+ # * compound commands having a testable exit status, especially «case»;
40
+ # * various built-in commands including «command», «set», and «ulimit».
41
+ #
42
+ # Important for patching:
43
+ #
44
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
45
+ # by Bash, Ksh, etc; in particular arrays are avoided.
46
+ #
47
+ # The "traditional" practice of packing multiple parameters into a
48
+ # space-separated string is a well documented source of bugs and security
49
+ # problems, so this is (mostly) avoided, by progressively accumulating
50
+ # options in "$@", and eventually passing that to Java.
51
+ #
52
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54
+ # see the in-line comments for details.
55
+ #
56
+ # There are tweaks for specific operating systems such as AIX, CygWin,
57
+ # Darwin, MinGW, and NonStop.
58
+ #
59
+ # (3) This script is generated from the Groovy template
60
+ # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61
+ # within the Gradle project.
62
+ #
63
+ # You can find Gradle at https://github.com/gradle/gradle/.
64
+ #
65
+ ##############################################################################
66
+
67
+ # Attempt to set APP_HOME
68
+
69
+ # Resolve links: $0 may be a link
70
+ app_path=$0
71
+
72
+ # Need this for daisy-chained symlinks.
73
+ while
74
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75
+ [ -h "$app_path" ]
76
+ do
77
+ ls=$( ls -ld "$app_path" )
78
+ link=${ls#*' -> '}
79
+ case $link in #(
80
+ /*) app_path=$link ;; #(
81
+ *) app_path=$APP_HOME$link ;;
82
+ esac
83
+ done
84
+
85
+ # This is normally unused
86
+ # shellcheck disable=SC2034
87
+ APP_BASE_NAME=${0##*/}
88
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89
+ APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90
+
91
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
92
+ MAX_FD=maximum
93
+
94
+ warn () {
95
+ echo "$*"
96
+ } >&2
97
+
98
+ die () {
99
+ echo
100
+ echo "$*"
101
+ echo
102
+ exit 1
103
+ } >&2
104
+
105
+ # OS specific support (must be 'true' or 'false').
106
+ cygwin=false
107
+ msys=false
108
+ darwin=false
109
+ nonstop=false
110
+ case "$( uname )" in #(
111
+ CYGWIN* ) cygwin=true ;; #(
112
+ Darwin* ) darwin=true ;; #(
113
+ MSYS* | MINGW* ) msys=true ;; #(
114
+ NONSTOP* ) nonstop=true ;;
115
+ esac
116
+
117
+
118
+
119
+ # Determine the Java command to use to start the JVM.
120
+ if [ -n "$JAVA_HOME" ] ; then
121
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
122
+ # IBM's JDK on AIX uses strange locations for the executables
123
+ JAVACMD=$JAVA_HOME/jre/sh/java
124
+ else
125
+ JAVACMD=$JAVA_HOME/bin/java
126
+ fi
127
+ if [ ! -x "$JAVACMD" ] ; then
128
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
129
+
130
+ Please set the JAVA_HOME variable in your environment to match the
131
+ location of your Java installation."
132
+ fi
133
+ else
134
+ JAVACMD=java
135
+ if ! command -v java >/dev/null 2>&1
136
+ then
137
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
138
+
139
+ Please set the JAVA_HOME variable in your environment to match the
140
+ location of your Java installation."
141
+ fi
142
+ fi
143
+
144
+ # Increase the maximum file descriptors if we can.
145
+ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
146
+ case $MAX_FD in #(
147
+ max*)
148
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
149
+ # shellcheck disable=SC2039,SC3045
150
+ MAX_FD=$( ulimit -H -n ) ||
151
+ warn "Could not query maximum file descriptor limit"
152
+ esac
153
+ case $MAX_FD in #(
154
+ '' | soft) :;; #(
155
+ *)
156
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
157
+ # shellcheck disable=SC2039,SC3045
158
+ ulimit -n "$MAX_FD" ||
159
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
160
+ esac
161
+ fi
162
+
163
+ # Collect all arguments for the java command, stacking in reverse order:
164
+ # * args from the command line
165
+ # * the main class name
166
+ # * -classpath
167
+ # * -D...appname settings
168
+ # * --module-path (only if needed)
169
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
170
+
171
+ # For Cygwin or MSYS, switch paths to Windows format before running java
172
+ if "$cygwin" || "$msys" ; then
173
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
174
+
175
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
176
+
177
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
178
+ for arg do
179
+ if
180
+ case $arg in #(
181
+ -*) false ;; # don't mess with options #(
182
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
183
+ [ -e "$t" ] ;; #(
184
+ *) false ;;
185
+ esac
186
+ then
187
+ arg=$( cygpath --path --ignore --mixed "$arg" )
188
+ fi
189
+ # Roll the args list around exactly as many times as the number of
190
+ # args, so each arg winds up back in the position where it started, but
191
+ # possibly modified.
192
+ #
193
+ # NB: a `for` loop captures its iteration list before it begins, so
194
+ # changing the positional parameters here affects neither the number of
195
+ # iterations, nor the values presented in `arg`.
196
+ shift # remove old arg
197
+ set -- "$@" "$arg" # push replacement arg
198
+ done
199
+ fi
200
+
201
+
202
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204
+
205
+ # Collect all arguments for the java command:
206
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207
+ # and any embedded shellness will be escaped.
208
+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209
+ # treated as '${Hostname}' itself on the command line.
210
+
211
+ set -- \
212
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
213
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
214
+ "$@"
215
+
216
+ # Stop when "xargs" is not available.
217
+ if ! command -v xargs >/dev/null 2>&1
218
+ then
219
+ die "xargs is not available"
220
+ fi
221
+
222
+ # Use "xargs" to parse quoted args.
223
+ #
224
+ # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
225
+ #
226
+ # In Bash we could simply go:
227
+ #
228
+ # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
229
+ # set -- "${ARGS[@]}" "$@"
230
+ #
231
+ # but POSIX shell has neither arrays nor command substitution, so instead we
232
+ # post-process each arg (as a line of input to sed) to backslash-escape any
233
+ # character that might be a shell metacharacter, then use eval to reverse
234
+ # that process (while maintaining the separation between arguments), and wrap
235
+ # the whole thing up as a single "set" statement.
236
+ #
237
+ # This will of course break if any of these variables contains a newline or
238
+ # an unmatched quote.
239
+ #
240
+
241
+ eval "set -- $(
242
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
243
+ xargs -n1 |
244
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
245
+ tr '\n' ' '
246
+ )" '"$@"'
247
+
248
+ exec "$JAVACMD" "$@"
@@ -0,0 +1,98 @@
1
+ @REM Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ @REM
3
+ @REM This source code is licensed under the MIT license found in the
4
+ @REM LICENSE file in the root directory of this source tree.
5
+
6
+ @rem
7
+ @rem Copyright 2015 the original author or authors.
8
+ @rem
9
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
10
+ @rem you may not use this file except in compliance with the License.
11
+ @rem You may obtain a copy of the License at
12
+ @rem
13
+ @rem https://www.apache.org/licenses/LICENSE-2.0
14
+ @rem
15
+ @rem Unless required by applicable law or agreed to in writing, software
16
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
17
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ @rem See the License for the specific language governing permissions and
19
+ @rem limitations under the License.
20
+ @rem
21
+ @rem SPDX-License-Identifier: Apache-2.0
22
+ @rem
23
+
24
+ @if "%DEBUG%"=="" @echo off
25
+ @rem ##########################################################################
26
+ @rem
27
+ @rem Gradle startup script for Windows
28
+ @rem
29
+ @rem ##########################################################################
30
+
31
+ @rem Set local scope for the variables with windows NT shell
32
+ if "%OS%"=="Windows_NT" setlocal
33
+
34
+ set DIRNAME=%~dp0
35
+ if "%DIRNAME%"=="" set DIRNAME=.
36
+ @rem This is normally unused
37
+ set APP_BASE_NAME=%~n0
38
+ set APP_HOME=%DIRNAME%
39
+
40
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
41
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
42
+
43
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
44
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
45
+
46
+ @rem Find java.exe
47
+ if defined JAVA_HOME goto findJavaFromJavaHome
48
+
49
+ set JAVA_EXE=java.exe
50
+ %JAVA_EXE% -version >NUL 2>&1
51
+ if %ERRORLEVEL% equ 0 goto execute
52
+
53
+ echo. 1>&2
54
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
55
+ echo. 1>&2
56
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
57
+ echo location of your Java installation. 1>&2
58
+
59
+ goto fail
60
+
61
+ :findJavaFromJavaHome
62
+ set JAVA_HOME=%JAVA_HOME:"=%
63
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
64
+
65
+ if exist "%JAVA_EXE%" goto execute
66
+
67
+ echo. 1>&2
68
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
69
+ echo. 1>&2
70
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
71
+ echo location of your Java installation. 1>&2
72
+
73
+ goto fail
74
+
75
+ :execute
76
+ @rem Setup the command line
77
+
78
+
79
+
80
+ @rem Execute Gradle
81
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
82
+
83
+ :end
84
+ @rem End local scope for the variables with windows NT shell
85
+ if %ERRORLEVEL% equ 0 goto mainEnd
86
+
87
+ :fail
88
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
89
+ rem the _cmd.exe /c_ return code!
90
+ set EXIT_CODE=%ERRORLEVEL%
91
+ if %EXIT_CODE% equ 0 set EXIT_CODE=1
92
+ if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
93
+ exit /b %EXIT_CODE%
94
+
95
+ :mainEnd
96
+ if "%OS%"=="Windows_NT" endlocal
97
+
98
+ :omega
@@ -0,0 +1,34 @@
1
+ /*
2
+ * STANDALONE BUILD ROOT.
3
+ *
4
+ * This file is used ONLY when `android/` is built on its own — which is the
5
+ * point of the whole module split: the rasterizer core can be proven on an
6
+ * emulator with `./gradlew connectedDebugAndroidTest` and no React Native, no
7
+ * Metro and no consuming app anywhere in the picture.
8
+ *
9
+ * When a React Native app autolinks the package, RN's own settings.gradle does
10
+ * `include ':react-native-pdf-canvas'` and points its projectDir at this
11
+ * directory. THIS FILE IS THEN NEVER EVALUATED — a settings script only runs
12
+ * for the build it is the root of. That asymmetry is exactly what `build.gradle`
13
+ * uses to decide whether to compile the React binding: see `standalone` there.
14
+ */
15
+
16
+ pluginManagement {
17
+ repositories {
18
+ google()
19
+ mavenCentral()
20
+ gradlePluginPortal()
21
+ }
22
+ }
23
+
24
+ dependencyResolutionManagement {
25
+ repositories {
26
+ google()
27
+ mavenCentral()
28
+ }
29
+ }
30
+
31
+ // Read by build.gradle. Present only on the standalone path, by construction.
32
+ gradle.ext.pdfCanvasStandalone = true
33
+
34
+ rootProject.name = 'react-native-pdf-canvas'