@legendapp/spark 0.0.1 → 0.0.3

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 (141) hide show
  1. package/native.d.cts +6 -3
  2. package/package.json +36 -28
  3. package/patches/dependencies.json +252 -0
  4. package/patches/expo-application@55.0.19.patch +54 -0
  5. package/patches/expo-blur@55.0.18.patch +130 -0
  6. package/patches/expo-device@55.0.21.patch +149 -0
  7. package/patches/expo-font@55.0.8.patch +55 -0
  8. package/patches/expo-glass-effect@55.0.11.patch +304 -0
  9. package/patches/expo-haptics@55.0.18.patch +54 -0
  10. package/patches/expo-image-manipulator@55.0.21.patch +312 -0
  11. package/patches/expo-image-picker@55.0.24.patch +327 -0
  12. package/patches/expo-image@55.0.11.patch +158 -0
  13. package/patches/expo-keep-awake@55.0.8.patch +41 -0
  14. package/patches/expo-localization@55.0.19.patch +32 -0
  15. package/patches/expo-location@55.1.15.patch +190 -0
  16. package/patches/expo-symbols@55.0.9.patch +286 -0
  17. package/patches/expo-system-ui@55.0.22.patch +61 -0
  18. package/patches/expo-web-browser@55.0.20.patch +13 -0
  19. package/patches/react-native-app-logs@0.3.1.patch +20 -0
  20. package/patches/react-native-blurhash@2.1.3.patch +318 -0
  21. package/patches/react-native-community-blur@4.4.1.patch +415 -0
  22. package/patches/react-native-community-datetimepicker@9.2.2.patch +320 -0
  23. package/patches/react-native-enriched-markdown@1.1.1.patch +141 -10
  24. package/patches/react-native-fast-image@10.9.9.patch +131 -0
  25. package/patches/react-native-graph@1.4.0.patch +157 -0
  26. package/patches/react-native-keyboard-controller@1.22.9.patch +16 -0
  27. package/patches/react-native-masked-view-masked-view@0.3.2.patch +140 -0
  28. package/patches/react-native-mmkv@4.3.2.patch +40 -0
  29. package/patches/react-native-nitro-fetch@1.9.0.patch +130 -0
  30. package/patches/react-native-nitro-zxing@0.3.0.patch +13 -0
  31. package/patches/react-native-quick-base64@3.0.1.patch +13 -0
  32. package/patches/react-native-quick-crypto@1.1.9.patch +31 -0
  33. package/patches/react-native-release-profiler@0.4.5.patch +37 -0
  34. package/patches/react-native-screen-corner-radius@0.2.3.patch +13 -0
  35. package/patches/react-native-screens@4.23.0.patch +160 -0
  36. package/patches/react-native-svg@15.15.3.patch +31 -0
  37. package/patches/react-native-unistyles@3.6.0.patch +203 -0
  38. package/patches/react-native-worklets-core@1.6.3.patch +13 -0
  39. package/patches/react-navigation-native-stack@7.21.0.patch +16 -0
  40. package/patches/sentry-react-native@8.32.0.patch +76 -0
  41. package/skills/spark/UPGRADING.md +122 -3
  42. package/vendor/node_modules/@legendapp/spark-ai/package.json +5 -5
  43. package/vendor/node_modules/@legendapp/spark-audio/package.json +5 -5
  44. package/vendor/node_modules/@legendapp/spark-audio/src/index.macos.ts +1 -0
  45. package/vendor/node_modules/@legendapp/spark-auth-session/package.json +6 -6
  46. package/vendor/node_modules/@legendapp/spark-auth-session/src/index.macos.ts +1 -0
  47. package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +2 -2
  48. package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +17 -5
  49. package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +4 -2
  50. package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +8 -4
  51. package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +45 -1
  52. package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +15 -3
  53. package/vendor/node_modules/@legendapp/spark-cli/dist/examples.js +2 -2
  54. package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-patch.cjs +3 -3
  55. package/vendor/node_modules/@legendapp/spark-cli/dist/expo-dev-preload.cjs +3 -0
  56. package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +26 -7
  57. package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +3 -1
  58. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +20 -5
  59. package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +1 -0
  60. package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +10 -2
  61. package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +3 -3
  62. package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +28 -10
  63. package/vendor/node_modules/@legendapp/spark-cli/dist/release-runner-root.js +108 -0
  64. package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +13 -13
  65. package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-input-cache.js +140 -0
  66. package/vendor/node_modules/@legendapp/spark-cli/dist/watchman.js +12 -0
  67. package/vendor/node_modules/@legendapp/spark-cli/dist/windows-geometry.js +2 -2
  68. package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +1 -1
  69. package/vendor/node_modules/@legendapp/spark-cli/package.json +3 -3
  70. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/desktop.config.json +1 -1
  71. package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +27 -25
  72. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/desktop.config.json +1 -1
  73. package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +35 -33
  74. package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +29 -27
  75. package/vendor/node_modules/@legendapp/spark-clipboard/package.json +5 -5
  76. package/vendor/node_modules/@legendapp/spark-clipboard/src/index.macos.ts +1 -0
  77. package/vendor/node_modules/@legendapp/spark-codex/package.json +4 -4
  78. package/vendor/node_modules/@legendapp/spark-commands/package.json +7 -7
  79. package/vendor/node_modules/@legendapp/spark-context-menu/package.json +4 -4
  80. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +7 -2
  81. package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +64 -2
  82. package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +3 -3
  83. package/vendor/node_modules/@legendapp/spark-desktop-config/accessibility-state.cjs +2 -2
  84. package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +12 -0
  85. package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +7 -6
  86. package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +1 -1
  87. package/vendor/node_modules/@legendapp/spark-desktop-config/fabric-lifecycle.cjs +1 -1
  88. package/vendor/node_modules/@legendapp/spark-desktop-config/keyboard-events.cjs +2 -2
  89. package/vendor/node_modules/@legendapp/spark-desktop-config/macos-host.cjs +39 -0
  90. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +73 -20
  91. package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +2 -1
  92. package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +8 -6
  93. package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-scroll-view.cjs +2 -2
  94. package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-alignment.cjs +2 -2
  95. package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-input-alignment.cjs +2 -2
  96. package/vendor/node_modules/@legendapp/spark-desktop-config/text-input-accessibility.cjs +2 -2
  97. package/vendor/node_modules/@legendapp/spark-desktop-host/macos/AppDelegate.h +6 -0
  98. package/vendor/node_modules/@legendapp/spark-desktop-host/macos/Main.storyboard +684 -0
  99. package/vendor/node_modules/@legendapp/spark-desktop-host/macos/main.m +5 -0
  100. package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +3 -2
  101. package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +5 -5
  102. package/vendor/node_modules/@legendapp/spark-desktop-links/src/index.macos.ts +1 -0
  103. package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +4 -4
  104. package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +68 -17
  105. package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +5 -5
  106. package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +2 -1
  107. package/vendor/node_modules/@legendapp/spark-documents/package.json +9 -9
  108. package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +4 -4
  109. package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +4 -4
  110. package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +14 -5
  111. package/vendor/node_modules/@legendapp/spark-file-system/package.json +4 -4
  112. package/vendor/node_modules/@legendapp/spark-file-system/src/index.ts +1 -1
  113. package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +4 -4
  114. package/vendor/node_modules/@legendapp/spark-html/package.json +4 -4
  115. package/vendor/node_modules/@legendapp/spark-markdown/package.json +4 -4
  116. package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +4 -4
  117. package/vendor/node_modules/@legendapp/spark-native-menu/package.json +4 -4
  118. package/vendor/node_modules/@legendapp/spark-notifications/package.json +4 -4
  119. package/vendor/node_modules/@legendapp/spark-processes/macos/RNDesktopProcesses.mm +110 -19
  120. package/vendor/node_modules/@legendapp/spark-processes/package.json +4 -4
  121. package/vendor/node_modules/@legendapp/spark-processes/src/index.ts +17 -3
  122. package/vendor/node_modules/@legendapp/spark-processes/src/types.ts +6 -0
  123. package/vendor/node_modules/@legendapp/spark-rich-text/package.json +4 -4
  124. package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +5 -5
  125. package/vendor/node_modules/@legendapp/spark-secure-storage/src/index.macos.ts +1 -0
  126. package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
  127. package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +6 -6
  128. package/vendor/node_modules/@legendapp/spark-sqlite/package.json +12 -5
  129. package/vendor/node_modules/@legendapp/spark-system/package.json +4 -4
  130. package/vendor/node_modules/@legendapp/spark-tray/package.json +4 -4
  131. package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +82 -18
  132. package/vendor/node_modules/@legendapp/spark-ui/package.json +6 -6
  133. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +4 -0
  134. package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +11 -9
  135. package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +20 -10
  136. package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +15 -10
  137. package/vendor/node_modules/@legendapp/spark-ui/src/index.macos.tsx +1 -0
  138. package/vendor/node_modules/@legendapp/spark-updates/package.json +4 -4
  139. package/vendor/node_modules/@legendapp/spark-webview/package.json +11 -4
  140. package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
  141. package/camera.ts +0 -13
