@hortemo/expo-photos 12.0.0 → 13.0.1

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/README.md CHANGED
@@ -18,7 +18,7 @@ npm install @hortemo/expo-photos
18
18
  - `pickAssets(options: PickAssetsOptions): Promise<PHAsset[]>`
19
19
  - `authorizationStatus(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>`
20
20
  - `requestAuthorization(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>`
21
- - `presentLimitedLibraryPicker(): Promise<void>`
21
+ - `presentLimitedLibraryPicker(): Promise<string[]>`
22
22
 
23
23
  ### Components
24
24
 
@@ -7,7 +7,8 @@ export declare class ExpoPhotosModule extends NativeModule {
7
7
  pickAssets(options: PickAssetsOptions): Promise<PHAsset[]>;
8
8
  authorizationStatus(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>;
9
9
  requestAuthorization(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>;
10
- presentLimitedLibraryPicker(): Promise<void>;
10
+ /** Resolves with newly selected local identifiers once the picker closes. */
11
+ presentLimitedLibraryPicker(): Promise<string[]>;
11
12
  }
12
13
  declare const _default: ExpoPhotosModule;
13
14
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoPhotosModule.d.ts","sourceRoot":"","sources":["../src/ExpoPhotosModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,YAAY;IACxD,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5D,YAAY,CAAC,OAAO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AM,EAAE,CAAC;CACjD;;AAED,wBAAmE"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoPhotosModule.js","sourceRoot":"","sources":["../src/ExpoPhotosModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAsBtE,eAAe,mBAAmB,CAAmB,YAAY,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo-modules-core\";\nimport type {\n FetchAssetsOptions,\n PHAuthorizationStatus,\n PHAccessLevel,\n PHAsset,\n PickAssetsOptions,\n RequestImageOptions,\n RequestVideoOptions,\n RequestImageResult,\n} from \"./ExpoPhotos.types\";\n\nexport declare class ExpoPhotosModule extends NativeModule {\n fetchAssets(options: FetchAssetsOptions): Promise<PHAsset[]>;\n requestImage(options: RequestImageOptions): Promise<RequestImageResult>;\n requestVideo(options: RequestVideoOptions): Promise<void>;\n pickAssets(options: PickAssetsOptions): Promise<PHAsset[]>;\n authorizationStatus(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>;\n requestAuthorization(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>;\n presentLimitedLibraryPicker(): Promise<void>;\n}\n\nexport default requireNativeModule<ExpoPhotosModule>(\"ExpoPhotos\");\n"]}
1
+ {"version":3,"file":"ExpoPhotosModule.js","sourceRoot":"","sources":["../src/ExpoPhotosModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAuBtE,eAAe,mBAAmB,CAAmB,YAAY,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo-modules-core\";\nimport type {\n FetchAssetsOptions,\n PHAuthorizationStatus,\n PHAccessLevel,\n PHAsset,\n PickAssetsOptions,\n RequestImageOptions,\n RequestVideoOptions,\n RequestImageResult,\n} from \"./ExpoPhotos.types\";\n\nexport declare class ExpoPhotosModule extends NativeModule {\n fetchAssets(options: FetchAssetsOptions): Promise<PHAsset[]>;\n requestImage(options: RequestImageOptions): Promise<RequestImageResult>;\n requestVideo(options: RequestVideoOptions): Promise<void>;\n pickAssets(options: PickAssetsOptions): Promise<PHAsset[]>;\n authorizationStatus(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>;\n requestAuthorization(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>;\n /** Resolves with newly selected local identifiers once the picker closes. */\n presentLimitedLibraryPicker(): Promise<string[]>;\n}\n\nexport default requireNativeModule<ExpoPhotosModule>(\"ExpoPhotos\");\n"]}
@@ -263,12 +263,22 @@ public final class ExpoPhotos: Module {
263
263
  }
264
264
  }
265
265
 
266
- AsyncFunction("presentLimitedLibraryPicker") { () async throws -> Void in
267
- try await MainActor.run {
268
- guard let viewController = self.appContext?.utilities?.currentViewController() else {
269
- throw ExpoPhotosError.noViewController
266
+ AsyncFunction("presentLimitedLibraryPicker") { () async throws -> [String] in
267
+ // Without limited access, the picker neither shows nor completes
268
+ guard PHPhotoLibrary.authorizationStatus(for: .readWrite) == .limited else {
269
+ return []
270
+ }
271
+
272
+ return try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<[String], Error>) in
273
+ Task { @MainActor in
274
+ guard let viewController = self.appContext?.utilities?.currentViewController() else {
275
+ continuation.resume(throwing: ExpoPhotosError.noViewController)
276
+ return
277
+ }
278
+ PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: viewController) { localIdentifiers in
279
+ continuation.resume(returning: localIdentifiers)
280
+ }
270
281
  }
271
- PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: viewController)
272
282
  }
273
283
  }
274
284
 
@@ -466,7 +476,8 @@ struct TargetSize: Convertible {
466
476
  extension Convertible where Self: RawRepresentable, Self.RawValue == Int {
467
477
  public static func convert(from value: Any?, appContext: AppContext) throws -> Self {
468
478
  guard
469
- let rawValue = value as? Int,
479
+ let number = value as? Double,
480
+ let rawValue = Int(exactly: number),
470
481
  let enumValue = Self(rawValue: rawValue)
471
482
  else {
472
483
  throw Conversions.ConvertingException<Self>(value)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hortemo/expo-photos",
3
- "version": "12.0.0",
3
+ "version": "13.0.1",
4
4
  "description": "Expo module exposing advanced iOS Photos APIs.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -17,7 +17,8 @@ export declare class ExpoPhotosModule extends NativeModule {
17
17
  pickAssets(options: PickAssetsOptions): Promise<PHAsset[]>;
18
18
  authorizationStatus(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>;
19
19
  requestAuthorization(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>;
20
- presentLimitedLibraryPicker(): Promise<void>;
20
+ /** Resolves with newly selected local identifiers once the picker closes. */
21
+ presentLimitedLibraryPicker(): Promise<string[]>;
21
22
  }
22
23
 
23
24
  export default requireNativeModule<ExpoPhotosModule>("ExpoPhotos");