expo-sharing 57.0.25 → 57.0.26
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/CHANGELOG.md +6 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/sharing/ShareIntoFileStore.kt +40 -0
- package/android/src/main/java/expo/modules/sharing/SharingModule.kt +1 -0
- package/android/src/main/java/expo/modules/sharing/dataParsers/ResolvingShareIntentDataParser.kt +4 -3
- package/build/Sharing.d.ts +3 -0
- package/build/Sharing.d.ts.map +1 -1
- package/build/Sharing.js +3 -0
- package/build/Sharing.js.map +1 -1
- package/build/Sharing.types.d.ts +5 -0
- package/build/Sharing.types.d.ts.map +1 -1
- package/build/Sharing.types.js.map +1 -1
- package/build/useIncomingShare.d.ts.map +1 -1
- package/build/useIncomingShare.js +9 -1
- package/build/useIncomingShare.js.map +1 -1
- package/expo-module.config.json +1 -1
- package/ios/SharingModule.swift +1 -0
- package/ios/shared/ShareIntoFileStore.swift +46 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26-sources.jar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26-sources.jar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26-sources.jar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26-sources.jar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.aar.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.aar.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.aar.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.aar.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/{57.0.25/expo.modules.sharing-57.0.25.module → 57.0.26/expo.modules.sharing-57.0.26.module} +22 -22
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.module.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.module.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.module.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.module.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/{57.0.25/expo.modules.sharing-57.0.25.pom → 57.0.26/expo.modules.sharing-57.0.26.pom} +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.pom.md5 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.pom.sha1 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.pom.sha256 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.26/expo.modules.sharing-57.0.26.pom.sha512 +1 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/maven-metadata.xml +4 -4
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/maven-metadata.xml.sha512 +1 -1
- package/package.json +4 -4
- package/plugin/template-files/ios/ShareIntoViewController.swift +7 -10
- package/src/Sharing.ts +3 -0
- package/src/Sharing.types.ts +5 -0
- package/src/useIncomingShare.ts +14 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25-sources.jar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25-sources.jar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25-sources.jar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25-sources.jar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25-sources.jar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.aar +0 -0
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.aar.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.aar.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.aar.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.aar.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.module.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.module.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.module.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.module.sha512 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.pom.md5 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.pom.sha1 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.pom.sha256 +0 -1
- package/local-maven-repo/host/exp/exponent/expo.modules.sharing/57.0.25/expo.modules.sharing-57.0.25.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 57.0.26 — 2026-11-12
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Store files shared into the app in a unique directory for each file, with a safe file name. Files with the same name no longer replace each other. `clearSharedPayloads()` now deletes these files, and files older than 24 hours are deleted when new shared files are processed. On iOS, the files are now in the app group's `Library/Caches/expo-sharing` directory. `useIncomingShare()` now also clears its returned payloads when you call `clearSharedPayloads()`. ([#51839](https://github.com/expo/expo/pull/51839) by [@behenate](https://github.com/behenate))
|
|
18
|
+
|
|
13
19
|
## 57.0.25 — 2026-11-05
|
|
14
20
|
|
|
15
21
|
_This version does not introduce any user-facing changes._
|
package/android/build.gradle
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package expo.modules.sharing
|
|
2
|
+
|
|
3
|
+
import java.io.File
|
|
4
|
+
import java.util.UUID
|
|
5
|
+
|
|
6
|
+
internal fun safeShareFileName(name: String = "", fallback: String): String {
|
|
7
|
+
val safeName = name.replace('/', '_').replace('\\', '_').replace('\u0000', '_')
|
|
8
|
+
return if (safeName.isEmpty() || safeName == "." || safeName == "..") {
|
|
9
|
+
fallback
|
|
10
|
+
} else {
|
|
11
|
+
safeName
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
internal class ShareIntoFileStore(cacheDir: File) {
|
|
16
|
+
val root = File(cacheDir, "expo-sharing")
|
|
17
|
+
|
|
18
|
+
fun newDestination(fileName: String): File {
|
|
19
|
+
val directory = File(root, UUID.randomUUID().toString())
|
|
20
|
+
directory.mkdirs()
|
|
21
|
+
return File(directory, fileName)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
fun removeStaleFiles() {
|
|
25
|
+
val threshold = System.currentTimeMillis() - STALE_FILE_AGE_MS
|
|
26
|
+
root.listFiles()?.forEach { directory ->
|
|
27
|
+
if (directory.lastModified() < threshold) {
|
|
28
|
+
directory.deleteRecursively()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fun removeAll() {
|
|
34
|
+
root.deleteRecursively()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
companion object {
|
|
38
|
+
const val STALE_FILE_AGE_MS = 24 * 60 * 60 * 1000L
|
|
39
|
+
}
|
|
40
|
+
}
|
package/android/src/main/java/expo/modules/sharing/dataParsers/ResolvingShareIntentDataParser.kt
CHANGED
|
@@ -5,7 +5,6 @@ import android.content.Intent
|
|
|
5
5
|
import android.content.Context
|
|
6
6
|
import android.net.Uri
|
|
7
7
|
import android.provider.OpenableColumns
|
|
8
|
-
import java.io.File
|
|
9
8
|
import java.io.FileOutputStream
|
|
10
9
|
import java.net.HttpURLConnection
|
|
11
10
|
import java.net.URL
|
|
@@ -16,6 +15,7 @@ class ResolvingShareIntentDataParser {
|
|
|
16
15
|
companion object {
|
|
17
16
|
fun parse(context: Context, intent: Intent): List<ResolvedSharePayload> {
|
|
18
17
|
val type = intent.type ?: return emptyList()
|
|
18
|
+
ShareIntoFileStore(context.cacheDir).removeStaleFiles()
|
|
19
19
|
|
|
20
20
|
return when (intent.action) {
|
|
21
21
|
Intent.ACTION_SEND -> handleSendAction(context, intent, type)
|
|
@@ -56,13 +56,13 @@ class ResolvingShareIntentDataParser {
|
|
|
56
56
|
|
|
57
57
|
private fun resolveUri(context: Context, uri: Uri, mimeType: String): ResolvedSharePayload {
|
|
58
58
|
val contentResolver = context.contentResolver
|
|
59
|
-
val fileName = getFileName(contentResolver, uri)
|
|
59
|
+
val fileName = safeShareFileName(getFileName(contentResolver, uri).orEmpty(), "unknown")
|
|
60
60
|
val fileSize = getFileSize(contentResolver, uri)
|
|
61
61
|
val specificMimeType = contentResolver.getType(uri) ?: mimeType
|
|
62
62
|
val type = ShareType.fromMimeType(specificMimeType)
|
|
63
63
|
|
|
64
64
|
// Copy to cache dir to ensure access
|
|
65
|
-
val file =
|
|
65
|
+
val file = ShareIntoFileStore(context.cacheDir).newDestination(fileName)
|
|
66
66
|
try {
|
|
67
67
|
contentResolver.openInputStream(uri)?.use { input ->
|
|
68
68
|
FileOutputStream(file).use { output ->
|
|
@@ -71,6 +71,7 @@ class ResolvingShareIntentDataParser {
|
|
|
71
71
|
}
|
|
72
72
|
} catch (e: Exception) {
|
|
73
73
|
e.printStackTrace()
|
|
74
|
+
file.parentFile?.deleteRecursively()
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
return ResolvedSharePayload().apply {
|
package/build/Sharing.d.ts
CHANGED
|
@@ -32,6 +32,9 @@ export declare function getSharedPayloads(): SharePayload[];
|
|
|
32
32
|
export declare function getResolvedSharedPayloadsAsync(): Promise<ResolvedSharePayload[]>;
|
|
33
33
|
/**
|
|
34
34
|
* Clears the data shared with the app.
|
|
35
|
+
* On Android and iOS, it also deletes the copies of shared files that `expo-sharing` keeps in a cache directory.
|
|
36
|
+
*
|
|
37
|
+
* > **Note:** Copy the files you want to keep before you call this method. After it runs, the `contentUri` of a file shared into the app no longer points to a file.
|
|
35
38
|
*/
|
|
36
39
|
export declare function clearSharedPayloads(): void;
|
|
37
40
|
//# sourceMappingURL=Sharing.d.ts.map
|
package/build/Sharing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sharing.d.ts","sourceRoot":"","sources":["../src/Sharing.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAI1F;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CASzD;AAGD;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKzF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,YAAY,EAAE,CAElD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAEtF;AAED
|
|
1
|
+
{"version":3,"file":"Sharing.d.ts","sourceRoot":"","sources":["../src/Sharing.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAI1F;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CASzD;AAGD;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKzF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,YAAY,EAAE,CAElD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAEtF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
|
package/build/Sharing.js
CHANGED
|
@@ -52,6 +52,9 @@ export async function getResolvedSharedPayloadsAsync() {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Clears the data shared with the app.
|
|
55
|
+
* On Android and iOS, it also deletes the copies of shared files that `expo-sharing` keeps in a cache directory.
|
|
56
|
+
*
|
|
57
|
+
* > **Note:** Copy the files you want to keep before you call this method. After it runs, the `contentUri` of a file shared into the app no longer points to a file.
|
|
55
58
|
*/
|
|
56
59
|
export function clearSharedPayloads() {
|
|
57
60
|
SharingNativeModule.clearSharedPayloads();
|
package/build/Sharing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sharing.js","sourceRoot":"","sources":["../src/Sharing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,cAAc;AACd;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,mBAAmB,EAAE,CAAC;QACxB,IAAI,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;YACzC,OAAO,MAAM,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;QACtD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,UAA0B,EAAE;IACxE,IAAI,CAAC,mBAAmB,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,CAAC;QAC5D,MAAM,IAAI,mBAAmB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,MAAM,mBAAmB,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,mBAAmB,CAAC,iBAAiB,EAAE,CAAC;AACjD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B;IAClD,OAAO,MAAM,mBAAmB,CAAC,8BAA8B,EAAE,CAAC;AACpE,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"Sharing.js","sourceRoot":"","sources":["../src/Sharing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,cAAc;AACd;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,mBAAmB,EAAE,CAAC;QACxB,IAAI,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;YACzC,OAAO,MAAM,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;QACtD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,UAA0B,EAAE;IACxE,IAAI,CAAC,mBAAmB,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,CAAC;QAC5D,MAAM,IAAI,mBAAmB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,MAAM,mBAAmB,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,mBAAmB,CAAC,iBAAiB,EAAE,CAAC;AACjD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B;IAClD,OAAO,MAAM,mBAAmB,CAAC,8BAA8B,EAAE,CAAC;AACpE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB;IACjC,mBAAmB,CAAC,mBAAmB,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport type { ResolvedSharePayload, SharePayload, SharingOptions } from './Sharing.types';\nimport SharingNativeModule from './SharingNativeModule';\n\n// @needsAudit\n/**\n * Determine if the sharing API can be used in this app.\n * @return A promise that fulfills with `true` if the sharing API can be used, and `false` otherwise.\n */\nexport async function isAvailableAsync(): Promise<boolean> {\n if (SharingNativeModule) {\n if (SharingNativeModule.isAvailableAsync) {\n return await SharingNativeModule.isAvailableAsync();\n }\n return true;\n }\n\n return false;\n}\n\n// @needsAudit\n/**\n * Opens action sheet to share file to different applications which can handle this type of file.\n * @param url Local file URL to share.\n * @param options A map of share options.\n */\nexport async function shareAsync(url: string, options: SharingOptions = {}): Promise<void> {\n if (!SharingNativeModule || !SharingNativeModule.shareAsync) {\n throw new UnavailabilityError('Sharing', 'shareAsync');\n }\n return await SharingNativeModule.shareAsync(url, options);\n}\n\n/**\n * Returns raw data shared with the app. Returns an empty array if no data has been shared with the app.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport function getSharedPayloads(): SharePayload[] {\n return SharingNativeModule.getSharedPayloads();\n}\n\n/**\n * Returns resolved data shared with the app. Compared to data returned from [`getSharedPayloads`](#sharinggetsharedpayloads) contains additional\n * information useful for reading and displaying the data. For example, when a web `URL` is shared with the app,\n * a resolved payload will contain additional information about the URL contents.\n *\n * > Depending on what has been shared, this method may require a network connection to resolve content details.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport async function getResolvedSharedPayloadsAsync(): Promise<ResolvedSharePayload[]> {\n return await SharingNativeModule.getResolvedSharedPayloadsAsync();\n}\n\n/**\n * Clears the data shared with the app.\n * On Android and iOS, it also deletes the copies of shared files that `expo-sharing` keeps in a cache directory.\n *\n * > **Note:** Copy the files you want to keep before you call this method. After it runs, the `contentUri` of a file shared into the app no longer points to a file.\n */\nexport function clearSharedPayloads(): void {\n SharingNativeModule.clearSharedPayloads();\n}\n"]}
|
package/build/Sharing.types.d.ts
CHANGED
|
@@ -82,6 +82,10 @@ export type BaseResolvedSharePayload = SharePayload & {
|
|
|
82
82
|
/**
|
|
83
83
|
* URI which can be used to access the shared content. When resolving contents of a URL with redirects, contains the redirect target URI.
|
|
84
84
|
* Null when resolving a [`SharePayload`](#sharepayload) with a `text` [`ShareType`](#sharetype).
|
|
85
|
+
*
|
|
86
|
+
* > **Note:** On Android and iOS, the URI of a file shared into the app points to a file in a cache directory. On iOS, this is the app group's `Library/Caches` directory.
|
|
87
|
+
* > The system can delete this file when storage is low. `expo-sharing` deletes files older than 24 hours when it processes new shared files.
|
|
88
|
+
* > [`Sharing.clearSharedPayloads()`](#sharingclearsharedpayloads) deletes all shared files right away. Copy the file to keep it.
|
|
85
89
|
*/
|
|
86
90
|
contentUri: string | null;
|
|
87
91
|
/**
|
|
@@ -147,6 +151,7 @@ export type UseIncomingShareResult = {
|
|
|
147
151
|
resolvedSharedPayloads: ResolvedSharePayload[];
|
|
148
152
|
/**
|
|
149
153
|
* Clears payloads shared with the app.
|
|
154
|
+
* On Android and iOS, it also deletes the copies of shared files that `expo-sharing` keeps in a cache directory. Copy the files you want to keep before you call it.
|
|
150
155
|
*/
|
|
151
156
|
clearSharedPayloads: () => void;
|
|
152
157
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sharing.types.d.ts","sourceRoot":"","sources":["../src/Sharing.types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE;QACP,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAIF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CA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":[],"mappings":"","sourcesContent":["// @needsAudit\nexport type SharingOptions = {\n /**\n * Sets `mimeType` for `Intent`.\n * @platform android\n */\n mimeType?: string;\n /**\n * [Uniform Type Identifier](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html)\n * - the type of the target file.\n * @platform ios\n */\n UTI?: string;\n /**\n * Sets share dialog title.\n * @platform android\n * @platform web\n */\n dialogTitle?: string;\n /**\n * Sets the anchor point for iPad\n * @platform ios\n */\n anchor?: {\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n };\n};\n\n// MARK: - Share into types\n\n/**\n * Determines the type of content being shared.\n * - `text`: Plain text content.\n * - `url`: A specific URL.\n * - `audio`: An audio file.\n * - `image`: An image file.\n * - `video`: A video file.\n * - `file`: A generic file.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type ShareType = 'text' | 'url' | 'audio' | 'image' | 'video' | 'file';\n\n/**\n * Describes the resolved content type.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type ContentType = 'text' | 'audio' | 'image' | 'video' | 'file' | 'website';\n\n/**\n * Represents raw data shared with the app.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type SharePayload = {\n /**\n * The primary value of the content.\n * - For `text`, this is the message body.\n * - For `url`, this is the URL string.\n * - For `file`, `image`, `video`, or `audio`, this is typically the file URI.\n *\n * @default \"\"\n */\n value: string;\n\n /**\n * The type of the shared content.\n * @default 'text'\n */\n shareType: ShareType;\n\n /**\n * The MIME type of the contents of the`value` field.\n *\n * @default 'text/plain'\n */\n mimeType?: string;\n};\n\nexport type BaseResolvedSharePayload = SharePayload & {\n /**\n * URI which can be used to access the shared content. When resolving contents of a URL with redirects, contains the redirect target URI.\n * Null when resolving a [`SharePayload`](#sharepayload) with a `text` [`ShareType`](#sharetype).\n */\n contentUri: string | null;\n\n /**\n * Type of the content accessible via the `contentUri`.\n */\n contentType: ContentType | null;\n\n /**\n * Mime type of the content accessible via the `contentUri`.\n */\n contentMimeType: string | null;\n\n /**\n * If applicable, value of the `suggestedFilename` HTTP header field, otherwise the last path component of the `contentUri` field.\n */\n originalName: string | null;\n\n /**\n * Size of the content accessible via the `contentUri`.\n */\n contentSize: number | null;\n};\n\n/**\n * Represents a resolved payload, for which the data can be accessed through a URI.\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type UriBasedResolvedSharePayload = BaseResolvedSharePayload & {\n contentType: 'audio' | 'file' | 'video' | 'image' | 'website';\n contentUri: string;\n};\n\n/**\n * Represents a resolved payload, where a text was shared with the app.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type TextBasedResolvedSharePayload = BaseResolvedSharePayload & {\n contentType?: 'text';\n};\n\n/**\n * Represents a payload shared with the app, with additional information about the shared contents.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type ResolvedSharePayload = UriBasedResolvedSharePayload | TextBasedResolvedSharePayload;\n\n/**\n * Object returned by [`useIncomingShare`](#useincomingshare) hook containing information about data shared with the app.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type UseIncomingShareResult = {\n /**\n * Returns unresolved payloads shared with the app. Synchronous and available immediately after creating the hook.\n */\n sharedPayloads: SharePayload[];\n /**\n * Contains an array of resolved payloads shared with the app. Returns an empty array if the shared payloads are being resolved or if the resolving has failed.\n */\n resolvedSharedPayloads: ResolvedSharePayload[];\n /**\n * Clears payloads shared with the app.\n */\n clearSharedPayloads: () => void;\n /**\n * Boolean indicating whether the current shared payloads are being resolved.\n */\n isResolving: boolean;\n /**\n * Contains an error encountered while resolving the shared payload. Null on success.\n */\n error: Error | null;\n /**\n * Forces a refresh of the shared payloads.\n */\n refreshSharePayloads: () => void;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Sharing.types.js","sourceRoot":"","sources":["../src/Sharing.types.ts"],"names":[],"mappings":"","sourcesContent":["// @needsAudit\nexport type SharingOptions = {\n /**\n * Sets `mimeType` for `Intent`.\n * @platform android\n */\n mimeType?: string;\n /**\n * [Uniform Type Identifier](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html)\n * - the type of the target file.\n * @platform ios\n */\n UTI?: string;\n /**\n * Sets share dialog title.\n * @platform android\n * @platform web\n */\n dialogTitle?: string;\n /**\n * Sets the anchor point for iPad\n * @platform ios\n */\n anchor?: {\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n };\n};\n\n// MARK: - Share into types\n\n/**\n * Determines the type of content being shared.\n * - `text`: Plain text content.\n * - `url`: A specific URL.\n * - `audio`: An audio file.\n * - `image`: An image file.\n * - `video`: A video file.\n * - `file`: A generic file.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type ShareType = 'text' | 'url' | 'audio' | 'image' | 'video' | 'file';\n\n/**\n * Describes the resolved content type.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type ContentType = 'text' | 'audio' | 'image' | 'video' | 'file' | 'website';\n\n/**\n * Represents raw data shared with the app.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type SharePayload = {\n /**\n * The primary value of the content.\n * - For `text`, this is the message body.\n * - For `url`, this is the URL string.\n * - For `file`, `image`, `video`, or `audio`, this is typically the file URI.\n *\n * @default \"\"\n */\n value: string;\n\n /**\n * The type of the shared content.\n * @default 'text'\n */\n shareType: ShareType;\n\n /**\n * The MIME type of the contents of the`value` field.\n *\n * @default 'text/plain'\n */\n mimeType?: string;\n};\n\nexport type BaseResolvedSharePayload = SharePayload & {\n /**\n * URI which can be used to access the shared content. When resolving contents of a URL with redirects, contains the redirect target URI.\n * Null when resolving a [`SharePayload`](#sharepayload) with a `text` [`ShareType`](#sharetype).\n *\n * > **Note:** On Android and iOS, the URI of a file shared into the app points to a file in a cache directory. On iOS, this is the app group's `Library/Caches` directory.\n * > The system can delete this file when storage is low. `expo-sharing` deletes files older than 24 hours when it processes new shared files.\n * > [`Sharing.clearSharedPayloads()`](#sharingclearsharedpayloads) deletes all shared files right away. Copy the file to keep it.\n */\n contentUri: string | null;\n\n /**\n * Type of the content accessible via the `contentUri`.\n */\n contentType: ContentType | null;\n\n /**\n * Mime type of the content accessible via the `contentUri`.\n */\n contentMimeType: string | null;\n\n /**\n * If applicable, value of the `suggestedFilename` HTTP header field, otherwise the last path component of the `contentUri` field.\n */\n originalName: string | null;\n\n /**\n * Size of the content accessible via the `contentUri`.\n */\n contentSize: number | null;\n};\n\n/**\n * Represents a resolved payload, for which the data can be accessed through a URI.\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type UriBasedResolvedSharePayload = BaseResolvedSharePayload & {\n contentType: 'audio' | 'file' | 'video' | 'image' | 'website';\n contentUri: string;\n};\n\n/**\n * Represents a resolved payload, where a text was shared with the app.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type TextBasedResolvedSharePayload = BaseResolvedSharePayload & {\n contentType?: 'text';\n};\n\n/**\n * Represents a payload shared with the app, with additional information about the shared contents.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type ResolvedSharePayload = UriBasedResolvedSharePayload | TextBasedResolvedSharePayload;\n\n/**\n * Object returned by [`useIncomingShare`](#useincomingshare) hook containing information about data shared with the app.\n *\n * @platform android\n * @platform ios\n * @experimental\n */\nexport type UseIncomingShareResult = {\n /**\n * Returns unresolved payloads shared with the app. Synchronous and available immediately after creating the hook.\n */\n sharedPayloads: SharePayload[];\n /**\n * Contains an array of resolved payloads shared with the app. Returns an empty array if the shared payloads are being resolved or if the resolving has failed.\n */\n resolvedSharedPayloads: ResolvedSharePayload[];\n /**\n * Clears payloads shared with the app.\n * On Android and iOS, it also deletes the copies of shared files that `expo-sharing` keeps in a cache directory. Copy the files you want to keep before you call it.\n */\n clearSharedPayloads: () => void;\n /**\n * Boolean indicating whether the current shared payloads are being resolved.\n */\n isResolving: boolean;\n /**\n * Contains an error encountered while resolving the shared payload. Null on success.\n */\n error: Error | null;\n /**\n * Forces a refresh of the shared payloads.\n */\n refreshSharePayloads: () => void;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIncomingShare.d.ts","sourceRoot":"","sources":["../src/useIncomingShare.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIncomingShare.d.ts","sourceRoot":"","sources":["../src/useIncomingShare.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAsC,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AA6BlG;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAsEzD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState, useCallback, useRef } from 'react';
|
|
2
2
|
import { AppState } from 'react-native';
|
|
3
|
-
import { clearSharedPayloads, getResolvedSharedPayloadsAsync, getSharedPayloads } from './Sharing';
|
|
3
|
+
import { clearSharedPayloads as clearNativeSharedPayloads, getResolvedSharedPayloadsAsync, getSharedPayloads, } from './Sharing';
|
|
4
4
|
function sharePayloadsAreEqual(a, b) {
|
|
5
5
|
if (a.length !== b.length) {
|
|
6
6
|
return false;
|
|
@@ -59,6 +59,14 @@ export function useIncomingShare() {
|
|
|
59
59
|
setError(e instanceof Error ? e : new Error('Failed to resolve data'));
|
|
60
60
|
}
|
|
61
61
|
}, []);
|
|
62
|
+
const clearSharedPayloads = useCallback(() => {
|
|
63
|
+
clearNativeSharedPayloads();
|
|
64
|
+
currentSharedDataRef.current = [];
|
|
65
|
+
setSharedPayloads([]);
|
|
66
|
+
setResolvedSharedPayloads([]);
|
|
67
|
+
setIsResolving(false);
|
|
68
|
+
setError(null);
|
|
69
|
+
}, []);
|
|
62
70
|
useEffect(() => {
|
|
63
71
|
refreshSharePayloads();
|
|
64
72
|
const subscription = AppState.addEventListener('change', (nextAppState) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIncomingShare.js","sourceRoot":"","sources":["../src/useIncomingShare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE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{ AppStateStatus } from 'react-native';\nimport { AppState } from 'react-native';\n\nimport {\n clearSharedPayloads as clearNativeSharedPayloads,\n getResolvedSharedPayloadsAsync,\n getSharedPayloads,\n} from './Sharing';\nimport type { ResolvedSharePayload, SharePayload, UseIncomingShareResult } from './Sharing.types';\n\nfunction sharePayloadsAreEqual(a: SharePayload[], b: SharePayload[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n\n const counts = new Map<string, number>();\n const getKey = (item: SharePayload) => `${item.value}|${item.mimeType}|${item.shareType}`;\n\n for (const item of a) {\n const key = getKey(item);\n counts.set(key, (counts.get(key) || 0) + 1);\n }\n\n for (const item of b) {\n const key = getKey(item);\n const count = counts.get(key);\n\n if (!count) {\n return false;\n }\n\n counts.set(key, count - 1);\n }\n\n return true;\n}\n\n/**\n * Hook, which returns the data shared with the application and updates the data if the shared payload has changed.\n */\nexport function useIncomingShare(): UseIncomingShareResult {\n const [sharedPayloads, setSharedPayloads] = useState<SharePayload[]>(getSharedPayloads());\n const [resolvedSharedPayloads, setResolvedSharedPayloads] = useState<ResolvedSharePayload[]>([]);\n const [isResolving, setIsResolving] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const currentSharedDataRef = useRef<SharePayload[]>([]);\n\n const refreshSharePayloads = useCallback(async () => {\n try {\n const newSharedData: SharePayload[] = getSharedPayloads();\n\n // Do not run `getResolvedSharedDataAsync` if the data hasn't changed to reduce network usage\n if (sharePayloadsAreEqual(newSharedData, currentSharedDataRef.current)) {\n return;\n }\n\n currentSharedDataRef.current = newSharedData;\n setSharedPayloads(newSharedData);\n setResolvedSharedPayloads([]);\n setError(null);\n\n if (newSharedData.length > 0) {\n setIsResolving(true);\n try {\n const resolved = await getResolvedSharedPayloadsAsync();\n setResolvedSharedPayloads(resolved);\n } catch (e) {\n setError(\n e instanceof Error ? e : new Error('Unknown error during shared payload resolution')\n );\n } finally {\n setIsResolving(false);\n }\n }\n } catch (e) {\n setError(e instanceof Error ? e : new Error('Failed to resolve data'));\n }\n }, []);\n\n const clearSharedPayloads = useCallback(() => {\n clearNativeSharedPayloads();\n currentSharedDataRef.current = [];\n setSharedPayloads([]);\n setResolvedSharedPayloads([]);\n setIsResolving(false);\n setError(null);\n }, []);\n\n useEffect(() => {\n refreshSharePayloads();\n\n const subscription = AppState.addEventListener('change', (nextAppState: AppStateStatus) => {\n if (nextAppState === 'active') {\n refreshSharePayloads();\n }\n });\n\n return () => {\n subscription.remove();\n };\n }, [refreshSharePayloads]);\n\n return {\n sharedPayloads,\n resolvedSharedPayloads,\n clearSharedPayloads,\n isResolving,\n error,\n refreshSharePayloads,\n };\n}\n"]}
|
package/expo-module.config.json
CHANGED
package/ios/SharingModule.swift
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
func safeShareFileName(_ name: String = "", fallback: String) -> String {
|
|
4
|
+
let safeName = name
|
|
5
|
+
.replacingOccurrences(of: "/", with: "_")
|
|
6
|
+
.replacingOccurrences(of: "\\", with: "_")
|
|
7
|
+
.replacingOccurrences(of: "\u{0}", with: "_")
|
|
8
|
+
return safeName.isEmpty || safeName == "." || safeName == ".." ? fallback : safeName
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
struct ShareIntoFileStore {
|
|
12
|
+
static let staleFileAge: TimeInterval = 24 * 60 * 60
|
|
13
|
+
|
|
14
|
+
let rootURL: URL
|
|
15
|
+
|
|
16
|
+
init?(appGroupId: String) {
|
|
17
|
+
guard let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupId) else {
|
|
18
|
+
return nil
|
|
19
|
+
}
|
|
20
|
+
rootURL = containerURL.appendingPathComponent("Library/Caches/expo-sharing", isDirectory: true)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func makeDestination(fileName: String) throws -> URL {
|
|
24
|
+
let directory = rootURL.appendingPathComponent(UUID().uuidString, isDirectory: true)
|
|
25
|
+
try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)
|
|
26
|
+
return directory.appendingPathComponent(fileName, isDirectory: false)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
func removeStaleFiles() {
|
|
30
|
+
let fileManager = FileManager.default
|
|
31
|
+
guard let directories = try? fileManager.contentsOfDirectory(at: rootURL, includingPropertiesForKeys: [.creationDateKey]) else {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
let threshold = Date().addingTimeInterval(-Self.staleFileAge)
|
|
35
|
+
for directory in directories {
|
|
36
|
+
let createdAt = try? directory.resourceValues(forKeys: [.creationDateKey]).creationDate
|
|
37
|
+
if let createdAt, createdAt < threshold {
|
|
38
|
+
try? fileManager.removeItem(at: directory)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
func removeAll() {
|
|
44
|
+
try? FileManager.default.removeItem(at: rootURL)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3475c1c5db85257271afa79a68eae087
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
96f40afb5384b8c3c0b279aaf59fc81d5e5cca1a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
02d6aacb230a5f6420b66a5644351df039f6e3055d60b5dd532af8677a6c2900
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
51c9e5d21b3e4e209720fcfa6d506abca8826e45a18044f116495f166f48c5ed195ed3b064fffdd433898ba26b9f0e849010f98a5bda1f4cc9efc76e5dcb57f9
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7c2d6b845c1236628983c5c0f2b9c292
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a4ebf75fe77ab0fd195a44927359d89be18eaf4c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5a5874a2d136e85cb69661f47471e2cd898c9ae0e5db3f4905265e59d0e64f7b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7d763b5ca256dcc6f78f24b71ba2ea9bb709447eab46b805eb59ef26baf0acd9ac566182c16cc5f7f6c0ae2b7e2bad5bba0a5a6cc6a6824b66e43a7025a4825e
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"component": {
|
|
4
4
|
"group": "host.exp.exponent",
|
|
5
5
|
"module": "expo.modules.sharing",
|
|
6
|
-
"version": "57.0.
|
|
6
|
+
"version": "57.0.26",
|
|
7
7
|
"attributes": {
|
|
8
8
|
"org.gradle.status": "release"
|
|
9
9
|
}
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
{
|
|
27
|
-
"name": "expo.modules.sharing-57.0.
|
|
28
|
-
"url": "expo.modules.sharing-57.0.
|
|
29
|
-
"size":
|
|
30
|
-
"sha512": "
|
|
31
|
-
"sha256": "
|
|
32
|
-
"sha1": "
|
|
33
|
-
"md5": "
|
|
27
|
+
"name": "expo.modules.sharing-57.0.26.aar",
|
|
28
|
+
"url": "expo.modules.sharing-57.0.26.aar",
|
|
29
|
+
"size": 62723,
|
|
30
|
+
"sha512": "7d763b5ca256dcc6f78f24b71ba2ea9bb709447eab46b805eb59ef26baf0acd9ac566182c16cc5f7f6c0ae2b7e2bad5bba0a5a6cc6a6824b66e43a7025a4825e",
|
|
31
|
+
"sha256": "5a5874a2d136e85cb69661f47471e2cd898c9ae0e5db3f4905265e59d0e64f7b",
|
|
32
|
+
"sha1": "a4ebf75fe77ab0fd195a44927359d89be18eaf4c",
|
|
33
|
+
"md5": "7c2d6b845c1236628983c5c0f2b9c292"
|
|
34
34
|
}
|
|
35
35
|
]
|
|
36
36
|
},
|
|
@@ -71,13 +71,13 @@
|
|
|
71
71
|
],
|
|
72
72
|
"files": [
|
|
73
73
|
{
|
|
74
|
-
"name": "expo.modules.sharing-57.0.
|
|
75
|
-
"url": "expo.modules.sharing-57.0.
|
|
76
|
-
"size":
|
|
77
|
-
"sha512": "
|
|
78
|
-
"sha256": "
|
|
79
|
-
"sha1": "
|
|
80
|
-
"md5": "
|
|
74
|
+
"name": "expo.modules.sharing-57.0.26.aar",
|
|
75
|
+
"url": "expo.modules.sharing-57.0.26.aar",
|
|
76
|
+
"size": 62723,
|
|
77
|
+
"sha512": "7d763b5ca256dcc6f78f24b71ba2ea9bb709447eab46b805eb59ef26baf0acd9ac566182c16cc5f7f6c0ae2b7e2bad5bba0a5a6cc6a6824b66e43a7025a4825e",
|
|
78
|
+
"sha256": "5a5874a2d136e85cb69661f47471e2cd898c9ae0e5db3f4905265e59d0e64f7b",
|
|
79
|
+
"sha1": "a4ebf75fe77ab0fd195a44927359d89be18eaf4c",
|
|
80
|
+
"md5": "7c2d6b845c1236628983c5c0f2b9c292"
|
|
81
81
|
}
|
|
82
82
|
]
|
|
83
83
|
},
|
|
@@ -91,13 +91,13 @@
|
|
|
91
91
|
},
|
|
92
92
|
"files": [
|
|
93
93
|
{
|
|
94
|
-
"name": "expo.modules.sharing-57.0.
|
|
95
|
-
"url": "expo.modules.sharing-57.0.
|
|
96
|
-
"size":
|
|
97
|
-
"sha512": "
|
|
98
|
-
"sha256": "
|
|
99
|
-
"sha1": "
|
|
100
|
-
"md5": "
|
|
94
|
+
"name": "expo.modules.sharing-57.0.26-sources.jar",
|
|
95
|
+
"url": "expo.modules.sharing-57.0.26-sources.jar",
|
|
96
|
+
"size": 10427,
|
|
97
|
+
"sha512": "51c9e5d21b3e4e209720fcfa6d506abca8826e45a18044f116495f166f48c5ed195ed3b064fffdd433898ba26b9f0e849010f98a5bda1f4cc9efc76e5dcb57f9",
|
|
98
|
+
"sha256": "02d6aacb230a5f6420b66a5644351df039f6e3055d60b5dd532af8677a6c2900",
|
|
99
|
+
"sha1": "96f40afb5384b8c3c0b279aaf59fc81d5e5cca1a",
|
|
100
|
+
"md5": "3475c1c5db85257271afa79a68eae087"
|
|
101
101
|
}
|
|
102
102
|
]
|
|
103
103
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
83af980bbc872d26a83be3f4cc52eb18
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5a59deb32409204b023ea56af3dff8fb599b38a4
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b50df137ef8646de31f7e6f89c33d6cb7bc96204617a3823cad2dee45dd21697
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0c078a8ba518be6acc5e4bfb68446d7f04e74c43b236188804c5eb846d7e186ac79758cc2b95e4efc71c2aa876a8aa244e99abb2c4d14e664d9dbf422ea25f55
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<modelVersion>4.0.0</modelVersion>
|
|
10
10
|
<groupId>host.exp.exponent</groupId>
|
|
11
11
|
<artifactId>expo.modules.sharing</artifactId>
|
|
12
|
-
<version>57.0.
|
|
12
|
+
<version>57.0.26</version>
|
|
13
13
|
<packaging>aar</packaging>
|
|
14
14
|
<name>expo.modules.sharing</name>
|
|
15
15
|
<url>https://github.com/expo/expo</url>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
756842340160f07d17e93ca9cc36ba08
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
21b54f8e7c2ff69143245c3446d44d7391ea94fc
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
442156fe5859a246d84068c8c280f3e178143f426f9eece28f229a7ac5f69bff
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3ea4177e2fbe81bdb62491a825d88ce85c61f1ffb0366ec0c1037076e1a4bc132aaf84bc1c7194dfa678ac647f3c0f1d1ebe18cc13f28e02f9dc3be5c6777f22
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>host.exp.exponent</groupId>
|
|
4
4
|
<artifactId>expo.modules.sharing</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>57.0.
|
|
7
|
-
<release>57.0.
|
|
6
|
+
<latest>57.0.26</latest>
|
|
7
|
+
<release>57.0.26</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>57.0.
|
|
9
|
+
<version>57.0.26</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20261112131751</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
5619d4ee5240ac59bd5399ef628502cc
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
884865d796464eb4996ac98eea9ac1cbbe36a87a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4e9fdc0583757af6363e564560b5a4ac71dd3efb2c038f554c1e910b41ac448a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
ce122f17cd348a503cf8c7ead015913d7dd42ed86b71703b6c8ed45f71de1163740f834c362c261fd420b1db5f64e5730a256e1ed0874301fc23a98c604db696
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-sharing",
|
|
3
|
-
"version": "57.0.
|
|
3
|
+
"version": "57.0.26",
|
|
4
4
|
"description": "Provides a way to share files directly with other compatible applications.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -26,21 +26,21 @@
|
|
|
26
26
|
"homepage": "https://docs.expo.dev/versions/latest/sdk/sharing/",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@expo/plist": "^0.8.2",
|
|
29
|
-
"@expo/config-plugins": "^57.0.
|
|
29
|
+
"@expo/config-plugins": "^57.0.13",
|
|
30
30
|
"@expo/config-types": "^57.0.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^22.14.0",
|
|
34
34
|
"@types/react": "~19.2.0",
|
|
35
35
|
"expo-module-scripts": "56.0.3",
|
|
36
|
-
"expo": "57.0.
|
|
36
|
+
"expo": "57.0.33"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"expo": "*",
|
|
40
40
|
"react": "*",
|
|
41
41
|
"react-native": "*"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "968a9dcec304789b2ccc1a41ef5d301938e91478",
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "expo-module build",
|
|
46
46
|
"build:plugin": "expo-module build plugin",
|
|
@@ -15,7 +15,7 @@ class ShareIntoViewController: SLComposeServiceViewController {
|
|
|
15
15
|
return _hostAppScheme
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
private var appGroupId: String {
|
|
18
|
+
nonisolated private var appGroupId: String {
|
|
19
19
|
guard let _appGroupId = Bundle.main.object(forInfoDictionaryKey: "AppGroupId") as? String else {
|
|
20
20
|
fatalError("Expo-sharing has failed to load the app group ID from `Info.plist`. Make sure the `expo-sharing` config plugin is configured correctly.")
|
|
21
21
|
}
|
|
@@ -61,6 +61,7 @@ class ShareIntoViewController: SLComposeServiceViewController {
|
|
|
61
61
|
|
|
62
62
|
nonisolated private func processInputItems(_ items: [NSExtensionItem]) async -> [SharePayload] {
|
|
63
63
|
var results: [SharePayload] = []
|
|
64
|
+
ShareIntoFileStore(appGroupId: appGroupId)?.removeStaleFiles()
|
|
64
65
|
|
|
65
66
|
for item in items {
|
|
66
67
|
guard let attachments = item.attachments else { continue }
|
|
@@ -201,20 +202,16 @@ class ShareIntoViewController: SLComposeServiceViewController {
|
|
|
201
202
|
// MARK: - File Management
|
|
202
203
|
|
|
203
204
|
private func copyAndProcessFile(url: URL, type: ShareType) -> SharePayload? {
|
|
204
|
-
|
|
205
|
+
let fileName = safeShareFileName(url.lastPathComponent, fallback: UUID().uuidString)
|
|
206
|
+
guard let destinationURL = try? ShareIntoFileStore(appGroupId: appGroupId)?.makeDestination(fileName: fileName) else {
|
|
205
207
|
return nil
|
|
206
208
|
}
|
|
207
209
|
|
|
208
|
-
let fileName = url.lastPathComponent.isEmpty ? UUID().uuidString : url.lastPathComponent
|
|
209
|
-
let destinationURL = containerURL.appendingPathComponent(fileName)
|
|
210
|
-
|
|
211
210
|
do {
|
|
212
|
-
if FileManager.default.fileExists(atPath: destinationURL.path) {
|
|
213
|
-
try FileManager.default.removeItem(at: destinationURL)
|
|
214
|
-
}
|
|
215
211
|
try FileManager.default.copyItem(at: url, to: destinationURL)
|
|
216
212
|
} catch {
|
|
217
213
|
print("Error copying file: \(error)")
|
|
214
|
+
try? FileManager.default.removeItem(at: destinationURL.deletingLastPathComponent())
|
|
218
215
|
return nil
|
|
219
216
|
}
|
|
220
217
|
|
|
@@ -236,14 +233,14 @@ class ShareIntoViewController: SLComposeServiceViewController {
|
|
|
236
233
|
}
|
|
237
234
|
|
|
238
235
|
private func saveDataToAppGroup(data: Data, fileName: String, type: ShareType, mimeType: String?) -> SharePayload? {
|
|
239
|
-
guard let
|
|
236
|
+
guard let destinationURL = try? ShareIntoFileStore(appGroupId: appGroupId)?.makeDestination(fileName: fileName) else {
|
|
240
237
|
return nil
|
|
241
238
|
}
|
|
242
|
-
let destinationURL = containerURL.appendingPathComponent(fileName)
|
|
243
239
|
|
|
244
240
|
do {
|
|
245
241
|
try data.write(to: destinationURL)
|
|
246
242
|
} catch {
|
|
243
|
+
try? FileManager.default.removeItem(at: destinationURL.deletingLastPathComponent())
|
|
247
244
|
return nil
|
|
248
245
|
}
|
|
249
246
|
|
package/src/Sharing.ts
CHANGED
|
@@ -60,6 +60,9 @@ export async function getResolvedSharedPayloadsAsync(): Promise<ResolvedSharePay
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Clears the data shared with the app.
|
|
63
|
+
* On Android and iOS, it also deletes the copies of shared files that `expo-sharing` keeps in a cache directory.
|
|
64
|
+
*
|
|
65
|
+
* > **Note:** Copy the files you want to keep before you call this method. After it runs, the `contentUri` of a file shared into the app no longer points to a file.
|
|
63
66
|
*/
|
|
64
67
|
export function clearSharedPayloads(): void {
|
|
65
68
|
SharingNativeModule.clearSharedPayloads();
|
package/src/Sharing.types.ts
CHANGED
|
@@ -91,6 +91,10 @@ export type BaseResolvedSharePayload = SharePayload & {
|
|
|
91
91
|
/**
|
|
92
92
|
* URI which can be used to access the shared content. When resolving contents of a URL with redirects, contains the redirect target URI.
|
|
93
93
|
* Null when resolving a [`SharePayload`](#sharepayload) with a `text` [`ShareType`](#sharetype).
|
|
94
|
+
*
|
|
95
|
+
* > **Note:** On Android and iOS, the URI of a file shared into the app points to a file in a cache directory. On iOS, this is the app group's `Library/Caches` directory.
|
|
96
|
+
* > The system can delete this file when storage is low. `expo-sharing` deletes files older than 24 hours when it processes new shared files.
|
|
97
|
+
* > [`Sharing.clearSharedPayloads()`](#sharingclearsharedpayloads) deletes all shared files right away. Copy the file to keep it.
|
|
94
98
|
*/
|
|
95
99
|
contentUri: string | null;
|
|
96
100
|
|
|
@@ -164,6 +168,7 @@ export type UseIncomingShareResult = {
|
|
|
164
168
|
resolvedSharedPayloads: ResolvedSharePayload[];
|
|
165
169
|
/**
|
|
166
170
|
* Clears payloads shared with the app.
|
|
171
|
+
* On Android and iOS, it also deletes the copies of shared files that `expo-sharing` keeps in a cache directory. Copy the files you want to keep before you call it.
|
|
167
172
|
*/
|
|
168
173
|
clearSharedPayloads: () => void;
|
|
169
174
|
/**
|
package/src/useIncomingShare.ts
CHANGED
|
@@ -2,7 +2,11 @@ import { useEffect, useState, useCallback, useRef } from 'react';
|
|
|
2
2
|
import type { AppStateStatus } from 'react-native';
|
|
3
3
|
import { AppState } from 'react-native';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
clearSharedPayloads as clearNativeSharedPayloads,
|
|
7
|
+
getResolvedSharedPayloadsAsync,
|
|
8
|
+
getSharedPayloads,
|
|
9
|
+
} from './Sharing';
|
|
6
10
|
import type { ResolvedSharePayload, SharePayload, UseIncomingShareResult } from './Sharing.types';
|
|
7
11
|
|
|
8
12
|
function sharePayloadsAreEqual(a: SharePayload[], b: SharePayload[]): boolean {
|
|
@@ -74,6 +78,15 @@ export function useIncomingShare(): UseIncomingShareResult {
|
|
|
74
78
|
}
|
|
75
79
|
}, []);
|
|
76
80
|
|
|
81
|
+
const clearSharedPayloads = useCallback(() => {
|
|
82
|
+
clearNativeSharedPayloads();
|
|
83
|
+
currentSharedDataRef.current = [];
|
|
84
|
+
setSharedPayloads([]);
|
|
85
|
+
setResolvedSharedPayloads([]);
|
|
86
|
+
setIsResolving(false);
|
|
87
|
+
setError(null);
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
77
90
|
useEffect(() => {
|
|
78
91
|
refreshSharePayloads();
|
|
79
92
|
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
cc731b917cc44c438bde1b2153366184
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
75afcb84144512069886d1d906727b3dac21a896
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
fcfd95da602a91c36614c8b36e6ba7f2d3a965bd493cf8de88f95ea158583fc1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
b0f482e9006b04048c86f7c2a0213459180dc0797272bb9702f03615d4295d3d2acf3ba5ef01e0444e3059b9fd3de632c27b05e41b881d2dbd3deeaf80658028
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
82aa55fce9de9b107dea0e6888c7a479
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
41910c5d3f3b2a544127524bc3ac50e65bee4702
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
bdcb7b8243328e6f7dad117911a79328b0bfc7ff91e1b05c5efab7c07a2a453f
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
15ac60d8fa939d9b2970c1ea8d98202432ed715b693410f440537a80af4fb62f558cfd8891e3e3b8019168a08e34735c11681e32366b686ac1fafbd02189c254
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
56d9065017fc87f90421619498ff7dde
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ab8eb849c32c2285b1291f5f651691e88776626b
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
cef3d51d2742c8b622bc9da4709b095170b8fb33fe39f4a91ce6ac751c9d3ba1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
a7e7fdf7187be0cc9197a0c27e61beb2df73fd32f8571d7405689ef6584acf4f889a6671f6b9de8cd351ed4ae800e6c7554c1f373cc6b70d38465931b5d4868c
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
fd3274d67824c9bef88ed4951e39cc1e
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
726e374fc4b294a8685a194d10c5f9b98bd24790
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
38986bf3cf11d914fa4345f5bd2496a2b3f6bf5d0291aaf2052633dfd04a0c8d
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
6e164dcb6d9cb3152011104473e04f5fc187c6af39c3a4518e480cea5b38dbf432583db2a3e2d181188410680a9fc775ec9d120fe1b327bfd428ff20509c16f4
|