@smileid/usesmileid_vision_face 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.
Files changed (34) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +33 -1
  3. package/dist/index.d.ts +4 -4
  4. package/dist/index.js +1 -36
  5. package/ios/UseSmileIDVisionFaceExpo.podspec +2 -5
  6. package/ios/UseSmileIDVisionFaceModule/ResizingFrameStorage.swift +1 -1
  7. package/ios/UseSmileIDVisionFaceModule/UseSmileIDVisionFaceKameraAnalysisTick.swift +61 -0
  8. package/ios/UseSmileIDVisionFaceModule/UseSmileIDVisionFaceModule.swift +6 -13
  9. package/package.json +13 -14
  10. package/plugin/build/index.d.ts +10 -1
  11. package/plugin/build/index.js +1 -132
  12. package/plugin/build/lib/deployment_target.js +1 -39
  13. package/plugin/build/lib/podfile.d.ts +15 -0
  14. package/plugin/build/lib/podfile.js +159 -130
  15. package/plugin/build/lib/signature_dedup.d.ts +14 -0
  16. package/plugin/build/lib/signature_dedup.js +2 -0
  17. package/plugin/build/lib/spm.d.ts +21 -0
  18. package/plugin/build/lib/spm.js +1 -196
  19. package/dist/index.d.ts.map +0 -1
  20. package/dist/index.js.map +0 -1
  21. package/ios/UseSmileIDVisionFaceModule/UseSmileIDVisionFaceFrameProcessorPlugin.swift +0 -96
  22. package/plugin/build/index.js.map +0 -1
  23. package/plugin/build/lib/deployment_target.js.map +0 -1
  24. package/plugin/build/lib/podfile.js.map +0 -1
  25. package/plugin/build/lib/spm.js.map +0 -1
  26. package/plugin/src/__tests__/deployment_target.test.ts +0 -41
  27. package/plugin/src/__tests__/podfile.test.ts +0 -136
  28. package/plugin/src/index.ts +0 -116
  29. package/plugin/src/lib/deployment_target.ts +0 -46
  30. package/plugin/src/lib/podfile.ts +0 -254
  31. package/plugin/src/lib/spm.ts +0 -314
  32. package/plugin/tsconfig.json +0 -24
  33. package/src/__tests__/use_smile_id_vision_face.test.ts +0 -79
  34. package/src/index.ts +0 -41
