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

@crossbell/ipfs-react

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crossbell/ipfs-react - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

dist/cjs/components/index.d.ts

2

dist/cjs/hooks/use-handle-link-click.d.ts
import React from 'react';
export declare function useHandleLinkClick(): (event: React.MouseEvent<HTMLAnchorElement>) => void;
export declare function useHandleLinkClick(onClick?: React.MouseEventHandler<HTMLAnchorElement>): (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void;
//# sourceMappingURL=use-handle-link-click.d.ts.map

@@ -7,31 +7,15 @@ "use strict";

exports.useHandleLinkClick = void 0;
const ipfs_gateway_1 = require("@crossbell/ipfs-gateway");
const react_1 = __importDefault(require("react"));
const use_ipfs_gateway_1 = require("./use-ipfs-gateway");
function useHandleLinkClick() {
function useHandleLinkClick(onClick) {
const ipfsGateway = (0, use_ipfs_gateway_1.useIpfsGateway)();
const onClickRef = react_1.default.useRef(onClick);
onClickRef.current = onClick;
return react_1.default.useCallback((event) => {
const elm = event.currentTarget;
const link = elm.href;
const gatewayPrefix = ipfsGateway.config.serviceWorker?.gatewayPrefix;
const ipfsUrl = (() => {
if ((0, ipfs_gateway_1.isIpfsUrl)(link)) {
return link;
}
else if (gatewayPrefix) {
return (0, ipfs_gateway_1.swGatewayUrlToIpfsUrl)(gatewayPrefix, link);
}
else {
return null;
}
})();
if (ipfsUrl) {
const newWindow = window.open();
if (newWindow) {
onClickRef.current?.(event);
if (!event.defaultPrevented) {
const ipfsUrl = ipfsGateway.convertToIpfsUrl(event.currentTarget.href);
if (ipfsUrl) {
event.preventDefault();
ipfsGateway
.getFastestWeb2Url(ipfsUrl)
.catch(() => null)
.then((url) => url ?? ipfsGateway.getFallbackWeb2Url(ipfsUrl))
.then((url) => (newWindow.location.href = url));
ipfsGateway.openIpfsUrl(ipfsUrl);
}

@@ -38,0 +22,0 @@ }

export * from './context';
export * from './hooks';
export * from './components';
//# sourceMappingURL=index.d.ts.map

@@ -19,1 +19,2 @@ "use strict";

__exportStar(require("./hooks"), exports);
__exportStar(require("./components"), exports);
import React from 'react';
export declare function useHandleLinkClick(): (event: React.MouseEvent<HTMLAnchorElement>) => void;
export declare function useHandleLinkClick(onClick?: React.MouseEventHandler<HTMLAnchorElement>): (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => void;
//# sourceMappingURL=use-handle-link-click.d.ts.map

@@ -1,30 +0,14 @@

import { isIpfsUrl, swGatewayUrlToIpfsUrl } from '@crossbell/ipfs-gateway';
import React from 'react';
import { useIpfsGateway } from './use-ipfs-gateway';
export function useHandleLinkClick() {
export function useHandleLinkClick(onClick) {
const ipfsGateway = useIpfsGateway();
const onClickRef = React.useRef(onClick);
onClickRef.current = onClick;
return React.useCallback((event) => {
const elm = event.currentTarget;
const link = elm.href;
const gatewayPrefix = ipfsGateway.config.serviceWorker?.gatewayPrefix;
const ipfsUrl = (() => {
if (isIpfsUrl(link)) {
return link;
}
else if (gatewayPrefix) {
return swGatewayUrlToIpfsUrl(gatewayPrefix, link);
}
else {
return null;
}
})();
if (ipfsUrl) {
const newWindow = window.open();
if (newWindow) {
onClickRef.current?.(event);
if (!event.defaultPrevented) {
const ipfsUrl = ipfsGateway.convertToIpfsUrl(event.currentTarget.href);
if (ipfsUrl) {
event.preventDefault();
ipfsGateway
.getFastestWeb2Url(ipfsUrl)
.catch(() => null)
.then((url) => url ?? ipfsGateway.getFallbackWeb2Url(ipfsUrl))
.then((url) => (newWindow.location.href = url));
ipfsGateway.openIpfsUrl(ipfsUrl);
}

@@ -31,0 +15,0 @@ }

export * from './context';
export * from './hooks';
export * from './components';
//# sourceMappingURL=index.d.ts.map
export * from './context';
export * from './hooks';
export * from './components';
{
"name": "@crossbell/ipfs-react",
"version": "0.0.11",
"version": "0.0.12",
"license": "MIT",

@@ -19,7 +19,7 @@ "repository": "github:Crossbell-Box/crossbell-monorepo",

"peerDependencies": {
"@crossbell/ipfs-gateway": "0.0.11",
"@crossbell/ipfs-gateway": "0.0.12",
"react": "^17 || ^18"
},
"devDependencies": {
"@crossbell/ipfs-gateway": "0.0.11",
"@crossbell/ipfs-gateway": "0.0.12",
"@types/react": "18.0.18",

@@ -26,0 +26,0 @@ "node-fetch": "^3.2.10",

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