expo-clipboard 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 6.0.1 — 2024-04-23
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
13
17
  ## 6.0.0 — 2024-04-18
14
18
 
15
19
  ### 💡 Others
@@ -1,7 +1,7 @@
1
1
  apply plugin: 'com.android.library'
2
2
 
3
3
  group = 'host.exp.exponent'
4
- version = '6.0.0'
4
+ version = '6.0.1'
5
5
 
6
6
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
7
7
  apply from: expoModulesCorePlugin
@@ -14,7 +14,7 @@ android {
14
14
  namespace "expo.modules.clipboard"
15
15
  defaultConfig {
16
16
  versionCode 3
17
- versionName '6.0.0'
17
+ versionName '6.0.1'
18
18
  }
19
19
  }
20
20
 
@@ -1 +1 @@
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,CAAC;IACD,OAAO,MAAM,aAAa,CAAC,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AAM,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
+ {"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;QACjC,MAAM,IAAI,mBAAmB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;KAC9D;IACD,OAAO,MAAM,aAAa,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAAY,EACZ,UAA4B,EAAE;IAE9B,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE;QACjC,MAAM,IAAI,mBAAmB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;KAC9D;IACD,OAAO,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,2CAA2C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AK,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 +1 @@
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
+ {"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;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, 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,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
+ {"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 +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;;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"}
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,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;;AAjJjC,wBAkJE"}
@@ -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,KAAK,CAAC,cAAc,CAAC,OAAyB;QAC5C,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,6BAA6B,EAAE,CAAC;QAC5C,CAAC;QAED,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,MAAM,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACxD,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,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"]}
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;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,CAAC,IAAI,EAAE,CAAC;iBACxC;gBACD,OAAO,CAAC,CAAC;oBACP,IAAI,IAAI,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;oBAChD,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,EAAE,EA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AAC;IACnE,CAAC;IACD,oBAAoB,KAAU,CAAC;IAC/B,uBAAuB,KAAU,CAAC;CACnC,CAAC;AAEF;;;;GAIG;AACH,KAAK,UAAU,sBAAsB,CAAC,KAAe;IACnD,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;QACxB,MAAM,IAAI,6BAA6B,EAAE,CAAC;KAC3C;IAED,IAAI;QACF,MAAM,cAAc,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACxD,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;KAC1F;IAAC,OAAO,CAAC,EAAE;QACV,gDAAgD;QAChD,IAAI,CAAC,CAAC,IAAI,KAAK,iBAAiB,IAAI,CAAC,MAAM,gCAAgC,EAAE,CAAC,EAAE;YAC9E,MAAM,IAAI,qBAAqB,EAAE,CAAC;SACnC;QACD,MAAM,CAAC,CAAC;KACT;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"]}
@@ -1 +1 @@
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,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S,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;QAC/D,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,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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": "6.0.0",
3
+ "version": "6.0.1",
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": "4165b8d72e1b9a1889c2767534cc619e21468110"
42
+ "gitHead": "ee4f30ef3b5fa567ad1bf94794197f7683fdd481"
43
43
  }