New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

expo-clipboard

Package Overview
Dependencies
Maintainers
24
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-clipboard - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

android/build.gradle

55

build/Clipboard.d.ts

@@ -1,2 +0,53 @@

import ExpoClipboard from './ExpoClipboard';
export default ExpoClipboard;
import { EventEmitter, Subscription } from '@unimodules/core';
declare type ClipboardEvent = {
/**
* The new content of the user's clipboard.
*/
content: string;
};
export { Subscription, EventEmitter, ClipboardEvent };
/**
* Gets the content of the user's clipboard. Please note that calling this method on web will prompt
* the user to grant your app permission to "see text and images copied to the clipboard."
*
* @returns A promise that resolves to the content of the clipboard.
*/
export declare function getStringAsync(): Promise<string>;
/**
* Sets the content of the user's clipboard.
*
* @param text The string to save to the clipboard.
*
* @returns On web, this returns a boolean value indicating whether or not the string was saved to
* the user's clipboard. On iOS and Android, nothing is returned.
*/
export declare function setString(text: string): void;
/**
* Adds a listener that will fire whenever the content of the user's clipboard changes. This method
* is a no-op on Web.
*
* @param listener Callback to execute when listener is triggered. The callback is provided a
* single argument that is an object with a `content` key.
*
* @example
* ```typescript
* addClipboardListener(({ content }: ClipboardEvent) => {
* alert('Copy pasta! Here's the string that was copied: ' + content);
* });
* ```
*/
export declare function addClipboardListener(listener: (event: ClipboardEvent) => void): Subscription;
/**
* Removes the listener added by addClipboardListener. This method is a no-op on Web.
*
* @param subscription The subscription to remove (created by addClipboardListener).
*
* @example
* ```typescript
* const subscription = addClipboardListener(() => {
* alert('Copy pasta!');
* });
* removeClipboardListener(subscription);
* ```
*/
export declare function removeClipboardListener(subscription: Subscription): void;

@@ -0,3 +1,65 @@

import { EventEmitter, UnavailabilityError } from '@unimodules/core';
import ExpoClipboard from './ExpoClipboard';
export default ExpoClipboard;
const emitter = new EventEmitter(ExpoClipboard);
const onClipboardEventName = 'onClipboardChanged';
export { EventEmitter };
/**
* Gets the content of the user's clipboard. Please note that calling this method on web will prompt
* the user to grant your app permission to "see text and images copied to the clipboard."
*
* @returns A promise that resolves to the content of the clipboard.
*/
export async function getStringAsync() {
if (!ExpoClipboard.getStringAsync) {
throw new UnavailabilityError('Clipboard', 'getStringAsync');
}
return await ExpoClipboard.getStringAsync();
}
/**
* Sets the content of the user's clipboard.
*
* @param text The string to save to the clipboard.
*
* @returns On web, this returns a boolean value indicating whether or not the string was saved to
* the user's clipboard. On iOS and Android, nothing is returned.
*/
export function setString(text) {
if (!ExpoClipboard.setString) {
throw new UnavailabilityError('Clipboard', 'setString');
}
return ExpoClipboard.setString(text);
}
/**
* Adds a listener that will fire whenever the content of the user's clipboard changes. This method
* is a no-op on Web.
*
* @param listener Callback to execute when listener is triggered. The callback is provided a
* single argument that is an object with a `content` key.
*
* @example
* ```typescript
* addClipboardListener(({ content }: ClipboardEvent) => {
* alert('Copy pasta! Here's the string that was copied: ' + content);
* });
* ```
*/
export function addClipboardListener(listener) {
return emitter.addListener(onClipboardEventName, listener);
}
/**
* Removes the listener added by addClipboardListener. This method is a no-op on Web.
*
* @param subscription The subscription to remove (created by addClipboardListener).
*
* @example
* ```typescript
* const subscription = addClipboardListener(() => {
* alert('Copy pasta!');
* });
* removeClipboardListener(subscription);
* ```
*/
export function removeClipboardListener(subscription) {
emitter.removeSubscription(subscription);
}
//# sourceMappingURL=Clipboard.js.map

5

build/ExpoClipboard.d.ts

@@ -1,5 +0,2 @@

declare const _default: {
getStringAsync(): Promise<string>;
setString(text: string): void;
};
declare const _default: import("@unimodules/core").ProxyNativeModule;
export default _default;

@@ -1,11 +0,3 @@

// Temporary for SDK 40 until we make our own native implementation
import Clipboard from 'react-native/Libraries/Components/Clipboard/Clipboard';
export default {
async getStringAsync() {
return await Clipboard.getString();
},
setString(text) {
Clipboard.setString(text);
},
};
import { NativeModulesProxy } from '@unimodules/core';
export default NativeModulesProxy.ExpoClipboard;
//# sourceMappingURL=ExpoClipboard.js.map

@@ -5,3 +5,5 @@ declare const _default: {

setString(text: string): boolean;
addClipboardListener(): void;
removeClipboardListener(): void;
};
export default _default;

