bleam 0.0.8 → 0.0.10

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 (96) hide show
  1. package/dist/cli.cjs +269 -22
  2. package/dist/cli.d.cts +32 -2
  3. package/dist/cli.d.ts +32 -2
  4. package/dist/cli.js +270 -23
  5. package/dist/platform.d.cts +2 -0
  6. package/dist/platform.d.ts +2 -0
  7. package/dist/{ui-1WepaMS4.d.cts → ui-Bg11tvlc.d.ts} +1 -1
  8. package/dist/{ui-Ce-pnUUA.d.ts → ui-Dd7SXdbg.d.cts} +7 -7
  9. package/dist/ui.d.cts +1 -1
  10. package/dist/ui.d.ts +1 -1
  11. package/dist/window.d.cts +1 -1
  12. package/dist/window.d.ts +1 -1
  13. package/package.json +5 -1
  14. package/templates/image-generation/app/index.tsx +1 -1
  15. package/templates/native/.gitattributes +1 -0
  16. package/templates/native/App.tsx +26 -0
  17. package/templates/native/app.json +12 -0
  18. package/templates/native/index.ts +8 -0
  19. package/templates/native/ios/.xcode.env +11 -0
  20. package/templates/native/ios/Bleam/AI/Flux2/Configuration/Flux2Config.swift +288 -0
  21. package/templates/native/ios/Bleam/AI/Flux2/Configuration/MemoryConfig.swift +233 -0
  22. package/templates/native/ios/Bleam/AI/Flux2/Configuration/MemoryOptimizationConfig.swift +157 -0
  23. package/templates/native/ios/Bleam/AI/Flux2/Configuration/ModelRegistry.swift +425 -0
  24. package/templates/native/ios/Bleam/AI/Flux2/Configuration/QuantizationConfig.swift +138 -0
  25. package/templates/native/ios/Bleam/AI/Flux2/Configuration/TransformerRepoProfile.swift +59 -0
  26. package/templates/native/ios/Bleam/AI/Flux2/Configuration/VAEConfig.swift +134 -0
  27. package/templates/native/ios/Bleam/AI/Flux2/Flux2Core.swift +55 -0
  28. package/templates/native/ios/Bleam/AI/Flux2/Loading/WeightLoader.swift +1192 -0
  29. package/templates/native/ios/Bleam/AI/Flux2/Pipeline/FluxImageRunner.swift +1282 -0
  30. package/templates/native/ios/Bleam/AI/Flux2/Pipeline/LatentUtils.swift +191 -0
  31. package/templates/native/ios/Bleam/AI/Flux2/Scheduler/FlowMatchEulerScheduler.swift +279 -0
  32. package/templates/native/ios/Bleam/AI/Flux2/Text/KleinTextEncoder.swift +380 -0
  33. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2Attention.swift +379 -0
  34. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2Embeddings.swift +159 -0
  35. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2FeedForward.swift +154 -0
  36. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2FusedKernels.swift +198 -0
  37. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2KVCache.swift +36 -0
  38. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2Modulation.swift +193 -0
  39. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2ParallelAttention.swift +389 -0
  40. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2RoPE.swift +304 -0
  41. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2SingleBlock.swift +290 -0
  42. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2Transformer.swift +530 -0
  43. package/templates/native/ios/Bleam/AI/Flux2/Transformer/Flux2TransformerBlock.swift +362 -0
  44. package/templates/native/ios/Bleam/AI/Flux2/Utils/Flux2Debug.swift +101 -0
  45. package/templates/native/ios/Bleam/AI/Flux2/Utils/MLXCheckpoint.swift +118 -0
  46. package/templates/native/ios/Bleam/AI/Flux2/Utils/MemoryManager.swift +201 -0
  47. package/templates/native/ios/Bleam/AI/Flux2/VAE/AutoencoderKL.swift +476 -0
  48. package/templates/native/ios/Bleam/AI/Flux2/VAE/ResnetBlock.swift +316 -0
  49. package/templates/native/ios/Bleam/AI/Flux2/VAE/VAEDecoder.swift +120 -0
  50. package/templates/native/ios/Bleam/AI/Flux2/VAE/VAEEncoder.swift +136 -0
  51. package/templates/native/ios/Bleam/AppDelegate.swift +482 -0
  52. package/templates/native/ios/Bleam/Appearance.swift +62 -0
  53. package/templates/native/ios/Bleam/Bridging-Header.h +3 -0
  54. package/templates/native/ios/Bleam/Images.xcassets/AppIcon.appiconset/Contents.json +13 -0
  55. package/templates/native/ios/Bleam/Images.xcassets/Contents.json +6 -0
  56. package/templates/native/ios/Bleam/Info.plist +76 -0
  57. package/templates/native/ios/Bleam/PrivacyInfo.xcprivacy +48 -0
  58. package/templates/native/ios/Bleam/SceneDelegate.swift +58 -0
  59. package/templates/native/ios/Bleam/SplashScreen.storyboard +47 -0
  60. package/templates/native/ios/Bleam/Supporting/Expo.plist +6 -0
  61. package/templates/native/ios/Bleam/bleam.entitlements +10 -0
  62. package/templates/native/ios/Bleam.xcodeproj/project.pbxproj +1147 -0
  63. package/templates/native/ios/Bleam.xcodeproj/xcshareddata/xcschemes/Bleam.xcscheme +88 -0
  64. package/templates/native/ios/GenerationService/GenerationService.entitlements +10 -0
  65. package/templates/native/ios/GenerationService/ImageGenerationRunner.swift +591 -0
  66. package/templates/native/ios/GenerationService/Info.plist +31 -0
  67. package/templates/native/ios/GenerationService/main.swift +165 -0
  68. package/templates/native/ios/PlatformHelper/main.swift +726 -0
  69. package/templates/native/ios/Podfile +198 -0
  70. package/templates/native/ios/Podfile.lock +2284 -0
  71. package/templates/native/ios/Podfile.properties.json +5 -0
  72. package/templates/native/ios/Shared/Generation/GenerationServiceProtocol.swift +12 -0
  73. package/templates/native/ios/Shared/Generation/GenerationWorkerProtocol.swift +124 -0
  74. package/templates/native/metro.config.js +6 -0
  75. package/templates/native/modules/bleam-runtime/BleamRuntime.podspec +14 -0
  76. package/templates/native/modules/bleam-runtime/expo-module.config.json +8 -0
  77. package/templates/native/modules/bleam-runtime/ios/AIModule.swift +1258 -0
  78. package/templates/native/modules/bleam-runtime/ios/GenerationContracts.swift +135 -0
  79. package/templates/native/modules/bleam-runtime/ios/PlatformModule.swift +329 -0
  80. package/templates/native/modules/bleam-runtime/package.json +5 -0
  81. package/templates/native/package.json +39 -0
  82. package/templates/native/scripts/build/mlx-frameworks.ts +421 -0
  83. package/templates/native/scripts/start/index.ts +474 -0
  84. package/templates/native/scripts/start/known-failures.ts +20 -0
  85. package/templates/native/scripts/start/loader.ts +76 -0
  86. package/templates/native/scripts/start/native-state.ts +242 -0
  87. package/templates/native/scripts/start/package.json +4 -0
  88. package/templates/native/scripts/start/swift-packages.ts +414 -0
  89. package/templates/native/scripts/start/xcode-formatter.ts +106 -0
  90. package/templates/native/tsconfig.json +14 -0
  91. package/templates/native/yarn.lock +3749 -0
  92. package/templates/updates/README.md +272 -0
  93. package/templates/updates/src/index.ts +385 -0
  94. package/templates/updates/src/schema.ts +385 -0
  95. package/templates/updates/tsconfig.json +12 -0
  96. package/templates/updates/wrangler.jsonc +19 -0
