expo-clipboard 5.0.0 → 6.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/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 6.0.0 — 2024-04-18
14
+
15
+ ### 💡 Others
16
+
17
+ - drop unused web `name` property. ([#27437](https://github.com/expo/expo/pull/27437) by [@EvanBacon](https://github.com/EvanBacon))
18
+ - Rename `CornerStyle` and `DisplayMode` types to include `Type` suffix in name. ([#27190](https://github.com/expo/expo/pull/27190) by [@simek](https://github.com/simek))
19
+ - Removed deprecated backward compatible Gradle settings. ([#28083](https://github.com/expo/expo/pull/28083) by [@kudo](https://github.com/kudo))
20
+
21
+ ## 5.0.1 - 2023-12-19
22
+
23
+ _This version does not introduce any user-facing changes._
24
+
13
25
  ## 5.0.0 — 2023-12-12
14
26
 
15
27
  ### 🐛 Bug fixes
@@ -1,113 +1,24 @@
1
1
  apply plugin: 'com.android.library'
2
- apply plugin: 'kotlin-android'
3
- apply plugin: 'maven-publish'
4
2
 
5
3
  group = 'host.exp.exponent'
6
- version = '5.0.0'
4
+ version = '6.0.0'
7
5
 
8
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
- if (expoModulesCorePlugin.exists()) {
10
- apply from: expoModulesCorePlugin
11
- applyKotlinExpoModulesCorePlugin()
12
- // Remove this check, but keep the contents after SDK49 support is dropped
13
- if (safeExtGet("expoProvidesDefaultConfig", false)) {
14
- useExpoPublishing()
15
- useCoreDependencies()
16
- }
17
- }
18
-
19
- buildscript {
20
- // Simple helper that allows the root project to override versions declared by this library.
21
- ext.safeExtGet = { prop, fallback ->
22
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
23
- }
24
-
25
- // Ensures backward compatibility
26
- ext.getKotlinVersion = {
27
- if (ext.has("kotlinVersion")) {
28
- ext.kotlinVersion()
29
- } else {
30
- ext.safeExtGet("kotlinVersion", "1.8.10")
31
- }
32
- }
33
-
34
- repositories {
35
- mavenCentral()
36
- }
37
-
38
- dependencies {
39
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
40
- }
41
- }
42
-
43
- // Remove this if and it's contents, when support for SDK49 is dropped
44
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
45
- afterEvaluate {
46
- publishing {
47
- publications {
48
- release(MavenPublication) {
49
- from components.release
50
- }
51
- }
52
- repositories {
53
- maven {
54
- url = mavenLocal().url
55
- }
56
- }
57
- }
58
- }
59
- }
7
+ apply from: expoModulesCorePlugin
8
+ applyKotlinExpoModulesCorePlugin()
9
+ useCoreDependencies()
10
+ useDefaultAndroidSdkVersions()
11
+ useExpoPublishing()
60
12
 
61
13
  android {
62
- // Remove this if and it's contents, when support for SDK49 is dropped
63
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
64
- compileSdkVersion safeExtGet("compileSdkVersion", 34)
65
-
66
- defaultConfig {
67
- minSdkVersion safeExtGet("minSdkVersion", 23)
68
- targetSdkVersion safeExtGet("targetSdkVersion", 34)
69
- }
70
-
71
- publishing {
72
- singleVariant("release") {
73
- withSourcesJar()
74
- }
75
- }
76
-
77
- lintOptions {
78
- abortOnError false
79
- }
80
- }
81
-
82
- def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
83
- if (agpVersion.tokenize('.')[0].toInteger() < 8) {
84
- compileOptions {
85
- sourceCompatibility JavaVersion.VERSION_11
86
- targetCompatibility JavaVersion.VERSION_11
87
- }
88
-
89
- kotlinOptions {
90
- jvmTarget = JavaVersion.VERSION_11.majorVersion
91
- }
92
- }
93
-
94
14
  namespace "expo.modules.clipboard"
95
15
  defaultConfig {
96
16
  versionCode 3
97
- versionName '5.0.0'
17
+ versionName '6.0.0'
98
18
  }
99
19
  }
100
20
 
101
- repositories {
102
- mavenCentral()
103
- }
104
-
105
21
  dependencies {
106
- // Remove this if and it's contents, when support for SDK49 is dropped
107
- if (!safeExtGet("expoProvidesDefaultConfig", false)) {
108
- implementation project(':expo-modules-core')
109
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
110
- }
111
22
  implementation "androidx.core:core-ktx:1.6.0"
112
23
  implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1")
113
24
  implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2")
@@ -17,7 +17,7 @@ internal class CopyFailureException(cause: Throwable?, kind: String = "item") :
17
17
  internal class InvalidImageException(image: String, cause: Throwable?) :
18
18
  CodedException(
19
19
  "Invalid base64 image: ${
20
- image.run { substring(0, minOf(length, 32)) + if (length > 32) "..." else ""}
20
+ image.run { substring(0, minOf(length, 32)) + if (length > 32) "..." else ""}
21
21
  }",
22
22
  cause
23
23
  )
@@ -93,6 +93,7 @@ class ClipboardFileProvider : ContentProvider() {
93
93
  columns[i] = OpenableColumns.DISPLAY_NAME
94
94
  values[i++] = file.name
95
95
  }
96
+
96
97
  OpenableColumns.SIZE -> {
97
98
  columns[i] = OpenableColumns.SIZE
98
99
  values[i++] = file.length()
@@ -223,10 +224,12 @@ class ClipboardFileProvider : ContentProvider() {
223
224
  val externalFilesDirs: Array<File> = context.getExternalFilesDirs(null)
224
225
  externalFilesDirs.takeIf { it.isNotEmpty() }?.let { it[0] }
225
226
  }
227
+
226
228
  TAG_EXTERNAL_CACHE -> {
227
229
  val externalCacheDirs: Array<File> = context.externalCacheDirs
228
230
  externalCacheDirs.takeIf { it.isNotEmpty() }?.let { it[0] }
229
231
  }
232
+
230
233
  else -> null
231
234
  }
232
235
 
@@ -309,9 +312,9 @@ class ClipboardFileProvider : ContentProvider() {
309
312
  for (root in roots.entries) {
310
313
  val rootPath = root.value.path
311
314
  if (path.startsWith(rootPath) && (
312
- mostSpecific == null ||
313
- rootPath.length > mostSpecific.value.path.length
314
- )
315
+ mostSpecific == null ||
316
+ rootPath.length > mostSpecific.value.path.length
317
+ )
315
318
  ) {
316
319
  mostSpecific = root
317
320
  }
@@ -32,7 +32,7 @@ data class ImageResult(
32
32
  "size" to bundleOf(
33
33
  "width" to width,
34
34
  "height" to height
35
- ),
35
+ )
36
36
  )
37
37
  }
38
38
  // endregion
@@ -93,7 +93,7 @@ internal suspend fun imageFromContentUri(
93
93
  internal suspend fun clipDataFromBase64Image(
94
94
  context: Context,
95
95
  base64Image: String,
96
- clipboardCacheDir: File,
96
+ clipboardCacheDir: File
97
97
  ): ClipData {
98
98
  // 1. Get bitmap from base64 string
99
99
  val bitmap = bitmapFromBase64String(base64Image)
@@ -58,7 +58,7 @@ class ClipboardModule : Module() {
58
58
  return@AsyncFunction true
59
59
  }
60
60
 
61
- AsyncFunction("hasStringAsync") {
61
+ AsyncFunction<Boolean>("hasStringAsync") {
62
62
  clipboardManager
63
63
  .primaryClipDescription
64
64
  ?.hasTextContent
@@ -102,7 +102,7 @@ class ClipboardModule : Module() {
102
102
  }
103
103
  }
104
104
 
105
- AsyncFunction("hasImageAsync") {
105
+ AsyncFunction<Boolean>("hasImageAsync") {
106
106
  clipboardManager.primaryClipDescription?.hasMimeType("image/*") == true
107
107
  }
108
108
  //endregion
@@ -24,7 +24,8 @@ internal class SetStringOptions : Record {
24
24
  }
25
25
 
26
26
  internal enum class ImageFormat(val jsName: String) : Enumerable {
27
- JPG("jpeg"), PNG("png");
27
+ JPG("jpeg"),
28
+ PNG("png");
28
29
 
29
30
  val compressFormat: Bitmap.CompressFormat
30
31
  get() = when (this) {
@@ -1,5 +1,5 @@
1
- import { Subscription } from 'expo-modules-core';
2
- import { ClipboardImage, ContentType, GetImageOptions, GetStringOptions, SetStringOptions } from './Clipboard.types';
1
+ import { type Subscription } from 'expo-modules-core';
2
+ import type { ClipboardImage, ContentType, GetImageOptions, GetStringOptions, SetStringOptions } from './Clipboard.types';
3
3
  import { ClipboardPasteButton } from './ClipboardPasteButton';
4
4
  type ClipboardEvent = {
5
5
  /**
@@ -154,5 +154,6 @@ export declare function removeClipboardListener(subscription: Subscription): voi
154
154
  */
155
155
  export declare const isPasteButtonAvailable: boolean;
156
156
  export * from './Clipboard.types';
157
+ export { ClipboardPasteButtonProps } from './ClipboardPasteButton';
157
158
  export { ClipboardPasteButton };
158
159
  //# sourceMappingURL=Clipboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Clipboard.d.ts","sourceRoot":"","sources":["../src/Clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAiC,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EACL,cAAc,EACd,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAO9D,KAAK,cAAc,GAAG;IACpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAExC;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAKpF;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,OAAO,CAAC,CAKlB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAQ5C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAKjD;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAK1D;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,C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EAAE;QAChC,MAAM,IAAI,mBAAmB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;KAC7D;IACD,OAAO,aAAa,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE;QAChC,MAAM,IAAI,mBAAmB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;KAC7D;IACD,OAAO,aAAa,CAAC,aAAa,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAyC;IAC5E,gGAAgG;IAChG,MAAM,eAAe,GAAG,CAAC,KAAqB,EAAE,EAAE;QAChD,MAAM,YAAY,GAAmB;YACnC,GAAG,KAAK;YACR,IAAI,OAAO;gBACT,OAAO,CAAC,IAAI,CACV,sHAAsH,CACvH,CAAC;gBACF,OAAO,EAAE,CAAC;YACZ,CAAC;SACF,CAAC;QACF,QAAQ,CAAC,YAAY,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAO,OAAO,CAAC,WAAW,CAAiB,oBAAoB,EAAE,eAAe,CAAC,CAAC;AACpF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CAAC,YAA0B;IAChE,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GACjC,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC,CAAC,KAAK,CAAC;AAEvE,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import { EventEmitter, Subscription, UnavailabilityError, Platform } from 'expo-modules-core';\n\nimport {\n ClipboardImage,\n ContentType,\n GetImageOptions,\n GetStringOptions,\n SetStringOptions,\n} from './Clipboard.types';\nimport { ClipboardPasteButton } from './ClipboardPasteButton';\nimport ExpoClipboard from './ExpoClipboard';\n\nconst emitter = new EventEmitter(ExpoClipboard);\n\nconst onClipboardEventName = 'onClipboardChanged';\n\ntype ClipboardEvent = {\n /**\n * @deprecated Returns empty string. Use [`getStringAsync()`](#getstringasyncoptions) instead to retrieve clipboard content.\n */\n content: string;\n /**\n * An array of content types that are available on the clipboard.\n */\n contentTypes: ContentType[];\n};\n\nexport { Subscription, ClipboardEvent };\n\n/**\n * Gets the content of the user's clipboard. Please note that calling this method on web will prompt\n * the user to grant your app permission to \"see text and images copied to the clipboard.\"\n *\n * @param options Options for the clipboard content to be retrieved.\n * @returns A promise that resolves to the content of the clipboard.\n */\nexport async function getStringAsync(options: GetStringOptions = {}): Promise<string> {\n if (!ExpoClipboard.getStringAsync) {\n throw new UnavailabilityError('Clipboard', 'getStringAsync');\n }\n return await ExpoClipboard.getStringAsync(options);\n}\n\n/**\n * Sets the content of the user's clipboard.\n *\n * @param text The string to save to the clipboard.\n * @param options Options for the clipboard content to be set.\n * @returns On web, this returns a promise that fulfills to a boolean value indicating whether or not\n * the string was saved to the user's clipboard. On iOS and Android, the promise always resolves to `true`.\n */\nexport async function setStringAsync(\n text: string,\n options: SetStringOptions = {}\n): Promise<boolean> {\n if (!ExpoClipboard.setStringAsync) {\n throw new UnavailabilityError('Clipboard', 'setStringAsync');\n }\n return ExpoClipboard.setStringAsync(text, options);\n}\n\n/**\n * Sets the content of the user's clipboard.\n * @deprecated Use [`setStringAsync()`](#setstringasynctext-options) instead.\n *\n * @returns On web, this returns a boolean value indicating whether or not the string was saved to\n * the user's clipboard. On iOS and Android, nothing is returned.\n */\nexport function setString(text: string): void {\n if (Platform.OS === 'web') {\n // on web, we need to return legacy method,\n // because of different return type\n return ExpoClipboard.setString(text);\n } else {\n setStringAsync(text);\n }\n}\n\n/**\n * Returns whether the clipboard has text content. Returns true for both plain text and rich text (e.g. HTML).\n *\n * On web, this requires the user to grant your app permission to _\"see text and images copied to the clipboard\"_.\n *\n * @returns A promise that fulfills to `true` if clipboard has text content, resolves to `false` otherwise.\n */\nexport function hasStringAsync(): Promise<boolean> {\n if (!ExpoClipboard.hasStringAsync) {\n throw new UnavailabilityError('Clipboard', 'hasStringAsync');\n }\n return ExpoClipboard.hasStringAsync();\n}\n\n/**\n * Gets the URL from the user's clipboard.\n *\n * @returns A promise that fulfills to the URL in the clipboard.\n * @platform ios\n */\nexport async function getUrlAsync(): Promise<string | null> {\n if (!ExpoClipboard.getUrlAsync) {\n throw new UnavailabilityError('Clipboard', 'getUrlAsync');\n }\n return await ExpoClipboard.getUrlAsync();\n}\n\n/**\n * Sets a URL in the user's clipboard.\n *\n * This function behaves the same as [`setStringAsync()`](#setstringasynctext-options), except that\n * it sets the clipboard content type to be a URL. It lets your app or other apps know that the\n * clipboard contains a URL and behave accordingly.\n *\n * @param url The URL to save to the clipboard.\n * @platform ios\n */\nexport async function setUrlAsync(url: string): Promise<void> {\n if (!ExpoClipboard.setUrlAsync) {\n throw new UnavailabilityError('Clipboard', 'setUrlAsync');\n }\n return ExpoClipboard.setUrlAsync(url);\n}\n\n/**\n * Returns whether the clipboard has a URL content.\n *\n * @returns A promise that fulfills to `true` if clipboard has URL content, resolves to `false` otherwise.\n * @platform ios\n */\nexport async function hasUrlAsync(): Promise<boolean> {\n if (!ExpoClipboard.hasUrlAsync) {\n throw new UnavailabilityError('Clipboard', 'hasUrlAsync');\n }\n return await ExpoClipboard.hasUrlAsync();\n}\n\n/**\n * Gets the image from the user's clipboard and returns it in the specified format. Please note that calling\n * this method on web will prompt the user to grant your app permission to \"see text and images copied to the clipboard.\"\n *\n * @param options A `GetImageOptions` object to specify the desired format of the image.\n * @returns If there was an image in the clipboard, the promise resolves to\n * a [`ClipboardImage`](#clipboardimage) object containing the base64 string and metadata of the image.\n * Otherwise, it resolves to `null`.\n *\n * @example\n * ```tsx\n * const img = await Clipboard.getImageAsync({ format: 'png' });\n * // ...\n * <Image source={{ uri: img?.data }} style={{ width: 200, height: 200 }} />\n * ```\n */\nexport async function getImageAsync(options: GetImageOptions): Promise<ClipboardImage | null> {\n if (!ExpoClipboard.getImageAsync) {\n throw new UnavailabilityError('Clipboard', 'getImageAsync');\n }\n return await ExpoClipboard.getImageAsync(options);\n}\n\n/**\n * Sets an image in the user's clipboard.\n *\n * @param base64Image Image encoded as a base64 string, without MIME type.\n *\n * @example\n * ```tsx\n * const result = await ImagePicker.launchImageLibraryAsync({\n * mediaTypes: ImagePicker.MediaTypeOptions.Images,\n * base64: true,\n * });\n * await Clipboard.setImageAsync(result.base64);\n * ```\n */\nexport async function setImageAsync(base64Image: string): Promise<void> {\n if (!ExpoClipboard.setImageAsync) {\n throw new UnavailabilityError('Clipboard', 'setImageAsync');\n }\n return ExpoClipboard.setImageAsync(base64Image);\n}\n\n/**\n * Returns whether the clipboard has an image content.\n *\n * On web, this requires the user to grant your app permission to _\"see text and images copied to the clipboard\"_.\n *\n * @returns A promise that fulfills to `true` if clipboard has image content, resolves to `false` otherwise.\n */\nexport async function hasImageAsync(): Promise<boolean> {\n if (!ExpoClipboard.hasImageAsync) {\n throw new UnavailabilityError('Clipboard', 'hasImageAsync');\n }\n return ExpoClipboard.hasImageAsync();\n}\n\n/**\n * Adds a listener that will fire whenever the content of the user's clipboard changes. This method\n * is a no-op on Web.\n *\n * @param listener Callback to execute when listener is triggered. The callback is provided a\n * single argument that is an object containing information about clipboard contents.\n *\n * @example\n * ```typescript\n * Clipboard.addClipboardListener(({ contentTypes }: ClipboardEvent) => {\n * if (contentTypes.includes(Clipboard.ContentType.PLAIN_TEXT)) {\n * Clipboard.getStringAsync().then(content => {\n * alert('Copy pasta! Here\\'s the string that was copied: ' + content)\n * });\n * } else if (contentTypes.includes(Clipboard.ContentType.IMAGE)) {\n * alert('Yay! Clipboard contains an image');\n * }\n * });\n * ```\n */\nexport function addClipboardListener(listener: (event: ClipboardEvent) => void): Subscription {\n // TODO: Get rid of this wrapper once we remove deprecated `content` property (not before SDK47)\n const listenerWrapper = (event: ClipboardEvent) => {\n const wrappedEvent: ClipboardEvent = {\n ...event,\n get content(): string {\n console.warn(\n \"The 'content' property of the clipboard event is deprecated. Use 'getStringAsync()' instead to get clipboard content\"\n );\n return '';\n },\n };\n listener(wrappedEvent);\n };\n return emitter.addListener<ClipboardEvent>(onClipboardEventName, listenerWrapper);\n}\n\n/**\n * Removes the listener added by addClipboardListener. This method is a no-op on Web.\n *\n * @param subscription The subscription to remove (created by addClipboardListener).\n *\n * @example\n * ```typescript\n * const subscription = addClipboardListener(() => {\n * alert('Copy pasta!');\n * });\n * removeClipboardListener(subscription);\n * ```\n */\nexport function removeClipboardListener(subscription: Subscription) {\n emitter.removeSubscription(subscription);\n}\n\n/**\n * Property that determines if the `ClipboardPasteButton` is available.\n *\n * This requires the users device to be using at least iOS 16.\n *\n * `true` if the component is available, and `false` otherwise.\n */\nexport const isPasteButtonAvailable: boolean =\n Platform.OS === 'ios' ? ExpoClipboard.isPasteButtonAvailable : false;\n\nexport * from './Clipboard.types';\nexport { ClipboardPasteButton };\n"]}
1
+ {"version":3,"file":"Clipboard.js","sourceRoot":"","sources":["../src/Clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqB,mBAAmB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AASnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,aAAa,CAAC,CAAC;AAEhD,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAelD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,UAA4B,EAAE;IACjE,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;QAClC,MAAM,IAAI,mBAAmB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IAC/D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AG,CAAC,KAAqB,EAAE,EAAE;QAChD,MAAM,YAAY,GAAmB;YACnC,GAAG,KAAK;YACR,IAAI,OAAO;gBACT,OAAO,CAAC,IAAI,CACV,sHAAsH,CACvH,CAAC;gBACF,OAAO,EAAE,CAAC;YACZ,CAAC;SACF,CAAC;QACF,QAAQ,CAAC,YAAY,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAO,OAAO,CAAC,WAAW,CAAiB,oBAAoB,EAAE,eAAe,CAAC,CAAC;AACpF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CAAC,YAA0B;IAChE,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GACjC,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC,CAAC,KAAK,CAAC;AAEvE,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import { EventEmitter, type Subscription, UnavailabilityError, Platform } from 'expo-modules-core';\n\nimport type {\n ClipboardImage,\n ContentType,\n GetImageOptions,\n GetStringOptions,\n SetStringOptions,\n} from './Clipboard.types';\nimport { ClipboardPasteButton } from './ClipboardPasteButton';\nimport ExpoClipboard from './ExpoClipboard';\n\nconst emitter = new EventEmitter(ExpoClipboard);\n\nconst onClipboardEventName = 'onClipboardChanged';\n\ntype ClipboardEvent = {\n /**\n * @deprecated Returns empty string. Use [`getStringAsync()`](#getstringasyncoptions) instead to retrieve clipboard content.\n */\n content: string;\n /**\n * An array of content types that are available on the clipboard.\n */\n contentTypes: ContentType[];\n};\n\nexport { Subscription, ClipboardEvent };\n\n/**\n * Gets the content of the user's clipboard. Please note that calling this method on web will prompt\n * the user to grant your app permission to \"see text and images copied to the clipboard.\"\n *\n * @param options Options for the clipboard content to be retrieved.\n * @returns A promise that resolves to the content of the clipboard.\n */\nexport async function getStringAsync(options: GetStringOptions = {}): Promise<string> {\n if (!ExpoClipboard.getStringAsync) {\n throw new UnavailabilityError('Clipboard', 'getStringAsync');\n }\n return await ExpoClipboard.getStringAsync(options);\n}\n\n/**\n * Sets the content of the user's clipboard.\n *\n * @param text The string to save to the clipboard.\n * @param options Options for the clipboard content to be set.\n * @returns On web, this returns a promise that fulfills to a boolean value indicating whether or not\n * the string was saved to the user's clipboard. On iOS and Android, the promise always resolves to `true`.\n */\nexport async function setStringAsync(\n text: string,\n options: SetStringOptions = {}\n): Promise<boolean> {\n if (!ExpoClipboard.setStringAsync) {\n throw new UnavailabilityError('Clipboard', 'setStringAsync');\n }\n return ExpoClipboard.setStringAsync(text, options);\n}\n\n/**\n * Sets the content of the user's clipboard.\n * @deprecated Use [`setStringAsync()`](#setstringasynctext-options) instead.\n *\n * @returns On web, this returns a boolean value indicating whether or not the string was saved to\n * the user's clipboard. On iOS and Android, nothing is returned.\n */\nexport function setString(text: string): void {\n if (Platform.OS === 'web') {\n // on web, we need to return legacy method,\n // because of different return type\n return ExpoClipboard.setString(text);\n } else {\n setStringAsync(text);\n }\n}\n\n/**\n * Returns whether the clipboard has text content. Returns true for both plain text and rich text (e.g. HTML).\n *\n * On web, this requires the user to grant your app permission to _\"see text and images copied to the clipboard\"_.\n *\n * @returns A promise that fulfills to `true` if clipboard has text content, resolves to `false` otherwise.\n */\nexport function hasStringAsync(): Promise<boolean> {\n if (!ExpoClipboard.hasStringAsync) {\n throw new UnavailabilityError('Clipboard', 'hasStringAsync');\n }\n return ExpoClipboard.hasStringAsync();\n}\n\n/**\n * Gets the URL from the user's clipboard.\n *\n * @returns A promise that fulfills to the URL in the clipboard.\n * @platform ios\n */\nexport async function getUrlAsync(): Promise<string | null> {\n if (!ExpoClipboard.getUrlAsync) {\n throw new UnavailabilityError('Clipboard', 'getUrlAsync');\n }\n return await ExpoClipboard.getUrlAsync();\n}\n\n/**\n * Sets a URL in the user's clipboard.\n *\n * This function behaves the same as [`setStringAsync()`](#setstringasynctext-options), except that\n * it sets the clipboard content type to be a URL. It lets your app or other apps know that the\n * clipboard contains a URL and behave accordingly.\n *\n * @param url The URL to save to the clipboard.\n * @platform ios\n */\nexport async function setUrlAsync(url: string): Promise<void> {\n if (!ExpoClipboard.setUrlAsync) {\n throw new UnavailabilityError('Clipboard', 'setUrlAsync');\n }\n return ExpoClipboard.setUrlAsync(url);\n}\n\n/**\n * Returns whether the clipboard has a URL content.\n *\n * @returns A promise that fulfills to `true` if clipboard has URL content, resolves to `false` otherwise.\n * @platform ios\n */\nexport async function hasUrlAsync(): Promise<boolean> {\n if (!ExpoClipboard.hasUrlAsync) {\n throw new UnavailabilityError('Clipboard', 'hasUrlAsync');\n }\n return await ExpoClipboard.hasUrlAsync();\n}\n\n/**\n * Gets the image from the user's clipboard and returns it in the specified format. Please note that calling\n * this method on web will prompt the user to grant your app permission to \"see text and images copied to the clipboard.\"\n *\n * @param options A `GetImageOptions` object to specify the desired format of the image.\n * @returns If there was an image in the clipboard, the promise resolves to\n * a [`ClipboardImage`](#clipboardimage) object containing the base64 string and metadata of the image.\n * Otherwise, it resolves to `null`.\n *\n * @example\n * ```tsx\n * const img = await Clipboard.getImageAsync({ format: 'png' });\n * // ...\n * <Image source={{ uri: img?.data }} style={{ width: 200, height: 200 }} />\n * ```\n */\nexport async function getImageAsync(options: GetImageOptions): Promise<ClipboardImage | null> {\n if (!ExpoClipboard.getImageAsync) {\n throw new UnavailabilityError('Clipboard', 'getImageAsync');\n }\n return await ExpoClipboard.getImageAsync(options);\n}\n\n/**\n * Sets an image in the user's clipboard.\n *\n * @param base64Image Image encoded as a base64 string, without MIME type.\n *\n * @example\n * ```tsx\n * const result = await ImagePicker.launchImageLibraryAsync({\n * mediaTypes: ImagePicker.MediaTypeOptions.Images,\n * base64: true,\n * });\n * await Clipboard.setImageAsync(result.base64);\n * ```\n */\nexport async function setImageAsync(base64Image: string): Promise<void> {\n if (!ExpoClipboard.setImageAsync) {\n throw new UnavailabilityError('Clipboard', 'setImageAsync');\n }\n return ExpoClipboard.setImageAsync(base64Image);\n}\n\n/**\n * Returns whether the clipboard has an image content.\n *\n * On web, this requires the user to grant your app permission to _\"see text and images copied to the clipboard\"_.\n *\n * @returns A promise that fulfills to `true` if clipboard has image content, resolves to `false` otherwise.\n */\nexport async function hasImageAsync(): Promise<boolean> {\n if (!ExpoClipboard.hasImageAsync) {\n throw new UnavailabilityError('Clipboard', 'hasImageAsync');\n }\n return ExpoClipboard.hasImageAsync();\n}\n\n/**\n * Adds a listener that will fire whenever the content of the user's clipboard changes. This method\n * is a no-op on Web.\n *\n * @param listener Callback to execute when listener is triggered. The callback is provided a\n * single argument that is an object containing information about clipboard contents.\n *\n * @example\n * ```typescript\n * Clipboard.addClipboardListener(({ contentTypes }: ClipboardEvent) => {\n * if (contentTypes.includes(Clipboard.ContentType.PLAIN_TEXT)) {\n * Clipboard.getStringAsync().then(content => {\n * alert('Copy pasta! Here\\'s the string that was copied: ' + content)\n * });\n * } else if (contentTypes.includes(Clipboard.ContentType.IMAGE)) {\n * alert('Yay! Clipboard contains an image');\n * }\n * });\n * ```\n */\nexport function addClipboardListener(listener: (event: ClipboardEvent) => void): Subscription {\n // TODO: Get rid of this wrapper once we remove deprecated `content` property (not before SDK47)\n const listenerWrapper = (event: ClipboardEvent) => {\n const wrappedEvent: ClipboardEvent = {\n ...event,\n get content(): string {\n console.warn(\n \"The 'content' property of the clipboard event is deprecated. Use 'getStringAsync()' instead to get clipboard content\"\n );\n return '';\n },\n };\n listener(wrappedEvent);\n };\n return emitter.addListener<ClipboardEvent>(onClipboardEventName, listenerWrapper);\n}\n\n/**\n * Removes the listener added by addClipboardListener. This method is a no-op on Web.\n *\n * @param subscription The subscription to remove (created by addClipboardListener).\n *\n * @example\n * ```typescript\n * const subscription = addClipboardListener(() => {\n * alert('Copy pasta!');\n * });\n * removeClipboardListener(subscription);\n * ```\n */\nexport function removeClipboardListener(subscription: Subscription) {\n emitter.removeSubscription(subscription);\n}\n\n/**\n * Property that determines if the `ClipboardPasteButton` is available.\n *\n * This requires the users device to be using at least iOS 16.\n *\n * `true` if the component is available, and `false` otherwise.\n */\nexport const isPasteButtonAvailable: boolean =\n Platform.OS === 'ios' ? ExpoClipboard.isPasteButtonAvailable : false;\n\nexport * from './Clipboard.types';\nexport { ClipboardPasteButtonProps } from './ClipboardPasteButton';\n\nexport { ClipboardPasteButton };\n"]}
@@ -1,5 +1,4 @@
1
- import { ViewProps, StyleProp, ViewStyle } from 'react-native';
2
- export interface GetImageOptions {
1
+ export type GetImageOptions = {
3
2
  /**
4
3
  * The format of the clipboard image to be converted to.
5
4
  */
@@ -10,15 +9,13 @@ export interface GetImageOptions {
10
9
  * @default 1
11
10
  */
12
11
  jpegQuality?: number;
13
- }
14
- export interface ClipboardImage {
12
+ };
13
+ export type ClipboardImage = {
15
14
  /**
16
- * A Base64-encoded string of the image data.
17
- * Its format is dependent on the `format` option.
15
+ * A Base64-encoded string of the image data. Its format is dependent on the `format` option.
16
+ * You can use it directly as the source of an `Image` element.
18
17
  *
19
18
  * > **NOTE:** The string is already prepended with `data:image/png;base64,` or `data:image/jpeg;base64,` prefix.
20
- *
21
- * You can use it directly as the source of an `Image` element.
22
19
  * @example
23
20
  * ```ts
24
21
  * <Image
@@ -35,7 +32,7 @@ export interface ClipboardImage {
35
32
  width: number;
36
33
  height: number;
37
34
  };
38
- }
35
+ };
39
36
  /**
40
37
  * Type used to define what type of data is stored in the clipboard.
41
38
  */
@@ -55,15 +52,15 @@ export declare enum StringFormat {
55
52
  PLAIN_TEXT = "plainText",
56
53
  HTML = "html"
57
54
  }
58
- export interface GetStringOptions {
55
+ export type GetStringOptions = {
59
56
  /**
60
57
  * The target format of the clipboard string to be converted to, if possible.
61
58
  *
62
59
  * @default StringFormat.PLAIN_TEXT
63
60
  */
64
61
  preferredFormat?: StringFormat;
65
- }
66
- export interface SetStringOptions {
62
+ };
63
+ export type SetStringOptions = {
67
64
  /**
68
65
  * The input format of the provided string.
69
66
  * Adjusting this option can help other applications interpret copied string properly.
@@ -71,76 +68,16 @@ export interface SetStringOptions {
71
68
  * @default StringFormat.PLAIN_TEXT
72
69
  */
73
70
  inputFormat?: StringFormat;
74
- }
75
- export interface ClipboardPasteButtonProps extends ViewProps {
76
- /**
77
- * A callback that is called with the result of the paste action.
78
- * Inspect the `type` property to determine the type of the pasted data.
79
-
80
- * Can be one of `text` or `image`.
81
- *
82
- * @example
83
- * ```ts
84
- * onPress={(data) => {
85
- * if (data.type === 'image') {
86
- * setImageData(data);
87
- * } else {
88
- * setTextData(data);
89
- * }
90
- * }}
91
- * ```
92
- */
93
- onPress: (data: PasteEventPayload) => void;
94
- /**
95
- * The backgroundColor of the button.
96
- * Leaving this as the default allows the color to adjust to the system theme settings.
97
- */
98
- backgroundColor?: string | null;
99
- /**
100
- * The foregroundColor of the button.
101
- * @default white
102
- */
103
- foregroundColor?: string | null;
104
- /**
105
- * The cornerStyle of the button.
106
- * @default capsule
107
- *
108
- * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uibutton/configuration/cornerstyle) for more details.
109
- */
110
- cornerStyle?: CornerStyle | null;
111
- /**
112
- * The displayMode of the button.
113
- * @default `iconAndLabel`
114
- *
115
- * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uipastecontrol/displaymode) for more details.
116
- */
117
- displayMode?: DisplayMode | null;
118
- /**
119
- * The custom style to apply to the button. Should not include `backgroundColor`, `borderRadius` or `color`
120
- * properties.
121
- */
122
- style?: StyleProp<Omit<ViewStyle, 'backgroundColor' | 'borderRadius' | 'color'>>;
123
- /**
124
- * The options to use when pasting an image from the clipboard.
125
- */
126
- imageOptions?: GetImageOptions | null;
127
- /**
128
- * An array of the content types that will cause the button to become active
129
- * @note do not include `plain-text` and `html` at the same time as this will cause all text to be treated as `html`
130
- * @default ['plain-text', 'image']
131
- */
132
- acceptedContentTypes?: AcceptedContentType[];
133
- }
134
- type AcceptedContentType = 'plain-text' | 'image' | 'url' | 'html';
135
- type CornerStyle = 'dynamic' | 'fixed' | 'capsule' | 'large' | 'medium' | 'small';
136
- type DisplayMode = 'iconAndLabel' | 'iconOnly' | 'labelOnly';
71
+ };
72
+ export type AcceptedContentType = 'plain-text' | 'image' | 'url' | 'html';
73
+ export type CornerStyleType = 'dynamic' | 'fixed' | 'capsule' | 'large' | 'medium' | 'small';
74
+ export type DisplayModeType = 'iconAndLabel' | 'iconOnly' | 'labelOnly';
137
75
  export type PasteEventPayload = TextPasteEvent | ImagePasteEvent;
138
- export interface TextPasteEvent {
76
+ export type TextPasteEvent = {
139
77
  text: string;
140
78
  type: 'text';
141
- }
142
- export interface ImagePasteEvent extends ClipboardImage {
79
+ };
80
+ export type ImagePasteEvent = {
143
81
  type: 'image';
144
- }
145
- export {};
82
+ } & ClipboardImage;
146
83
  //# sourceMappingURL=Clipboard.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Clipboard.types.d.ts","sourceRoot":"","sources":["../src/Clipboard.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG/D,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;;OAcG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,oBAAY,WAAW;IACrB,UAAU,eAAe;IACzB,IAAI,SAAS;IACb,KAAK,UAAU;IACf;;OAEG;IACH,GAAG,QAAQ;CACZ;AAED;;GAEG;AACH,oBAAY,YAAY;IACtB,UAAU,cAAc;IACxB,IAAI,SAAS;CACd;AAED,MAAM,WA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C;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,OAAO,CAAC;CACf,GAAG,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Clipboard.types.js","sourceRoot":"","sources":["../src/Clipboard.types.ts"],"names":[],"mappings":"AA2CA;;GAEG;AACH,MAAM,CAAN,IAAY,WAQX;AARD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf;;OAEG;IACH,0BAAW,CAAA;AACb,CAAC,EARW,WAAW,KAAX,WAAW,QAQtB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,wCAAwB,CAAA;IACxB,6BAAa,CAAA;AACf,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB","sourcesContent":["import { ViewProps, StyleProp, ViewStyle } from 'react-native';\n\n// @needsAudit\nexport interface GetImageOptions {\n /**\n * The format of the clipboard image to be converted to.\n */\n format: 'png' | 'jpeg';\n /**\n * Specify the quality of the returned image, between `0` and `1`. Defaults to `1` (highest quality).\n * Applicable only when `format` is set to `jpeg`, ignored otherwise.\n * @default 1\n */\n jpegQuality?: number;\n}\n\n// @needsAudit\nexport interface ClipboardImage {\n /**\n * A Base64-encoded string of the image data.\n * Its format is dependent on the `format` option.\n *\n * > **NOTE:** The string is already prepended with `data:image/png;base64,` or `data:image/jpeg;base64,` prefix.\n *\n * You can use it directly as the source of an `Image` element.\n * @example\n * ```ts\n * <Image\n * source={{ uri: clipboardImage.data }}\n * style={{ width: 200, height: 200 }}\n * />\n * ```\n */\n data: string;\n /**\n * Dimensions (`width` and `height`) of the image pasted from clipboard.\n */\n size: {\n width: number;\n height: number;\n };\n}\n\n/**\n * Type used to define what type of data is stored in the clipboard.\n */\nexport enum ContentType {\n PLAIN_TEXT = 'plain-text',\n HTML = 'html',\n IMAGE = 'image',\n /**\n * @platform iOS\n */\n URL = 'url',\n}\n\n/**\n * Type used to determine string format stored in the clipboard.\n */\nexport enum StringFormat {\n PLAIN_TEXT = 'plainText',\n HTML = 'html',\n}\n\nexport interface GetStringOptions {\n /**\n * The target format of the clipboard string to be converted to, if possible.\n *\n * @default StringFormat.PLAIN_TEXT\n */\n preferredFormat?: StringFormat;\n}\n\nexport interface SetStringOptions {\n /**\n * The input format of the provided string.\n * Adjusting this option can help other applications interpret copied string properly.\n *\n * @default StringFormat.PLAIN_TEXT\n */\n inputFormat?: StringFormat;\n}\n\n// @needsAudit\nexport interface ClipboardPasteButtonProps extends ViewProps {\n /**\n * A callback that is called with the result of the paste action.\n * Inspect the `type` property to determine the type of the pasted data.\n \n * Can be one of `text` or `image`.\n *\n * @example\n * ```ts\n * onPress={(data) => {\n * if (data.type === 'image') {\n * setImageData(data);\n * } else {\n * setTextData(data);\n * }\n * }}\n * ```\n */\n onPress: (data: PasteEventPayload) => void;\n /**\n * The backgroundColor of the button.\n * Leaving this as the default allows the color to adjust to the system theme settings.\n */\n backgroundColor?: string | null;\n /**\n * The foregroundColor of the button.\n * @default white\n */\n foregroundColor?: string | null;\n /**\n * The cornerStyle of the button.\n * @default capsule\n *\n * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uibutton/configuration/cornerstyle) for more details.\n */\n cornerStyle?: CornerStyle | null;\n /**\n * The displayMode of the button.\n * @default `iconAndLabel`\n *\n * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uipastecontrol/displaymode) for more details.\n */\n displayMode?: DisplayMode | null;\n /**\n * The custom style to apply to the button. Should not include `backgroundColor`, `borderRadius` or `color`\n * properties.\n */\n style?: StyleProp<Omit<ViewStyle, 'backgroundColor' | 'borderRadius' | 'color'>>;\n /**\n * The options to use when pasting an image from the clipboard.\n */\n imageOptions?: GetImageOptions | null;\n /**\n * An array of the content types that will cause the button to become active\n * @note do not include `plain-text` and `html` at the same time as this will cause all text to be treated as `html`\n * @default ['plain-text', 'image']\n */\n acceptedContentTypes?: AcceptedContentType[];\n}\n\ntype AcceptedContentType = 'plain-text' | 'image' | 'url' | 'html';\n\ntype CornerStyle = 'dynamic' | 'fixed' | 'capsule' | 'large' | 'medium' | 'small';\n\ntype DisplayMode = 'iconAndLabel' | 'iconOnly' | 'labelOnly';\n\nexport type PasteEventPayload = TextPasteEvent | ImagePasteEvent;\n\nexport interface TextPasteEvent {\n text: string;\n type: 'text';\n}\n\nexport interface ImagePasteEvent extends ClipboardImage {\n type: 'image';\n}\n"]}
1
+ {"version":3,"file":"Clipboard.types.js","sourceRoot":"","sources":["../src/Clipboard.types.ts"],"names":[],"mappings":"AAuCA;;GAEG;AACH,MAAM,CAAN,IAAY,WAQX;AARD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf;;OAEG;IACH,0BAAW,CAAA;AACb,CAAC,EARW,WAAW,KAAX,WAAW,QAQtB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,wCAAwB,CAAA;IACxB,6BAAa,CAAA;AACf,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB","sourcesContent":["// @needsAudit\nexport type GetImageOptions = {\n /**\n * The format of the clipboard image to be converted to.\n */\n format: 'png' | 'jpeg';\n /**\n * Specify the quality of the returned image, between `0` and `1`. Defaults to `1` (highest quality).\n * Applicable only when `format` is set to `jpeg`, ignored otherwise.\n * @default 1\n */\n jpegQuality?: number;\n};\n\n// @needsAudit\nexport type ClipboardImage = {\n /**\n * A Base64-encoded string of the image data. Its format is dependent on the `format` option.\n * You can use it directly as the source of an `Image` element.\n *\n * > **NOTE:** The string is already prepended with `data:image/png;base64,` or `data:image/jpeg;base64,` prefix.\n * @example\n * ```ts\n * <Image\n * source={{ uri: clipboardImage.data }}\n * style={{ width: 200, height: 200 }}\n * />\n * ```\n */\n data: string;\n /**\n * Dimensions (`width` and `height`) of the image pasted from clipboard.\n */\n size: {\n width: number;\n height: number;\n };\n};\n\n/**\n * Type used to define what type of data is stored in the clipboard.\n */\nexport enum ContentType {\n PLAIN_TEXT = 'plain-text',\n HTML = 'html',\n IMAGE = 'image',\n /**\n * @platform iOS\n */\n URL = 'url',\n}\n\n/**\n * Type used to determine string format stored in the clipboard.\n */\nexport enum StringFormat {\n PLAIN_TEXT = 'plainText',\n HTML = 'html',\n}\n\nexport type GetStringOptions = {\n /**\n * The target format of the clipboard string to be converted to, if possible.\n *\n * @default StringFormat.PLAIN_TEXT\n */\n preferredFormat?: StringFormat;\n};\n\nexport type SetStringOptions = {\n /**\n * The input format of the provided string.\n * Adjusting this option can help other applications interpret copied string properly.\n *\n * @default StringFormat.PLAIN_TEXT\n */\n inputFormat?: StringFormat;\n};\n\nexport type AcceptedContentType = 'plain-text' | 'image' | 'url' | 'html';\n\nexport type CornerStyleType = 'dynamic' | 'fixed' | 'capsule' | 'large' | 'medium' | 'small';\n\nexport type DisplayModeType = 'iconAndLabel' | 'iconOnly' | 'labelOnly';\n\nexport type PasteEventPayload = TextPasteEvent | ImagePasteEvent;\n\nexport type TextPasteEvent = {\n text: string;\n type: 'text';\n};\n\nexport type ImagePasteEvent = {\n type: 'image';\n} & ClipboardImage;\n"]}
@@ -1,4 +1,64 @@
1
- import { ClipboardPasteButtonProps } from './Clipboard.types';
1
+ import { StyleProp, ViewProps, ViewStyle } from 'react-native';
2
+ import { AcceptedContentType, CornerStyleType, DisplayModeType, GetImageOptions, PasteEventPayload } from './Clipboard.types';
3
+ export type ClipboardPasteButtonProps = {
4
+ /**
5
+ * A callback that is called with the result of the paste action.
6
+ * Inspect the `type` property to determine the type of the pasted data.
7
+ *
8
+ * Can be one of `text` or `image`.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * onPress={(data) => {
13
+ * if (data.type === 'image') {
14
+ * setImageData(data);
15
+ * } else {
16
+ * setTextData(data);
17
+ * }
18
+ * }}
19
+ * ```
20
+ */
21
+ onPress: (data: PasteEventPayload) => void;
22
+ /**
23
+ * The backgroundColor of the button.
24
+ * Leaving this as the default allows the color to adjust to the system theme settings.
25
+ */
26
+ backgroundColor?: string | null;
27
+ /**
28
+ * The foregroundColor of the button.
29
+ * @default 'white'
30
+ */
31
+ foregroundColor?: string | null;
32
+ /**
33
+ * The cornerStyle of the button.
34
+ * @default 'capsule'
35
+ *
36
+ * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uibutton/configuration/cornerstyle) for more details.
37
+ */
38
+ cornerStyle?: CornerStyleType | null;
39
+ /**
40
+ * The displayMode of the button.
41
+ * @default 'iconAndLabel'
42
+ *
43
+ * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uipastecontrol/displaymode) for more details.
44
+ */
45
+ displayMode?: DisplayModeType | null;
46
+ /**
47
+ * The custom style to apply to the button. Should not include `backgroundColor`, `borderRadius` or `color`
48
+ * properties.
49
+ */
50
+ style?: StyleProp<Omit<ViewStyle, 'backgroundColor' | 'borderRadius' | 'color'>>;
51
+ /**
52
+ * The options to use when pasting an image from the clipboard.
53
+ */
54
+ imageOptions?: GetImageOptions | null;
55
+ /**
56
+ * An array of the content types that will cause the button to become active.
57
+ * > Do not include `plain-text` and `html` at the same time as this will cause all text to be treated as `html`.
58
+ * @default ['plain-text', 'image']
59
+ */
60
+ acceptedContentTypes?: AcceptedContentType[];
61
+ } & ViewProps;
2
62
  /**
3
63
  * This component displays the `UIPasteControl` button on your screen. This allows pasting from the clipboard without requesting permission from the user.
4
64
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ClipboardPasteButton.d.ts","sourceRoot":"","sources":["../src/ClipboardPasteButton.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAqB,MAAM,mBAAmB,CAAC;AAIjF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,EAAE,yBAAyB,sBAaxF"}
1
+ {"version":3,"file":"ClipboardPasteButton.d.ts","sourceRoot":"","sources":["../src/ClipboardPasteButton.tsx"],"names":[],"mappings":"AACA,OAAO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C,wBAAwB,EAAE;QAC7B,IAAI,OAAO,EAAE;YACX,OAAO,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;SACtD;QACD,OAAO,IAAI,CAAC;KACb;IAED,MAAM,cAAc,GAAG,CAAC,EAAE,WAAW,EAA2C,EAAE,EAAE;QAClF,OAAO,CAAC,WAAW,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,CAAC,IAAI,SAAS,CAAC,EAAG,CAAC;AACrF,CAAC","sourcesContent":["import React from 'react';\nimport { NativeSyntheticEvent } from 'react-native';\n\nimport { ClipboardPasteButtonProps, PasteEventPayload } from './Clipboard.types';\nimport ExpoClipboardPasteButton from './ExpoClipboardPasteButton';\n\n// @needsAudit\n/**\n * This component displays the `UIPasteControl` button on your screen. This allows pasting from the clipboard without requesting permission from the user.\n *\n * You should only attempt to render this if [`Clipboard.isPasteButtonAvailable`](#ispastebuttonavailable)\n * is `true`. This component will render nothing if it is not available, and you will get\n * a warning in development mode (`__DEV__ === true`).\n *\n * The properties of this component extend from `View`; however, you should not attempt to set\n * `backgroundColor`, `color` or `borderRadius` with the `style` property. Apple restricts customisation of this view.\n * Instead, you should use the backgroundColor and foregroundColor properties to set the colors of the button, the cornerStyle property to change the border radius,\n * and the displayMode property to change the appearance of the icon and label. The word \"Paste\" is not editable and neither is the icon.\n *\n * Make sure to attach height and width via the style props as without these styles, the button will\n * not appear on the screen.\n *\n * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uipastecontrol) for more details.\n */\nexport function ClipboardPasteButton({ onPress, ...restProps }: ClipboardPasteButtonProps) {\n if (!ExpoClipboardPasteButton) {\n if (__DEV__) {\n console.warn(\"'ApplePasteButton' is not available.\");\n }\n return null;\n }\n\n const onPastePressed = ({ nativeEvent }: NativeSyntheticEvent<PasteEventPayload>) => {\n onPress(nativeEvent);\n };\n\n return <ExpoClipboardPasteButton onPastePressed={onPastePressed} {...restProps} />;\n}\n"]}
1
+ {"version":3,"file":"ClipboardPasteButton.js","sourceRoot":"","sources":["../src/ClipboardPasteButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AA+DlE,cAAc;AACd;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,EAA6B;IACvF,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC9B,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,cAAc,GAAG,CAAC,EAAE,WAAW,EAA2C,EAAE,EAAE;QAClF,OAAO,CAAC,WAAW,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,CAAC,IAAI,SAAS,CAAC,EAAG,CAAC;AACrF,CAAC","sourcesContent":["import React from 'react';\nimport { NativeSyntheticEvent, StyleProp, ViewProps, ViewStyle } from 'react-native';\n\nimport {\n AcceptedContentType,\n CornerStyleType,\n DisplayModeType,\n GetImageOptions,\n PasteEventPayload,\n} from './Clipboard.types';\nimport ExpoClipboardPasteButton from './ExpoClipboardPasteButton';\n\n// @needsAudit\nexport type ClipboardPasteButtonProps = {\n /**\n * A callback that is called with the result of the paste action.\n * Inspect the `type` property to determine the type of the pasted data.\n *\n * Can be one of `text` or `image`.\n *\n * @example\n * ```ts\n * onPress={(data) => {\n * if (data.type === 'image') {\n * setImageData(data);\n * } else {\n * setTextData(data);\n * }\n * }}\n * ```\n */\n onPress: (data: PasteEventPayload) => void;\n /**\n * The backgroundColor of the button.\n * Leaving this as the default allows the color to adjust to the system theme settings.\n */\n backgroundColor?: string | null;\n /**\n * The foregroundColor of the button.\n * @default 'white'\n */\n foregroundColor?: string | null;\n /**\n * The cornerStyle of the button.\n * @default 'capsule'\n *\n * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uibutton/configuration/cornerstyle) for more details.\n */\n cornerStyle?: CornerStyleType | null;\n /**\n * The displayMode of the button.\n * @default 'iconAndLabel'\n *\n * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uipastecontrol/displaymode) for more details.\n */\n displayMode?: DisplayModeType | null;\n /**\n * The custom style to apply to the button. Should not include `backgroundColor`, `borderRadius` or `color`\n * properties.\n */\n style?: StyleProp<Omit<ViewStyle, 'backgroundColor' | 'borderRadius' | 'color'>>;\n /**\n * The options to use when pasting an image from the clipboard.\n */\n imageOptions?: GetImageOptions | null;\n /**\n * An array of the content types that will cause the button to become active.\n * > Do not include `plain-text` and `html` at the same time as this will cause all text to be treated as `html`.\n * @default ['plain-text', 'image']\n */\n acceptedContentTypes?: AcceptedContentType[];\n} & ViewProps;\n\n// @needsAudit\n/**\n * This component displays the `UIPasteControl` button on your screen. This allows pasting from the clipboard without requesting permission from the user.\n *\n * You should only attempt to render this if [`Clipboard.isPasteButtonAvailable`](#ispastebuttonavailable)\n * is `true`. This component will render nothing if it is not available, and you will get\n * a warning in development mode (`__DEV__ === true`).\n *\n * The properties of this component extend from `View`; however, you should not attempt to set\n * `backgroundColor`, `color` or `borderRadius` with the `style` property. Apple restricts customisation of this view.\n * Instead, you should use the backgroundColor and foregroundColor properties to set the colors of the button, the cornerStyle property to change the border radius,\n * and the displayMode property to change the appearance of the icon and label. The word \"Paste\" is not editable and neither is the icon.\n *\n * Make sure to attach height and width via the style props as without these styles, the button will\n * not appear on the screen.\n *\n * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uipastecontrol) for more details.\n */\nexport function ClipboardPasteButton({ onPress, ...restProps }: ClipboardPasteButtonProps) {\n if (!ExpoClipboardPasteButton) {\n if (__DEV__) {\n console.warn(\"'ApplePasteButton' is not available.\");\n }\n return null;\n }\n\n const onPastePressed = ({ nativeEvent }: NativeSyntheticEvent<PasteEventPayload>) => {\n onPress(nativeEvent);\n };\n\n return <ExpoClipboardPasteButton onPastePressed={onPastePressed} {...restProps} />;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoClipboardPasteButton.js","sourceRoot":"","sources":["../src/ExpoClipboardPasteButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,IAAI,aAAkB,CAAC;AAEvB,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;IACzB,aAAa,GAAG,wBAAwB,CAAC,eAAe,CAAC,CAAC;CAC3D;AAED,eAAe,aAAa,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nlet ExpoClipboard: any;\n\nif (Platform.OS === 'ios') {\n ExpoClipboard = requireNativeViewManager('ExpoClipboard');\n}\n\nexport default ExpoClipboard;\n"]}
1
+ {"version":3,"file":"ExpoClipboardPasteButton.js","sourceRoot":"","sources":["../src/ExpoClipboardPasteButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,IAAI,aAAkB,CAAC;AAEvB,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;IAC1B,aAAa,GAAG,wBAAwB,CAAC,eAAe,CAAC,CAAC;AAC5D,CAAC;AAED,eAAe,aAAa,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nlet ExpoClipboard: any;\n\nif (Platform.OS === 'ios') {\n ExpoClipboard = requireNativeViewManager('ExpoClipboard');\n}\n\nexport default ExpoClipboard;\n"]}
@@ -1,6 +1,5 @@
1
1
  import { ClipboardImage, GetImageOptions, GetStringOptions, SetStringOptions } from '../Clipboard.types';
2
2
  declare const _default: {
3
- readonly name: string;
4
3
  getStringAsync(options: GetStringOptions): Promise<string>;
5
4
  setString(text: string): boolean;
6
5
  setStringAsync(text: string, options: SetStringOptions): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"ClipboardModule.d.ts","sourceRoot":"","sources":["../../src/web/ClipboardModule.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;;;4BAMI,gBAAgB,GAAG,QAAQ,MAAM,CAAC;oBA6ChD,MAAM,GAAG,OAAO;yBAcL,MAAM,WAAW,gBAAgB,GAAG,QAAQ,OAAO,CAAC;sBAkCvD,QAAQ,OAAO,CAAC;4BAGV,eAAe,GAAG,QAAQ,cAAc,GAAG,IAAI,CAAC;+BA0B7C,MAAM,GAAG,QAAQ,IAAI,CAAC;qBAkBhC,QAAQ,OAAO,CAAC;4BAGf,IAAI;+BACD,IAAI;;AApJjC,wBAqJE"}
1
+ {"version":3,"file":"ClipboardModule.d.ts","sourceRoot":"","sources":["../../src/web/ClipboardModule.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAEjB,MAAM,oBAAoB,CAAC;;4BAGI,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;oBA6ChD,MAAM,GAAG,OAAO;yBAcL,MAAM,WAAW,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;sBAkCvD,OAAO,CAAC,OAAO,CAAC;4BAGV,eAAe,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;+BA0B7C,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;qBAkBhC,OAAO,CAAC,OAAO,CAAC;4BAGf,IAAI;+BACD,IAAI;;AAjJjC,wBAkJE"}
@@ -2,9 +2,6 @@ import { ClipboardUnavailableException, CopyFailureException, NoPermissionExcept
2
2
  import { base64toBlob, blobToBase64Async, findHtmlInClipboardAsync, findImageInClipboardAsync, getImageSizeFromBlobAsync, htmlToPlainText, isClipboardPermissionDeniedAsync, } from './Utils';
3
3
  import { StringFormat, } from '../Clipboard.types';
4
4
  export default {
5
- get name() {
6
- return 'ExpoClipboard';
7
- },
8
5
  async getStringAsync(options) {
9
6
  if (!navigator.clipboard) {
10
7
  throw new ClipboardUnavailableException();
@@ -1 +1 @@
1
- {"version":3,"file":"ClipboardModule.js","sourceRoot":"","sources":["../../src/web/ClipboardModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,eAAe,EACf,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,OAAO,EAKL,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,eAAe;IACb,IAAI,IAAI;QACN,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,OAAyB;QAC5C,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;YACxB,MAAM,IAAI,6BAA6B,EAAE,CAAC;SAC3C;QAED,IAAI;YACF,QAAQ,OAAO,CAAC,eAAe,EAAE;gBAC/B,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;oBACtB,yBAAyB;oBACzB,MAAM,cAAc,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;oBACxD,MAAM,IAAI,GAAG,MAAM,wBAAwB,CAAC,cAAc,CAAC,CAAC;oBAC5D,IAAI,CAAC,IAAI,EAAE;wBACT,0BAA0B;wBAC1B,OAAO,MAAM,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;qBAC7C;oBACD,OAAO,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,CAA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\n ClipboardUnavailableException,\n CopyFailureException,\n NoPermissionException,\n PasteFailureException,\n} from './Exceptions';\nimport {\n base64toBlob,\n blobToBase64Async,\n findHtmlInClipboardAsync,\n findImageInClipboardAsync,\n getImageSizeFromBlobAsync,\n htmlToPlainText,\n isClipboardPermissionDeniedAsync,\n} from './Utils';\nimport {\n ClipboardImage,\n GetImageOptions,\n GetStringOptions,\n SetStringOptions,\n StringFormat,\n} from '../Clipboard.types';\n\nexport default {\n get name(): string {\n return 'ExpoClipboard';\n },\n async getStringAsync(options: GetStringOptions): Promise<string> {\n if (!navigator.clipboard) {\n throw new ClipboardUnavailableException();\n }\n\n try {\n switch (options.preferredFormat) {\n case StringFormat.HTML: {\n // Try reading HTML first\n const clipboardItems = await navigator.clipboard.read();\n const blob = await findHtmlInClipboardAsync(clipboardItems);\n if (!blob) {\n // Fall back to plain text\n return await navigator.clipboard.readText();\n }\n return await new Response(blob).text();\n }\n default: {\n let text = await navigator.clipboard.readText();\n if (!text || text === '') {\n // If there's no direct plain text, try reading HTML\n const clipboardItems = await navigator.clipboard.read();\n const blob = await findHtmlInClipboardAsync(clipboardItems);\n const blobText = await blob?.text();\n text = htmlToPlainText(blobText ?? '');\n }\n return text;\n }\n }\n } catch (e) {\n // it might fail, because user denied permission\n if (e.name === 'NotAllowedError' || (await isClipboardPermissionDeniedAsync())) {\n throw new NoPermissionException();\n }\n\n try {\n // Internet Explorer\n // @ts-ignore\n return window.clipboardData.getData('Text');\n } catch {\n return Promise.reject(new Error('Unable to retrieve item from clipboard'));\n }\n }\n },\n // TODO: (barthap) The `setString` was deprecated in SDK 45. Remove this function in a few SDK cycles.\n setString(text: string): boolean {\n const textField = document.createElement('textarea');\n textField.textContent = text;\n document.body.appendChild(textField);\n textField.select();\n try {\n document.execCommand('copy');\n return true;\n } catch {\n return false;\n } finally {\n document.body.removeChild(textField);\n }\n },\n async setStringAsync(text: string, options: SetStringOptions): Promise<boolean> {\n switch (options.inputFormat) {\n case StringFormat.HTML: {\n if (!navigator.clipboard) {\n throw new ClipboardUnavailableException();\n }\n\n try {\n const clipboardItemInput = createHtmlClipboardItem(text);\n await navigator.clipboard.write([clipboardItemInput]);\n return true;\n } catch (e) {\n // it might fail, because user denied permission\n if (e.name === 'NotAllowedError' || (await isClipboardPermissionDeniedAsync())) {\n throw new NoPermissionException();\n }\n throw new CopyFailureException(e.message);\n }\n }\n default: {\n try {\n if (!navigator.clipboard) {\n throw new Error();\n }\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n // we can fall back to legacy behavior in any kind of failure\n // including navigator.clipboard unavailability\n return this.setString(text);\n }\n }\n }\n },\n async hasStringAsync(): Promise<boolean> {\n return await clipboardHasTypesAsync(['text/plain', 'text/html']);\n },\n async getImageAsync(_options: GetImageOptions): Promise<ClipboardImage | null> {\n if (!navigator.clipboard) {\n throw new ClipboardUnavailableException();\n }\n\n try {\n const clipboardItems = await navigator.clipboard.read();\n const blob = await findImageInClipboardAsync(clipboardItems);\n if (!blob) {\n return null;\n }\n\n const [data, size] = await Promise.all([\n blobToBase64Async(blob),\n getImageSizeFromBlobAsync(blob),\n ]);\n\n return { data, size };\n } catch (e) {\n // it might fail, because user denied permission\n if (e.name === 'NotAllowedError' || (await isClipboardPermissionDeniedAsync())) {\n throw new NoPermissionException();\n }\n throw new PasteFailureException(e.message);\n }\n },\n async setImageAsync(base64image: string): Promise<void> {\n if (!navigator.clipboard) {\n throw new ClipboardUnavailableException();\n }\n\n try {\n // we set it always to `image/png` because it's the only format supported by the clipboard\n // but it seems to work even when provided jpeg data\n const blob = base64toBlob(base64image, 'image/png');\n await navigator.clipboard.write([\n new ClipboardItem({\n [blob.type]: blob,\n }),\n ]);\n } catch (err: any) {\n throw new CopyFailureException(err.message);\n }\n },\n async hasImageAsync(): Promise<boolean> {\n return await clipboardHasTypesAsync(['image/png', 'image/jpeg']);\n },\n addClipboardListener(): void {},\n removeClipboardListener(): void {},\n};\n\n/**\n * Resolves to true if clipboard has one of provided {@link types}.\n * @throws `ClipboardUnavailableException` if AsyncClipboard API is not available\n * @throws `NoPermissionException` if user denied permission\n */\nasync function clipboardHasTypesAsync(types: string[]): Promise<boolean> {\n if (!navigator.clipboard) {\n throw new ClipboardUnavailableException();\n }\n\n try {\n const clipboardItems = await navigator.clipboard.read();\n return clipboardItems.flatMap((item) => item.types).some((type) => types.includes(type));\n } catch (e) {\n // it might fail, because user denied permission\n if (e.name === 'NotAllowedError' || (await isClipboardPermissionDeniedAsync())) {\n throw new NoPermissionException();\n }\n throw e;\n }\n}\n\nfunction createHtmlClipboardItem(htmlString: string): ClipboardItem {\n return new ClipboardItem({\n // @ts-ignore `Blob` from `lib.dom.d.ts` and the one from `@types/react-native` differ\n 'text/html': new Blob([htmlString], { type: 'text/html' }),\n // @ts-ignore `Blob` from `lib.dom.d.ts` and the one from `@types/react-native` differ\n 'text/plain': new Blob([htmlToPlainText(htmlString)], { type: 'text/plain' }),\n });\n}\n"]}
1
+ {"version":3,"file":"ClipboardModule.js","sourceRoot":"","sources":["../../src/web/ClipboardModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,eAAe,EACf,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,OAAO,EAKL,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,eAAe;IACb,KAAK,CAAC,cAAc,CAAC,OAAyB;QAC5C,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,6BAA6B,EAAE,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC;YACH,QAAQ,OAAO,CAAC,eAAe,EAAE,CAAC;gBAChC,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;oBACvB,yBAAyB;oBACzB,MAAM,cAAc,GAAG,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,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3F,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,gDAAgD;QAChD,IAAI,CAAC,CAAC,IAAI,KAAK,iBAAiB,IAAI,CAAC,MAAM,gCAAgC,EAAE,CAAC,EAAE,CAAC;YAC/E,MAAM,IAAI,qBAAqB,EAAE,CAAC;QACpC,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,UAAkB;IACjD,OAAO,IAAI,aAAa,CAAC;QACvB,sFAAsF;QACtF,WAAW,EAAE,IAAI,IAAI,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;QAC1D,sFAAsF;QACtF,YAAY,EAAE,IAAI,IAAI,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;KAC9E,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n ClipboardUnavailableException,\n CopyFailureException,\n NoPermissionException,\n PasteFailureException,\n} from './Exceptions';\nimport {\n base64toBlob,\n blobToBase64Async,\n findHtmlInClipboardAsync,\n findImageInClipboardAsync,\n getImageSizeFromBlobAsync,\n htmlToPlainText,\n isClipboardPermissionDeniedAsync,\n} from './Utils';\nimport {\n ClipboardImage,\n GetImageOptions,\n GetStringOptions,\n SetStringOptions,\n StringFormat,\n} from '../Clipboard.types';\n\nexport default {\n async getStringAsync(options: GetStringOptions): Promise<string> {\n if (!navigator.clipboard) {\n throw new ClipboardUnavailableException();\n }\n\n try {\n switch (options.preferredFormat) {\n case StringFormat.HTML: {\n // Try reading HTML first\n const clipboardItems = await navigator.clipboard.read();\n const blob = await findHtmlInClipboardAsync(clipboardItems);\n if (!blob) {\n // Fall back to plain text\n return await navigator.clipboard.readText();\n }\n return await new Response(blob).text();\n }\n default: {\n let text = await navigator.clipboard.readText();\n if (!text || text === '') {\n // If there's no direct plain text, try reading HTML\n const clipboardItems = await navigator.clipboard.read();\n const blob = await findHtmlInClipboardAsync(clipboardItems);\n const blobText = await blob?.text();\n text = htmlToPlainText(blobText ?? '');\n }\n return text;\n }\n }\n } catch (e) {\n // it might fail, because user denied permission\n if (e.name === 'NotAllowedError' || (await isClipboardPermissionDeniedAsync())) {\n throw new NoPermissionException();\n }\n\n try {\n // Internet Explorer\n // @ts-ignore\n return window.clipboardData.getData('Text');\n } catch {\n return Promise.reject(new Error('Unable to retrieve item from clipboard'));\n }\n }\n },\n // TODO: (barthap) The `setString` was deprecated in SDK 45. Remove this function in a few SDK cycles.\n setString(text: string): boolean {\n const textField = document.createElement('textarea');\n textField.textContent = text;\n document.body.appendChild(textField);\n textField.select();\n try {\n document.execCommand('copy');\n return true;\n } catch {\n return false;\n } finally {\n document.body.removeChild(textField);\n }\n },\n async setStringAsync(text: string, options: SetStringOptions): Promise<boolean> {\n switch (options.inputFormat) {\n case StringFormat.HTML: {\n if (!navigator.clipboard) {\n throw new ClipboardUnavailableException();\n }\n\n try {\n const clipboardItemInput = createHtmlClipboardItem(text);\n await navigator.clipboard.write([clipboardItemInput]);\n return true;\n } catch (e) {\n // it might fail, because user denied permission\n if (e.name === 'NotAllowedError' || (await isClipboardPermissionDeniedAsync())) {\n throw new NoPermissionException();\n }\n throw new CopyFailureException(e.message);\n }\n }\n default: {\n try {\n if (!navigator.clipboard) {\n throw new Error();\n }\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n // we can fall back to legacy behavior in any kind of failure\n // including navigator.clipboard unavailability\n return this.setString(text);\n }\n }\n }\n },\n async hasStringAsync(): Promise<boolean> {\n return await clipboardHasTypesAsync(['text/plain', 'text/html']);\n },\n async getImageAsync(_options: GetImageOptions): Promise<ClipboardImage | null> {\n if (!navigator.clipboard) {\n throw new ClipboardUnavailableException();\n }\n\n try {\n const clipboardItems = await navigator.clipboard.read();\n const blob = await findImageInClipboardAsync(clipboardItems);\n if (!blob) {\n return null;\n }\n\n const [data, size] = await Promise.all([\n blobToBase64Async(blob),\n getImageSizeFromBlobAsync(blob),\n ]);\n\n return { data, size };\n } catch (e) {\n // it might fail, because user denied permission\n if (e.name === 'NotAllowedError' || (await isClipboardPermissionDeniedAsync())) {\n throw new NoPermissionException();\n }\n throw new PasteFailureException(e.message);\n }\n },\n async setImageAsync(base64image: string): Promise<void> {\n if (!navigator.clipboard) {\n throw new ClipboardUnavailableException();\n }\n\n try {\n // we set it always to `image/png` because it's the only format supported by the clipboard\n // but it seems to work even when provided jpeg data\n const blob = base64toBlob(base64image, 'image/png');\n await navigator.clipboard.write([\n new ClipboardItem({\n [blob.type]: blob,\n }),\n ]);\n } catch (err: any) {\n throw new CopyFailureException(err.message);\n }\n },\n async hasImageAsync(): Promise<boolean> {\n return await clipboardHasTypesAsync(['image/png', 'image/jpeg']);\n },\n addClipboardListener(): void {},\n removeClipboardListener(): void {},\n};\n\n/**\n * Resolves to true if clipboard has one of provided {@link types}.\n * @throws `ClipboardUnavailableException` if AsyncClipboard API is not available\n * @throws `NoPermissionException` if user denied permission\n */\nasync function clipboardHasTypesAsync(types: string[]): Promise<boolean> {\n if (!navigator.clipboard) {\n throw new ClipboardUnavailableException();\n }\n\n try {\n const clipboardItems = await navigator.clipboard.read();\n return clipboardItems.flatMap((item) => item.types).some((type) => types.includes(type));\n } catch (e) {\n // it might fail, because user denied permission\n if (e.name === 'NotAllowedError' || (await isClipboardPermissionDeniedAsync())) {\n throw new NoPermissionException();\n }\n throw e;\n }\n}\n\nfunction createHtmlClipboardItem(htmlString: string): ClipboardItem {\n return new ClipboardItem({\n // @ts-ignore `Blob` from `lib.dom.d.ts` and the one from `@types/react-native` differ\n 'text/html': new Blob([htmlString], { type: 'text/html' }),\n // @ts-ignore `Blob` from `lib.dom.d.ts` and the one from `@types/react-native` differ\n 'text/plain': new Blob([htmlToPlainText(htmlString)], { type: 'text/plain' }),\n });\n}\n"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,KAAK,WAAW,CAAC,EAAE;YAC5D,OAAO,MAAM,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACjD;QAED,0CAA0C;QAC1C,oFAAoF;QACpF,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,YAAY,CAAC,EAAE;YAC7D,OAAO,MAAM,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;SAClD;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,KAAqB;IAClE,KAAK,MAAM,aAAa,IAAI,KAAK,EAAE;QACjC,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,WAAW,CAAC,EAAE;YAC5D,OAAO,MAAM,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACjD;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,MAAM,SAAS,GAAG,EAAE,IAAI,EAAE,gBAAkC,EAAE,CAAC;IAC/D,MAAM,gBAAgB,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACtE,OAAO,gBAAgB,CAAC,KAAK,KAAK,QAAQ,CAAC;AAC7C,CAAC","sourcesContent":["/**\n * Converts base64-encoded data to a `Blob` object.\n * @see https://stackoverflow.com/a/20151856\n */\nexport function base64toBlob(base64Data: string, contentType: string): Blob {\n contentType = contentType || '';\n const sliceSize = 1024;\n const byteCharacters = atob(base64Data);\n const bytesLength = byteCharacters.length;\n const slicesCount = Math.ceil(bytesLength / sliceSize);\n const byteArrays = new Array(slicesCount);\n\n for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {\n const begin = sliceIndex * sliceSize;\n const end = Math.min(begin + sliceSize, bytesLength);\n\n const bytes = new Array(end - begin);\n for (let offset = begin, i = 0; offset < end; ++i, ++offset) {\n bytes[i] = byteCharacters[offset].charCodeAt(0);\n }\n byteArrays[sliceIndex] = new Uint8Array(bytes);\n }\n // I cannot use `@ts-expect-error` here because some environments consider this correct:\n // expo-module build - OK,\n // expo-module test - error\n // @ts-ignore `Blob` from `lib.dom.d.ts` and the one from `@types/react-native` differ somehow\n return new Blob(byteArrays, { type: contentType });\n}\n\n/**\n * Converts blob to base64-encoded string with Data-URL prefix.\n */\nexport function blobToBase64Async(blob: Blob): Promise<string> {\n return new Promise((resolve, _) => {\n const reader = new FileReader();\n reader.onloadend = () => resolve(reader.result as string);\n reader.readAsDataURL(blob);\n });\n}\n\nexport function htmlToPlainText(html: string) {\n const tempDivElement = document.createElement('div');\n tempDivElement.innerHTML = html;\n return tempDivElement.textContent || tempDivElement.innerText || '';\n}\n\nexport function getImageSizeFromBlobAsync(blob: Blob): Promise<{ width: number; height: number }> {\n return new Promise((resolve, _) => {\n const blobUrl = URL.createObjectURL(blob);\n const img = document.createElement('img');\n img.src = blobUrl;\n img.onload = function () {\n resolve({ width: img.width, height: img.height });\n };\n });\n}\n\nexport async function findImageInClipboardAsync(items: ClipboardItems): Promise<Blob | null> {\n for (const clipboardItem of items) {\n // first look for png\n if (clipboardItem.types.some((type) => type === 'image/png')) {\n return await clipboardItem.getType('image/png');\n }\n\n // alternatively, an image might be a jpeg\n // NOTE: Currently, this is not supported by browsers yet. They only support PNG now\n if (clipboardItem.types.some((type) => type === 'image/jpeg')) {\n return await clipboardItem.getType('image/jpeg');\n }\n }\n return null;\n}\n\nexport async function findHtmlInClipboardAsync(items: ClipboardItems): Promise<Blob | null> {\n for (const clipboardItem of items) {\n if (clipboardItem.types.some((type) => type === 'text/html')) {\n return await clipboardItem.getType('text/html');\n }\n }\n return null;\n}\n\nexport async function isClipboardPermissionDeniedAsync(): Promise<boolean> {\n const queryOpts = { name: 'clipboard-read' as PermissionName };\n const permissionStatus = await navigator.permissions.query(queryOpts);\n return permissionStatus.state === 'denied';\n}\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../src/web/Utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB,EAAE,WAAmB;IAClE,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,CAAC;IACvB,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC;IAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;IAE1C,KAAK,IAAI,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC;QAChE,MAAM,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,SAAS,EAAE,WAAW,CAAC,CAAC;QAErD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;QACrC,KAAK,IAAI,MAAM,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC;YAC5D,KAAK,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC;QACD,UAAU,CAAC,UAAU,CAAC,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IACD,wFAAwF;IACxF,0BAA0B;IAC1B,2BAA2B;IAC3B,8FAA8F;IAC9F,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,IA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CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,WAAW,CAAC,EAAE,CAAC;YAC7D,OAAO,MAAM,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;QAED,0CAA0C;QAC1C,oFAAoF;QACpF,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,YAAY,CAAC,EAAE,CAAC;YAC9D,OAAO,MAAM,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,KAAqB;IAClE,KAAK,MAAM,aAAa,IAAI,KAAK,EAAE,CAAC;QAClC,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,WAAW,CAAC,EAAE,CAAC;YAC7D,OAAO,MAAM,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,MAAM,SAAS,GAAG,EAAE,IAAI,EAAE,gBAAkC,EAAE,CAAC;IAC/D,MAAM,gBAAgB,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACtE,OAAO,gBAAgB,CAAC,KAAK,KAAK,QAAQ,CAAC;AAC7C,CAAC","sourcesContent":["/**\n * Converts base64-encoded data to a `Blob` object.\n * @see https://stackoverflow.com/a/20151856\n */\nexport function base64toBlob(base64Data: string, contentType: string): Blob {\n contentType = contentType || '';\n const sliceSize = 1024;\n const byteCharacters = atob(base64Data);\n const bytesLength = byteCharacters.length;\n const slicesCount = Math.ceil(bytesLength / sliceSize);\n const byteArrays = new Array(slicesCount);\n\n for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {\n const begin = sliceIndex * sliceSize;\n const end = Math.min(begin + sliceSize, bytesLength);\n\n const bytes = new Array(end - begin);\n for (let offset = begin, i = 0; offset < end; ++i, ++offset) {\n bytes[i] = byteCharacters[offset].charCodeAt(0);\n }\n byteArrays[sliceIndex] = new Uint8Array(bytes);\n }\n // I cannot use `@ts-expect-error` here because some environments consider this correct:\n // expo-module build - OK,\n // expo-module test - error\n // @ts-ignore `Blob` from `lib.dom.d.ts` and the one from `@types/react-native` differ somehow\n return new Blob(byteArrays, { type: contentType });\n}\n\n/**\n * Converts blob to base64-encoded string with Data-URL prefix.\n */\nexport function blobToBase64Async(blob: Blob): Promise<string> {\n return new Promise((resolve, _) => {\n const reader = new FileReader();\n reader.onloadend = () => resolve(reader.result as string);\n reader.readAsDataURL(blob);\n });\n}\n\nexport function htmlToPlainText(html: string) {\n const tempDivElement = document.createElement('div');\n tempDivElement.innerHTML = html;\n return tempDivElement.textContent || tempDivElement.innerText || '';\n}\n\nexport function getImageSizeFromBlobAsync(blob: Blob): Promise<{ width: number; height: number }> {\n return new Promise((resolve, _) => {\n const blobUrl = URL.createObjectURL(blob);\n const img = document.createElement('img');\n img.src = blobUrl;\n img.onload = function () {\n resolve({ width: img.width, height: img.height });\n };\n });\n}\n\nexport async function findImageInClipboardAsync(items: ClipboardItems): Promise<Blob | null> {\n for (const clipboardItem of items) {\n // first look for png\n if (clipboardItem.types.some((type) => type === 'image/png')) {\n return await clipboardItem.getType('image/png');\n }\n\n // alternatively, an image might be a jpeg\n // NOTE: Currently, this is not supported by browsers yet. They only support PNG now\n if (clipboardItem.types.some((type) => type === 'image/jpeg')) {\n return await clipboardItem.getType('image/jpeg');\n }\n }\n return null;\n}\n\nexport async function findHtmlInClipboardAsync(items: ClipboardItems): Promise<Blob | null> {\n for (const clipboardItem of items) {\n if (clipboardItem.types.some((type) => type === 'text/html')) {\n return await clipboardItem.getType('text/html');\n }\n }\n return null;\n}\n\nexport async function isClipboardPermissionDeniedAsync(): Promise<boolean> {\n const queryOpts = { name: 'clipboard-read' as PermissionName };\n const permissionStatus = await navigator.permissions.query(queryOpts);\n return permissionStatus.state === 'denied';\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-clipboard",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "ExpoClipboard standalone module",
5
5
  "main": "build/Clipboard.js",
6
6
  "types": "build/Clipboard.d.ts",
@@ -39,5 +39,5 @@
39
39
  "jest": {
40
40
  "preset": "expo-module-scripts/universal"
41
41
  },
42
- "gitHead": "6aca7ce098ddc667776a3d7cf612adbb985e264a"
42
+ "gitHead": "4165b8d72e1b9a1889c2767534cc619e21468110"
43
43
  }
package/src/Clipboard.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { EventEmitter, Subscription, UnavailabilityError, Platform } from 'expo-modules-core';
1
+ import { EventEmitter, type Subscription, UnavailabilityError, Platform } from 'expo-modules-core';
2
2
 
3
- import {
3
+ import type {
4
4
  ClipboardImage,
5
5
  ContentType,
6
6
  GetImageOptions,
@@ -256,4 +256,6 @@ export const isPasteButtonAvailable: boolean =
256
256
  Platform.OS === 'ios' ? ExpoClipboard.isPasteButtonAvailable : false;
257
257
 
258
258
  export * from './Clipboard.types';
259
+ export { ClipboardPasteButtonProps } from './ClipboardPasteButton';
260
+
259
261
  export { ClipboardPasteButton };
@@ -1,7 +1,5 @@
1
- import { ViewProps, StyleProp, ViewStyle } from 'react-native';
2
-
3
1
  // @needsAudit
4
- export interface GetImageOptions {
2
+ export type GetImageOptions = {
5
3
  /**
6
4
  * The format of the clipboard image to be converted to.
7
5
  */
@@ -12,17 +10,15 @@ export interface GetImageOptions {
12
10
  * @default 1
13
11
  */
14
12
  jpegQuality?: number;
15
- }
13
+ };
16
14
 
17
15
  // @needsAudit
18
- export interface ClipboardImage {
16
+ export type ClipboardImage = {
19
17
  /**
20
- * A Base64-encoded string of the image data.
21
- * Its format is dependent on the `format` option.
18
+ * A Base64-encoded string of the image data. Its format is dependent on the `format` option.
19
+ * You can use it directly as the source of an `Image` element.
22
20
  *
23
21
  * > **NOTE:** The string is already prepended with `data:image/png;base64,` or `data:image/jpeg;base64,` prefix.
24
- *
25
- * You can use it directly as the source of an `Image` element.
26
22
  * @example
27
23
  * ```ts
28
24
  * <Image
@@ -39,7 +35,7 @@ export interface ClipboardImage {
39
35
  width: number;
40
36
  height: number;
41
37
  };
42
- }
38
+ };
43
39
 
44
40
  /**
45
41
  * Type used to define what type of data is stored in the clipboard.
@@ -62,16 +58,16 @@ export enum StringFormat {
62
58
  HTML = 'html',
63
59
  }
64
60
 
65
- export interface GetStringOptions {
61
+ export type GetStringOptions = {
66
62
  /**
67
63
  * The target format of the clipboard string to be converted to, if possible.
68
64
  *
69
65
  * @default StringFormat.PLAIN_TEXT
70
66
  */
71
67
  preferredFormat?: StringFormat;
72
- }
68
+ };
73
69
 
74
- export interface SetStringOptions {
70
+ export type SetStringOptions = {
75
71
  /**
76
72
  * The input format of the provided string.
77
73
  * Adjusting this option can help other applications interpret copied string properly.
@@ -79,82 +75,21 @@ export interface SetStringOptions {
79
75
  * @default StringFormat.PLAIN_TEXT
80
76
  */
81
77
  inputFormat?: StringFormat;
82
- }
78
+ };
83
79
 
84
- // @needsAudit
85
- export interface ClipboardPasteButtonProps extends ViewProps {
86
- /**
87
- * A callback that is called with the result of the paste action.
88
- * Inspect the `type` property to determine the type of the pasted data.
89
-
90
- * Can be one of `text` or `image`.
91
- *
92
- * @example
93
- * ```ts
94
- * onPress={(data) => {
95
- * if (data.type === 'image') {
96
- * setImageData(data);
97
- * } else {
98
- * setTextData(data);
99
- * }
100
- * }}
101
- * ```
102
- */
103
- onPress: (data: PasteEventPayload) => void;
104
- /**
105
- * The backgroundColor of the button.
106
- * Leaving this as the default allows the color to adjust to the system theme settings.
107
- */
108
- backgroundColor?: string | null;
109
- /**
110
- * The foregroundColor of the button.
111
- * @default white
112
- */
113
- foregroundColor?: string | null;
114
- /**
115
- * The cornerStyle of the button.
116
- * @default capsule
117
- *
118
- * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uibutton/configuration/cornerstyle) for more details.
119
- */
120
- cornerStyle?: CornerStyle | null;
121
- /**
122
- * The displayMode of the button.
123
- * @default `iconAndLabel`
124
- *
125
- * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uipastecontrol/displaymode) for more details.
126
- */
127
- displayMode?: DisplayMode | null;
128
- /**
129
- * The custom style to apply to the button. Should not include `backgroundColor`, `borderRadius` or `color`
130
- * properties.
131
- */
132
- style?: StyleProp<Omit<ViewStyle, 'backgroundColor' | 'borderRadius' | 'color'>>;
133
- /**
134
- * The options to use when pasting an image from the clipboard.
135
- */
136
- imageOptions?: GetImageOptions | null;
137
- /**
138
- * An array of the content types that will cause the button to become active
139
- * @note do not include `plain-text` and `html` at the same time as this will cause all text to be treated as `html`
140
- * @default ['plain-text', 'image']
141
- */
142
- acceptedContentTypes?: AcceptedContentType[];
143
- }
144
-
145
- type AcceptedContentType = 'plain-text' | 'image' | 'url' | 'html';
80
+ export type AcceptedContentType = 'plain-text' | 'image' | 'url' | 'html';
146
81
 
147
- type CornerStyle = 'dynamic' | 'fixed' | 'capsule' | 'large' | 'medium' | 'small';
82
+ export type CornerStyleType = 'dynamic' | 'fixed' | 'capsule' | 'large' | 'medium' | 'small';
148
83
 
149
- type DisplayMode = 'iconAndLabel' | 'iconOnly' | 'labelOnly';
84
+ export type DisplayModeType = 'iconAndLabel' | 'iconOnly' | 'labelOnly';
150
85
 
151
86
  export type PasteEventPayload = TextPasteEvent | ImagePasteEvent;
152
87
 
153
- export interface TextPasteEvent {
88
+ export type TextPasteEvent = {
154
89
  text: string;
155
90
  type: 'text';
156
- }
91
+ };
157
92
 
158
- export interface ImagePasteEvent extends ClipboardImage {
93
+ export type ImagePasteEvent = {
159
94
  type: 'image';
160
- }
95
+ } & ClipboardImage;
@@ -1,9 +1,76 @@
1
1
  import React from 'react';
2
- import { NativeSyntheticEvent } from 'react-native';
2
+ import { NativeSyntheticEvent, StyleProp, ViewProps, ViewStyle } from 'react-native';
3
3
 
4
- import { ClipboardPasteButtonProps, PasteEventPayload } from './Clipboard.types';
4
+ import {
5
+ AcceptedContentType,
6
+ CornerStyleType,
7
+ DisplayModeType,
8
+ GetImageOptions,
9
+ PasteEventPayload,
10
+ } from './Clipboard.types';
5
11
  import ExpoClipboardPasteButton from './ExpoClipboardPasteButton';
6
12
 
13
+ // @needsAudit
14
+ export type ClipboardPasteButtonProps = {
15
+ /**
16
+ * A callback that is called with the result of the paste action.
17
+ * Inspect the `type` property to determine the type of the pasted data.
18
+ *
19
+ * Can be one of `text` or `image`.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * onPress={(data) => {
24
+ * if (data.type === 'image') {
25
+ * setImageData(data);
26
+ * } else {
27
+ * setTextData(data);
28
+ * }
29
+ * }}
30
+ * ```
31
+ */
32
+ onPress: (data: PasteEventPayload) => void;
33
+ /**
34
+ * The backgroundColor of the button.
35
+ * Leaving this as the default allows the color to adjust to the system theme settings.
36
+ */
37
+ backgroundColor?: string | null;
38
+ /**
39
+ * The foregroundColor of the button.
40
+ * @default 'white'
41
+ */
42
+ foregroundColor?: string | null;
43
+ /**
44
+ * The cornerStyle of the button.
45
+ * @default 'capsule'
46
+ *
47
+ * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uibutton/configuration/cornerstyle) for more details.
48
+ */
49
+ cornerStyle?: CornerStyleType | null;
50
+ /**
51
+ * The displayMode of the button.
52
+ * @default 'iconAndLabel'
53
+ *
54
+ * @see [Apple Documentation](https://developer.apple.com/documentation/uikit/uipastecontrol/displaymode) for more details.
55
+ */
56
+ displayMode?: DisplayModeType | null;
57
+ /**
58
+ * The custom style to apply to the button. Should not include `backgroundColor`, `borderRadius` or `color`
59
+ * properties.
60
+ */
61
+ style?: StyleProp<Omit<ViewStyle, 'backgroundColor' | 'borderRadius' | 'color'>>;
62
+ /**
63
+ * The options to use when pasting an image from the clipboard.
64
+ */
65
+ imageOptions?: GetImageOptions | null;
66
+ /**
67
+ * An array of the content types that will cause the button to become active.
68
+ * > Do not include `plain-text` and `html` at the same time as this will cause all text to be treated as `html`.
69
+ * @default ['plain-text', 'image']
70
+ */
71
+ acceptedContentTypes?: AcceptedContentType[];
72
+ } & ViewProps;
73
+
7
74
  // @needsAudit
8
75
  /**
9
76
  * This component displays the `UIPasteControl` button on your screen. This allows pasting from the clipboard without requesting permission from the user.
@@ -22,9 +22,6 @@ import {
22
22
  } from '../Clipboard.types';
23
23
 
24
24
  export default {
25
- get name(): string {
26
- return 'ExpoClipboard';
27
- },
28
25
  async getStringAsync(options: GetStringOptions): Promise<string> {
29
26
  if (!navigator.clipboard) {
30
27
  throw new ClipboardUnavailableException();