oakscriptjs 0.8.2 → 0.9.1
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/LICENSE +1 -1
- package/README.md +31 -9
- package/dist/cjs/array/index.d.ts +701 -0
- package/dist/cjs/array/index.d.ts.map +1 -0
- package/dist/cjs/array/index.js +393 -0
- package/dist/cjs/array/index.js.map +7 -0
- package/dist/cjs/box/index.d.ts +444 -0
- package/dist/cjs/box/index.d.ts.map +1 -0
- package/dist/cjs/box/index.js +246 -0
- package/dist/cjs/box/index.js.map +7 -0
- package/dist/cjs/callsite/index.d.ts +88 -0
- package/dist/cjs/callsite/index.d.ts.map +1 -0
- package/dist/cjs/callsite/index.js +112 -0
- package/dist/cjs/callsite/index.js.map +7 -0
- package/dist/cjs/chartpoint/index.d.ts +90 -0
- package/dist/cjs/chartpoint/index.d.ts.map +1 -0
- package/dist/cjs/chartpoint/index.js +56 -0
- package/dist/cjs/chartpoint/index.js.map +7 -0
- package/dist/cjs/color/index.d.ts +286 -0
- package/dist/cjs/color/index.d.ts.map +1 -0
- package/dist/cjs/color/index.js +122 -0
- package/dist/cjs/color/index.js.map +7 -0
- package/dist/cjs/color/parse.d.ts +29 -0
- package/dist/cjs/color/parse.d.ts.map +1 -0
- package/dist/cjs/color/parse.js +57 -0
- package/dist/cjs/color/parse.js.map +7 -0
- package/dist/cjs/compare/index.d.ts +26 -0
- package/dist/cjs/compare/index.d.ts.map +1 -0
- package/dist/cjs/compare/index.js +50 -0
- package/dist/cjs/compare/index.js.map +7 -0
- package/dist/cjs/drawing/registry.d.ts +42 -0
- package/dist/cjs/drawing/registry.d.ts.map +1 -0
- package/dist/cjs/drawing/registry.js +87 -0
- package/dist/cjs/drawing/registry.js.map +7 -0
- package/dist/cjs/index.d.ts +85 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +184 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/indicator.d.ts +117 -0
- package/dist/cjs/indicator.d.ts.map +1 -0
- package/dist/cjs/indicator.js +74 -0
- package/dist/cjs/indicator.js.map +7 -0
- package/dist/cjs/input.d.ts +196 -0
- package/dist/cjs/input.d.ts.map +1 -0
- package/dist/cjs/input.js +197 -0
- package/dist/cjs/input.js.map +7 -0
- package/dist/cjs/label/index.d.ts +303 -0
- package/dist/cjs/label/index.d.ts.map +1 -0
- package/dist/cjs/label/index.js +190 -0
- package/dist/cjs/label/index.js.map +7 -0
- package/dist/cjs/lib/index.d.ts +8 -0
- package/dist/cjs/lib/index.d.ts.map +1 -0
- package/dist/cjs/lib/index.js +19 -0
- package/dist/cjs/lib/index.js.map +7 -0
- package/dist/{lib → cjs/lib}/zigzag/index.d.ts +4 -1
- package/dist/cjs/lib/zigzag/index.d.ts.map +1 -0
- package/dist/cjs/lib/zigzag/index.js +27 -0
- package/dist/cjs/lib/zigzag/index.js.map +7 -0
- package/dist/cjs/lib/zigzag/zigzag.d.ts +100 -0
- package/dist/cjs/lib/zigzag/zigzag.d.ts.map +1 -0
- package/dist/cjs/lib/zigzag/zigzag.js +207 -0
- package/dist/cjs/lib/zigzag/zigzag.js.map +7 -0
- package/dist/cjs/line/index.d.ts +342 -0
- package/dist/cjs/line/index.d.ts.map +1 -0
- package/dist/cjs/line/index.js +193 -0
- package/dist/cjs/line/index.js.map +7 -0
- package/dist/cjs/linefill/index.d.ts +124 -0
- package/dist/cjs/linefill/index.d.ts.map +1 -0
- package/dist/cjs/linefill/index.js +56 -0
- package/dist/cjs/linefill/index.js.map +7 -0
- package/dist/cjs/map/index.d.ts +69 -0
- package/dist/cjs/map/index.d.ts.map +1 -0
- package/dist/cjs/map/index.js +80 -0
- package/dist/cjs/map/index.js.map +7 -0
- package/dist/cjs/math/index.d.ts +560 -0
- package/dist/cjs/math/index.d.ts.map +1 -0
- package/dist/cjs/math/index.js +441 -0
- package/dist/cjs/math/index.js.map +7 -0
- package/dist/cjs/matrix/index.d.ts +1231 -0
- package/dist/cjs/matrix/index.d.ts.map +1 -0
- package/dist/cjs/matrix/index.js +1200 -0
- package/dist/cjs/matrix/index.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plot.d.ts +76 -0
- package/dist/cjs/plot.d.ts.map +1 -0
- package/dist/cjs/plot.js +51 -0
- package/dist/cjs/plot.js.map +7 -0
- package/dist/cjs/polyline/index.d.ts +115 -0
- package/dist/cjs/polyline/index.d.ts.map +1 -0
- package/dist/cjs/polyline/index.js +76 -0
- package/dist/cjs/polyline/index.js.map +7 -0
- package/dist/cjs/runtime/adapters/LightweightChartsAdapter.d.ts +86 -0
- package/dist/cjs/runtime/adapters/LightweightChartsAdapter.d.ts.map +1 -0
- package/dist/cjs/runtime/adapters/LightweightChartsAdapter.js +141 -0
- package/dist/cjs/runtime/adapters/LightweightChartsAdapter.js.map +7 -0
- package/dist/cjs/runtime/adapters/SimpleInputAdapter.d.ts +59 -0
- package/dist/cjs/runtime/adapters/SimpleInputAdapter.d.ts.map +1 -0
- package/dist/cjs/runtime/adapters/SimpleInputAdapter.js +117 -0
- package/dist/cjs/runtime/adapters/SimpleInputAdapter.js.map +7 -0
- package/dist/{runtime → cjs/runtime}/index.d.ts +12 -5
- package/dist/cjs/runtime/index.d.ts.map +1 -0
- package/dist/cjs/runtime/index.js +49 -0
- package/dist/cjs/runtime/index.js.map +7 -0
- package/dist/cjs/runtime/inputs.d.ts +91 -0
- package/dist/cjs/runtime/inputs.d.ts.map +1 -0
- package/dist/cjs/runtime/inputs.js +262 -0
- package/dist/cjs/runtime/inputs.js.map +7 -0
- package/dist/cjs/runtime/runtime.d.ts +70 -0
- package/dist/cjs/runtime/runtime.d.ts.map +1 -0
- package/dist/cjs/runtime/runtime.js +148 -0
- package/dist/cjs/runtime/runtime.js.map +7 -0
- package/dist/cjs/runtime/series.d.ts +362 -0
- package/dist/cjs/runtime/series.d.ts.map +1 -0
- package/dist/cjs/runtime/series.js +560 -0
- package/dist/cjs/runtime/series.js.map +7 -0
- package/dist/cjs/runtime/types.d.ts +282 -0
- package/dist/cjs/runtime/types.d.ts.map +1 -0
- package/dist/cjs/runtime/types.js +17 -0
- package/dist/cjs/runtime/types.js.map +7 -0
- package/dist/cjs/script/index.d.ts +991 -0
- package/dist/cjs/script/index.d.ts.map +1 -0
- package/dist/cjs/script/index.js +1174 -0
- package/dist/cjs/script/index.js.map +7 -0
- package/dist/cjs/security/resample.d.ts +63 -0
- package/dist/cjs/security/resample.d.ts.map +1 -0
- package/dist/cjs/security/resample.js +84 -0
- package/dist/cjs/security/resample.js.map +7 -0
- package/dist/cjs/session/bars.d.ts +80 -0
- package/dist/cjs/session/bars.d.ts.map +1 -0
- package/dist/cjs/session/bars.js +219 -0
- package/dist/cjs/session/bars.js.map +7 -0
- package/dist/cjs/session/calendar.d.ts +70 -0
- package/dist/cjs/session/calendar.d.ts.map +1 -0
- package/dist/cjs/session/calendar.js +164 -0
- package/dist/cjs/session/calendar.js.map +7 -0
- package/dist/cjs/str/dateformat.d.ts +15 -0
- package/dist/cjs/str/dateformat.d.ts.map +1 -0
- package/dist/cjs/str/dateformat.js +149 -0
- package/dist/cjs/str/dateformat.js.map +7 -0
- package/dist/cjs/str/index.d.ts +459 -0
- package/dist/cjs/str/index.d.ts.map +1 -0
- package/dist/cjs/str/index.js +143 -0
- package/dist/cjs/str/index.js.map +7 -0
- package/dist/cjs/str/messageformat.d.ts +14 -0
- package/dist/cjs/str/messageformat.d.ts.map +1 -0
- package/dist/cjs/str/messageformat.js +114 -0
- package/dist/cjs/str/messageformat.js.map +7 -0
- package/dist/cjs/str/numberformat.d.ts +19 -0
- package/dist/cjs/str/numberformat.d.ts.map +1 -0
- package/dist/cjs/str/numberformat.js +170 -0
- package/dist/cjs/str/numberformat.js.map +7 -0
- package/dist/{strategy → cjs/strategy}/index.d.ts +50 -0
- package/dist/cjs/strategy/index.d.ts.map +1 -0
- package/dist/cjs/strategy/index.js +92 -0
- package/dist/cjs/strategy/index.js.map +7 -0
- package/dist/cjs/ta/index.d.ts +1400 -0
- package/dist/cjs/ta/index.d.ts.map +1 -0
- package/dist/cjs/ta/index.js +1719 -0
- package/dist/cjs/ta/index.js.map +7 -0
- package/dist/cjs/ta/running-sum.d.ts +30 -0
- package/dist/cjs/ta/running-sum.d.ts.map +1 -0
- package/dist/cjs/ta/running-sum.js +99 -0
- package/dist/cjs/ta/running-sum.js.map +7 -0
- package/dist/cjs/ta-series.d.ts +558 -0
- package/dist/cjs/ta-series.d.ts.map +1 -0
- package/dist/cjs/ta-series.js +606 -0
- package/dist/cjs/ta-series.js.map +7 -0
- package/dist/cjs/text/index.d.ts +14 -0
- package/dist/cjs/text/index.d.ts.map +1 -0
- package/dist/cjs/text/index.js +29 -0
- package/dist/cjs/text/index.js.map +7 -0
- package/dist/cjs/time/datestring.d.ts +23 -0
- package/dist/cjs/time/datestring.d.ts.map +1 -0
- package/dist/cjs/time/datestring.js +106 -0
- package/dist/cjs/time/datestring.js.map +7 -0
- package/dist/cjs/time/index.d.ts +89 -0
- package/dist/cjs/time/index.d.ts.map +1 -0
- package/dist/cjs/time/index.js +85 -0
- package/dist/cjs/time/index.js.map +7 -0
- package/dist/cjs/time/session.d.ts +17 -0
- package/dist/cjs/time/session.d.ts.map +1 -0
- package/dist/cjs/time/session.js +65 -0
- package/dist/cjs/time/session.js.map +7 -0
- package/dist/cjs/time/timezone.d.ts +40 -0
- package/dist/cjs/time/timezone.d.ts.map +1 -0
- package/dist/cjs/time/timezone.js +125 -0
- package/dist/cjs/time/timezone.js.map +7 -0
- package/dist/cjs/timeframe/index.d.ts +73 -0
- package/dist/cjs/timeframe/index.d.ts.map +1 -0
- package/dist/cjs/timeframe/index.js +85 -0
- package/dist/cjs/timeframe/index.js.map +7 -0
- package/dist/cjs/types/index.d.ts +343 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/index.js +32 -0
- package/dist/cjs/types/index.js.map +7 -0
- package/dist/cjs/types/metadata.d.ts +300 -0
- package/dist/cjs/types/metadata.d.ts.map +1 -0
- package/dist/cjs/types/metadata.js +17 -0
- package/dist/cjs/types/metadata.js.map +7 -0
- package/dist/cjs/utils/index.d.ts +167 -0
- package/dist/cjs/utils/index.d.ts.map +1 -0
- package/dist/cjs/utils/index.js +209 -0
- package/dist/cjs/utils/index.js.map +7 -0
- package/dist/esm/array/index.d.ts +701 -0
- package/dist/esm/array/index.d.ts.map +1 -0
- package/dist/esm/array/index.js +984 -0
- package/dist/esm/array/index.js.map +1 -0
- package/dist/esm/box/index.d.ts +444 -0
- package/dist/esm/box/index.d.ts.map +1 -0
- package/dist/esm/box/index.js +602 -0
- package/dist/esm/box/index.js.map +1 -0
- package/dist/esm/callsite/index.d.ts +88 -0
- package/dist/esm/callsite/index.d.ts.map +1 -0
- package/dist/esm/callsite/index.js +176 -0
- package/dist/esm/callsite/index.js.map +1 -0
- package/dist/esm/chartpoint/index.d.ts +90 -0
- package/dist/esm/chartpoint/index.d.ts.map +1 -0
- package/dist/esm/chartpoint/index.js +113 -0
- package/dist/esm/chartpoint/index.js.map +1 -0
- package/dist/esm/color/index.d.ts +286 -0
- package/dist/esm/color/index.d.ts.map +1 -0
- package/dist/esm/color/index.js +350 -0
- package/dist/esm/color/index.js.map +1 -0
- package/dist/esm/color/parse.d.ts +29 -0
- package/dist/esm/color/parse.d.ts.map +1 -0
- package/dist/esm/color/parse.js +55 -0
- package/dist/esm/color/parse.js.map +1 -0
- package/dist/esm/compare/index.d.ts +26 -0
- package/dist/esm/compare/index.d.ts.map +1 -0
- package/dist/esm/compare/index.js +39 -0
- package/dist/esm/compare/index.js.map +1 -0
- package/dist/esm/drawing/registry.d.ts +42 -0
- package/dist/esm/drawing/registry.d.ts.map +1 -0
- package/dist/esm/drawing/registry.js +89 -0
- package/dist/esm/drawing/registry.js.map +1 -0
- package/dist/esm/index.d.ts +85 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +96 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/indicator.d.ts +117 -0
- package/dist/esm/indicator.d.ts.map +1 -0
- package/dist/esm/indicator.js +84 -0
- package/dist/esm/indicator.js.map +1 -0
- package/dist/esm/input.d.ts +196 -0
- package/dist/esm/input.d.ts.map +1 -0
- package/dist/esm/input.js +183 -0
- package/dist/esm/input.js.map +1 -0
- package/dist/esm/label/index.d.ts +303 -0
- package/dist/esm/label/index.d.ts.map +1 -0
- package/dist/esm/label/index.js +417 -0
- package/dist/esm/label/index.js.map +1 -0
- package/dist/esm/lib/index.d.ts +8 -0
- package/dist/esm/lib/index.d.ts.map +1 -0
- package/dist/esm/lib/index.js +8 -0
- package/dist/esm/lib/index.js.map +1 -0
- package/dist/esm/lib/zigzag/index.d.ts +5 -0
- package/dist/esm/lib/zigzag/index.d.ts.map +1 -0
- package/dist/esm/lib/zigzag/index.js +5 -0
- package/dist/esm/lib/zigzag/index.js.map +1 -0
- package/dist/esm/lib/zigzag/zigzag.d.ts +100 -0
- package/dist/esm/lib/zigzag/zigzag.d.ts.map +1 -0
- package/dist/esm/lib/zigzag/zigzag.js +229 -0
- package/dist/esm/lib/zigzag/zigzag.js.map +1 -0
- package/dist/esm/line/index.d.ts +342 -0
- package/dist/esm/line/index.d.ts.map +1 -0
- package/dist/esm/line/index.js +470 -0
- package/dist/esm/line/index.js.map +1 -0
- package/dist/esm/linefill/index.d.ts +124 -0
- package/dist/esm/linefill/index.d.ts.map +1 -0
- package/dist/esm/linefill/index.js +144 -0
- package/dist/esm/linefill/index.js.map +1 -0
- package/dist/esm/map/index.d.ts +69 -0
- package/dist/esm/map/index.d.ts.map +1 -0
- package/dist/esm/map/index.js +106 -0
- package/dist/esm/map/index.js.map +1 -0
- package/dist/esm/math/index.d.ts +560 -0
- package/dist/esm/math/index.d.ts.map +1 -0
- package/dist/esm/math/index.js +495 -0
- package/dist/esm/math/index.js.map +1 -0
- package/dist/esm/matrix/index.d.ts +1231 -0
- package/dist/esm/matrix/index.d.ts.map +1 -0
- package/dist/esm/matrix/index.js +2450 -0
- package/dist/esm/matrix/index.js.map +1 -0
- package/dist/esm/plot.d.ts +76 -0
- package/dist/esm/plot.d.ts.map +1 -0
- package/dist/esm/plot.js +63 -0
- package/dist/esm/plot.js.map +1 -0
- package/dist/esm/polyline/index.d.ts +115 -0
- package/dist/esm/polyline/index.d.ts.map +1 -0
- package/dist/esm/polyline/index.js +157 -0
- package/dist/esm/polyline/index.js.map +1 -0
- package/dist/esm/runtime/adapters/LightweightChartsAdapter.d.ts +86 -0
- package/dist/esm/runtime/adapters/LightweightChartsAdapter.d.ts.map +1 -0
- package/dist/esm/runtime/adapters/LightweightChartsAdapter.js +140 -0
- package/dist/esm/runtime/adapters/LightweightChartsAdapter.js.map +1 -0
- package/dist/esm/runtime/adapters/SimpleInputAdapter.d.ts +59 -0
- package/dist/esm/runtime/adapters/SimpleInputAdapter.d.ts.map +1 -0
- package/dist/esm/runtime/adapters/SimpleInputAdapter.js +115 -0
- package/dist/esm/runtime/adapters/SimpleInputAdapter.js.map +1 -0
- package/dist/esm/runtime/index.d.ts +13 -0
- package/dist/esm/runtime/index.d.ts.map +1 -0
- package/dist/esm/runtime/index.js +14 -0
- package/dist/esm/runtime/index.js.map +1 -0
- package/dist/esm/runtime/inputs.d.ts +91 -0
- package/dist/esm/runtime/inputs.d.ts.map +1 -0
- package/dist/esm/runtime/inputs.js +334 -0
- package/dist/esm/runtime/inputs.js.map +1 -0
- package/dist/esm/runtime/runtime.d.ts +70 -0
- package/dist/esm/runtime/runtime.d.ts.map +1 -0
- package/dist/esm/runtime/runtime.js +193 -0
- package/dist/esm/runtime/runtime.js.map +1 -0
- package/dist/esm/runtime/series.d.ts +362 -0
- package/dist/esm/runtime/series.d.ts.map +1 -0
- package/dist/esm/runtime/series.js +583 -0
- package/dist/esm/runtime/series.js.map +1 -0
- package/dist/esm/runtime/types.d.ts +282 -0
- package/dist/esm/runtime/types.d.ts.map +1 -0
- package/dist/esm/runtime/types.js +7 -0
- package/dist/esm/runtime/types.js.map +1 -0
- package/dist/esm/script/index.d.ts +991 -0
- package/dist/esm/script/index.d.ts.map +1 -0
- package/dist/esm/script/index.js +1294 -0
- package/dist/esm/script/index.js.map +1 -0
- package/dist/esm/security/resample.d.ts +63 -0
- package/dist/esm/security/resample.d.ts.map +1 -0
- package/dist/esm/security/resample.js +110 -0
- package/dist/esm/security/resample.js.map +1 -0
- package/dist/esm/session/bars.d.ts +80 -0
- package/dist/esm/session/bars.d.ts.map +1 -0
- package/dist/esm/session/bars.js +232 -0
- package/dist/esm/session/bars.js.map +1 -0
- package/dist/esm/session/calendar.d.ts +70 -0
- package/dist/esm/session/calendar.d.ts.map +1 -0
- package/dist/esm/session/calendar.js +172 -0
- package/dist/esm/session/calendar.js.map +1 -0
- package/dist/esm/str/dateformat.d.ts +15 -0
- package/dist/esm/str/dateformat.d.ts.map +1 -0
- package/dist/esm/str/dateformat.js +136 -0
- package/dist/esm/str/dateformat.js.map +1 -0
- package/dist/esm/str/index.d.ts +459 -0
- package/dist/esm/str/index.d.ts.map +1 -0
- package/dist/esm/str/index.js +540 -0
- package/dist/esm/str/index.js.map +1 -0
- package/dist/esm/str/messageformat.d.ts +14 -0
- package/dist/esm/str/messageformat.d.ts.map +1 -0
- package/dist/esm/str/messageformat.js +111 -0
- package/dist/esm/str/messageformat.js.map +1 -0
- package/dist/esm/str/numberformat.d.ts +19 -0
- package/dist/esm/str/numberformat.d.ts.map +1 -0
- package/dist/esm/str/numberformat.js +189 -0
- package/dist/esm/str/numberformat.js.map +1 -0
- package/dist/esm/strategy/index.d.ts +245 -0
- package/dist/esm/strategy/index.d.ts.map +1 -0
- package/dist/esm/strategy/index.js +84 -0
- package/dist/esm/strategy/index.js.map +1 -0
- package/dist/esm/ta/index.d.ts +1400 -0
- package/dist/esm/ta/index.d.ts.map +1 -0
- package/dist/esm/ta/index.js +3236 -0
- package/dist/esm/ta/index.js.map +1 -0
- package/dist/esm/ta/running-sum.d.ts +30 -0
- package/dist/esm/ta/running-sum.d.ts.map +1 -0
- package/dist/esm/ta/running-sum.js +113 -0
- package/dist/esm/ta/running-sum.js.map +1 -0
- package/dist/esm/ta-series.d.ts +558 -0
- package/dist/esm/ta-series.d.ts.map +1 -0
- package/dist/esm/ta-series.js +910 -0
- package/dist/esm/ta-series.js.map +1 -0
- package/dist/esm/text/index.d.ts +14 -0
- package/dist/esm/text/index.d.ts.map +1 -0
- package/dist/esm/text/index.js +14 -0
- package/dist/esm/text/index.js.map +1 -0
- package/dist/esm/time/datestring.d.ts +23 -0
- package/dist/esm/time/datestring.d.ts.map +1 -0
- package/dist/esm/time/datestring.js +94 -0
- package/dist/esm/time/datestring.js.map +1 -0
- package/dist/esm/time/index.d.ts +89 -0
- package/dist/esm/time/index.d.ts.map +1 -0
- package/dist/esm/time/index.js +108 -0
- package/dist/esm/time/index.js.map +1 -0
- package/dist/esm/time/session.d.ts +17 -0
- package/dist/esm/time/session.d.ts.map +1 -0
- package/dist/esm/time/session.js +69 -0
- package/dist/esm/time/session.js.map +1 -0
- package/dist/esm/time/timezone.d.ts +40 -0
- package/dist/esm/time/timezone.d.ts.map +1 -0
- package/dist/esm/time/timezone.js +144 -0
- package/dist/esm/time/timezone.js.map +1 -0
- package/dist/esm/timeframe/index.d.ts +73 -0
- package/dist/esm/timeframe/index.d.ts.map +1 -0
- package/dist/esm/timeframe/index.js +131 -0
- package/dist/esm/timeframe/index.js.map +1 -0
- package/dist/esm/types/index.d.ts +343 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +17 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/metadata.d.ts +300 -0
- package/dist/esm/types/metadata.d.ts.map +1 -0
- package/dist/esm/types/metadata.js +7 -0
- package/dist/esm/types/metadata.js.map +1 -0
- package/dist/esm/utils/index.d.ts +167 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +295 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/package.json +53 -23
- package/src/array/index.ts +1057 -0
- package/src/box/index.ts +680 -0
- package/src/callsite/index.ts +178 -0
- package/src/chartpoint/index.ts +126 -0
- package/src/color/index.ts +389 -0
- package/src/color/parse.ts +56 -0
- package/src/compare/index.ts +46 -0
- package/src/drawing/registry.ts +106 -0
- package/src/index.ts +201 -0
- package/src/indicator.ts +185 -0
- package/src/input.ts +280 -0
- package/src/label/index.ts +490 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/zigzag/index.ts +13 -0
- package/src/lib/zigzag/zigzag.ts +318 -0
- package/src/line/index.ts +530 -0
- package/src/linefill/index.ts +152 -0
- package/src/map/index.ts +115 -0
- package/src/math/index.ts +1071 -0
- package/src/matrix/index.ts +2697 -0
- package/src/plot.ts +121 -0
- package/src/polyline/index.ts +184 -0
- package/src/runtime/adapters/LightweightChartsAdapter.ts +201 -0
- package/src/runtime/adapters/SimpleInputAdapter.ts +132 -0
- package/src/runtime/index.ts +52 -0
- package/src/runtime/inputs.ts +377 -0
- package/src/runtime/runtime.ts +241 -0
- package/src/runtime/series.ts +644 -0
- package/src/runtime/types.ts +292 -0
- package/src/script/index.ts +1870 -0
- package/src/security/resample.ts +119 -0
- package/src/session/bars.ts +262 -0
- package/src/session/calendar.ts +199 -0
- package/src/str/dateformat.ts +104 -0
- package/src/str/index.ts +557 -0
- package/src/str/messageformat.ts +109 -0
- package/src/str/numberformat.ts +197 -0
- package/src/strategy/index.ts +281 -0
- package/src/ta/index.ts +3587 -0
- package/src/ta/running-sum.ts +117 -0
- package/src/ta-series.ts +1036 -0
- package/src/text/index.ts +14 -0
- package/src/time/datestring.ts +96 -0
- package/src/time/index.ts +161 -0
- package/src/time/session.ts +79 -0
- package/src/time/timezone.ts +180 -0
- package/src/timeframe/index.ts +144 -0
- package/src/types/index.ts +398 -0
- package/src/types/metadata.ts +334 -0
- package/src/utils/index.ts +334 -0
- package/dist/array/index.d.ts +0 -57
- package/dist/array/index.d.ts.map +0 -1
- package/dist/box/index.d.ts +0 -37
- package/dist/box/index.d.ts.map +0 -1
- package/dist/callsite/index.d.ts +0 -7
- package/dist/callsite/index.d.ts.map +0 -1
- package/dist/chartpoint/index.d.ts +0 -8
- package/dist/chartpoint/index.d.ts.map +0 -1
- package/dist/color/index.d.ts +0 -28
- package/dist/color/index.d.ts.map +0 -1
- package/dist/compare/index.d.ts +0 -8
- package/dist/compare/index.d.ts.map +0 -1
- package/dist/drawing/registry.d.ts +0 -19
- package/dist/drawing/registry.d.ts.map +0 -1
- package/dist/index.cjs +0 -7981
- package/dist/index.d.ts +0 -64
- package/dist/index.d.ts.map +0 -1
- package/dist/index.mjs +0 -7964
- package/dist/indicator.d.ts +0 -42
- package/dist/indicator.d.ts.map +0 -1
- package/dist/input.d.ts +0 -47
- package/dist/input.d.ts.map +0 -1
- package/dist/label/index.d.ts +0 -30
- package/dist/label/index.d.ts.map +0 -1
- package/dist/lib/index.d.ts +0 -2
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/zigzag/index.d.ts.map +0 -1
- package/dist/lib/zigzag/zigzag.d.ts +0 -47
- package/dist/lib/zigzag/zigzag.d.ts.map +0 -1
- package/dist/line/index.d.ts +0 -30
- package/dist/line/index.d.ts.map +0 -1
- package/dist/linefill/index.d.ts +0 -10
- package/dist/linefill/index.d.ts.map +0 -1
- package/dist/map/index.d.ts +0 -14
- package/dist/map/index.d.ts.map +0 -1
- package/dist/math/index.d.ts +0 -53
- package/dist/math/index.d.ts.map +0 -1
- package/dist/matrix/index.d.ts +0 -52
- package/dist/matrix/index.d.ts.map +0 -1
- package/dist/plot.d.ts +0 -20
- package/dist/plot.d.ts.map +0 -1
- package/dist/polyline/index.d.ts +0 -11
- package/dist/polyline/index.d.ts.map +0 -1
- package/dist/runtime/adapters/LightweightChartsAdapter.d.ts +0 -15
- package/dist/runtime/adapters/LightweightChartsAdapter.d.ts.map +0 -1
- package/dist/runtime/adapters/SimpleInputAdapter.d.ts +0 -16
- package/dist/runtime/adapters/SimpleInputAdapter.d.ts.map +0 -1
- package/dist/runtime/index.cjs +0 -600
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.mjs +0 -577
- package/dist/runtime/inputs.d.ts +0 -13
- package/dist/runtime/inputs.d.ts.map +0 -1
- package/dist/runtime/runtime.d.ts +0 -16
- package/dist/runtime/runtime.d.ts.map +0 -1
- package/dist/runtime/series.d.ts +0 -60
- package/dist/runtime/series.d.ts.map +0 -1
- package/dist/runtime/types.d.ts +0 -126
- package/dist/runtime/types.d.ts.map +0 -1
- package/dist/script/index.cjs +0 -6377
- package/dist/script/index.d.ts +0 -713
- package/dist/script/index.d.ts.map +0 -1
- package/dist/script/index.mjs +0 -6360
- package/dist/security/resample.d.ts +0 -13
- package/dist/security/resample.d.ts.map +0 -1
- package/dist/session/bars.d.ts +0 -34
- package/dist/session/bars.d.ts.map +0 -1
- package/dist/session/calendar.d.ts +0 -31
- package/dist/session/calendar.d.ts.map +0 -1
- package/dist/str/dateformat.d.ts +0 -2
- package/dist/str/dateformat.d.ts.map +0 -1
- package/dist/str/index.d.ts +0 -24
- package/dist/str/index.d.ts.map +0 -1
- package/dist/str/messageformat.d.ts +0 -2
- package/dist/str/messageformat.d.ts.map +0 -1
- package/dist/str/numberformat.d.ts +0 -3
- package/dist/str/numberformat.d.ts.map +0 -1
- package/dist/strategy/index.d.ts.map +0 -1
- package/dist/ta/index.d.ts +0 -72
- package/dist/ta/index.d.ts.map +0 -1
- package/dist/ta/running-sum.d.ts +0 -3
- package/dist/ta/running-sum.d.ts.map +0 -1
- package/dist/ta-series.d.ts +0 -143
- package/dist/ta-series.d.ts.map +0 -1
- package/dist/text/index.d.ts +0 -4
- package/dist/text/index.d.ts.map +0 -1
- package/dist/time/datestring.d.ts +0 -2
- package/dist/time/datestring.d.ts.map +0 -1
- package/dist/time/index.d.ts +0 -15
- package/dist/time/index.d.ts.map +0 -1
- package/dist/time/session.d.ts +0 -2
- package/dist/time/session.d.ts.map +0 -1
- package/dist/time/timezone.d.ts +0 -13
- package/dist/time/timezone.d.ts.map +0 -1
- package/dist/timeframe/index.d.ts +0 -17
- package/dist/timeframe/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -181
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/metadata.d.ts +0 -132
- package/dist/types/metadata.d.ts.map +0 -1
- package/dist/utils/index.d.ts +0 -26
- package/dist/utils/index.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/line/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEjE,KAAK,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;AACzC,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AACrD,KAAK,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,CAAC;AAE7F;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CACtB,WAAW,EAAE,UAAU,EACvB,YAAY,EAAE,UAAU,EACxB,IAAI,CAAC,EAAE,QAAQ,EACf,MAAM,CAAC,EAAE,UAAU,EACnB,SAAS,CAAC,EAAE,KAAK,EACjB,KAAK,CAAC,EAAE,SAAS,EACjB,KAAK,CAAC,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,OAAO,GACtB,IAAI,CAAC;AACR,wBAAgB,QAAQ,CACtB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE,QAAQ,EACf,MAAM,CAAC,EAAE,UAAU,EACnB,SAAS,CAAC,EAAE,KAAK,EACjB,KAAK,CAAC,EAAE,SAAS,EACjB,KAAK,CAAC,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,OAAO,GACtB,IAAI,CAAC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AAC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all2) => {
|
|
7
|
+
for (var name in all2)
|
|
8
|
+
__defProp(target, name, { get: all2[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var line_exports = {};
|
|
20
|
+
__export(line_exports, {
|
|
21
|
+
all: () => all,
|
|
22
|
+
copy: () => copy,
|
|
23
|
+
delete: () => delete_line,
|
|
24
|
+
delete_line: () => delete_line,
|
|
25
|
+
get_price: () => get_price,
|
|
26
|
+
get_x1: () => get_x1,
|
|
27
|
+
get_x2: () => get_x2,
|
|
28
|
+
get_y1: () => get_y1,
|
|
29
|
+
get_y2: () => get_y2,
|
|
30
|
+
new: () => new_line,
|
|
31
|
+
new_line: () => new_line,
|
|
32
|
+
set_color: () => set_color,
|
|
33
|
+
set_extend: () => set_extend,
|
|
34
|
+
set_first_point: () => set_first_point,
|
|
35
|
+
set_second_point: () => set_second_point,
|
|
36
|
+
set_style: () => set_style,
|
|
37
|
+
set_width: () => set_width,
|
|
38
|
+
set_x1: () => set_x1,
|
|
39
|
+
set_x2: () => set_x2,
|
|
40
|
+
set_xloc: () => set_xloc,
|
|
41
|
+
set_xy1: () => set_xy1,
|
|
42
|
+
set_xy2: () => set_xy2,
|
|
43
|
+
set_y1: () => set_y1,
|
|
44
|
+
set_y2: () => set_y2
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(line_exports);
|
|
47
|
+
var import_registry = require("../drawing/registry.js");
|
|
48
|
+
function new_line(...args) {
|
|
49
|
+
let x1, y1, x2, y2, rest;
|
|
50
|
+
if (typeof args[0] === "object" && args[0] !== null) {
|
|
51
|
+
const [p1, p2, ...others] = args;
|
|
52
|
+
const xloc2 = others[0] ?? "bar_index";
|
|
53
|
+
[x1, y1, x2, y2, rest] = [pointX(p1, xloc2), p1.price, pointX(p2, xloc2), p2.price, others];
|
|
54
|
+
} else {
|
|
55
|
+
[x1, y1, x2, y2] = args;
|
|
56
|
+
rest = args.slice(4);
|
|
57
|
+
}
|
|
58
|
+
const [xloc, extend, lineColor, style, width, force_overlay] = rest;
|
|
59
|
+
return (0, import_registry.register)("line", {
|
|
60
|
+
x1,
|
|
61
|
+
y1,
|
|
62
|
+
x2,
|
|
63
|
+
y2,
|
|
64
|
+
xloc: xloc ?? "bar_index",
|
|
65
|
+
extend: extend ?? "none",
|
|
66
|
+
color: lineColor,
|
|
67
|
+
style: style || "solid",
|
|
68
|
+
width: width || 1,
|
|
69
|
+
force_overlay: force_overlay ?? false
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function get_price(id, x) {
|
|
73
|
+
const { x1, y1, x2, y2, extend, xloc } = id;
|
|
74
|
+
if (xloc === "bar_time") {
|
|
75
|
+
throw new Error("line.get_price() only works with xloc.bar_index lines, not xloc.bar_time");
|
|
76
|
+
}
|
|
77
|
+
if (x2 === x1) {
|
|
78
|
+
return NaN;
|
|
79
|
+
}
|
|
80
|
+
const slope = (y2 - y1) / (x2 - x1);
|
|
81
|
+
const price = y1 + slope * (x - x1);
|
|
82
|
+
if (extend === "none") {
|
|
83
|
+
if (x < Math.min(x1, x2) || x > Math.max(x1, x2)) {
|
|
84
|
+
return NaN;
|
|
85
|
+
}
|
|
86
|
+
} else if (extend === "left") {
|
|
87
|
+
if (x > Math.max(x1, x2)) {
|
|
88
|
+
return NaN;
|
|
89
|
+
}
|
|
90
|
+
} else if (extend === "right") {
|
|
91
|
+
if (x < Math.min(x1, x2)) {
|
|
92
|
+
return NaN;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return price;
|
|
96
|
+
}
|
|
97
|
+
function get_x1(id) {
|
|
98
|
+
return id.x1;
|
|
99
|
+
}
|
|
100
|
+
function get_x2(id) {
|
|
101
|
+
return id.x2;
|
|
102
|
+
}
|
|
103
|
+
function get_y1(id) {
|
|
104
|
+
return id.y1;
|
|
105
|
+
}
|
|
106
|
+
function get_y2(id) {
|
|
107
|
+
return id.y2;
|
|
108
|
+
}
|
|
109
|
+
function copy(id) {
|
|
110
|
+
return (0, import_registry.register)("line", { ...id });
|
|
111
|
+
}
|
|
112
|
+
function set_x1(id, x) {
|
|
113
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
114
|
+
id.x1 = x;
|
|
115
|
+
return id;
|
|
116
|
+
}
|
|
117
|
+
function set_x2(id, x) {
|
|
118
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
119
|
+
id.x2 = x;
|
|
120
|
+
return id;
|
|
121
|
+
}
|
|
122
|
+
function set_y1(id, y) {
|
|
123
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
124
|
+
id.y1 = y;
|
|
125
|
+
return id;
|
|
126
|
+
}
|
|
127
|
+
function set_y2(id, y) {
|
|
128
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
129
|
+
id.y2 = y;
|
|
130
|
+
return id;
|
|
131
|
+
}
|
|
132
|
+
function set_xy1(id, x, y) {
|
|
133
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
134
|
+
id.x1 = x;
|
|
135
|
+
id.y1 = y;
|
|
136
|
+
return id;
|
|
137
|
+
}
|
|
138
|
+
function set_xy2(id, x, y) {
|
|
139
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
140
|
+
id.x2 = x;
|
|
141
|
+
id.y2 = y;
|
|
142
|
+
return id;
|
|
143
|
+
}
|
|
144
|
+
function set_xloc(id, x1, x2, xloc) {
|
|
145
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
146
|
+
id.x1 = x1;
|
|
147
|
+
id.x2 = x2;
|
|
148
|
+
id.xloc = xloc;
|
|
149
|
+
return id;
|
|
150
|
+
}
|
|
151
|
+
function set_extend(id, extend) {
|
|
152
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
153
|
+
id.extend = extend;
|
|
154
|
+
return id;
|
|
155
|
+
}
|
|
156
|
+
function set_color(id, lineColor) {
|
|
157
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
158
|
+
id.color = lineColor;
|
|
159
|
+
return id;
|
|
160
|
+
}
|
|
161
|
+
function set_style(id, style) {
|
|
162
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
163
|
+
id.style = style;
|
|
164
|
+
return id;
|
|
165
|
+
}
|
|
166
|
+
function set_width(id, width) {
|
|
167
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
168
|
+
id.width = width;
|
|
169
|
+
return id;
|
|
170
|
+
}
|
|
171
|
+
function delete_line(id) {
|
|
172
|
+
(0, import_registry.remove)("line", id);
|
|
173
|
+
}
|
|
174
|
+
function pointX(point, xloc) {
|
|
175
|
+
const x = xloc === "bar_time" ? point.time : point.index;
|
|
176
|
+
return x ?? NaN;
|
|
177
|
+
}
|
|
178
|
+
function all() {
|
|
179
|
+
return (0, import_registry.all)("line");
|
|
180
|
+
}
|
|
181
|
+
function set_first_point(id, point) {
|
|
182
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
183
|
+
id.x1 = pointX(point, id.xloc);
|
|
184
|
+
id.y1 = point.price;
|
|
185
|
+
return id;
|
|
186
|
+
}
|
|
187
|
+
function set_second_point(id, point) {
|
|
188
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
189
|
+
id.x2 = pointX(point, id.xloc);
|
|
190
|
+
id.y2 = point.price;
|
|
191
|
+
return id;
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/line/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Line namespace\n * Functions for creating and manipulating line drawing objects.\n *\n * @remarks\n * While lines are primarily visual in PineScript, the line.get_price() function provides\n * computational value for algorithmic trading - calculating trend line breakouts,\n * support/resistance levels, and pattern recognition.\n *\n * @version 6\n */\n\nimport { all as allDrawings, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { ChartPoint, Line, color } from '../types/index.js';\n\ntype LineXloc = 'bar_index' | 'bar_time';\ntype LineExtend = 'none' | 'left' | 'right' | 'both';\ntype LineStyle = 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both';\n\n/**\n * Creates a new line (PineScript `line.new`), with two chart points or with coordinates:\n *\n * - `line.new(first_point, second_point, xloc?, extend?, color?, style?, width?, force_overlay?)`\n * - `line.new(x1, y1, x2, y2, xloc?, extend?, color?, style?, width?, force_overlay?)`\n *\n * With chart points, x is `point.index` for `bar_index` lines and `point.time` for `bar_time` lines.\n *\n * @example\n * ```typescript\n * // Create a trend line from bar 0 (price 100) to bar 50 (price 150)\n * const trendLine = line.new(0, 100, 50, 150, 'bar_index', 'right');\n * const fromPoints = line.new(chartPoint.from_index(0, 100), chartPoint.from_index(50, 150));\n *\n * // Calculate price at bar 75 (extrapolated)\n * const price = line.get_price(trendLine, 75); // Returns 175\n * ```\n */\nexport function new_line(\n first_point: ChartPoint,\n second_point: ChartPoint,\n xloc?: LineXloc,\n extend?: LineExtend,\n lineColor?: color,\n style?: LineStyle,\n width?: number,\n force_overlay?: boolean\n): Line;\nexport function new_line(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n xloc?: LineXloc,\n extend?: LineExtend,\n lineColor?: color,\n style?: LineStyle,\n width?: number,\n force_overlay?: boolean\n): Line;\nexport function new_line(...args: unknown[]): Line {\n let x1: number, y1: number, x2: number, y2: number, rest: unknown[];\n if (typeof args[0] === 'object' && args[0] !== null) {\n const [p1, p2, ...others] = args as [ChartPoint, ChartPoint, ...unknown[]];\n const xloc = (others[0] as LineXloc | undefined) ?? 'bar_index';\n [x1, y1, x2, y2, rest] = [pointX(p1, xloc), p1.price, pointX(p2, xloc), p2.price, others];\n } else {\n [x1, y1, x2, y2] = args as [number, number, number, number];\n rest = args.slice(4);\n }\n const [xloc, extend, lineColor, style, width, force_overlay] = rest as [\n LineXloc?, LineExtend?, color?, LineStyle?, number?, boolean?,\n ];\n return register('line', {\n x1,\n y1,\n x2,\n y2,\n xloc: xloc ?? 'bar_index',\n extend: extend ?? 'none',\n color: lineColor,\n style: style || 'solid',\n width: width || 1,\n force_overlay: force_overlay ?? false,\n });\n}\n\n/**\n * Returns the price level of a line at a given bar index.\n *\n * @param id - Line object\n * @param x - Bar index to calculate price at\n * @returns Price level at the given bar index, or NaN if outside bounds and not extended\n *\n * @remarks\n * - **CRITICAL COMPUTATIONAL FUNCTION** - Enables trend line breakout detection\n * - Uses linear interpolation: y = y1 + (y2 - y1) * (x - x1) / (x2 - x1)\n * - Respects extend mode:\n * - 'none': Returns NaN if x is outside [x1, x2]\n * - 'left': Extends infinitely to the left (x < x1)\n * - 'right': Extends infinitely to the right (x > x2)\n * - 'both': Extends infinitely in both directions\n * - Only works with xloc='bar_index' lines (not xloc='bar_time')\n * - In PineScript, this function treats all lines as if extend='both' regardless of actual setting\n * For compatibility, we follow the actual extend setting\n *\n * @example\n * ```typescript\n * const trendLine = line.new(0, 100, 50, 150, 'bar_index', 'right');\n *\n * // Within segment\n * line.get_price(trendLine, 25); // Returns 125\n *\n * // Extended right\n * line.get_price(trendLine, 100); // Returns 200\n *\n * // Not extended left (with extend='right')\n * line.get_price(trendLine, -10); // Returns NaN\n *\n * // Use for breakout detection\n * const currentPrice = close[close.length - 1];\n * const linePrice = line.get_price(trendLine, close.length - 1);\n * if (currentPrice > linePrice) {\n * console.log('Breakout above trend line!');\n * }\n * ```\n */\nexport function get_price(id: Line, x: number): number {\n const { x1, y1, x2, y2, extend, xloc } = id;\n\n // Only works with bar_index xloc\n if (xloc === 'bar_time') {\n throw new Error('line.get_price() only works with xloc.bar_index lines, not xloc.bar_time');\n }\n\n // Avoid division by zero\n if (x2 === x1) {\n // Vertical line - return NaN or could return y1/y2\n return NaN;\n }\n\n // Linear interpolation formula: y = y1 + (y2 - y1) * (x - x1) / (x2 - x1)\n const slope = (y2 - y1) / (x2 - x1);\n const price = y1 + slope * (x - x1);\n\n // Check bounds based on extend mode\n if (extend === 'none') {\n // Only valid within the segment\n if (x < Math.min(x1, x2) || x > Math.max(x1, x2)) {\n return NaN;\n }\n } else if (extend === 'left') {\n // Valid to the left and within, but not to the right\n if (x > Math.max(x1, x2)) {\n return NaN;\n }\n } else if (extend === 'right') {\n // Valid to the right and within, but not to the left\n if (x < Math.min(x1, x2)) {\n return NaN;\n }\n }\n // extend === 'both': always valid\n\n return price;\n}\n\n/**\n * Returns the first point's x coordinate.\n *\n * @param id - Line object\n * @returns X coordinate of the first point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const x1 = line.get_x1(line); // Returns 10\n * ```\n */\nexport function get_x1(id: Line): number {\n return id.x1;\n}\n\n/**\n * Returns the second point's x coordinate.\n *\n * @param id - Line object\n * @returns X coordinate of the second point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const x2 = line.get_x2(line); // Returns 50\n * ```\n */\nexport function get_x2(id: Line): number {\n return id.x2;\n}\n\n/**\n * Returns the first point's y coordinate (price level).\n *\n * @param id - Line object\n * @returns Y coordinate (price) of the first point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const y1 = line.get_y1(line); // Returns 100\n * ```\n */\nexport function get_y1(id: Line): number {\n return id.y1;\n}\n\n/**\n * Returns the second point's y coordinate (price level).\n *\n * @param id - Line object\n * @returns Y coordinate (price) of the second point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const y2 = line.get_y2(line); // Returns 150\n * ```\n */\nexport function get_y2(id: Line): number {\n return id.y2;\n}\n\n/**\n * Creates a copy of the line object.\n *\n * @param id - Line object to copy\n * @returns New line object with same properties\n *\n * @remarks\n * Creates a shallow copy of the line. Modifications to the copy won't affect the original.\n *\n * @example\n * ```typescript\n * const originalLine = line.new(0, 100, 50, 150);\n * const copiedLine = line.copy(originalLine);\n *\n * // Modify copy without affecting original\n * copiedLine.y2 = 200;\n * ```\n */\nexport function copy(id: Line): Line {\n return register('line', { ...id });\n}\n\n/**\n * Sets the first point's x coordinate.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate (bar index or timestamp)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_x1(line, 10); // Move first point to bar 10\n * ```\n */\nexport function set_x1(id: Line, x: number): Line {\n if (isDeleted(id)) return id;\n id.x1 = x;\n return id;\n}\n\n/**\n * Sets the second point's x coordinate.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate (bar index or timestamp)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_x2(line, 60); // Move second point to bar 60\n * ```\n */\nexport function set_x2(id: Line, x: number): Line {\n if (isDeleted(id)) return id;\n id.x2 = x;\n return id;\n}\n\n/**\n * Sets the first point's y coordinate (price level).\n *\n * @param id - Line object to modify\n * @param y - New y coordinate (price)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_y1(line, 110); // Move first point to price 110\n * ```\n */\nexport function set_y1(id: Line, y: number): Line {\n if (isDeleted(id)) return id;\n id.y1 = y;\n return id;\n}\n\n/**\n * Sets the second point's y coordinate (price level).\n *\n * @param id - Line object to modify\n * @param y - New y coordinate (price)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_y2(line, 160); // Move second point to price 160\n * ```\n */\nexport function set_y2(id: Line, y: number): Line {\n if (isDeleted(id)) return id;\n id.y2 = y;\n return id;\n}\n\n/**\n * Sets both coordinates of the first point.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_xy1(line, 5, 105); // Move first point to (5, 105)\n * ```\n */\nexport function set_xy1(id: Line, x: number, y: number): Line {\n if (isDeleted(id)) return id;\n id.x1 = x;\n id.y1 = y;\n return id;\n}\n\n/**\n * Sets both coordinates of the second point.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_xy2(line, 60, 160); // Move second point to (60, 160)\n * ```\n */\nexport function set_xy2(id: Line, x: number, y: number): Line {\n if (isDeleted(id)) return id;\n id.x2 = x;\n id.y2 = y;\n return id;\n}\n\n/**\n * Sets the coordinate system for the line.\n *\n * @param id - Line object to modify\n * @param x1 - New first point x coordinate\n * @param x2 - New second point x coordinate\n * @param xloc - New coordinate system ('bar_index' or 'bar_time')\n * @returns Modified line object\n *\n * @remarks\n * When changing xloc, you must provide appropriate x coordinates for the new system.\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * // Change to timestamp-based coordinates\n * line.set_xloc(line, 1609459200000, 1609545600000, 'bar_time');\n * ```\n */\nexport function set_xloc(id: Line, x1: number, x2: number, xloc: 'bar_index' | 'bar_time'): Line {\n if (isDeleted(id)) return id;\n id.x1 = x1;\n id.x2 = x2;\n id.xloc = xloc;\n return id;\n}\n\n/**\n * Sets the extension mode of the line.\n *\n * @param id - Line object to modify\n * @param extend - New extension mode\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_extend(line, 'right'); // Extend line to the right\n * ```\n */\nexport function set_extend(id: Line, extend: 'none' | 'left' | 'right' | 'both'): Line {\n if (isDeleted(id)) return id;\n id.extend = extend;\n return id;\n}\n\n/**\n * Sets the line color.\n *\n * @param id - Line object to modify\n * @param color - New line color\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_color(line, '#FF0000'); // Change to red\n * ```\n */\nexport function set_color(id: Line, lineColor: color): Line {\n if (isDeleted(id)) return id;\n id.color = lineColor;\n return id;\n}\n\n/**\n * Sets the line style.\n *\n * @param id - Line object to modify\n * @param style - New line style\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_style(line, 'dashed'); // Change to dashed line\n * ```\n */\nexport function set_style(id: Line, style: 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both'): Line {\n if (isDeleted(id)) return id;\n id.style = style;\n return id;\n}\n\n/**\n * Sets the line width.\n *\n * @param id - Line object to modify\n * @param width - New line width in pixels\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_width(line, 3); // Make line thicker\n * ```\n */\nexport function set_width(id: Line, width: number): Line {\n if (isDeleted(id)) return id;\n id.width = width;\n return id;\n}\n\n/**\n * Deletes the line object.\n *\n * @param id - Line object to delete\n *\n * @remarks\n * Removes the line from `line.all()`. As in PineScript, the deleted line is `na`: its getters\n * return NaN and its setters do nothing. Deleting it twice has no effect. Deleting a line also deletes the linefills that use it.\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.delete(line);\n * // line.all() no longer contains it\n * ```\n */\nexport function delete_line(id: Line): void {\n remove('line', id);\n}\n\n/** x coordinate of a chart point for an object's xloc (`na` when the point has no such coordinate). */\nfunction pointX(point: ChartPoint, xloc: 'bar_index' | 'bar_time'): number {\n const x = xloc === 'bar_time' ? point.time : point.index;\n return x ?? NaN;\n}\n\n/**\n * All live lines, in creation order (PineScript `line.all`). A new array: later changes do not affect it.\n */\nexport function all(): Line[] {\n return allDrawings('line');\n}\n\n/**\n * Sets the first point of the line from a chart point: `point.index` for `bar_index` lines,\n * `point.time` for `bar_time` lines (`na` when the point does not have it), and `point.price`.\n */\nexport function set_first_point(id: Line, point: ChartPoint): Line {\n if (isDeleted(id)) return id;\n id.x1 = pointX(point, id.xloc);\n id.y1 = point.price;\n return id;\n}\n\n/**\n * Sets the second point of the line from a chart point (see {@link set_first_point}).\n */\nexport function set_second_point(id: Line, point: ChartPoint): Line {\n if (isDeleted(id)) return id;\n id.x2 = pointX(point, id.xloc);\n id.y2 = point.price;\n return id;\n}\n\n// Alias to match PineScript API\nexport { new_line as new };\nexport { delete_line as delete };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sBAAgE;AA+CzD,SAAS,YAAY,MAAuB;AACjD,MAAI,IAAY,IAAY,IAAY,IAAY;AACpD,MAAI,OAAO,KAAK,CAAC,MAAM,YAAY,KAAK,CAAC,MAAM,MAAM;AACnD,UAAM,CAAC,IAAI,IAAI,GAAG,MAAM,IAAI;AAC5B,UAAMA,QAAQ,OAAO,CAAC,KAA8B;AACpD,KAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,IAAIA,KAAI,GAAG,GAAG,OAAO,OAAO,IAAIA,KAAI,GAAG,GAAG,OAAO,MAAM;AAAA,EAC1F,OAAO;AACL,KAAC,IAAI,IAAI,IAAI,EAAE,IAAI;AACnB,WAAO,KAAK,MAAM,CAAC;AAAA,EACrB;AAC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AACT;AAkBO,SAAS,YAAY,IAAgB;AAC1C,8BAAO,QAAQ,EAAE;AACnB;AAGA,SAAS,OAAO,OAAmB,MAAwC;AACzE,QAAM,IAAI,SAAS,aAAa,MAAM,OAAO,MAAM;AACnD,SAAO,KAAK;AACd;AAKO,SAAS,MAAc;AAC5B,aAAO,gBAAAC,KAAY,MAAM;AAC3B;AAMO,SAAS,gBAAgB,IAAU,OAAyB;AACjE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,KAAK,OAAO,OAAO,GAAG,IAAI;AAC7B,KAAG,KAAK,MAAM;AACd,SAAO;AACT;AAKO,SAAS,iBAAiB,IAAU,OAAyB;AAClE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,KAAK,OAAO,OAAO,GAAG,IAAI;AAC7B,KAAG,KAAK,MAAM;AACd,SAAO;AACT;",
|
|
6
|
+
"names": ["xloc", "allDrawings"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linefill namespace
|
|
3
|
+
* Functions for creating and manipulating linefill drawing objects.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Linefill objects fill the area between two lines with a color.
|
|
7
|
+
* They have minimal computational value but automatically follow line movements
|
|
8
|
+
* and provide a way to retrieve the underlying line references.
|
|
9
|
+
*
|
|
10
|
+
* @version 6
|
|
11
|
+
*/
|
|
12
|
+
import type { Linefill, Line, color } from '../types/index.js';
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new linefill object that fills the area between two lines.
|
|
15
|
+
*
|
|
16
|
+
* @param line1 - First line object
|
|
17
|
+
* @param line2 - Second line object
|
|
18
|
+
* @param fillColor - Fill color (optional)
|
|
19
|
+
* @returns New linefill object
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* - Automatically follows line movements (if lines are updated, fill updates too)
|
|
23
|
+
* - Automatically deleted if either line is deleted
|
|
24
|
+
* - If both lines extend in same direction, fill extends too
|
|
25
|
+
* - Purely visual in PineScript, but getters allow retrieving line references
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { line, linefill } from 'oakscriptjs';
|
|
30
|
+
*
|
|
31
|
+
* // Create channel lines
|
|
32
|
+
* const upperLine = line.new(0, 160, 50, 170, 'bar_index', 'right');
|
|
33
|
+
* const lowerLine = line.new(0, 140, 50, 150, 'bar_index', 'right');
|
|
34
|
+
*
|
|
35
|
+
* // Fill channel with color
|
|
36
|
+
* const channelFill = linefill.new(upperLine, lowerLine, '#0000FF20'); // Transparent blue
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function new_linefill(line1: Line, line2: Line, fillColor?: color): Linefill;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the first line reference.
|
|
42
|
+
*
|
|
43
|
+
* @param id - Linefill object
|
|
44
|
+
* @returns First line object
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* Can be used to retrieve and manipulate the first line.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const channelFill = linefill.new(upperLine, lowerLine);
|
|
52
|
+
*
|
|
53
|
+
* // Later, retrieve and update the first line
|
|
54
|
+
* const line1 = linefill.get_line1(channelFill);
|
|
55
|
+
* line.set_y2(line1, 175); // Update upper line's second point
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function get_line1(id: Linefill): Line;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the second line reference.
|
|
61
|
+
*
|
|
62
|
+
* @param id - Linefill object
|
|
63
|
+
* @returns Second line object
|
|
64
|
+
*
|
|
65
|
+
* @remarks
|
|
66
|
+
* Can be used to retrieve and manipulate the second line.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const channelFill = linefill.new(upperLine, lowerLine);
|
|
71
|
+
*
|
|
72
|
+
* // Later, retrieve and update the second line
|
|
73
|
+
* const line2 = linefill.get_line2(channelFill);
|
|
74
|
+
* line.set_y2(line2, 145); // Update lower line's second point
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function get_line2(id: Linefill): Line;
|
|
78
|
+
/**
|
|
79
|
+
* Sets the fill color.
|
|
80
|
+
*
|
|
81
|
+
* @param id - Linefill object to modify
|
|
82
|
+
* @param fillColor - New fill color
|
|
83
|
+
* @returns Modified linefill object
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* Useful for dynamically changing channel colors based on conditions.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const channelFill = linefill.new(upperLine, lowerLine, '#0000FF20');
|
|
91
|
+
*
|
|
92
|
+
* // Change color based on trend
|
|
93
|
+
* if (bullish) {
|
|
94
|
+
* linefill.set_color(channelFill, '#00FF0020'); // Green
|
|
95
|
+
* } else {
|
|
96
|
+
* linefill.set_color(channelFill, '#FF000020'); // Red
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function set_color(id: Linefill, fillColor: color): Linefill;
|
|
101
|
+
/**
|
|
102
|
+
* Deletes the linefill object.
|
|
103
|
+
*
|
|
104
|
+
* @param id - Linefill object to delete
|
|
105
|
+
*
|
|
106
|
+
* @remarks
|
|
107
|
+
* Removes the linefill from `linefill.all()`. As in PineScript, the deleted linefill is `na`: its getters
|
|
108
|
+
* return NaN and its setters do nothing. Deleting it twice has no effect.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const channelFill = linefill.new(upperLine, lowerLine);
|
|
113
|
+
* linefill.delete(channelFill);
|
|
114
|
+
* // linefill.all() no longer contains it
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare function delete_linefill(id: Linefill): void;
|
|
118
|
+
/**
|
|
119
|
+
* All live linefills, in creation order (PineScript `linefill.all`). A new array.
|
|
120
|
+
*/
|
|
121
|
+
export declare function all(): Linefill[];
|
|
122
|
+
export { new_linefill as new };
|
|
123
|
+
export { delete_linefill as delete };
|
|
124
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/linefill/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAMlF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAE5C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAE5C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,GAAG,QAAQ,CAIlE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAElD;AAGD;;GAEG;AACH,wBAAgB,GAAG,IAAI,QAAQ,EAAE,CAEhC;AAGD,OAAO,EAAE,YAAY,IAAI,GAAG,EAAE,CAAC;AAC/B,OAAO,EAAE,eAAe,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all2) => {
|
|
7
|
+
for (var name in all2)
|
|
8
|
+
__defProp(target, name, { get: all2[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var linefill_exports = {};
|
|
20
|
+
__export(linefill_exports, {
|
|
21
|
+
all: () => all,
|
|
22
|
+
delete: () => delete_linefill,
|
|
23
|
+
delete_linefill: () => delete_linefill,
|
|
24
|
+
get_line1: () => get_line1,
|
|
25
|
+
get_line2: () => get_line2,
|
|
26
|
+
new: () => new_linefill,
|
|
27
|
+
new_linefill: () => new_linefill,
|
|
28
|
+
set_color: () => set_color
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(linefill_exports);
|
|
31
|
+
var import_registry = require("../drawing/registry.js");
|
|
32
|
+
function new_linefill(line1, line2, fillColor) {
|
|
33
|
+
return (0, import_registry.register)("linefill", {
|
|
34
|
+
line1,
|
|
35
|
+
line2,
|
|
36
|
+
color: fillColor
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function get_line1(id) {
|
|
40
|
+
return id.line1;
|
|
41
|
+
}
|
|
42
|
+
function get_line2(id) {
|
|
43
|
+
return id.line2;
|
|
44
|
+
}
|
|
45
|
+
function set_color(id, fillColor) {
|
|
46
|
+
if ((0, import_registry.isDeleted)(id)) return id;
|
|
47
|
+
id.color = fillColor;
|
|
48
|
+
return id;
|
|
49
|
+
}
|
|
50
|
+
function delete_linefill(id) {
|
|
51
|
+
(0, import_registry.remove)("linefill", id);
|
|
52
|
+
}
|
|
53
|
+
function all() {
|
|
54
|
+
return (0, import_registry.all)("linefill");
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/linefill/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Linefill namespace\n * Functions for creating and manipulating linefill drawing objects.\n *\n * @remarks\n * Linefill objects fill the area between two lines with a color.\n * They have minimal computational value but automatically follow line movements\n * and provide a way to retrieve the underlying line references.\n *\n * @version 6\n */\n\nimport { all as allDrawings, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { Linefill, Line, color } from '../types/index.js';\n\n/**\n * Creates a new linefill object that fills the area between two lines.\n *\n * @param line1 - First line object\n * @param line2 - Second line object\n * @param fillColor - Fill color (optional)\n * @returns New linefill object\n *\n * @remarks\n * - Automatically follows line movements (if lines are updated, fill updates too)\n * - Automatically deleted if either line is deleted\n * - If both lines extend in same direction, fill extends too\n * - Purely visual in PineScript, but getters allow retrieving line references\n *\n * @example\n * ```typescript\n * import { line, linefill } from 'oakscriptjs';\n *\n * // Create channel lines\n * const upperLine = line.new(0, 160, 50, 170, 'bar_index', 'right');\n * const lowerLine = line.new(0, 140, 50, 150, 'bar_index', 'right');\n *\n * // Fill channel with color\n * const channelFill = linefill.new(upperLine, lowerLine, '#0000FF20'); // Transparent blue\n * ```\n */\nexport function new_linefill(line1: Line, line2: Line, fillColor?: color): Linefill {\n return register('linefill', {\n line1,\n line2,\n color: fillColor\n });\n}\n\n/**\n * Returns the first line reference.\n *\n * @param id - Linefill object\n * @returns First line object\n *\n * @remarks\n * Can be used to retrieve and manipulate the first line.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine);\n *\n * // Later, retrieve and update the first line\n * const line1 = linefill.get_line1(channelFill);\n * line.set_y2(line1, 175); // Update upper line's second point\n * ```\n */\nexport function get_line1(id: Linefill): Line {\n return id.line1;\n}\n\n/**\n * Returns the second line reference.\n *\n * @param id - Linefill object\n * @returns Second line object\n *\n * @remarks\n * Can be used to retrieve and manipulate the second line.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine);\n *\n * // Later, retrieve and update the second line\n * const line2 = linefill.get_line2(channelFill);\n * line.set_y2(line2, 145); // Update lower line's second point\n * ```\n */\nexport function get_line2(id: Linefill): Line {\n return id.line2;\n}\n\n/**\n * Sets the fill color.\n *\n * @param id - Linefill object to modify\n * @param fillColor - New fill color\n * @returns Modified linefill object\n *\n * @remarks\n * Useful for dynamically changing channel colors based on conditions.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine, '#0000FF20');\n *\n * // Change color based on trend\n * if (bullish) {\n * linefill.set_color(channelFill, '#00FF0020'); // Green\n * } else {\n * linefill.set_color(channelFill, '#FF000020'); // Red\n * }\n * ```\n */\nexport function set_color(id: Linefill, fillColor: color): Linefill {\n if (isDeleted(id)) return id;\n id.color = fillColor;\n return id;\n}\n\n/**\n * Deletes the linefill object.\n *\n * @param id - Linefill object to delete\n *\n * @remarks\n * Removes the linefill from `linefill.all()`. As in PineScript, the deleted linefill is `na`: its getters\n * return NaN and its setters do nothing. Deleting it twice has no effect.\n *\n * @example\n * ```typescript\n * const channelFill = linefill.new(upperLine, lowerLine);\n * linefill.delete(channelFill);\n * // linefill.all() no longer contains it\n * ```\n */\nexport function delete_linefill(id: Linefill): void {\n remove('linefill', id);\n}\n\n\n/**\n * All live linefills, in creation order (PineScript `linefill.all`). A new array.\n */\nexport function all(): Linefill[] {\n return allDrawings('linefill');\n}\n\n// Alias to match PineScript API\nexport { new_linefill as new };\nexport { delete_linefill as delete };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sBAAgE;AA6BzD,SAAS,aAAa,OAAa,OAAa,WAA6B;AAClF,aAAO,0BAAS,YAAY;AAAA,IAC1B;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT,CAAC;AACH;AAoBO,SAAS,UAAU,IAAoB;AAC5C,SAAO,GAAG;AACZ;AAoBO,SAAS,UAAU,IAAoB;AAC5C,SAAO,GAAG;AACZ;AAwBO,SAAS,UAAU,IAAc,WAA4B;AAClE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,QAAQ;AACX,SAAO;AACT;AAkBO,SAAS,gBAAgB,IAAoB;AAClD,8BAAO,YAAY,EAAE;AACvB;AAMO,SAAS,MAAkB;AAChC,aAAO,gBAAAA,KAAY,UAAU;AAC/B;",
|
|
6
|
+
"names": ["allDrawings"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map namespace
|
|
3
|
+
* Mirrors PineScript's map.* functions.
|
|
4
|
+
*
|
|
5
|
+
* A PineScript map is a JS `Map`. PineScript rules:
|
|
6
|
+
* - `keys()` and `values()` follow insertion order; putting an existing key keeps its position,
|
|
7
|
+
* removing a key and putting it again moves it to the end
|
|
8
|
+
* - keys are equal only when they are exactly equal (no float tolerance)
|
|
9
|
+
* - `put()` and `remove()` return the previous value, or `na` (`undefined`) when there was none
|
|
10
|
+
* - a map holds at most 50,000 key-value pairs
|
|
11
|
+
*/
|
|
12
|
+
import type { PineArray, PineMap, PineMapKey, bool, int } from '../types/index.js';
|
|
13
|
+
/** Maximum number of key-value pairs in a PineScript map. */
|
|
14
|
+
export declare const MAX_SIZE = 50000;
|
|
15
|
+
/**
|
|
16
|
+
* Creates an empty map (PineScript `map.new<keyType, valueType>()`).
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const levels = map.new_map<string, number>();
|
|
21
|
+
* map.put(levels, 'high', 105.2);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function new_map<K extends PineMapKey, V>(): PineMap<K, V>;
|
|
25
|
+
/**
|
|
26
|
+
* Puts a key-value pair in the map. An existing key keeps its position.
|
|
27
|
+
* @returns The previous value of the key, or `undefined` (`na`) when the key was new
|
|
28
|
+
* @throws RangeError when the map would hold more than 50,000 pairs
|
|
29
|
+
*/
|
|
30
|
+
export declare function put<K extends PineMapKey, V>(id: PineMap<K, V>, key: K, value: V): V | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Puts all pairs of `id2` in `id` (existing keys are overwritten and keep their position).
|
|
33
|
+
* @throws RangeError when `id` would hold more than 50,000 pairs
|
|
34
|
+
*/
|
|
35
|
+
export declare function put_all<K extends PineMapKey, V>(id: PineMap<K, V>, id2: PineMap<K, V>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the value of `key`, or `undefined` (`na`) when the map does not contain it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function get<K extends PineMapKey, V>(id: PineMap<K, V>, key: K): V | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Returns true when the map contains `key` (also when its value is `na`).
|
|
42
|
+
*/
|
|
43
|
+
export declare function contains<K extends PineMapKey, V>(id: PineMap<K, V>, key: K): bool;
|
|
44
|
+
/**
|
|
45
|
+
* Removes `key` from the map.
|
|
46
|
+
* @returns The removed value, or `undefined` (`na`) when the map did not contain the key
|
|
47
|
+
*/
|
|
48
|
+
export declare function remove<K extends PineMapKey, V>(id: PineMap<K, V>, key: K): V | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the number of key-value pairs.
|
|
51
|
+
*/
|
|
52
|
+
export declare function size<K extends PineMapKey, V>(id: PineMap<K, V>): int;
|
|
53
|
+
/**
|
|
54
|
+
* Removes all pairs.
|
|
55
|
+
*/
|
|
56
|
+
export declare function clear<K extends PineMapKey, V>(id: PineMap<K, V>): void;
|
|
57
|
+
/**
|
|
58
|
+
* Returns a new array of the keys, in insertion order.
|
|
59
|
+
*/
|
|
60
|
+
export declare function keys<K extends PineMapKey, V>(id: PineMap<K, V>): PineArray<K>;
|
|
61
|
+
/**
|
|
62
|
+
* Returns a new array of the values, in insertion order of their keys.
|
|
63
|
+
*/
|
|
64
|
+
export declare function values<K extends PineMapKey, V>(id: PineMap<K, V>): PineArray<V>;
|
|
65
|
+
/**
|
|
66
|
+
* Returns a shallow copy of the map (same order; object values are shared).
|
|
67
|
+
*/
|
|
68
|
+
export declare function copy<K extends PineMapKey, V>(id: PineMap<K, V>): PineMap<K, V>;
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/map/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEnF,6DAA6D;AAC7D,eAAO,MAAM,QAAQ,QAAS,CAAC;AAM/B;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAK/F;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAK5F;AAED;;GAEG;AACH,wBAAgB,GAAG,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,EAAE,CAAC,CAAC,CAE9E"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var map_exports = {};
|
|
20
|
+
__export(map_exports, {
|
|
21
|
+
MAX_SIZE: () => MAX_SIZE,
|
|
22
|
+
clear: () => clear,
|
|
23
|
+
contains: () => contains,
|
|
24
|
+
copy: () => copy,
|
|
25
|
+
get: () => get,
|
|
26
|
+
keys: () => keys,
|
|
27
|
+
new_map: () => new_map,
|
|
28
|
+
put: () => put,
|
|
29
|
+
put_all: () => put_all,
|
|
30
|
+
remove: () => remove,
|
|
31
|
+
size: () => size,
|
|
32
|
+
values: () => values
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(map_exports);
|
|
35
|
+
const MAX_SIZE = 5e4;
|
|
36
|
+
function tooLarge(size2) {
|
|
37
|
+
return new RangeError(`A map cannot have more than ${MAX_SIZE} key-value pairs. The current size is ${size2}.`);
|
|
38
|
+
}
|
|
39
|
+
function new_map() {
|
|
40
|
+
return /* @__PURE__ */ new Map();
|
|
41
|
+
}
|
|
42
|
+
function put(id, key, value) {
|
|
43
|
+
const previous = id.get(key);
|
|
44
|
+
if (!id.has(key) && id.size >= MAX_SIZE) throw tooLarge(id.size + 1);
|
|
45
|
+
id.set(key, value);
|
|
46
|
+
return previous;
|
|
47
|
+
}
|
|
48
|
+
function put_all(id, id2) {
|
|
49
|
+
let size2 = id.size;
|
|
50
|
+
for (const key of id2.keys()) if (!id.has(key)) size2++;
|
|
51
|
+
if (size2 > MAX_SIZE) throw tooLarge(size2);
|
|
52
|
+
for (const [key, value] of id2) id.set(key, value);
|
|
53
|
+
}
|
|
54
|
+
function get(id, key) {
|
|
55
|
+
return id.get(key);
|
|
56
|
+
}
|
|
57
|
+
function contains(id, key) {
|
|
58
|
+
return id.has(key);
|
|
59
|
+
}
|
|
60
|
+
function remove(id, key) {
|
|
61
|
+
const value = id.get(key);
|
|
62
|
+
id.delete(key);
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
function size(id) {
|
|
66
|
+
return id.size;
|
|
67
|
+
}
|
|
68
|
+
function clear(id) {
|
|
69
|
+
id.clear();
|
|
70
|
+
}
|
|
71
|
+
function keys(id) {
|
|
72
|
+
return [...id.keys()];
|
|
73
|
+
}
|
|
74
|
+
function values(id) {
|
|
75
|
+
return [...id.values()];
|
|
76
|
+
}
|
|
77
|
+
function copy(id) {
|
|
78
|
+
return new Map(id);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/map/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Map namespace\n * Mirrors PineScript's map.* functions.\n *\n * A PineScript map is a JS `Map`. PineScript rules:\n * - `keys()` and `values()` follow insertion order; putting an existing key keeps its position,\n * removing a key and putting it again moves it to the end\n * - keys are equal only when they are exactly equal (no float tolerance)\n * - `put()` and `remove()` return the previous value, or `na` (`undefined`) when there was none\n * - a map holds at most 50,000 key-value pairs\n */\n\nimport type { PineArray, PineMap, PineMapKey, bool, int } from '../types/index.js';\n\n/** Maximum number of key-value pairs in a PineScript map. */\nexport const MAX_SIZE = 50_000;\n\nfunction tooLarge(size: number): RangeError {\n return new RangeError(`A map cannot have more than ${MAX_SIZE} key-value pairs. The current size is ${size}.`);\n}\n\n/**\n * Creates an empty map (PineScript `map.new<keyType, valueType>()`).\n *\n * @example\n * ```typescript\n * const levels = map.new_map<string, number>();\n * map.put(levels, 'high', 105.2);\n * ```\n */\nexport function new_map<K extends PineMapKey, V>(): PineMap<K, V> {\n return new Map<K, V>();\n}\n\n/**\n * Puts a key-value pair in the map. An existing key keeps its position.\n * @returns The previous value of the key, or `undefined` (`na`) when the key was new\n * @throws RangeError when the map would hold more than 50,000 pairs\n */\nexport function put<K extends PineMapKey, V>(id: PineMap<K, V>, key: K, value: V): V | undefined {\n const previous = id.get(key);\n if (!id.has(key) && id.size >= MAX_SIZE) throw tooLarge(id.size + 1);\n id.set(key, value);\n return previous;\n}\n\n/**\n * Puts all pairs of `id2` in `id` (existing keys are overwritten and keep their position).\n * @throws RangeError when `id` would hold more than 50,000 pairs\n */\nexport function put_all<K extends PineMapKey, V>(id: PineMap<K, V>, id2: PineMap<K, V>): void {\n let size = id.size;\n for (const key of id2.keys()) if (!id.has(key)) size++;\n if (size > MAX_SIZE) throw tooLarge(size);\n for (const [key, value] of id2) id.set(key, value);\n}\n\n/**\n * Returns the value of `key`, or `undefined` (`na`) when the map does not contain it.\n */\nexport function get<K extends PineMapKey, V>(id: PineMap<K, V>, key: K): V | undefined {\n return id.get(key);\n}\n\n/**\n * Returns true when the map contains `key` (also when its value is `na`).\n */\nexport function contains<K extends PineMapKey, V>(id: PineMap<K, V>, key: K): bool {\n return id.has(key);\n}\n\n/**\n * Removes `key` from the map.\n * @returns The removed value, or `undefined` (`na`) when the map did not contain the key\n */\nexport function remove<K extends PineMapKey, V>(id: PineMap<K, V>, key: K): V | undefined {\n const value = id.get(key);\n id.delete(key);\n return value;\n}\n\n/**\n * Returns the number of key-value pairs.\n */\nexport function size<K extends PineMapKey, V>(id: PineMap<K, V>): int {\n return id.size;\n}\n\n/**\n * Removes all pairs.\n */\nexport function clear<K extends PineMapKey, V>(id: PineMap<K, V>): void {\n id.clear();\n}\n\n/**\n * Returns a new array of the keys, in insertion order.\n */\nexport function keys<K extends PineMapKey, V>(id: PineMap<K, V>): PineArray<K> {\n return [...id.keys()];\n}\n\n/**\n * Returns a new array of the values, in insertion order of their keys.\n */\nexport function values<K extends PineMapKey, V>(id: PineMap<K, V>): PineArray<V> {\n return [...id.values()];\n}\n\n/**\n * Returns a shallow copy of the map (same order; object values are shared).\n */\nexport function copy<K extends PineMapKey, V>(id: PineMap<K, V>): PineMap<K, V> {\n return new Map(id);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,MAAM,WAAW;AAExB,SAAS,SAASA,OAA0B;AAC1C,SAAO,IAAI,WAAW,+BAA+B,QAAQ,yCAAyCA,KAAI,GAAG;AAC/G;AAWO,SAAS,UAAkD;AAChE,SAAO,oBAAI,IAAU;AACvB;AAOO,SAAS,IAA6B,IAAmB,KAAQ,OAAyB;AAC/F,QAAM,WAAW,GAAG,IAAI,GAAG;AAC3B,MAAI,CAAC,GAAG,IAAI,GAAG,KAAK,GAAG,QAAQ,SAAU,OAAM,SAAS,GAAG,OAAO,CAAC;AACnE,KAAG,IAAI,KAAK,KAAK;AACjB,SAAO;AACT;AAMO,SAAS,QAAiC,IAAmB,KAA0B;AAC5F,MAAIA,QAAO,GAAG;AACd,aAAW,OAAO,IAAI,KAAK,EAAG,KAAI,CAAC,GAAG,IAAI,GAAG,EAAG,CAAAA;AAChD,MAAIA,QAAO,SAAU,OAAM,SAASA,KAAI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