@smileid/usesmileid_vision_document 12.0.2 → 12.1.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.
- package/CHANGELOG.md +12 -0
- package/README.md +33 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -34
- package/ios/UseSmileIDVisionDocumentExpo.podspec +2 -5
- package/ios/UseSmileIDVisionDocumentModule/ResizingFrameStorage.swift +1 -1
- package/ios/UseSmileIDVisionDocumentModule/UseSmileIDVisionDocumentKameraAnalysisTick.swift +80 -0
- package/ios/UseSmileIDVisionDocumentModule/UseSmileIDVisionDocumentModule.swift +9 -14
- package/package.json +13 -14
- package/plugin/build/index.d.ts +10 -1
- package/plugin/build/index.js +1 -124
- package/plugin/build/lib/deployment_target.js +1 -39
- package/plugin/build/lib/podfile.d.ts +15 -0
- package/plugin/build/lib/podfile.js +159 -130
- package/plugin/build/lib/signature_dedup.d.ts +14 -0
- package/plugin/build/lib/signature_dedup.js +2 -0
- package/plugin/build/lib/spm.d.ts +21 -0
- package/plugin/build/lib/spm.js +1 -196
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/ios/UseSmileIDVisionDocumentModule/UseSmileIDVisionDocumentFrameProcessorPlugin.swift +0 -149
- package/plugin/build/index.js.map +0 -1
- package/plugin/build/lib/deployment_target.js.map +0 -1
- package/plugin/build/lib/podfile.js.map +0 -1
- package/plugin/build/lib/spm.js.map +0 -1
- package/plugin/src/__tests__/deployment_target.test.ts +0 -41
- package/plugin/src/__tests__/podfile.test.ts +0 -138
- package/plugin/src/index.ts +0 -108
- package/plugin/src/lib/deployment_target.ts +0 -46
- package/plugin/src/lib/podfile.ts +0 -254
- package/plugin/src/lib/spm.ts +0 -314
- package/plugin/tsconfig.json +0 -24
- package/src/__tests__/use_smile_id_vision_document.test.ts +0 -79
- package/src/index.ts +0 -42
package/ios/UseSmileIDVisionDocumentModule/UseSmileIDVisionDocumentFrameProcessorPlugin.swift
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import CoreMedia
|
|
2
|
-
import CoreImage
|
|
3
|
-
import UIKit
|
|
4
|
-
import UseSmileIDBridge
|
|
5
|
-
import VisionCamera
|
|
6
|
-
|
|
7
|
-
/// VisionCamera frame processor that feeds camera frames into the active
|
|
8
|
-
/// `UseSmileIDDocumentSession` without crossing the JS thread. Session ops
|
|
9
|
-
/// serialise through `UseSmileIDVisionDocumentSessionHolder.operationQueue`;
|
|
10
|
-
/// the `CIContext` is reused across frames (per-frame creation re-compiles the
|
|
11
|
-
/// GPU pipeline).
|
|
12
|
-
@objc(UseSmileIDVisionDocumentFrameProcessorPlugin)
|
|
13
|
-
public class UseSmileIDVisionDocumentFrameProcessorPlugin: FrameProcessorPlugin {
|
|
14
|
-
|
|
15
|
-
/// GPU-backed context reused across frames (CPU fallback if Metal unavailable).
|
|
16
|
-
private let ciContext = CIContext(options: [.useSoftwareRenderer: false])
|
|
17
|
-
|
|
18
|
-
@objc public override init(proxy: VisionCameraProxyHolder, options: [AnyHashable: Any]? = nil) {
|
|
19
|
-
super.init(proxy: proxy, options: options)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public override func callback(_ frame: Frame, withArguments arguments: [AnyHashable: Any]?) -> Any? {
|
|
23
|
-
guard frame.isValid else {
|
|
24
|
-
return ["error": "frame_conversion_failed"]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
guard let pixelBuffer = CMSampleBufferGetImageBuffer(frame.buffer) else {
|
|
28
|
-
return ["error": "frame_conversion_failed"]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Bake rotation + mirror into the pixels (CIImage.oriented) rather than an
|
|
32
|
-
// EXIF flag — some consumers ignore the flag. `frame.orientation` only
|
|
33
|
-
// uprights to the sensor-natural (portrait) axis; the document screen
|
|
34
|
-
// force-locks the interface, so we additionally rotate onto that LOCKED
|
|
35
|
-
// INTERFACE axis so the saved JPEG matches the preview and the guide-rect
|
|
36
|
-
// crop. `viewportOrientation` is the interface orientation in degrees
|
|
37
|
-
// (0/90/270); each maps to a device-verified rotation in
|
|
38
|
-
// `rotatedOntoViewportAxis` — including the portrait (0°) half-turn.
|
|
39
|
-
let orientationFlag = frame.isMirrored
|
|
40
|
-
? frame.orientation.composedWithHorizontalMirror()
|
|
41
|
-
: frame.orientation
|
|
42
|
-
let viewportOrientation = (arguments?["viewportOrientation"] as? NSNumber)?.intValue ?? 0
|
|
43
|
-
let orientedImage = CIImage(cvPixelBuffer: pixelBuffer)
|
|
44
|
-
.oriented(CGImagePropertyOrientation(orientationFlag))
|
|
45
|
-
.rotatedOntoViewportAxis(degrees: viewportOrientation)
|
|
46
|
-
|
|
47
|
-
guard let cgImage = ciContext.createCGImage(orientedImage, from: orientedImage.extent) else {
|
|
48
|
-
return ["error": "frame_conversion_failed"]
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let rotation = (arguments?["rotation"] as? NSNumber)?.intValue ?? 0
|
|
52
|
-
let uiImage = UIImage(cgImage: cgImage)
|
|
53
|
-
|
|
54
|
-
// Forward the on-screen document guide rectangle (if JS supplied it) so the
|
|
55
|
-
// saved capture is cropped to exactly what the user framed. Set before the
|
|
56
|
-
// scan so the storage holds the region when this frame's `persist` runs.
|
|
57
|
-
// Both calls serialise through the holder's operation queue, so the region
|
|
58
|
-
// is stable for the duration of this frame's scan.
|
|
59
|
-
UseSmileIDVisionDocumentSessionHolder.shared.setCropRegion(cropRegionFrom(arguments))
|
|
60
|
-
|
|
61
|
-
guard let result = UseSmileIDVisionDocumentSessionHolder.shared.scanAndDrain(
|
|
62
|
-
image: uiImage,
|
|
63
|
-
rotation: rotation
|
|
64
|
-
) else {
|
|
65
|
-
return ["error": "session_not_configured"]
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return result
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/// Build the `ViewportCropRegion` from the flat numeric crop args the JS
|
|
72
|
-
/// worklet supplies. Returns `nil` when `cropWidth <= 0` (the "no region"
|
|
73
|
-
/// signal for selfie / before the viewport is measured). Flat primitives
|
|
74
|
-
/// because frame-processor arguments don't reliably accept nested objects.
|
|
75
|
-
private func cropRegionFrom(_ arguments: [AnyHashable: Any]?) -> ViewportCropRegion? {
|
|
76
|
-
guard let width = (arguments?["cropWidth"] as? NSNumber)?.floatValue, width > 0 else {
|
|
77
|
-
return nil
|
|
78
|
-
}
|
|
79
|
-
return ViewportCropRegion(
|
|
80
|
-
left: (arguments?["cropLeft"] as? NSNumber)?.floatValue ?? 0,
|
|
81
|
-
top: (arguments?["cropTop"] as? NSNumber)?.floatValue ?? 0,
|
|
82
|
-
width: width,
|
|
83
|
-
height: (arguments?["cropHeight"] as? NSNumber)?.floatValue ?? 0,
|
|
84
|
-
viewportWidthPx: (arguments?["cropViewportWidth"] as? NSNumber)?.intValue ?? 0,
|
|
85
|
-
viewportHeightPx: (arguments?["cropViewportHeight"] as? NSNumber)?.intValue ?? 0,
|
|
86
|
-
contentScale: .crop
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
private extension UIImage.Orientation {
|
|
93
|
-
/// Fold the buffer's horizontal mirror into this orientation so rendering
|
|
94
|
-
/// undoes the flip with the rotation (.left ↔ .leftMirrored, etc.).
|
|
95
|
-
func composedWithHorizontalMirror() -> UIImage.Orientation {
|
|
96
|
-
switch self {
|
|
97
|
-
case .up: return .upMirrored
|
|
98
|
-
case .upMirrored: return .up
|
|
99
|
-
case .down: return .downMirrored
|
|
100
|
-
case .downMirrored: return .down
|
|
101
|
-
case .left: return .leftMirrored
|
|
102
|
-
case .leftMirrored: return .left
|
|
103
|
-
case .right: return .rightMirrored
|
|
104
|
-
case .rightMirrored: return .right
|
|
105
|
-
@unknown default: return self
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
private extension CIImage {
|
|
112
|
-
/// Rotate the sensor-natural (portrait) image onto the locked interface
|
|
113
|
-
/// (viewport) axis so the guide-rect crop lands on the right pixels and the
|
|
114
|
-
/// preview matches the capture. `degrees` is the interface orientation
|
|
115
|
-
/// (0/90/270). Directions are device-verified on iPhone — the opposite
|
|
116
|
-
/// assignment lands the document upside down.
|
|
117
|
-
func rotatedOntoViewportAxis(degrees: Int) -> CIImage {
|
|
118
|
-
let normalized = ((degrees % 360) + 360) % 360
|
|
119
|
-
switch normalized {
|
|
120
|
-
// Portrait document (0° interface): the rear camera's sensor-natural upright
|
|
121
|
-
// sits 180° from the portrait interface — the phone is held flat over the
|
|
122
|
-
// document — so the saved portrait document needs a half-turn. The guide
|
|
123
|
-
// rect is centred, so the half-turn leaves the crop aligned.
|
|
124
|
-
case 0: return oriented(.down)
|
|
125
|
-
case 90: return oriented(.left)
|
|
126
|
-
case 270: return oriented(.right)
|
|
127
|
-
default: return self
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private extension CGImagePropertyOrientation {
|
|
133
|
-
/// Case-for-case translation from `UIImage.Orientation` — the two
|
|
134
|
-
/// enums share semantics but not raw values, so a direct cast would
|
|
135
|
-
/// silently produce the wrong transform.
|
|
136
|
-
init(_ uiOrientation: UIImage.Orientation) {
|
|
137
|
-
switch uiOrientation {
|
|
138
|
-
case .up: self = .up
|
|
139
|
-
case .upMirrored: self = .upMirrored
|
|
140
|
-
case .down: self = .down
|
|
141
|
-
case .downMirrored: self = .downMirrored
|
|
142
|
-
case .left: self = .left
|
|
143
|
-
case .leftMirrored: self = .leftMirrored
|
|
144
|
-
case .right: self = .right
|
|
145
|
-
case .rightMirrored: self = .rightMirrored
|
|
146
|
-
@unknown default: self = .up
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,iEAAiE;AACjE,0DAA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C,IAAI,GAAG,CAAC;AAC3B,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { raiseDeploymentTarget } from "../lib/deployment_target";
|
|
4
|
-
|
|
5
|
-
describe("raiseDeploymentTarget", () => {
|
|
6
|
-
it("sets the floor when the project declares nothing", () => {
|
|
7
|
-
expect(raiseDeploymentTarget({}, "16.4")).toEqual({
|
|
8
|
-
"ios.deploymentTarget": "16.4",
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("raises a target below the floor", () => {
|
|
13
|
-
expect(
|
|
14
|
-
raiseDeploymentTarget({ "ios.deploymentTarget": "15.0" }, "16.4"),
|
|
15
|
-
).toEqual({ "ios.deploymentTarget": "16.4" });
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("leaves a higher target the partner chose alone", () => {
|
|
19
|
-
expect(
|
|
20
|
-
raiseDeploymentTarget({ "ios.deploymentTarget": "18.0" }, "16.4"),
|
|
21
|
-
).toEqual({ "ios.deploymentTarget": "18.0" });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("compares components numerically rather than as text", () => {
|
|
25
|
-
expect(
|
|
26
|
-
raiseDeploymentTarget({ "ios.deploymentTarget": "16.10" }, "16.4"),
|
|
27
|
-
).toEqual({ "ios.deploymentTarget": "16.10" });
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("overwrites a value it cannot parse", () => {
|
|
31
|
-
expect(
|
|
32
|
-
raiseDeploymentTarget({ "ios.deploymentTarget": "latest" }, "16.4"),
|
|
33
|
-
).toEqual({ "ios.deploymentTarget": "16.4" });
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("preserves unrelated Podfile properties", () => {
|
|
37
|
-
expect(
|
|
38
|
-
raiseDeploymentTarget({ "expo.jsEngine": "hermes" }, "16.4"),
|
|
39
|
-
).toEqual({ "expo.jsEngine": "hermes", "ios.deploymentTarget": "16.4" });
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { injectPodfileSpmBlock } from "../lib/podfile";
|
|
4
|
-
import type { SpmPackage } from "../lib/spm";
|
|
5
|
-
|
|
6
|
-
const PACKAGE: SpmPackage = {
|
|
7
|
-
url: "https://github.com/smileidentity/ios-spm",
|
|
8
|
-
requirement: { kind: "exactVersion", version: "12.0.1" },
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const PODFILE = `platform :ios, podfile_properties['ios.deploymentTarget']
|
|
12
|
-
|
|
13
|
-
target 'sample' do
|
|
14
|
-
use_expo_modules!
|
|
15
|
-
config = use_native_modules!
|
|
16
|
-
|
|
17
|
-
post_install do |installer|
|
|
18
|
-
react_native_post_install(
|
|
19
|
-
installer,
|
|
20
|
-
config[:reactNativePath],
|
|
21
|
-
)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
function injectProvider(podfile: string): string {
|
|
27
|
-
return injectPodfileSpmBlock(podfile, {
|
|
28
|
-
marker: "usesmileid_vision_document",
|
|
29
|
-
package: PACKAGE,
|
|
30
|
-
podTarget: "UseSmileIDVisionDocumentExpo",
|
|
31
|
-
products: ["UseSmileIDVisionDocument", "UseSmileIDBridge"],
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function injectBridge(podfile: string): string {
|
|
36
|
-
return injectPodfileSpmBlock(podfile, {
|
|
37
|
-
marker: "usesmileid_bridge",
|
|
38
|
-
package: PACKAGE,
|
|
39
|
-
podTarget: "UseSmileIDBridgeExpo",
|
|
40
|
-
products: ["UseSmileIDBridge"],
|
|
41
|
-
required: true,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
describe("injectPodfileSpmBlock", () => {
|
|
46
|
-
it("keeps the provider and bridge blocks as two separate regions", () => {
|
|
47
|
-
const result = injectBridge(injectProvider(PODFILE));
|
|
48
|
-
|
|
49
|
-
expect(result).toContain(
|
|
50
|
-
"# === BEGIN smileid-spm: usesmileid_vision_document",
|
|
51
|
-
);
|
|
52
|
-
expect(result).toContain("# === BEGIN smileid-spm: usesmileid_bridge");
|
|
53
|
-
expect(result).toContain("target_name = 'UseSmileIDVisionDocumentExpo'");
|
|
54
|
-
expect(result).toContain("target_name = 'UseSmileIDBridgeExpo'");
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("nests neither block inside the other", () => {
|
|
58
|
-
const result = injectBridge(injectProvider(PODFILE));
|
|
59
|
-
|
|
60
|
-
const order = [
|
|
61
|
-
result.indexOf("# === BEGIN smileid-spm: usesmileid_bridge"),
|
|
62
|
-
result.indexOf("# === END smileid-spm: usesmileid_bridge"),
|
|
63
|
-
result.indexOf("# === BEGIN smileid-spm: usesmileid_vision_document"),
|
|
64
|
-
result.indexOf("# === END smileid-spm: usesmileid_vision_document"),
|
|
65
|
-
];
|
|
66
|
-
expect(order.every((index) => index >= 0)).toBe(true);
|
|
67
|
-
expect(order[1]).toBeLessThan(order[2]);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("leaves the React Native post-install call in place", () => {
|
|
71
|
-
const result = injectBridge(injectProvider(PODFILE));
|
|
72
|
-
|
|
73
|
-
expect(result).toContain("react_native_post_install(");
|
|
74
|
-
expect(result.match(/post_install do \|installer\|/g)).toHaveLength(1);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("is idempotent for both blocks", () => {
|
|
78
|
-
const once = injectBridge(injectProvider(PODFILE));
|
|
79
|
-
|
|
80
|
-
expect(injectBridge(injectProvider(once))).toBe(once);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("fails pod install when a required pod target is missing", () => {
|
|
84
|
-
const result = injectBridge(PODFILE);
|
|
85
|
-
|
|
86
|
-
const bridgeBlock = blockFor(result, "usesmileid_bridge");
|
|
87
|
-
expect(bridgeBlock).toContain('raise "[smileid-spm] Pod target');
|
|
88
|
-
expect(bridgeBlock).not.toContain("skipping SPM link");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("only warns when a non-required pod target is missing", () => {
|
|
92
|
-
const result = injectProvider(PODFILE);
|
|
93
|
-
|
|
94
|
-
const providerBlock = blockFor(result, "usesmileid_vision_document");
|
|
95
|
-
expect(providerBlock).toContain("skipping SPM link");
|
|
96
|
-
expect(providerBlock).not.toContain('raise "[smileid-spm] Pod target');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("refuses to inject without a post_install hook to anchor on", () => {
|
|
100
|
-
expect(() => injectProvider("target 'sample' do\nend\n")).toThrow(
|
|
101
|
-
/post_install/,
|
|
102
|
-
);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("rejects a pod target that could break out of the Ruby literal", () => {
|
|
106
|
-
expect(() =>
|
|
107
|
-
injectPodfileSpmBlock(PODFILE, {
|
|
108
|
-
marker: "usesmileid_bridge",
|
|
109
|
-
package: PACKAGE,
|
|
110
|
-
podTarget: "Bridge'; system('rm -rf /') #",
|
|
111
|
-
products: ["UseSmileIDBridge"],
|
|
112
|
-
}),
|
|
113
|
-
).toThrow(/unsafe character/);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// The diagnostics are double-quoted Ruby, where `#{...}` evaluates.
|
|
117
|
-
it.each([
|
|
118
|
-
["interpolation", "Bridge#{`rm -rf /`}"],
|
|
119
|
-
["double quote", 'Bridge"'],
|
|
120
|
-
])("rejects a pod target carrying a Ruby %s", (_label, podTarget) => {
|
|
121
|
-
expect(() =>
|
|
122
|
-
injectPodfileSpmBlock(PODFILE, {
|
|
123
|
-
marker: "usesmileid_bridge",
|
|
124
|
-
package: PACKAGE,
|
|
125
|
-
podTarget,
|
|
126
|
-
products: ["UseSmileIDBridge"],
|
|
127
|
-
}),
|
|
128
|
-
).toThrow(/unsafe character/);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
function blockFor(podfile: string, marker: string): string {
|
|
133
|
-
const begin = podfile.indexOf(`# === BEGIN smileid-spm: ${marker} ===`);
|
|
134
|
-
const end = podfile.indexOf(`# === END smileid-spm: ${marker} ===`);
|
|
135
|
-
expect(begin).toBeGreaterThanOrEqual(0);
|
|
136
|
-
expect(end).toBeGreaterThan(begin);
|
|
137
|
-
return podfile.slice(begin, end);
|
|
138
|
-
}
|
package/plugin/src/index.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
// Expo config plugin that wires the Smile Identity Swift Package
|
|
2
|
-
// (`https://github.com/smileidentity/ios-spm`) into both:
|
|
3
|
-
// 1. The consuming app's Xcode project — so the .xcframeworks ship
|
|
4
|
-
// and embed in the final .app bundle.
|
|
5
|
-
// 2. The autogenerated Pods.xcodeproj at `pod install` time — so
|
|
6
|
-
// the Expo Module bridge (`UseSmileIDVisionDocumentExpo`) compiles
|
|
7
|
-
// with `import UseSmileIDVisionDocument` / `import UseSmileIDBridge`.
|
|
8
|
-
//
|
|
9
|
-
// Why a plugin: `expo-modules-autolinking@55.0.x`'s
|
|
10
|
-
// `RawModuleConfigApple` schema has no `dependencies` field, so the
|
|
11
|
-
// `apple.dependencies` block in `expo-module.config.json` is silently
|
|
12
|
-
// ignored. Without this plugin, neither the bridge nor the host app
|
|
13
|
-
// know about the SPM package.
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
ConfigPlugin,
|
|
17
|
-
withDangerousMod,
|
|
18
|
-
withXcodeProject,
|
|
19
|
-
} from "expo/config-plugins";
|
|
20
|
-
import * as fs from "fs";
|
|
21
|
-
import * as path from "path";
|
|
22
|
-
|
|
23
|
-
import { withIosDeploymentTargetFloor } from "./lib/deployment_target";
|
|
24
|
-
import { injectPodfileSpmBlock } from "./lib/podfile";
|
|
25
|
-
import { linkSpmPackage, SpmPackage } from "./lib/spm";
|
|
26
|
-
|
|
27
|
-
// The lowest the Expo iOS template and the pods alongside it still compile at.
|
|
28
|
-
const IOS_DEPLOYMENT_TARGET = "16.4";
|
|
29
|
-
|
|
30
|
-
// Pinned to the exact `12.0.0` release tag — `from: 12.0.0`
|
|
31
|
-
// would not resolve because `ios-spm` publishes pre-release tags (e.g.
|
|
32
|
-
// `12.0.0`), and SPM excludes pre-release tags from open-ended
|
|
33
|
-
// major-version requirements.
|
|
34
|
-
const SMILE_ID_PACKAGE: SpmPackage = {
|
|
35
|
-
url: "https://github.com/smileidentity/ios-spm",
|
|
36
|
-
requirement: {
|
|
37
|
-
kind: "exactVersion",
|
|
38
|
-
version: "12.0.2",
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const POD_TARGET = "UseSmileIDVisionDocumentExpo";
|
|
43
|
-
const SPM_PRODUCTS = ["UseSmileIDVisionDocument", "UseSmileIDBridge"] as const;
|
|
44
|
-
const PODFILE_MARKER = "usesmileid_vision_document";
|
|
45
|
-
|
|
46
|
-
// Nothing else links the bridge's own pod target, so without this block its
|
|
47
|
-
// `import UseSmileIDBridge` fails. Both vision plugins emit it; the injection is
|
|
48
|
-
// idempotent per marker, so installing both is harmless.
|
|
49
|
-
const BRIDGE_POD_TARGET = "UseSmileIDBridgeExpo";
|
|
50
|
-
const BRIDGE_SPM_PRODUCTS = ["UseSmileIDBridge"] as const;
|
|
51
|
-
const BRIDGE_PODFILE_MARKER = "usesmileid_bridge";
|
|
52
|
-
|
|
53
|
-
const withVisionDocumentSpm: ConfigPlugin = (config) => {
|
|
54
|
-
config = withIosDeploymentTargetFloor(config, IOS_DEPLOYMENT_TARGET);
|
|
55
|
-
|
|
56
|
-
// 1. Add the package + products to the host app's Xcode project so
|
|
57
|
-
// Xcode resolves the binary xcframeworks and embeds them in the
|
|
58
|
-
// .app at link time.
|
|
59
|
-
config = withXcodeProject(config, (config) => {
|
|
60
|
-
const appTarget = config.modRequest.projectName;
|
|
61
|
-
if (!appTarget) {
|
|
62
|
-
throw new Error(
|
|
63
|
-
"[usesmileid_vision_document] Unable to resolve host app native target name from Expo config.",
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
linkSpmPackage(config.modResults, SMILE_ID_PACKAGE, {
|
|
67
|
-
targetName: appTarget,
|
|
68
|
-
products: [...SPM_PRODUCTS],
|
|
69
|
-
});
|
|
70
|
-
return config;
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// 2. Inject a Ruby block into the Podfile's post_install hook that
|
|
74
|
-
// re-applies the same wiring to Pods.xcodeproj when CocoaPods
|
|
75
|
-
// materializes it. The bridge pod target needs the products
|
|
76
|
-
// visible at compile time; the host-app step alone isn't enough.
|
|
77
|
-
config = withDangerousMod(config, [
|
|
78
|
-
"ios",
|
|
79
|
-
(config) => {
|
|
80
|
-
const podfilePath = path.join(
|
|
81
|
-
config.modRequest.platformProjectRoot,
|
|
82
|
-
"Podfile",
|
|
83
|
-
);
|
|
84
|
-
const original = fs.readFileSync(podfilePath, "utf-8");
|
|
85
|
-
let next = injectPodfileSpmBlock(original, {
|
|
86
|
-
marker: PODFILE_MARKER,
|
|
87
|
-
package: SMILE_ID_PACKAGE,
|
|
88
|
-
podTarget: POD_TARGET,
|
|
89
|
-
products: [...SPM_PRODUCTS],
|
|
90
|
-
});
|
|
91
|
-
next = injectPodfileSpmBlock(next, {
|
|
92
|
-
marker: BRIDGE_PODFILE_MARKER,
|
|
93
|
-
package: SMILE_ID_PACKAGE,
|
|
94
|
-
podTarget: BRIDGE_POD_TARGET,
|
|
95
|
-
products: [...BRIDGE_SPM_PRODUCTS],
|
|
96
|
-
required: true,
|
|
97
|
-
});
|
|
98
|
-
if (next !== original) {
|
|
99
|
-
fs.writeFileSync(podfilePath, next);
|
|
100
|
-
}
|
|
101
|
-
return config;
|
|
102
|
-
},
|
|
103
|
-
]);
|
|
104
|
-
|
|
105
|
-
return config;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export default withVisionDocumentSpm;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// The Podfile prebuild generates reads `ios.deploymentTarget` from
|
|
2
|
-
// `ios/Podfile.properties.json`, which nothing the SDK publishes used to set.
|
|
3
|
-
|
|
4
|
-
import { type ConfigPlugin, withPodfileProperties } from "expo/config-plugins";
|
|
5
|
-
|
|
6
|
-
/** Sets `ios.deploymentTarget` to `minimum` unless the project already asks for a higher one. */
|
|
7
|
-
export const withIosDeploymentTargetFloor: ConfigPlugin<string> = (
|
|
8
|
-
config,
|
|
9
|
-
minimum,
|
|
10
|
-
) =>
|
|
11
|
-
withPodfileProperties(config, (config) => {
|
|
12
|
-
config.modResults = raiseDeploymentTarget(config.modResults, minimum);
|
|
13
|
-
return config;
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
/** Pure form of the edit the plugin makes to the Podfile properties. */
|
|
17
|
-
export function raiseDeploymentTarget(
|
|
18
|
-
properties: Readonly<Record<string, string>>,
|
|
19
|
-
minimum: string,
|
|
20
|
-
): Record<string, string> {
|
|
21
|
-
const current = properties["ios.deploymentTarget"];
|
|
22
|
-
if (current !== undefined && compareVersions(current, minimum) >= 0) {
|
|
23
|
-
return { ...properties };
|
|
24
|
-
}
|
|
25
|
-
return { ...properties, "ios.deploymentTarget": minimum };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// An unparseable component sorts as 0 so a bad value in a partner's project is
|
|
29
|
-
// overwritten rather than crashing prebuild.
|
|
30
|
-
function compareVersions(left: string, right: string): number {
|
|
31
|
-
const leftParts = left.split(".");
|
|
32
|
-
const rightParts = right.split(".");
|
|
33
|
-
for (let i = 0; i < Math.max(leftParts.length, rightParts.length); i++) {
|
|
34
|
-
const difference =
|
|
35
|
-
toNumber(leftParts[i] ?? "0") - toNumber(rightParts[i] ?? "0");
|
|
36
|
-
if (difference !== 0) {
|
|
37
|
-
return difference;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function toNumber(part: string): number {
|
|
44
|
-
const parsed = Number.parseInt(part, 10);
|
|
45
|
-
return Number.isNaN(parsed) ? 0 : parsed;
|
|
46
|
-
}
|