@@ -0,0 +1,135 @@
1
+ import Foundation
2
+
3
+ @objc protocol GenerationServiceProtocol {
4
+ func startGeneration(requestData: Data, reply: @escaping (Bool) -> Void)
5
+ func cancelGeneration(reply: @escaping (Bool) -> Void)
6
+ func memoryTelemetry(reply: @escaping (Data?) -> Void)
7
+ func shutdown(reply: @escaping (Bool) -> Void)
8
+ }
9
+
10
+ @objc protocol GenerationServiceClientProtocol {
11
+ func generationWorkerDidEmit(eventData: Data)
12
+ }
13
+
14
+ struct GenerationWorkerRequest: Codable, Sendable {
15
+ let jobID: UUID
16
+ let model: String
17
+ let prompt: String
18
+ let sourceImagePath: String?
19
+ let maskImagePath: String?
20
+ let maskMode: String?
21
+ let outpaintWidth: Int?
22
+ let outpaintHeight: Int?
23
+ let outpaintSourceX: Int?
24
+ let outpaintSourceY: Int?
25
+ let outpaintSourceWidth: Int?
26
+ let outpaintSourceHeight: Int?
27
+ let outpaintAutoCrop: Bool?
28
+ let resizeMode: String?
29
+ let maxInputLongSide: Int?
30
+ let referenceImagePaths: [String]
31
+ let referenceInfluences: [Double]?
32
+ let loraPaths: [String]
33
+ let loraScales: [Double]?
34
+ let loraIds: [String]?
35
+ let sigmaSchedule: [Double]?
36
+ let width: Int
37
+ let height: Int
38
+ let steps: Int
39
+ let guidance: Double
40
+ let strength: Double?
41
+ let seed: Int?
42
+ let inputIds: [Int]
43
+ let attentionMask: [Int]
44
+ let modelRoot: String
45
+ let textEncoderPath: String
46
+ let transformerPath: String
47
+ let vaePath: String
48
+ let stagingDirectoryPath: String
49
+ }
50
+
51
+ struct GenerationWorkerEvent: Codable, Sendable {
52
+ enum EventType: String, Codable, Sendable {
53
+ case ready
54
+ case progress
55
+ case completed
56
+ case canceled
57
+ case failed
58
+ case log
59
+ }
60
+
61
+ let type: EventType
62
+ let message: String?
63
+ let currentStep: Int?
64
+ let totalSteps: Int?
65
+ let path: String?
66
+ let width: Int?
67
+ let height: Int?
68
+ let model: String?
69
+ let level: String?
70
+ let category: String?
71
+ let jobID: String?
72
+ let stage: String?
73
+ let metadata: GenerationWorkerMetadata?
74
+
75
+ init(
76
+ type: EventType,
77
+ message: String? = nil,
78
+ currentStep: Int? = nil,
79
+ totalSteps: Int? = nil,
80
+ path: String? = nil,
81
+ width: Int? = nil,
82
+ height: Int? = nil,
83
+ model: String? = nil,
84
+ level: String? = nil,
85
+ category: String? = nil,
86
+ jobID: String? = nil,
87
+ stage: String? = nil,
88
+ metadata: GenerationWorkerMetadata? = nil
89
+ ) {
90
+ self.type = type
91
+ self.message = message
92
+ self.currentStep = currentStep
93
+ self.totalSteps = totalSteps
94
+ self.path = path
95
+ self.width = width
96
+ self.height = height
97
+ self.model = model
98
+ self.level = level
99
+ self.category = category
100
+ self.jobID = jobID
101
+ self.stage = stage
102
+ self.metadata = metadata
103
+ }
104
+ }
105
+
106
+ struct GenerationWorkerFailure: LocalizedError {
107
+ let message: String
108
+ let stage: String?
109
+
110
+ init(message: String, stage: String? = nil) {
111
+ self.message = message
112
+ self.stage = stage
113
+ }
114
+
115
+ var errorDescription: String? { message }
116
+ }
117
+
118
+ struct GenerationWorkerMetadata: Codable, Sendable {
119
+ let model: String
120
+ let width: Int
121
+ let height: Int
122
+ let steps: Int
123
+ let guidance: Double
124
+ let strength: Double?
125
+ let seed: Int?
126
+ let elapsedMs: Int
127
+ let appliedLoRAs: [GenerationWorkerLoRA]?
128
+ let sigmaSchedule: [Double]?
129
+ }
130
+
131
+ struct GenerationWorkerLoRA: Codable, Sendable {
132
+ let id: String?
133
+ let path: String
134
+ let scale: Double
135
+ }
@@ -0,0 +1,329 @@
1
+ import AVFoundation
2
+ import Contacts
3
+ import CoreLocation
4
+ import EventKit
5
+ import ExpoModulesCore
6
+ import Foundation
7
+ import Photos
8
+
9
+ @objc private protocol PlatformHelperProtocol {
10
+ func health(reply: @escaping (Data?) -> Void)
11
+ func downloadPlatformUpdate(requestData: Data, reply: @escaping (Data?) -> Void)
12
+ func applyPlatformUpdate(requestData: Data, reply: @escaping (Bool) -> Void)
13
+ }
14
+
15
+ public final class PlatformModule: Module {
16
+ public func definition() -> ModuleDefinition {
17
+ Name("Platform")
18
+
19
+ AsyncFunction("helperStatus") { (promise: Promise) in
20
+ guard Self.isSupportedInstallLocation else {
21
+ UserDefaults.standard.set(false, forKey: "BleamPlatformUpdatesSupported")
22
+ promise.resolve([
23
+ "healthy": false,
24
+ "protocolVersion": 1,
25
+ "helperVersion": "unavailable",
26
+ "platformVersion": "unavailable",
27
+ "capabilities": [],
28
+ "updatesSupported": false,
29
+ "installPath": Bundle.main.bundleURL.path,
30
+ "reason": "reinstall_required",
31
+ ])
32
+ return
33
+ }
34
+ let serviceName = "\(Bundle.main.bundleIdentifier ?? "dev.bleam.app").PlatformHelper"
35
+ guard let connection = Self.makeConnection(serviceName: serviceName) else {
36
+ promise.reject("HELPER_UNAVAILABLE", "The app helper is unavailable")
37
+ return
38
+ }
39
+ connection.remoteObjectInterface = NSXPCInterface(with: PlatformHelperProtocol.self)
40
+ connection.resume()
41
+
42
+ guard let service = connection.remoteObjectProxyWithErrorHandler({ error in
43
+ connection.invalidate()
44
+ promise.reject("HELPER_UNAVAILABLE", error.localizedDescription)
45
+ }) as? PlatformHelperProtocol else {
46
+ connection.invalidate()
47
+ promise.reject("HELPER_UNAVAILABLE", "The app helper is unavailable")
48
+ return
49
+ }
50
+
51
+ service.health { data in
52
+ defer { connection.invalidate() }
53
+ guard
54
+ let data,
55
+ var status = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
56
+ else {
57
+ promise.reject("HELPER_INVALID_RESPONSE", "The app helper returned an invalid response")
58
+ return
59
+ }
60
+ let supported = Self.isSupportedInstallLocation
61
+ status["updatesSupported"] = supported
62
+ status["installPath"] = Bundle.main.bundleURL.path
63
+ if !supported {
64
+ status["reason"] = "reinstall_required"
65
+ }
66
+ UserDefaults.standard.set(status["healthy"], forKey: "BleamHelperHealthy")
67
+ UserDefaults.standard.set(status["platformVersion"], forKey: "BleamHelperPlatformVersion")
68
+ UserDefaults.standard.set(supported, forKey: "BleamPlatformUpdatesSupported")
69
+ promise.resolve(status)
70
+ }
71
+ }
72
+
73
+ AsyncFunction("permissionState") { (capability: String, promise: Promise) in
74
+ guard let state = Self.permissionState(capability) else {
75
+ promise.reject("INVALID_CAPABILITY", "Unknown permission capability: \(capability)")
76
+ return
77
+ }
78
+ promise.resolve(Self.permissionResponse(capability: capability, state: state))
79
+ }
80
+
81
+ AsyncFunction("permissionStates") { (promise: Promise) in
82
+ let states: [[String: Any]] = Self.permissionCapabilities.compactMap { capability in
83
+ guard let state = Self.permissionState(capability) else { return nil }
84
+ return Self.permissionResponse(capability: capability, state: state)
85
+ }
86
+ promise.resolve(states)
87
+ }
88
+
89
+ AsyncFunction("downloadPlatformUpdate") { (promise: Promise) in
90
+ guard Self.isSupportedInstallLocation else {
91
+ promise.reject("REINSTALL_REQUIRED", "Platform updates require the app to be installed directly in ~/Applications")
92
+ return
93
+ }
94
+ guard
95
+ let serviceURL = Bundle.main.object(forInfoDictionaryKey: "BleamUpdateServiceURL") as? String,
96
+ let bundleIdentifier = Bundle.main.bundleIdentifier,
97
+ let teamIdentifier = Bundle.main.object(forInfoDictionaryKey: "BleamTeamIdentifier") as? String,
98
+ let platformVersion = Bundle.main.object(forInfoDictionaryKey: "BleamRuntimeVersion") as? String,
99
+ let platformFingerprint = Bundle.main.object(forInfoDictionaryKey: "BleamPlatformFingerprint") as? String,
100
+ let requestData = try? JSONSerialization.data(withJSONObject: [
101
+ "serviceURL": serviceURL,
102
+ "bundleIdentifier": bundleIdentifier,
103
+ "teamIdentifier": teamIdentifier,
104
+ "platformVersion": platformVersion,
105
+ "platformFingerprint": platformFingerprint,
106
+ ])
107
+ else {
108
+ promise.reject("UPDATES_UNAVAILABLE", "Platform updates are not configured")
109
+ return
110
+ }
111
+
112
+ guard let connection = Self.makeConnection(serviceName: "\(bundleIdentifier).PlatformHelper") else {
113
+ promise.reject("HELPER_UNAVAILABLE", "The app helper is unavailable")
114
+ return
115
+ }
116
+ connection.remoteObjectInterface = NSXPCInterface(with: PlatformHelperProtocol.self)
117
+ connection.resume()
118
+ guard let service = connection.remoteObjectProxyWithErrorHandler({ error in
119
+ connection.invalidate()
120
+ promise.reject("PLATFORM_DOWNLOAD_FAILED", error.localizedDescription)
121
+ }) as? PlatformHelperProtocol else {
122
+ connection.invalidate()
123
+ promise.reject("HELPER_UNAVAILABLE", "The app helper is unavailable")
124
+ return
125
+ }
126
+
127
+ service.downloadPlatformUpdate(requestData: requestData) { data in
128
+ defer { connection.invalidate() }
129
+ guard
130
+ let data,
131
+ let result = try? JSONSerialization.jsonObject(with: data) as? [String: Any]
132
+ else {
133
+ promise.reject("PLATFORM_DOWNLOAD_FAILED", "The platform update could not be downloaded")
134
+ return
135
+ }
136
+ if let error = result["error"] as? String {
137
+ UserDefaults.standard.set(error, forKey: "BleamPlatformDownloadError")
138
+ promise.reject("PLATFORM_VERIFICATION_FAILED", error)
139
+ return
140
+ }
141
+ UserDefaults.standard.set(result["releaseId"], forKey: "BleamPlatformDownloadRelease")
142
+ promise.resolve(result)
143
+ }
144
+ }
145
+
146
+ AsyncFunction("updateAndRelaunch") { (releaseId: String, promise: Promise) in
147
+ guard Self.isSupportedInstallLocation else {
148
+ promise.reject("REINSTALL_REQUIRED", "Platform updates require the app to be installed directly in ~/Applications")
149
+ return
150
+ }
151
+ guard
152
+ let bundleIdentifier = Bundle.main.bundleIdentifier,
153
+ let teamIdentifier = Bundle.main.object(forInfoDictionaryKey: "BleamTeamIdentifier") as? String,
154
+ let requestData = try? JSONSerialization.data(withJSONObject: [
155
+ "releaseId": releaseId,
156
+ "bundleIdentifier": bundleIdentifier,
157
+ "teamIdentifier": teamIdentifier,
158
+ "installedAppPath": Bundle.main.bundleURL.path,
159
+ "appPID": ProcessInfo.processInfo.processIdentifier,
160
+ ]),
161
+ let connection = Self.makeConnection(serviceName: "\(bundleIdentifier).PlatformHelper")
162
+ else {
163
+ promise.reject("PLATFORM_UPDATE_UNAVAILABLE", "The platform update cannot be applied")
164
+ return
165
+ }
166
+ connection.remoteObjectInterface = NSXPCInterface(with: PlatformHelperProtocol.self)
167
+ connection.resume()
168
+ guard let service = connection.remoteObjectProxyWithErrorHandler({ error in
169
+ connection.invalidate()
170
+ promise.reject("PLATFORM_UPDATE_FAILED", error.localizedDescription)
171
+ }) as? PlatformHelperProtocol else {
172
+ connection.invalidate()
173
+ promise.reject("HELPER_UNAVAILABLE", "The app helper is unavailable")
174
+ return
175
+ }
176
+ service.applyPlatformUpdate(requestData: requestData) { accepted in
177
+ connection.invalidate()
178
+ UserDefaults.standard.set(accepted, forKey: "BleamPlatformApplyAccepted")
179
+ guard accepted else {
180
+ promise.reject("PLATFORM_UPDATE_REJECTED", "The platform update is not verified or the app is not installed in ~/Applications")
181
+ return
182
+ }
183
+ promise.resolve(nil)
184
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
185
+ exit(0)
186
+ }
187
+ }
188
+ }
189
+ }
190
+
191
+ private static func makeConnection(serviceName: String) -> NSXPCConnection? {
192
+ #if targetEnvironment(macCatalyst)
193
+ let connectionClass: AnyObject = NSXPCConnection.self as AnyObject
194
+ let allocated = connectionClass.perform(NSSelectorFromString("alloc"))?.takeUnretainedValue() as AnyObject?
195
+ let selector = NSSelectorFromString("initWithMachServiceName:options:")
196
+ guard let allocated, allocated.responds(to: selector) else { return nil }
197
+
198
+ typealias Initializer = @convention(c) (
199
+ AnyObject,
200
+ Selector,
201
+ NSString,
202
+ UInt
203
+ ) -> Unmanaged<AnyObject>
204
+ let initialize = unsafeBitCast(allocated.method(for: selector), to: Initializer.self)
205
+ return initialize(
206
+ allocated,
207
+ selector,
208
+ serviceName as NSString,
209
+ 0
210
+ ).takeRetainedValue() as? NSXPCConnection
211
+ #else
212
+ return NSXPCConnection(machServiceName: serviceName)
213
+ #endif
214
+ }
215
+
216
+ private static let permissionCapabilities = [
217
+ "camera",
218
+ "microphone",
219
+ "photos",
220
+ "contacts",
221
+ "calendars",
222
+ "reminders",
223
+ "location",
224
+ ]
225
+
226
+ private static func permissionResponse(capability: String, state: String) -> [String: Any] {
227
+ [
228
+ "capability": capability,
229
+ "status": state,
230
+ "granted": state == "granted" || state == "limited",
231
+ "canAskAgain": state == "not-determined",
232
+ "expires": "never",
233
+ ]
234
+ }
235
+
236
+ private static func permissionState(_ capability: String) -> String? {
237
+ switch capability {
238
+ case "camera":
239
+ return authorizationState(AVCaptureDevice.authorizationStatus(for: .video))
240
+ case "microphone":
241
+ return authorizationState(AVCaptureDevice.authorizationStatus(for: .audio))
242
+ case "photos":
243
+ switch PHPhotoLibrary.authorizationStatus(for: .readWrite) {
244
+ case .authorized:
245
+ return "granted"
246
+ case .limited:
247
+ return "limited"
248
+ case .denied:
249
+ return "denied"
250
+ case .restricted:
251
+ return "restricted"
252
+ case .notDetermined:
253
+ return "not-determined"
254
+ @unknown default:
255
+ return "unsupported"
256
+ }
257
+ case "contacts":
258
+ switch CNContactStore.authorizationStatus(for: .contacts) {
259
+ case .authorized:
260
+ return "granted"
261
+ case .denied:
262
+ return "denied"
263
+ case .restricted:
264
+ return "restricted"
265
+ case .notDetermined:
266
+ return "not-determined"
267
+ @unknown default:
268
+ return "unsupported"
269
+ }
270
+ case "calendars":
271
+ return eventAuthorizationState(EKEventStore.authorizationStatus(for: .event))
272
+ case "reminders":
273
+ return eventAuthorizationState(EKEventStore.authorizationStatus(for: .reminder))
274
+ case "location":
275
+ switch CLLocationManager().authorizationStatus {
276
+ case .authorizedAlways, .authorizedWhenInUse:
277
+ return "granted"
278
+ case .denied:
279
+ return "denied"
280
+ case .restricted:
281
+ return "restricted"
282
+ case .notDetermined:
283
+ return "not-determined"
284
+ @unknown default:
285
+ return "unsupported"
286
+ }
287
+ default:
288
+ return nil
289
+ }
290
+ }
291
+
292
+ private static func authorizationState(_ status: AVAuthorizationStatus) -> String {
293
+ switch status {
294
+ case .authorized:
295
+ return "granted"
296
+ case .denied:
297
+ return "denied"
298
+ case .restricted:
299
+ return "restricted"
300
+ case .notDetermined:
301
+ return "not-determined"
302
+ @unknown default:
303
+ return "unsupported"
304
+ }
305
+ }
306
+
307
+ private static func eventAuthorizationState(_ status: EKAuthorizationStatus) -> String {
308
+ switch status {
309
+ case .fullAccess, .authorized:
310
+ return "granted"
311
+ case .writeOnly:
312
+ return "limited"
313
+ case .denied:
314
+ return "denied"
315
+ case .restricted:
316
+ return "restricted"
317
+ case .notDetermined:
318
+ return "not-determined"
319
+ @unknown default:
320
+ return "unsupported"
321
+ }
322
+ }
323
+
324
+ private static var isSupportedInstallLocation: Bool {
325
+ let applications = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true)
326
+ .appendingPathComponent("Applications", isDirectory: true).standardizedFileURL
327
+ return Bundle.main.bundleURL.standardizedFileURL.deletingLastPathComponent() == applications
328
+ }
329
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "bleam-runtime",
3
+ "version": "0.0.0",
4
+ "private": true
5
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "bleam",
3
+ "version": "1.0.0",
4
+ "main": "index.ts",
5
+ "dependencies": {
6
+ "@nativescript-community/sqlite": "^3.5.9",
7
+ "@nativescript/react-native": "9.0.0-preview.4",
8
+ "expo": "~57.0.2",
9
+ "react": "19.2.3",
10
+ "react-native": "0.86.0"
11
+ },
12
+ "scripts": {
13
+ "verify": "../../node_modules/.bin/biome check .",
14
+ "verify:write": "../../node_modules/.bin/biome check --write .",
15
+ "format": "../../node_modules/.bin/biome format --write .",
16
+ "format:check": "../../node_modules/.bin/biome format .",
17
+ "lint": "../../node_modules/.bin/biome lint .",
18
+ "build:runtime": "xcodebuild -workspace ios/bleam.xcworkspace -scheme Bleam -configuration Debug -destination 'platform=macOS,arch=arm64,variant=Mac Catalyst' -derivedDataPath build ARCHS=arm64 build",
19
+ "start": "tsx scripts/start/index.ts",
20
+ "start:clean": "tsx scripts/start/index.ts --clean",
21
+ "typecheck": "tsc --noEmit"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^25.5.0",
25
+ "tsx": "^4.21.0",
26
+ "typescript": "7.0.1-rc"
27
+ },
28
+ "expo": {
29
+ "autolinking": {
30
+ "nativeModulesDir": "modules"
31
+ },
32
+ "install": {
33
+ "exclude": [
34
+ "typescript"
35
+ ]
36
+ }
37
+ },
38
+ "private": true
39
+ }