@g9tm/lynxcontrols-native 2.6.19 → 2.7.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.
Files changed (61) hide show
  1. package/README.md +40 -1
  2. package/android/build.gradle.kts +7 -0
  3. package/android/src/main/java/com/g9lynx/g9native/G9HostModule.kt +20 -0
  4. package/android/src/main/java/com/g9lynx/g9native/G9NativeImages.kt +16 -0
  5. package/android/src/main/java/com/g9lynx/g9native/canvas/G9CanvasModel.kt +2 -2
  6. package/android/src/main/java/com/g9lynx/g9native/canvas/G9CanvasPaths.kt +7 -26
  7. package/android/src/main/java/com/g9lynx/g9native/canvas/G9CanvasView.kt +9 -4
  8. package/android/src/main/java/com/g9lynx/g9native/generated/G9HostModuleSpec.java +3 -0
  9. package/android/src/main/java/com/g9lynx/g9native/generated/G9ImageModuleSpec.java +27 -0
  10. package/android/src/main/java/com/g9lynx/g9native/image/G9HostTypeface.kt +49 -0
  11. package/android/src/main/java/com/g9lynx/g9native/image/G9ImageDraw.kt +222 -0
  12. package/android/src/main/java/com/g9lynx/g9native/image/G9ImageModule.kt +54 -0
  13. package/android/src/main/java/com/g9lynx/g9native/image/G9ImageProcessor.kt +464 -0
  14. package/android/src/main/java/com/g9lynx/g9native/image/core/G9HostFont.kt +28 -0
  15. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageBudget.kt +54 -0
  16. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageColor.kt +48 -0
  17. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageError.kt +19 -0
  18. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageExifTags.kt +61 -0
  19. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageFiles.kt +99 -0
  20. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageGeometry.kt +150 -0
  21. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageJson.kt +200 -0
  22. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageQuality.kt +65 -0
  23. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageRedaction.kt +77 -0
  24. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageService.kt +102 -0
  25. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageSniff.kt +63 -0
  26. package/android/src/main/java/com/g9lynx/g9native/image/core/G9ImageSpec.kt +237 -0
  27. package/catalog/catalog.json +161 -1
  28. package/catalog/index.md +1 -1
  29. package/dist/.tsbuildinfo +1 -1
  30. package/dist/image.d.ts +219 -0
  31. package/dist/image.d.ts.map +1 -0
  32. package/dist/image.js +116 -0
  33. package/dist/image.js.map +1 -0
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +1 -0
  37. package/dist/protocol.d.ts +17 -0
  38. package/dist/protocol.d.ts.map +1 -1
  39. package/dist/services.d.ts.map +1 -1
  40. package/dist/services.js +12 -0
  41. package/dist/services.js.map +1 -1
  42. package/generated/G9HostModule.ts +1 -0
  43. package/generated/G9ImageModule.ts +64 -0
  44. package/ios/Tests/G9NativeTestSuite.h +8 -0
  45. package/ios/Tests/G9NativeTestSuite.m +350 -0
  46. package/ios/Tests/G9NativeTests.m +16 -0
  47. package/ios/g9lynx-native-swift.podspec +1 -1
  48. package/ios/g9lynx-native.podspec +5 -4
  49. package/ios/src/G9HostModule.m +10 -0
  50. package/ios/src/G9ImageModule.h +30 -0
  51. package/ios/src/G9ImageModule.m +986 -0
  52. package/ios/src/core/G9ImageCore.h +201 -0
  53. package/ios/src/core/G9ImageCore.m +1039 -0
  54. package/ios/src/generated/G9HostModuleSpec.h +1 -0
  55. package/ios/src/generated/G9ImageModuleSpec.h +16 -0
  56. package/ios/src/generated/G9ImageModuleSpec.m +2 -0
  57. package/ios/swift/canvas/G9LCCanvasCore.swift +3 -2
  58. package/ios/swift/canvas/G9LCCanvasView.swift +15 -4
  59. package/ios/swift/shared/G9LCFonts.swift +18 -2
  60. package/package.json +4 -4
  61. package/types/platform-native-module.d.ts +23 -0
@@ -7,9 +7,27 @@
7
7
  #import "../src/core/G9PreferencesCore.h"
8
8
  #import "../src/core/G9VideoCore.h"
9
9
  #import "../src/core/G9DigitsCore.h"
10
+ #import "../src/core/G9ImageCore.h"
10
11
  #import "../src/core/G9SqliteCore.h"
11
12
  #import "../src/core/G9SqliteTransport.h"
12
13
 
14
+ /** The quality search's encoder in tests: `perQuality` bytes per quality step (monotonic), or failing below `failBelow`. */
15
+ @interface G9FakeQualityEncoder : NSObject <G9ImageQualityEncoder> {
16
+ @public
17
+ long long _perQuality;
18
+ NSInteger _failBelow;
19
+ NSInteger _calls;
20
+ }
21
+ @end
22
+
23
+ @implementation G9FakeQualityEncoder
24
+ - (long long)byteCountAtQuality:(NSInteger)quality {
25
+ _calls++;
26
+ if (quality < _failBelow) return -1;
27
+ return (long long)quality * _perQuality;
28
+ }
29
+ @end
30
+
13
31
  #pragma mark - Values
14
32
 
