@capgo/capacitor-llm 8.0.10 → 8.0.11

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.
@@ -11,7 +11,15 @@ Pod::Spec.new do |s|
11
11
  s.author = package['author']
12
12
  s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
13
  s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.platform = :ios, '15.0'
14
15
  s.ios.deployment_target = '15.0'
16
+ s.pod_target_xcconfig = {
17
+ 'SUPPORTS_MACCATALYST' => 'NO',
18
+ 'EXCLUDED_ARCHS[sdk=macosx*]' => 'arm64 x86_64'
19
+ }
20
+ s.user_target_xcconfig = {
21
+ 'EXCLUDED_ARCHS[sdk=macosx*]' => 'arm64 x86_64'
22
+ }
15
23
  s.dependency 'Capacitor'
16
24
  s.dependency 'MediaPipeTasksGenAI'
17
25
  s.dependency 'MediaPipeTasksGenAIC'
package/README.md CHANGED
@@ -11,6 +11,8 @@ Adds support for LLM locally run for Capacitor
11
11
 
12
12
  It uses Apple Intelligence (default) or MediaPipe custom models on iOS, and MediaPipe's tasks-genai on Android
13
13
 
14
+ **Mac Catalyst:** Native iOS functionality is disabled for Mac Catalyst builds. MediaPipe pods are skipped and native calls will return an unsupported response; use an iOS/iPadOS target for native features.
15
+
14
16
  ## Documentation
15
17
 
16
18
  The most complete doc is available here: https://capgo.app/docs/plugins/llm/
@@ -9,7 +9,7 @@ import com.getcapacitor.annotation.CapacitorPlugin;
9
9
  @CapacitorPlugin(name = "CapgoLLM")
10
10
  public class LLMPlugin extends Plugin {
11
11
 
12
- private final String pluginVersion = "8.0.10";
12
+ private final String pluginVersion = "8.0.11";
13
13
 
14
14
  private LLM llm;
15
15
 
@@ -5,7 +5,7 @@ import FoundationModels
5
5
  #endif
6
6
  // For CocoaPods, MediaPipeTasksGenAI should always be available
7
7
  // For SPM, we need conditional import when SPM support is added
8
- #if canImport(MediaPipeTasksGenAI)
8
+ #if canImport(MediaPipeTasksGenAI) && !targetEnvironment(macCatalyst)
9
9
  import MediaPipeTasksGenAI
10
10
  #endif
11
11
 
@@ -16,7 +16,10 @@ import MediaPipeTasksGenAI
16
16
 
17
17
  @objc(LLMPlugin)
18
18
  public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
19
- private let pluginVersion: String = "8.0.10"
19
+ private let pluginVersion: String = "8.0.11"
20
+ #if targetEnvironment(macCatalyst)
21
+ private let catalystNotSupportedMessage = "CapgoLLM is not available on Mac Catalyst. Use an iOS/iPadOS target instead."
22
+ #endif
20
23
  public let identifier = "LLMPlugin"
21
24
  public let jsName = "CapgoLLM"
22
25
  public var pluginMethods: [CAPPluginMethod] = [
@@ -49,7 +52,7 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
49
52
  private var appleChats: [String: Any] = [:]
50
53
  #endif
51
54
 
52
- #if COCOAPODS || canImport(MediaPipeTasksGenAI)
55
+ #if !targetEnvironment(macCatalyst) && (COCOAPODS || canImport(MediaPipeTasksGenAI))
53
56
  private var llmInference: LlmInference?
54
57
  #endif
55
58
 
@@ -59,6 +62,11 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
59
62
  return
60
63
  }
61
64
 
65
+ #if targetEnvironment(macCatalyst)
66
+ call.reject(catalystNotSupportedMessage)
67
+ return
68
+ #endif
69
+
62
70
  print("[CapgoLLM] Setting model path: \(path)")
63
71
 
64
72
  // Extract model parameters
@@ -80,7 +88,7 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
80
88
  return
81
89
  }
82
90
 
83
- #if canImport(MediaPipeTasksGenAI)
91
+ #if !targetEnvironment(macCatalyst) && canImport(MediaPipeTasksGenAI)
84
92
  Task {
85
93
  do {
86
94
  let modelURL: URL
@@ -151,11 +159,16 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
151
159
  }
152
160
  }
153
161
  #else
154
- call.reject("MediaPipe is not available. Please install via CocoaPods.")
162
+ call.reject("MediaPipe is not available on this platform. Please install via CocoaPods on iOS.")
155
163
  #endif
156
164
  }
157
165
 
158
166
  @objc func createChat(_ call: CAPPluginCall) {
167
+ #if targetEnvironment(macCatalyst)
168
+ call.reject(catalystNotSupportedMessage)
169
+ return
170
+ #endif
171
+
159
172
  print("[CapgoLLM] Creating chat with model type: \(currentModelType)")
160
173
  switch currentModelType {
161
174
  case .appleIntelligence:
@@ -176,7 +189,7 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
176
189
  #endif
177
190
 
178
191
  case .mediaPipe:
179
- #if COCOAPODS || canImport(MediaPipeTasksGenAI)
192
+ #if !targetEnvironment(macCatalyst) && (COCOAPODS || canImport(MediaPipeTasksGenAI))
180
193
  guard llmInference != nil else {
181
194
  print("[CapgoLLM] Error: Model not loaded when creating chat")
182
195
  call.reject("Model not loaded")
@@ -190,12 +203,18 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
190
203
  "id": id
191
204
  ])
192
205
  #else
193
- call.reject("MediaPipe is not available. Please install via CocoaPods.")
206
+ call.reject("MediaPipe is not available on this platform. Please install via CocoaPods on iOS.")
194
207
  #endif
195
208
  }
196
209
  }
197
210
 
198
211
  @objc func getReadiness(_ call: CAPPluginCall) {
212
+ #if targetEnvironment(macCatalyst)
213
+ call.resolve(["readiness": "unsupported_on_maccatalyst"])
214
+ notifyListeners("readinessChange", data: ["readiness": "unsupported_on_maccatalyst"])
215
+ return
216
+ #endif
217
+
199
218
  let readiness = getReadinessStatus()
200
219
  call.resolve(["readiness": readiness])
201
220
  // Also notify listeners
@@ -232,6 +251,11 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
232
251
  }
233
252
 
234
253
  @objc func sendMessage(_ call: CAPPluginCall) {
254
+ #if targetEnvironment(macCatalyst)
255
+ call.reject(catalystNotSupportedMessage)
256
+ return
257
+ #endif
258
+
235
259
  let chatId = call.getString("chatId", "")
236
260
  guard let message = call.getString("message") else {
237
261
  call.reject("message not found")
@@ -318,7 +342,7 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
318
342
  #endif
319
343
 
320
344
  case .mediaPipe:
321
- #if COCOAPODS || canImport(MediaPipeTasksGenAI)
345
+ #if !targetEnvironment(macCatalyst) && (COCOAPODS || canImport(MediaPipeTasksGenAI))
322
346
  guard let inference = llmInference else {
323
347
  call.reject("Model not loaded")
324
348
  return
@@ -358,7 +382,7 @@ public class LLMPlugin: CAPPlugin, CAPBridgedPlugin {
358
382
  }
359
383
  }
360
384
  #else
361
- call.reject("MediaPipe is not available. Please install via CocoaPods.")
385
+ call.reject("MediaPipe is not available on this platform. Please install via CocoaPods on iOS.")
362
386
  #endif
363
387
  }
364
388
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-llm",
3
- "version": "8.0.10",
3
+ "version": "8.0.11",
4
4
  "description": "Adds support for LLM locally runned for Capacitor",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",