@hortemo/expo-photos 7.0.0 → 9.0.0
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 +36 -6
- package/build/ExpoPhotos.types.d.ts +39 -24
- package/build/ExpoPhotos.types.d.ts.map +1 -1
- package/build/ExpoPhotos.types.js +40 -24
- package/build/ExpoPhotos.types.js.map +1 -1
- package/build/PHImage.d.ts +29 -0
- package/build/PHImage.d.ts.map +1 -0
- package/build/PHImage.js +6 -0
- package/build/PHImage.js.map +1 -0
- package/build/PHVideo.d.ts +5 -2
- package/build/PHVideo.d.ts.map +1 -1
- package/build/PHVideo.js +2 -2
- package/build/PHVideo.js.map +1 -1
- package/build/index.d.ts +4 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/ios/ExpoPhotos.podspec +1 -2
- package/ios/ExpoPhotosModule.swift +34 -0
- package/ios/PHImageView.swift +152 -0
- package/package.json +1 -11
- package/src/ExpoPhotos.types.ts +41 -28
- package/src/PHImage.tsx +50 -0
- package/src/PHVideo.tsx +12 -3
- package/src/index.ts +4 -4
- package/build/PHImageSource.d.ts +0 -32
- package/build/PHImageSource.d.ts.map +0 -1
- package/build/PHImageSource.js +0 -46
- package/build/PHImageSource.js.map +0 -1
- package/ios/ExpoPhotosImageLoader.m +0 -8
- package/ios/ExpoPhotosImageLoader.swift +0 -187
- package/src/PHImageSource.tsx +0 -86
package/README.md
CHANGED
|
@@ -19,21 +19,51 @@ npm install @hortemo/expo-photos
|
|
|
19
19
|
- `authorizationStatus(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>`
|
|
20
20
|
- `requestAuthorization(accessLevel: PHAccessLevel): Promise<PHAuthorizationStatus>`
|
|
21
21
|
- `presentLimitedLibraryPicker(): Promise<void>`
|
|
22
|
-
- `createPHImageSource(options: PHImageSourceOptions): ImageSourcePropType | undefined`
|
|
23
22
|
|
|
24
23
|
### Components
|
|
25
24
|
|
|
26
|
-
####
|
|
25
|
+
#### PHImageView
|
|
26
|
+
|
|
27
|
+
A native image component that displays photos from the Photos library using `PHImageManager`.
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import {
|
|
31
|
+
PHImageView,
|
|
32
|
+
PHImageContentMode,
|
|
33
|
+
PHImageRequestOptionsResizeMode,
|
|
34
|
+
PHImageRequestOptionsDeliveryMode,
|
|
35
|
+
UIViewContentMode,
|
|
36
|
+
} from "@hortemo/expo-photos";
|
|
37
|
+
|
|
38
|
+
<PHImageView
|
|
39
|
+
localIdentifier={asset.localIdentifier}
|
|
40
|
+
contentMode={UIViewContentMode.scaleAspectFill}
|
|
41
|
+
requestOptions={{
|
|
42
|
+
contentMode: PHImageContentMode.aspectFit,
|
|
43
|
+
resizeMode: PHImageRequestOptionsResizeMode.fast,
|
|
44
|
+
deliveryMode: PHImageRequestOptionsDeliveryMode.highQualityFormat,
|
|
45
|
+
targetSize: { width: 300, height: 300 },
|
|
46
|
+
isNetworkAccessAllowed: true,
|
|
47
|
+
}}
|
|
48
|
+
onLoad={(event) => console.log(event.nativeEvent)}
|
|
49
|
+
onError={(event) => console.log(event.nativeEvent.message)}
|
|
50
|
+
style={{ width: 300, height: 300 }}
|
|
51
|
+
/>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### PHVideoView
|
|
27
55
|
|
|
28
56
|
A video player component that streams videos from the library.
|
|
29
57
|
|
|
30
58
|
```tsx
|
|
31
|
-
import {
|
|
59
|
+
import { PHVideoView, PHVideoRequestOptionsDeliveryMode } from "@hortemo/expo-photos";
|
|
32
60
|
|
|
33
|
-
<
|
|
61
|
+
<PHVideoView
|
|
34
62
|
localIdentifier={asset.localIdentifier}
|
|
35
|
-
|
|
36
|
-
|
|
63
|
+
requestOptions={{
|
|
64
|
+
isNetworkAccessAllowed: true,
|
|
65
|
+
deliveryMode: PHVideoRequestOptionsDeliveryMode.automatic,
|
|
66
|
+
}}
|
|
37
67
|
onLoad={(event) => console.log(event.nativeEvent)}
|
|
38
68
|
onError={(event) => console.log(event.nativeEvent.message)}
|
|
39
69
|
style={{ width: 300, height: 200 }}
|
|
@@ -19,22 +19,22 @@ export declare enum PHAccessLevel {
|
|
|
19
19
|
readWrite = 2
|
|
20
20
|
}
|
|
21
21
|
export declare enum PHAssetMediaType {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
unknown = 0,
|
|
23
|
+
image = 1,
|
|
24
|
+
video = 2,
|
|
25
|
+
audio = 3
|
|
26
26
|
}
|
|
27
27
|
export declare enum PHAssetMediaSubtype {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
none = 0,
|
|
29
|
+
photoPanorama = 1,
|
|
30
|
+
photoHDR = 2,
|
|
31
|
+
photoScreenshot = 4,
|
|
32
|
+
photoLive = 8,
|
|
33
|
+
photoDepthEffect = 16,
|
|
34
|
+
videoStreamed = 65536,
|
|
35
|
+
videoHighFrameRate = 131072,
|
|
36
|
+
videoTimelapse = 262144,
|
|
37
|
+
videoCinematic = 524288
|
|
38
38
|
}
|
|
39
39
|
export interface NSSortDescriptor {
|
|
40
40
|
key: string;
|
|
@@ -53,19 +53,34 @@ export interface CGSize {
|
|
|
53
53
|
export type PHImageManagerMaximumSize = "PHImageManagerMaximumSize";
|
|
54
54
|
export type RequestImageTargetSize = CGSize | PHImageManagerMaximumSize;
|
|
55
55
|
export declare enum PHImageRequestOptionsResizeMode {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
none = 0,
|
|
57
|
+
fast = 1,
|
|
58
|
+
exact = 2
|
|
59
59
|
}
|
|
60
60
|
export declare enum PHImageRequestOptionsDeliveryMode {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
opportunistic = 0,
|
|
62
|
+
highQualityFormat = 1,
|
|
63
|
+
fastFormat = 2
|
|
64
64
|
}
|
|
65
65
|
export declare enum PHImageContentMode {
|
|
66
66
|
aspectFit = 0,
|
|
67
67
|
aspectFill = 1
|
|
68
68
|
}
|
|
69
|
+
export declare enum UIViewContentMode {
|
|
70
|
+
scaleToFill = 0,
|
|
71
|
+
scaleAspectFit = 1,
|
|
72
|
+
scaleAspectFill = 2,
|
|
73
|
+
redraw = 3,
|
|
74
|
+
center = 4,
|
|
75
|
+
top = 5,
|
|
76
|
+
bottom = 6,
|
|
77
|
+
left = 7,
|
|
78
|
+
right = 8,
|
|
79
|
+
topLeft = 9,
|
|
80
|
+
topRight = 10,
|
|
81
|
+
bottomLeft = 11,
|
|
82
|
+
bottomRight = 12
|
|
83
|
+
}
|
|
69
84
|
export interface PHImageRequestOptions {
|
|
70
85
|
isNetworkAccessAllowed?: boolean;
|
|
71
86
|
resizeMode?: PHImageRequestOptionsResizeMode;
|
|
@@ -76,10 +91,10 @@ export interface SDImageCoderOptions {
|
|
|
76
91
|
encodeMaxFileSize?: number;
|
|
77
92
|
}
|
|
78
93
|
export declare enum PHVideoRequestOptionsDeliveryMode {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
94
|
+
automatic = 0,
|
|
95
|
+
highQualityFormat = 1,
|
|
96
|
+
mediumQualityFormat = 2,
|
|
97
|
+
fastFormat = 3
|
|
83
98
|
}
|
|
84
99
|
export interface PHVideoRequestOptions {
|
|
85
100
|
isNetworkAccessAllowed?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoPhotos.types.d.ts","sourceRoot":"","sources":["../src/ExpoPhotos.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,aAAa,EAAE,mBAAmB,CAAC;IACnC,QAAQ,EAAE,MAAM,CA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M,WAAW;IACjB,GAAG,QAAQ;CACZ;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -13,47 +13,63 @@ export var PHAccessLevel;
|
|
|
13
13
|
})(PHAccessLevel || (PHAccessLevel = {}));
|
|
14
14
|
export var PHAssetMediaType;
|
|
15
15
|
(function (PHAssetMediaType) {
|
|
16
|
-
PHAssetMediaType[PHAssetMediaType["
|
|
17
|
-
PHAssetMediaType[PHAssetMediaType["
|
|
18
|
-
PHAssetMediaType[PHAssetMediaType["
|
|
19
|
-
PHAssetMediaType[PHAssetMediaType["
|
|
16
|
+
PHAssetMediaType[PHAssetMediaType["unknown"] = 0] = "unknown";
|
|
17
|
+
PHAssetMediaType[PHAssetMediaType["image"] = 1] = "image";
|
|
18
|
+
PHAssetMediaType[PHAssetMediaType["video"] = 2] = "video";
|
|
19
|
+
PHAssetMediaType[PHAssetMediaType["audio"] = 3] = "audio";
|
|
20
20
|
})(PHAssetMediaType || (PHAssetMediaType = {}));
|
|
21
21
|
export var PHAssetMediaSubtype;
|
|
22
22
|
(function (PHAssetMediaSubtype) {
|
|
23
|
-
PHAssetMediaSubtype[PHAssetMediaSubtype["
|
|
24
|
-
PHAssetMediaSubtype[PHAssetMediaSubtype["
|
|
25
|
-
PHAssetMediaSubtype[PHAssetMediaSubtype["
|
|
26
|
-
PHAssetMediaSubtype[PHAssetMediaSubtype["
|
|
27
|
-
PHAssetMediaSubtype[PHAssetMediaSubtype["
|
|
28
|
-
PHAssetMediaSubtype[PHAssetMediaSubtype["
|
|
29
|
-
PHAssetMediaSubtype[PHAssetMediaSubtype["
|
|
30
|
-
PHAssetMediaSubtype[PHAssetMediaSubtype["
|
|
31
|
-
PHAssetMediaSubtype[PHAssetMediaSubtype["
|
|
32
|
-
PHAssetMediaSubtype[PHAssetMediaSubtype["
|
|
23
|
+
PHAssetMediaSubtype[PHAssetMediaSubtype["none"] = 0] = "none";
|
|
24
|
+
PHAssetMediaSubtype[PHAssetMediaSubtype["photoPanorama"] = 1] = "photoPanorama";
|
|
25
|
+
PHAssetMediaSubtype[PHAssetMediaSubtype["photoHDR"] = 2] = "photoHDR";
|
|
26
|
+
PHAssetMediaSubtype[PHAssetMediaSubtype["photoScreenshot"] = 4] = "photoScreenshot";
|
|
27
|
+
PHAssetMediaSubtype[PHAssetMediaSubtype["photoLive"] = 8] = "photoLive";
|
|
28
|
+
PHAssetMediaSubtype[PHAssetMediaSubtype["photoDepthEffect"] = 16] = "photoDepthEffect";
|
|
29
|
+
PHAssetMediaSubtype[PHAssetMediaSubtype["videoStreamed"] = 65536] = "videoStreamed";
|
|
30
|
+
PHAssetMediaSubtype[PHAssetMediaSubtype["videoHighFrameRate"] = 131072] = "videoHighFrameRate";
|
|
31
|
+
PHAssetMediaSubtype[PHAssetMediaSubtype["videoTimelapse"] = 262144] = "videoTimelapse";
|
|
32
|
+
PHAssetMediaSubtype[PHAssetMediaSubtype["videoCinematic"] = 524288] = "videoCinematic";
|
|
33
33
|
})(PHAssetMediaSubtype || (PHAssetMediaSubtype = {}));
|
|
34
34
|
export var PHImageRequestOptionsResizeMode;
|
|
35
35
|
(function (PHImageRequestOptionsResizeMode) {
|
|
36
|
-
PHImageRequestOptionsResizeMode[PHImageRequestOptionsResizeMode["
|
|
37
|
-
PHImageRequestOptionsResizeMode[PHImageRequestOptionsResizeMode["
|
|
38
|
-
PHImageRequestOptionsResizeMode[PHImageRequestOptionsResizeMode["
|
|
36
|
+
PHImageRequestOptionsResizeMode[PHImageRequestOptionsResizeMode["none"] = 0] = "none";
|
|
37
|
+
PHImageRequestOptionsResizeMode[PHImageRequestOptionsResizeMode["fast"] = 1] = "fast";
|
|
38
|
+
PHImageRequestOptionsResizeMode[PHImageRequestOptionsResizeMode["exact"] = 2] = "exact";
|
|
39
39
|
})(PHImageRequestOptionsResizeMode || (PHImageRequestOptionsResizeMode = {}));
|
|
40
40
|
export var PHImageRequestOptionsDeliveryMode;
|
|
41
41
|
(function (PHImageRequestOptionsDeliveryMode) {
|
|
42
|
-
PHImageRequestOptionsDeliveryMode[PHImageRequestOptionsDeliveryMode["
|
|
43
|
-
PHImageRequestOptionsDeliveryMode[PHImageRequestOptionsDeliveryMode["
|
|
44
|
-
PHImageRequestOptionsDeliveryMode[PHImageRequestOptionsDeliveryMode["
|
|
42
|
+
PHImageRequestOptionsDeliveryMode[PHImageRequestOptionsDeliveryMode["opportunistic"] = 0] = "opportunistic";
|
|
43
|
+
PHImageRequestOptionsDeliveryMode[PHImageRequestOptionsDeliveryMode["highQualityFormat"] = 1] = "highQualityFormat";
|
|
44
|
+
PHImageRequestOptionsDeliveryMode[PHImageRequestOptionsDeliveryMode["fastFormat"] = 2] = "fastFormat";
|
|
45
45
|
})(PHImageRequestOptionsDeliveryMode || (PHImageRequestOptionsDeliveryMode = {}));
|
|
46
46
|
export var PHImageContentMode;
|
|
47
47
|
(function (PHImageContentMode) {
|
|
48
48
|
PHImageContentMode[PHImageContentMode["aspectFit"] = 0] = "aspectFit";
|
|
49
49
|
PHImageContentMode[PHImageContentMode["aspectFill"] = 1] = "aspectFill";
|
|
50
50
|
})(PHImageContentMode || (PHImageContentMode = {}));
|
|
51
|
+
export var UIViewContentMode;
|
|
52
|
+
(function (UIViewContentMode) {
|
|
53
|
+
UIViewContentMode[UIViewContentMode["scaleToFill"] = 0] = "scaleToFill";
|
|
54
|
+
UIViewContentMode[UIViewContentMode["scaleAspectFit"] = 1] = "scaleAspectFit";
|
|
55
|
+
UIViewContentMode[UIViewContentMode["scaleAspectFill"] = 2] = "scaleAspectFill";
|
|
56
|
+
UIViewContentMode[UIViewContentMode["redraw"] = 3] = "redraw";
|
|
57
|
+
UIViewContentMode[UIViewContentMode["center"] = 4] = "center";
|
|
58
|
+
UIViewContentMode[UIViewContentMode["top"] = 5] = "top";
|
|
59
|
+
UIViewContentMode[UIViewContentMode["bottom"] = 6] = "bottom";
|
|
60
|
+
UIViewContentMode[UIViewContentMode["left"] = 7] = "left";
|
|
61
|
+
UIViewContentMode[UIViewContentMode["right"] = 8] = "right";
|
|
62
|
+
UIViewContentMode[UIViewContentMode["topLeft"] = 9] = "topLeft";
|
|
63
|
+
UIViewContentMode[UIViewContentMode["topRight"] = 10] = "topRight";
|
|
64
|
+
UIViewContentMode[UIViewContentMode["bottomLeft"] = 11] = "bottomLeft";
|
|
65
|
+
UIViewContentMode[UIViewContentMode["bottomRight"] = 12] = "bottomRight";
|
|
66
|
+
})(UIViewContentMode || (UIViewContentMode = {}));
|
|
51
67
|
export var PHVideoRequestOptionsDeliveryMode;
|
|
52
68
|
(function (PHVideoRequestOptionsDeliveryMode) {
|
|
53
|
-
PHVideoRequestOptionsDeliveryMode[PHVideoRequestOptionsDeliveryMode["
|
|
54
|
-
PHVideoRequestOptionsDeliveryMode[PHVideoRequestOptionsDeliveryMode["
|
|
55
|
-
PHVideoRequestOptionsDeliveryMode[PHVideoRequestOptionsDeliveryMode["
|
|
56
|
-
PHVideoRequestOptionsDeliveryMode[PHVideoRequestOptionsDeliveryMode["
|
|
69
|
+
PHVideoRequestOptionsDeliveryMode[PHVideoRequestOptionsDeliveryMode["automatic"] = 0] = "automatic";
|
|
70
|
+
PHVideoRequestOptionsDeliveryMode[PHVideoRequestOptionsDeliveryMode["highQualityFormat"] = 1] = "highQualityFormat";
|
|
71
|
+
PHVideoRequestOptionsDeliveryMode[PHVideoRequestOptionsDeliveryMode["mediumQualityFormat"] = 2] = "mediumQualityFormat";
|
|
72
|
+
PHVideoRequestOptionsDeliveryMode[PHVideoRequestOptionsDeliveryMode["fastFormat"] = 3] = "fastFormat";
|
|
57
73
|
})(PHVideoRequestOptionsDeliveryMode || (PHVideoRequestOptionsDeliveryMode = {}));
|
|
58
74
|
export var AVFileType;
|
|
59
75
|
(function (AVFileType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoPhotos.types.js","sourceRoot":"","sources":["../src/ExpoPhotos.types.ts"],"names":[],"mappings":"AAUA,MAAM,CAAN,IAAY,qBAMX;AAND,WAAY,qBAAqB;IAC/B,mFAAiB,CAAA;IACjB,6EAAc,CAAA;IACd,qEAAU,CAAA;IACV,6EAAc,CAAA;IACd,uEAAW,CAAA;AACb,CAAC,EANW,qBAAqB,KAArB,qBAAqB,QAMhC;AAED,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,uDAAW,CAAA;IACX,2DAAa,CAAA;AACf,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAED,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,6DAAW,CAAA;IACX,yDAAS,CAAA;IACT,yDAAS,CAAA;IACT,yDAAS,CAAA;AACX,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAED,MAAM,CAAN,IAAY,mBAWX;AAXD,WAAY,mBAAmB;IAC7B,6DAAQ,CAAA;IACR,+EAAsB,CAAA;IACtB,qEAAiB,CAAA;IACjB,mFAAwB,CAAA;IACxB,uEAAkB,CAAA;IAClB,sFAAyB,CAAA;IACzB,mFAAuB,CAAA;IACvB,8FAA4B,CAAA;IAC5B,sFAAwB,CAAA;IACxB,sFAAwB,CAAA;AAC1B,CAAC,EAXW,mBAAmB,KAAnB,mBAAmB,QAW9B;AAwBD,MAAM,CAAN,IAAY,+BAIX;AAJD,WAAY,+BAA+B;IACzC,qFAAQ,CAAA;IACR,qFAAQ,CAAA;IACR,uFAAS,CAAA;AACX,CAAC,EAJW,+BAA+B,KAA/B,+BAA+B,QAI1C;AAED,MAAM,CAAN,IAAY,iCAIX;AAJD,WAA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,CAAA;IACnB,yCAA2B,CAAA;IAC3B,yCAA2B,CAAA;IAC3B,wCAA0B,CAAA;IAC1B,0CAA4B,CAAA;IAC5B,+CAAiC,CAAA;IACjC,gCAAkB,CAAA;IAClB,mCAAqB,CAAA;IACrB,sCAAwB,CAAA;IACxB,iCAAmB,CAAA;IACnB,kDAAoC,CAAA;AACtC,CAAC,EAzBW,UAAU,KAAV,UAAU,QAyBrB;AAED,MAAM,CAAN,IAAY,mBA6BX;AA7BD,WAAY,mBAAmB;IAC7B,mEAA4C,CAAA;IAC5C,yEAAkD,CAAA;IAClD,2EAAoD,CAAA;IACpD,mFAA4D,CAAA;IAC5D,qGAA8E,CAAA;IAC9E,gEAAyC,CAAA;IACzC,gEAAyC,CAAA;IACzC,kEAA2C,CAAA;IAC3C,oEAA6C,CAAA;IAC7C,oEAA6C,CAAA;IAC7C,yEAAkD,CAAA;IAClD,yEAAkD,CAAA;IAClD,2FAAoE,CAAA;IACpE,2FAAoE,CAAA;IACpE,yEAAkD,CAAA;IAClD,yEAAkD,CAAA;IAClD,6EAAsD,CAAA;IACtD,2EAAoD,CAAA;IACpD,2EAAoD,CAAA;IACpD,6EAAsD,CAAA;IACtD,uEAAgD,CAAA;IAChD,6EAAsD,CAAA;IACtD,+EAAwD,CAAA;IACxD,uEAAgD,CAAA;IAChD,mFAA4D,CAAA;IAC5D,qFAA8D,CAAA;IAC9D,qEAA8C,CAAA;IAC9C,+DAAwC,CAAA;AAC1C,CAAC,EA7BW,mBAAmB,KAAnB,mBAAmB,QA6B9B;AA+BD,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;IACjB,6BAAW,CAAA;AACb,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB","sourcesContent":["export interface PHAsset {\n localIdentifier: string;\n creationDate: number;\n mediaType: PHAssetMediaType;\n mediaSubtypes: PHAssetMediaSubtype;\n duration: number;\n pixelWidth: number;\n pixelHeight: number;\n}\n\nexport enum PHAuthorizationStatus {\n notDetermined = 0,\n restricted = 1,\n denied = 2,\n authorized = 3,\n limited = 4,\n}\n\nexport enum PHAccessLevel {\n addOnly = 1,\n readWrite = 2,\n}\n\nexport enum PHAssetMediaType {\n unknown = 0,\n image = 1,\n video = 2,\n audio = 3,\n}\n\nexport enum PHAssetMediaSubtype {\n none = 0,\n photoPanorama = 1 << 0,\n photoHDR = 1 << 1,\n photoScreenshot = 1 << 2,\n photoLive = 1 << 3,\n photoDepthEffect = 1 << 4,\n videoStreamed = 1 << 16,\n videoHighFrameRate = 1 << 17,\n videoTimelapse = 1 << 18,\n videoCinematic = 1 << 19,\n}\n\nexport interface NSSortDescriptor {\n key: string;\n ascending: boolean;\n}\n\nexport interface PHFetchOptions {\n predicate?: string;\n fetchLimit?: number;\n sortDescriptors?: NSSortDescriptor[];\n}\n\nexport type FetchAssetsOptions = PHFetchOptions;\n\nexport interface CGSize {\n width: number;\n height: number;\n}\n\nexport type PHImageManagerMaximumSize = \"PHImageManagerMaximumSize\";\n\nexport type RequestImageTargetSize = CGSize | PHImageManagerMaximumSize;\n\nexport enum PHImageRequestOptionsResizeMode {\n none = 0,\n fast = 1,\n exact = 2,\n}\n\nexport enum PHImageRequestOptionsDeliveryMode {\n opportunistic = 0,\n highQualityFormat = 1,\n fastFormat = 2,\n}\n\nexport enum PHImageContentMode {\n aspectFit = 0,\n aspectFill = 1,\n}\n\nexport enum UIViewContentMode {\n scaleToFill = 0,\n scaleAspectFit = 1,\n scaleAspectFill = 2,\n redraw = 3,\n center = 4,\n top = 5,\n bottom = 6,\n left = 7,\n right = 8,\n topLeft = 9,\n topRight = 10,\n bottomLeft = 11,\n bottomRight = 12,\n}\nexport interface PHImageRequestOptions {\n isNetworkAccessAllowed?: boolean;\n resizeMode?: PHImageRequestOptionsResizeMode;\n deliveryMode?: PHImageRequestOptionsDeliveryMode;\n}\n\nexport interface SDImageCoderOptions {\n encodeCompressionQuality?: number;\n encodeMaxFileSize?: number;\n}\n\nexport enum PHVideoRequestOptionsDeliveryMode {\n automatic = 0,\n highQualityFormat = 1,\n mediumQualityFormat = 2,\n fastFormat = 3,\n}\n\nexport interface PHVideoRequestOptions {\n isNetworkAccessAllowed?: boolean;\n deliveryMode?: PHVideoRequestOptionsDeliveryMode;\n}\n\nexport interface CMTimeRange {\n start: number;\n duration: number;\n}\n\nexport enum AVFileType {\n ac3 = \"public.ac3-audio\",\n aifc = \"public.aifc-audio\",\n aiff = \"public.aiff-audio\",\n AHAP = \"com.apple.itt\",\n amr = \"org.3gpp.adaptive-multi-rate-audio\",\n appleiTT = \"com.apple.itt\",\n au = \"public.au-audio\",\n avci = \"public.avci\",\n caf = \"com.apple.coreaudio-format\",\n dng = \"com.adobe.raw-image\",\n eac3 = \"public.eac3-audio\",\n heic = \"public.heic\",\n heif = \"public.heif\",\n jpg = \"public.jpeg\",\n m4a = \"com.apple.m4a-audio\",\n m4v = \"com.apple.m4v-video\",\n mobile3GPP = \"public.3gpp\",\n mobile3GPP2 = \"public.3gpp2\",\n mov = \"com.apple.quicktime-movie\",\n mp3 = \"public.mp3\",\n mp4 = \"public.mpeg-4\",\n SCC = \"com.scenarist.cc\",\n tif = \"public.tiff\",\n wav = \"com.microsoft.waveform-audio\",\n}\n\nexport enum AVAssetExportPreset {\n LowQuality = \"AVAssetExportPresetLowQuality\",\n MediumQuality = \"AVAssetExportPresetMediumQuality\",\n HighestQuality = \"AVAssetExportPresetHighestQuality\",\n HEVCHighestQuality = \"AVAssetExportPresetHEVCHighestQuality\",\n HEVCHighestQualityWithAlpha = \"AVAssetExportPresetHEVCHighestQualityWithAlpha\",\n AVC640x480 = \"AVAssetExportPreset640x480\",\n AVC960x540 = \"AVAssetExportPreset960x540\",\n AVC1280x720 = \"AVAssetExportPreset1280x720\",\n AVC1920x1080 = \"AVAssetExportPreset1920x1080\",\n AVC3840x2160 = \"AVAssetExportPreset3840x2160\",\n HEVC1920x1080 = \"AVAssetExportPresetHEVC1920x1080\",\n HEVC3840x2160 = \"AVAssetExportPresetHEVC3840x2160\",\n HEVC1920x1080WithAlpha = \"AVAssetExportPresetHEVC1920x1080WithAlpha\",\n HEVC3840x2160WithAlpha = \"AVAssetExportPresetHEVC3840x2160WithAlpha\",\n HEVC7680x4320 = \"AVAssetExportPresetHEVC7680x4320\",\n MVHEVC960x960 = \"AVAssetExportPresetMVHEVC960x960\",\n MVHEVC1440x1440 = \"AVAssetExportPresetMVHEVC1440x1440\",\n AppleM4V480pSD = \"AVAssetExportPresetAppleM4V480pSD\",\n AppleM4V720pHD = \"AVAssetExportPresetAppleM4V720pHD\",\n AppleM4V1080pHD = \"AVAssetExportPresetAppleM4V1080pHD\",\n AppleM4ViPod = \"AVAssetExportPresetAppleM4ViPod\",\n AppleM4VAppleTV = \"AVAssetExportPresetAppleM4VAppleTV\",\n AppleM4VCellular = \"AVAssetExportPresetAppleM4VCellular\",\n AppleM4VWiFi = \"AVAssetExportPresetAppleM4VWiFi\",\n AppleProRes422LPCM = \"AVAssetExportPresetAppleProRes422LPCM\",\n AppleProRes4444LPCM = \"AVAssetExportPresetAppleProRes4444LPCM\",\n Passthrough = \"AVAssetExportPresetPassthrough\",\n AppleM4A = \"AVAssetExportPresetAppleM4A\",\n}\n\nexport interface AVAssetExportSessionOptions {\n outputURL: string;\n outputFileType?: AVFileType;\n fileLengthLimit?: number;\n timeRange?: CMTimeRange;\n}\n\nexport interface RequestImageOptions\n extends PHImageRequestOptions, SDImageCoderOptions {\n localIdentifier: string;\n targetSize: RequestImageTargetSize;\n contentMode: PHImageContentMode;\n outputURL?: string;\n timeout?: number;\n}\n\nexport interface RequestImageResult {\n size: CGSize;\n scale: number;\n imageOrientation: number;\n}\n\nexport interface RequestVideoOptions\n extends PHVideoRequestOptions, AVAssetExportSessionOptions {\n localIdentifier: string;\n exportPreset: AVAssetExportPreset;\n timeout?: number;\n}\n\nexport enum PHPickerFilter {\n images = \"images\",\n videos = \"videos\",\n any = \"any\",\n}\n\nexport interface PickAssetsOptions {\n filter?: PHPickerFilter;\n selectionLimit?: number;\n}\n\nexport interface PHVideoLoadEvent {\n duration: number;\n naturalSize: { width: number; height: number };\n}\n\nexport interface PHVideoErrorEvent {\n message: string;\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ViewProps } from "react-native";
|
|
2
|
+
import { PHImageContentMode, PHImageRequestOptions, RequestImageTargetSize, UIViewContentMode } from "./ExpoPhotos.types";
|
|
3
|
+
export interface PHImageLoadEvent {
|
|
4
|
+
size: {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
8
|
+
scale: number;
|
|
9
|
+
}
|
|
10
|
+
export interface PHImageErrorEvent {
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PHImageViewRequestOptions extends PHImageRequestOptions {
|
|
14
|
+
contentMode?: PHImageContentMode;
|
|
15
|
+
targetSize?: RequestImageTargetSize;
|
|
16
|
+
}
|
|
17
|
+
export interface PHImageViewProps extends ViewProps {
|
|
18
|
+
localIdentifier: string;
|
|
19
|
+
contentMode?: UIViewContentMode;
|
|
20
|
+
requestOptions?: PHImageViewRequestOptions;
|
|
21
|
+
onLoad?: (event: {
|
|
22
|
+
nativeEvent: PHImageLoadEvent;
|
|
23
|
+
}) => void;
|
|
24
|
+
onError?: (event: {
|
|
25
|
+
nativeEvent: PHImageErrorEvent;
|
|
26
|
+
}) => void;
|
|
27
|
+
}
|
|
28
|
+
export declare function PHImageView({ requestOptions, contentMode, ...rest }: PHImageViewProps): import("react").JSX.Element;
|
|
29
|
+
//# sourceMappingURL=PHImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PHImage.d.ts","sourceRoot":"","sources":["../src/PHImage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,yBAA0B,SAAQ,qBAAqB;IACtE,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,UAAU,CAAC,EAAE,sBAAsB,CAAC;CACrC;AAED,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,cAAc,CAAC,EAAE,yBAAyB,CAAC;IAC3C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,gBAAgB,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,iBAAiB,CAAA;KAAE,KAAK,IAAI,CAAC;CAC/D;AAID,wBAAgB,WAAW,CAAC,EAC1B,cAAc,EACd,WAAW,EACX,GAAG,IAAI,EACR,EAAE,gBAAgB,+BAYlB"}
|
package/build/PHImage.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { requireNativeViewManager } from "expo-modules-core";
|
|
2
|
+
const NativePHImageView = requireNativeViewManager("ExpoPhotos", "PHImageView");
|
|
3
|
+
export function PHImageView({ requestOptions, contentMode, ...rest }) {
|
|
4
|
+
return (<NativePHImageView viewContentMode={contentMode} requestContentMode={requestOptions?.contentMode} isNetworkAccessAllowed={requestOptions?.isNetworkAccessAllowed} deliveryMode={requestOptions?.deliveryMode} resizeMode={requestOptions?.resizeMode} targetSize={requestOptions?.targetSize} {...rest}/>);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=PHImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PHImage.js","sourceRoot":"","sources":["../src/PHImage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AA+B7D,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;AAEhF,MAAM,UAAU,WAAW,CAAC,EAC1B,cAAc,EACd,WAAW,EACX,GAAG,IAAI,EACU;IACjB,OAAO,CACL,CAAC,iBAAiB,CAChB,eAAe,CAAC,CAAC,WAAW,CAAC,CAC7B,kBAAkB,CAAC,CAAC,cAAc,EAAE,WAAW,CAAC,CAChD,sBAAsB,CAAC,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAC/D,YAAY,CAAC,CAAC,cAAc,EAAE,YAAY,CAAC,CAC3C,UAAU,CAAC,CAAC,cAAc,EAAE,UAAU,CAAC,CACvC,UAAU,CAAC,CAAC,cAAc,EAAE,UAAU,CAAC,CACvC,IAAI,IAAI,CAAC,EACT,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeViewManager } from \"expo-modules-core\";\nimport { ViewProps } from \"react-native\";\nimport {\n PHImageContentMode,\n PHImageRequestOptions,\n RequestImageTargetSize,\n UIViewContentMode,\n} from \"./ExpoPhotos.types\";\n\nexport interface PHImageLoadEvent {\n size: { width: number; height: number };\n scale: number;\n}\n\nexport interface PHImageErrorEvent {\n message: string;\n}\n\nexport interface PHImageViewRequestOptions extends PHImageRequestOptions {\n contentMode?: PHImageContentMode;\n targetSize?: RequestImageTargetSize;\n}\n\nexport interface PHImageViewProps extends ViewProps {\n localIdentifier: string;\n contentMode?: UIViewContentMode;\n requestOptions?: PHImageViewRequestOptions;\n onLoad?: (event: { nativeEvent: PHImageLoadEvent }) => void;\n onError?: (event: { nativeEvent: PHImageErrorEvent }) => void;\n}\n\nconst NativePHImageView = requireNativeViewManager(\"ExpoPhotos\", \"PHImageView\");\n\nexport function PHImageView({\n requestOptions,\n contentMode,\n ...rest\n}: PHImageViewProps) {\n return (\n <NativePHImageView\n viewContentMode={contentMode}\n requestContentMode={requestOptions?.contentMode}\n isNetworkAccessAllowed={requestOptions?.isNetworkAccessAllowed}\n deliveryMode={requestOptions?.deliveryMode}\n resizeMode={requestOptions?.resizeMode}\n targetSize={requestOptions?.targetSize}\n {...rest}\n />\n );\n}\n"]}
|
package/build/PHVideo.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ViewProps } from "react-native";
|
|
2
2
|
import { PHVideoLoadEvent, PHVideoErrorEvent, PHVideoRequestOptions } from "./ExpoPhotos.types";
|
|
3
|
-
export interface
|
|
3
|
+
export interface PHVideoViewRequestOptions extends PHVideoRequestOptions {
|
|
4
|
+
}
|
|
5
|
+
export interface PHVideoViewProps extends ViewProps {
|
|
4
6
|
localIdentifier: string;
|
|
7
|
+
requestOptions?: PHVideoViewRequestOptions;
|
|
5
8
|
onLoad?: (event: {
|
|
6
9
|
nativeEvent: PHVideoLoadEvent;
|
|
7
10
|
}) => void;
|
|
@@ -9,5 +12,5 @@ export interface PHVideoProps extends ViewProps, PHVideoRequestOptions {
|
|
|
9
12
|
nativeEvent: PHVideoErrorEvent;
|
|
10
13
|
}) => void;
|
|
11
14
|
}
|
|
12
|
-
export declare function
|
|
15
|
+
export declare function PHVideoView({ requestOptions, ...rest }: PHVideoViewProps): import("react").JSX.Element;
|
|
13
16
|
//# sourceMappingURL=PHVideo.d.ts.map
|
package/build/PHVideo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PHVideo.d.ts","sourceRoot":"","sources":["../src/PHVideo.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"PHVideo.d.ts","sourceRoot":"","sources":["../src/PHVideo.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,yBAA0B,SAAQ,qBAAqB;CAAG;AAE3E,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,yBAAyB,CAAC;IAC3C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,gBAAgB,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,iBAAiB,CAAA;KAAE,KAAK,IAAI,CAAC;CAC/D;AAID,wBAAgB,WAAW,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,EAAE,gBAAgB,+BAQxE"}
|
package/build/PHVideo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { requireNativeViewManager } from "expo-modules-core";
|
|
2
2
|
const NativePHVideoView = requireNativeViewManager("ExpoPhotos", "PHVideoView");
|
|
3
|
-
export function
|
|
4
|
-
return <NativePHVideoView {...
|
|
3
|
+
export function PHVideoView({ requestOptions, ...rest }) {
|
|
4
|
+
return (<NativePHVideoView isNetworkAccessAllowed={requestOptions?.isNetworkAccessAllowed} deliveryMode={requestOptions?.deliveryMode} {...rest}/>);
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=PHVideo.js.map
|
package/build/PHVideo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PHVideo.js","sourceRoot":"","sources":["../src/PHVideo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"PHVideo.js","sourceRoot":"","sources":["../src/PHVideo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAiB7D,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;AAEhF,MAAM,UAAU,WAAW,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,EAAoB;IACvE,OAAO,CACL,CAAC,iBAAiB,CAChB,sBAAsB,CAAC,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAC/D,YAAY,CAAC,CAAC,cAAc,EAAE,YAAY,CAAC,CAC3C,IAAI,IAAI,CAAC,EACT,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeViewManager } from \"expo-modules-core\";\nimport { ViewProps } from \"react-native\";\nimport {\n PHVideoLoadEvent,\n PHVideoErrorEvent,\n PHVideoRequestOptions,\n} from \"./ExpoPhotos.types\";\n\nexport interface PHVideoViewRequestOptions extends PHVideoRequestOptions {}\n\nexport interface PHVideoViewProps extends ViewProps {\n localIdentifier: string;\n requestOptions?: PHVideoViewRequestOptions;\n onLoad?: (event: { nativeEvent: PHVideoLoadEvent }) => void;\n onError?: (event: { nativeEvent: PHVideoErrorEvent }) => void;\n}\n\nconst NativePHVideoView = requireNativeViewManager(\"ExpoPhotos\", \"PHVideoView\");\n\nexport function PHVideoView({ requestOptions, ...rest }: PHVideoViewProps) {\n return (\n <NativePHVideoView\n isNetworkAccessAllowed={requestOptions?.isNetworkAccessAllowed}\n deliveryMode={requestOptions?.deliveryMode}\n {...rest}\n />\n );\n}\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { default } from "./ExpoPhotosModule";
|
|
2
2
|
export * from "./ExpoPhotos.types";
|
|
3
|
-
export {
|
|
4
|
-
export type {
|
|
5
|
-
export {
|
|
6
|
-
export type {
|
|
3
|
+
export { PHImageView } from "./PHImage";
|
|
4
|
+
export type { PHImageViewProps, PHImageViewRequestOptions, PHImageLoadEvent, PHImageErrorEvent } from "./PHImage";
|
|
5
|
+
export { PHVideoView } from "./PHVideo";
|
|
6
|
+
export type { PHVideoViewProps, PHVideoViewRequestOptions } from "./PHVideo";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAClH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default } from "./ExpoPhotosModule";
|
|
2
2
|
export * from "./ExpoPhotos.types";
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { PHImageView } from "./PHImage";
|
|
4
|
+
export { PHVideoView } from "./PHVideo";
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC","sourcesContent":["export { default } from \"./ExpoPhotosModule\";\nexport * from \"./ExpoPhotos.types\";\nexport { PHImageView } from \"./PHImage\";\nexport type { PHImageViewProps, PHImageViewRequestOptions, PHImageLoadEvent, PHImageErrorEvent } from \"./PHImage\";\nexport { PHVideoView } from \"./PHVideo\";\nexport type { PHVideoViewProps, PHVideoViewRequestOptions } from \"./PHVideo\";\n"]}
|
package/ios/ExpoPhotos.podspec
CHANGED
|
@@ -14,11 +14,10 @@ Pod::Spec.new do |s|
|
|
|
14
14
|
s.swift_version = '5.9'
|
|
15
15
|
s.source = { git: package['repository'] || 'https://github.com/hortemo/expo-photos' }
|
|
16
16
|
s.static_framework = true
|
|
17
|
+
s.frameworks = 'Photos','PhotosUI'
|
|
17
18
|
|
|
18
19
|
s.dependency 'ExpoModulesCore'
|
|
19
|
-
s.dependency 'React-Core'
|
|
20
20
|
s.dependency 'SDWebImageWebPCoder', '~> 0.14'
|
|
21
21
|
|
|
22
22
|
s.source_files = '**/*.{h,m,swift}'
|
|
23
|
-
s.requires_arc = true
|
|
24
23
|
end
|
|
@@ -305,6 +305,38 @@ public final class ExpoPhotos: Module {
|
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
View(PHImageView.self) {
|
|
309
|
+
Prop("localIdentifier") { (view: PHImageView, localIdentifier: String?) in
|
|
310
|
+
view.localIdentifier = localIdentifier
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
Prop("isNetworkAccessAllowed") { (view: PHImageView, isNetworkAccessAllowed: Bool?) in
|
|
314
|
+
view.isNetworkAccessAllowed = isNetworkAccessAllowed ?? true
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
Prop("deliveryMode") { (view: PHImageView, deliveryMode: PHImageRequestOptionsDeliveryMode?) in
|
|
318
|
+
view.deliveryMode = deliveryMode ?? .opportunistic
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
Prop("resizeMode") { (view: PHImageView, resizeMode: PHImageRequestOptionsResizeMode?) in
|
|
322
|
+
view.resizeMode = resizeMode ?? .none
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
Prop("requestContentMode") { (view: PHImageView, contentMode: PHImageContentMode?) in
|
|
326
|
+
view.requestContentMode = contentMode ?? .aspectFill
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
Prop("viewContentMode") { (view: PHImageView, contentMode: UIView.ContentMode?) in
|
|
330
|
+
view.viewContentMode = contentMode ?? .scaleAspectFill
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
Prop("targetSize") { (view: PHImageView, targetSize: TargetSize?) in
|
|
334
|
+
view.targetSize = targetSize?.value
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
Events("onLoad", "onError")
|
|
338
|
+
}
|
|
339
|
+
|
|
308
340
|
View(PHVideoView.self) {
|
|
309
341
|
Prop("localIdentifier") { (view: PHVideoView, localIdentifier: String?) in
|
|
310
342
|
view.localIdentifier = localIdentifier
|
|
@@ -472,6 +504,8 @@ extension PHVideoRequestOptionsDeliveryMode: @retroactive Convertible {}
|
|
|
472
504
|
extension AVFileType: @retroactive Convertible {}
|
|
473
505
|
extension PHAccessLevel: @retroactive Convertible {}
|
|
474
506
|
|
|
507
|
+
extension UIView.ContentMode: @retroactive Convertible {}
|
|
508
|
+
|
|
475
509
|
extension PHPickerFilter: @retroactive Convertible {
|
|
476
510
|
public static func convert(from value: Any?, appContext: AppContext) throws -> Self {
|
|
477
511
|
guard let rawValue = value as? String else {
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import Photos
|
|
3
|
+
import UIKit
|
|
4
|
+
|
|
5
|
+
public final class PHImageView: ExpoView {
|
|
6
|
+
let onLoad = EventDispatcher()
|
|
7
|
+
let onError = EventDispatcher()
|
|
8
|
+
|
|
9
|
+
private var currentRequestId: PHImageRequestID?
|
|
10
|
+
private var imageView: UIImageView
|
|
11
|
+
|
|
12
|
+
var localIdentifier: String? {
|
|
13
|
+
didSet {
|
|
14
|
+
if localIdentifier != oldValue {
|
|
15
|
+
loadImage()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var isNetworkAccessAllowed: Bool = true {
|
|
21
|
+
didSet {
|
|
22
|
+
if isNetworkAccessAllowed != oldValue {
|
|
23
|
+
loadImage()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var deliveryMode: PHImageRequestOptionsDeliveryMode = .opportunistic {
|
|
29
|
+
didSet {
|
|
30
|
+
if deliveryMode != oldValue {
|
|
31
|
+
loadImage()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var resizeMode: PHImageRequestOptionsResizeMode = .none {
|
|
37
|
+
didSet {
|
|
38
|
+
if resizeMode != oldValue {
|
|
39
|
+
loadImage()
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var targetSize: CGSize? {
|
|
45
|
+
didSet {
|
|
46
|
+
if targetSize != oldValue {
|
|
47
|
+
loadImage()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var requestContentMode: PHImageContentMode = .aspectFill {
|
|
53
|
+
didSet {
|
|
54
|
+
if requestContentMode != oldValue {
|
|
55
|
+
loadImage()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var viewContentMode: UIView.ContentMode = .scaleAspectFill {
|
|
61
|
+
didSet {
|
|
62
|
+
if viewContentMode != oldValue {
|
|
63
|
+
imageView.contentMode = viewContentMode
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public required init(appContext: AppContext? = nil) {
|
|
69
|
+
imageView = UIImageView()
|
|
70
|
+
super.init(appContext: appContext)
|
|
71
|
+
imageView.clipsToBounds = true
|
|
72
|
+
imageView.contentMode = viewContentMode
|
|
73
|
+
addSubview(imageView)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public override func layoutSubviews() {
|
|
77
|
+
super.layoutSubviews()
|
|
78
|
+
imageView.frame = bounds
|
|
79
|
+
loadImage()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public override func willMove(toWindow newWindow: UIWindow?) {
|
|
83
|
+
super.willMove(toWindow: newWindow)
|
|
84
|
+
if newWindow == nil {
|
|
85
|
+
cleanup()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private func loadImage() {
|
|
90
|
+
cleanup()
|
|
91
|
+
|
|
92
|
+
guard let localIdentifier = localIdentifier else { return }
|
|
93
|
+
guard bounds.width > 0 && bounds.height > 0 else { return }
|
|
94
|
+
|
|
95
|
+
guard let asset = PHAsset.fetchAssets(withLocalIdentifiers: [localIdentifier], options: nil).firstObject else {
|
|
96
|
+
onError(["message": "Asset not found for identifier: \(localIdentifier)"])
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let options = PHImageRequestOptions()
|
|
101
|
+
options.isNetworkAccessAllowed = isNetworkAccessAllowed
|
|
102
|
+
options.deliveryMode = deliveryMode
|
|
103
|
+
options.resizeMode = resizeMode
|
|
104
|
+
|
|
105
|
+
let scale = window?.screen.scale ?? UIScreen.main.scale
|
|
106
|
+
let boundsSize = CGSize(width: bounds.width * scale, height: bounds.height * scale)
|
|
107
|
+
|
|
108
|
+
currentRequestId = PHImageManager.default().requestImage(
|
|
109
|
+
for: asset,
|
|
110
|
+
targetSize: targetSize ?? boundsSize,
|
|
111
|
+
contentMode: requestContentMode,
|
|
112
|
+
options: options
|
|
113
|
+
) { [weak self] image, info in
|
|
114
|
+
guard let self = self else { return }
|
|
115
|
+
|
|
116
|
+
DispatchQueue.main.async {
|
|
117
|
+
let isCancelled = (info?[PHImageCancelledKey] as? NSNumber)?.boolValue ?? false
|
|
118
|
+
if isCancelled { return }
|
|
119
|
+
|
|
120
|
+
if let error = info?[PHImageErrorKey] as? Error {
|
|
121
|
+
self.onError(["message": error.localizedDescription])
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
guard let image = image else {
|
|
126
|
+
self.onError(["message": "Failed to load image"])
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
self.imageView.image = image
|
|
131
|
+
|
|
132
|
+
let isDegraded = (info?[PHImageResultIsDegradedKey] as? NSNumber)?.boolValue ?? false
|
|
133
|
+
if !isDegraded {
|
|
134
|
+
self.onLoad([
|
|
135
|
+
"size": [
|
|
136
|
+
"width": image.size.width,
|
|
137
|
+
"height": image.size.height,
|
|
138
|
+
],
|
|
139
|
+
"scale": image.scale,
|
|
140
|
+
])
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private func cleanup() {
|
|
147
|
+
if let requestId = currentRequestId {
|
|
148
|
+
PHImageManager.default().cancelImageRequest(requestId)
|
|
149
|
+
currentRequestId = nil
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hortemo/expo-photos",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Expo module exposing advanced iOS Photos APIs.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -38,15 +38,5 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"expo": "*",
|
|
40
40
|
"react-native": "*"
|
|
41
|
-
},
|
|
42
|
-
"codegenConfig": {
|
|
43
|
-
"name": "expo-photos",
|
|
44
|
-
"type": "modules",
|
|
45
|
-
"jsSrcsDir": "./src",
|
|
46
|
-
"ios": {
|
|
47
|
-
"modulesConformingToProtocol": {
|
|
48
|
-
"RCTImageURLLoader": "ExpoPhotosImageLoader"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
41
|
}
|
|
52
42
|
}
|
package/src/ExpoPhotos.types.ts
CHANGED
|
@@ -22,23 +22,23 @@ export enum PHAccessLevel {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export enum PHAssetMediaType {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
unknown = 0,
|
|
26
|
+
image = 1,
|
|
27
|
+
video = 2,
|
|
28
|
+
audio = 3,
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export enum PHAssetMediaSubtype {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
none = 0,
|
|
33
|
+
photoPanorama = 1 << 0,
|
|
34
|
+
photoHDR = 1 << 1,
|
|
35
|
+
photoScreenshot = 1 << 2,
|
|
36
|
+
photoLive = 1 << 3,
|
|
37
|
+
photoDepthEffect = 1 << 4,
|
|
38
|
+
videoStreamed = 1 << 16,
|
|
39
|
+
videoHighFrameRate = 1 << 17,
|
|
40
|
+
videoTimelapse = 1 << 18,
|
|
41
|
+
videoCinematic = 1 << 19,
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface NSSortDescriptor {
|
|
@@ -64,15 +64,15 @@ export type PHImageManagerMaximumSize = "PHImageManagerMaximumSize";
|
|
|
64
64
|
export type RequestImageTargetSize = CGSize | PHImageManagerMaximumSize;
|
|
65
65
|
|
|
66
66
|
export enum PHImageRequestOptionsResizeMode {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
none = 0,
|
|
68
|
+
fast = 1,
|
|
69
|
+
exact = 2,
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export enum PHImageRequestOptionsDeliveryMode {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
opportunistic = 0,
|
|
74
|
+
highQualityFormat = 1,
|
|
75
|
+
fastFormat = 2,
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
export enum PHImageContentMode {
|
|
@@ -80,6 +80,21 @@ export enum PHImageContentMode {
|
|
|
80
80
|
aspectFill = 1,
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
export enum UIViewContentMode {
|
|
84
|
+
scaleToFill = 0,
|
|
85
|
+
scaleAspectFit = 1,
|
|
86
|
+
scaleAspectFill = 2,
|
|
87
|
+
redraw = 3,
|
|
88
|
+
center = 4,
|
|
89
|
+
top = 5,
|
|
90
|
+
bottom = 6,
|
|
91
|
+
left = 7,
|
|
92
|
+
right = 8,
|
|
93
|
+
topLeft = 9,
|
|
94
|
+
topRight = 10,
|
|
95
|
+
bottomLeft = 11,
|
|
96
|
+
bottomRight = 12,
|
|
97
|
+
}
|
|
83
98
|
export interface PHImageRequestOptions {
|
|
84
99
|
isNetworkAccessAllowed?: boolean;
|
|
85
100
|
resizeMode?: PHImageRequestOptionsResizeMode;
|
|
@@ -92,10 +107,10 @@ export interface SDImageCoderOptions {
|
|
|
92
107
|
}
|
|
93
108
|
|
|
94
109
|
export enum PHVideoRequestOptionsDeliveryMode {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
110
|
+
automatic = 0,
|
|
111
|
+
highQualityFormat = 1,
|
|
112
|
+
mediumQualityFormat = 2,
|
|
113
|
+
fastFormat = 3,
|
|
99
114
|
}
|
|
100
115
|
|
|
101
116
|
export interface PHVideoRequestOptions {
|
|
@@ -174,8 +189,7 @@ export interface AVAssetExportSessionOptions {
|
|
|
174
189
|
}
|
|
175
190
|
|
|
176
191
|
export interface RequestImageOptions
|
|
177
|
-
extends PHImageRequestOptions,
|
|
178
|
-
SDImageCoderOptions {
|
|
192
|
+
extends PHImageRequestOptions, SDImageCoderOptions {
|
|
179
193
|
localIdentifier: string;
|
|
180
194
|
targetSize: RequestImageTargetSize;
|
|
181
195
|
contentMode: PHImageContentMode;
|
|
@@ -190,8 +204,7 @@ export interface RequestImageResult {
|
|
|
190
204
|
}
|
|
191
205
|
|
|
192
206
|
export interface RequestVideoOptions
|
|
193
|
-
extends PHVideoRequestOptions,
|
|
194
|
-
AVAssetExportSessionOptions {
|
|
207
|
+
extends PHVideoRequestOptions, AVAssetExportSessionOptions {
|
|
195
208
|
localIdentifier: string;
|
|
196
209
|
exportPreset: AVAssetExportPreset;
|
|
197
210
|
timeout?: number;
|
package/src/PHImage.tsx
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { requireNativeViewManager } from "expo-modules-core";
|
|
2
|
+
import { ViewProps } from "react-native";
|
|
3
|
+
import {
|
|
4
|
+
PHImageContentMode,
|
|
5
|
+
PHImageRequestOptions,
|
|
6
|
+
RequestImageTargetSize,
|
|
7
|
+
UIViewContentMode,
|
|
8
|
+
} from "./ExpoPhotos.types";
|
|
9
|
+
|
|
10
|
+
export interface PHImageLoadEvent {
|
|
11
|
+
size: { width: number; height: number };
|
|
12
|
+
scale: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface PHImageErrorEvent {
|
|
16
|
+
message: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface PHImageViewRequestOptions extends PHImageRequestOptions {
|
|
20
|
+
contentMode?: PHImageContentMode;
|
|
21
|
+
targetSize?: RequestImageTargetSize;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface PHImageViewProps extends ViewProps {
|
|
25
|
+
localIdentifier: string;
|
|
26
|
+
contentMode?: UIViewContentMode;
|
|
27
|
+
requestOptions?: PHImageViewRequestOptions;
|
|
28
|
+
onLoad?: (event: { nativeEvent: PHImageLoadEvent }) => void;
|
|
29
|
+
onError?: (event: { nativeEvent: PHImageErrorEvent }) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const NativePHImageView = requireNativeViewManager("ExpoPhotos", "PHImageView");
|
|
33
|
+
|
|
34
|
+
export function PHImageView({
|
|
35
|
+
requestOptions,
|
|
36
|
+
contentMode,
|
|
37
|
+
...rest
|
|
38
|
+
}: PHImageViewProps) {
|
|
39
|
+
return (
|
|
40
|
+
<NativePHImageView
|
|
41
|
+
viewContentMode={contentMode}
|
|
42
|
+
requestContentMode={requestOptions?.contentMode}
|
|
43
|
+
isNetworkAccessAllowed={requestOptions?.isNetworkAccessAllowed}
|
|
44
|
+
deliveryMode={requestOptions?.deliveryMode}
|
|
45
|
+
resizeMode={requestOptions?.resizeMode}
|
|
46
|
+
targetSize={requestOptions?.targetSize}
|
|
47
|
+
{...rest}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
package/src/PHVideo.tsx
CHANGED
|
@@ -6,14 +6,23 @@ import {
|
|
|
6
6
|
PHVideoRequestOptions,
|
|
7
7
|
} from "./ExpoPhotos.types";
|
|
8
8
|
|
|
9
|
-
export interface
|
|
9
|
+
export interface PHVideoViewRequestOptions extends PHVideoRequestOptions {}
|
|
10
|
+
|
|
11
|
+
export interface PHVideoViewProps extends ViewProps {
|
|
10
12
|
localIdentifier: string;
|
|
13
|
+
requestOptions?: PHVideoViewRequestOptions;
|
|
11
14
|
onLoad?: (event: { nativeEvent: PHVideoLoadEvent }) => void;
|
|
12
15
|
onError?: (event: { nativeEvent: PHVideoErrorEvent }) => void;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
const NativePHVideoView = requireNativeViewManager("ExpoPhotos", "PHVideoView");
|
|
16
19
|
|
|
17
|
-
export function
|
|
18
|
-
return
|
|
20
|
+
export function PHVideoView({ requestOptions, ...rest }: PHVideoViewProps) {
|
|
21
|
+
return (
|
|
22
|
+
<NativePHVideoView
|
|
23
|
+
isNetworkAccessAllowed={requestOptions?.isNetworkAccessAllowed}
|
|
24
|
+
deliveryMode={requestOptions?.deliveryMode}
|
|
25
|
+
{...rest}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
19
28
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default } from "./ExpoPhotosModule";
|
|
2
2
|
export * from "./ExpoPhotos.types";
|
|
3
|
-
export {
|
|
4
|
-
export type {
|
|
5
|
-
export {
|
|
6
|
-
export type {
|
|
3
|
+
export { PHImageView } from "./PHImage";
|
|
4
|
+
export type { PHImageViewProps, PHImageViewRequestOptions, PHImageLoadEvent, PHImageErrorEvent } from "./PHImage";
|
|
5
|
+
export { PHVideoView } from "./PHVideo";
|
|
6
|
+
export type { PHVideoViewProps, PHVideoViewRequestOptions } from "./PHVideo";
|
package/build/PHImageSource.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ImageSourcePropType } from "react-native";
|
|
2
|
-
import { PHImageContentMode, PHImageRequestOptionsDeliveryMode, PHImageRequestOptionsResizeMode, RequestImageTargetSize } from "./ExpoPhotos.types";
|
|
3
|
-
export interface PHImageSourceOptions {
|
|
4
|
-
localIdentifier: string;
|
|
5
|
-
targetSize?: RequestImageTargetSize;
|
|
6
|
-
resizeMode?: PHImageRequestOptionsResizeMode;
|
|
7
|
-
deliveryMode?: PHImageRequestOptionsDeliveryMode;
|
|
8
|
-
contentMode?: PHImageContentMode;
|
|
9
|
-
isNetworkAccessAllowed?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Creates a source object for React Native's Image component from a Photos library asset identifier.
|
|
13
|
-
*
|
|
14
|
-
* @param options - Configuration for image source, including the local identifier
|
|
15
|
-
* @returns A source object that can be used with the Image component's `source` prop, or undefined if no identifier is provided
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```tsx
|
|
19
|
-
* import { Image } from 'react-native';
|
|
20
|
-
* import { createPHImageSource } from '@hortemo/expo-photos';
|
|
21
|
-
*
|
|
22
|
-
* <Image
|
|
23
|
-
* source={createPHImageSource({
|
|
24
|
-
* localIdentifier: asset.localIdentifier,
|
|
25
|
-
* targetSize: { width: 200, height: 200 },
|
|
26
|
-
* contentMode: PHImageContentMode.aspectFill,
|
|
27
|
-
* })}
|
|
28
|
-
* />
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare function createPHImageSource(options: PHImageSourceOptions): ImageSourcePropType;
|
|
32
|
-
//# sourceMappingURL=PHImageSource.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PHImageSource.d.ts","sourceRoot":"","sources":["../src/PHImageSource.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EACL,kBAAkB,EAClB,iCAAiC,EACjC,+BAA+B,EAC/B,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACpC,UAAU,CAAC,EAAE,+BAA+B,CAAC;IAC7C,YAAY,CAAC,EAAE,iCAAiC,CAAC;IACjD,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAwBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,oBAAoB,GAC5B,mBAAmB,CAwBrB"}
|
package/build/PHImageSource.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const buildQueryString = (params) => {
|
|
2
|
-
const entries = Object.entries(params).filter(([, value]) => value !== undefined);
|
|
3
|
-
if (entries.length === 0) {
|
|
4
|
-
return "";
|
|
5
|
-
}
|
|
6
|
-
return ("?" +
|
|
7
|
-
entries
|
|
8
|
-
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value ?? "")}`)
|
|
9
|
-
.join("&"));
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Creates a source object for React Native's Image component from a Photos library asset identifier.
|
|
13
|
-
*
|
|
14
|
-
* @param options - Configuration for image source, including the local identifier
|
|
15
|
-
* @returns A source object that can be used with the Image component's `source` prop, or undefined if no identifier is provided
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```tsx
|
|
19
|
-
* import { Image } from 'react-native';
|
|
20
|
-
* import { createPHImageSource } from '@hortemo/expo-photos';
|
|
21
|
-
*
|
|
22
|
-
* <Image
|
|
23
|
-
* source={createPHImageSource({
|
|
24
|
-
* localIdentifier: asset.localIdentifier,
|
|
25
|
-
* targetSize: { width: 200, height: 200 },
|
|
26
|
-
* contentMode: PHImageContentMode.aspectFill,
|
|
27
|
-
* })}
|
|
28
|
-
* />
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export function createPHImageSource(options) {
|
|
32
|
-
const { localIdentifier, resizeMode, deliveryMode, contentMode, isNetworkAccessAllowed, } = options;
|
|
33
|
-
const targetSize = options.targetSize && typeof options.targetSize === "object"
|
|
34
|
-
? `${options.targetSize.width}x${options.targetSize.height}`
|
|
35
|
-
: options.targetSize;
|
|
36
|
-
const query = buildQueryString({
|
|
37
|
-
localIdentifier,
|
|
38
|
-
targetSize,
|
|
39
|
-
resizeMode,
|
|
40
|
-
deliveryMode,
|
|
41
|
-
contentMode,
|
|
42
|
-
isNetworkAccessAllowed,
|
|
43
|
-
});
|
|
44
|
-
return { uri: `expo-photos://${query}` };
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=PHImageSource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PHImageSource.js","sourceRoot":"","sources":["../src/PHImageSource.tsx"],"names":[],"mappings":"AAiBA,MAAM,gBAAgB,GAAG,CACvB,MAA6D,EACrD,EAAE;IACV,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAC3C,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CACnC,CAAC;IAEF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,CACL,GAAG;QACH,OAAO;aACJ,GAAG,CACF,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CACf,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAClE;aACA,IAAI,CAAC,GAAG,CAAC,CACb,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAA6B;IAE7B,MAAM,EACJ,eAAe,EACf,UAAU,EACV,YAAY,EACZ,WAAW,EACX,sBAAsB,GACvB,GAAG,OAAO,CAAC;IAEZ,MAAM,UAAU,GACd,OAAO,CAAC,UAAU,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ;QAC1D,CAAC,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE;QAC5D,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAEzB,MAAM,KAAK,GAAG,gBAAgB,CAAC;QAC7B,eAAe;QACf,UAAU;QACV,UAAU;QACV,YAAY;QACZ,WAAW;QACX,sBAAsB;KACvB,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,EAAE,iBAAiB,KAAK,EAAE,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["import type { ImageSourcePropType } from \"react-native\";\nimport {\n PHImageContentMode,\n PHImageRequestOptionsDeliveryMode,\n PHImageRequestOptionsResizeMode,\n RequestImageTargetSize,\n} from \"./ExpoPhotos.types\";\n\nexport interface PHImageSourceOptions {\n localIdentifier: string;\n targetSize?: RequestImageTargetSize;\n resizeMode?: PHImageRequestOptionsResizeMode;\n deliveryMode?: PHImageRequestOptionsDeliveryMode;\n contentMode?: PHImageContentMode;\n isNetworkAccessAllowed?: boolean;\n}\n\nconst buildQueryString = (\n params: Record<string, string | number | boolean | undefined>\n): string => {\n const entries = Object.entries(params).filter(\n ([, value]) => value !== undefined\n );\n\n if (entries.length === 0) {\n return \"\";\n }\n\n return (\n \"?\" +\n entries\n .map(\n ([key, value]) =>\n `${encodeURIComponent(key)}=${encodeURIComponent(value ?? \"\")}`\n )\n .join(\"&\")\n );\n};\n\n/**\n * Creates a source object for React Native's Image component from a Photos library asset identifier.\n *\n * @param options - Configuration for image source, including the local identifier\n * @returns A source object that can be used with the Image component's `source` prop, or undefined if no identifier is provided\n *\n * @example\n * ```tsx\n * import { Image } from 'react-native';\n * import { createPHImageSource } from '@hortemo/expo-photos';\n *\n * <Image\n * source={createPHImageSource({\n * localIdentifier: asset.localIdentifier,\n * targetSize: { width: 200, height: 200 },\n * contentMode: PHImageContentMode.aspectFill,\n * })}\n * />\n * ```\n */\nexport function createPHImageSource(\n options: PHImageSourceOptions\n): ImageSourcePropType {\n const {\n localIdentifier,\n resizeMode,\n deliveryMode,\n contentMode,\n isNetworkAccessAllowed,\n } = options;\n\n const targetSize =\n options.targetSize && typeof options.targetSize === \"object\"\n ? `${options.targetSize.width}x${options.targetSize.height}`\n : options.targetSize;\n\n const query = buildQueryString({\n localIdentifier,\n targetSize,\n resizeMode,\n deliveryMode,\n contentMode,\n isNetworkAccessAllowed,\n });\n\n return { uri: `expo-photos://${query}` };\n}\n"]}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
#if canImport(React)
|
|
2
|
-
import Foundation
|
|
3
|
-
import Photos
|
|
4
|
-
import React
|
|
5
|
-
import UIKit
|
|
6
|
-
|
|
7
|
-
@objc(ExpoPhotosImageLoader)
|
|
8
|
-
class ExpoPhotosImageLoader: NSObject, RCTBridgeModule, RCTImageURLLoader {
|
|
9
|
-
static func moduleName() -> String! {
|
|
10
|
-
return "ExpoPhotosImageLoader"
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static func requiresMainQueueSetup() -> Bool {
|
|
14
|
-
return false
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// MARK: - Helper Functions
|
|
18
|
-
|
|
19
|
-
private static func queryItems(from url: URL) -> [String: String] {
|
|
20
|
-
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
|
|
21
|
-
let queryItems = components.queryItems else {
|
|
22
|
-
return [:]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var result: [String: String] = [:]
|
|
26
|
-
for item in queryItems {
|
|
27
|
-
if let value = item.value {
|
|
28
|
-
result[item.name] = value
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return result
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// MARK: - RCTImageURLLoader
|
|
35
|
-
|
|
36
|
-
func canLoadImageURL(_ requestURL: URL) -> Bool {
|
|
37
|
-
return requestURL.scheme?.caseInsensitiveCompare("expo-photos") == .orderedSame
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
func loaderPriority() -> Float {
|
|
41
|
-
return 1.0
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
func loadImage(
|
|
45
|
-
for imageURL: URL,
|
|
46
|
-
size: CGSize,
|
|
47
|
-
scale: CGFloat,
|
|
48
|
-
resizeMode: RCTResizeMode,
|
|
49
|
-
progressHandler: RCTImageLoaderProgressBlock!,
|
|
50
|
-
partialLoadHandler: RCTImageLoaderPartialLoadBlock!,
|
|
51
|
-
completionHandler: @escaping RCTImageLoaderCompletionBlock
|
|
52
|
-
) -> RCTImageLoaderCancellationBlock! {
|
|
53
|
-
|
|
54
|
-
guard imageURL.scheme?.caseInsensitiveCompare("expo-photos") == .orderedSame else {
|
|
55
|
-
completionHandler(RCTErrorWithMessage("Unsupported image URL scheme for ExpoPhotos"), nil)
|
|
56
|
-
return {}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let queryParams = Self.queryItems(from: imageURL)
|
|
60
|
-
|
|
61
|
-
guard let localIdentifier = queryParams["localIdentifier"], !localIdentifier.isEmpty else {
|
|
62
|
-
completionHandler(RCTErrorWithMessage("Missing localIdentifier query parameter"), nil)
|
|
63
|
-
return {}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let assets = PHAsset.fetchAssets(withLocalIdentifiers: [localIdentifier], options: nil)
|
|
67
|
-
guard let asset = assets.firstObject else {
|
|
68
|
-
completionHandler(RCTErrorWithMessage("Failed to fetch PHAsset with local identifier \(localIdentifier)"), nil)
|
|
69
|
-
return {}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let imageOptions = PHImageRequestOptions()
|
|
73
|
-
|
|
74
|
-
var targetSize = size.applying(CGAffineTransform(scaleX: scale, y: scale))
|
|
75
|
-
|
|
76
|
-
if let targetSizeString = queryParams["targetSize"] {
|
|
77
|
-
if targetSizeString.caseInsensitiveCompare("PHImageManagerMaximumSize") == .orderedSame {
|
|
78
|
-
targetSize = PHImageManagerMaximumSize
|
|
79
|
-
} else {
|
|
80
|
-
let components = targetSizeString.lowercased().components(separatedBy: "x")
|
|
81
|
-
guard components.count == 2,
|
|
82
|
-
let width = Double(components[0]),
|
|
83
|
-
let height = Double(components[1]) else {
|
|
84
|
-
completionHandler(RCTErrorWithMessage("Invalid targetSize format. Expected WIDTHxHEIGHT or PHImageManagerMaximumSize."), nil)
|
|
85
|
-
return {}
|
|
86
|
-
}
|
|
87
|
-
targetSize = CGSize(width: width, height: height)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if let deliveryModeString = queryParams["deliveryMode"] {
|
|
92
|
-
guard let deliveryMode = PHImageRequestOptionsDeliveryMode.from(queryParam: deliveryModeString) else {
|
|
93
|
-
completionHandler(RCTErrorWithMessage("Invalid deliveryMode value."), nil)
|
|
94
|
-
return {}
|
|
95
|
-
}
|
|
96
|
-
imageOptions.deliveryMode = deliveryMode
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if let resizeModeString = queryParams["resizeMode"] {
|
|
100
|
-
guard let resizeMode = PHImageRequestOptionsResizeMode.from(queryParam: resizeModeString) else {
|
|
101
|
-
completionHandler(RCTErrorWithMessage("Invalid resizeMode value."), nil)
|
|
102
|
-
return {}
|
|
103
|
-
}
|
|
104
|
-
imageOptions.resizeMode = resizeMode
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if let isNetworkAccessAllowedString = queryParams["isNetworkAccessAllowed"] {
|
|
108
|
-
imageOptions.isNetworkAccessAllowed = Bool.from(queryParam: isNetworkAccessAllowedString)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
var contentMode: PHImageContentMode = .default
|
|
112
|
-
if let contentModeString = queryParams["contentMode"] {
|
|
113
|
-
guard let _contentMode = PHImageContentMode.from(queryParam: contentModeString) else {
|
|
114
|
-
completionHandler(RCTErrorWithMessage("Invalid contentMode value."), nil)
|
|
115
|
-
return {}
|
|
116
|
-
}
|
|
117
|
-
contentMode = _contentMode
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if let progressHandler = progressHandler {
|
|
121
|
-
imageOptions.progressHandler = { progress, error, stop, info in
|
|
122
|
-
let multiplier: Int64 = 1_000_000
|
|
123
|
-
progressHandler(Int64(progress * Double(multiplier)), multiplier)
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
let requestID = PHImageManager.default().requestImage(
|
|
128
|
-
for: asset,
|
|
129
|
-
targetSize: targetSize,
|
|
130
|
-
contentMode: contentMode,
|
|
131
|
-
options: imageOptions
|
|
132
|
-
) { result, info in
|
|
133
|
-
guard let info = info else {
|
|
134
|
-
return
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
let isCancelled = (info[PHImageCancelledKey] as? NSNumber)?.boolValue ?? false
|
|
138
|
-
let isDegraded = (info[PHImageResultIsDegradedKey] as? NSNumber)?.boolValue ?? false
|
|
139
|
-
|
|
140
|
-
if isCancelled {
|
|
141
|
-
return
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if let result = result {
|
|
145
|
-
if isDegraded {
|
|
146
|
-
partialLoadHandler?(result)
|
|
147
|
-
} else {
|
|
148
|
-
completionHandler(nil, result)
|
|
149
|
-
}
|
|
150
|
-
} else if let error = info[PHImageErrorKey] as? Error {
|
|
151
|
-
completionHandler(error, nil)
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
PHImageManager.default().cancelImageRequest(requestID)
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// MARK: - RawRepresentable Extension
|
|
162
|
-
|
|
163
|
-
extension RawRepresentable where RawValue == Int {
|
|
164
|
-
static func from(queryParam string: String?) -> Self? {
|
|
165
|
-
guard let string = string, !string.isEmpty else {
|
|
166
|
-
return nil
|
|
167
|
-
}
|
|
168
|
-
guard let intValue = Int(string) else {
|
|
169
|
-
return nil
|
|
170
|
-
}
|
|
171
|
-
return Self(rawValue: intValue)
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// MARK: - Bool Extension
|
|
176
|
-
|
|
177
|
-
extension Bool {
|
|
178
|
-
static func from(queryParam string: String?) -> Bool {
|
|
179
|
-
guard let string = string, !string.isEmpty else {
|
|
180
|
-
return false
|
|
181
|
-
}
|
|
182
|
-
return string.lowercased() == "true"
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
#endif
|
|
187
|
-
|
package/src/PHImageSource.tsx
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { ImageSourcePropType } from "react-native";
|
|
2
|
-
import {
|
|
3
|
-
PHImageContentMode,
|
|
4
|
-
PHImageRequestOptionsDeliveryMode,
|
|
5
|
-
PHImageRequestOptionsResizeMode,
|
|
6
|
-
RequestImageTargetSize,
|
|
7
|
-
} from "./ExpoPhotos.types";
|
|
8
|
-
|
|
9
|
-
export interface PHImageSourceOptions {
|
|
10
|
-
localIdentifier: string;
|
|
11
|
-
targetSize?: RequestImageTargetSize;
|
|
12
|
-
resizeMode?: PHImageRequestOptionsResizeMode;
|
|
13
|
-
deliveryMode?: PHImageRequestOptionsDeliveryMode;
|
|
14
|
-
contentMode?: PHImageContentMode;
|
|
15
|
-
isNetworkAccessAllowed?: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const buildQueryString = (
|
|
19
|
-
params: Record<string, string | number | boolean | undefined>
|
|
20
|
-
): string => {
|
|
21
|
-
const entries = Object.entries(params).filter(
|
|
22
|
-
([, value]) => value !== undefined
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
if (entries.length === 0) {
|
|
26
|
-
return "";
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
"?" +
|
|
31
|
-
entries
|
|
32
|
-
.map(
|
|
33
|
-
([key, value]) =>
|
|
34
|
-
`${encodeURIComponent(key)}=${encodeURIComponent(value ?? "")}`
|
|
35
|
-
)
|
|
36
|
-
.join("&")
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Creates a source object for React Native's Image component from a Photos library asset identifier.
|
|
42
|
-
*
|
|
43
|
-
* @param options - Configuration for image source, including the local identifier
|
|
44
|
-
* @returns A source object that can be used with the Image component's `source` prop, or undefined if no identifier is provided
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```tsx
|
|
48
|
-
* import { Image } from 'react-native';
|
|
49
|
-
* import { createPHImageSource } from '@hortemo/expo-photos';
|
|
50
|
-
*
|
|
51
|
-
* <Image
|
|
52
|
-
* source={createPHImageSource({
|
|
53
|
-
* localIdentifier: asset.localIdentifier,
|
|
54
|
-
* targetSize: { width: 200, height: 200 },
|
|
55
|
-
* contentMode: PHImageContentMode.aspectFill,
|
|
56
|
-
* })}
|
|
57
|
-
* />
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export function createPHImageSource(
|
|
61
|
-
options: PHImageSourceOptions
|
|
62
|
-
): ImageSourcePropType {
|
|
63
|
-
const {
|
|
64
|
-
localIdentifier,
|
|
65
|
-
resizeMode,
|
|
66
|
-
deliveryMode,
|
|
67
|
-
contentMode,
|
|
68
|
-
isNetworkAccessAllowed,
|
|
69
|
-
} = options;
|
|
70
|
-
|
|
71
|
-
const targetSize =
|
|
72
|
-
options.targetSize && typeof options.targetSize === "object"
|
|
73
|
-
? `${options.targetSize.width}x${options.targetSize.height}`
|
|
74
|
-
: options.targetSize;
|
|
75
|
-
|
|
76
|
-
const query = buildQueryString({
|
|
77
|
-
localIdentifier,
|
|
78
|
-
targetSize,
|
|
79
|
-
resizeMode,
|
|
80
|
-
deliveryMode,
|
|
81
|
-
contentMode,
|
|
82
|
-
isNetworkAccessAllowed,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
return { uri: `expo-photos://${query}` };
|
|
86
|
-
}
|