15
33
  static NSData *G9Hex(NSString *hex) {
@@ -605,4 +623,336 @@ static NSString *G9U(unichar c) {
605
623
  return f;
606
624
  }
607
625
 
626
+ #pragma mark - G9ImageCore
627
+
628
+ static BOOL G9Near(double a, double b) {
629
+ return fabs(a - b) < 1e-9;
630
+ }
631
+
632
+ static BOOL G9BoxIs(G9ImageBox box, double x, double y, double w, double h) {
633
+ return G9Near(box.x, x) && G9Near(box.y, y) && G9Near(box.width, w) && G9Near(box.height, h);
634
+ }
635
+
636
+ static G9ImageAffine G9Affine(double a, double b, double c, double d, double e, double f) {
637
+ G9ImageAffine m = {a, b, c, d, e, f};
638
+ return m;
639
+ }
640
+
641
+ + (NSArray *)imageGeometry {
642
+ NSMutableArray *f = [NSMutableArray array];
643
+ // A raw 400 × 300 file: which raw corner each orientation shows at the displayed top-left and top-right (EXIF: where
644
+ // the 0th row and 0th column land).
645
+ double W = 400, H = 300;
646
+ double topLeft[9][2] = {{0, 0}, {0, 0}, {W, 0}, {W, H}, {0, H}, {0, 0}, {0, H}, {W, H}, {W, 0}};
647
+ double topRight[9][2] = {{0, 0}, {W, 0}, {0, 0}, {0, H}, {W, H}, {0, H}, {0, 0}, {W, 0}, {W, H}};
648
+ double bottomLeft[9][2] = {{0, 0}, {0, H}, {W, H}, {W, 0}, {0, 0}, {W, 0}, {W, H}, {0, H}, {0, 0}};
649
+ for (NSInteger o = 1; o <= 8; o++) {
650
+ double ow, oh;
651
+ [G9ImageCore orientedSizeForRawWidth:W rawHeight:H orientation:o width:&ow height:&oh];
652
+ BOOL swap = o >= 5;
653
+ if (!G9Near(ow, swap ? H : W) || !G9Near(oh, swap ? W : H)) [f addObject:[NSString stringWithFormat:@"oriented size %ld", (long)o]];
654
+ if ([G9ImageCore orientationSwapsAxes:o] != swap) [f addObject:[NSString stringWithFormat:@"swaps %ld", (long)o]];
655
+ G9ImageAffine m = [G9ImageCore orientedToRawForOrientation:o rawWidth:W rawHeight:H];
656
+ double x, y;
657
+ G9ImageAffineApply(m, 0, 0, &x, &y);
658
+ if (!G9Near(x, topLeft[o][0]) || !G9Near(y, topLeft[o][1])) [f addObject:[NSString stringWithFormat:@"top-left %ld → %g,%g", (long)o, x, y]];
659
+ G9ImageAffineApply(m, ow, 0, &x, &y);
660
+ if (!G9Near(x, topRight[o][0]) || !G9Near(y, topRight[o][1])) [f addObject:[NSString stringWithFormat:@"top-right %ld → %g,%g", (long)o, x, y]];
661
+ G9ImageAffineApply(m, 0, oh, &x, &y);
662
+ if (!G9Near(x, bottomLeft[o][0]) || !G9Near(y, bottomLeft[o][1])) [f addObject:[NSString stringWithFormat:@"bottom-left %ld → %g,%g", (long)o, x, y]];
663
+ }
664
+ if ([G9ImageCore normalizedOrientation:0] != 1 || [G9ImageCore normalizedOrientation:9] != 1) [f addObject:@"orientation outside 1..8"];
665
+
666
+ // The raw box: a 100 × 100 output at the top-left of an orientation-6 4000 × 3000 file is the raw bottom-left strip.
667
+ G9ImageBox box = [G9ImageCore rawBoxForOutputWidth:100 height:100 matrix:G9ImageAffineIdentity() orientation:6 rawWidth:4000 rawHeight:3000 margin:2];
668
+ if (!G9BoxIs(box, 0, 2898, 102, 102)) [f addObject:[NSString stringWithFormat:@"box o6 %g,%g %gx%g", box.x, box.y, box.width, box.height]];
669
+ // A 2× crop at (500, 1000), orientation 1.
670
+ box = [G9ImageCore rawBoxForOutputWidth:200 height:100 matrix:G9Affine(2, 0, 0, 2, 500, 1000) orientation:1 rawWidth:4000 rawHeight:3000 margin:2];
671
+ if (!G9BoxIs(box, 498, 998, 404, 204)) [f addObject:@"box crop o1"];
672
+ // The same crop on orientation 3 (180°): the mirrored box.
673
+ box = [G9ImageCore rawBoxForOutputWidth:200 height:100 matrix:G9Affine(2, 0, 0, 2, 500, 1000) orientation:3 rawWidth:4000 rawHeight:3000 margin:2];
674
+ if (!G9BoxIs(box, 4000 - 902, 3000 - 1202, 404, 204)) [f addObject:@"box crop o3"];
675
+ // Orientation 8: rx = W − y, ry = x.
676
+ box = [G9ImageCore rawBoxForOutputWidth:200 height:100 matrix:G9Affine(2, 0, 0, 2, 500, 1000) orientation:8 rawWidth:4000 rawHeight:3000 margin:0];
677
+ if (!G9BoxIs(box, 4000 - 1200, 500, 200, 400)) [f addObject:@"box crop o8"];
678
+ // A quarter turn in the matrix (x' = −y + 300, y' = x): the corners' bounding box.
679
+ box = [G9ImageCore rawBoxForOutputWidth:100 height:300 matrix:G9Affine(0, 1, -1, 0, 300, 0) orientation:1 rawWidth:4000 rawHeight:3000 margin:0];
680
+ if (!G9BoxIs(box, 0, 0, 300, 100)) [f addObject:[NSString stringWithFormat:@"box quarter %g,%g %gx%g", box.x, box.y, box.width, box.height]];
681
+ // Clamped to the picture; nothing when the output misses it.
682
+ box = [G9ImageCore rawBoxForOutputWidth:1000 height:1000 matrix:G9Affine(1, 0, 0, 1, 3500, 2500) orientation:1 rawWidth:4000 rawHeight:3000 margin:2];
683
+ if (!G9BoxIs(box, 3498, 2498, 502, 502)) [f addObject:@"box clamped"];
684
+ box = [G9ImageCore rawBoxForOutputWidth:100 height:100 matrix:G9Affine(1, 0, 0, 1, -1000, -1000) orientation:1 rawWidth:4000 rawHeight:3000 margin:2];
685
+ if (box.width != 0 || box.height != 0) [f addObject:@"box outside"];
686
+ // A free angle: 45° about the origin, the box is the rotated square's bounds (whole pixels, outward).
687
+ double c = cos(acos(-1.0) / 4), s = sin(acos(-1.0) / 4);
688
+ box = [G9ImageCore rawBoxForOutputWidth:100 height:100 matrix:G9Affine(c, s, -s, c, 1000, 1000) orientation:1 rawWidth:4000 rawHeight:3000 margin:0];
689
+ if (!G9BoxIs(box, floor(1000 - 100 * s), 1000, ceil(1000 + 100 * c) - floor(1000 - 100 * s), ceil(1000 + 100 * (s + c)) - 1000))
690
+ [f addObject:[NSString stringWithFormat:@"box 45° %g,%g %gx%g", box.x, box.y, box.width, box.height]];
691
+
692
+ // The affine helpers.
693
+ G9ImageAffine m = G9Affine(2, 0.5, -1, 3, 10, -4);
694
+ BOOL ok = NO;
695
+ G9ImageAffine back = G9ImageAffineConcat(G9ImageAffineInvert(m, &ok), m);
696
+ if (!ok || !G9Near(back.a, 1) || !G9Near(back.b, 0) || !G9Near(back.c, 0) || !G9Near(back.d, 1) || !G9Near(back.e, 0) || !G9Near(back.f, 0))
697
+ [f addObject:@"invert"];
698
+ G9ImageAffineInvert(G9Affine(1, 2, 2, 4, 0, 0), &ok);
699
+ if (ok) [f addObject:@"singular"];
700
+
701
+ // Subsample: the largest of 1/2/4/8 at or under the source px per output px.
702
+ if ([G9ImageCore subsampleForSourcePerOutput:0.5] != 1 || [G9ImageCore subsampleForSourcePerOutput:1.99] != 1 ||
703
+ [G9ImageCore subsampleForSourcePerOutput:2] != 2 || [G9ImageCore subsampleForSourcePerOutput:3.9] != 2 ||
704
+ [G9ImageCore subsampleForSourcePerOutput:4] != 4 || [G9ImageCore subsampleForSourcePerOutput:7.9] != 4 ||
705
+ [G9ImageCore subsampleForSourcePerOutput:100] != 8 || [G9ImageCore subsampleForSourcePerOutput:NAN] != 1)
706
+ [f addObject:@"subsample"];
707
+ if (!G9Near([G9ImageCore sourcePixelsPerOutputPixel:G9Affine(3, 0, 0, 5, 9, 9)], 3)) [f addObject:@"source per output"];
708
+ if (!G9Near([G9ImageCore sourcePixelsPerOutputPixel:G9Affine(0, 2, -2, 0, 0, 0)], 2)) [f addObject:@"source per output, turned"];
709
+ // Preview: never upscaled.
710
+ if ([G9ImageCore previewMaxPixelForMaxSide:1080 width:4000 height:3000] != 1080) [f addObject:@"preview max"];
711
+ if ([G9ImageCore previewMaxPixelForMaxSide:5000 width:4000 height:3000] != 4000) [f addObject:@"preview no upscale"];
712
+ return f;
713
+ }
714
+
715
+ + (NSArray *)imageEncoding {
716
+ NSMutableArray *f = [NSMutableArray array];
717
+ G9FakeQualityEncoder *enc = [[G9FakeQualityEncoder alloc] init];
718
+ enc->_perQuality = 1000;
719
+ NSInteger attempts = 0;
720
+ // 90 fits: one encoding.
721
+ if ([G9ImageCore qualityForMaxBytes:1000000 start:90 floor:30 encoder:enc attempts:&attempts] != 90 || attempts != 1) [f addObject:@"start fits"];
722
+ // The highest quality ≤ 55 500 bytes is 55, found by binary search in a handful of encodings.
723
+ NSInteger q = [G9ImageCore qualityForMaxBytes:55500 start:90 floor:30 encoder:enc attempts:&attempts];
724
+ if (q != 55) [f addObject:[NSString stringWithFormat:@"search → %ld", (long)q]];
725
+ if (attempts > 8) [f addObject:[NSString stringWithFormat:@"search took %ld encodings", (long)attempts]];
726
+ // Exactly at the floor, and below it.
727
+ if ([G9ImageCore qualityForMaxBytes:30000 start:90 floor:30 encoder:enc attempts:NULL] != 30) [f addObject:@"floor fits"];
728
+ if ([G9ImageCore qualityForMaxBytes:29999 start:90 floor:30 encoder:enc attempts:NULL] != -1) [f addObject:@"floor too big"];
729
+ // Failed encodings count as too big.
730
+ enc->_failBelow = 60;
731
+ if ([G9ImageCore qualityForMaxBytes:55500 start:90 floor:30 encoder:enc attempts:NULL] != -1) [f addObject:@"failures"];
732
+ enc->_failBelow = 0;
733
+ // A start below the floor searches only itself.
734
+ if ([G9ImageCore qualityForMaxBytes:100000 start:20 floor:30 encoder:enc attempts:NULL] != 20) [f addObject:@"low start"];
735
+ if ([G9ImageCore qualityFloorForQuality:90] != 30 || [G9ImageCore qualityFloorForQuality:20] != 20) [f addObject:@"floor"];
736
+ // The scale step.
737
+ if ([G9ImageCore scaledDimension:1600] != 1360 || [G9ImageCore scaledDimension:2000] != 1700 || [G9ImageCore scaledDimension:1] != 1)
738
+ [f addObject:@"scale step"];
739
+ // Scaling gives up once the shorter side would drop below 16 px (19 → 16 still allowed, 18 → 15 not).
740
+ if (![G9ImageCore canScaleWidth:1600 height:2000] || ![G9ImageCore canScaleWidth:1000 height:19] ||
741
+ [G9ImageCore canScaleWidth:1000 height:18] || [G9ImageCore canScaleWidth:16 height:16])
742
+ [f addObject:@"scale give-up"];
743
+ if (!G9Near([G9ImageCore lineHeightForSize:32], 40)) [f addObject:@"line height"];
744
+ // Formats: iOS writes WebP only when it can; HEIC becomes JPEG.
745
+ if (![[G9ImageCore outputFormatForRequested:@"webp" sourceMime:nil hasAlpha:NO webpEncodable:NO] isEqualToString:@"jpeg"]) [f addObject:@"webp → jpeg"];
746
+ if (![[G9ImageCore outputFormatForRequested:@"webp" sourceMime:nil hasAlpha:NO webpEncodable:YES] isEqualToString:@"webp"]) [f addObject:@"webp"];
747
+ if (![[G9ImageCore outputFormatForRequested:@"source" sourceMime:@"image/heic" hasAlpha:NO webpEncodable:NO] isEqualToString:@"jpeg"]) [f addObject:@"heic → jpeg"];
748
+ if (![[G9ImageCore outputFormatForRequested:@"source" sourceMime:@"image/png" hasAlpha:YES webpEncodable:NO] isEqualToString:@"png"]) [f addObject:@"source png"];
749
+ if (![[G9ImageCore outputFormatForRequested:@"source" sourceMime:@"image/jpeg" hasAlpha:NO webpEncodable:NO] isEqualToString:@"jpeg"]) [f addObject:@"source jpeg"];
750
+ if (![[G9ImageCore outputFormatForRequested:@"source" sourceMime:@"image/gif" hasAlpha:YES webpEncodable:NO] isEqualToString:@"png"]) [f addObject:@"source gif"];
751
+ if (![[G9ImageCore outputFormatForRequested:@"source" sourceMime:@"image/webp" hasAlpha:YES webpEncodable:NO] isEqualToString:@"png"]) [f addObject:@"source webp, alpha"];
752
+ if (![[G9ImageCore extensionForFormat:@"jpeg"] isEqualToString:@"jpg"] || ![[G9ImageCore mimeForFormat:@"png"] isEqualToString:@"image/png"])
753
+ [f addObject:@"extension / mime"];
754
+ if (![[G9ImageCore mimeForTypeIdentifier:@"public.heic"] isEqualToString:@"image/heic"] ||
755
+ ![[G9ImageCore formatForMime:[G9ImageCore mimeForTypeIdentifier:@"public.jpeg"]] isEqualToString:@"jpeg"] ||
756
+ [G9ImageCore formatForMime:@"text/plain"] != nil)
757
+ [f addObject:@"type identifiers"];
758
+ if (![G9ImageCore formatHasAlpha:@"png"] || [G9ImageCore formatHasAlpha:@"jpeg"]) [f addObject:@"alpha formats"];
759
+ // Redaction sizes from the output's shorter side.
760
+ if (!G9Near([G9ImageCore pixelateBlockForStrength:0.5 width:1600 height:2000], 64) ||
761
+ !G9Near([G9ImageCore pixelateBlockForStrength:0 width:1600 height:2000], 4) ||
762
+ !G9Near([G9ImageCore pixelateBlockForStrength:3 width:1600 height:2000], 128))
763
+ [f addObject:@"pixelate block"];
764
+ if (!G9Near([G9ImageCore blurRadiusForStrength:0.5 width:1600 height:2000], 40) || !G9Near([G9ImageCore blurRadiusForStrength:0 width:100 height:100], 2))
765
+ [f addObject:@"blur radius"];
766
+ if (!G9Near([G9ImageCore fontWeightTraitForWeight:400], 0) || !G9Near([G9ImageCore fontWeightTraitForWeight:700], 0.4) ||
767
+ !G9Near([G9ImageCore fontWeightTraitForWeight:50], -0.8) || !G9Near([G9ImageCore fontWeightTraitForWeight:900], 0.62))
768
+ [f addObject:@"weights"];
769
+ return f;
770
+ }
771
+
772
+ + (NSArray *)imageNamesColoursPaths {
773
+ NSMutableArray *f = [NSMutableArray array];
774
+ if (![[G9ImageCore defaultNameForEpochMs:1700000000000LL random:0xABCD12F4u] isEqualToString:@"g9photo-1700000000000-12f4"]) [f addObject:@"default name"];
775
+ if (![[G9ImageCore defaultNameForEpochMs:5 random:7] isEqualToString:@"g9photo-5-0007"]) [f addObject:@"default name padding"];
776
+ if (![G9ImageCore isUsableName:@"photo 1"] || [G9ImageCore isUsableName:@"a/b"] || [G9ImageCore isUsableName:@".."] ||
777
+ [G9ImageCore isUsableName:@""] || [G9ImageCore isUsableName:@"a\\b"])
778
+ [f addObject:@"usable names"];
779
+ // Unique paths in a scratch folder.
780
+ NSFileManager *fm = [NSFileManager defaultManager];
781
+ NSString *dir = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"g9-image-%d", (int)getpid()]];
782
+ [fm createDirectoryAtPath:dir withIntermediateDirectories:YES attributes:nil error:NULL];
783
+ NSString *first = [G9ImageCore uniquePathInDirectory:dir base:@"shot" extension:@"jpg"];
784
+ if (![[first lastPathComponent] isEqualToString:@"shot.jpg"]) [f addObject:@"unique first"];
785
+ [[NSData data] writeToFile:first atomically:NO];
786
+ NSString *second = [G9ImageCore uniquePathInDirectory:dir base:@"shot" extension:@"jpg"];
787
+ if (![[second lastPathComponent] isEqualToString:@"shot-1.jpg"]) [f addObject:[NSString stringWithFormat:@"unique second %@", second]];
788
+ [[NSData data] writeToFile:second atomically:NO];
789
+ if (![[[G9ImageCore uniquePathInDirectory:dir base:@"shot" extension:@"jpg"] lastPathComponent] isEqualToString:@"shot-2.jpg"]) [f addObject:@"unique third"];
790
+ if (![[[G9ImageCore uniquePathInDirectory:dir base:@"shot" extension:@"png"] lastPathComponent] isEqualToString:@"shot.png"]) [f addObject:@"unique per extension"];
791
+ [fm removeItemAtPath:dir error:NULL];
792
+ // Paths and file:// URIs.
793
+ if (![[G9ImageCore filePathFromString:@"file:///var/mobile/a%20b.jpg"] isEqualToString:@"/var/mobile/a b.jpg"]) [f addObject:@"file uri"];
794
+ if (![[G9ImageCore filePathFromString:@"file://localhost/tmp/x.png"] isEqualToString:@"/tmp/x.png"]) [f addObject:@"file localhost"];
795
+ if (![[G9ImageCore filePathFromString:@"/tmp/x y.png"] isEqualToString:@"/tmp/x y.png"]) [f addObject:@"plain path"];
796
+ if ([G9ImageCore filePathFromString:@"content://media/1"] != nil || [G9ImageCore filePathFromString:@""] != nil ||
797
+ [G9ImageCore filePathFromString:nil] != nil)
798
+ [f addObject:@"other schemes"];
799
+ // Colours.
800
+ double c[4];
801
+ if (![G9ImageCore parseColor:@"#fff" rgba:c] || !G9Near(c[0], 1) || !G9Near(c[3], 1)) [f addObject:@"#rgb"];
802
+ if (![G9ImageCore parseColor:@"#000000aa" rgba:c] || !G9Near(c[0], 0) || !G9Near(c[3], 170.0 / 255)) [f addObject:@"#rrggbbaa"];
803
+ if (![G9ImageCore parseColor:@"#E53935" rgba:c] || !G9Near(c[0], 229.0 / 255) || !G9Near(c[1], 57.0 / 255) || !G9Near(c[2], 53.0 / 255)) [f addObject:@"#rrggbb"];
804
+ if (![G9ImageCore parseColor:@"#f008" rgba:c] || !G9Near(c[3], 136.0 / 255)) [f addObject:@"#rgba"];
805
+ if (![G9ImageCore parseColor:@"rgba(255, 0, 0, 0.5)" rgba:c] || !G9Near(c[0], 1) || !G9Near(c[3], 128.0 / 255)) [f addObject:@"rgba()"];
806
+ if (![G9ImageCore parseColor:@"rgb(5 22 31 / 50%)" rgba:c] || !G9Near(c[1], 22.0 / 255) || !G9Near(c[3], 128.0 / 255)) [f addObject:@"rgb() spaces"];
807
+ if (![G9ImageCore parseColor:@" Transparent " rgba:c] || !G9Near(c[3], 0)) [f addObject:@"transparent"];
808
+ if ([G9ImageCore parseColor:@"#12345" rgba:c] || [G9ImageCore parseColor:@"red" rgba:c] || [G9ImageCore parseColor:@"#ggg" rgba:c] ||
809
+ [G9ImageCore parseColor:@"rgb(1,2)" rgba:c] || [G9ImageCore parseColor:nil rgba:c])
810
+ [f addObject:@"bad colours"];
811
+ // SVG path data.
812
+ NSData *data = [G9ImageCore pathSegmentsFromData:@"M10 10 L200 40 C1 2 3 4 5 6 Z"];
813
+ const G9PathSegment *seg = [data bytes];
814
+ NSUInteger n = [data length] / sizeof(G9PathSegment);
815
+ if (n != 4 || seg[0].op != G9PathMove || seg[1].op != G9PathLine || !G9Near(seg[1].p[0], 200) || seg[2].op != G9PathCubic ||
816
+ !G9Near(seg[2].p[4], 5) || !G9Near(seg[2].p[5], 6) || seg[3].op != G9PathClose)
817
+ [f addObject:@"path absolute"];
818
+ data = [G9ImageCore pathSegmentsFromData:@"m10 10 l5 5 h5 v-5 z"];
819
+ seg = [data bytes];
820
+ n = [data length] / sizeof(G9PathSegment);
821
+ if (n != 5 || !G9Near(seg[1].p[0], 15) || !G9Near(seg[1].p[1], 15) || !G9Near(seg[2].p[0], 20) || !G9Near(seg[3].p[1], 10) || seg[4].op != G9PathClose)
822
+ [f addObject:@"path relative"];
823
+ data = [G9ImageCore pathSegmentsFromData:@"M0,0 10,10 20-5"];
824
+ seg = [data bytes];
825
+ n = [data length] / sizeof(G9PathSegment);
826
+ if (n != 3 || seg[1].op != G9PathLine || !G9Near(seg[2].p[0], 20) || !G9Near(seg[2].p[1], -5)) [f addObject:@"path implicit lines"];
827
+ data = [G9ImageCore pathSegmentsFromData:@"M0 0 C0 10 10 10 10 0 S20 -10 20 0 Q25 5 30 0 T40 0"];
828
+ seg = [data bytes];
829
+ n = [data length] / sizeof(G9PathSegment);
830
+ // S reflects (10,10) about (10,0) → (10,−10); T reflects (25,5) about (30,0) → (35,−5).
831
+ if (n != 5 || !G9Near(seg[2].p[0], 10) || !G9Near(seg[2].p[1], -10) || seg[4].op != G9PathQuad || !G9Near(seg[4].p[0], 35) || !G9Near(seg[4].p[1], -5))
832
+ [f addObject:@"path smooth"];
833
+ data = [G9ImageCore pathSegmentsFromData:@"M1.5.5L1e1 2"];
834
+ seg = [data bytes];
835
+ n = [data length] / sizeof(G9PathSegment);
836
+ if (n != 2 || !G9Near(seg[0].p[0], 1.5) || !G9Near(seg[0].p[1], 0.5) || !G9Near(seg[1].p[0], 10)) [f addObject:@"path numbers"];
837
+ if ([[G9ImageCore pathSegmentsFromData:@"M10"] length] != 0 || [[G9ImageCore pathSegmentsFromData:nil] length] != 0) [f addObject:@"path broken"];
838
+ return f;
839
+ }
840
+
841
+ + (NSArray *)imageSpec {
842
+ NSMutableArray *f = [NSMutableArray array];
843
+ NSString *message = nil;
844
+ // A minimal spec: defaults filled in.
845
+ NSDictionary *spec = [G9ImageCore validateProcessSpec:[G9ImageCore objectFromJSON:@"{\"path\":\"file:///tmp/a.jpg\",\"width\":1600,\"height\":2000,\"matrix\":[2,0,0,2,10,20]}"] message:&message];
846
+ if (spec == nil) {
847
+ [f addObject:[NSString stringWithFormat:@"minimal spec: %@", message]];
848
+ } else {
849
+ if (![[spec objectForKey:@"path"] isEqualToString:@"/tmp/a.jpg"]) [f addObject:@"spec path"];
850
+ if ([[spec objectForKey:@"width"] integerValue] != 1600 || [[spec objectForKey:@"height"] integerValue] != 2000) [f addObject:@"spec size"];
851
+ if (![[spec objectForKey:@"format"] isEqualToString:@"jpeg"] || [[spec objectForKey:@"quality"] integerValue] != 90) [f addObject:@"spec format defaults"];
852
+ if ([[spec objectForKey:@"maxBytes"] longLongValue] != 0 || [[spec objectForKey:@"keepMetadata"] boolValue] || [[spec objectForKey:@"circle"] boolValue])
853
+ [f addObject:@"spec flag defaults"];
854
+ if ([spec objectForKey:@"background"] != nil || [spec objectForKey:@"token"] != nil || [spec objectForKey:@"dir"] != nil) [f addObject:@"spec absent fields"];
855
+ G9ImageAffine m = [G9ImageCore affineFromArray:[spec objectForKey:@"matrix"]];
856
+ if (!G9Near(m.a, 2) || !G9Near(m.e, 10) || !G9Near(m.f, 20)) [f addObject:@"spec matrix"];
857
+ }
858
+ // A full spec with redactions and overlays.
859
+ NSString *full = @"{\"token\":\"t1\",\"path\":\"/tmp/a.heic\",\"width\":100,\"height\":50,\"background\":\"#ffffff\",\"circle\":true,"
860
+ @"\"redact\":[{\"x\":1,\"y\":2,\"width\":30,\"height\":12,\"angle\":15,\"mode\":\"blur\",\"strength\":4}],"
861
+ @"\"overlay\":[{\"k\":\"path\",\"d\":\"M0 0 L10 10\",\"stroke\":\"#e53935\",\"width\":8,\"fill\":null,\"cap\":\"round\",\"dash\":[12,8]},"
862
+ @"{\"k\":\"text\",\"text\":\"\\u0646\\u0645\\u0648\\u0646\\u0647\",\"x\":40,\"y\":30,\"background\":\"#000000aa\",\"rtl\":true,\"weight\":700}],"
863
+ @"\"format\":\"webp\",\"quality\":80,\"maxBytes\":500000,\"keepMetadata\":true,\"dir\":\"/tmp/out\",\"name\":\"fit\"}";
864
+ spec = [G9ImageCore validateProcessSpec:[G9ImageCore objectFromJSON:full] message:&message];
865
+ if (spec == nil) {
866
+ [f addObject:[NSString stringWithFormat:@"full spec: %@", message]];
867
+ } else {
868
+ NSDictionary *r = [[spec objectForKey:@"redact"] objectAtIndex:0];
869
+ if (![[r objectForKey:@"mode"] isEqualToString:@"blur"] || !G9Near([[r objectForKey:@"strength"] doubleValue], 1)) [f addObject:@"redact normalized"];
870
+ NSDictionary *p = [[spec objectForKey:@"overlay"] objectAtIndex:0];
871
+ if (![[p objectForKey:@"cap"] isEqualToString:@"round"] || ![[p objectForKey:@"join"] isEqualToString:@"miter"] || [p objectForKey:@"fill"] != nil ||
872
+ [[p objectForKey:@"transform"] count] != 6)
873
+ [f addObject:@"path op defaults"];
874
+ NSDictionary *t = [[spec objectForKey:@"overlay"] objectAtIndex:1];
875
+ if (![[t objectForKey:@"color"] isEqualToString:@"#000000"] || ![[t objectForKey:@"align"] isEqualToString:@"center"] ||
876
+ ![[t objectForKey:@"rtl"] boolValue] || !G9Near([[t objectForKey:@"size"] doubleValue], 32) || ![[t objectForKey:@"font"] isEqualToString:@""] ||
877
+ [[t objectForKey:@"text"] length] != 5)
878
+ [f addObject:@"text op defaults"];
879
+ if (![[spec objectForKey:@"token"] isEqualToString:@"t1"] || ![[spec objectForKey:@"name"] isEqualToString:@"fit"] ||
880
+ [[spec objectForKey:@"maxBytes"] longLongValue] != 500000 || ![[spec objectForKey:@"keepMetadata"] boolValue])
881
+ [f addObject:@"full spec fields"];
882
+ }
883
+ // The size limit is 20000 a side, with no area rule.
884
+ if ([G9ImageCore validateProcessSpec:[G9ImageCore objectFromJSON:@"{\"path\":\"/a\",\"width\":20000,\"height\":20000}"] message:&message] == nil)
885
+ [f addObject:[NSString stringWithFormat:@"20000 × 20000: %@", message]];
886
+ // Passthrough needs no size.
887
+ if ([G9ImageCore validateProcessSpec:[G9ImageCore objectFromJSON:@"{\"path\":\"/tmp/a.jpg\",\"passthrough\":true}"] message:&message] == nil) [f addObject:@"passthrough spec"];
888
+ // Rejections.
889
+ NSArray *bad = [NSArray arrayWithObjects:
890
+ @"[]", @"{\"width\":1,\"height\":1}", @"{\"path\":\"content://x\",\"width\":1,\"height\":1}",
891
+ @"{\"path\":\"/a\",\"height\":1}", @"{\"path\":\"/a\",\"width\":1.5,\"height\":1}", @"{\"path\":\"/a\",\"width\":0,\"height\":1}",
892
+ @"{\"path\":\"/a\",\"width\":40000,\"height\":1}", @"{\"path\":\"/a\",\"width\":1,\"height\":20001}",
893
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"matrix\":[1,2,2,4,0,0]}", @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"matrix\":[1,0,0,1]}",
894
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"background\":\"blue\"}", @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"format\":\"gif\"}",
895
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"quality\":101}", @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"name\":\"../x\"}",
896
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"redact\":[{\"x\":0,\"y\":0,\"width\":0,\"height\":1}]}",
897
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"redact\":[{\"x\":0,\"y\":0,\"width\":1,\"height\":1,\"mode\":\"smear\"}]}",
898
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"overlay\":[{\"k\":\"circle\"}]}",
899
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"overlay\":[{\"k\":\"text\",\"text\":\"a\",\"x\":0}]}",
900
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"overlay\":[{\"k\":\"path\",\"d\":\"M0 0\",\"dash\":[-1]}]}",
901
+ @"{\"path\":\"/a\",\"width\":1,\"height\":1,\"circle\":\"yes\"}", nil];
902
+ for (NSString *json in bad) {
903
+ message = nil;
904
+ if ([G9ImageCore validateProcessSpec:[G9ImageCore objectFromJSON:json] message:&message] != nil || message == nil)
905
+ [f addObject:[NSString stringWithFormat:@"accepted %@", json]];
906
+ }
907
+ // probe / preview / cancel arguments.
908
+ if ([G9ImageCore validateProbeArguments:[G9ImageCore objectFromJSON:@"{\"path\":\"/a.jpg\"}"] message:NULL] == nil ||
909
+ [G9ImageCore validateProbeArguments:[G9ImageCore objectFromJSON:@"{}"] message:NULL] != nil)
910
+ [f addObject:@"probe arguments"];
911
+ NSDictionary *preview = [G9ImageCore validatePreviewArguments:[G9ImageCore objectFromJSON:@"{\"path\":\"/a.jpg\",\"maxSide\":1080.7,\"dir\":null}"] message:NULL];
912
+ if ([[preview objectForKey:@"maxSide"] integerValue] != 1080 || [preview objectForKey:@"dir"] != nil) [f addObject:@"preview arguments"];
913
+ if ([G9ImageCore validatePreviewArguments:[G9ImageCore objectFromJSON:@"{\"path\":\"/a.jpg\",\"maxSide\":0}"] message:NULL] != nil) [f addObject:@"preview maxSide"];
914
+ if ([G9ImageCore validateCancelArguments:[G9ImageCore objectFromJSON:@"{\"token\":\"\"}"] message:NULL] != nil) [f addObject:@"cancel arguments"];
915
+ // Replies.
916
+ NSDictionary *ok = [G9ImageCore objectFromJSON:[G9ImageCore okReply:[NSDictionary dictionaryWithObject:[NSNull null] forKey:@"quality"]]];
917
+ if (![[ok objectForKey:@"ok"] boolValue] || [[ok objectForKey:@"value"] objectForKey:@"quality"] != [NSNull null]) [f addObject:@"ok reply"];
918
+ NSDictionary *fail = [G9ImageCore objectFromJSON:[G9ImageCore failReply:G9ImageErrorCancelled message:@"stopped"]];
919
+ if ([[fail objectForKey:@"ok"] boolValue] || ![[[fail objectForKey:@"error"] objectForKey:@"code"] isEqualToString:@"cancelled"]) [f addObject:@"fail reply"];
920
+ if (![[G9ImageCore objectFromJSON:[G9ImageCore okReply:nil]] objectForKey:@"value"]) [f addObject:@"empty ok reply"];
921
+ // Metadata: GPS, dates and camera kept, orientation 1, dimensions and the rest dropped.
922
+ NSMutableDictionary *exif = [NSMutableDictionary dictionary];
923
+ [exif setObject:@"2026:11:30 10:00:00" forKey:@"DateTimeOriginal"];
924
+ [exif setObject:[NSNumber numberWithInt:4000] forKey:@"PixelXDimension"];
925
+ [exif setObject:[NSNumber numberWithInt:3000] forKey:@"PixelYDimension"];
926
+ NSMutableDictionary *tiff = [NSMutableDictionary dictionary];
927
+ [tiff setObject:[NSNumber numberWithInt:6] forKey:@"Orientation"];
928
+ [tiff setObject:@"Apple" forKey:@"Make"];
929
+ NSMutableDictionary *source = [NSMutableDictionary dictionary];
930
+ [source setObject:exif forKey:@"{Exif}"];
931
+ [source setObject:tiff forKey:@"{TIFF}"];
932
+ [source setObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithDouble:35.7] forKey:@"Latitude"] forKey:@"{GPS}"];
933
+ [source setObject:[NSDictionary dictionary] forKey:@"{JFIF}"];
934
+ [source setObject:[NSNumber numberWithInt:6] forKey:@"Orientation"];
935
+ [source setObject:[NSNumber numberWithInt:4000] forKey:@"PixelWidth"];
936
+ [source setObject:@"RGB" forKey:@"ColorModel"];
937
+ [source setObject:[NSNumber numberWithInt:72] forKey:@"DPIWidth"];
938
+ NSDictionary *meta = [G9ImageCore outputMetadataFromSourceProperties:source];
939
+ if ([[meta objectForKey:@"Orientation"] intValue] != 1 || [[[meta objectForKey:@"{TIFF}"] objectForKey:@"Orientation"] intValue] != 1) [f addObject:@"meta orientation"];
940
+ if (![[[meta objectForKey:@"{TIFF}"] objectForKey:@"Make"] isEqualToString:@"Apple"]) [f addObject:@"meta camera"];
941
+ if (![[[meta objectForKey:@"{Exif}"] objectForKey:@"DateTimeOriginal"] isEqualToString:@"2026:11:30 10:00:00"]) [f addObject:@"meta date"];
942
+ if ([[meta objectForKey:@"{Exif}"] objectForKey:@"PixelXDimension"] != nil || [meta objectForKey:@"PixelWidth"] != nil) [f addObject:@"meta dimensions"];
943
+ if (!G9Near([[[meta objectForKey:@"{GPS}"] objectForKey:@"Latitude"] doubleValue], 35.7)) [f addObject:@"meta gps"];
944
+ if ([meta objectForKey:@"{JFIF}"] != nil || [meta objectForKey:@"ColorModel"] != nil || [meta objectForKey:@"DPIWidth"] == nil) [f addObject:@"meta others"];
945
+ if ([[exif objectForKey:@"PixelXDimension"] intValue] != 4000 || [[tiff objectForKey:@"Orientation"] intValue] != 6) [f addObject:@"meta source untouched"];
946
+ // The cancel registry.
947
+ G9ImageCancelRegistry *registry = [[G9ImageCancelRegistry alloc] init];
948
+ if ([registry cancel:@"t1"]) [f addObject:@"cancel unknown"];
949
+ [registry begin:@"t1"];
950
+ if ([registry isCancelled:@"t1"] || ![registry cancel:@"t1"] || ![registry isCancelled:@"t1"]) [f addObject:@"cancel pending"];
951
+ [registry end:@"t1"];
952
+ if ([registry isCancelled:@"t1"] || [registry cancel:@"t1"]) [f addObject:@"cancel ended"];
953
+ [registry begin:nil];
954
+ if ([registry cancel:nil] || [registry isCancelled:@""]) [f addObject:@"cancel no token"];
955
+ return f;
956
+ }
957
+
608
958
  @end
