simframe 0.4.0 → 0.4.2

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 (2) hide show
  1. package/native/ocr.swift +29 -0
  2. package/package.json +2 -1
@@ -0,0 +1,29 @@
1
+ import Foundation
2
+ import Vision
3
+ import AppKit
4
+
5
+ let args = CommandLine.arguments
6
+ guard args.count > 1, let img = NSImage(contentsOfFile: args[1]),
7
+ let cg = img.cgImage(forProposedRect: nil, context: nil, hints: nil) else {
8
+ FileHandle.standardError.write("cannot read image\n".data(using: .utf8)!); exit(1)
9
+ }
10
+ let req = VNRecognizeTextRequest()
11
+ req.recognitionLevel = .accurate
12
+ req.usesLanguageCorrection = false
13
+ try! VNImageRequestHandler(cgImage: cg, options: [:]).perform([req])
14
+ let w = Double(cg.width), h = Double(cg.height)
15
+ var out: [[String: Any]] = []
16
+ for obs in (req.results ?? []) {
17
+ guard let top = obs.topCandidates(1).first else { continue }
18
+ let b = obs.boundingBox // normalized, origin bottom-left
19
+ out.append([
20
+ "text": top.string,
21
+ "confidence": top.confidence,
22
+ "x": b.origin.x * w,
23
+ "y": (1 - b.origin.y - b.size.height) * h,
24
+ "width": b.size.width * w,
25
+ "height": b.size.height * h,
26
+ ])
27
+ }
28
+ let data = try! JSONSerialization.data(withJSONObject: out)
29
+ FileHandle.standardOutput.write(data)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simframe",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "mcpName": "io.github.lvlrSajjad/simframe",
5
5
  "description": "Always-warm iOS Simulator frames: agents read the screen in ~20ms instead of waiting on screenshots. MCP server + CLI.",
6
6
  "keywords": [
@@ -40,6 +40,7 @@
40
40
  },
41
41
  "files": [
42
42
  "src",
43
+ "native",
43
44
  "README.md",
44
45
  "LICENSE"
45
46
  ],