@@ -17,3 +17,3 @@ export default {

catch (e) {
Promise.reject(new Error('Unable to retrieve item from clipboard.'));
return Promise.reject(new Error('Unable to retrieve item from clipboard.'));
}

@@ -26,3 +26,3 @@ }

const textField = document.createElement('textarea');
textField.innerText = text;
textField.textContent = text;
document.body.appendChild(textField);

@@ -38,3 +38,5 @@ textField.select();

},
addClipboardListener() { },
removeClipboardListener() { },
};
//# sourceMappingURL=ExpoClipboard.web.js.map

@@ -11,2 +11,15 @@ # Changelog

### 💡 Others
## 1.1.0 — 2021-06-16
### 🎉 New features
- Added Clipboard event listener ([#13050](https://github.com/expo/expo/pull/13050) by [@cruzach](https://github.com/cruzach))
### 🐛 Bug fixes
- Fixed `getStringAsync` causing crashes on Web when an exception is thrown. ([#12494](https://github.com/expo/expo/pull/12494) by [@robertherber](https://github.com/robertherber))
- Fixed newlines not being copied on web. ([#12951](https://github.com/expo/expo/pull/12951) by [@cruzach](https://github.com/cruzach))
## 1.0.2 — 2021-03-23

@@ -13,0 +26,0 @@

{
"name": "expo-clipboard",
"version": "1.0.2",
"version": "1.1.0",
"description": "ExpoClipboard standalone module",

@@ -38,3 +38,3 @@ "main": "build/Clipboard.js",

},
"gitHead": "c2520eef58fddcc435c41d95829084f5f89b3e8e"
"gitHead": "c80d4c938920c5111e34c2dbca3a6bf500dff0e1"
}

@@ -0,2 +1,79 @@

import { EventEmitter, Subscription, UnavailabilityError } from '@unimodules/core';
import ExpoClipboard from './ExpoClipboard';
export default ExpoClipboard;
const emitter = new EventEmitter(ExpoClipboard);
const onClipboardEventName = 'onClipboardChanged';
type ClipboardEvent = {
/**
* The new content of the user's clipboard.
*/
content: string;
};
export { Subscription, EventEmitter, ClipboardEvent };
/**
* Gets the content of the user's clipboard. Please note that calling this method on web will prompt
* the user to grant your app permission to "see text and images copied to the clipboard."
*
* @returns A promise that resolves to the content of the clipboard.
*/
export async function getStringAsync(): Promise<string> {
if (!ExpoClipboard.getStringAsync) {
throw new UnavailabilityError('Clipboard', 'getStringAsync');
}
return await ExpoClipboard.getStringAsync();
}
/**
* Sets the content of the user's clipboard.
*
* @param text The string to save to the clipboard.
*
* @returns On web, this returns a boolean value indicating whether or not the string was saved to
* the user's clipboard. On iOS and Android, nothing is returned.
*/
export function setString(text: string): void {
if (!ExpoClipboard.setString) {
throw new UnavailabilityError('Clipboard', 'setString');
}
return ExpoClipboard.setString(text);
}
/**
* Adds a listener that will fire whenever the content of the user's clipboard changes. This method
* is a no-op on Web.
*
* @param listener Callback to execute when listener is triggered. The callback is provided a
* single argument that is an object with a `content` key.
*
* @example
* ```typescript
* addClipboardListener(({ content }: ClipboardEvent) => {
* alert('Copy pasta! Here's the string that was copied: ' + content);
* });
* ```
*/
export function addClipboardListener(listener: (event: ClipboardEvent) => void): Subscription {
return emitter.addListener<ClipboardEvent>(onClipboardEventName, listener);
}
/**
* Removes the listener added by addClipboardListener. This method is a no-op on Web.
*
* @param subscription The subscription to remove (created by addClipboardListener).
*
* @example
* ```typescript
* const subscription = addClipboardListener(() => {
* alert('Copy pasta!');
* });
* removeClipboardListener(subscription);
* ```
*/
export function removeClipboardListener(subscription: Subscription) {
emitter.removeSubscription(subscription);
}

@@ -1,11 +0,3 @@

// Temporary for SDK 40 until we make our own native implementation
import Clipboard from 'react-native/Libraries/Components/Clipboard/Clipboard';
import { NativeModulesProxy } from '@unimodules/core';
export default {
async getStringAsync(): Promise<string> {
return await Clipboard.getString();
},
setString(text: string): void {
Clipboard.setString(text);
},
};
export default NativeModulesProxy.ExpoClipboard;

@@ -15,3 +15,3 @@ export default {

} catch (e) {
Promise.reject(new Error('Unable to retrieve item from clipboard.'));
return Promise.reject(new Error('Unable to retrieve item from clipboard.'));
}

@@ -24,3 +24,3 @@ }

const textField = document.createElement('textarea');
textField.innerText = text;
textField.textContent = text;
document.body.appendChild(textField);

@@ -35,2 +35,4 @@ textField.select();

},
addClipboardListener(): void {},
removeClipboardListener(): void {},
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc