@simahfud/pine-to-kline 0.1.0 → 0.1.2

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.
@@ -95,7 +95,7 @@
95
95
  * pine-to-kline — KlineChart Adapter
96
96
  * Converts PineRuntime IR → KlineChart IndicatorTemplate
97
97
  * @license Apache-2.0
98
- */class U{toIndicatorTemplate(t){const{meta:e,inputs:s,plots:r,hlines:n,calcFn:l}=t;return{name:e.name.toUpperCase().replace(/[^A-Z0-9_]/g,"_"),shortName:e.shortName??e.name,series:e.overlay?"price":"normal",calcParams:s.map(c=>c.defaultValue),figures:this.mapFigures(r),regenerateFigures:s.length>0?c=>this.mapFigures(r):void 0,calc:(c,o)=>{const u=o.calcParams??s.map(N=>N.defaultValue);return l(c,u)},...n.length>0&&{draw:c=>{const{ctx:o,bounding:u,indicator:N,yAxis:d}=c;if(!o||!d)return!1;for(const A of n){const w=d.convertToPixel(A.price);if(w<u.top||w>u.top+u.height)continue;o.save(),o.strokeStyle=M(A.color),o.lineWidth=A.linewidth??1;const V=Vt(A.linestyle);V.length&&o.setLineDash(V),o.beginPath(),o.moveTo(u.left,w),o.lineTo(u.left+u.width,w),o.stroke(),A.title&&(o.fillStyle=M(A.color),o.font="10px sans-serif",o.textAlign="right",o.fillText(A.title,u.left+u.width-4,w-4)),o.restore()}return!1}},createTooltipDataSource:c=>{const{indicator:o}=c,u=(o==null?void 0:o.result)??[],N=u[u.length-1];return{name:e.name,calcParamsText:s.length>0?`(${((o==null?void 0:o.calcParams)??[]).join(", ")})`:"",values:r.map(d=>({title:`${d.title??d.id}: `,value:(N==null?void 0:N[d.id])??"--"}))}}}}mapFigures(t){return t.map(e=>({key:e.id,title:`${e.title??e.id}: `,type:Gt(e.style),styles:(s,r,n)=>({color:M(e.color)})}))}}/**
98
+ */class U{toIndicatorTemplate(t){const{meta:e,inputs:s,plots:r,hlines:n,calcFn:l}=t;return{name:e.name.toUpperCase().replace(/[^A-Z0-9_]/g,"_"),shortName:e.shortName??e.name,series:e.overlay?"price":"normal",calcParams:s.map(c=>c.defaultValue),extendData:{pineInputs:s.map(c=>c.title||c.id||"Param")},figures:this.mapFigures(r),regenerateFigures:s.length>0?c=>this.mapFigures(r):void 0,calc:(c,o)=>{const u=o.calcParams??s.map(N=>N.defaultValue);return l(c,u)},...n.length>0&&{draw:c=>{const{ctx:o,bounding:u,indicator:N,yAxis:d}=c;if(!o||!d)return!1;for(const A of n){const w=d.convertToPixel(A.price);if(w<u.top||w>u.top+u.height)continue;o.save(),o.strokeStyle=M(A.color),o.lineWidth=A.linewidth??1;const V=Vt(A.linestyle);V.length&&o.setLineDash(V),o.beginPath(),o.moveTo(u.left,w),o.lineTo(u.left+u.width,w),o.stroke(),A.title&&(o.fillStyle=M(A.color),o.font="10px sans-serif",o.textAlign="right",o.fillText(A.title,u.left+u.width-4,w-4)),o.restore()}return!1}},createTooltipDataSource:c=>{const{indicator:o}=c,u=(o==null?void 0:o.result)??[],N=u[u.length-1];return{name:e.name,calcParamsText:s.length>0?`(${((o==null?void 0:o.calcParams)??[]).join(", ")})`:"",values:r.map(d=>({title:`${d.title??d.id}: `,value:(N==null?void 0:N[d.id])??"--"}))}}}}mapFigures(t){return t.map(e=>({key:e.id,title:`${e.title??e.id}: `,type:Gt(e.style),styles:(s,r,n)=>({color:M(e.color)})}))}}/**
99
99
  * pine-to-kline — PineInterpreter
100
100
  * Main entry point class for the library
101
101
  * @license Apache-2.0