@reekon-tools/react-native-pdf-canvas 0.1.1 → 0.2.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 (121) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +57 -0
  3. package/PdfCanvas.podspec +68 -39
  4. package/README.md +213 -1316
  5. package/android/build.gradle +67 -54
  6. package/android/consumer-rules.pro +7 -0
  7. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasNativeTest.java +254 -0
  8. package/android/src/androidTest/java/tools/reekon/pdfcanvas/TestPdfs.java +60 -468
  9. package/android/src/main/cpp/CMakeLists.txt +54 -0
  10. package/android/src/main/cpp/pdfcanvas-jni.cpp +262 -0
  11. package/android/src/main/java/tools/reekon/pdfcanvas/PdfCanvasNative.java +167 -0
  12. package/android/src/main/java/tools/reekon/pdfcanvas/PdfErrorCode.java +14 -4
  13. package/android/src/main/java/tools/reekon/pdfcanvas/PdfRasterException.java +10 -4
  14. package/android/src/reactnative/java/tools/reekon/pdfcanvas/rn/PdfCanvasModule.java +160 -376
  15. package/android/tools/compile-gate.sh +81 -101
  16. package/dist/controller.d.ts +14 -0
  17. package/dist/controller.js +4 -3
  18. package/dist/rasterizer/index.native.d.ts +8 -12
  19. package/dist/rasterizer/index.native.js +15 -21
  20. package/dist/rasterizer/native-bridge.d.ts +51 -75
  21. package/dist/rasterizer/native-bridge.js +49 -33
  22. package/dist/rasterizer/native.d.ts +45 -0
  23. package/dist/rasterizer/native.js +123 -0
  24. package/dist/react/usePdfDocument.d.ts +5 -5
  25. package/dist/react/usePdfLayer.d.ts +10 -1
  26. package/dist/react/usePdfLayer.js +10 -2
  27. package/dist/testing/scenes.d.ts +3 -3
  28. package/dist/testing/scenes.js +4 -4
  29. package/dist/types.d.ts +36 -42
  30. package/ios/Sources/PdfCanvasBridge/PdfCanvasModule.mm +234 -536
  31. package/native/.clangd +5 -0
  32. package/native/CMakeLists.txt +89 -0
  33. package/native/core/include/pdfcanvas/document.h +90 -0
  34. package/native/core/include/pdfcanvas/error.h +47 -0
  35. package/native/core/include/pdfcanvas/jsi.h +18 -0
  36. package/native/core/include/pdfcanvas/jsi_config.h +30 -0
  37. package/native/core/include/pdfcanvas/library.h +28 -0
  38. package/native/core/include/pdfcanvas/pixels.h +92 -0
  39. package/native/core/include/pdfcanvas/service.h +87 -0
  40. package/native/core/include/pdfcanvas/slots.h +113 -0
  41. package/native/core/include/pdfcanvas/types.h +110 -0
  42. package/native/core/pdfcanvas-core.cmake +22 -0
  43. package/native/core/src/document.cpp +516 -0
  44. package/native/core/src/error.cpp +29 -0
  45. package/native/core/src/jsi.cpp +66 -0
  46. package/native/core/src/library.cpp +52 -0
  47. package/native/core/src/pixels.cpp +45 -0
  48. package/native/core/src/service.cpp +156 -0
  49. package/native/core/src/slots.cpp +139 -0
  50. package/native/tests/fixtures.cpp +451 -0
  51. package/native/tests/fixtures.h +96 -0
  52. package/native/tests/harness.h +122 -0
  53. package/native/tests/main.cpp +64 -0
  54. package/native/tests/pixels_util.h +126 -0
  55. package/native/tests/test_document.cpp +485 -0
  56. package/native/tests/test_service.cpp +130 -0
  57. package/native/tests/test_slots.cpp +250 -0
  58. package/package.json +27 -7
  59. package/react-native.config.js +5 -2
  60. package/scripts/fetch-pdfium.mjs +487 -0
  61. package/scripts/pdfium-manifest.json +46 -0
  62. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasCancellationTest.java +0 -226
  63. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasConcurrencyTest.java +0 -239
  64. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasDeviceTimingTest.java +0 -251
  65. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasFailureTest.java +0 -221
  66. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasJsiTransportTest.java +0 -783
  67. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasPhaseTimingTest.java +0 -1388
  68. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasPoisonGuardTest.java +0 -98
  69. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasQuirksTest.java +0 -324
  70. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PdfCanvasRasterizerTest.java +0 -775
  71. package/android/src/androidTest/java/tools/reekon/pdfcanvas/PoisonsTheProcess.java +0 -20
  72. package/android/src/jsi/cpp/CMakeLists.txt +0 -33
  73. package/android/src/jsi/cpp/pdfcanvas-jsi.cpp +0 -469
  74. package/android/src/jsi/java/tools/reekon/pdfcanvas/jsi/PdfCanvasPixelBridge.java +0 -140
  75. package/android/src/main/java/tools/reekon/pdfcanvas/PageGeometry.java +0 -45
  76. package/android/src/main/java/tools/reekon/pdfcanvas/PdfCanvasRasterizer.java +0 -564
  77. package/android/src/main/java/tools/reekon/pdfcanvas/PdfPlatformQuirks.java +0 -277
  78. package/android/src/main/java/tools/reekon/pdfcanvas/PdfPreflight.java +0 -214
  79. package/android/src/main/java/tools/reekon/pdfcanvas/PdfRendererPool.java +0 -234
  80. package/android/src/main/java/tools/reekon/pdfcanvas/RasterCancellation.java +0 -47
  81. package/android/src/main/java/tools/reekon/pdfcanvas/RasterPixels.java +0 -143
  82. package/android/src/main/java/tools/reekon/pdfcanvas/RasterRequest.java +0 -95
  83. package/dist/rasterizer/android.d.ts +0 -121
  84. package/dist/rasterizer/android.js +0 -126
  85. package/dist/rasterizer/ios.d.ts +0 -84
  86. package/dist/rasterizer/ios.js +0 -155
  87. package/ios/Package.swift +0 -58
  88. package/ios/Sources/PdfCanvasCore/PdfCanvasCancellation.m +0 -38
  89. package/ios/Sources/PdfCanvasCore/PdfCanvasDocumentPool.m +0 -389
  90. package/ios/Sources/PdfCanvasCore/PdfCanvasErrorCode.m +0 -57
  91. package/ios/Sources/PdfCanvasCore/PdfCanvasPageGeometry.m +0 -44
  92. package/ios/Sources/PdfCanvasCore/PdfCanvasPageTransform.m +0 -82
  93. package/ios/Sources/PdfCanvasCore/PdfCanvasPixelSink.m +0 -37
  94. package/ios/Sources/PdfCanvasCore/PdfCanvasPreflight.m +0 -158
  95. package/ios/Sources/PdfCanvasCore/PdfCanvasRasterPixels.m +0 -80
  96. package/ios/Sources/PdfCanvasCore/PdfCanvasRasterRequest.m +0 -65
  97. package/ios/Sources/PdfCanvasCore/PdfCanvasRasterizer.m +0 -548
  98. package/ios/Sources/PdfCanvasCore/include/PdfCanvasCancellation.h +0 -48
  99. package/ios/Sources/PdfCanvasCore/include/PdfCanvasCore.h +0 -26
  100. package/ios/Sources/PdfCanvasCore/include/PdfCanvasDocumentPool.h +0 -122
  101. package/ios/Sources/PdfCanvasCore/include/PdfCanvasErrorCode.h +0 -80
  102. package/ios/Sources/PdfCanvasCore/include/PdfCanvasPageGeometry.h +0 -79
  103. package/ios/Sources/PdfCanvasCore/include/PdfCanvasPageTransform.h +0 -129
  104. package/ios/Sources/PdfCanvasCore/include/PdfCanvasPixelSink.h +0 -100
  105. package/ios/Sources/PdfCanvasCore/include/PdfCanvasPreflight.h +0 -65
  106. package/ios/Sources/PdfCanvasCore/include/PdfCanvasRasterPixels.h +0 -111
  107. package/ios/Sources/PdfCanvasCore/include/PdfCanvasRasterRequest.h +0 -85
  108. package/ios/Sources/PdfCanvasCore/include/PdfCanvasRasterizer.h +0 -163
  109. package/ios/Sources/PdfCanvasSlots/PdfCanvasSlots.mm +0 -297
  110. package/ios/Sources/PdfCanvasSlots/include/PdfCanvasSlots.h +0 -140
  111. package/ios/Tests/PdfCanvasCoreTests/ConcurrencyTests.swift +0 -358
  112. package/ios/Tests/PdfCanvasCoreTests/FailureTests.swift +0 -262
  113. package/ios/Tests/PdfCanvasCoreTests/GeometryTests.swift +0 -173
  114. package/ios/Tests/PdfCanvasCoreTests/PreviewTests.swift +0 -114
  115. package/ios/Tests/PdfCanvasCoreTests/RasterAssertions.swift +0 -158
  116. package/ios/Tests/PdfCanvasCoreTests/RasterizerTests.swift +0 -544
  117. package/ios/Tests/PdfCanvasCoreTests/SinkTests.swift +0 -287
  118. package/ios/Tests/PdfCanvasCoreTests/SlotsTests.swift +0 -396
  119. package/ios/Tests/PdfCanvasCoreTests/TestPdfs.swift +0 -639
  120. package/ios/Tests/PdfCanvasCoreTests/TimingTests.swift +0 -179
  121. package/ios/Tests/PdfCanvasCoreTests/TransformTests.swift +0 -283
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 REEKON Tools
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,57 @@
1
+ @reekon-tools/react-native-pdf-canvas
2
+ Copyright 2026 REEKON Tools
3
+
4
+ This product includes software developed by REEKON Tools (https://reekon.tools).
5
+
6
+ Licensed under the Apache License, Version 2.0. See the LICENSE file for terms.
7
+
8
+ --------------------------------------------------------------------------------
9
+ THIRD-PARTY COMPONENTS
10
+ --------------------------------------------------------------------------------
11
+
12
+ This package contains no third-party source code. It does, however, build
13
+ against PDFium, which it downloads at build time rather than vendoring — so an
14
+ application that ships this package also ships PDFium and inherits the
15
+ attribution obligations below. Reproduce them in your application's
16
+ third-party-notices screen.
17
+
18
+ PDFium
19
+ Copyright 2014 PDFium Authors. Copyright 2014 Google Inc.
20
+ Licensed under the 3-Clause BSD License.
21
+ https://pdfium.googlesource.com/pdfium/
22
+
23
+ PDFium bundles the following components, whose license texts are shipped in
24
+ the `licenses/` directory of every prebuilt PDFium archive this package
25
+ fetches (see `scripts/pdfium-manifest.json` for the pinned release):
26
+
27
+ Abseil Apache License 2.0
28
+ Anti-Grain Geometry 2.3 Permissive (AGG 2.3 license)
29
+ FreeType FreeType License (FTL) — requires credit in
30
+ documentation for any product using FreeType
31
+ ICU Unicode License
32
+ Little CMS (lcms2) MIT License
33
+ fast_float Apache License 2.0 / MIT / BSL-1.0
34
+ libjpeg-turbo IJG License / 3-Clause BSD
35
+ libpng PNG Reference Library License
36
+ llvm-libc Apache License 2.0 with LLVM Exception
37
+ OpenJPEG 2-Clause BSD License
38
+ simdutf Apache License 2.0 / MIT
39
+ zlib zlib License
40
+
41
+ pdfium-binaries (the prebuilt PDFium archives, and the build scripts that
42
+ produce them)
43
+ Copyright 2014-2025 Benoit Blanchon
44
+ Licensed under the MIT License.
45
+ https://github.com/bblanchon/pdfium-binaries
46
+
47
+ @embedpdf/pdfium (web backend only, an optional peer dependency — resolved only
48
+ by hosts that use the `./worker` subpath)
49
+ Copyright (c) 2024 CloudPDF, Ji Chang
50
+ Licensed under the MIT License.
51
+ https://github.com/embedpdf/embed-pdf-viewer
52
+
53
+ --------------------------------------------------------------------------------
54
+
55
+ @shopify/react-native-skia, react, react-native and react-native-reanimated are
56
+ peer dependencies. They are neither bundled nor redistributed by this package,
57
+ so their notices are your application's to carry on its own account.
package/PdfCanvas.podspec CHANGED
@@ -2,76 +2,105 @@ require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
 
5
+ # FETCH PDFIUM WHILE THE PODSPEC IS EVALUATED.
6
+ #
7
+ # `prepare_command` looks like the hook for this and is not: CocoaPods skips it
8
+ # for a `:path` pod, which is exactly what React Native autolinking makes this
9
+ # one. The only code that runs on every `pod install` (and on every `pod ipc
10
+ # spec` autolinking performs to read the spec) is the spec file itself, so the
11
+ # fetch happens here. It is idempotent — a stamp file makes a repeat run a stat
12
+ # and a node start-up — and it verifies every download against the SHA-256 in
13
+ # scripts/pdfium-manifest.json before extracting a byte. Assembling the
14
+ # xcframework needs lipo / install_name_tool / xcodebuild, which exist wherever
15
+ # `pod install` does.
16
+ #
17
+ # Offline builds: point PDFCANVAS_PDFIUM_CACHE at a folder of the pre-downloaded
18
+ # .tgz files, or PDFCANVAS_PDFIUM_MIRROR at an internal copy of the release URL
19
+ # layout. See scripts/fetch-pdfium.mjs.
20
+ node = ENV["PDFCANVAS_NODE"] || "node"
21
+ fetched = system(node, File.join(__dir__, "scripts", "fetch-pdfium.mjs"), "ios")
22
+ unless fetched
23
+ raise "[PdfCanvas] Could not fetch the pinned PDFium build for iOS. " \
24
+ "Run `node scripts/fetch-pdfium.mjs ios` in #{__dir__} to see why."
25
+ end
26
+
5
27
  # The pod is named `PdfCanvas`, matching the JS-side native module name, so
6
28
  # `NativeModules.PdfCanvas`, `RCT_EXPORT_MODULE(PdfCanvas)`, the Android
7
29
  # `PdfCanvasModule.NAME` and the line in `Podfile.lock` are all the same word. A
8
30
  # `pod install` that does not print it means autolinking never saw this file — see
9
- # `react-native.config.js`, which names it explicitly for the same reason the
10
- # Android entry names its `packageImportPath`.
31
+ # `react-native.config.js`, which names it explicitly.
11
32
  Pod::Spec.new do |s|
12
33
  s.name = "PdfCanvas"
13
34
  s.version = package["version"]
14
35
  s.summary = package["description"]
15
36
  s.description = <<-DESC
16
37
  The iOS rasterizer for @reekon-tools/react-native-pdf-canvas: PDF pages as
17
- RGBA bytes at exact doc-space rects, through CoreGraphics for tiles and PDFKit
18
- where annotations have to be composited.
38
+ RGBA bytes at exact doc-space rects, rendered by PDFium — the same engine and
39
+ the same pinned release as the Android and web backends.
19
40
  DESC
20
41
  s.homepage = "https://gitlab.com/reekon-tools/software/rock-pro/react-native-pdf-canvas"
21
- s.license = { :type => "MIT" }
42
+ # READ FROM package.json, never restated. A hardcoded type here silently
43
+ # outlived the relicense from MIT and told CocoaPods the wrong thing while
44
+ # `package.json` said Apache-2.0 — and this is the copy an iOS consumer's
45
+ # acknowledgements screen is generated from, so the two must not drift.
46
+ # `:file` is resolved against the pod root, which for the `:path` pod that
47
+ # autolinking creates is the installed package directory; LICENSE ships in
48
+ # `package.json#files` precisely so it is there.
49
+ s.license = { :type => package["license"], :file => "LICENSE" }
22
50
  s.authors = { "REEKON Tools" => "hello@reekon.tools" }
23
51
  s.source = { :git => "https://gitlab.com/reekon-tools/software/rock-pro/react-native-pdf-canvas.git", :tag => "#{s.version}" }
24
52
 
25
- # 13.0 rather than the app's 16.4. Nothing here needs anything newer:
26
- # `CGPDFDocument`, `CGBitmapContext` and `PDFKit` on iOS all predate it, and
27
- # `-[NSFileHandle readDataUpToLength:error:]` — the newest API touched — is 13.0.
28
- # `ios/Package.swift` declares the same floor, so the host-machine build and the
29
- # pod build agree about what is reachable.
53
+ # 13.0 is the floor of the PDFium dylib bblanchon ships (MinimumOSVersion in
54
+ # the framework's Info.plist is written to match). Nothing in this pod needs
55
+ # anything newer.
30
56
  s.platforms = { :ios => "13.0" }
31
57
  s.requires_arc = true
32
58
 
33
- # PDFKit and CoreGraphics are the whole dependency list. Note what is NOT here:
34
- # UIKit. `PdfCanvasCore` is compiled for macOS by `ios/Package.swift` so that
35
- # `swift test` can prove it on a laptop, and a UIKit import would break that
36
- # build — which is exactly when it should break.
37
- s.frameworks = "PDFKit", "CoreGraphics", "CoreFoundation"
59
+ # THE CORE IS C++ AND SHARED WITH ANDROID: `native/core` is compiled into this
60
+ # pod exactly as android/src/main/cpp/CMakeLists.txt compiles it into
61
+ # libpdfcanvas.so, and proven by `native/tests` on a laptop. `ios/Sources` is the
62
+ # React binding only — marshalling, a queue, a transport flag. CocoaPods does not
63
+ # read CMake, so the core's file list is restated here as globs; keep it in step
64
+ # with native/core/pdfcanvas-core.cmake.
65
+ s.source_files = [
66
+ "ios/Sources/**/*.{h,mm}",
67
+ "native/core/src/**/*.cpp",
68
+ "native/core/include/**/*.h",
69
+ ]
70
+ s.public_header_files = "ios/Sources/PdfCanvasBridge/include/*.h"
71
+ s.private_header_files = "native/core/include/**/*.h"
38
72
 
39
- # THREE TARGETS' WORTH OF SOURCE, ONE POD, mirroring the three source sets
40
- # `android/build.gradle` splits with its `standalone` flag:
41
- #
42
- # PdfCanvasCore — the React-free rasterizer. Also a SwiftPM target.
43
- # PdfCanvasSlots — the raster transport's storage. Also a SwiftPM target,
44
- # because it guards `<jsi/jsi.h>` with `__has_include`; this
45
- # build is the one where that header IS present, so the host
46
- # function is compiled in.
47
- # PdfCanvasBridge — the React binding. Only ever built here: it needs
48
- # `<React/RCTBridgeModule.h>` and
49
- # `<ReactCommon/RCTInteropTurboModule.h>`.
50
- s.source_files = "ios/Sources/**/*.{h,m,mm}"
73
+ # The prebuilt engine: device arm64 + simulator arm64/x86_64, assembled by
74
+ # scripts/fetch-pdfium.mjs from bblanchon/pdfium-binaries' official tarballs.
75
+ # A dynamic framework — CocoaPods embeds and re-signs it whatever `linkage`
76
+ # the host chose for its own pods.
77
+ s.vendored_frameworks = "native/.pdfium/ios/PDFium.xcframework"
78
+ s.frameworks = "Foundation"
51
79
 
52
- # Both `include` directories, so `#import <PdfCanvasRasterizer.h>` resolves from
53
- # the bridge and `#import "PdfCanvasSlots.h"` resolves from itself. Angle-bracket
54
- # imports of a pod's own headers are what survives `use_frameworks!`, which this
55
- # package's first consumer uses (`ios.useFrameworks: static`).
56
80
  s.pod_target_xcconfig = {
81
+ # The core includes PDFium as plain "fpdfview.h" (portable across Android,
82
+ # the host build and here), so the release's headers go on the search path
83
+ # rather than being reached through the framework module.
57
84
  "HEADER_SEARCH_PATHS" => [
58
- '"$(PODS_TARGET_SRCROOT)/ios/Sources/PdfCanvasCore/include"',
59
- '"$(PODS_TARGET_SRCROOT)/ios/Sources/PdfCanvasSlots/include"',
85
+ '"$(PODS_TARGET_SRCROOT)/native/core/include"',
86
+ '"$(PODS_TARGET_SRCROOT)/native/.pdfium/ios/include"',
60
87
  '"$(PODS_TARGET_SRCROOT)/ios/Sources/PdfCanvasBridge/include"',
61
88
  ].join(" "),
62
- # C++17 is the floor `<jsi/jsi.h>` needs; the React Native podspecs in the
63
- # same install compile at 20, and `install_modules_dependencies` below raises
64
- # this to match when it is available.
89
+ # C++17 is the floor `<jsi/jsi.h>` and the core need; the React Native
90
+ # podspecs in the same install compile at 20, and
91
+ # `install_modules_dependencies` raises this to match when it is available.
65
92
  "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
93
+ # Turns the JSI half of the core on: the slot buffer becomes a
94
+ # `jsi::MutableBuffer` and `installTakePixels` installs the host function.
95
+ # React-jsi's headers arrive through install_modules_dependencies below.
96
+ "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) PDFCANVAS_WITH_JSI=1",
66
97
  "DEFINES_MODULE" => "YES",
67
98
  }
68
99
 
69
100
  # `install_modules_dependencies` is React Native's own helper (react_native_pods.rb).
70
101
  # It adds React-Core, React-jsi, ReactCommon/turbomodule and the rest, and sets
71
102
  # the new-architecture compiler flags — so the pod tracks whatever the host's RN
72
- # version wants rather than restating a dependency list that would go stale. The
73
- # `defined?` guard is what every RN library ships: it lets `pod lib lint` and any
74
- # non-RN install still evaluate the podspec.
103
+ # version wants rather than restating a dependency list that would go stale.
75
104
  if defined?(install_modules_dependencies) != nil
76
105
  install_modules_dependencies(s)
77
106
  else