svelte-tradingview-widget
Version:
Svelte component for rendering the TradingView Advanced Real-Time Chart Widget.
3 lines (2 loc) • 9.83 kB
JavaScript
var app=function(){"use strict";function t(){}function n(t){return t()}function e(){return Object.create(null)}function o(t){t.forEach(n)}function r(t){return"function"==typeof t}function i(t,n){return t!=t?n==n:t!==n||t&&"object"==typeof t||"function"==typeof t}function a(t,n){t.appendChild(n)}function s(t,n,e){t.insertBefore(n,e||null)}function c(t){t.parentNode.removeChild(t)}function l(t){return document.createElement(t)}function d(){return t=" ",document.createTextNode(t);var t}function u(t,n,e){null==e?t.removeAttribute(n):t.getAttribute(n)!==e&&t.setAttribute(n,e)}let f;function g(t){f=t}const m=[],p=[],h=[],x=[],$=Promise.resolve();let w=!1;function y(t){h.push(t)}let v=!1;const b=new Set;function _(){if(!v){v=!0;do{for(let t=0;t<m.length;t+=1){const n=m[t];g(n),E(n.$$)}for(m.length=0;p.length;)p.pop()();for(let t=0;t<h.length;t+=1){const n=h[t];b.has(n)||(b.add(n),n())}h.length=0}while(m.length);for(;x.length;)x.pop()();w=!1,v=!1,b.clear()}}function E(t){if(null!==t.fragment){t.update(),o(t.before_update);const n=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,n),t.after_update.forEach(y)}}const T=new Set;let k,A;function j(t,n){t&&t.i&&(T.delete(t),t.i(n))}function C(t,n,e,o){if(t&&t.o){if(T.has(t))return;T.add(t),k.c.push(()=>{T.delete(t),o&&(e&&t.d(1),o())}),t.o(n)}}function N(t){t&&t.c()}function B(t,e,i){const{fragment:a,on_mount:s,on_destroy:c,after_update:l}=t.$$;a&&a.m(e,i),y(()=>{const e=s.map(n).filter(r);c?c.push(...e):o(e),t.$$.on_mount=[]}),l.forEach(y)}function S(t,n){const e=t.$$;null!==e.fragment&&(o(e.on_destroy),e.fragment&&e.fragment.d(n),e.on_destroy=e.fragment=null,e.ctx=[])}function O(t,n){-1===t.$$.dirty[0]&&(m.push(t),w||(w=!0,$.then(_)),t.$$.dirty.fill(0)),t.$$.dirty[n/31|0]|=1<<n%31}function D(n,r,i,a,s,l,d=[-1]){const u=f;g(n);const m=r.props||{},p=n.$$={fragment:null,ctx:null,props:l,update:t,not_equal:s,bound:e(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(u?u.$$.context:[]),callbacks:e(),dirty:d};let h=!1;if(p.ctx=i?i(n,m,(t,e,...o)=>{const r=o.length?o[0]:e;return p.ctx&&s(p.ctx[t],p.ctx[t]=r)&&(p.bound[t]&&p.bound[t](r),h&&O(n,t)),e}):[],p.update(),h=!0,o(p.before_update),p.fragment=!!a&&a(p.ctx),r.target){if(r.hydrate){const t=(x=r.target,Array.from(x.childNodes));p.fragment&&p.fragment.l(t),t.forEach(c)}else p.fragment&&p.fragment.c();r.intro&&j(n.$$.fragment),B(n,r.target,r.anchor),_()}var x;g(u)}class V{$destroy(){S(this,1),this.$destroy=t}$on(t,n){const e=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return e.push(n),()=>{const t=e.indexOf(n);-1!==t&&e.splice(t,1)}}$set(){}}function M(){}function H(t){return t()}function I(){return Object.create(null)}function L(t){t.forEach(H)}function P(t){return"function"==typeof t}function q(t,n){return t!=t?n==n:t!==n||t&&"object"==typeof t||"function"==typeof t}function R(t){t.parentNode.removeChild(t)}function U(t,n,e){null==e?t.removeAttribute(n):t.getAttribute(n)!==e&&t.setAttribute(n,e)}function W(t){A=t}function z(t){(function(){if(!A)throw new Error("Function called outside component initialization");return A})().$$.on_mount.push(t)}const F=[],G=[],Y=[],J=[],K=Promise.resolve();let Q=!1;function X(t){Y.push(t)}let Z=!1;const tt=new Set;function nt(){if(!Z){Z=!0;do{for(let t=0;t<F.length;t+=1){const n=F[t];W(n),et(n.$$)}for(F.length=0;G.length;)G.pop()();for(let t=0;t<Y.length;t+=1){const n=Y[t];tt.has(n)||(tt.add(n),n())}Y.length=0}while(F.length);for(;J.length;)J.pop()();Q=!1,Z=!1,tt.clear()}}function et(t){if(null!==t.fragment){t.update(),L(t.before_update);const n=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,n),t.after_update.forEach(X)}}const ot=new Set;function rt(t,n){-1===t.$$.dirty[0]&&(F.push(t),Q||(Q=!0,K.then(nt)),t.$$.dirty.fill(0)),t.$$.dirty[n/31|0]|=1<<n%31}function it(t,n,e,o,r,i,a=[-1]){const s=A;W(t);const c=n.props||{},l=t.$$={fragment:null,ctx:null,props:i,update:M,not_equal:r,bound:I(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(s?s.$$.context:[]),callbacks:I(),dirty:a};let d=!1;if(l.ctx=e?e(t,c,(n,e,...o)=>{const i=o.length?o[0]:e;return l.ctx&&r(l.ctx[n],l.ctx[n]=i)&&(l.bound[n]&&l.bound[n](i),d&&rt(t,n)),e}):[],l.update(),d=!0,L(l.before_update),l.fragment=!!o&&o(l.ctx),n.target){if(n.hydrate){const t=(g=n.target,Array.from(g.childNodes));l.fragment&&l.fragment.l(t),t.forEach(R)}else l.fragment&&l.fragment.c();n.intro&&((u=t.$$.fragment)&&u.i&&(ot.delete(u),u.i(f))),function(t,n,e){const{fragment:o,on_mount:r,on_destroy:i,after_update:a}=t.$$;o&&o.m(n,e),X(()=>{const n=r.map(H).filter(P);i?i.push(...n):L(n),t.$$.on_mount=[]}),a.forEach(X)}(t,n.target,n.anchor),nt()}var u,f,g;W(s)}class at{$destroy(){!function(t,n){const e=t.$$;null!==e.fragment&&(L(e.on_destroy),e.fragment&&e.fragment.d(n),e.on_destroy=e.fragment=null,e.ctx=[])}(this,1),this.$destroy=M}$on(t,n){const e=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return e.push(n),()=>{const t=e.indexOf(n);-1!==t&&e.splice(t,1)}}$set(){}}function st(t){let n;return{c(){var e;e="div",U(n=document.createElement(e),"id",t[0])},m(t,e){!function(t,n,e){t.insertBefore(n,e||null)}(t,n,e)},p(t,[e]){1&e&&U(n,"id",t[0])},i:M,o:M,d(t){t&&R(n)}}}const ct="tradingview-widget-script";function lt(t){if("undefined"==typeof window||!window.document||!window.document.createElement)return void t();if(null!==dt())return"undefined"==typeof TradingView?void function(t){const n=dt(),e=n.onload;n.onload=(()=>{e(),t()})}(t):void t();const n=document.createElement("script");n.id=ct,n.type="text/javascript",n.async=!0,n.src="https://s3.tradingview.com/tv.js",n.onload=t,document.getElementsByTagName("head")[0].appendChild(n)}function dt(){return document.getElementById(ct)}function ut(t,n,e){let{options:o=Object}=n,r="";function i(){"undefined"!=typeof TradingView&&new window.TradingView.widget(Object.assign({container_id:r},o))}return z(()=>{e(0,r=o&&o.container_id?o.container_id:"svelte-tradingview-widget;"),lt(i)}),t.$set=(t=>{"options"in t&&e(1,o=t.options)}),[r,o]}class ft extends at{constructor(t){super(),it(this,t,ut,st,q,{options:1})}}function gt(n){let e,o,r,i,f,g,m,p,h,x,$,w;const y=new ft({props:{options:n[0]}}),v=new ft({props:{options:n[1]}});return{c(){(e=l("div")).innerHTML='<div class="max-w-screen-xl mx-auto py-12 px-4 sm:px-6 lg:py-12 lg:px-8 lg:flex\n lg:items-center lg:justify-between"><h2 class="text-3xl leading-9 font-extrabold tracking-tight text-gray-900\n sm:text-3xl sm:leading-10">\n svelte-tradingview-widget\n <br> \n <span class="font-normal text-gray-500"><a href="https://www.tradingview.com/widget/advanced-chart/" class="text-indigo-600">\n [TradingView Advanced Real-Time Chart Widget]\n </a> \n <br>\n Svelte component for rendering the TradingView Advanced Real-Time Chart\n Widget\n </span> \n <div class="flex mt-4"><img src="https://img.shields.io/npm/v/svelte-tradingview-widget.svg?style=for-the-badge" alt="svelte-tradingview-widget npm"> \n <img src="https://img.shields.io/github/license/mashape/apistatus.svg?style=for-the-badge" alt="svelte-tradingview-widget license" class="ml-1"> \n <img src="https://img.shields.io/npm/dt/svelte-tradingview-widget.svg?style=for-the-badge" alt="svelte-tradingview-widget downloads" class="ml-1"></div></h2> \n <div class="mt-8 flex lg:flex-shrink-0 lg:mt-0"><div class="inline-flex rounded-md shadow"><a href="https://github.com/borakilicoglu/svelte-tradingview-widget" class="inline-flex items-center justify-center px-5 py-1 border\n border-transparent text-base leading-6 font-medium rounded-md\n text-white bg-indigo-600 hover:bg-indigo-500 focus:outline-none\n focus:shadow-outline transition duration-150 ease-in-out">\n Github\n </a></div></div></div>',o=d(),(r=l("div")).innerHTML='<h2 class="text-3xl leading-9 font-normal tracking-tight mb-4 sm:text-3xl\n sm:leading-10">\n Props\n </h2> \n\n <p class="font-normal text-gray-500">\n You can easily create your own properties from\n <a href="https://www.tradingview.com/widget/advanced-chart/" class="font-normal text-indigo-600">\n here\n </a>\n then you can pass them to your component.\n </p>',i=d(),f=l("div"),(g=l("h2")).textContent="Demo Dark",m=d(),N(y.$$.fragment),p=d(),h=l("div"),(x=l("h2")).textContent="Demo Light",$=d(),N(v.$$.fragment),u(e,"class","bg-gray-100 border-b border-gray-200"),u(r,"class","max-w-screen-xl mx-auto py-12 px-4 sm:px-6 lg:py-12 lg:px-8 lg:flex-row\n overflow-x-auto lg:items-center lg:justify-between"),u(g,"class","text-3xl leading-9 font-normal tracking-tight mb-4 sm:text-3xl\n sm:leading-10"),u(f,"class","max-w-screen-xl mx-auto py-12 px-4 sm:px-6 lg:py-12 lg:px-8"),u(x,"class","text-3xl leading-9 font-normal tracking-tight mb-4 sm:text-3xl\n sm:leading-10"),u(h,"class","max-w-screen-xl mx-auto py-12 px-4 sm:px-6 lg:py-12 lg:px-8")},m(t,n){s(t,e,n),s(t,o,n),s(t,r,n),s(t,i,n),s(t,f,n),a(f,g),a(f,m),B(y,f,null),s(t,p,n),s(t,h,n),a(h,x),a(h,$),B(v,h,null),w=!0},p:t,i(t){w||(j(y.$$.fragment,t),j(v.$$.fragment,t),w=!0)},o(t){C(y.$$.fragment,t),C(v.$$.fragment,t),w=!1},d(t){t&&c(e),t&&c(o),t&&c(r),t&&c(i),t&&c(f),S(y),t&&c(p),t&&c(h),S(v)}}}function mt(t){return[{symbol:"BINANCE:BTCUSDT",theme:"dark",height:"500px",width:"100%",locale:"fr",container_id:"options"},{symbol:"BINANCE:ETHUSDT",theme:"light",height:"500px",width:"100%",locale:"en",container_id:"options2"}]}class pt extends V{constructor(t){super(),D(this,t,mt,gt,i,{})}}function ht(n){let e;const o=new pt({});return{c(){N(o.$$.fragment)},m(t,n){B(o,t,n),e=!0},p:t,i(t){e||(j(o.$$.fragment,t),e=!0)},o(t){C(o.$$.fragment,t),e=!1},d(t){S(o,t)}}}return new class extends V{constructor(t){super(),D(this,t,null,ht,i,{})}}({target:document.body})}();
//# sourceMappingURL=bundle.js.map