@@ -58,6 +58,22 @@
58
58
  XCTAssertEqualObjects([G9NativeTestSuite digitsCore], @[]);
59
59
  }
60
60
 
61
+ - (void)testImageGeometry {
62
+ XCTAssertEqualObjects([G9NativeTestSuite imageGeometry], @[]);
63
+ }
64
+
65
+ - (void)testImageEncoding {
66
+ XCTAssertEqualObjects([G9NativeTestSuite imageEncoding], @[]);
67
+ }
68
+
69
+ - (void)testImageNamesColoursPaths {
70
+ XCTAssertEqualObjects([G9NativeTestSuite imageNamesColoursPaths], @[]);
71
+ }
72
+
73
+ - (void)testImageSpec {
74
+ XCTAssertEqualObjects([G9NativeTestSuite imageSpec], @[]);
75
+ }
76
+
61
77
  // The pod's font bundle is found and registered, and a Persian field's font draws ASCII '5' with the digits font's
62
78
  // glyph while a letter falls back to the field's own font: what `g9-digits` relies on (ledger N-062).
63
79
  - (void)testDigitFontsDrawDigitsAndFallBack {
@@ -6,7 +6,7 @@
6
6
  # same :path. Its version is the family's (npm run check:versions).
7
7
  Pod::Spec.new do |s|
8
8
  s.name = 'g9lynx-native-swift'
9
- s.version = '2.6.19'
9
+ s.version = '2.7.1'
10
10
  s.summary = 'The Swift views of the G9 <g9-richtext>, <g9-canvas> and <g9-blurhash> Lynx elements (UIKit, Core Text).'
11
11
  s.homepage = 'https://github.com/imankari/g9lynxcontrols'
12
12
  s.license = { :type => 'MIT' }
@@ -4,8 +4,8 @@
4
4
  # package version — the family's own LYNX_VERSION (scripts/lynx-version.mjs; npm run check:versions).
5
5
  Pod::Spec.new do |s|
6
6
  s.name = 'g9lynx-native'
7
- s.version = '2.6.19'
8
- s.summary = 'G9 SQLite, host and speech native modules, the <g9-video>, <g9-richtext>, <g9-canvas> and <g9-blurhash> elements and the digit-drawing <input>/<textarea> for Lynx (sqlite3, NSUserDefaults, UIKit, AVFoundation, Speech, Core Text).'
7
+ s.version = '2.7.1'
8
+ s.summary = 'G9 SQLite, host, speech and image native modules, the <g9-video>, <g9-richtext>, <g9-canvas> and <g9-blurhash> elements and the digit-drawing <input>/<textarea> for Lynx (sqlite3, NSUserDefaults, UIKit, AVFoundation, Speech, Core Text, ImageIO, Core Image).'
9
9
  s.homepage = 'https://github.com/imankari/g9lynxcontrols'
10
10
  s.license = { :type => 'MIT' }
11
11
  s.author = 'G9LynxControls'
@@ -22,7 +22,8 @@ Pod::Spec.new do |s|
22
22
  s.libraries = 'sqlite3'
23
23
  # Speech: G9SpeechModule (dictation; the host's Info.plist carries NSSpeechRecognitionUsageDescription).
24
24
  # Core Text: G9InputUI registers the digit fonts.
25
- s.frameworks = 'UIKit', 'AVFoundation', 'Speech', 'CoreText'
25
+ # ImageIO, Core Graphics, Core Image: G9ImageModule (decode, draw, redact, encode; G9PhotoEditor, 2.7.1).
26
+ s.frameworks = 'UIKit', 'AVFoundation', 'Speech', 'CoreText', 'ImageIO', 'CoreGraphics', 'CoreImage'
26
27
  # The digit fonts of `g9-digits` (G9InputUI.m; ios/fonts/build-digit-fonts.py, from Vazirmatn, SIL OFL 1.1 — the
27
28
  # license travels with them).
28
29
  s.resource_bundles = { 'G9LynxNativeFonts' => ['fonts/*.ttf', 'fonts/OFL.txt'] }
@@ -37,7 +38,7 @@ Pod::Spec.new do |s|
37
38
  # golden, interrupt, core edges, preferences and the digits plan (Tests/G9NativeTestSuite.m, also run on Linux by
38
39
  # test:ios-core), plus the UIKit checks: the hit-test patch and the digit fonts.
39
40
  s.test_spec 'Tests' do |t|
40
- t.source_files = 'Tests/G9NativeTestSuite.{h,m}', 'Tests/G9NativeTests.m'
41
+ t.source_files = 'Tests/G9NativeTestSuite.{h,m}', 'Tests/G9NativeTests.m', 'Tests/G9ImageModuleTests.m'
41
42
  t.frameworks = 'XCTest'
42
43
  end
43
44
  end
@@ -28,6 +28,7 @@ static NSDictionary *G9Ok(id value) {
28
28
  @"hapticTick" : NSStringFromSelector(@selector(hapticTick)),
29
29
  @"appDataDirectory" : NSStringFromSelector(@selector(appDataDirectory:)),
30
30
  @"assetUri" : NSStringFromSelector(@selector(assetUri:callback:)),
31
+ @"screenProtection" : NSStringFromSelector(@selector(screenProtection:callback:)),
31
32
  };
32
33
  }
