Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-tiny-link

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-tiny-link - npm Package Compare versions

Comparing version 3.6.0 to 3.6.1

src/useScraper.d.ts

2

package.json
{
"name": "react-tiny-link",
"version": "3.6.0",
"version": "3.6.1",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -40,20 +40,45 @@ # React-Tiny-Link

| PropName | Description | PropType | value | required |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | ---------------------------------------------- | -------- |
| **url** | URL to be display as preview | string | | `true` |
| **cardSize** | Size of the card | string | default (`small`) `small`,`large` | `false` |
| **maxLine** | Maximum number of line to ellipsis | number | 2 | `false` |
| **minLine** | Minimum number of line to ellipsis | number | 1 | `false` |
| **width** | Width of the link preview card | number | default(`100vw`) | `false` |
| **header** | Default Header content | string | null | `false` |
| **description** | Default description content | string | null | `false` |
| **proxyUrl** | Proxy URL to pass that resolve CORS | string | default(`https://cors-anywhere.herokuapp.com`) | `false` |
| **showGraphic** | Boolean value to display graphics | boolean | default(`true`) | `false` |
| **autoPlay** | Boolean value to play the media if provided url is video | boolean | default(`false`) | `false` |
| **defaultMedia** | Default value to provide the media for failure cases | string | N.A | `false` |
| **onError** | Error callback on when the url failed to fetch | onError(`error:Error`) | N.A | `false` |
| **onSuccess** | Success callback on when the url was fetched successfully | onSuccess(`data:IResponseData`) | N.A | `false` |
| **onClick** | Click event which will allow to add custom implementation `onClick` event if it was not provided the component itself will render as `<a></a>`. | onClick(`e:Event,data:IResponseData`) | default(`null`) | `false` |
| **loadSecureUrl** | Load only secure ( `https://` ) resources. If no secure resource was found, then don't render the `<img>` and `<video>` element | boolean | default(`false`) | `false` |
| PropName | Description | PropType | value | required |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | ---------------------------------------------- | -------- |
| **url** | URL to be display as preview | string | | `true` |
| **cardSize** | Size of the card | string | default (`small`) `small`,`large` | `false` |
| **maxLine** | Maximum number of line to ellipsis | number | 2 | `false` |
| **minLine** | Minimum number of line to ellipsis | number | 1 | `false` |
| **width** | Width of the link preview card | number | default(`100vw`) | `false` |
| **header** | Default Header content | string | null | `false` |
| **description** | Default description content | string | null | `false` |
| **proxyUrl** | Proxy URL to pass that resolve CORS | string | default(`https://cors-anywhere.herokuapp.com`) | `false` |
| **showGraphic** | Boolean value to display graphics | boolean | default(`true`) | `false` |
| **autoPlay** | Boolean value to play the media if provided url is video | boolean | default(`false`) | `false` |
| **defaultMedia** | Default value to provide the media for failure cases | string | N.A | `false` |
| **noCache** | Disables cache of link result | boolean | default(`false`) | `false` |
| **onError** | Error callback on when the url failed to fetch | onError(`error:Error`) | N.A | `false` |
| **onSuccess** | Success callback on when the url was fetched successfully | onSuccess(`data:IResponseData`) | N.A | `false` |
| **onClick** | Click event which will allow to add custom implementation `onClick` event if it was not provided the component itself will render as `<a></a>`. | onClick(`e:Event,data:IResponseData`) | default(`null`) | `false` |
| **loadSecureUrl** | Load only secure ( `https://` ) resources. If no secure resource was found, then don't render the `<img>` and `<video>` element | boolean | default(`false`) | `false` |
| **requestHeaders** | Request headers that will override the fetch headers | Record<string, string>; | default(`false`) | `false` |
## Hook usage
```javascript
import { useScrapper } from 'react-tiny-link'
const [result, loading, error] = useScrapper({
url:
'https://www.amazon.com/Steve-Madden-Mens-Jagwar-10-5/dp/B016X44MKA/ref=lp_18637582011_1_1?srs=18637582011&ie=UTF8&qid=1550721409&sr=8-1',
})
```
## Params
| PropName | Description | PropType | value | required |
| ----------------- | --------------------------------------------------------- | ------------------------------- | ---------------------------------------------- | -------- |
| **url** | URL to be display as preview | string | | `true` |
| **proxyUrl** | Proxy URL to pass that resolve CORS | string | default(`https://cors-anywhere.herokuapp.com`) | `false` |
| **defaultMedias** | Default value to provide the media for failure cases | string[] | N.A | `false` |
| **defaultValue** | Default response to provide for failure cases | IReactTinyLinkData | N.A | `false` |
| **noCache** | Disables cache of link result | boolean | default(`false`) | `false` |
| **onError** | Error callback on when the url failed to fetch | onError(`error:Error`) | N.A | `false` |
| **onSuccess** | Success callback on when the url was fetched successfully | onSuccess(`data:IResponseData`) | N.A | `false` |
## Demo App &

@@ -106,2 +131,3 @@

<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

@@ -108,0 +134,0 @@

export { ReactTinyLink } from "./ReactTinyLink";
export { ScrapperWraper } from "./ReactTinyLink";
export { useScrapper } from "./ReactTinyLink";
import * as React from 'react';
import { IReactTinyLinkProps } from './ReactTinyLinkTypes';
import { useScraper } from './useScraper';
export declare const useScrapper: typeof useScraper;
export declare const ScrapperWraper: (url: string, httpClient: any, defaultMedia: string[]) => Promise<{

@@ -4,0 +6,0 @@ title: any;

@@ -18,2 +18,3 @@ export declare enum ReactTinyLinkType {

url: string;
requestHeaders?: Headers | string[][] | Record<string, string>;
header?: string;

@@ -27,2 +28,3 @@ onError?: (error: Error) => void;

width?: string | number;
noCache?: boolean;
proxyUrl?: string;

@@ -29,0 +31,0 @@ loadSecureUrl?: boolean;

@@ -10,3 +10,3 @@ export enum ReactTinyLinkType {

TYPE_BOARDGAMEGEEK = 'TYPE_BOARDGAMEGEEK',
TYPE_TWITTER = "TYPE_TWITTER",
TYPE_TWITTER = 'TYPE_TWITTER',
}

@@ -21,2 +21,3 @@

url: string
requestHeaders?: Headers | string[][] | Record<string, string>
header?: string

@@ -30,2 +31,3 @@ onError?: (error: Error) => void

width?: string | number
noCache?: boolean
proxyUrl?: string

@@ -32,0 +34,0 @@ loadSecureUrl?: boolean

@@ -6,4 +6,5 @@ import { ReactTinyLinkType } from '../../ReactTinyLinkTypes'

const scrappedData = JSON.parse(data)
return {
title: scrappedData.title,
title: scrappedData.graphql.shortcode_media.accessibility_caption,
content: url,

@@ -14,6 +15,6 @@ url: url,

image: !defaultMedia
? [scrappedData.thumbnail_url]
: [scrappedData.thumbnail_url, defaultMedia].filter(i => !isEmpty(i)),
? [scrappedData.graphql.shortcode_media.display_url]
: [scrappedData.graphql.shortcode_media.display_url, defaultMedia].filter(i => !isEmpty(i)),
type: ReactTinyLinkType.TYPE_IMAGE, // MIME Type
}
}

Sorry, the diff of this file is too big to display

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

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