Skip to content

Fix dead scan options and iOS PDF sizing, add NativePHP v4 support - #5

Merged
Ikromjon1998 merged 5 commits into
mainfrom
fix/v3-baseline-and-platform-parity
Oct 3, 2026
Merged

Ikromjon1998 merged 5 commits into
mainfrom
fix/v3-baseline-and-platform-parity

Conversation

@Ikromjon1998

@Ikromjon1998 Ikromjon1998 commented Aug 27, 2026 •

Copy link
Copy Markdown
Owner

Three scan options were documented as working but had no effect at runtime, and iOS PDF output was distorted. Also aligns packaging with the NativePHP Mobile v3 plugin spec.

Native fixes:

  • jpegQuality was a no-op on Android. Scanned pages were copied byte-for-byte from ML Kit's output URI, so the requested quality was never applied. Pages are now decoded and re-encoded at the requested quality, falling back to a raw copy if a page cannot be decoded.
  • maxPages was a no-op on iOS. VisionKit has no page-limit API, so the option was parsed and discarded. Enforced now by post-scan truncation (Epic 3), clamped by the max_pages_limit config the same way Android clamps it.
  • iOS PDF output forced every page to 612x792 US Letter and stretched the image to fit, so non-Letter documents came out distorted and low-res. Each page is now sized to its source image, matching Android.
  • pageCount in DocumentScanned reported 1 for PDF scans on iOS (the file count) while Android reported the page count. Both now report pages.

Packaging:

  • Android min_version 21 -> 29 and iOS 13.0 -> 18.0 to match the v3 baseline documented in the plugin spec. This is a breaking change for consumers targeting older OS versions.
  • Declare illuminate/support explicitly rather than relying on transitive resolution through nativephp/mobile.
  • Drop the "ocr" keyword; the plugin performs no OCR.

Added on 3 Oct: NativePHP for Mobile v4 support

  • nativephp/mobile constraint widened to ^3.0|^4.0. Without it the package cannot be installed in a v4 app.
  • CI gained a nativephp/mobile axis (^3.0, ^4.0) on PHP 8.3 and 8.4. Since nativephp/mobile 4.5.0 restored PHP 8.3 support, every job would otherwise resolve v4 and leave v3 untested.
  • CI reports one aggregate tests check. Branch protection requires a check with that name, but the matrix jobs report as "PHP 8.3" and so on, so the requirement could never be met.
  • The changelog entry is now 1.5.0-beta.1.

What was verified

  • composer check passes against nativephp/mobile 3.3.9 and 4.6.0 (133 tests, Pint, Rector, PHPStan).
  • In a fresh Laravel 13 app on nativephp/mobile 4.6.0, this branch compiles for iOS (Xcode 27, simulator) and Android (assembleDebug, compile/target SDK 36).
  • On the iOS simulator, imagesToPdf() and pdfToImages() return results and PdfCreated reaches both a Laravel listener and a Livewire #[OnNative] handler.

What was not verified

Scanning itself. VisionKit and the ML Kit scanner need a physical camera, so the jpegQuality re-encode, the iOS maxPages truncation and the iOS PDF page sizing in this PR have not been run on a device. That is why this ships as a pre-release first.

Three scan options were documented as working but had no effect at runtime,
and iOS PDF output was distorted. Also aligns packaging with the NativePHP
Mobile v3 plugin spec.

Native fixes:

- jpegQuality was a no-op on Android. Scanned pages were copied byte-for-byte
  from ML Kit's output URI, so the requested quality was never applied. Pages
  are now decoded and re-encoded at the requested quality, falling back to a
  raw copy if a page cannot be decoded.
- maxPages was a no-op on iOS. VisionKit has no page-limit API, so the option
  was parsed and discarded. Enforced now by post-scan truncation (Epic 3),
  clamped by the max_pages_limit config the same way Android clamps it.
- iOS PDF output forced every page to 612x792 US Letter and stretched the
  image to fit, so non-Letter documents came out distorted and low-res. Each
  page is now sized to its source image, matching Android.
- pageCount in DocumentScanned reported 1 for PDF scans on iOS (the file
  count) while Android reported the page count. Both now report pages.

Packaging:

- Android min_version 21 -> 29 and iOS 13.0 -> 18.0 to match the v3 baseline
  documented in the plugin spec. This is a breaking change for consumers
  targeting older OS versions.
- Declare illuminate/support explicitly rather than relying on transitive
  resolution through nativephp/mobile.
- Drop the "ocr" keyword; the plugin performs no OCR.
testbench ^9.0 resolves only to laravel/framework ^11.x, and Composer now
refuses to install any 11.x release because they all carry unresolved
security advisories. Dependency installation therefore failed outright on
both PHP 8.3 and 8.4.

This is pre-existing breakage, not a regression from the platform fixes —
CI last ran in April, before the advisories were published, so main is
equally affected.

testbench 10 targets Laravel 12 and testbench 11 targets Laravel 13; both
accept the PHPUnit ^11.5 that Pest 3 requires, so the test suite and its
Pest 3 syntax are unchanged.
@Ikromjon1998
Ikromjon1998 force-pushed the fix/v3-baseline-and-platform-parity branch from 6359c2a to 31e21eb Compare August 27, 2026 22:56
Rector's AddArrowFunctionReturnTypeRector and ClosureReturnTypeRector now
infer string|false for the nativephp_call stub closures, which all return
json_encode(). rector --dry-run failed on six test files as a result.

Version drift rather than a regression: CI last ran in April against an
older Rector, so main fails the same check. tests/Helpers.php is left alone
because Rector does not flag its fn () => null stub.
Add a nativephp/mobile axis so both majors run on PHP 8.3 and 8.4; without it every job resolves v4 now that nativephp/mobile 4.5.0 supports PHP 8.3 again.

Branch protection requires a check named "tests", but the matrix jobs report as "PHP 8.3" and so on, so the requirement could never be met. Add a final tests job that passes only when every other job did.
Widen the nativephp/mobile constraint to ^3.0|^4.0. The bridge, event and manifest contracts the plugin uses are unchanged in v4: both platforms compile in a v4 app, and imagesToPdf / pdfToImages run on the iOS simulator.

Mark the changelog entry as 1.5.0-beta.1: the native fixes in this branch have not been run on a physical device yet.
@Ikromjon1998 Ikromjon1998 changed the title Fix dead scan options, iOS PDF sizing, and v3 platform baselines Fix dead scan options and iOS PDF sizing, add NativePHP v4 support Oct 3, 2026
@Ikromjon1998
Ikromjon1998 merged commit c3e3f6c into main Oct 3, 2026
7 checks passed
@Ikromjon1998
Ikromjon1998 deleted the fix/v3-baseline-and-platform-parity branch October 3, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant