@legendapp/spark 0.0.2 → 0.0.4
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.
- package/init-template.cjs +7 -1
- package/package.json +10 -5
- package/patches/dependencies.json +252 -0
- package/patches/expo-application@55.0.19.patch +54 -0
- package/patches/expo-blur@55.0.18.patch +130 -0
- package/patches/expo-device@55.0.21.patch +149 -0
- package/patches/expo-font@55.0.8.patch +55 -0
- package/patches/expo-glass-effect@55.0.11.patch +304 -0
- package/patches/expo-haptics@55.0.18.patch +54 -0
- package/patches/expo-image-manipulator@55.0.21.patch +312 -0
- package/patches/expo-image-picker@55.0.24.patch +327 -0
- package/patches/expo-image@55.0.11.patch +158 -0
- package/patches/expo-keep-awake@55.0.8.patch +41 -0
- package/patches/expo-localization@55.0.19.patch +32 -0
- package/patches/expo-location@55.1.15.patch +190 -0
- package/patches/expo-symbols@55.0.9.patch +286 -0
- package/patches/expo-system-ui@55.0.22.patch +61 -0
- package/patches/expo-web-browser@55.0.20.patch +13 -0
- package/patches/react-native-app-logs@0.3.1.patch +20 -0
- package/patches/react-native-blurhash@2.1.3.patch +318 -0
- package/patches/react-native-community-blur@4.4.1.patch +415 -0
- package/patches/react-native-community-datetimepicker@9.2.2.patch +320 -0
- package/patches/react-native-fast-image@10.9.9.patch +131 -0
- package/patches/react-native-graph@1.4.0.patch +157 -0
- package/patches/react-native-keyboard-controller@1.22.9.patch +16 -0
- package/patches/react-native-masked-view-masked-view@0.3.2.patch +140 -0
- package/patches/react-native-mmkv@4.3.2.patch +40 -0
- package/patches/react-native-nitro-fetch@1.9.0.patch +130 -0
- package/patches/react-native-nitro-zxing@0.3.0.patch +13 -0
- package/patches/react-native-nitro-zxing@0.3.1.patch +22 -0
- package/patches/react-native-quick-base64@3.0.1.patch +13 -0
- package/patches/react-native-quick-crypto@1.1.9.patch +31 -0
- package/patches/react-native-release-profiler@0.4.5.patch +37 -0
- package/patches/react-native-screen-corner-radius@0.2.3.patch +13 -0
- package/patches/react-native-screens@4.23.0.patch +160 -0
- package/patches/react-native-svg@15.15.3.patch +31 -0
- package/patches/react-native-unistyles@3.6.0.patch +203 -0
- package/patches/react-native-worklets-core@1.6.3.patch +13 -0
- package/patches/react-navigation-native-stack@7.21.0.patch +16 -0
- package/patches/registry.json +615 -0
- package/patches/sentry-react-native@8.32.0.patch +76 -0
- package/patches/workspace/expo-audio@55.0.18.patch +159 -0
- package/patches/workspace/op-engineering-op-sqlite@18.2.1.patch +796 -0
- package/patches/workspace/react-native-nitro-modules@0.37.0.patch +1348 -0
- package/patches/workspace/react-native-runtimes-core@0.1.0-alpha.2.patch +276 -0
- package/patches/workspace/react-native-webview@16.0.0.patch +208 -0
- package/postinstall.cjs +10 -1
- package/skills/spark/SKILL.md +37 -4
- package/skills/spark/UPGRADING.md +150 -1
- package/skills/spark/ai-customize.md +39 -0
- package/skills/spark/app-and-documents.md +56 -0
- package/skills/spark/external-libraries.md +87 -0
- package/skills/spark/files.md +64 -0
- package/skills/spark/integrations.md +69 -0
- package/skills/spark/keyboard.md +54 -0
- package/skills/spark/library-compat.md +76 -0
- package/skills/spark/menus-tray-dock.md +83 -0
- package/skills/spark/storage-settings.md +85 -0
- package/skills/spark/ui.md +57 -0
- package/skills/spark/windows.md +91 -0
- package/ui-popover.ts +1 -0
- package/ui-progress.ts +1 -0
- package/ui-sheet.ts +1 -0
- package/ui-split-view.ts +1 -0
- package/ui-table.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-audio/package.json +3 -13
- package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +5 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +139 -104
- package/vendor/node_modules/@legendapp/spark-cli/dist/cli-arguments.js +4 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/commands.js +16 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/dependency-pins.js +19 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev-command.js +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/dev.js +10 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/enriched-html-pins.js +2 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/errors.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/index.js +57 -9
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +12 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.d.cts +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/metro.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrate.js +65 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.cjs +4 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/migration-helpers.d.cts +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/dist/migrations.cjs +15 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/native-patch-preflight.js +35 -7
- package/vendor/node_modules/@legendapp/spark-cli/dist/patch.js +92 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project-version.js +12 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +20 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +20 -20
- package/vendor/node_modules/@legendapp/spark-cli/dist/runtime-input-cache.js +140 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/upgrade.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +3 -0
- package/vendor/node_modules/@legendapp/spark-cli/package.json +5 -4
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-clipboard/macos/RNDesktopClipboard.mm +1 -1
- package/vendor/node_modules/@legendapp/spark-clipboard/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-clipboard/src/desktop.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-codex/package.json +3 -7
- package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
- package/vendor/node_modules/@legendapp/spark-context-menu/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +3 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +51 -10
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.h +4 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkStorage.mm +82 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +64 -2
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +2 -8
- package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +3 -2
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +6 -8
- package/vendor/node_modules/@legendapp/spark-desktop-config/identity.cjs +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.cjs +315 -68
- package/vendor/node_modules/@legendapp/spark-desktop-config/native-patches.d.cts +7 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.cjs +318 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/patch-registry.d.cts +20 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +66 -9
- package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +1 -0
- package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +7 -2
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +235 -240
- package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +4 -11
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/api.ts +9 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/macos-adapter.ts +7 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/types.ts +32 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/validation.ts +28 -11
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/createWindowsNavigator.tsx +15 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/primaryWindowLifecycle.ts +12 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/usePrimaryWindowLifecycle.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-desktop-windows/src/windows/useWindowFocusEffect.ts +4 -1
- package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
- package/vendor/node_modules/@legendapp/spark-drag-drop/macos/RNDesktopDragView.mm +77 -17
- package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +3 -8
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/DesktopDragViewNativeComponent.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/contracts.ts +13 -4
- package/vendor/node_modules/@legendapp/spark-drag-drop/src/index.tsx +5 -3
- package/vendor/node_modules/@legendapp/spark-drag-drop/windows/SparkDragDrop/SparkDragDrop.h +6 -1
- package/vendor/node_modules/@legendapp/spark-expo-compat/metro.cjs +44 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/package.json +20 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/src/clipboard.ts +40 -0
- package/vendor/node_modules/@legendapp/spark-expo-compat/src/document-picker.ts +52 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +5 -2
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +3 -3
- package/vendor/node_modules/@legendapp/spark-file-system/macos/RNDesktopFileSystem.mm +1 -1
- package/vendor/node_modules/@legendapp/spark-file-system/package.json +3 -11
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +1 -0
- package/vendor/node_modules/@legendapp/spark-native-menu/package.json +3 -9
- package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +4 -0
- package/vendor/node_modules/@legendapp/spark-notifications/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-processes/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-system/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-tray/package.json +3 -10
- package/vendor/node_modules/@legendapp/spark-tray/src/index.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +82 -14
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.h +1 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +94 -11
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +235 -18
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.h +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkPaneSplitView.mm +216 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.h +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewComponent.mm +212 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSparkSplitViewUpdates.h +6 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +26 -13
- package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/popover/RNSparkPopover.mm +126 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/progress/RNSparkProgressIndicator.mm +66 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/radio-group/RNSparkRadioGroup.mm +118 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -12
- package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sheet/RNSparkSheet.mm +109 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +418 -102
- package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.h +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/table/RNSparkTable.mm +179 -0
- package/vendor/node_modules/@legendapp/spark-ui/package.json +9 -8
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkButtonNativeComponent.ts +10 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/SparkTextInputNativeComponent.ts +2 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SidebarSplitViewNativeComponent.ts +9 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitView.tsx +99 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/SplitViewNativeComponent.ts +29 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/appkit-split-view/index.tsx +34 -17
- package/vendor/node_modules/@legendapp/spark-ui/src/availability.ts +5 -4
- package/vendor/node_modules/@legendapp/spark-ui/src/checkbox-unavailable.tsx +20 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/control.ts +24 -3
- package/vendor/node_modules/@legendapp/spark-ui/src/desktop.tsx +63 -13
- package/vendor/node_modules/@legendapp/spark-ui/src/index.android.tsx +12 -7
- package/vendor/node_modules/@legendapp/spark-ui/src/index.ios.tsx +12 -7
- package/vendor/node_modules/@legendapp/spark-ui/src/index.web.tsx +35 -13
- package/vendor/node_modules/@legendapp/spark-ui/src/mobile-input.tsx +2 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/native-select/NativeSegmentedControlNativeComponent.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/popover/PopoverNativeComponent.ts +20 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/popover/index.tsx +45 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/progress/ProgressIndicatorNativeComponent.ts +13 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/progress/index.tsx +32 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/radio-group/RadioGroupNativeComponent.ts +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sheet/SheetNativeComponent.ts +15 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sheet/index.tsx +38 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarItemNativeComponent.ts +9 -1
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +17 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +106 -22
- package/vendor/node_modules/@legendapp/spark-ui/src/table/TableNativeComponent.ts +22 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/table/index.tsx +118 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/types.ts +39 -6
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.ts +3 -1
- package/vendor/node_modules/@legendapp/spark-ui/uniwind.web.ts +2 -1
- package/vendor/node_modules/@legendapp/spark-ui/windows/SparkUI/SparkUI.h +46 -15
- package/vendor/node_modules/@legendapp/spark-updates/package.json +3 -9
- package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
|
@@ -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
|