33
34
 
@@ -72,6 +73,15 @@ static NSDictionary *G9Ok(id value) {
72
73
  }
73
74
  }
74
75
 
76
+ // iOS has no switch that blocks a screenshot or a recording (2.7.1, G9Hub 147): `blocked` stays NO and `captured` says
77
+ // whether the screen is being recorded, mirrored or cast now (UIScreen.isCaptured), so the page can cover itself.
78
+ - (void)screenProtection:(BOOL)on callback:(id)callback {
79
+ dispatch_async(dispatch_get_main_queue(), ^{
80
+ BOOL captured = UIScreen.mainScreen.isCaptured;
81
+ ((G9Reply)callback)(G9Ok(@{@"blocked" : @NO, @"captured" : @(captured)}));
82
+ });
83
+ }
84
+
75
85
  static UIWindow *G9KeyWindow(void) {
76
86
  for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) {
77
87
  if (![scene isKindOfClass:[UIWindowScene class]]) continue;
@@ -0,0 +1,30 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <UIKit/UIKit.h>
3
+ #import <Lynx/LynxModule.h>
4
+ #import "generated/G9ImageModuleSpec.h"
5
+
6
+ NS_ASSUME_NONNULL_BEGIN
7
+
8
+ // Hosts register the module on their LynxConfig (the pod does not self-register it)
9
+ // (`[config registerModule:G9ImageModule.class]`, apps/ios-host/Sources/GalleryViewController.m).
10
+
11
+ /**
12
+ * `NativeModules.G9ImageModule` on iOS (2.7.0): probe, preview, process and cancel for G9PhotoEditor and the headless
13
+ * "fit this photo" API (the native contract). Every method takes one JSON string and answers one JSON string
14
+ * (`{"ok":true,"value":…}` / `{"ok":false,"error":{"code","message"}}`) from a serial background queue. ImageIO
15
+ * decodes (subsampled, the orientation applied once), Core Graphics draws in sRGB, Core Image redacts, Core Text sets
16
+ * the text overlays (Persian shaping and RTL), ImageIO encodes (no WebP encoder on iOS: JPEG, and the result says
17
+ * `format: "jpeg"`). The platform-free rules are G9ImageCore. TWIN: G9ImageModule.kt.
18
+ */
19
+ @interface G9ImageModule : NSObject <G9ImageModuleSpec>
20
+
21
+ /**
22
+ * The font of a text overlay whose `font` is empty: the host's text font at a size and a CSS weight (100–900). It is
23
+ * also handed to the Swift elements' `G9LCFonts.textFont` (through `G9LCFontsBridge`), so one call sets the text font
24
+ * of every native element. nil restores the default, the system font.
25
+ */
26
+ + (void)setTextFontProvider:(nullable UIFont * (^)(CGFloat size, CGFloat weight))provider;
27
+
28
+ @end
29
+
30
+ NS_ASSUME_NONNULL_END