@ape.swap/bonds-sdk 2.0.4-testseed.34 → 2.0.4-testseed.37
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/dist/main.js +784 -11
- package/dist/styles.css +10 -6
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -4,7 +4,6 @@ import { useWaitForTransactionReceipt, useChainId, useAccount, useSwitchChain, u
|
|
|
4
4
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import { ConnectButton as ConnectButton$1 } from '@rainbow-me/rainbowkit';
|
|
7
|
-
import domtoimage from 'dom-to-image';
|
|
8
7
|
|
|
9
8
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
10
9
|
|
|
@@ -6295,7 +6294,7 @@ const Text$1 = /*#__PURE__*/React__default.forwardRef(function Text(props, ref)
|
|
|
6295
6294
|
* Image style variants can be defined in the theme.images object.
|
|
6296
6295
|
* @see https://theme-ui.com/components/image/
|
|
6297
6296
|
*/
|
|
6298
|
-
const Image = /*#__PURE__*/React__default.forwardRef(function Image(props, ref) {
|
|
6297
|
+
const Image$1 = /*#__PURE__*/React__default.forwardRef(function Image(props, ref) {
|
|
6299
6298
|
const __outerCss = props.__css;
|
|
6300
6299
|
return jsx$2(Box$1, {
|
|
6301
6300
|
ref: ref,
|
|
@@ -71315,8 +71314,9 @@ const MenuSelect = (_a) => {
|
|
|
71315
71314
|
display: 'flex',
|
|
71316
71315
|
width: '100%',
|
|
71317
71316
|
paddingRight: '4px',
|
|
71317
|
+
background: 'white2',
|
|
71318
71318
|
} }, props, { className: "dropdown", children: options === null || options === void 0 ? void 0 : options.map((option) => {
|
|
71319
|
-
return (jsx$2(SelectItem, { size: "xsm", value: option.value, children: jsx$2(Text, { sx: { fontWeight: 400, pl: '10px' }, children: option.label }) }, option.label));
|
|
71319
|
+
return (jsx$2(SelectItem, { size: "xsm", value: option.value, children: jsx$2(Text, { sx: { fontWeight: 400, pl: '10px' }, className: "menu-selector", children: option.label }) }, option.label));
|
|
71320
71320
|
}) })));
|
|
71321
71321
|
};
|
|
71322
71322
|
|
|
@@ -71393,7 +71393,7 @@ const BondFilters = ({ setChainFilterOption, chainFilterOption, filterOptions, f
|
|
|
71393
71393
|
setChainFilterOption(['All Chains']);
|
|
71394
71394
|
setFilterOption(newOption);
|
|
71395
71395
|
}, [setChainFilterOption, setFilterOption]);
|
|
71396
|
-
return (jsxs("div", { className: "bonds-filters", children: [jsx$2("div", { className: "desktop-rec-container", children: jsx$2(RecommendationSelector, { options: filterOptions, activeOption: filterOption, setActiveOption: handleFilterSelection }) }), jsx$2("div", { className: "mobile-rec-container", children: jsx$2(MenuSelect, { selectedOption: filterOption, setOption: setFilterOption, options: mappedFilters
|
|
71396
|
+
return (jsxs("div", { className: "bonds-filters", children: [jsx$2("div", { className: "desktop-rec-container", children: jsx$2(RecommendationSelector, { options: filterOptions, activeOption: filterOption, setActiveOption: handleFilterSelection }) }), jsx$2("div", { className: "mobile-rec-container", children: jsx$2(MenuSelect, { selectedOption: filterOption, setOption: setFilterOption, options: mappedFilters }) }), jsx$2("div", { className: "network-filter", children: jsx$2(NetworkFilter, { chainFilterOption: chainFilterOption, setChainFilterOption: setChainFilterOption }) }), jsxs("div", { className: "clear-all-button", onClick: () => {
|
|
71397
71397
|
setChainFilterOption(['All Chains']);
|
|
71398
71398
|
setFilterOption(asPath.includes('yourBonds') ? 'CLAIMABLE' : 'ALL');
|
|
71399
71399
|
onHandleQueryChange('');
|
|
@@ -72276,9 +72276,9 @@ const TokenSelectorPanel = ({ typedValue, setTypedValue, selectedToken, chainId,
|
|
|
72276
72276
|
!!v.currentTarget.value && isNumber$1(v.currentTarget.value) && parseFloat(v.currentTarget.value) >= 0
|
|
72277
72277
|
? v.currentTarget.value
|
|
72278
72278
|
: v.currentTarget.value.slice(0, v.currentTarget.value.length - 1);
|
|
72279
|
-
} }) }), jsxs(Flex$1, { className: "input-container token", onClick: () => (enableZap ? onTokenSelectorModal() : null), sx: { cursor: enableZap ? 'pointer' : 'default' }, children: [jsxs(Flex$1, { children: [jsx$2(Flex$1, { className: "input-container bondicon", children: lodashExports.isArray(splited) ? (jsx$2(TokenImage, { symbol: splited[0], symbol2: splited[1], size: 28, chain: chainId })) : (jsx$2(TokenImage, { symbol: getSymbol(selectedToken, chainId), size: 28, chain: chainId })) }), jsx$2(Flex$1, { className: "title-container tokenname", children: getSymbol(selectedToken, chainId) })] }), enableZap && (jsx$2(Flex$1, { sx: { mr: '8px' }, children: jsx$2(Svg, { icon: "caret" }) }))] })] }),
|
|
72279
|
+
} }) }), jsxs(Flex$1, { className: "input-container token", onClick: () => (enableZap ? onTokenSelectorModal() : null), sx: { cursor: enableZap ? 'pointer' : 'default' }, children: [jsxs(Flex$1, { children: [jsx$2(Flex$1, { className: "input-container bondicon", children: lodashExports.isArray(splited) ? (jsx$2(TokenImage, { symbol: splited[0], symbol2: splited[1], size: 28, chain: chainId })) : (jsx$2(TokenImage, { symbol: getSymbol(selectedToken, chainId), size: 28, chain: chainId })) }), jsx$2(Flex$1, { className: "title-container tokenname", children: getSymbol(selectedToken, chainId) })] }), enableZap && (jsx$2(Flex$1, { sx: { mr: '8px' }, children: jsx$2(Svg, { icon: "caret" }) }))] })] }), jsxs(Flex$1, { className: "input-container balancerow", children: [jsx$2(Flex$1, { children: selectedTokenPrice && typedValue
|
|
72280
72280
|
? `$${formatUSDNumber((selectedTokenPrice * parseFloat(typedValue)).toFixed(2))}`
|
|
72281
|
-
: '' }), jsxs(Flex$1, { children: [jsxs(Flex$1, { className: "balancerow text", children: ["Balance: ", tokenBalanceString] }), jsxs(Flex$1, { className: "balancerow max", children: [tokenBalance !== '0' && handleValueBtn && modalVariant !== 'alt' && (jsx$2(Fragment$1, { children: jsx$2(Button, { className: "max-button", onClick: () => { var _a; return handleValueBtn((_a = new BigNumber$1(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0')) === null || _a === void 0 ? void 0 : _a.toString()); }, children: "Max" }) })), tokenBalance !== '0' && handleValueBtn && modalVariant === 'alt' && (jsxs(
|
|
72281
|
+
: '' }), jsxs(Flex$1, { children: [jsxs(Flex$1, { className: "balancerow text", children: ["Balance: ", tokenBalanceString] }), jsxs(Flex$1, { className: "balancerow max", children: [tokenBalance && tokenBalance !== '0' && handleValueBtn && modalVariant !== 'alt' && (jsx$2(Fragment$1, { children: jsx$2(Button, { className: "max-button", onClick: () => { var _a; return handleValueBtn((_a = new BigNumber$1(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0')) === null || _a === void 0 ? void 0 : _a.toString()); }, children: "Max" }) })), tokenBalance && tokenBalance !== '0' && handleValueBtn && modalVariant === 'alt' && (jsxs(Flex$1, { children: [jsx$2(Button, { className: "max-button", onClick: () => handleValueBtn((parseFloat(tokenBalance) / 4).toString()), children: "25%" }), jsx$2(Button, { className: "max-button", onClick: () => handleValueBtn((parseFloat(tokenBalance) / 2).toString()), children: "50%" }), jsx$2(Button, { className: "max-button", onClick: () => handleValueBtn((parseFloat(tokenBalance) * 0.75).toString()), children: "75%" }), jsx$2(Button, { className: "max-button", onClick: () => { var _a; return handleValueBtn((_a = new BigNumber$1(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0')) === null || _a === void 0 ? void 0 : _a.toString()); }, children: "Max" })] }))] })] })] })] }));
|
|
72282
72282
|
};
|
|
72283
72283
|
|
|
72284
72284
|
var NetworkNames;
|
|
@@ -73103,7 +73103,7 @@ const SafeHTMLComponent = ({ html }) => {
|
|
|
73103
73103
|
|
|
73104
73104
|
const ProjectDescription = ({ description }) => {
|
|
73105
73105
|
const [isOpen, setIsOpen] = useState(false);
|
|
73106
|
-
return (jsxs(Flex, { className: "
|
|
73106
|
+
return (jsxs(Flex, { className: "description-container", children: [jsxs(Flex, { sx: { display: ['flex', 'flex', 'flex', 'none'], flexDirection: 'column' }, children: [jsx$2(Text, { sx: {
|
|
73107
73107
|
fontSize: ['12px', '12px', '12px', '14px'],
|
|
73108
73108
|
mt: '10px',
|
|
73109
73109
|
lineHeight: ['18px', '18px', '18px', '21px'],
|
|
@@ -73139,7 +73139,7 @@ const BondModalHeaderAlt = ({ bondData, onDismiss, showProjectInfoButton, }) =>
|
|
|
73139
73139
|
// },
|
|
73140
73140
|
// })
|
|
73141
73141
|
// }
|
|
73142
|
-
return (jsx$2(Flex, { className: "modaltable-container title-container", children: jsx$2(Flex, { className: "slipagge-close-icons", sx: { flexDirection: 'row' }, children: onDismiss ? (jsxs(Fragment$1, { children: [jsx$2(Flex, { sx: {
|
|
73142
|
+
return (jsx$2(Flex, { className: "modaltable-container title-container", children: jsx$2(Flex, { className: "slipagge-close-icons", sx: { flexDirection: 'row' }, children: onDismiss ? (jsxs(Fragment$1, { children: [jsx$2(Flex, { sx: { pr: '10px' }, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) }), jsx$2(IconButton, { icon: "close", color: "text", variant: "transparent", onClick: handleClose })] })) : (jsx$2(Flex, { sx: {}, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) })) }) }));
|
|
73143
73143
|
};
|
|
73144
73144
|
|
|
73145
73145
|
const ImageAndShortDescription = ({ bondData, onDismiss }) => {
|
|
@@ -73177,7 +73177,7 @@ const ImageAndShortDescription = ({ bondData, onDismiss }) => {
|
|
|
73177
73177
|
justifyContent: 'center',
|
|
73178
73178
|
}, children: jsx$2("img", { className: "project-image", src: "https://placehold.co/400x200" }) }, 2)] }), jsx$2(Flex, { sx: { position: 'absolute', bottom: ['15px', '15px', '15px', '20px'], left: 'calc(50% - 28,5px)', zIndex: 2 }, children: [...Array(imagesLength)].map((_, i) => {
|
|
73179
73179
|
return jsx$2(SwiperDots, { isActive: i === activeSlide, onClick: () => slideTo(i) }, i);
|
|
73180
|
-
}) })] }), jsxs(Flex, { sx: { alignItems: 'center', display: ['flex', 'flex', 'flex', 'none'], p: '10px', width: '100%' }, children: [jsxs(Flex, { sx: { width: ['50%', '50%', '50%', '100%'], alignItems: 'center' }, children: [jsx$2(Flex, { sx: { mr: '5px' }, children: jsx$2(TokenImage, { symbol: (_a = bondData.showcaseTokenName) !== null && _a !== void 0 ? _a : bondData.earnToken.symbol, size: 30, chain: bondData.chainId }) }), jsxs("h2", { className: "modal-tokenname-chainicon", sx: { margin: '0px' }, children: [bondData === null || bondData === void 0 ? void 0 : bondData.showcaseTokenName, ' '] })] }), jsx$2(Flex, { className: "modal-marketprice-header", sx: { justifyContent: 'flex-end',
|
|
73180
|
+
}) })] }), jsxs(Flex, { sx: { alignItems: 'center', display: ['flex', 'flex', 'flex', 'none'], p: '10px', width: '100%' }, children: [jsxs(Flex, { sx: { width: ['50%', '50%', '50%', '100%'], alignItems: 'center' }, children: [jsx$2(Flex, { sx: { mr: '5px' }, children: jsx$2(TokenImage, { symbol: (_a = bondData.showcaseTokenName) !== null && _a !== void 0 ? _a : bondData.earnToken.symbol, size: 30, chain: bondData.chainId }) }), jsxs("h2", { className: "modal-tokenname-chainicon", sx: { margin: '0px' }, children: [bondData === null || bondData === void 0 ? void 0 : bondData.showcaseTokenName, ' '] })] }), jsx$2(Flex, { className: "modal-marketprice-header", sx: { justifyContent: 'flex-end', alignItems: 'center' }, children: jsxs("span", { className: "modal-marketprice", children: ["Market Price: $", earnTokenPrice(bondData)] }) }), jsx$2(Flex, { className: "bondmodal-header-alt", sx: { mb: '10px' }, children: jsx$2(BondModalHeaderAlt, { bondData: bondData, onDismiss: onDismiss, showProjectInfoButton: (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.referenceId) === 'apebond' }) })] }), jsx$2(Flex, { className: "description-container paragraph-spaced", sx: { px: '10px', opacity: 0.7, mt: ['0', '0', '0', '10px'] }, children: jsx$2(ProjectDescription, { description: bondData === null || bondData === void 0 ? void 0 : bondData.shortDescription }) })] }));
|
|
73181
73181
|
};
|
|
73182
73182
|
|
|
73183
73183
|
const BondModal = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond }) => {
|
|
@@ -73644,7 +73644,7 @@ const BondRow = ({ bond }) => {
|
|
|
73644
73644
|
const tokens = new BigNumber$1(tokensRemaining);
|
|
73645
73645
|
return tokens.times(payoutTokenPrice);
|
|
73646
73646
|
};
|
|
73647
|
-
return (jsxs("div", { className: "bond-row", onClick: handleOpenModal, children: [jsx$2("div", { className: "token-info-container", children: jsx$2(TokenInfoAndName, { bill: bond }) }), jsxs("div", { className: "bond-info-columns", children: [jsx$2("div", { className: `discount-column ${getDiscountColor(discount)}`, children: discount !== undefined ? `${discount === null || discount === void 0 ? void 0 : discount.toFixed(2)}%` : '-' }), jsx$2("div", { className: "arr-column", children: calculateARR(bond) !== undefined ? calculateARR(bond) : '-' }), jsx$2("div", { className: "terms-column", children: ((_a = vestingTime(bond === null || bond === void 0 ? void 0 : bond.vestingTerm)) === null || _a === void 0 ? void 0 : _a.days) ? `${(_b = vestingTime(bond === null || bond === void 0 ? void 0 : bond.vestingTerm)) === null || _b === void 0 ? void 0 : _b.days} D` : '-' }), jsx$2("div", { className: "tokens-remaining-column", children: jsx$2(ProgressBarWrapper$1, { title: '', value: jsx$2(ProgressBar, { value: remainingPercentage(bond) }), style: {
|
|
73647
|
+
return (jsxs("div", { className: "bond-row", onClick: handleOpenModal, children: [jsx$2("div", { className: "token-info-container bond-market", children: jsx$2(TokenInfoAndName, { bill: bond }) }), jsxs("div", { className: "bond-info-columns", children: [jsx$2("div", { className: `discount-column ${getDiscountColor(discount)}`, children: discount !== undefined ? `${discount === null || discount === void 0 ? void 0 : discount.toFixed(2)}%` : '-' }), jsx$2("div", { className: "arr-column", children: calculateARR(bond) !== undefined ? calculateARR(bond) : '-' }), jsx$2("div", { className: "terms-column", children: ((_a = vestingTime(bond === null || bond === void 0 ? void 0 : bond.vestingTerm)) === null || _a === void 0 ? void 0 : _a.days) ? `${(_b = vestingTime(bond === null || bond === void 0 ? void 0 : bond.vestingTerm)) === null || _b === void 0 ? void 0 : _b.days} D` : '-' }), jsx$2("div", { className: "tokens-remaining-column", children: jsx$2(ProgressBarWrapper$1, { title: '', value: jsx$2(ProgressBar, { value: remainingPercentage(bond) }), style: {
|
|
73648
73648
|
width: '127px',
|
|
73649
73649
|
height: '25px',
|
|
73650
73650
|
flexDirection: 'column',
|
|
@@ -73903,7 +73903,7 @@ const RecommendationCards$1 = () => {
|
|
|
73903
73903
|
color: 'grey',
|
|
73904
73904
|
fontSize: ['11px'],
|
|
73905
73905
|
fontWeight: 500,
|
|
73906
|
-
}, children: "BONDS MARKETS:" }), jsx$2(RecommendationSelector, { options: options, activeOption: activeOption, setActiveOption: setActiveOption })] }), jsx$2(Flex, { sx: { display: ['none', 'none', 'none', 'flex'] }, children: jsx$2(Image, { width: 190, height: 20, alt: "poweredBy", src: "/images/bills/powered.png", sx: {
|
|
73906
|
+
}, children: "BONDS MARKETS:" }), jsx$2(RecommendationSelector, { options: options, activeOption: activeOption, setActiveOption: setActiveOption })] }), jsx$2(Flex, { sx: { display: ['none', 'none', 'none', 'flex'] }, children: jsx$2(Image$1, { width: 190, height: 20, alt: "poweredBy", src: "/images/bills/powered.png", sx: {
|
|
73907
73907
|
width: '190px',
|
|
73908
73908
|
height: '20px',
|
|
73909
73909
|
cursor: 'pointer',
|
|
@@ -90600,6 +90600,779 @@ const ProjectViewWithProviders = (props) => {
|
|
|
90600
90600
|
return (jsx$2(Providers, { children: jsx$2(ProjectView, Object.assign({}, props)) }));
|
|
90601
90601
|
};
|
|
90602
90602
|
|
|
90603
|
+
var domToImage = {exports: {}};
|
|
90604
|
+
|
|
90605
|
+
(function (module) {
|
|
90606
|
+
(function (global) {
|
|
90607
|
+
|
|
90608
|
+
var util = newUtil();
|
|
90609
|
+
var inliner = newInliner();
|
|
90610
|
+
var fontFaces = newFontFaces();
|
|
90611
|
+
var images = newImages();
|
|
90612
|
+
|
|
90613
|
+
// Default impl options
|
|
90614
|
+
var defaultOptions = {
|
|
90615
|
+
// Default is to fail on error, no placeholder
|
|
90616
|
+
imagePlaceholder: undefined,
|
|
90617
|
+
// Default cache bust is false, it will use the cache
|
|
90618
|
+
cacheBust: false
|
|
90619
|
+
};
|
|
90620
|
+
|
|
90621
|
+
var domtoimage = {
|
|
90622
|
+
toSvg: toSvg,
|
|
90623
|
+
toPng: toPng,
|
|
90624
|
+
toJpeg: toJpeg,
|
|
90625
|
+
toBlob: toBlob,
|
|
90626
|
+
toPixelData: toPixelData,
|
|
90627
|
+
impl: {
|
|
90628
|
+
fontFaces: fontFaces,
|
|
90629
|
+
images: images,
|
|
90630
|
+
util: util,
|
|
90631
|
+
inliner: inliner,
|
|
90632
|
+
options: {}
|
|
90633
|
+
}
|
|
90634
|
+
};
|
|
90635
|
+
|
|
90636
|
+
module.exports = domtoimage;
|
|
90637
|
+
|
|
90638
|
+
|
|
90639
|
+
/**
|
|
90640
|
+
* @param {Node} node - The DOM Node object to render
|
|
90641
|
+
* @param {Object} options - Rendering options
|
|
90642
|
+
* @param {Function} options.filter - Should return true if passed node should be included in the output
|
|
90643
|
+
* (excluding node means excluding it's children as well). Not called on the root node.
|
|
90644
|
+
* @param {String} options.bgcolor - color for the background, any valid CSS color value.
|
|
90645
|
+
* @param {Number} options.width - width to be applied to node before rendering.
|
|
90646
|
+
* @param {Number} options.height - height to be applied to node before rendering.
|
|
90647
|
+
* @param {Object} options.style - an object whose properties to be copied to node's style before rendering.
|
|
90648
|
+
* @param {Number} options.quality - a Number between 0 and 1 indicating image quality (applicable to JPEG only),
|
|
90649
|
+
defaults to 1.0.
|
|
90650
|
+
* @param {String} options.imagePlaceholder - dataURL to use as a placeholder for failed images, default behaviour is to fail fast on images we can't fetch
|
|
90651
|
+
* @param {Boolean} options.cacheBust - set to true to cache bust by appending the time to the request url
|
|
90652
|
+
* @return {Promise} - A promise that is fulfilled with a SVG image data URL
|
|
90653
|
+
* */
|
|
90654
|
+
function toSvg(node, options) {
|
|
90655
|
+
options = options || {};
|
|
90656
|
+
copyOptions(options);
|
|
90657
|
+
return Promise.resolve(node)
|
|
90658
|
+
.then(function (node) {
|
|
90659
|
+
return cloneNode(node, options.filter, true);
|
|
90660
|
+
})
|
|
90661
|
+
.then(embedFonts)
|
|
90662
|
+
.then(inlineImages)
|
|
90663
|
+
.then(applyOptions)
|
|
90664
|
+
.then(function (clone) {
|
|
90665
|
+
return makeSvgDataUri(clone,
|
|
90666
|
+
options.width || util.width(node),
|
|
90667
|
+
options.height || util.height(node)
|
|
90668
|
+
);
|
|
90669
|
+
});
|
|
90670
|
+
|
|
90671
|
+
function applyOptions(clone) {
|
|
90672
|
+
if (options.bgcolor) clone.style.backgroundColor = options.bgcolor;
|
|
90673
|
+
|
|
90674
|
+
if (options.width) clone.style.width = options.width + 'px';
|
|
90675
|
+
if (options.height) clone.style.height = options.height + 'px';
|
|
90676
|
+
|
|
90677
|
+
if (options.style)
|
|
90678
|
+
Object.keys(options.style).forEach(function (property) {
|
|
90679
|
+
clone.style[property] = options.style[property];
|
|
90680
|
+
});
|
|
90681
|
+
|
|
90682
|
+
return clone;
|
|
90683
|
+
}
|
|
90684
|
+
}
|
|
90685
|
+
|
|
90686
|
+
/**
|
|
90687
|
+
* @param {Node} node - The DOM Node object to render
|
|
90688
|
+
* @param {Object} options - Rendering options, @see {@link toSvg}
|
|
90689
|
+
* @return {Promise} - A promise that is fulfilled with a Uint8Array containing RGBA pixel data.
|
|
90690
|
+
* */
|
|
90691
|
+
function toPixelData(node, options) {
|
|
90692
|
+
return draw(node, options || {})
|
|
90693
|
+
.then(function (canvas) {
|
|
90694
|
+
return canvas.getContext('2d').getImageData(
|
|
90695
|
+
0,
|
|
90696
|
+
0,
|
|
90697
|
+
util.width(node),
|
|
90698
|
+
util.height(node)
|
|
90699
|
+
).data;
|
|
90700
|
+
});
|
|
90701
|
+
}
|
|
90702
|
+
|
|
90703
|
+
/**
|
|
90704
|
+
* @param {Node} node - The DOM Node object to render
|
|
90705
|
+
* @param {Object} options - Rendering options, @see {@link toSvg}
|
|
90706
|
+
* @return {Promise} - A promise that is fulfilled with a PNG image data URL
|
|
90707
|
+
* */
|
|
90708
|
+
function toPng(node, options) {
|
|
90709
|
+
return draw(node, options || {})
|
|
90710
|
+
.then(function (canvas) {
|
|
90711
|
+
return canvas.toDataURL();
|
|
90712
|
+
});
|
|
90713
|
+
}
|
|
90714
|
+
|
|
90715
|
+
/**
|
|
90716
|
+
* @param {Node} node - The DOM Node object to render
|
|
90717
|
+
* @param {Object} options - Rendering options, @see {@link toSvg}
|
|
90718
|
+
* @return {Promise} - A promise that is fulfilled with a JPEG image data URL
|
|
90719
|
+
* */
|
|
90720
|
+
function toJpeg(node, options) {
|
|
90721
|
+
options = options || {};
|
|
90722
|
+
return draw(node, options)
|
|
90723
|
+
.then(function (canvas) {
|
|
90724
|
+
return canvas.toDataURL('image/jpeg', options.quality || 1.0);
|
|
90725
|
+
});
|
|
90726
|
+
}
|
|
90727
|
+
|
|
90728
|
+
/**
|
|
90729
|
+
* @param {Node} node - The DOM Node object to render
|
|
90730
|
+
* @param {Object} options - Rendering options, @see {@link toSvg}
|
|
90731
|
+
* @return {Promise} - A promise that is fulfilled with a PNG image blob
|
|
90732
|
+
* */
|
|
90733
|
+
function toBlob(node, options) {
|
|
90734
|
+
return draw(node, options || {})
|
|
90735
|
+
.then(util.canvasToBlob);
|
|
90736
|
+
}
|
|
90737
|
+
|
|
90738
|
+
function copyOptions(options) {
|
|
90739
|
+
// Copy options to impl options for use in impl
|
|
90740
|
+
if(typeof(options.imagePlaceholder) === 'undefined') {
|
|
90741
|
+
domtoimage.impl.options.imagePlaceholder = defaultOptions.imagePlaceholder;
|
|
90742
|
+
} else {
|
|
90743
|
+
domtoimage.impl.options.imagePlaceholder = options.imagePlaceholder;
|
|
90744
|
+
}
|
|
90745
|
+
|
|
90746
|
+
if(typeof(options.cacheBust) === 'undefined') {
|
|
90747
|
+
domtoimage.impl.options.cacheBust = defaultOptions.cacheBust;
|
|
90748
|
+
} else {
|
|
90749
|
+
domtoimage.impl.options.cacheBust = options.cacheBust;
|
|
90750
|
+
}
|
|
90751
|
+
}
|
|
90752
|
+
|
|
90753
|
+
function draw(domNode, options) {
|
|
90754
|
+
return toSvg(domNode, options)
|
|
90755
|
+
.then(util.makeImage)
|
|
90756
|
+
.then(util.delay(100))
|
|
90757
|
+
.then(function (image) {
|
|
90758
|
+
var canvas = newCanvas(domNode);
|
|
90759
|
+
canvas.getContext('2d').drawImage(image, 0, 0);
|
|
90760
|
+
return canvas;
|
|
90761
|
+
});
|
|
90762
|
+
|
|
90763
|
+
function newCanvas(domNode) {
|
|
90764
|
+
var canvas = document.createElement('canvas');
|
|
90765
|
+
canvas.width = options.width || util.width(domNode);
|
|
90766
|
+
canvas.height = options.height || util.height(domNode);
|
|
90767
|
+
|
|
90768
|
+
if (options.bgcolor) {
|
|
90769
|
+
var ctx = canvas.getContext('2d');
|
|
90770
|
+
ctx.fillStyle = options.bgcolor;
|
|
90771
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
90772
|
+
}
|
|
90773
|
+
|
|
90774
|
+
return canvas;
|
|
90775
|
+
}
|
|
90776
|
+
}
|
|
90777
|
+
|
|
90778
|
+
function cloneNode(node, filter, root) {
|
|
90779
|
+
if (!root && filter && !filter(node)) return Promise.resolve();
|
|
90780
|
+
|
|
90781
|
+
return Promise.resolve(node)
|
|
90782
|
+
.then(makeNodeCopy)
|
|
90783
|
+
.then(function (clone) {
|
|
90784
|
+
return cloneChildren(node, clone, filter);
|
|
90785
|
+
})
|
|
90786
|
+
.then(function (clone) {
|
|
90787
|
+
return processClone(node, clone);
|
|
90788
|
+
});
|
|
90789
|
+
|
|
90790
|
+
function makeNodeCopy(node) {
|
|
90791
|
+
if (node instanceof HTMLCanvasElement) return util.makeImage(node.toDataURL());
|
|
90792
|
+
return node.cloneNode(false);
|
|
90793
|
+
}
|
|
90794
|
+
|
|
90795
|
+
function cloneChildren(original, clone, filter) {
|
|
90796
|
+
var children = original.childNodes;
|
|
90797
|
+
if (children.length === 0) return Promise.resolve(clone);
|
|
90798
|
+
|
|
90799
|
+
return cloneChildrenInOrder(clone, util.asArray(children), filter)
|
|
90800
|
+
.then(function () {
|
|
90801
|
+
return clone;
|
|
90802
|
+
});
|
|
90803
|
+
|
|
90804
|
+
function cloneChildrenInOrder(parent, children, filter) {
|
|
90805
|
+
var done = Promise.resolve();
|
|
90806
|
+
children.forEach(function (child) {
|
|
90807
|
+
done = done
|
|
90808
|
+
.then(function () {
|
|
90809
|
+
return cloneNode(child, filter);
|
|
90810
|
+
})
|
|
90811
|
+
.then(function (childClone) {
|
|
90812
|
+
if (childClone) parent.appendChild(childClone);
|
|
90813
|
+
});
|
|
90814
|
+
});
|
|
90815
|
+
return done;
|
|
90816
|
+
}
|
|
90817
|
+
}
|
|
90818
|
+
|
|
90819
|
+
function processClone(original, clone) {
|
|
90820
|
+
if (!(clone instanceof Element)) return clone;
|
|
90821
|
+
|
|
90822
|
+
return Promise.resolve()
|
|
90823
|
+
.then(cloneStyle)
|
|
90824
|
+
.then(clonePseudoElements)
|
|
90825
|
+
.then(copyUserInput)
|
|
90826
|
+
.then(fixSvg)
|
|
90827
|
+
.then(function () {
|
|
90828
|
+
return clone;
|
|
90829
|
+
});
|
|
90830
|
+
|
|
90831
|
+
function cloneStyle() {
|
|
90832
|
+
copyStyle(window.getComputedStyle(original), clone.style);
|
|
90833
|
+
|
|
90834
|
+
function copyStyle(source, target) {
|
|
90835
|
+
if (source.cssText) target.cssText = source.cssText;
|
|
90836
|
+
else copyProperties(source, target);
|
|
90837
|
+
|
|
90838
|
+
function copyProperties(source, target) {
|
|
90839
|
+
util.asArray(source).forEach(function (name) {
|
|
90840
|
+
target.setProperty(
|
|
90841
|
+
name,
|
|
90842
|
+
source.getPropertyValue(name),
|
|
90843
|
+
source.getPropertyPriority(name)
|
|
90844
|
+
);
|
|
90845
|
+
});
|
|
90846
|
+
}
|
|
90847
|
+
}
|
|
90848
|
+
}
|
|
90849
|
+
|
|
90850
|
+
function clonePseudoElements() {
|
|
90851
|
+
[':before', ':after'].forEach(function (element) {
|
|
90852
|
+
clonePseudoElement(element);
|
|
90853
|
+
});
|
|
90854
|
+
|
|
90855
|
+
function clonePseudoElement(element) {
|
|
90856
|
+
var style = window.getComputedStyle(original, element);
|
|
90857
|
+
var content = style.getPropertyValue('content');
|
|
90858
|
+
|
|
90859
|
+
if (content === '' || content === 'none') return;
|
|
90860
|
+
|
|
90861
|
+
var className = util.uid();
|
|
90862
|
+
clone.className = clone.className + ' ' + className;
|
|
90863
|
+
var styleElement = document.createElement('style');
|
|
90864
|
+
styleElement.appendChild(formatPseudoElementStyle(className, element, style));
|
|
90865
|
+
clone.appendChild(styleElement);
|
|
90866
|
+
|
|
90867
|
+
function formatPseudoElementStyle(className, element, style) {
|
|
90868
|
+
var selector = '.' + className + ':' + element;
|
|
90869
|
+
var cssText = style.cssText ? formatCssText(style) : formatCssProperties(style);
|
|
90870
|
+
return document.createTextNode(selector + '{' + cssText + '}');
|
|
90871
|
+
|
|
90872
|
+
function formatCssText(style) {
|
|
90873
|
+
var content = style.getPropertyValue('content');
|
|
90874
|
+
return style.cssText + ' content: ' + content + ';';
|
|
90875
|
+
}
|
|
90876
|
+
|
|
90877
|
+
function formatCssProperties(style) {
|
|
90878
|
+
|
|
90879
|
+
return util.asArray(style)
|
|
90880
|
+
.map(formatProperty)
|
|
90881
|
+
.join('; ') + ';';
|
|
90882
|
+
|
|
90883
|
+
function formatProperty(name) {
|
|
90884
|
+
return name + ': ' +
|
|
90885
|
+
style.getPropertyValue(name) +
|
|
90886
|
+
(style.getPropertyPriority(name) ? ' !important' : '');
|
|
90887
|
+
}
|
|
90888
|
+
}
|
|
90889
|
+
}
|
|
90890
|
+
}
|
|
90891
|
+
}
|
|
90892
|
+
|
|
90893
|
+
function copyUserInput() {
|
|
90894
|
+
if (original instanceof HTMLTextAreaElement) clone.innerHTML = original.value;
|
|
90895
|
+
if (original instanceof HTMLInputElement) clone.setAttribute("value", original.value);
|
|
90896
|
+
}
|
|
90897
|
+
|
|
90898
|
+
function fixSvg() {
|
|
90899
|
+
if (!(clone instanceof SVGElement)) return;
|
|
90900
|
+
clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
|
90901
|
+
|
|
90902
|
+
if (!(clone instanceof SVGRectElement)) return;
|
|
90903
|
+
['width', 'height'].forEach(function (attribute) {
|
|
90904
|
+
var value = clone.getAttribute(attribute);
|
|
90905
|
+
if (!value) return;
|
|
90906
|
+
|
|
90907
|
+
clone.style.setProperty(attribute, value);
|
|
90908
|
+
});
|
|
90909
|
+
}
|
|
90910
|
+
}
|
|
90911
|
+
}
|
|
90912
|
+
|
|
90913
|
+
function embedFonts(node) {
|
|
90914
|
+
return fontFaces.resolveAll()
|
|
90915
|
+
.then(function (cssText) {
|
|
90916
|
+
var styleNode = document.createElement('style');
|
|
90917
|
+
node.appendChild(styleNode);
|
|
90918
|
+
styleNode.appendChild(document.createTextNode(cssText));
|
|
90919
|
+
return node;
|
|
90920
|
+
});
|
|
90921
|
+
}
|
|
90922
|
+
|
|
90923
|
+
function inlineImages(node) {
|
|
90924
|
+
return images.inlineAll(node)
|
|
90925
|
+
.then(function () {
|
|
90926
|
+
return node;
|
|
90927
|
+
});
|
|
90928
|
+
}
|
|
90929
|
+
|
|
90930
|
+
function makeSvgDataUri(node, width, height) {
|
|
90931
|
+
return Promise.resolve(node)
|
|
90932
|
+
.then(function (node) {
|
|
90933
|
+
node.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
|
|
90934
|
+
return new XMLSerializer().serializeToString(node);
|
|
90935
|
+
})
|
|
90936
|
+
.then(util.escapeXhtml)
|
|
90937
|
+
.then(function (xhtml) {
|
|
90938
|
+
return '<foreignObject x="0" y="0" width="100%" height="100%">' + xhtml + '</foreignObject>';
|
|
90939
|
+
})
|
|
90940
|
+
.then(function (foreignObject) {
|
|
90941
|
+
return '<svg xmlns="http://www.w3.org/2000/svg" width="' + width + '" height="' + height + '">' +
|
|
90942
|
+
foreignObject + '</svg>';
|
|
90943
|
+
})
|
|
90944
|
+
.then(function (svg) {
|
|
90945
|
+
return 'data:image/svg+xml;charset=utf-8,' + svg;
|
|
90946
|
+
});
|
|
90947
|
+
}
|
|
90948
|
+
|
|
90949
|
+
function newUtil() {
|
|
90950
|
+
return {
|
|
90951
|
+
escape: escape,
|
|
90952
|
+
parseExtension: parseExtension,
|
|
90953
|
+
mimeType: mimeType,
|
|
90954
|
+
dataAsUrl: dataAsUrl,
|
|
90955
|
+
isDataUrl: isDataUrl,
|
|
90956
|
+
canvasToBlob: canvasToBlob,
|
|
90957
|
+
resolveUrl: resolveUrl,
|
|
90958
|
+
getAndEncode: getAndEncode,
|
|
90959
|
+
uid: uid(),
|
|
90960
|
+
delay: delay,
|
|
90961
|
+
asArray: asArray,
|
|
90962
|
+
escapeXhtml: escapeXhtml,
|
|
90963
|
+
makeImage: makeImage,
|
|
90964
|
+
width: width,
|
|
90965
|
+
height: height
|
|
90966
|
+
};
|
|
90967
|
+
|
|
90968
|
+
function mimes() {
|
|
90969
|
+
/*
|
|
90970
|
+
* Only WOFF and EOT mime types for fonts are 'real'
|
|
90971
|
+
* see http://www.iana.org/assignments/media-types/media-types.xhtml
|
|
90972
|
+
*/
|
|
90973
|
+
var WOFF = 'application/font-woff';
|
|
90974
|
+
var JPEG = 'image/jpeg';
|
|
90975
|
+
|
|
90976
|
+
return {
|
|
90977
|
+
'woff': WOFF,
|
|
90978
|
+
'woff2': WOFF,
|
|
90979
|
+
'ttf': 'application/font-truetype',
|
|
90980
|
+
'eot': 'application/vnd.ms-fontobject',
|
|
90981
|
+
'png': 'image/png',
|
|
90982
|
+
'jpg': JPEG,
|
|
90983
|
+
'jpeg': JPEG,
|
|
90984
|
+
'gif': 'image/gif',
|
|
90985
|
+
'tiff': 'image/tiff',
|
|
90986
|
+
'svg': 'image/svg+xml'
|
|
90987
|
+
};
|
|
90988
|
+
}
|
|
90989
|
+
|
|
90990
|
+
function parseExtension(url) {
|
|
90991
|
+
var match = /\.([^\.\/]*?)$/g.exec(url);
|
|
90992
|
+
if (match) return match[1];
|
|
90993
|
+
else return '';
|
|
90994
|
+
}
|
|
90995
|
+
|
|
90996
|
+
function mimeType(url) {
|
|
90997
|
+
var extension = parseExtension(url).toLowerCase();
|
|
90998
|
+
return mimes()[extension] || '';
|
|
90999
|
+
}
|
|
91000
|
+
|
|
91001
|
+
function isDataUrl(url) {
|
|
91002
|
+
return url.search(/^(data:)/) !== -1;
|
|
91003
|
+
}
|
|
91004
|
+
|
|
91005
|
+
function toBlob(canvas) {
|
|
91006
|
+
return new Promise(function (resolve) {
|
|
91007
|
+
var binaryString = window.atob(canvas.toDataURL().split(',')[1]);
|
|
91008
|
+
var length = binaryString.length;
|
|
91009
|
+
var binaryArray = new Uint8Array(length);
|
|
91010
|
+
|
|
91011
|
+
for (var i = 0; i < length; i++)
|
|
91012
|
+
binaryArray[i] = binaryString.charCodeAt(i);
|
|
91013
|
+
|
|
91014
|
+
resolve(new Blob([binaryArray], {
|
|
91015
|
+
type: 'image/png'
|
|
91016
|
+
}));
|
|
91017
|
+
});
|
|
91018
|
+
}
|
|
91019
|
+
|
|
91020
|
+
function canvasToBlob(canvas) {
|
|
91021
|
+
if (canvas.toBlob)
|
|
91022
|
+
return new Promise(function (resolve) {
|
|
91023
|
+
canvas.toBlob(resolve);
|
|
91024
|
+
});
|
|
91025
|
+
|
|
91026
|
+
return toBlob(canvas);
|
|
91027
|
+
}
|
|
91028
|
+
|
|
91029
|
+
function resolveUrl(url, baseUrl) {
|
|
91030
|
+
var doc = document.implementation.createHTMLDocument();
|
|
91031
|
+
var base = doc.createElement('base');
|
|
91032
|
+
doc.head.appendChild(base);
|
|
91033
|
+
var a = doc.createElement('a');
|
|
91034
|
+
doc.body.appendChild(a);
|
|
91035
|
+
base.href = baseUrl;
|
|
91036
|
+
a.href = url;
|
|
91037
|
+
return a.href;
|
|
91038
|
+
}
|
|
91039
|
+
|
|
91040
|
+
function uid() {
|
|
91041
|
+
var index = 0;
|
|
91042
|
+
|
|
91043
|
+
return function () {
|
|
91044
|
+
return 'u' + fourRandomChars() + index++;
|
|
91045
|
+
|
|
91046
|
+
function fourRandomChars() {
|
|
91047
|
+
/* see http://stackoverflow.com/a/6248722/2519373 */
|
|
91048
|
+
return ('0000' + (Math.random() * Math.pow(36, 4) << 0).toString(36)).slice(-4);
|
|
91049
|
+
}
|
|
91050
|
+
};
|
|
91051
|
+
}
|
|
91052
|
+
|
|
91053
|
+
function makeImage(uri) {
|
|
91054
|
+
return new Promise(function (resolve, reject) {
|
|
91055
|
+
var image = new Image();
|
|
91056
|
+
image.onload = function () {
|
|
91057
|
+
resolve(image);
|
|
91058
|
+
};
|
|
91059
|
+
image.onerror = reject;
|
|
91060
|
+
image.src = uri;
|
|
91061
|
+
});
|
|
91062
|
+
}
|
|
91063
|
+
|
|
91064
|
+
function getAndEncode(url) {
|
|
91065
|
+
var TIMEOUT = 30000;
|
|
91066
|
+
if(domtoimage.impl.options.cacheBust) {
|
|
91067
|
+
// Cache bypass so we dont have CORS issues with cached images
|
|
91068
|
+
// Source: https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache
|
|
91069
|
+
url += ((/\?/).test(url) ? "&" : "?") + (new Date()).getTime();
|
|
91070
|
+
}
|
|
91071
|
+
|
|
91072
|
+
return new Promise(function (resolve) {
|
|
91073
|
+
var request = new XMLHttpRequest();
|
|
91074
|
+
|
|
91075
|
+
request.onreadystatechange = done;
|
|
91076
|
+
request.ontimeout = timeout;
|
|
91077
|
+
request.responseType = 'blob';
|
|
91078
|
+
request.timeout = TIMEOUT;
|
|
91079
|
+
request.open('GET', url, true);
|
|
91080
|
+
request.send();
|
|
91081
|
+
|
|
91082
|
+
var placeholder;
|
|
91083
|
+
if(domtoimage.impl.options.imagePlaceholder) {
|
|
91084
|
+
var split = domtoimage.impl.options.imagePlaceholder.split(/,/);
|
|
91085
|
+
if(split && split[1]) {
|
|
91086
|
+
placeholder = split[1];
|
|
91087
|
+
}
|
|
91088
|
+
}
|
|
91089
|
+
|
|
91090
|
+
function done() {
|
|
91091
|
+
if (request.readyState !== 4) return;
|
|
91092
|
+
|
|
91093
|
+
if (request.status !== 200) {
|
|
91094
|
+
if(placeholder) {
|
|
91095
|
+
resolve(placeholder);
|
|
91096
|
+
} else {
|
|
91097
|
+
fail('cannot fetch resource: ' + url + ', status: ' + request.status);
|
|
91098
|
+
}
|
|
91099
|
+
|
|
91100
|
+
return;
|
|
91101
|
+
}
|
|
91102
|
+
|
|
91103
|
+
var encoder = new FileReader();
|
|
91104
|
+
encoder.onloadend = function () {
|
|
91105
|
+
var content = encoder.result.split(/,/)[1];
|
|
91106
|
+
resolve(content);
|
|
91107
|
+
};
|
|
91108
|
+
encoder.readAsDataURL(request.response);
|
|
91109
|
+
}
|
|
91110
|
+
|
|
91111
|
+
function timeout() {
|
|
91112
|
+
if(placeholder) {
|
|
91113
|
+
resolve(placeholder);
|
|
91114
|
+
} else {
|
|
91115
|
+
fail('timeout of ' + TIMEOUT + 'ms occured while fetching resource: ' + url);
|
|
91116
|
+
}
|
|
91117
|
+
}
|
|
91118
|
+
|
|
91119
|
+
function fail(message) {
|
|
91120
|
+
console.error(message);
|
|
91121
|
+
resolve('');
|
|
91122
|
+
}
|
|
91123
|
+
});
|
|
91124
|
+
}
|
|
91125
|
+
|
|
91126
|
+
function dataAsUrl(content, type) {
|
|
91127
|
+
return 'data:' + type + ';base64,' + content;
|
|
91128
|
+
}
|
|
91129
|
+
|
|
91130
|
+
function escape(string) {
|
|
91131
|
+
return string.replace(/([.*+?^${}()|\[\]\/\\])/g, '\\$1');
|
|
91132
|
+
}
|
|
91133
|
+
|
|
91134
|
+
function delay(ms) {
|
|
91135
|
+
return function (arg) {
|
|
91136
|
+
return new Promise(function (resolve) {
|
|
91137
|
+
setTimeout(function () {
|
|
91138
|
+
resolve(arg);
|
|
91139
|
+
}, ms);
|
|
91140
|
+
});
|
|
91141
|
+
};
|
|
91142
|
+
}
|
|
91143
|
+
|
|
91144
|
+
function asArray(arrayLike) {
|
|
91145
|
+
var array = [];
|
|
91146
|
+
var length = arrayLike.length;
|
|
91147
|
+
for (var i = 0; i < length; i++) array.push(arrayLike[i]);
|
|
91148
|
+
return array;
|
|
91149
|
+
}
|
|
91150
|
+
|
|
91151
|
+
function escapeXhtml(string) {
|
|
91152
|
+
return string.replace(/#/g, '%23').replace(/\n/g, '%0A');
|
|
91153
|
+
}
|
|
91154
|
+
|
|
91155
|
+
function width(node) {
|
|
91156
|
+
var leftBorder = px(node, 'border-left-width');
|
|
91157
|
+
var rightBorder = px(node, 'border-right-width');
|
|
91158
|
+
return node.scrollWidth + leftBorder + rightBorder;
|
|
91159
|
+
}
|
|
91160
|
+
|
|
91161
|
+
function height(node) {
|
|
91162
|
+
var topBorder = px(node, 'border-top-width');
|
|
91163
|
+
var bottomBorder = px(node, 'border-bottom-width');
|
|
91164
|
+
return node.scrollHeight + topBorder + bottomBorder;
|
|
91165
|
+
}
|
|
91166
|
+
|
|
91167
|
+
function px(node, styleProperty) {
|
|
91168
|
+
var value = window.getComputedStyle(node).getPropertyValue(styleProperty);
|
|
91169
|
+
return parseFloat(value.replace('px', ''));
|
|
91170
|
+
}
|
|
91171
|
+
}
|
|
91172
|
+
|
|
91173
|
+
function newInliner() {
|
|
91174
|
+
var URL_REGEX = /url\(['"]?([^'"]+?)['"]?\)/g;
|
|
91175
|
+
|
|
91176
|
+
return {
|
|
91177
|
+
inlineAll: inlineAll,
|
|
91178
|
+
shouldProcess: shouldProcess,
|
|
91179
|
+
impl: {
|
|
91180
|
+
readUrls: readUrls,
|
|
91181
|
+
inline: inline
|
|
91182
|
+
}
|
|
91183
|
+
};
|
|
91184
|
+
|
|
91185
|
+
function shouldProcess(string) {
|
|
91186
|
+
return string.search(URL_REGEX) !== -1;
|
|
91187
|
+
}
|
|
91188
|
+
|
|
91189
|
+
function readUrls(string) {
|
|
91190
|
+
var result = [];
|
|
91191
|
+
var match;
|
|
91192
|
+
while ((match = URL_REGEX.exec(string)) !== null) {
|
|
91193
|
+
result.push(match[1]);
|
|
91194
|
+
}
|
|
91195
|
+
return result.filter(function (url) {
|
|
91196
|
+
return !util.isDataUrl(url);
|
|
91197
|
+
});
|
|
91198
|
+
}
|
|
91199
|
+
|
|
91200
|
+
function inline(string, url, baseUrl, get) {
|
|
91201
|
+
return Promise.resolve(url)
|
|
91202
|
+
.then(function (url) {
|
|
91203
|
+
return baseUrl ? util.resolveUrl(url, baseUrl) : url;
|
|
91204
|
+
})
|
|
91205
|
+
.then(get || util.getAndEncode)
|
|
91206
|
+
.then(function (data) {
|
|
91207
|
+
return util.dataAsUrl(data, util.mimeType(url));
|
|
91208
|
+
})
|
|
91209
|
+
.then(function (dataUrl) {
|
|
91210
|
+
return string.replace(urlAsRegex(url), '$1' + dataUrl + '$3');
|
|
91211
|
+
});
|
|
91212
|
+
|
|
91213
|
+
function urlAsRegex(url) {
|
|
91214
|
+
return new RegExp('(url\\([\'"]?)(' + util.escape(url) + ')([\'"]?\\))', 'g');
|
|
91215
|
+
}
|
|
91216
|
+
}
|
|
91217
|
+
|
|
91218
|
+
function inlineAll(string, baseUrl, get) {
|
|
91219
|
+
if (nothingToInline()) return Promise.resolve(string);
|
|
91220
|
+
|
|
91221
|
+
return Promise.resolve(string)
|
|
91222
|
+
.then(readUrls)
|
|
91223
|
+
.then(function (urls) {
|
|
91224
|
+
var done = Promise.resolve(string);
|
|
91225
|
+
urls.forEach(function (url) {
|
|
91226
|
+
done = done.then(function (string) {
|
|
91227
|
+
return inline(string, url, baseUrl, get);
|
|
91228
|
+
});
|
|
91229
|
+
});
|
|
91230
|
+
return done;
|
|
91231
|
+
});
|
|
91232
|
+
|
|
91233
|
+
function nothingToInline() {
|
|
91234
|
+
return !shouldProcess(string);
|
|
91235
|
+
}
|
|
91236
|
+
}
|
|
91237
|
+
}
|
|
91238
|
+
|
|
91239
|
+
function newFontFaces() {
|
|
91240
|
+
return {
|
|
91241
|
+
resolveAll: resolveAll,
|
|
91242
|
+
impl: {
|
|
91243
|
+
readAll: readAll
|
|
91244
|
+
}
|
|
91245
|
+
};
|
|
91246
|
+
|
|
91247
|
+
function resolveAll() {
|
|
91248
|
+
return readAll()
|
|
91249
|
+
.then(function (webFonts) {
|
|
91250
|
+
return Promise.all(
|
|
91251
|
+
webFonts.map(function (webFont) {
|
|
91252
|
+
return webFont.resolve();
|
|
91253
|
+
})
|
|
91254
|
+
);
|
|
91255
|
+
})
|
|
91256
|
+
.then(function (cssStrings) {
|
|
91257
|
+
return cssStrings.join('\n');
|
|
91258
|
+
});
|
|
91259
|
+
}
|
|
91260
|
+
|
|
91261
|
+
function readAll() {
|
|
91262
|
+
return Promise.resolve(util.asArray(document.styleSheets))
|
|
91263
|
+
.then(getCssRules)
|
|
91264
|
+
.then(selectWebFontRules)
|
|
91265
|
+
.then(function (rules) {
|
|
91266
|
+
return rules.map(newWebFont);
|
|
91267
|
+
});
|
|
91268
|
+
|
|
91269
|
+
function selectWebFontRules(cssRules) {
|
|
91270
|
+
return cssRules
|
|
91271
|
+
.filter(function (rule) {
|
|
91272
|
+
return rule.type === CSSRule.FONT_FACE_RULE;
|
|
91273
|
+
})
|
|
91274
|
+
.filter(function (rule) {
|
|
91275
|
+
return inliner.shouldProcess(rule.style.getPropertyValue('src'));
|
|
91276
|
+
});
|
|
91277
|
+
}
|
|
91278
|
+
|
|
91279
|
+
function getCssRules(styleSheets) {
|
|
91280
|
+
var cssRules = [];
|
|
91281
|
+
styleSheets.forEach(function (sheet) {
|
|
91282
|
+
try {
|
|
91283
|
+
util.asArray(sheet.cssRules || []).forEach(cssRules.push.bind(cssRules));
|
|
91284
|
+
} catch (e) {
|
|
91285
|
+
console.log('Error while reading CSS rules from ' + sheet.href, e.toString());
|
|
91286
|
+
}
|
|
91287
|
+
});
|
|
91288
|
+
return cssRules;
|
|
91289
|
+
}
|
|
91290
|
+
|
|
91291
|
+
function newWebFont(webFontRule) {
|
|
91292
|
+
return {
|
|
91293
|
+
resolve: function resolve() {
|
|
91294
|
+
var baseUrl = (webFontRule.parentStyleSheet || {}).href;
|
|
91295
|
+
return inliner.inlineAll(webFontRule.cssText, baseUrl);
|
|
91296
|
+
},
|
|
91297
|
+
src: function () {
|
|
91298
|
+
return webFontRule.style.getPropertyValue('src');
|
|
91299
|
+
}
|
|
91300
|
+
};
|
|
91301
|
+
}
|
|
91302
|
+
}
|
|
91303
|
+
}
|
|
91304
|
+
|
|
91305
|
+
function newImages() {
|
|
91306
|
+
return {
|
|
91307
|
+
inlineAll: inlineAll,
|
|
91308
|
+
impl: {
|
|
91309
|
+
newImage: newImage
|
|
91310
|
+
}
|
|
91311
|
+
};
|
|
91312
|
+
|
|
91313
|
+
function newImage(element) {
|
|
91314
|
+
return {
|
|
91315
|
+
inline: inline
|
|
91316
|
+
};
|
|
91317
|
+
|
|
91318
|
+
function inline(get) {
|
|
91319
|
+
if (util.isDataUrl(element.src)) return Promise.resolve();
|
|
91320
|
+
|
|
91321
|
+
return Promise.resolve(element.src)
|
|
91322
|
+
.then(get || util.getAndEncode)
|
|
91323
|
+
.then(function (data) {
|
|
91324
|
+
return util.dataAsUrl(data, util.mimeType(element.src));
|
|
91325
|
+
})
|
|
91326
|
+
.then(function (dataUrl) {
|
|
91327
|
+
return new Promise(function (resolve, reject) {
|
|
91328
|
+
element.onload = resolve;
|
|
91329
|
+
element.onerror = reject;
|
|
91330
|
+
element.src = dataUrl;
|
|
91331
|
+
});
|
|
91332
|
+
});
|
|
91333
|
+
}
|
|
91334
|
+
}
|
|
91335
|
+
|
|
91336
|
+
function inlineAll(node) {
|
|
91337
|
+
if (!(node instanceof Element)) return Promise.resolve(node);
|
|
91338
|
+
|
|
91339
|
+
return inlineBackground(node)
|
|
91340
|
+
.then(function () {
|
|
91341
|
+
if (node instanceof HTMLImageElement)
|
|
91342
|
+
return newImage(node).inline();
|
|
91343
|
+
else
|
|
91344
|
+
return Promise.all(
|
|
91345
|
+
util.asArray(node.childNodes).map(function (child) {
|
|
91346
|
+
return inlineAll(child);
|
|
91347
|
+
})
|
|
91348
|
+
);
|
|
91349
|
+
});
|
|
91350
|
+
|
|
91351
|
+
function inlineBackground(node) {
|
|
91352
|
+
var background = node.style.getPropertyValue('background');
|
|
91353
|
+
|
|
91354
|
+
if (!background) return Promise.resolve(node);
|
|
91355
|
+
|
|
91356
|
+
return inliner.inlineAll(background)
|
|
91357
|
+
.then(function (inlined) {
|
|
91358
|
+
node.style.setProperty(
|
|
91359
|
+
'background',
|
|
91360
|
+
inlined,
|
|
91361
|
+
node.style.getPropertyPriority('background')
|
|
91362
|
+
);
|
|
91363
|
+
})
|
|
91364
|
+
.then(function () {
|
|
91365
|
+
return node;
|
|
91366
|
+
});
|
|
91367
|
+
}
|
|
91368
|
+
}
|
|
91369
|
+
}
|
|
91370
|
+
})();
|
|
91371
|
+
} (domToImage));
|
|
91372
|
+
|
|
91373
|
+
var domToImageExports = domToImage.exports;
|
|
91374
|
+
var domtoimage = /*@__PURE__*/getDefaultExportFromCjs(domToImageExports);
|
|
91375
|
+
|
|
90603
91376
|
function getTemplateHTML(data) {
|
|
90604
91377
|
var _a, _b, _c;
|
|
90605
91378
|
const isProfit = data.data.payout * +data.data.payoutTokenPrice - data.data.dollarValue > 0;
|
package/dist/styles.css
CHANGED
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
border-radius: 10px;
|
|
155
155
|
z-index: 1001;
|
|
156
156
|
width: 100%;
|
|
157
|
-
max-width:
|
|
157
|
+
max-width: 700px;
|
|
158
158
|
min-width: 700px;
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -261,6 +261,7 @@
|
|
|
261
261
|
font-weight: 400;
|
|
262
262
|
font-size: 14px;
|
|
263
263
|
line-height: 21px;
|
|
264
|
+
padding: 10px 0;
|
|
264
265
|
}
|
|
265
266
|
|
|
266
267
|
.modaltable-container.blocks-container {
|
|
@@ -443,7 +444,7 @@
|
|
|
443
444
|
border-radius: 10px;
|
|
444
445
|
border: medium;
|
|
445
446
|
padding-right: 10px;
|
|
446
|
-
width:
|
|
447
|
+
width: 100%;
|
|
447
448
|
height: 50px;
|
|
448
449
|
font-size: 22px;
|
|
449
450
|
}
|
|
@@ -468,6 +469,10 @@
|
|
|
468
469
|
justify-content: space-between;
|
|
469
470
|
}
|
|
470
471
|
|
|
472
|
+
.input-container.bondicon {
|
|
473
|
+
margin-left: 5px;
|
|
474
|
+
}
|
|
475
|
+
|
|
471
476
|
.modaltable-container.button-container {
|
|
472
477
|
width: 100%;
|
|
473
478
|
padding-top: 10px;
|
|
@@ -504,7 +509,7 @@
|
|
|
504
509
|
.modaltable-container.accordion-container {
|
|
505
510
|
display: flex;
|
|
506
511
|
position: absolute;
|
|
507
|
-
padding:
|
|
512
|
+
padding: 30px 50px;
|
|
508
513
|
background: #12131A;
|
|
509
514
|
width: 100%;
|
|
510
515
|
border-radius: 0 0 10px 10px;
|
|
@@ -618,10 +623,9 @@ span.flex-inline {
|
|
|
618
623
|
.token-selector-panel {
|
|
619
624
|
flex-direction: column;
|
|
620
625
|
border-radius: 10px;
|
|
621
|
-
background: var(--theme-ui-colors-
|
|
626
|
+
background: var(--theme-ui-colors-white3);
|
|
622
627
|
padding: 10px;
|
|
623
|
-
|
|
624
|
-
border: 1px solid rgba(129, 126, 126, 0.64);
|
|
628
|
+
min-height: 92px;
|
|
625
629
|
}
|
|
626
630
|
|
|
627
631
|
.bond-row {
|