@@ -0,0 +1,312 @@
1
+ diff --git a/ios/ExpoImageManipulator.podspec b/ios/ExpoImageManipulator.podspec
2
+ index ea6d6dc..5e9de70 100644
3
+ --- a/ios/ExpoImageManipulator.podspec
4
+ +++ b/ios/ExpoImageManipulator.podspec
5
+ @@ -12,7 +12,8 @@ Pod::Spec.new do |s|
6
+ s.homepage = package['homepage']
7
+ s.platforms = {
8
+ :ios => '15.1',
9
+ - :tvos => '15.1'
10
+ + :tvos => '15.1',
11
+ + :osx => '14.0'
12
+ }
13
+ s.swift_version = '5.9'
14
+ s.source = { git: 'https://github.com/expo/expo.git' }
15
+ diff --git a/ios/ImageManipulatorMacOS.swift b/ios/ImageManipulatorMacOS.swift
16
+ new file mode 100644
17
+ index 0000000..329b05c
18
+ --- /dev/null
19
+ +++ b/ios/ImageManipulatorMacOS.swift
20
+ @@ -0,0 +1,154 @@
21
+ +// Copyright 2024-present 650 Industries. All rights reserved.
22
+ +
23
+ +// macOS: NSImage stands in for UIImage (ExpoModulesCore aliases it), sized in pixels at scale 1.
24
+ +#if os(macOS)
25
+ +import AppKit
26
+ +import ImageIO
27
+ +
28
+ +// Files that don't import ExpoModulesCore don't see its UIImage alias.
29
+ +typealias UIImage = NSImage
30
+ +
31
+ +extension NSImage {
32
+ + // Decoded images are already oriented up, so only `.up` occurs.
33
+ + enum Orientation {
34
+ + case up, down, left, right, upMirrored, downMirrored, leftMirrored, rightMirrored
35
+ + }
36
+ +
37
+ + var imageOrientation: Orientation { .up }
38
+ + var scale: CGFloat { 1 }
39
+ + var cgImage: CGImage? { cgImage(forProposedRect: nil, context: nil, hints: nil) }
40
+ +
41
+ + convenience init(cgImage: CGImage) {
42
+ + self.init(cgImage: cgImage, size: NSSize(width: cgImage.width, height: cgImage.height))
43
+ + }
44
+ +
45
+ + convenience init(cgImage: CGImage, scale: CGFloat, orientation: Orientation) {
46
+ + self.init(cgImage: cgImage)
47
+ + }
48
+ +
49
+ + func jpegData(compressionQuality: CGFloat) -> Data? {
50
+ + cgImage.flatMap { NSBitmapImageRep(cgImage: $0).representation(using: .jpeg, properties: [.compressionFactor: compressionQuality]) }
51
+ + }
52
+ +
53
+ + func pngData() -> Data? {
54
+ + cgImage.flatMap { NSBitmapImageRep(cgImage: $0).representation(using: .png, properties: [:]) }
55
+ + }
56
+ +}
57
+ +
58
+ +// Applies EXIF orientation while decoding, as UIImage(data:) does on iOS.
59
+ +internal func decodeImage(_ data: Data) -> NSImage? {
60
+ + guard let source = CGImageSourceCreateWithData(data as CFData, nil),
61
+ + let properties = CGImageSourceCopyPropertiesAtIndex(source, 0, nil) as? [CFString: Any],
62
+ + let width = properties[kCGImagePropertyPixelWidth] as? Int,
63
+ + let height = properties[kCGImagePropertyPixelHeight] as? Int else {
64
+ + return nil
65
+ + }
66
+ + let options: [CFString: Any] = [
67
+ + kCGImageSourceCreateThumbnailFromImageAlways: true,
68
+ + kCGImageSourceCreateThumbnailWithTransform: true,
69
+ + kCGImageSourceThumbnailMaxPixelSize: max(width, height)
70
+ + ]
71
+ + return CGImageSourceCreateThumbnailAtIndex(source, 0, options as CFDictionary).map { NSImage(cgImage: $0) }
72
+ +}
73
+ +
74
+ +internal func loadImageFromPhotoLibrary(url: URL) async throws -> NSImage {
75
+ + throw ImageNotFoundException()
76
+ +}
77
+ +
78
+ +// Spark's host exports SparkNamespace(); look it up at runtime so this keeps no link dependency on Spark.
79
+ +internal let appNamespace: String = {
80
+ + typealias Namespace = @convention(c) () -> Unmanaged<NSString>
81
+ + if let symbol = dlsym(UnsafeMutableRawPointer(bitPattern: -2), "SparkNamespace") {
82
+ + return unsafeBitCast(symbol, to: Namespace.self)().takeUnretainedValue() as String
83
+ + }
84
+ + return Bundle.main.bundleIdentifier ?? ProcessInfo.processInfo.processName
85
+ +}()
86
+ +
87
+ +// A bitmap context in CoreGraphics' own orientation: origin bottom-left, so CGImages draw upright.
88
+ +private func render(size: CGSize, drawing: (CGContext) -> Void) -> NSImage? {
89
+ + guard let context = CGContext(
90
+ + data: nil,
91
+ + width: Int(size.width),
92
+ + height: Int(size.height),
93
+ + bitsPerComponent: 8,
94
+ + bytesPerRow: 0,
95
+ + space: CGColorSpaceCreateDeviceRGB(),
96
+ + bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
97
+ + ) else {
98
+ + return nil
99
+ + }
100
+ + drawing(context)
101
+ + return context.makeImage().map { NSImage(cgImage: $0) }
102
+ +}
103
+ +
104
+ +extension ImageFlipTransformer {
105
+ + func transform(image: NSImage) async throws -> NSImage {
106
+ + guard let cgImage = image.cgImage else {
107
+ + throw ImageNotFoundException()
108
+ + }
109
+ + let size = CGSize(width: cgImage.width, height: cgImage.height)
110
+ + let flipped = render(size: size) { context in
111
+ + switch flip {
112
+ + case .vertical:
113
+ + context.concatenate(CGAffineTransform(a: 1, b: 0, c: 0, d: -1, tx: 0, ty: size.height))
114
+ + case .horizontal:
115
+ + context.concatenate(CGAffineTransform(a: -1, b: 0, c: 0, d: 1, tx: size.width, ty: 0))
116
+ + }
117
+ + context.draw(cgImage, in: CGRect(origin: .zero, size: size))
118
+ + }
119
+ + guard let flipped else {
120
+ + throw ImageDrawingFailedException()
121
+ + }
122
+ + return flipped
123
+ + }
124
+ +}
125
+ +
126
+ +extension ImageRotateTransformer {
127
+ + func transform(image: NSImage) async throws -> NSImage {
128
+ + guard let cgImage = image.cgImage else {
129
+ + throw ImageNotFoundException()
130
+ + }
131
+ + let rads = rotate * .pi / 180
132
+ + let size = CGSize(width: cgImage.width, height: cgImage.height)
133
+ + let bounds = CGRect(origin: .zero, size: size).applying(CGAffineTransform(rotationAngle: rads))
134
+ + let rotatedSize = CGSize(width: bounds.width.rounded(.down), height: bounds.height.rounded(.down))
135
+ + let rotated = render(size: rotatedSize) { context in
136
+ + context.translateBy(x: rotatedSize.width / 2, y: rotatedSize.height / 2)
137
+ + // Positive angles turn clockwise, as on iOS; CoreGraphics turns counterclockwise.
138
+ + context.rotate(by: -rads)
139
+ + context.draw(cgImage, in: CGRect(origin: CGPoint(x: -size.width / 2, y: -size.height / 2), size: size))
140
+ + }
141
+ + guard let rotated else {
142
+ + throw ImageDrawingFailedException()
143
+ + }
144
+ + return rotated
145
+ + }
146
+ +}
147
+ +
148
+ +extension ImageResizeTransformer {
149
+ + func transform(image: NSImage) async throws -> NSImage {
150
+ + guard let cgImage = image.cgImage else {
151
+ + throw ImageNotFoundException()
152
+ + }
153
+ + let imageRatio = CGFloat(cgImage.width) / CGFloat(cgImage.height)
154
+ + var targetSize = CGSize.zero
155
+ +
156
+ + if let width = options.width {
157
+ + targetSize.width = width
158
+ + targetSize.height = width / imageRatio
159
+ + }
160
+ + if let height = options.height {
161
+ + targetSize.height = height
162
+ + targetSize.width = targetSize.width == 0 ? imageRatio * targetSize.height : targetSize.width
163
+ + }
164
+ + let resized = render(size: targetSize) { context in
165
+ + context.interpolationQuality = .high
166
+ + context.draw(cgImage, in: CGRect(origin: .zero, size: targetSize))
167
+ + }
168
+ + guard let resized else {
169
+ + throw ImageDrawingFailedException()
170
+ + }
171
+ + return resized
172
+ + }
173
+ +}
174
+ +#endif
175
+ diff --git a/ios/ImageManipulatorModule.swift b/ios/ImageManipulatorModule.swift
176
+ index 1f8c73a..ca0588c 100644
177
+ --- a/ios/ImageManipulatorModule.swift
178
+ +++ b/ios/ImageManipulatorModule.swift
179
+ @@ -2,7 +2,9 @@
180
+
181
+ import CoreGraphics
182
+ import Photos
183
+ +#if !os(macOS)
184
+ import UIKit
185
+ +#endif
186
+ import ExpoModulesCore
187
+ internal import SDWebImageWebPCoder
188
+
189
+ diff --git a/ios/ImageManipulatorUtils.swift b/ios/ImageManipulatorUtils.swift
190
+ index 13739d5..b5d1d92 100644
191
+ --- a/ios/ImageManipulatorUtils.swift
192
+ +++ b/ios/ImageManipulatorUtils.swift
193
+ @@ -9,7 +9,7 @@ internal typealias SaveImageResult = (url: URL, data: Data)
194
+ */
195
+ internal func loadImage(atUrl url: URL, appContext: AppContext) async throws -> UIImage {
196
+ if url.scheme == "data" {
197
+ - guard let data = try? Data(contentsOf: url), let image = UIImage(data: data) else {
198
+ + guard let data = try? Data(contentsOf: url), let image = decodeImage(data) else {
199
+ throw CorruptedImageDataException()
200
+ }
201
+ return image
202
+ @@ -35,12 +35,17 @@ internal func loadImage(atUrl url: URL, appContext: AppContext) async throws ->
203
+ }
204
+
205
+ // Read local files directly so UIKit preserves HEIC/EXIF orientation metadata.
206
+ - guard let data = try? Data(contentsOf: url), let image = UIImage(data: data) else {
207
+ + guard let data = try? Data(contentsOf: url), let image = decodeImage(data) else {
208
+ throw FileSystemReadPermissionException(url.absoluteString)
209
+ }
210
+ return image
211
+ }
212
+
213
+ +#if !os(macOS)
214
+ +internal func decodeImage(_ data: Data) -> UIImage? {
215
+ + return UIImage(data: data)
216
+ +}
217
+ +
218
+ /**
219
+ Loads the image from user's photo library.
220
+ */
221
+ @@ -67,6 +72,8 @@ internal func loadImageFromPhotoLibrary(url: URL) async throws -> UIImage {
222
+ }
223
+ }
224
+
225
+ +#endif
226
+ +
227
+ /**
228
+ Returns pixel data representation of the image.
229
+ */
230
+ @@ -81,6 +88,7 @@ func imageData(from image: UIImage, format: ImageFormat, compression: Double) ->
231
+ }
232
+ }
233
+
234
+ +#if !os(macOS)
235
+ /**
236
+ Checks if we are dealing with a ph asset URL and uses the correct method to fetch it.
237
+ */
238
+ @@ -106,6 +114,7 @@ internal func drawInNewContext(size: CGSize, drawing: (UIGraphicsImageRendererCo
239
+ drawing(context)
240
+ }
241
+ }
242
+ +#endif
243
+
244
+ /**
245
+ Saves the image as a file.
246
+ @@ -115,7 +124,12 @@ internal func saveImage(_ image: UIImage, options: ManipulateOptions, appContext
247
+ throw FileSystemNotFoundException()
248
+ }
249
+
250
+ + #if os(macOS)
251
+ + // macOS shares the user's Caches folder between apps, so each app gets its own subfolder.
252
+ + let directory = URL(fileURLWithPath: cachesDirectory.path).appendingPathComponent(appNamespace).appendingPathComponent("ImageManipulator")
253
+ + #else
254
+ let directory = URL(fileURLWithPath: cachesDirectory.path).appendingPathComponent("ImageManipulator")
255
+ + #endif
256
+ let filename = UUID().uuidString.appending(options.format.fileExtension)
257
+ let fileUrl = directory.appendingPathComponent(filename)
258
+
259
+ diff --git a/ios/Transformers/ImageFlipTransformer.swift b/ios/Transformers/ImageFlipTransformer.swift
260
+ index 2272c13..a64a3a8 100644
261
+ --- a/ios/Transformers/ImageFlipTransformer.swift
262
+ +++ b/ios/Transformers/ImageFlipTransformer.swift
263
+ @@ -6,6 +6,7 @@
264
+ internal struct ImageFlipTransformer: ImageTransformer {
265
+ let flip: FlipType
266
+
267
+ +#if !os(macOS)
268
+ @MainActor
269
+ func transform(image: UIImage) async -> UIImage {
270
+ let imageView = UIImageView(image: image)
271
+ @@ -22,4 +23,5 @@ internal struct ImageFlipTransformer: ImageTransformer {
272
+ imageView.layer.render(in: context.cgContext)
273
+ }
274
+ }
275
+ +#endif
276
+ }
277
+ diff --git a/ios/Transformers/ImageResizeTransformer.swift b/ios/Transformers/ImageResizeTransformer.swift
278
+ index e3ef679..1b578a4 100644
279
+ --- a/ios/Transformers/ImageResizeTransformer.swift
280
+ +++ b/ios/Transformers/ImageResizeTransformer.swift
281
+ @@ -6,6 +6,7 @@
282
+ internal struct ImageResizeTransformer: ImageTransformer {
283
+ let options: ResizeOptions
284
+
285
+ +#if !os(macOS)
286
+ func transform(image: UIImage) async -> UIImage {
287
+ let imageWidth = image.size.width
288
+ let imageHeight = image.size.height
289
+ @@ -31,4 +32,5 @@ internal struct ImageResizeTransformer: ImageTransformer {
290
+ image.draw(in: CGRect(origin: .zero, size: targetSize))
291
+ }
292
+ }
293
+ +#endif
294
+ }
295
+ diff --git a/ios/Transformers/ImageRotateTransformer.swift b/ios/Transformers/ImageRotateTransformer.swift
296
+ index 66aa5cb..158eaf0 100644
297
+ --- a/ios/Transformers/ImageRotateTransformer.swift
298
+ +++ b/ios/Transformers/ImageRotateTransformer.swift
299
+ @@ -6,6 +6,7 @@
300
+ internal struct ImageRotateTransformer: ImageTransformer {
301
+ let rotate: Double
302
+
303
+ +#if !os(macOS)
304
+ @MainActor
305
+ func transform(image: UIImage) async throws -> UIImage {
306
+ guard let cgImage = image.cgImage else {
307
+ @@ -27,4 +28,5 @@ internal struct ImageRotateTransformer: ImageTransformer {
308
+ cgContext.draw(cgImage, in: CGRect(origin: origin, size: image.size))
309
+ }
310
+ }
311
+ +#endif
312
+ }
@@ -0,0 +1,327 @@
1
+ diff --git a/ios/ExpoImagePicker.podspec b/ios/ExpoImagePicker.podspec
2
+ index c9bac13..348e96e 100644
3
+ --- a/ios/ExpoImagePicker.podspec
4
+ +++ b/ios/ExpoImagePicker.podspec
5
+ @@ -11,7 +11,8 @@ Pod::Spec.new do |s|
6
+ s.author = package['author']
7
+ s.homepage = package['homepage']
8
+ s.platforms = {
9
+ - :ios => '15.1'
10
+ + :ios => '15.1',
11
+ + :osx => '14.0'
12
+ }
13
+ s.swift_version = '5.9'
14
+ s.source = { git: 'https://github.com/expo/expo.git' }
15
+ diff --git a/ios/ImagePickerExceptions.swift b/ios/ImagePickerExceptions.swift
16
+ index a0810e5..cb6e87c 100644
17
+ --- a/ios/ImagePickerExceptions.swift
18
+ +++ b/ios/ImagePickerExceptions.swift
19
+ @@ -1,3 +1,4 @@
20
+ +#if !os(macOS)
21
+ // Copyright 2022-present 650 Industries. All rights reserved.
22
+
23
+ import ExpoModulesCore
24
+ @@ -139,3 +140,4 @@ internal final class FailedToPickLivePhotoException: Exception {
25
+ "Failed to read the selected item as a live photo"
26
+ }
27
+ }
28
+ +#endif
29
+ diff --git a/ios/ImagePickerHandler.swift b/ios/ImagePickerHandler.swift
30
+ index 476910d..4e1dd8d 100644
31
+ --- a/ios/ImagePickerHandler.swift
32
+ +++ b/ios/ImagePickerHandler.swift
33
+ @@ -1,3 +1,4 @@
34
+ +#if !os(macOS)
35
+ // Copyright 2022-present 650 Industries. All rights reserved.
36
+
37
+ import PhotosUI
38
+ @@ -106,3 +107,4 @@ extension PHPickerViewController: PickerUIController {
39
+ self.presentationController?.delegate = handler
40
+ }
41
+ }
42
+ +#endif
43
+ diff --git a/ios/ImagePickerModule.swift b/ios/ImagePickerModule.swift
44
+ index 4b7bf34..f990a2f 100644
45
+ --- a/ios/ImagePickerModule.swift
46
+ +++ b/ios/ImagePickerModule.swift
47
+ @@ -1,3 +1,4 @@
48
+ +#if !os(macOS)
49
+ // Copyright 2022-present 650 Industries. All rights reserved.
50
+
51
+ import UIKit
52
+ @@ -249,3 +250,4 @@ public class ImagePickerModule: Module, OnMediaPickingResultHandler {
53
+ }
54
+ }
55
+ }
56
+ +#endif
57
+ diff --git a/ios/ImagePickerModuleMacOS.swift b/ios/ImagePickerModuleMacOS.swift
58
+ new file mode 100644
59
+ index 0000000..02df7a3
60
+ --- /dev/null
61
+ +++ b/ios/ImagePickerModuleMacOS.swift
62
+ @@ -0,0 +1,111 @@
63
+ +// Copyright 2022-present 650 Industries. All rights reserved.
64
+ +
65
+ +#if os(macOS)
66
+ +import AppKit
67
+ +import AVFoundation
68
+ +import ExpoModulesCore
69
+ +import UniformTypeIdentifiers
70
+ +
71
+ +// macOS has no photo library or camera picker UI. The library opens an NSOpenPanel on image and
72
+ +// movie files; launchCameraAsync is not defined, so the JavaScript layer reports it unavailable.
73
+ +internal struct MacImagePickerOptions: Record {
74
+ + @Field var mediaTypes: [String] = ["images"]
75
+ + @Field var allowsMultipleSelection: Bool = false
76
+ + @Field var selectionLimit: Int = 0
77
+ + @Field var base64: Bool = false
78
+ +}
79
+ +
80
+ +public class ImagePickerModule: Module {
81
+ + public func definition() -> ModuleDefinition {
82
+ + Name("ExponentImagePicker")
83
+ +
84
+ + AsyncFunction("getCameraPermissionsAsync") { () -> [String: Any] in
85
+ + Self.cameraPermission(AVCaptureDevice.authorizationStatus(for: .video))
86
+ + }
87
+ +
88
+ + AsyncFunction("requestCameraPermissionsAsync") { (promise: Promise) in
89
+ + AVCaptureDevice.requestAccess(for: .video) { _ in
90
+ + promise.resolve(Self.cameraPermission(AVCaptureDevice.authorizationStatus(for: .video)))
91
+ + }
92
+ + }
93
+ +
94
+ + // Files the user picks in the open panel need no library permission.
95
+ + AsyncFunction("getMediaLibraryPermissionsAsync") { (_: Bool) -> [String: Any] in
96
+ + Self.permission("granted", canAskAgain: true, extra: ["accessPrivileges": "all"])
97
+ + }
98
+ +
99
+ + AsyncFunction("requestMediaLibraryPermissionsAsync") { (_: Bool) -> [String: Any] in
100
+ + Self.permission("granted", canAskAgain: true, extra: ["accessPrivileges": "all"])
101
+ + }
102
+ +
103
+ + AsyncFunction("launchImageLibraryAsync") { (options: MacImagePickerOptions, promise: Promise) in
104
+ + let panel = NSOpenPanel()
105
+ + panel.canChooseDirectories = false
106
+ + panel.allowsMultipleSelection = options.allowsMultipleSelection
107
+ + panel.allowedContentTypes = options.mediaTypes.compactMap { type in
108
+ + switch type {
109
+ + case "images", "livePhotos": return UTType.image
110
+ + case "videos": return UTType.movie
111
+ + default: return nil
112
+ + }
113
+ + }
114
+ + let finish = { (response: NSApplication.ModalResponse) in
115
+ + guard response == .OK else {
116
+ + return promise.resolve(["canceled": true, "assets": NSNull()])
117
+ + }
118
+ + let urls = options.selectionLimit > 0 ? Array(panel.urls.prefix(options.selectionLimit)) : panel.urls
119
+ + promise.resolve(["canceled": false, "assets": urls.map { Self.asset($0, base64: options.base64) }])
120
+ + }
121
+ + if let window = NSApp.keyWindow ?? NSApp.mainWindow {
122
+ + panel.beginSheetModal(for: window, completionHandler: finish)
123
+ + } else {
124
+ + panel.begin(completionHandler: finish)
125
+ + }
126
+ + }
127
+ + .runOnQueue(.main)
128
+ + }
129
+ +
130
+ + private static func asset(_ url: URL, base64: Bool) -> [String: Any] {
131
+ + let type = UTType(filenameExtension: url.pathExtension)
132
+ + let isVideo = type?.conforms(to: .movie) ?? false
133
+ + var asset: [String: Any] = [
134
+ + "assetId": NSNull(),
135
+ + "type": isVideo ? "video" : "image",
136
+ + "uri": url.absoluteString,
137
+ + "fileName": url.lastPathComponent,
138
+ + "fileSize": (try? url.resourceValues(forKeys: [.fileSizeKey]).fileSize) ?? NSNull(),
139
+ + "mimeType": type?.preferredMIMEType ?? NSNull(),
140
+ + "exif": NSNull(),
141
+ + "base64": NSNull(),
142
+ + "width": 0,
143
+ + "height": 0
144
+ + ]
145
+ + if isVideo {
146
+ + let track = AVURLAsset(url: url).tracks(withMediaType: .video).first
147
+ + let size = track.map { $0.naturalSize.applying($0.preferredTransform) } ?? .zero
148
+ + asset["width"] = abs(size.width)
149
+ + asset["height"] = abs(size.height)
150
+ + asset["duration"] = AVURLAsset(url: url).duration.seconds * 1000
151
+ + } else if let rep = NSImageRep(contentsOf: url) {
152
+ + asset["width"] = rep.pixelsWide
153
+ + asset["height"] = rep.pixelsHigh
154
+ + if base64, let data = try? Data(contentsOf: url) {
155
+ + asset["base64"] = data.base64EncodedString()
156
+ + }
157
+ + }
158
+ + return asset
159
+ + }
160
+ +
161
+ + private static func cameraPermission(_ status: AVAuthorizationStatus) -> [String: Any] {
162
+ + switch status {
163
+ + case .authorized: return permission("granted", canAskAgain: true)
164
+ + case .notDetermined: return permission("undetermined", canAskAgain: true)
165
+ + default: return permission("denied", canAskAgain: false)
166
+ + }
167
+ + }
168
+ +
169
+ + private static func permission(_ status: String, canAskAgain: Bool, extra: [String: Any] = [:]) -> [String: Any] {
170
+ + ["status": status, "granted": status == "granted", "canAskAgain": canAskAgain, "expires": "never"].merging(extra) { _, new in new }
171
+ + }
172
+ +}
173
+ +#endif
174
+ diff --git a/ios/ImagePickerOptions.swift b/ios/ImagePickerOptions.swift
175
+ index bdaf98f..e945b97 100644
176
+ --- a/ios/ImagePickerOptions.swift
177
+ +++ b/ios/ImagePickerOptions.swift
178
+ @@ -1,3 +1,4 @@
179
+ +#if !os(macOS)
180
+ // Copyright 2022-present 650 Industries. All rights reserved.
181
+
182
+ import ExpoModulesCore
183
+ @@ -257,3 +258,4 @@ internal enum CameraType: String, Enumerable {
184
+ case back
185
+ case front
186
+ }
187
+ +#endif
188
+ diff --git a/ios/ImagePickerPermissionRequesters.swift b/ios/ImagePickerPermissionRequesters.swift
189
+ index ad92115..2679aaf 100644
190
+ --- a/ios/ImagePickerPermissionRequesters.swift
191
+ +++ b/ios/ImagePickerPermissionRequesters.swift
192
+ @@ -1,3 +1,4 @@
193
+ +#if !os(macOS)
194
+ // Copyright 2022-present 650 Industries. All rights reserved.
195
+
196
+ import Photos
197
+ @@ -122,3 +123,4 @@ extension DefaultMediaLibraryPermissionRequester {
198
+ return PHAccessLevel.readWrite
199
+ }
200
+ }
201
+ +#endif
202
+ diff --git a/ios/ImagePickerResponse.swift b/ios/ImagePickerResponse.swift
203
+ index 21b9bb1..3e693bf 100644
204
+ --- a/ios/ImagePickerResponse.swift
205
+ +++ b/ios/ImagePickerResponse.swift
206
+ @@ -1,3 +1,4 @@
207
+ +#if !os(macOS)
208
+ // Copyright 2022-present 650 Industries. All rights reserved.
209
+
210
+ // swiftlint:disable redundant_optional_initialization
211
+ @@ -41,3 +42,4 @@ internal struct AssetInfo: Record {
212
+ @Field var duration: Double? = nil
213
+ @Field var pairedVideoAsset: AssetInfo? = nil
214
+ }
215
+ +#endif
216
+ diff --git a/ios/ImagePickerUtils.swift b/ios/ImagePickerUtils.swift
217
+ index cfd0bcb..eb76f4c 100644
218
+ --- a/ios/ImagePickerUtils.swift
219
+ +++ b/ios/ImagePickerUtils.swift
220
+ @@ -1,3 +1,4 @@
221
+ +#if !os(macOS)
222
+ // Copyright 2024-present 650 Industries. All rights reserved.
223
+
224
+ /**
225
+ @@ -14,3 +15,4 @@ func asyncMap<ItemsType: Sequence, ResultType>(
226
+ }
227
+ return values
228
+ }
229
+ +#endif
230
+ diff --git a/ios/ImageUtils.swift b/ios/ImageUtils.swift
231
+ index d9d1cd4..f09532f 100644
232
+ --- a/ios/ImageUtils.swift
233
+ +++ b/ios/ImageUtils.swift
234
+ @@ -1,3 +1,4 @@
235
+ +#if !os(macOS)
236
+ // Copyright 2024-present 650 Industries. All rights reserved.
237
+
238
+ import CoreGraphics
239
+ @@ -390,3 +391,4 @@ internal struct ImageUtils {
240
+ return CGSize(width: width, height: height)
241
+ }
242
+ }
243
+ +#endif
244
+ diff --git a/ios/MediaHandler.swift b/ios/MediaHandler.swift
245
+ index a0e3a44..e11aec4 100644
246
+ --- a/ios/MediaHandler.swift
247
+ +++ b/ios/MediaHandler.swift
248
+ @@ -1,3 +1,4 @@
249
+ +#if !os(macOS)
250
+ // Copyright 2022-present 650 Industries. All rights reserved.
251
+
252
+ import ExpoModulesCore
253
+ @@ -564,3 +565,4 @@ extension PHAssetResourceManager {
254
+ }
255
+ }
256
+ }
257
+ +#endif
258
+ diff --git a/ios/NSItemProvider+Async.swift b/ios/NSItemProvider+Async.swift
259
+ index 08cdf4c..83b2542 100644
260
+ --- a/ios/NSItemProvider+Async.swift
261
+ +++ b/ios/NSItemProvider+Async.swift
262
+ @@ -1,3 +1,4 @@
263
+ +#if !os(macOS)
264
+ import Foundation
265
+ import Photos
266
+
267
+ @@ -30,3 +31,4 @@ internal extension NSItemProvider {
268
+ }
269
+ }
270
+ }
271
+ +#endif
272
+ diff --git a/ios/StatusBarVisibilityController.swift b/ios/StatusBarVisibilityController.swift
273
+ index 907af58..61cce12 100644
274
+ --- a/ios/StatusBarVisibilityController.swift
275
+ +++ b/ios/StatusBarVisibilityController.swift
276
+ @@ -1,3 +1,4 @@
277
+ +#if !os(macOS)
278
+ // Copyright 2022-present 650 Industries. All rights reserved.
279
+
280
+ /**
281
+ @@ -50,3 +51,4 @@ internal class StatusBarVisibilityController {
282
+ // prints "Hello Fabio!"
283
+ }
284
+ }
285
+ +#endif
286
+ diff --git a/ios/UIImage+fixOrientation.swift b/ios/UIImage+fixOrientation.swift
287
+ index 22849c2..d005706 100644
288
+ --- a/ios/UIImage+fixOrientation.swift
289
+ +++ b/ios/UIImage+fixOrientation.swift
290
+ @@ -1,3 +1,4 @@
291
+ +#if !os(macOS)
292
+ // Copyright 2022-present 650 Industries. All rights reserved.
293
+
294
+ import UIKit
295
+ @@ -78,3 +79,4 @@ extension UIImage {
296
+ return UIImage(cgImage: resultCgImage)
297
+ }
298
+ }
299
+ +#endif
300
+ diff --git a/ios/UIImagePickerControllerExtentsion.swift b/ios/UIImagePickerControllerExtentsion.swift
301
+ index 865a59d..9b3ee35 100644
302
+ --- a/ios/UIImagePickerControllerExtentsion.swift
303
+ +++ b/ios/UIImagePickerControllerExtentsion.swift
304
+ @@ -1,3 +1,4 @@
305
+ +#if !os(macOS)
306
+ // Copyright 2016-present 650 Industries. All rights reserved.
307
+
308
+ extension UIImagePickerController {
309
+ @@ -55,3 +56,4 @@ extension UIImagePickerController {
310
+ return nil
311
+ }
312
+ }
313
+ +#endif
314
+ diff --git a/ios/VideoUtils.swift b/ios/VideoUtils.swift
315
+ index f78c50d..2b88d16 100644
316
+ --- a/ios/VideoUtils.swift
317
+ +++ b/ios/VideoUtils.swift
318
+ @@ -1,3 +1,4 @@
319
+ +#if !os(macOS)
320
+ // Copyright 2024-present 650 Industries. All rights reserved.
321
+
322
+ import AVFoundation
323
+ @@ -97,3 +98,4 @@ internal struct VideoUtils {
324
+ }
325
+ }
326
+ }
327
+ +#endif