@@ -1,96 +0,0 @@
1
- import CoreMedia
2
- import CoreImage
3
- import UIKit
4
- import VisionCamera
5
-
6
- /// VisionCamera frame processor plugin that feeds camera frames directly
7
- /// into the active `UseSmileIDFaceSession` without crossing the JS thread.
8
- ///
9
- /// Registered programmatically via `FrameProcessorPluginRegistry` (avoids ObjC bridging-header
10
- /// constraint); the `OnCreate` guard prevents double-registration on fast-refresh reloads.
11
- /// All session ops are serialised through `UseSmileIDVisionFaceSessionHolder.operationQueue`.
12
- /// `CIContext` is created once per instance — per-frame creation causes GPU pipeline re-compilation.
13
- @objc(UseSmileIDVisionFaceFrameProcessorPlugin)
14
- public class UseSmileIDVisionFaceFrameProcessorPlugin: FrameProcessorPlugin {
15
-
16
- /// GPU-backed context reused across frames (CPU fallback if Metal unavailable).
17
- private let ciContext = CIContext(options: [.useSoftwareRenderer: false])
18
-
19
- @objc public override init(proxy: VisionCameraProxyHolder, options: [AnyHashable: Any]? = nil) {
20
- super.init(proxy: proxy, options: options)
21
- }
22
-
23
- public override func callback(_ frame: Frame, withArguments arguments: [AnyHashable: Any]?) -> Any? {
24
- guard frame.isValid else {
25
- return ["error": "frame_conversion_failed"]
26
- }
27
-
28
- guard let pixelBuffer = CMSampleBufferGetImageBuffer(frame.buffer) else {
29
- return ["error": "frame_conversion_failed"]
30
- }
31
-
32
- // Bake rotation physically into pixels (CIImage.oriented) rather than
33
- // tagging UIImage with an orientation flag: some consumers honour the flag
34
- // (UIKit draw) but others ignore it (raw CGImage ops), so physical pixels are safer.
35
- // The front camera's mirror is preserved — the analyzer's head-pose
36
- // convention is calibrated on mirrored pixels; un-mirroring flips
37
- // Vision's yaw sign and inverts the ESS head-turn gates.
38
- let orientationFlag = frame.isMirrored
39
- ? frame.orientation.oppositeRotationPreservingMirror()
40
- : frame.orientation
41
- let orientedImage = CIImage(cvPixelBuffer: pixelBuffer)
42
- .oriented(CGImagePropertyOrientation(orientationFlag))
43
-
44
- guard let cgImage = ciContext.createCGImage(orientedImage, from: orientedImage.extent) else {
45
- return ["error": "frame_conversion_failed"]
46
- }
47
-
48
- let rotation = (arguments?["rotation"] as? NSNumber)?.intValue ?? 0
49
- let uiImage = UIImage(cgImage: cgImage)
50
-
51
- guard let result = UseSmileIDVisionFaceSessionHolder.shared.scanAndDrain(
52
- image: uiImage,
53
- rotation: rotation
54
- ) else {
55
- return ["error": "session_not_configured"]
56
- }
57
-
58
- return result
59
- }
60
- }
61
-
62
-
63
- private extension UIImage.Orientation {
64
- /// Rotation-only flag that uprights a MIRRORED buffer while keeping its
65
- /// mirror — flipH ∘ transpose is the opposite 90°, so quarter-turns swap.
66
- /// Device-verified: `.right` ⇒ upright mirrored; raw `.left` ⇒ upside down.
67
- func oppositeRotationPreservingMirror() -> UIImage.Orientation {
68
- switch self {
69
- case .left: return .right
70
- case .right: return .left
71
- case .leftMirrored: return .rightMirrored
72
- case .rightMirrored: return .leftMirrored
73
- default: return self
74
- }
75
- }
76
- }
77
-
78
-
79
- private extension CGImagePropertyOrientation {
80
- /// Case-for-case translation from `UIImage.Orientation` — the two
81
- /// enums share semantics but not raw values, so a direct cast would
82
- /// silently produce the wrong transform.
83
- init(_ uiOrientation: UIImage.Orientation) {
84
- switch uiOrientation {
85
- case .up: self = .up
86
- case .upMirrored: self = .upMirrored
87
- case .down: self = .down
88
- case .downMirrored: self = .downMirrored
89
- case .left: self = .left
90
- case .leftMirrored: self = .leftMirrored
91
- case .right: self = .right
92
- case .rightMirrored: self = .rightMirrored
93
- @unknown default: self = .up
94
- }
95
- }
96
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,iEAAiE;AACjE,0DAA0D;AAC1D,qEAAqE;AACrE,2CAA2C;AAC3C,mEAAmE;AACnE,oEAAoE;AACpE,uEAAuE;AACvE,EAAE;AACF,oDAAoD;AACpD,oEAAoE;AACpE,sEAAsE;AACtE,oEAAoE;AACpE,8BAA8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{ 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,136 +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_face",
29
- package: PACKAGE,
30
- podTarget: "UseSmileIDVisionFaceExpo",
31
- products: ["UseSmileIDVisionFace", "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("# === BEGIN smileid-spm: usesmileid_vision_face");
50
- expect(result).toContain("# === BEGIN smileid-spm: usesmileid_bridge");
51
- expect(result).toContain("target_name = 'UseSmileIDVisionFaceExpo'");
52
- expect(result).toContain("target_name = 'UseSmileIDBridgeExpo'");
53
- });
54
-
55
- it("nests neither block inside the other", () => {
56
- const result = injectBridge(injectProvider(PODFILE));
57
-
58
- const order = [
59
- result.indexOf("# === BEGIN smileid-spm: usesmileid_bridge"),
60
- result.indexOf("# === END smileid-spm: usesmileid_bridge"),
61
- result.indexOf("# === BEGIN smileid-spm: usesmileid_vision_face"),
62
- result.indexOf("# === END smileid-spm: usesmileid_vision_face"),
63
- ];
64
- expect(order.every((index) => index >= 0)).toBe(true);
65
- expect(order[1]).toBeLessThan(order[2]);
66
- });
67
-
68
- it("leaves the React Native post-install call in place", () => {
69
- const result = injectBridge(injectProvider(PODFILE));
70
-
71
- expect(result).toContain("react_native_post_install(");
72
- expect(result.match(/post_install do \|installer\|/g)).toHaveLength(1);
73
- });
74
-
75
- it("is idempotent for both blocks", () => {
76
- const once = injectBridge(injectProvider(PODFILE));
77
-
78
- expect(injectBridge(injectProvider(once))).toBe(once);
79
- });
80
-
81
- it("fails pod install when a required pod target is missing", () => {
82
- const result = injectBridge(PODFILE);
83
-
84
- const bridgeBlock = blockFor(result, "usesmileid_bridge");
85
- expect(bridgeBlock).toContain('raise "[smileid-spm] Pod target');
86
- expect(bridgeBlock).not.toContain("skipping SPM link");
87
- });
88
-
89
- it("only warns when a non-required pod target is missing", () => {
90
- const result = injectProvider(PODFILE);
91
-
92
- const providerBlock = blockFor(result, "usesmileid_vision_face");
93
- expect(providerBlock).toContain("skipping SPM link");
94
- expect(providerBlock).not.toContain('raise "[smileid-spm] Pod target');
95
- });
96
-
97
- it("refuses to inject without a post_install hook to anchor on", () => {
98
- expect(() => injectProvider("target 'sample' do\nend\n")).toThrow(
99
- /post_install/,
100
- );
101
- });
102
-
103
- it("rejects a pod target that could break out of the Ruby literal", () => {
104
- expect(() =>
105
- injectPodfileSpmBlock(PODFILE, {
106
- marker: "usesmileid_bridge",
107
- package: PACKAGE,
108
- podTarget: "Bridge'; system('rm -rf /') #",
109
- products: ["UseSmileIDBridge"],
110
- }),
111
- ).toThrow(/unsafe character/);
112
- });
113
-
114
- // The diagnostics are double-quoted Ruby, where `#{...}` evaluates.
115
- it.each([
116
- ["interpolation", "Bridge#{`rm -rf /`}"],
117
- ["double quote", 'Bridge"'],
118
- ])("rejects a pod target carrying a Ruby %s", (_label, podTarget) => {
119
- expect(() =>
120
- injectPodfileSpmBlock(PODFILE, {
121
- marker: "usesmileid_bridge",
122
- package: PACKAGE,
123
- podTarget,
124
- products: ["UseSmileIDBridge"],
125
- }),
126
- ).toThrow(/unsafe character/);
127
- });
128
- });
129
-
130
- function blockFor(podfile: string, marker: string): string {
131
- const begin = podfile.indexOf(`# === BEGIN smileid-spm: ${marker} ===`);
132
- const end = podfile.indexOf(`# === END smileid-spm: ${marker} ===`);
133
- expect(begin).toBeGreaterThanOrEqual(0);
134
- expect(end).toBeGreaterThan(begin);
135
- return podfile.slice(begin, end);
136
- }
@@ -1,116 +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 (`UseSmileIDVisionFaceExpo`) compiles
7
- // with `import UseSmileIDVisionFace` / `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 = "UseSmileIDVisionFaceExpo";
43
- // `UseSmileIDBridge` is also listed explicitly even though the Vision
44
- // library product wraps it as a transitive target — empirically this
45
- // is what makes `import UseSmileIDBridge` resolve in the bridge under
46
- // SPM-via-CocoaPods. A cleaner config that drops the redundant
47
- // listing is plausible (the SPM Package.swift declares
48
- // `targets: ["UseSmileIDVisionFace", "UseSmileIDBridge"]` for the Vision
49
- // library product) but unverified, and the duplicate produces only a
50
- // benign "Conflicting parseable interfaces" warning at link time.
51
- const SPM_PRODUCTS = ["UseSmileIDVisionFace", "UseSmileIDBridge"] as const;
52
- const PODFILE_MARKER = "usesmileid_vision_face";
53
-
54
- // Nothing else links the bridge's own pod target, so without this block its
55
- // `import UseSmileIDBridge` fails. Both vision plugins emit it; the injection is
56
- // idempotent per marker, so installing both is harmless.
57
- const BRIDGE_POD_TARGET = "UseSmileIDBridgeExpo";
58
- const BRIDGE_SPM_PRODUCTS = ["UseSmileIDBridge"] as const;
59
- const BRIDGE_PODFILE_MARKER = "usesmileid_bridge";
60
-
61
- const withVisionFaceSpm: ConfigPlugin = (config) => {
62
- config = withIosDeploymentTargetFloor(config, IOS_DEPLOYMENT_TARGET);
63
-
64
- // 1. Add the package + products to the host app's Xcode project so
65
- // Xcode resolves the binary xcframeworks and embeds them in the
66
- // .app at link time.
67
- config = withXcodeProject(config, (config) => {
68
- const appTarget = config.modRequest.projectName;
69
- if (!appTarget) {
70
- throw new Error(
71
- "[usesmileid_vision_face] Unable to resolve host app native target name from Expo config.",
72
- );
73
- }
74
- linkSpmPackage(config.modResults, SMILE_ID_PACKAGE, {
75
- targetName: appTarget,
76
- products: [...SPM_PRODUCTS],
77
- });
78
- return config;
79
- });
80
-
81
- // 2. Inject a Ruby block into the Podfile's post_install hook that
82
- // re-applies the same wiring to Pods.xcodeproj when CocoaPods
83
- // materializes it. The bridge pod target needs the products
84
- // visible at compile time; the host-app step alone isn't enough.
85
- config = withDangerousMod(config, [
86
- "ios",
87
- (config) => {
88
- const podfilePath = path.join(
89
- config.modRequest.platformProjectRoot,
90
- "Podfile",
91
- );
92
- const original = fs.readFileSync(podfilePath, "utf-8");
93
- let next = injectPodfileSpmBlock(original, {
94
- marker: PODFILE_MARKER,
95
- package: SMILE_ID_PACKAGE,
96
- podTarget: POD_TARGET,
97
- products: [...SPM_PRODUCTS],
98
- });
99
- next = injectPodfileSpmBlock(next, {
100
- marker: BRIDGE_PODFILE_MARKER,
101
- package: SMILE_ID_PACKAGE,
102
- podTarget: BRIDGE_POD_TARGET,
103
- products: [...BRIDGE_SPM_PRODUCTS],
104
- required: true,
105
- });
106
- if (next !== original) {
107
- fs.writeFileSync(podfilePath, next);
108
- }
109
- return config;
110
- },
111
- ]);
112
-
113
- return config;
114
- };
115
-
116
- export default withVisionFaceSpm;
@@ -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
- }