Comparing version 0.4.0 to 0.4.1
import React from 'react'; | ||
declare type RenderCompleteHandlerProps = { | ||
duration: number; | ||
}; | ||
declare type RenderCompleteHandler = (props: RenderCompleteHandlerProps) => Promise<any> | any | void; | ||
/** | ||
@@ -17,2 +21,4 @@ * | ||
network: Network; | ||
onRenderComplete?: RenderCompleteHandler; | ||
}>; | ||
export {}; |
@@ -23,3 +23,3 @@ "use strict"; | ||
var Asset = function (_a) { | ||
var address = _a.address, tokenId = _a.tokenId, _b = _a.preset, preset = _b === void 0 ? 'medium' : _b, _c = _a.network, network = _c === void 0 ? CenterProvider_1.DEFAULT_NETWORK : _c; | ||
var address = _a.address, tokenId = _a.tokenId, _b = _a.preset, preset = _b === void 0 ? 'medium' : _b, _c = _a.network, network = _c === void 0 ? CenterProvider_1.DEFAULT_NETWORK : _c, onRenderComplete = _a.onRenderComplete; | ||
if (Number.isInteger(tokenId)) { | ||
@@ -36,2 +36,3 @@ tokenId = tokenId.toString(); | ||
react_1.default.useEffect(function () { | ||
var startedAt = performance.now(); | ||
client | ||
@@ -45,2 +46,3 @@ .renderAssetPreset({ | ||
.then(function (resp) { | ||
var completedAt = performance.now(); | ||
var contentType = resp.data.contentType; | ||
@@ -63,2 +65,7 @@ if (contentType) { | ||
setMediaUrl(resp.data.mediaUrl); | ||
if (onRenderComplete && typeof onRenderComplete === 'function') { | ||
onRenderComplete({ | ||
duration: completedAt - startedAt, | ||
}); | ||
} | ||
}) | ||
@@ -71,4 +78,7 @@ .catch(function (err) { | ||
if (mediaUrl === undefined) { | ||
return react_1.default.createElement("div", null); | ||
return react_1.default.createElement("div", null, "no media url"); | ||
} | ||
else { | ||
console.info(mediaUrl); | ||
} | ||
if (mediaType === 'image') { | ||
@@ -88,4 +98,4 @@ return react_1.default.createElement("img", { src: mediaUrl }); | ||
}, [mediaUrl, mediaType, mimeType, address, tokenId]); | ||
return react_1.default.createElement("div", null, mediaElement); | ||
return mediaElement; | ||
}; | ||
exports.Asset = Asset; |
import React from 'react'; | ||
declare type RenderCompleteHandlerProps = { | ||
duration: number; | ||
}; | ||
declare type RenderCompleteHandler = (props: RenderCompleteHandlerProps) => Promise<any> | any | void; | ||
/** | ||
@@ -17,2 +21,4 @@ * | ||
network: Network; | ||
onRenderComplete?: RenderCompleteHandler; | ||
}>; | ||
export {}; |
@@ -17,3 +17,3 @@ import React from 'react'; | ||
export var Asset = function (_a) { | ||
var address = _a.address, tokenId = _a.tokenId, _b = _a.preset, preset = _b === void 0 ? 'medium' : _b, _c = _a.network, network = _c === void 0 ? DEFAULT_NETWORK : _c; | ||
var address = _a.address, tokenId = _a.tokenId, _b = _a.preset, preset = _b === void 0 ? 'medium' : _b, _c = _a.network, network = _c === void 0 ? DEFAULT_NETWORK : _c, onRenderComplete = _a.onRenderComplete; | ||
if (Number.isInteger(tokenId)) { | ||
@@ -30,2 +30,3 @@ tokenId = tokenId.toString(); | ||
React.useEffect(function () { | ||
var startedAt = performance.now(); | ||
client | ||
@@ -39,2 +40,3 @@ .renderAssetPreset({ | ||
.then(function (resp) { | ||
var completedAt = performance.now(); | ||
var contentType = resp.data.contentType; | ||
@@ -57,2 +59,7 @@ if (contentType) { | ||
setMediaUrl(resp.data.mediaUrl); | ||
if (onRenderComplete && typeof onRenderComplete === 'function') { | ||
onRenderComplete({ | ||
duration: completedAt - startedAt, | ||
}); | ||
} | ||
}) | ||
@@ -84,3 +91,3 @@ .catch(function (err) { | ||
}, [mediaUrl, mediaType, mimeType, address, tokenId]); | ||
return React.createElement("div", null, mediaElement); | ||
return mediaElement; | ||
}; |
{ | ||
"name": "nft-react", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "React components for interacting with NFTs", | ||
@@ -48,3 +48,3 @@ "main": "./dist/cjs/index.js", | ||
"dependencies": { | ||
"@center-inc/api-client": "^0.4.0", | ||
"@center-inc/api-client": "^0.4.1", | ||
"@center-inc/corp-vars": "^1.0.23", | ||
@@ -51,0 +51,0 @@ "axios": "^0.26.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
38130
901
0