oakscriptjs 0.9.5 → 0.10.0

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.
Files changed (256) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/array/index.d.ts +93 -50
  3. package/dist/cjs/array/index.d.ts.map +1 -1
  4. package/dist/cjs/array/index.js +239 -78
  5. package/dist/cjs/array/index.js.map +3 -3
  6. package/dist/cjs/callsite/index.d.ts +81 -2
  7. package/dist/cjs/callsite/index.d.ts.map +1 -1
  8. package/dist/cjs/callsite/index.js +62 -1
  9. package/dist/cjs/callsite/index.js.map +2 -2
  10. package/dist/cjs/color/index.d.ts +7 -3
  11. package/dist/cjs/color/index.d.ts.map +1 -1
  12. package/dist/cjs/color/index.js +6 -1
  13. package/dist/cjs/color/index.js.map +2 -2
  14. package/dist/cjs/drawing/bar-time.d.ts +24 -0
  15. package/dist/cjs/drawing/bar-time.d.ts.map +1 -0
  16. package/dist/cjs/drawing/bar-time.js +47 -0
  17. package/dist/cjs/drawing/bar-time.js.map +7 -0
  18. package/dist/cjs/drawing/output.d.ts +32 -0
  19. package/dist/cjs/drawing/output.d.ts.map +1 -0
  20. package/dist/cjs/drawing/output.js +184 -0
  21. package/dist/cjs/drawing/output.js.map +7 -0
  22. package/dist/cjs/drawing/registry.d.ts +5 -4
  23. package/dist/cjs/drawing/registry.d.ts.map +1 -1
  24. package/dist/cjs/drawing/registry.js +11 -2
  25. package/dist/cjs/drawing/registry.js.map +2 -2
  26. package/dist/cjs/index.d.ts +6 -3
  27. package/dist/cjs/index.d.ts.map +1 -1
  28. package/dist/cjs/index.js +9 -2
  29. package/dist/cjs/index.js.map +2 -2
  30. package/dist/cjs/label/index.d.ts.map +1 -1
  31. package/dist/cjs/label/index.js +2 -1
  32. package/dist/cjs/label/index.js.map +2 -2
  33. package/dist/cjs/linefill/index.d.ts.map +1 -1
  34. package/dist/cjs/linefill/index.js +1 -0
  35. package/dist/cjs/linefill/index.js.map +2 -2
  36. package/dist/cjs/math/index.d.ts +76 -21
  37. package/dist/cjs/math/index.d.ts.map +1 -1
  38. package/dist/cjs/math/index.js +155 -41
  39. package/dist/cjs/math/index.js.map +3 -3
  40. package/dist/cjs/matrix/index.d.ts.map +1 -1
  41. package/dist/cjs/matrix/index.js +42 -36
  42. package/dist/cjs/matrix/index.js.map +2 -2
  43. package/dist/cjs/polyline/index.d.ts +3 -5
  44. package/dist/cjs/polyline/index.d.ts.map +1 -1
  45. package/dist/cjs/polyline/index.js +0 -5
  46. package/dist/cjs/polyline/index.js.map +2 -2
  47. package/dist/cjs/runtime/series.d.ts +9 -0
  48. package/dist/cjs/runtime/series.d.ts.map +1 -1
  49. package/dist/cjs/runtime/series.js +16 -2
  50. package/dist/cjs/runtime/series.js.map +2 -2
  51. package/dist/cjs/runtime/types.d.ts +22 -0
  52. package/dist/cjs/runtime/types.d.ts.map +1 -1
  53. package/dist/cjs/runtime/types.js.map +1 -1
  54. package/dist/cjs/script/index.d.ts +97 -36
  55. package/dist/cjs/script/index.d.ts.map +1 -1
  56. package/dist/cjs/script/index.js +173 -26
  57. package/dist/cjs/script/index.js.map +3 -3
  58. package/dist/cjs/session/calendar.d.ts.map +1 -1
  59. package/dist/cjs/session/calendar.js +15 -2
  60. package/dist/cjs/session/calendar.js.map +2 -2
  61. package/dist/cjs/str/index.d.ts +50 -38
  62. package/dist/cjs/str/index.d.ts.map +1 -1
  63. package/dist/cjs/str/index.js +43 -15
  64. package/dist/cjs/str/index.js.map +2 -2
  65. package/dist/cjs/str/messageformat.d.ts +2 -1
  66. package/dist/cjs/str/messageformat.d.ts.map +1 -1
  67. package/dist/cjs/str/messageformat.js +4 -1
  68. package/dist/cjs/str/messageformat.js.map +2 -2
  69. package/dist/cjs/str/numberformat.d.ts +4 -0
  70. package/dist/cjs/str/numberformat.d.ts.map +1 -1
  71. package/dist/cjs/str/numberformat.js +26 -4
  72. package/dist/cjs/str/numberformat.js.map +3 -3
  73. package/dist/cjs/ta/index.d.ts +86 -43
  74. package/dist/cjs/ta/index.d.ts.map +1 -1
  75. package/dist/cjs/ta/index.js +173 -267
  76. package/dist/cjs/ta/index.js.map +3 -3
  77. package/dist/cjs/ta/running-sum.d.ts +54 -2
  78. package/dist/cjs/ta/running-sum.d.ts.map +1 -1
  79. package/dist/cjs/ta/running-sum.js +132 -52
  80. package/dist/cjs/ta/running-sum.js.map +2 -2
  81. package/dist/cjs/ta-series.d.ts +4 -4
  82. package/dist/cjs/ta-series.d.ts.map +1 -1
  83. package/dist/cjs/ta-series.js +4 -3
  84. package/dist/cjs/ta-series.js.map +2 -2
  85. package/dist/cjs/table/index.d.ts +87 -0
  86. package/dist/cjs/table/index.d.ts.map +1 -0
  87. package/dist/cjs/table/index.js +150 -0
  88. package/dist/cjs/table/index.js.map +7 -0
  89. package/dist/cjs/text/index.d.ts +17 -2
  90. package/dist/cjs/text/index.d.ts.map +1 -1
  91. package/dist/cjs/text/index.js +15 -1
  92. package/dist/cjs/text/index.js.map +2 -2
  93. package/dist/cjs/time/datestring.d.ts +1 -0
  94. package/dist/cjs/time/datestring.d.ts.map +1 -1
  95. package/dist/cjs/time/datestring.js +7 -0
  96. package/dist/cjs/time/datestring.js.map +2 -2
  97. package/dist/cjs/time/index.d.ts.map +1 -1
  98. package/dist/cjs/time/index.js +2 -1
  99. package/dist/cjs/time/index.js.map +2 -2
  100. package/dist/cjs/time/session.d.ts +28 -9
  101. package/dist/cjs/time/session.d.ts.map +1 -1
  102. package/dist/cjs/time/session.js +74 -28
  103. package/dist/cjs/time/session.js.map +2 -2
  104. package/dist/cjs/time/timezone.d.ts +5 -0
  105. package/dist/cjs/time/timezone.d.ts.map +1 -1
  106. package/dist/cjs/time/timezone.js +15 -1
  107. package/dist/cjs/time/timezone.js.map +2 -2
  108. package/dist/cjs/types/index.d.ts +30 -1
  109. package/dist/cjs/types/index.d.ts.map +1 -1
  110. package/dist/cjs/types/index.js +12 -0
  111. package/dist/cjs/types/index.js.map +2 -2
  112. package/dist/cjs/types/metadata.d.ts +258 -26
  113. package/dist/cjs/types/metadata.d.ts.map +1 -1
  114. package/dist/cjs/types/metadata.js.map +1 -1
  115. package/dist/esm/array/index.d.ts +93 -50
  116. package/dist/esm/array/index.d.ts.map +1 -1
  117. package/dist/esm/array/index.js +383 -133
  118. package/dist/esm/array/index.js.map +1 -1
  119. package/dist/esm/callsite/index.d.ts +81 -2
  120. package/dist/esm/callsite/index.d.ts.map +1 -1
  121. package/dist/esm/callsite/index.js +145 -3
  122. package/dist/esm/callsite/index.js.map +1 -1
  123. package/dist/esm/color/index.d.ts +7 -3
  124. package/dist/esm/color/index.d.ts.map +1 -1
  125. package/dist/esm/color/index.js +15 -3
  126. package/dist/esm/color/index.js.map +1 -1
  127. package/dist/esm/drawing/bar-time.d.ts +24 -0
  128. package/dist/esm/drawing/bar-time.d.ts.map +1 -0
  129. package/dist/esm/drawing/bar-time.js +44 -0
  130. package/dist/esm/drawing/bar-time.js.map +1 -0
  131. package/dist/esm/drawing/output.d.ts +32 -0
  132. package/dist/esm/drawing/output.d.ts.map +1 -0
  133. package/dist/esm/drawing/output.js +190 -0
  134. package/dist/esm/drawing/output.js.map +1 -0
  135. package/dist/esm/drawing/registry.d.ts +5 -4
  136. package/dist/esm/drawing/registry.d.ts.map +1 -1
  137. package/dist/esm/drawing/registry.js +12 -2
  138. package/dist/esm/drawing/registry.js.map +1 -1
  139. package/dist/esm/index.d.ts +6 -3
  140. package/dist/esm/index.d.ts.map +1 -1
  141. package/dist/esm/index.js +7 -3
  142. package/dist/esm/index.js.map +1 -1
  143. package/dist/esm/label/index.d.ts.map +1 -1
  144. package/dist/esm/label/index.js +2 -1
  145. package/dist/esm/label/index.js.map +1 -1
  146. package/dist/esm/linefill/index.d.ts.map +1 -1
  147. package/dist/esm/linefill/index.js +3 -0
  148. package/dist/esm/linefill/index.js.map +1 -1
  149. package/dist/esm/math/index.d.ts +76 -21
  150. package/dist/esm/math/index.d.ts.map +1 -1
  151. package/dist/esm/math/index.js +227 -61
  152. package/dist/esm/math/index.js.map +1 -1
  153. package/dist/esm/matrix/index.d.ts.map +1 -1
  154. package/dist/esm/matrix/index.js +57 -43
  155. package/dist/esm/matrix/index.js.map +1 -1
  156. package/dist/esm/polyline/index.d.ts +3 -5
  157. package/dist/esm/polyline/index.d.ts.map +1 -1
  158. package/dist/esm/polyline/index.js +3 -9
  159. package/dist/esm/polyline/index.js.map +1 -1
  160. package/dist/esm/runtime/series.d.ts +9 -0
  161. package/dist/esm/runtime/series.d.ts.map +1 -1
  162. package/dist/esm/runtime/series.js +18 -1
  163. package/dist/esm/runtime/series.js.map +1 -1
  164. package/dist/esm/runtime/types.d.ts +22 -0
  165. package/dist/esm/runtime/types.d.ts.map +1 -1
  166. package/dist/esm/script/index.d.ts +97 -36
  167. package/dist/esm/script/index.d.ts.map +1 -1
  168. package/dist/esm/script/index.js +211 -22
  169. package/dist/esm/script/index.js.map +1 -1
  170. package/dist/esm/session/calendar.d.ts.map +1 -1
  171. package/dist/esm/session/calendar.js +22 -2
  172. package/dist/esm/session/calendar.js.map +1 -1
  173. package/dist/esm/str/index.d.ts +50 -38
  174. package/dist/esm/str/index.d.ts.map +1 -1
  175. package/dist/esm/str/index.js +103 -52
  176. package/dist/esm/str/index.js.map +1 -1
  177. package/dist/esm/str/messageformat.d.ts +2 -1
  178. package/dist/esm/str/messageformat.d.ts.map +1 -1
  179. package/dist/esm/str/messageformat.js +7 -2
  180. package/dist/esm/str/messageformat.js.map +1 -1
  181. package/dist/esm/str/numberformat.d.ts +4 -0
  182. package/dist/esm/str/numberformat.d.ts.map +1 -1
  183. package/dist/esm/str/numberformat.js +38 -4
  184. package/dist/esm/str/numberformat.js.map +1 -1
  185. package/dist/esm/ta/index.d.ts +86 -43
  186. package/dist/esm/ta/index.d.ts.map +1 -1
  187. package/dist/esm/ta/index.js +296 -348
  188. package/dist/esm/ta/index.js.map +1 -1
  189. package/dist/esm/ta/running-sum.d.ts +54 -2
  190. package/dist/esm/ta/running-sum.d.ts.map +1 -1
  191. package/dist/esm/ta/running-sum.js +166 -71
  192. package/dist/esm/ta/running-sum.js.map +1 -1
  193. package/dist/esm/ta-series.d.ts +4 -4
  194. package/dist/esm/ta-series.d.ts.map +1 -1
  195. package/dist/esm/ta-series.js +5 -4
  196. package/dist/esm/ta-series.js.map +1 -1
  197. package/dist/esm/table/index.d.ts +87 -0
  198. package/dist/esm/table/index.d.ts.map +1 -0
  199. package/dist/esm/table/index.js +169 -0
  200. package/dist/esm/table/index.js.map +1 -0
  201. package/dist/esm/text/index.d.ts +17 -2
  202. package/dist/esm/text/index.d.ts.map +1 -1
  203. package/dist/esm/text/index.js +17 -2
  204. package/dist/esm/text/index.js.map +1 -1
  205. package/dist/esm/time/datestring.d.ts +1 -0
  206. package/dist/esm/time/datestring.d.ts.map +1 -1
  207. package/dist/esm/time/datestring.js +12 -0
  208. package/dist/esm/time/datestring.js.map +1 -1
  209. package/dist/esm/time/index.d.ts.map +1 -1
  210. package/dist/esm/time/index.js +3 -1
  211. package/dist/esm/time/index.js.map +1 -1
  212. package/dist/esm/time/session.d.ts +28 -9
  213. package/dist/esm/time/session.d.ts.map +1 -1
  214. package/dist/esm/time/session.js +113 -42
  215. package/dist/esm/time/session.js.map +1 -1
  216. package/dist/esm/time/timezone.d.ts +5 -0
  217. package/dist/esm/time/timezone.d.ts.map +1 -1
  218. package/dist/esm/time/timezone.js +21 -1
  219. package/dist/esm/time/timezone.js.map +1 -1
  220. package/dist/esm/types/index.d.ts +30 -1
  221. package/dist/esm/types/index.d.ts.map +1 -1
  222. package/dist/esm/types/index.js +14 -0
  223. package/dist/esm/types/index.js.map +1 -1
  224. package/dist/esm/types/metadata.d.ts +258 -26
  225. package/dist/esm/types/metadata.d.ts.map +1 -1
  226. package/package.json +1 -1
  227. package/src/array/index.ts +364 -150
  228. package/src/callsite/index.ts +147 -3
  229. package/src/color/index.ts +15 -5
  230. package/src/drawing/bar-time.ts +42 -0
  231. package/src/drawing/output.ts +214 -0
  232. package/src/drawing/registry.ts +16 -6
  233. package/src/index.ts +9 -3
  234. package/src/label/index.ts +2 -1
  235. package/src/linefill/index.ts +2 -0
  236. package/src/math/index.ts +256 -74
  237. package/src/matrix/index.ts +52 -52
  238. package/src/polyline/index.ts +3 -12
  239. package/src/runtime/series.ts +22 -1
  240. package/src/runtime/types.ts +23 -0
  241. package/src/script/index.ts +307 -25
  242. package/src/session/calendar.ts +22 -2
  243. package/src/str/index.ts +95 -51
  244. package/src/str/messageformat.ts +7 -2
  245. package/src/str/numberformat.ts +39 -4
  246. package/src/ta/index.ts +306 -386
  247. package/src/ta/running-sum.ts +187 -74
  248. package/src/ta-series.ts +8 -7
  249. package/src/table/index.ts +221 -0
  250. package/src/text/index.ts +18 -2
  251. package/src/time/datestring.ts +10 -0
  252. package/src/time/index.ts +3 -1
  253. package/src/time/session.ts +97 -47
  254. package/src/time/timezone.ts +21 -1
  255. package/src/types/index.ts +32 -1
  256. package/src/types/metadata.ts +325 -26
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/color/index.ts"],
4
- "sourcesContent": ["/**\n * Color namespace\n * Mirrors PineScript's color.* functions for color creation and manipulation.\n *\n * @remarks\n * All color functions in this namespace follow PineScript v6 API specifications.\n * Colors are represented as RGB or RGBA strings.\n * Transparency values range from 0 (fully opaque) to 100 (fully transparent).\n *\n * @version 6\n */\n\nimport type { color, int, float, simple_int, simple_float } from '../types/index.js';\nimport { alphaByte, parseColor } from './parse.js';\n\n/** Channel of color.rgb: na is 0, a fraction is truncated. */\nconst channel = (v: number): int =>\n v === null || v === undefined || Number.isNaN(v) ? 0 : Math.max(0, Math.min(255, Math.trunc(v)));\n\n/**\n * Alpha (0-1) of a transparency given to color.rgb / color.new: na is fully transparent, clamped to 0..100.\n * `1 - t / 100` as in PineScript: `color.new(c, 90)` has the alpha byte 25 (0.09999999999999998 * 255 rounded).\n */\nconst alphaOf = (transp: number): float =>\n transp === null || Number.isNaN(transp) ? 0 : 1 - Math.max(0, Math.min(100, transp)) / 100;\n\n/**\n * Creates a color from RGB values with optional transparency.\n *\n * @param red - Red component (0-255, values are clamped)\n * @param green - Green component (0-255, values are clamped)\n * @param blue - Blue component (0-255, values are clamped)\n * @param transp - Optional transparency (0-100). 0 = opaque, 100 = fully transparent\n * @returns Color string in rgb() or rgba() format\n *\n * @remarks\n * - RGB values are automatically clamped to the 0-255 range\n * - Transparency of 0 or omitted results in rgb() format\n * - Transparency > 0 results in rgba() format\n * - Transparency is converted to alpha channel (0-1 range)\n *\n * PineScript rules:\n * - an `na` channel is 0; a fractional channel is truncated (127.6 is 127)\n * - the transparency is clamped to 0..100 (140 is fully transparent, -5 is opaque); an `na` transparency is fully\n * transparent\n *\n * @example\n * ```typescript\n * color.rgb(255, 0, 0) // Returns: \"rgb(255, 0, 0)\" - Red\n * color.rgb(0, 255, 0, 50) // Returns: \"rgba(0, 255, 0, 0.5)\" - Semi-transparent green\n * color.rgb(300, 0, 0) // Returns: \"rgb(255, 0, 0)\" - Clamped to 255\n * ```\n */\nexport function rgb(red: simple_int, green: simple_int, blue: simple_int, transp?: simple_float): string {\n const r = channel(red);\n const g = channel(green);\n const b = channel(blue);\n const a = transp !== undefined ? alphaOf(transp) : 1;\n\n if (a === 1) {\n return `rgb(${r}, ${g}, ${b})`;\n }\n return `rgba(${r}, ${g}, ${b}, ${a})`;\n}\n\n/**\n * Creates a color from a hexadecimal string with optional transparency.\n *\n * @param hex - Hex color string (with or without '#' prefix, e.g., \"#FF0000\" or \"FF0000\")\n * @param transp - Optional transparency (0-100). 0 = opaque, 100 = fully transparent\n * @returns Color string in rgb() or rgba() format\n *\n * @remarks\n * - Accepts hex strings with or without '#' prefix\n * - Case-insensitive (accepts both \"FF0000\" and \"ff0000\")\n * - Must be 6 characters (excluding '#')\n * - Format: RRGGBB where each component is 00-FF\n *\n * @example\n * ```typescript\n * color.from_hex(\"#FF0000\") // Returns: \"rgb(255, 0, 0)\" - Red\n * color.from_hex(\"00FF00\", 50) // Returns: \"rgba(0, 255, 0, 0.5)\" - Semi-transparent green\n * color.from_hex(\"#0000FF\") // Returns: \"rgb(0, 0, 255)\" - Blue\n * color.from_hex(\"FFA500\") // Returns: \"rgb(255, 165, 0)\" - Orange\n * ```\n */\nexport function from_hex(hex: string, transp?: simple_float): string {\n // Remove # if present\n hex = hex.replace('#', '');\n\n const r = parseInt(hex.substring(0, 2), 16);\n const g = parseInt(hex.substring(2, 4), 16);\n const b = parseInt(hex.substring(4, 6), 16);\n\n return rgb(r, g, b, transp);\n}\n\n/**\n * Creates a new color with modified transparency, preserving RGB components.\n *\n * @param baseColor - The base color to modify\n * @param transp - New transparency value (0-100). 0 = opaque, 100 = fully transparent\n * @returns New color with updated transparency\n *\n * @remarks\n * - Preserves the RGB values from the base color\n * - Replaces the transparency with the new value\n * - Useful for creating semi-transparent versions of existing colors\n * - PineScript clamps the transparency to 0..100 (`color.new(c, 140)` is fully transparent, `color.new(c, -5)` is\n * opaque); an `na` transparency is fully transparent\n *\n * @example\n * ```typescript\n * const red = color.rgb(255, 0, 0)\n * color.new_color(red, 50) // Returns: \"rgba(255, 0, 0, 0.5)\" - Semi-transparent red\n * color.new_color(red, 0) // Returns: \"rgb(255, 0, 0)\" - Fully opaque\n * color.new_color(red, 100) // Returns: \"rgba(255, 0, 0, 0)\" - Fully transparent\n * ```\n */\nexport function new_color(baseColor: color, transp: simple_float): string {\n // Parse the color and apply transparency\n const rgba = parseColor(baseColor);\n return rgb(rgba.r, rgba.g, rgba.b, transp);\n}\n\n/**\n * Extracts the red component from a color.\n *\n * @param clr - The color to extract from\n * @returns Red component value (0-255)\n *\n * @example\n * ```typescript\n * color.r(color.rgb(255, 128, 64)) // Returns: 255\n * color.r(color.from_hex(\"#FF0000\")) // Returns: 255\n * color.r(color.from_hex(\"#FFA500\")) // Returns: 255 (orange)\n * ```\n */\nexport function r(clr: color): int {\n return parseColor(clr).r;\n}\n\n/**\n * Extracts the green component from a color.\n *\n * @param clr - The color to extract from\n * @returns Green component value (0-255)\n *\n * @example\n * ```typescript\n * color.g(color.rgb(255, 128, 64)) // Returns: 128\n * color.g(color.from_hex(\"#00FF00\")) // Returns: 255\n * color.g(color.from_hex(\"#FFA500\")) // Returns: 165 (orange)\n * ```\n */\nexport function g(clr: color): int {\n return parseColor(clr).g;\n}\n\n/**\n * Extracts the blue component from a color.\n *\n * @param clr - The color to extract from\n * @returns Blue component value (0-255)\n *\n * @example\n * ```typescript\n * color.b(color.rgb(255, 128, 64)) // Returns: 64\n * color.b(color.from_hex(\"#0000FF\")) // Returns: 255\n * color.b(color.from_hex(\"#FFA500\")) // Returns: 0 (orange)\n * ```\n */\nexport function b(clr: color): int {\n return parseColor(clr).b;\n}\n\n/**\n * Extracts the transparency component from a color.\n *\n * @param clr - The color to extract from\n * @returns Transparency value (0-100). 0 = fully opaque, 100 = fully transparent\n *\n * @remarks\n * - Returns 0 for colors without transparency (rgb format)\n * - Converts alpha channel (0-1) to transparency (0-100)\n * - PineScript stores the alpha as a byte (0-255) and returns an integer transparency:\n * `color.t(color.new(c, 33.3))` is 33\n *\n * @example\n * ```typescript\n * color.t(color.rgb(255, 0, 0)) // Returns: 0 (opaque)\n * color.t(color.rgb(255, 0, 0, 50)) // Returns: 50\n * color.t(color.rgb(255, 0, 0, 100)) // Returns: 100 (fully transparent)\n * ```\n */\nexport function t(clr: color): float {\n return Math.round((1 - alphaByte(parseColor(clr).a) / 255) * 100);\n}\n\n// Predefined color constants of PineScript v6.\n// PineScript v5 differs for red (#FF5252), teal (#00897B) and yellow (#FFEB3B).\n/**\n * Aqua/Cyan color constant\n * @constant {string} #00BCD4 - RGB(0, 188, 212)\n */\nexport const aqua = '#00BCD4';\n\n/**\n * Black color constant\n * @constant {string} #363A45 - RGB(54, 58, 69)\n */\nexport const black = '#363A45';\n\n/**\n * Blue color constant\n * @constant {string} #2962FF - RGB(41, 98, 255)\n */\nexport const blue = '#2962FF';\n\n/**\n * Fuchsia/Magenta color constant\n * @constant {string} #E040FB - RGB(224, 64, 251)\n */\nexport const fuchsia = '#E040FB';\n\n/**\n * Gray color constant\n * @constant {string} #787B86 - RGB(120, 123, 134)\n */\nexport const gray = '#787B86';\n\n/**\n * Green color constant (same as lime)\n * @constant {string} #4CAF50 - RGB(76, 175, 80)\n */\nexport const green = '#4CAF50';\n\n/**\n * Lime color constant (same as green)\n * @constant {string} #00E676 - RGB(0, 230, 118)\n */\nexport const lime = '#00E676';\n\n/**\n * Maroon color constant\n * @constant {string} #880E4F - RGB(136, 14, 79)\n */\nexport const maroon = '#880E4F';\n\n/**\n * Navy color constant\n * @constant {string} #311B92 - RGB(49, 27, 146)\n */\nexport const navy = '#311B92';\n\n/**\n * Olive color constant\n * @constant {string} #808000 - RGB(128, 128, 0)\n */\nexport const olive = '#808000';\n\n/**\n * Orange color constant\n * @constant {string} #FF9800 - RGB(255, 152, 0)\n */\nexport const orange = '#FF9800';\n\n/**\n * Purple color constant\n * @constant {string} #9C27B0 - RGB(156, 39, 176)\n */\nexport const purple = '#9C27B0';\n\n/**\n * Red color constant\n * @constant {string} #F23645 - RGB(242, 54, 69)\n */\nexport const red = '#F23645';\n\n/**\n * Silver color constant\n * @constant {string} #B2B5BE - RGB(178, 181, 190)\n */\nexport const silver = '#B2B5BE';\n\n/**\n * Teal color constant\n * @constant {string} #089981 - RGB(8, 153, 129)\n */\nexport const teal = '#089981';\n\n/**\n * White color constant\n * @constant {string} #FFFFFF - RGB(255, 255, 255)\n */\nexport const white = '#FFFFFF';\n\n/**\n * Yellow color constant\n * @constant {string} #FDD835 - RGB(253, 216, 53)\n */\nexport const yellow = '#FDD835';\n\n/**\n * Creates a color from a gradient based on value position.\n *\n * @param value - Value to calculate position-dependent color\n * @param bottom_value - Bottom position value corresponding to bottom_color\n * @param top_value - Top position value corresponding to top_color\n * @param bottom_color - Bottom position color\n * @param top_color - Top position color\n * @returns Color calculated from linear gradient\n *\n * @remarks\n * PineScript rules:\n * - If value <= bottom_value, returns bottom_color; else if value >= top_value, returns top_color\n * - An inverted range (bottom_value > top_value) returns bottom_color, wherever the value is\n * - Otherwise the colours are mixed with their transparency (premultiplied alpha, alpha as a byte); the RGB channels\n * and the alpha are truncated. PineScript's float rounding order is not known: a channel can differ by 1 when the\n * exact result is an integer (same RGB at both ends)\n * - An na value or bottom_value / top_value, or bottom_value == top_value, gives a fully transparent colour\n * - An na colour counts as fully transparent\n * - Works with rgb(), rgba() and hex (#RRGGBB, #RRGGBBAA) colours\n *\n * @example\n * ```typescript\n * // Value at middle of range gets middle color\n * const midColor = color.from_gradient(50, 0, 100,\n * color.rgb(255, 0, 0), // Red at bottom\n * color.rgb(0, 255, 0) // Green at top\n * ); // Returns color between red and green\n *\n * // Value at extremes\n * const lowColor = color.from_gradient(-10, 0, 100, red, green); // Returns red\n * const highColor = color.from_gradient(150, 0, 100, red, green); // Returns green\n * ```\n */\nexport function from_gradient(\n value: float,\n bottom_value: float,\n top_value: float,\n bottom_color: color,\n top_color: color\n): string {\n const transparent = 'rgba(0, 0, 0, 0)';\n if ([value, bottom_value, top_value].some((v) => v === null || v === undefined || Number.isNaN(v)) || bottom_value === top_value) {\n return transparent;\n }\n const k =\n value <= bottom_value || bottom_value > top_value\n ? 0\n : value >= top_value\n ? 1\n : (value - bottom_value) / (top_value - bottom_value);\n // alpha as a byte (0-255), as PineScript stores it; an na colour (null / undefined) is fully transparent\n const rgba = (c: color) => {\n if (c === null || c === undefined) return { r: 0, g: 0, b: 0, a: 0 };\n const p = parseColor(c);\n return { r: p.r, g: p.g, b: p.b, a: alphaByte(p.a) };\n };\n const c1 = rgba(bottom_color);\n const c2 = rgba(top_color);\n const a = c1.a * (1 - k) + c2.a * k;\n if (a === 0) return transparent;\n // operation order with the fewest differences to PineScript (channels as 0-1, alpha as a byte)\n const mix = (x1: number, x2: number) => Math.floor((((x1 / 255) * c1.a) * (1 - k) + ((x2 / 255) * c2.a) * k) / (a / 255));\n const [r, g, b] = [mix(c1.r, c2.r), mix(c1.g, c2.g), mix(c1.b, c2.b)];\n const alpha = Math.floor(a);\n return alpha === 255 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${alpha / 255})`;\n}\n\n/**\n * Alias for new_color function.\n * Creates a new color with specified transparency from an existing color.\n *\n * @param baseColor - The base color\n * @param transp - Transparency value (0-100). 0 = fully opaque, 100 = fully transparent\n * @returns New color with applied transparency\n *\n * @remarks\n * This is an alias for `new_color()` to match PineScript's `color.new()` syntax.\n *\n * @example\n * ```typescript\n * const redColor = color.rgb(255, 0, 0);\n * const transparentRed = color.new(redColor, 50); // 50% transparent red\n * ```\n */\nexport { new_color as new };\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;AAAA;AAAA;AAaA,mBAAsC;AAGtC,MAAM,UAAU,CAAC,MACf,MAAM,QAAQ,MAAM,UAAa,OAAO,MAAM,CAAC,IAAI,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC;AAMjG,MAAM,UAAU,CAAC,WACf,WAAW,QAAQ,OAAO,MAAM,MAAM,IAAI,IAAI,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,MAAM,CAAC,IAAI;AA6BlF,SAAS,IAAIA,MAAiBC,QAAmBC,OAAkB,QAA+B;AACvG,QAAMC,KAAI,QAAQH,IAAG;AACrB,QAAMI,KAAI,QAAQH,MAAK;AACvB,QAAMI,KAAI,QAAQH,KAAI;AACtB,QAAM,IAAI,WAAW,SAAY,QAAQ,MAAM,IAAI;AAEnD,MAAI,MAAM,GAAG;AACX,WAAO,OAAOC,EAAC,KAAKC,EAAC,KAAKC,EAAC;AAAA,EAC7B;AACA,SAAO,QAAQF,EAAC,KAAKC,EAAC,KAAKC,EAAC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AAM,CAAC,CAAC,KAAK,iBAAiB,WAAW;AAChI,WAAO;AAAA,EACT;AACA,QAAM,IACJ,SAAS,gBAAgB,eAAe,YACpC,IACA,SAAS,YACP,KACC,QAAQ,iBAAiB,YAAY;AAE9C,QAAM,OAAO,CAAC,MAAa;AACzB,QAAI,MAAM,QAAQ,MAAM,OAAW,QAAO,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AACnE,UAAM,QAAI,yBAAW,CAAC;AACtB,WAAO,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,GAAG,OAAG,wBAAU,EAAE,CAAC,EAAE;AAAA,EACrD;AACA,QAAM,KAAK,KAAK,YAAY;AAC5B,QAAM,KAAK,KAAK,SAAS;AACzB,QAAM,IAAI,GAAG,KAAK,IAAI,KAAK,GAAG,IAAI;AAClC,MAAI,MAAM,EAAG,QAAO;AAEpB,QAAM,MAAM,CAAC,IAAY,OAAe,KAAK,OAAS,KAAK,MAAO,GAAG,KAAM,IAAI,KAAO,KAAK,MAAO,GAAG,IAAK,MAAM,IAAI,IAAI;AACxH,QAAM,CAACF,IAAGC,IAAGC,EAAC,IAAI,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC;AACpE,QAAM,QAAQ,KAAK,MAAM,CAAC;AAC1B,SAAO,UAAU,MAAM,OAAOF,EAAC,KAAKC,EAAC,KAAKC,EAAC,MAAM,QAAQF,EAAC,KAAKC,EAAC,KAAKC,EAAC,KAAK,QAAQ,GAAG;AACxF;",
4
+ "sourcesContent": ["/**\n * Color namespace\n * Mirrors PineScript's color.* functions for color creation and manipulation.\n *\n * @remarks\n * All color functions in this namespace follow PineScript v6 API specifications.\n * Colors are represented as RGB or RGBA strings.\n * Transparency values range from 0 (fully opaque) to 100 (fully transparent).\n *\n * @version 6\n */\n\nimport type { color, int, float, simple_int, simple_float } from '../types/index.js';\nimport { alphaByte, parseColor } from './parse.js';\n\n/** Channel of color.rgb: na is 0, a fraction is truncated. */\nconst channel = (v: number): int =>\n v === null || v === undefined || Number.isNaN(v) ? 0 : Math.max(0, Math.min(255, Math.trunc(v)));\n\n/**\n * Alpha (0-1) of a transparency given to color.rgb / color.new: na is fully transparent, clamped to 0..100.\n * `1 - t / 100` as in PineScript: `color.new(c, 90)` has the alpha byte 25 (0.09999999999999998 * 255 rounded).\n */\nconst alphaOf = (transp: number): float =>\n transp === null || Number.isNaN(transp) ? 0 : 1 - Math.max(0, Math.min(100, transp)) / 100;\n\n/**\n * Creates a color from RGB values with optional transparency.\n *\n * @param red - Red component (0-255, values are clamped)\n * @param green - Green component (0-255, values are clamped)\n * @param blue - Blue component (0-255, values are clamped)\n * @param transp - Optional transparency (0-100). 0 = opaque, 100 = fully transparent\n * @returns Color string in rgb() or rgba() format\n *\n * @remarks\n * - RGB values are automatically clamped to the 0-255 range\n * - Transparency of 0 or omitted results in rgb() format\n * - Transparency > 0 results in rgba() format\n * - Transparency is converted to alpha channel (0-1 range)\n *\n * PineScript rules:\n * - an `na` channel is 0; a fractional channel is truncated (127.6 is 127)\n * - the transparency is clamped to 0..100 (140 is fully transparent, -5 is opaque); an `na` transparency is fully\n * transparent\n *\n * @example\n * ```typescript\n * color.rgb(255, 0, 0) // Returns: \"rgb(255, 0, 0)\" - Red\n * color.rgb(0, 255, 0, 50) // Returns: \"rgba(0, 255, 0, 0.5)\" - Semi-transparent green\n * color.rgb(300, 0, 0) // Returns: \"rgb(255, 0, 0)\" - Clamped to 255\n * ```\n */\nexport function rgb(red: simple_int, green: simple_int, blue: simple_int, transp?: simple_float): string {\n const r = channel(red);\n const g = channel(green);\n const b = channel(blue);\n const a = transp !== undefined ? alphaOf(transp) : 1;\n\n if (a === 1) {\n return `rgb(${r}, ${g}, ${b})`;\n }\n return `rgba(${r}, ${g}, ${b}, ${a})`;\n}\n\n/**\n * Creates a color from a hexadecimal string with optional transparency.\n *\n * @param hex - Hex color string (with or without '#' prefix, e.g., \"#FF0000\" or \"FF0000\")\n * @param transp - Optional transparency (0-100). 0 = opaque, 100 = fully transparent\n * @returns Color string in rgb() or rgba() format\n *\n * @remarks\n * - Accepts hex strings with or without '#' prefix\n * - Case-insensitive (accepts both \"FF0000\" and \"ff0000\")\n * - Must be 6 characters (excluding '#')\n * - Format: RRGGBB where each component is 00-FF\n *\n * @example\n * ```typescript\n * color.from_hex(\"#FF0000\") // Returns: \"rgb(255, 0, 0)\" - Red\n * color.from_hex(\"00FF00\", 50) // Returns: \"rgba(0, 255, 0, 0.5)\" - Semi-transparent green\n * color.from_hex(\"#0000FF\") // Returns: \"rgb(0, 0, 255)\" - Blue\n * color.from_hex(\"FFA500\") // Returns: \"rgb(255, 165, 0)\" - Orange\n * ```\n */\nexport function from_hex(hex: string, transp?: simple_float): string {\n // Remove # if present\n hex = hex.replace('#', '');\n\n const r = parseInt(hex.substring(0, 2), 16);\n const g = parseInt(hex.substring(2, 4), 16);\n const b = parseInt(hex.substring(4, 6), 16);\n\n return rgb(r, g, b, transp);\n}\n\n/**\n * Creates a new color with modified transparency, preserving RGB components.\n *\n * @param baseColor - The base color to modify\n * @param transp - New transparency value (0-100). 0 = opaque, 100 = fully transparent\n * @returns New color with updated transparency\n *\n * @remarks\n * - Preserves the RGB values from the base color\n * - Replaces the transparency with the new value\n * - Useful for creating semi-transparent versions of existing colors\n * - PineScript clamps the transparency to 0..100 (`color.new(c, 140)` is fully transparent, `color.new(c, -5)` is\n * opaque); an `na` transparency is fully transparent (measured: the colour is not na, its RGB is kept)\n * - an `na` colour (null / undefined) gives black with the new transparency: `color.new(na, 30)` is\n * `rgba(0, 0, 0, 0.7)`, as PineScript does for an na colour variable (measured, #150). In PineScript, the constant\n * `color.new(color(na), 30)` is computed at compile time and stays na; a JS function cannot tell the two apart.\n *\n * @example\n * ```typescript\n * const red = color.rgb(255, 0, 0)\n * color.new_color(red, 50) // Returns: \"rgba(255, 0, 0, 0.5)\" - Semi-transparent red\n * color.new_color(red, 0) // Returns: \"rgb(255, 0, 0)\" - Fully opaque\n * color.new_color(red, 100) // Returns: \"rgba(255, 0, 0, 0)\" - Fully transparent\n * ```\n */\nexport function new_color(baseColor: color | null | undefined, transp: simple_float): string {\n if (baseColor === null || baseColor === undefined) return rgb(0, 0, 0, transp); // na colour: black\n // Parse the color and apply transparency\n const rgba = parseColor(baseColor);\n return rgb(rgba.r, rgba.g, rgba.b, transp);\n}\n\n/**\n * Extracts the red component from a color.\n *\n * @param clr - The color to extract from\n * @returns Red component value (0-255)\n *\n * @example\n * ```typescript\n * color.r(color.rgb(255, 128, 64)) // Returns: 255\n * color.r(color.from_hex(\"#FF0000\")) // Returns: 255\n * color.r(color.from_hex(\"#FFA500\")) // Returns: 255 (orange)\n * ```\n */\nexport function r(clr: color): int {\n return parseColor(clr).r;\n}\n\n/**\n * Extracts the green component from a color.\n *\n * @param clr - The color to extract from\n * @returns Green component value (0-255)\n *\n * @example\n * ```typescript\n * color.g(color.rgb(255, 128, 64)) // Returns: 128\n * color.g(color.from_hex(\"#00FF00\")) // Returns: 255\n * color.g(color.from_hex(\"#FFA500\")) // Returns: 165 (orange)\n * ```\n */\nexport function g(clr: color): int {\n return parseColor(clr).g;\n}\n\n/**\n * Extracts the blue component from a color.\n *\n * @param clr - The color to extract from\n * @returns Blue component value (0-255)\n *\n * @example\n * ```typescript\n * color.b(color.rgb(255, 128, 64)) // Returns: 64\n * color.b(color.from_hex(\"#0000FF\")) // Returns: 255\n * color.b(color.from_hex(\"#FFA500\")) // Returns: 0 (orange)\n * ```\n */\nexport function b(clr: color): int {\n return parseColor(clr).b;\n}\n\n/**\n * Extracts the transparency component from a color.\n *\n * @param clr - The color to extract from\n * @returns Transparency value (0-100). 0 = fully opaque, 100 = fully transparent\n *\n * @remarks\n * - Returns 0 for colors without transparency (rgb format)\n * - Converts alpha channel (0-1) to transparency (0-100)\n * - PineScript stores the alpha as a byte (0-255) and returns an integer transparency:\n * `color.t(color.new(c, 33.3))` is 33\n * - an `na` colour (null / undefined) is fully transparent: 100\n *\n * @example\n * ```typescript\n * color.t(color.rgb(255, 0, 0)) // Returns: 0 (opaque)\n * color.t(color.rgb(255, 0, 0, 50)) // Returns: 50\n * color.t(color.rgb(255, 0, 0, 100)) // Returns: 100 (fully transparent)\n * ```\n */\nexport function t(clr: color | null | undefined): float {\n if (clr === null || clr === undefined) return 100;\n return Math.round((1 - alphaByte(parseColor(clr).a) / 255) * 100);\n}\n\n// Predefined color constants of PineScript v6.\n// PineScript v5 differs for red (#FF5252), teal (#00897B) and yellow (#FFEB3B).\n/**\n * Aqua/Cyan color constant\n * @constant {string} #00BCD4 - RGB(0, 188, 212)\n */\nexport const aqua = '#00BCD4';\n\n/**\n * Black color constant\n * @constant {string} #363A45 - RGB(54, 58, 69)\n */\nexport const black = '#363A45';\n\n/**\n * Blue color constant\n * @constant {string} #2962FF - RGB(41, 98, 255)\n */\nexport const blue = '#2962FF';\n\n/**\n * Fuchsia/Magenta color constant\n * @constant {string} #E040FB - RGB(224, 64, 251)\n */\nexport const fuchsia = '#E040FB';\n\n/**\n * Gray color constant\n * @constant {string} #787B86 - RGB(120, 123, 134)\n */\nexport const gray = '#787B86';\n\n/**\n * Green color constant (same as lime)\n * @constant {string} #4CAF50 - RGB(76, 175, 80)\n */\nexport const green = '#4CAF50';\n\n/**\n * Lime color constant (same as green)\n * @constant {string} #00E676 - RGB(0, 230, 118)\n */\nexport const lime = '#00E676';\n\n/**\n * Maroon color constant\n * @constant {string} #880E4F - RGB(136, 14, 79)\n */\nexport const maroon = '#880E4F';\n\n/**\n * Navy color constant\n * @constant {string} #311B92 - RGB(49, 27, 146)\n */\nexport const navy = '#311B92';\n\n/**\n * Olive color constant\n * @constant {string} #808000 - RGB(128, 128, 0)\n */\nexport const olive = '#808000';\n\n/**\n * Orange color constant\n * @constant {string} #FF9800 - RGB(255, 152, 0)\n */\nexport const orange = '#FF9800';\n\n/**\n * Purple color constant\n * @constant {string} #9C27B0 - RGB(156, 39, 176)\n */\nexport const purple = '#9C27B0';\n\n/**\n * Red color constant\n * @constant {string} #F23645 - RGB(242, 54, 69)\n */\nexport const red = '#F23645';\n\n/**\n * Silver color constant\n * @constant {string} #B2B5BE - RGB(178, 181, 190)\n */\nexport const silver = '#B2B5BE';\n\n/**\n * Teal color constant\n * @constant {string} #089981 - RGB(8, 153, 129)\n */\nexport const teal = '#089981';\n\n/**\n * White color constant\n * @constant {string} #FFFFFF - RGB(255, 255, 255)\n */\nexport const white = '#FFFFFF';\n\n/**\n * Yellow color constant\n * @constant {string} #FDD835 - RGB(253, 216, 53)\n */\nexport const yellow = '#FDD835';\n\n/**\n * Creates a color from a gradient based on value position.\n *\n * @param value - Value to calculate position-dependent color\n * @param bottom_value - Bottom position value corresponding to bottom_color\n * @param top_value - Top position value corresponding to top_color\n * @param bottom_color - Bottom position color\n * @param top_color - Top position color\n * @returns Color calculated from linear gradient\n *\n * @remarks\n * PineScript rules:\n * - If value <= bottom_value, returns bottom_color; else if value >= top_value, returns top_color\n * - An inverted range (bottom_value > top_value) returns bottom_color, wherever the value is\n * - Otherwise the colours are mixed with their transparency (premultiplied alpha, alpha as a byte); the RGB channels\n * and the alpha are truncated. PineScript's float rounding order is not known: a channel can differ by 1 when the\n * exact result is an integer (same RGB at both ends)\n * - An na value or bottom_value / top_value, or bottom_value == top_value, gives a fully transparent colour\n * - An na colour counts as fully transparent\n * - Works with rgb(), rgba() and hex (#RRGGBB, #RRGGBBAA) colours\n *\n * @example\n * ```typescript\n * // Value at middle of range gets middle color\n * const midColor = color.from_gradient(50, 0, 100,\n * color.rgb(255, 0, 0), // Red at bottom\n * color.rgb(0, 255, 0) // Green at top\n * ); // Returns color between red and green\n *\n * // Value at extremes\n * const lowColor = color.from_gradient(-10, 0, 100, red, green); // Returns red\n * const highColor = color.from_gradient(150, 0, 100, red, green); // Returns green\n * ```\n */\nexport function from_gradient(\n value: float,\n bottom_value: float,\n top_value: float,\n bottom_color: color,\n top_color: color\n): string {\n const transparent = 'rgba(0, 0, 0, 0)';\n if ([value, bottom_value, top_value].some((v) => v === null || v === undefined || Number.isNaN(v)) || bottom_value === top_value) {\n return transparent;\n }\n const k =\n value <= bottom_value || bottom_value > top_value\n ? 0\n : value >= top_value\n ? 1\n : (value - bottom_value) / (top_value - bottom_value);\n // alpha as a byte (0-255), as PineScript stores it; an na colour (null / undefined) is fully transparent\n const rgba = (c: color) => {\n if (c === null || c === undefined) return { r: 0, g: 0, b: 0, a: 0 };\n const p = parseColor(c);\n return { r: p.r, g: p.g, b: p.b, a: alphaByte(p.a) };\n };\n const c1 = rgba(bottom_color);\n const c2 = rgba(top_color);\n const a = c1.a * (1 - k) + c2.a * k;\n if (a === 0) return transparent;\n // PineScript order (bit for bit, #146): premultiplied channels ((alpha / 255) * channel) * weight, divided by the\n // byte-alpha mix / 255, truncated. At an end (k = 0 / 1) this is floor(x * a / a): the end colour or one unit less.\n const scale = a / 255;\n const w1 = c1.a / 255;\n const w2 = c2.a / 255;\n const mix = (x1: number, x2: number) => Math.floor(((w1 * x1) * (1 - k) + (w2 * x2) * k) / scale);\n const [r, g, b] = [mix(c1.r, c2.r), mix(c1.g, c2.g), mix(c1.b, c2.b)];\n const alpha = Math.floor(a);\n return alpha === 255 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${alpha / 255})`;\n}\n\n/**\n * Alias for new_color function.\n * Creates a new color with specified transparency from an existing color.\n *\n * @param baseColor - The base color\n * @param transp - Transparency value (0-100). 0 = fully opaque, 100 = fully transparent\n * @returns New color with applied transparency\n *\n * @remarks\n * This is an alias for `new_color()` to match PineScript's `color.new()` syntax.\n *\n * @example\n * ```typescript\n * const redColor = color.rgb(255, 0, 0);\n * const transparentRed = color.new(redColor, 50); // 50% transparent red\n * ```\n */\nexport { new_color as new };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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GAAG,EAAE,GAAG,GAAG,EAAE,GAAG,OAAG,wBAAU,EAAE,CAAC,EAAE;AAAA,EACrD;AACA,QAAM,KAAK,KAAK,YAAY;AAC5B,QAAM,KAAK,KAAK,SAAS;AACzB,QAAM,IAAI,GAAG,KAAK,IAAI,KAAK,GAAG,IAAI;AAClC,MAAI,MAAM,EAAG,QAAO;AAGpB,QAAM,QAAQ,IAAI;AAClB,QAAM,KAAK,GAAG,IAAI;AAClB,QAAM,KAAK,GAAG,IAAI;AAClB,QAAM,MAAM,CAAC,IAAY,OAAe,KAAK,OAAQ,KAAK,MAAO,IAAI,KAAM,KAAK,KAAM,KAAK,KAAK;AAChG,QAAM,CAACF,IAAGC,IAAGC,EAAC,IAAI,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC;AACpE,QAAM,QAAQ,KAAK,MAAM,CAAC;AAC1B,SAAO,UAAU,MAAM,OAAOF,EAAC,KAAKC,EAAC,KAAKC,EAAC,MAAM,QAAQF,EAAC,KAAKC,EAAC,KAAKC,EAAC,KAAK,QAAQ,GAAG;AACxF;",
6
6
  "names": ["red", "green", "blue", "r", "g", "b"]
7
7
  }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Times of bars after the last bar.
3
+ *
4
+ * PineScript draws on future bars: `line.new(..., bar_index + 15, ...)`, box edges after the last bar,
5
+ * `plot(..., offset = k)`. These points get the time of the future bar: the last bar time plus k times the bar
6
+ * interval. The bar interval is the most frequent gap between two consecutive bars (1 day on daily bars even with
7
+ * weekends and holidays). A renderer that adds the same future bar slots to the chart draws a point at
8
+ * `barTime(bars, n - 1 + k)` k bars after the last bar.
9
+ *
10
+ * @module drawing/bar-time
11
+ */
12
+ /** Most frequent positive gap between consecutive bar times (in the unit of the bar times); 0 with fewer than 2 bars. */
13
+ export declare function barInterval(bars: ReadonlyArray<{
14
+ time: number;
15
+ }>): number;
16
+ /**
17
+ * Time of bar `index`: the bar time for 0 <= index < bars.length, the time of a future bar for
18
+ * index >= bars.length (last bar time + (index - last index) * barInterval(bars)). NaN for a negative or non-integer
19
+ * index, or no bar. `interval` can be passed to avoid recomputing it.
20
+ */
21
+ export declare function barTime(bars: ReadonlyArray<{
22
+ time: number;
23
+ }>, index: number, interval?: number): number;
24
+ //# sourceMappingURL=bar-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bar-time.d.ts","sourceRoot":"","sources":["../../../src/drawing/bar-time.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,yHAAyH;AACzH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,CAgBzE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAKvG"}
@@ -0,0 +1,47 @@
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 bar_time_exports = {};
20
+ __export(bar_time_exports, {
21
+ barInterval: () => barInterval,
22
+ barTime: () => barTime
23
+ });
24
+ module.exports = __toCommonJS(bar_time_exports);
25
+ function barInterval(bars) {
26
+ const counts = /* @__PURE__ */ new Map();
27
+ let best = 0;
28
+ let bestCount = 0;
29
+ for (let i = 1; i < bars.length; i++) {
30
+ const d = bars[i].time - bars[i - 1].time;
31
+ if (!(d > 0)) continue;
32
+ const c = (counts.get(d) ?? 0) + 1;
33
+ counts.set(d, c);
34
+ if (c > bestCount || c === bestCount && d < best) {
35
+ best = d;
36
+ bestCount = c;
37
+ }
38
+ }
39
+ return best;
40
+ }
41
+ function barTime(bars, index, interval) {
42
+ const n = bars.length;
43
+ if (n === 0 || index < 0 || !Number.isInteger(index)) return NaN;
44
+ if (index < n) return bars[index].time;
45
+ return bars[n - 1].time + (index - (n - 1)) * (interval ?? barInterval(bars));
46
+ }
47
+ //# sourceMappingURL=bar-time.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/drawing/bar-time.ts"],
4
+ "sourcesContent": ["/**\n * Times of bars after the last bar.\n *\n * PineScript draws on future bars: `line.new(..., bar_index + 15, ...)`, box edges after the last bar,\n * `plot(..., offset = k)`. These points get the time of the future bar: the last bar time plus k times the bar\n * interval. The bar interval is the most frequent gap between two consecutive bars (1 day on daily bars even with\n * weekends and holidays). A renderer that adds the same future bar slots to the chart draws a point at\n * `barTime(bars, n - 1 + k)` k bars after the last bar.\n *\n * @module drawing/bar-time\n */\n\n/** Most frequent positive gap between consecutive bar times (in the unit of the bar times); 0 with fewer than 2 bars. */\nexport function barInterval(bars: ReadonlyArray<{ time: number }>): number {\n const counts = new Map<number, number>();\n let best = 0;\n let bestCount = 0;\n for (let i = 1; i < bars.length; i++) {\n const d = bars[i]!.time - bars[i - 1]!.time;\n if (!(d > 0)) continue;\n const c = (counts.get(d) ?? 0) + 1;\n counts.set(d, c);\n // ties: the smaller gap\n if (c > bestCount || (c === bestCount && d < best)) {\n best = d;\n bestCount = c;\n }\n }\n return best;\n}\n\n/**\n * Time of bar `index`: the bar time for 0 <= index < bars.length, the time of a future bar for\n * index >= bars.length (last bar time + (index - last index) * barInterval(bars)). NaN for a negative or non-integer\n * index, or no bar. `interval` can be passed to avoid recomputing it.\n */\nexport function barTime(bars: ReadonlyArray<{ time: number }>, index: number, interval?: number): number {\n const n = bars.length;\n if (n === 0 || index < 0 || !Number.isInteger(index)) return NaN;\n if (index < n) return bars[index]!.time;\n return bars[n - 1]!.time + (index - (n - 1)) * (interval ?? barInterval(bars));\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,YAAY,MAA+C;AACzE,QAAM,SAAS,oBAAI,IAAoB;AACvC,MAAI,OAAO;AACX,MAAI,YAAY;AAChB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,IAAI,KAAK,CAAC,EAAG,OAAO,KAAK,IAAI,CAAC,EAAG;AACvC,QAAI,EAAE,IAAI,GAAI;AACd,UAAM,KAAK,OAAO,IAAI,CAAC,KAAK,KAAK;AACjC,WAAO,IAAI,GAAG,CAAC;AAEf,QAAI,IAAI,aAAc,MAAM,aAAa,IAAI,MAAO;AAClD,aAAO;AACP,kBAAY;AAAA,IACd;AAAA,EACF;AACA,SAAO;AACT;AAOO,SAAS,QAAQ,MAAuC,OAAe,UAA2B;AACvG,QAAM,IAAI,KAAK;AACf,MAAI,MAAM,KAAK,QAAQ,KAAK,CAAC,OAAO,UAAU,KAAK,EAAG,QAAO;AAC7D,MAAI,QAAQ,EAAG,QAAO,KAAK,KAAK,EAAG;AACnC,SAAO,KAAK,IAAI,CAAC,EAAG,QAAQ,SAAS,IAAI,OAAO,YAAY,YAAY,IAAI;AAC9E;",
6
+ "names": []
7
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Renderable form of the live drawing objects (labels, lines, boxes, linefills, polylines, tables): the
3
+ * `IndicatorResult` fields `labels`, `lines`, `boxes`, `linefills`, `polylines` and `tables`.
4
+ *
5
+ * Conversion rules:
6
+ * - x coordinates become bar times: a `bar_index` x is the time of that bar, or of a future bar after the last bar
7
+ * (see {@link barTime}); a `bar_time` x (UNIX ms, as PineScript) is converted to the unit of the bar times
8
+ * - an object with an `na` coordinate (or a bar index before the first bar) is not drawn, as in PineScript
9
+ * - a property the script did not set is omitted (the renderer uses the PineScript default); a colour set to `na`
10
+ * is 'transparent'
11
+ * - `force_overlay` is kept only when true
12
+ *
13
+ * @module drawing/output
14
+ */
15
+ import type { BoxData, LabelData, LineDrawingData, LinefillData, PolylineData, TableData } from '../types/metadata.js';
16
+ /** Drawing fields of an IndicatorResult; a kind without live objects is undefined. */
17
+ export interface DrawingOutputs {
18
+ labels?: LabelData[];
19
+ lines?: LineDrawingData[];
20
+ boxes?: BoxData[];
21
+ linefills?: LinefillData[];
22
+ polylines?: PolylineData[];
23
+ tables?: TableData[];
24
+ }
25
+ /**
26
+ * Converts the live drawing objects of the registry. `bars` are the chart bars (their `time` in `timeUnit`, 's' by
27
+ * default as lightweight-charts); they give the time of a bar index.
28
+ */
29
+ export declare function drawingOutputs(bars: ReadonlyArray<{
30
+ time: number;
31
+ }>, timeUnit?: 's' | 'ms'): DrawingOutputs;
32
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../src/drawing/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,eAAe,EACf,YAAY,EACZ,YAAY,EAEZ,SAAS,EACV,MAAM,sBAAsB,CAAC;AAE9B,sFAAsF;AACtF,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;CACtB;AAiBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,QAAQ,GAAE,GAAG,GAAG,IAAU,GAAG,cAAc,CA4JhH"}
@@ -0,0 +1,184 @@
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 output_exports = {};
20
+ __export(output_exports, {
21
+ drawingOutputs: () => drawingOutputs
22
+ });
23
+ module.exports = __toCommonJS(output_exports);
24
+ var import_registry = require("./registry.js");
25
+ var import_bar_time = require("./bar-time.js");
26
+ function colorOut(c) {
27
+ if (c === void 0) return void 0;
28
+ if (c === null || typeof c === "number" && Number.isNaN(c)) return "transparent";
29
+ return typeof c === "number" ? `#${(c & 16777215).toString(16).padStart(6, "0")}` : c;
30
+ }
31
+ function compact(obj) {
32
+ for (const k of Object.keys(obj)) if (obj[k] === void 0) delete obj[k];
33
+ return obj;
34
+ }
35
+ const overlay = (flag) => flag ? true : void 0;
36
+ function drawingOutputs(bars, timeUnit = "s") {
37
+ const interval = (0, import_bar_time.barInterval)(bars);
38
+ const msUnit = timeUnit === "ms" ? 1 : 1e3;
39
+ const xTime = (x, xloc) => xloc === "bar_time" ? x / msUnit : (0, import_bar_time.barTime)(bars, x, interval);
40
+ const ok = (...values) => values.every(Number.isFinite);
41
+ const lineData = (l) => {
42
+ const time1 = xTime(l.x1, l.xloc);
43
+ const time2 = xTime(l.x2, l.xloc);
44
+ if (!ok(time1, time2, l.y1, l.y2)) return void 0;
45
+ return compact({
46
+ time1,
47
+ price1: l.y1,
48
+ time2,
49
+ price2: l.y2,
50
+ color: colorOut(l.color),
51
+ width: l.width,
52
+ style: l.style,
53
+ extend: l.extend,
54
+ forceOverlay: overlay(l.force_overlay)
55
+ });
56
+ };
57
+ const labelData = (l) => {
58
+ const time = xTime(l.x, l.xloc);
59
+ if (!ok(time) || l.yloc === "price" && !ok(l.y)) return void 0;
60
+ return compact({
61
+ time,
62
+ price: l.y,
63
+ text: l.text ?? "",
64
+ color: colorOut(l.color),
65
+ textColor: colorOut(l.textcolor),
66
+ style: l.style,
67
+ size: l.size,
68
+ yloc: l.yloc,
69
+ textAlign: l.textalign,
70
+ tooltip: l.tooltip,
71
+ fontFamily: l.text_font_family,
72
+ textFormatting: l.text_formatting,
73
+ forceOverlay: overlay(l.force_overlay)
74
+ });
75
+ };
76
+ const boxData = (b) => {
77
+ const time1 = xTime(b.left, b.xloc);
78
+ const time2 = xTime(b.right, b.xloc);
79
+ if (!ok(time1, time2, b.top, b.bottom)) return void 0;
80
+ return compact({
81
+ time1,
82
+ price1: b.top,
83
+ time2,
84
+ price2: b.bottom,
85
+ bgColor: colorOut(b.bgcolor),
86
+ borderColor: colorOut(b.border_color),
87
+ borderWidth: b.border_width,
88
+ borderStyle: b.border_style,
89
+ text: b.text,
90
+ textColor: colorOut(b.text_color),
91
+ textSize: b.text_size,
92
+ textHAlign: b.text_halign,
93
+ textVAlign: b.text_valign,
94
+ textWrap: b.text_wrap,
95
+ fontFamily: b.text_font_family,
96
+ textFormatting: b.text_formatting,
97
+ extend: b.extend,
98
+ forceOverlay: overlay(b.force_overlay)
99
+ });
100
+ };
101
+ const polylineData = (p) => {
102
+ const points = [];
103
+ for (const point of p.points) {
104
+ const x = p.xloc === "bar_time" ? point.time : point.index;
105
+ const time = x === null ? NaN : xTime(x, p.xloc);
106
+ if (ok(time, point.price)) points.push({ time, price: point.price });
107
+ }
108
+ if (points.length === 0) return void 0;
109
+ return compact({
110
+ points,
111
+ curved: p.curved,
112
+ closed: p.closed,
113
+ lineColor: colorOut(p.line_color),
114
+ fillColor: p.fill_color === null ? void 0 : colorOut(p.fill_color),
115
+ lineStyle: p.line_style,
116
+ lineWidth: p.line_width,
117
+ forceOverlay: overlay(p.force_overlay)
118
+ });
119
+ };
120
+ const tableData = (t) => {
121
+ const cells = [];
122
+ for (const [key, c] of t.cells ?? []) {
123
+ const [column, row] = key.split(",").map(Number);
124
+ cells.push(
125
+ compact({
126
+ row,
127
+ column,
128
+ text: c.text ?? "",
129
+ bgColor: colorOut(c.bgcolor),
130
+ textColor: colorOut(c.text_color),
131
+ textSize: c.text_size,
132
+ width: c.width,
133
+ height: c.height,
134
+ textHAlign: c.text_halign,
135
+ textVAlign: c.text_valign,
136
+ tooltip: c.tooltip,
137
+ fontFamily: c.text_font_family,
138
+ textFormatting: c.text_formatting
139
+ })
140
+ );
141
+ }
142
+ cells.sort((a, b) => a.row - b.row || a.column - b.column);
143
+ const merges = (t.merges ?? []).map((m) => ({
144
+ startColumn: m.start_column,
145
+ startRow: m.start_row,
146
+ endColumn: m.end_column,
147
+ endRow: m.end_row
148
+ }));
149
+ return compact({
150
+ position: t.position,
151
+ columns: t.columns,
152
+ rows: t.rows,
153
+ cells,
154
+ merges: merges.length ? merges : void 0,
155
+ bgColor: colorOut(t.bgcolor),
156
+ frameColor: colorOut(t.frame_color),
157
+ frameWidth: t.frame_width,
158
+ borderColor: colorOut(t.border_color),
159
+ borderWidth: t.border_width,
160
+ forceOverlay: overlay(t.force_overlay)
161
+ });
162
+ };
163
+ const convert = (items, fn) => {
164
+ const out = [];
165
+ for (const item of items) {
166
+ const r = fn(item);
167
+ if (r !== void 0) out.push(r);
168
+ }
169
+ return out.length ? out : void 0;
170
+ };
171
+ return {
172
+ labels: convert((0, import_registry.all)("label"), labelData),
173
+ lines: convert((0, import_registry.all)("line"), lineData),
174
+ boxes: convert((0, import_registry.all)("box"), boxData),
175
+ linefills: convert((0, import_registry.all)("linefill"), (f) => {
176
+ const line1 = lineData(f.line1);
177
+ const line2 = lineData(f.line2);
178
+ return line1 && line2 ? compact({ line1, line2, color: colorOut(f.color) }) : void 0;
179
+ }),
180
+ polylines: convert((0, import_registry.all)("polyline"), polylineData),
181
+ tables: convert((0, import_registry.all)("table"), tableData)
182
+ };
183
+ }
184
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/drawing/output.ts"],
4
+ "sourcesContent": ["/**\n * Renderable form of the live drawing objects (labels, lines, boxes, linefills, polylines, tables): the\n * `IndicatorResult` fields `labels`, `lines`, `boxes`, `linefills`, `polylines` and `tables`.\n *\n * Conversion rules:\n * - x coordinates become bar times: a `bar_index` x is the time of that bar, or of a future bar after the last bar\n * (see {@link barTime}); a `bar_time` x (UNIX ms, as PineScript) is converted to the unit of the bar times\n * - an object with an `na` coordinate (or a bar index before the first bar) is not drawn, as in PineScript\n * - a property the script did not set is omitted (the renderer uses the PineScript default); a colour set to `na`\n * is 'transparent'\n * - `force_overlay` is kept only when true\n *\n * @module drawing/output\n */\n\nimport { all } from './registry.js';\nimport { barInterval, barTime } from './bar-time.js';\nimport type { Box, ChartPoint, Label, Line, Polyline, Table, color } from '../types/index.js';\nimport type {\n BoxData,\n LabelData,\n LineDrawingData,\n LinefillData,\n PolylineData,\n TableCellData,\n TableData,\n} from '../types/metadata.js';\n\n/** Drawing fields of an IndicatorResult; a kind without live objects is undefined. */\nexport interface DrawingOutputs {\n labels?: LabelData[];\n lines?: LineDrawingData[];\n boxes?: BoxData[];\n linefills?: LinefillData[];\n polylines?: PolylineData[];\n tables?: TableData[];\n}\n\n/** A colour of the result: 'transparent' for na (null), '#rrggbb' for a numeric colour. */\nfunction colorOut(c: color | null | undefined): string | undefined {\n if (c === undefined) return undefined;\n if (c === null || (typeof c === 'number' && Number.isNaN(c))) return 'transparent';\n return typeof c === 'number' ? `#${(c & 0xffffff).toString(16).padStart(6, '0')}` : c;\n}\n\n/** The object without its undefined fields (so that the result has only the properties that were set). */\nfunction compact<T extends object>(obj: T): T {\n for (const k of Object.keys(obj) as Array<keyof T>) if (obj[k] === undefined) delete obj[k];\n return obj;\n}\n\nconst overlay = (flag: boolean | undefined): true | undefined => (flag ? true : undefined);\n\n/**\n * Converts the live drawing objects of the registry. `bars` are the chart bars (their `time` in `timeUnit`, 's' by\n * default as lightweight-charts); they give the time of a bar index.\n */\nexport function drawingOutputs(bars: ReadonlyArray<{ time: number }>, timeUnit: 's' | 'ms' = 's'): DrawingOutputs {\n const interval = barInterval(bars);\n const msUnit = timeUnit === 'ms' ? 1 : 1000;\n const xTime = (x: number, xloc: 'bar_index' | 'bar_time'): number =>\n xloc === 'bar_time' ? x / msUnit : barTime(bars, x, interval);\n const ok = (...values: number[]): boolean => values.every(Number.isFinite);\n\n const lineData = (l: Line): LineDrawingData | undefined => {\n const time1 = xTime(l.x1, l.xloc);\n const time2 = xTime(l.x2, l.xloc);\n if (!ok(time1, time2, l.y1, l.y2)) return undefined;\n return compact({\n time1,\n price1: l.y1,\n time2,\n price2: l.y2,\n color: colorOut(l.color),\n width: l.width,\n style: l.style,\n extend: l.extend,\n forceOverlay: overlay(l.force_overlay),\n });\n };\n\n const labelData = (l: Label): LabelData | undefined => {\n const time = xTime(l.x, l.xloc);\n // abovebar / belowbar labels are placed at the bar, not at y\n if (!ok(time) || (l.yloc === 'price' && !ok(l.y))) return undefined;\n return compact({\n time,\n price: l.y,\n text: l.text ?? '',\n color: colorOut(l.color),\n textColor: colorOut(l.textcolor),\n style: l.style,\n size: l.size as LabelData['size'],\n yloc: l.yloc,\n textAlign: l.textalign,\n tooltip: l.tooltip,\n fontFamily: l.text_font_family,\n textFormatting: l.text_formatting,\n forceOverlay: overlay(l.force_overlay),\n });\n };\n\n const boxData = (b: Box): BoxData | undefined => {\n const time1 = xTime(b.left, b.xloc);\n const time2 = xTime(b.right, b.xloc);\n if (!ok(time1, time2, b.top, b.bottom)) return undefined;\n return compact({\n time1,\n price1: b.top,\n time2,\n price2: b.bottom,\n bgColor: colorOut(b.bgcolor),\n borderColor: colorOut(b.border_color),\n borderWidth: b.border_width,\n borderStyle: b.border_style,\n text: b.text,\n textColor: colorOut(b.text_color),\n textSize: b.text_size as BoxData['textSize'],\n textHAlign: b.text_halign,\n textVAlign: b.text_valign,\n textWrap: b.text_wrap,\n fontFamily: b.text_font_family,\n textFormatting: b.text_formatting,\n extend: b.extend,\n forceOverlay: overlay(b.force_overlay),\n });\n };\n\n const polylineData = (p: Polyline): PolylineData | undefined => {\n const points: PolylineData['points'] = [];\n for (const point of p.points as ChartPoint[]) {\n const x = p.xloc === 'bar_time' ? point.time : point.index;\n const time = x === null ? NaN : xTime(x, p.xloc);\n if (ok(time, point.price)) points.push({ time, price: point.price });\n }\n if (points.length === 0) return undefined;\n return compact({\n points,\n curved: p.curved,\n closed: p.closed,\n lineColor: colorOut(p.line_color),\n fillColor: p.fill_color === null ? undefined : colorOut(p.fill_color),\n lineStyle: p.line_style,\n lineWidth: p.line_width,\n forceOverlay: overlay(p.force_overlay),\n });\n };\n\n const tableData = (t: Table): TableData => {\n const cells: TableCellData[] = [];\n for (const [key, c] of t.cells ?? []) {\n const [column, row] = key.split(',').map(Number) as [number, number];\n cells.push(\n compact({\n row,\n column,\n text: c.text ?? '',\n bgColor: colorOut(c.bgcolor),\n textColor: colorOut(c.text_color),\n textSize: c.text_size as TableCellData['textSize'],\n width: c.width,\n height: c.height,\n textHAlign: c.text_halign,\n textVAlign: c.text_valign,\n tooltip: c.tooltip,\n fontFamily: c.text_font_family,\n textFormatting: c.text_formatting,\n })\n );\n }\n cells.sort((a, b) => a.row - b.row || a.column - b.column);\n const merges = (t.merges ?? []).map((m) => ({\n startColumn: m.start_column,\n startRow: m.start_row,\n endColumn: m.end_column,\n endRow: m.end_row,\n }));\n return compact({\n position: t.position,\n columns: t.columns,\n rows: t.rows,\n cells,\n merges: merges.length ? merges : undefined,\n bgColor: colorOut(t.bgcolor),\n frameColor: colorOut(t.frame_color),\n frameWidth: t.frame_width,\n borderColor: colorOut(t.border_color),\n borderWidth: t.border_width,\n forceOverlay: overlay(t.force_overlay),\n });\n };\n\n const convert = <T, R>(items: T[], fn: (item: T) => R | undefined): R[] | undefined => {\n const out: R[] = [];\n for (const item of items) {\n const r = fn(item);\n if (r !== undefined) out.push(r);\n }\n return out.length ? out : undefined;\n };\n\n return {\n labels: convert(all('label'), labelData),\n lines: convert(all('line'), lineData),\n boxes: convert(all('box'), boxData),\n linefills: convert(all('linefill'), (f): LinefillData | undefined => {\n const line1 = lineData(f.line1);\n const line2 = lineData(f.line2);\n return line1 && line2 ? compact({ line1, line2, color: colorOut(f.color) }) : undefined;\n }),\n polylines: convert(all('polyline'), polylineData),\n tables: convert(all('table'), tableData),\n };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,sBAAoB;AACpB,sBAAqC;AAuBrC,SAAS,SAAS,GAAiD;AACjE,MAAI,MAAM,OAAW,QAAO;AAC5B,MAAI,MAAM,QAAS,OAAO,MAAM,YAAY,OAAO,MAAM,CAAC,EAAI,QAAO;AACrE,SAAO,OAAO,MAAM,WAAW,KAAK,IAAI,UAAU,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,KAAK;AACtF;AAGA,SAAS,QAA0B,KAAW;AAC5C,aAAW,KAAK,OAAO,KAAK,GAAG,EAAqB,KAAI,IAAI,CAAC,MAAM,OAAW,QAAO,IAAI,CAAC;AAC1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EAAE,WAAW;AAAA,MAClC,YAAY,EAAE;AAAA,MACd,aAAa,SAAS,EAAE,YAAY;AAAA,MACpC,aAAa,EAAE;AAAA,MACf,cAAc,QAAQ,EAAE,aAAa;AAAA,IACvC,CAAC;AAAA,EACH;AAEA,QAAM,UAAU,CAAO,OAAY,OAAoD;AACrF,UAAM,MAAW,CAAC;AAClB,eAAW,QAAQ,OAAO;AACxB,YAAM,IAAI,GAAG,IAAI;AACjB,UAAI,MAAM,OAAW,KAAI,KAAK,CAAC;AAAA,IACjC;AACA,WAAO,IAAI,SAAS,MAAM;AAAA,EAC5B;AAEA,SAAO;AAAA,IACL,QAAQ,YAAQ,qBAAI,OAAO,GAAG,SAAS;AAAA,IACvC,OAAO,YAAQ,qBAAI,MAAM,GAAG,QAAQ;AAAA,IACpC,OAAO,YAAQ,qBAAI,KAAK,GAAG,OAAO;AAAA,IAClC,WAAW,YAAQ,qBAAI,UAAU,GAAG,CAAC,MAAgC;AACnE,YAAM,QAAQ,SAAS,EAAE,KAAK;AAC9B,YAAM,QAAQ,SAAS,EAAE,KAAK;AAC9B,aAAO,SAAS,QAAQ,QAAQ,EAAE,OAAO,OAAO,OAAO,SAAS,EAAE,KAAK,EAAE,CAAC,IAAI;AAAA,IAChF,CAAC;AAAA,IACD,WAAW,YAAQ,qBAAI,UAAU,GAAG,YAAY;AAAA,IAChD,QAAQ,YAAQ,qBAAI,OAAO,GAAG,SAAS;AAAA,EACzC;AACF;",
6
+ "names": []
7
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Registry of the live drawing objects (lines, labels, boxes, polylines, linefills), as PineScript
2
+ * Registry of the live drawing objects (lines, labels, boxes, polylines, linefills, tables), as PineScript
3
3
  * keeps them. PineScript rules:
4
4
  *
5
5
  * - `line.all`, `label.all`, ... list the live objects in creation order (a copy of the list)
@@ -14,18 +14,19 @@
14
14
  *
15
15
  * @module drawing/registry
16
16
  */
17
- import type { Box, Label, Line, Linefill, Polyline } from '../types/index.js';
18
- export type DrawingKind = 'line' | 'label' | 'box' | 'polyline' | 'linefill';
17
+ import type { Box, Label, Line, Linefill, Polyline, Table } from '../types/index.js';
18
+ export type DrawingKind = 'line' | 'label' | 'box' | 'polyline' | 'linefill' | 'table';
19
19
  interface DrawingTypes {
20
20
  line: Line;
21
21
  label: Label;
22
22
  box: Box;
23
23
  polyline: Polyline;
24
24
  linefill: Linefill;
25
+ table: Table;
25
26
  }
26
27
  /** Default `max_lines_count`, `max_labels_count`, `max_boxes_count`, `max_polylines_count`. */
27
28
  export declare const DEFAULT_MAX_COUNT = 50;
28
- export type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill'>, number>>;
29
+ export type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill' | 'table'>, number>>;
29
30
  /** Records a new object and deletes the oldest objects of its kind when the count is too high. */
30
31
  export declare function register<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): DrawingTypes[K];
31
32
  /** Deletes an object (no effect when it is already deleted). */
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/drawing/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,CAAC;AAE7E,UAAU,YAAY;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAIpC,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE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KAAK,EAAE,KAAK,CAAC;CACd;AAED,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAIpC,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAoChG,kGAAkG;AAClG,wBAAgB,QAAQ,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAS9F;AAED,gEAAgE;AAChE,wBAAgB,MAAM,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAKjF;AAED,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE/C;AAED,mEAAmE;AACnE,wBAAgB,GAAG,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAE1E;AAED,4FAA4F;AAC5F,wBAAgB,aAAa,CAAC,SAAS,GAAE,aAAkB,GAAG,IAAI,CAQjE;AAED,uGAAuG;AACvG,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAE/D"}
@@ -29,7 +29,14 @@ __export(registry_exports, {
29
29
  module.exports = __toCommonJS(registry_exports);
30
30
  const DEFAULT_MAX_COUNT = 50;
31
31
  const SLACK = 5;
32
- const live = { line: [], label: [], box: [], polyline: [], linefill: [] };
32
+ const live = {
33
+ line: [],
34
+ label: [],
35
+ box: [],
36
+ polyline: [],
37
+ linefill: [],
38
+ table: []
39
+ };
33
40
  let limits = {
34
41
  line: DEFAULT_MAX_COUNT,
35
42
  label: DEFAULT_MAX_COUNT,
@@ -42,7 +49,8 @@ const COORDINATES = {
42
49
  label: ["x", "y"],
43
50
  box: ["left", "top", "right", "bottom"],
44
51
  polyline: [],
45
- linefill: []
52
+ linefill: [],
53
+ table: []
46
54
  };
47
55
  function markDeleted(kind, obj, explicit) {
48
56
  deleted.add(obj);
@@ -54,6 +62,7 @@ function markDeleted(kind, obj, explicit) {
54
62
  function register(kind, obj) {
55
63
  const list = live[kind];
56
64
  list.push(obj);
65
+ if (kind === "table") return obj;
57
66
  const max = limits[kind === "linefill" ? "line" : kind];
58
67
  if (list.length > max + SLACK) {
59
68
  for (const old of list.splice(0, list.length - max)) markDeleted(kind, old, false);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/drawing/registry.ts"],
4
- "sourcesContent": ["/**\n * Registry of the live drawing objects (lines, labels, boxes, polylines, linefills), as PineScript\n * keeps them. PineScript rules:\n *\n * - `line.all`, `label.all`, ... list the live objects in creation order (a copy of the list)\n * - `delete` removes an object; the object becomes `na`: its getters return NaN and its setters\n * do nothing. Deleting a line with `line.delete` also deletes the linefills that use it\n * - when a creation brings the count above `max_*_count + 5`, the oldest objects are deleted until\n * `max_*_count` remain (default 50). Copies count as creations. Linefills follow the same rule with\n * `max_lines_count`; lines deleted by this rule do not delete their linefills\n *\n * The script API (`executeScript`) resets the registry at the start of every run and applies the\n * `max_*_count` values of `indicator()`. Outside a script run the registry is global to the module.\n *\n * @module drawing/registry\n */\n\nimport type { Box, Label, Line, Linefill, Polyline } from '../types/index.js';\n\nexport type DrawingKind = 'line' | 'label' | 'box' | 'polyline' | 'linefill';\n\ninterface DrawingTypes {\n line: Line;\n label: Label;\n box: Box;\n polyline: Polyline;\n linefill: Linefill;\n}\n\n/** Default `max_lines_count`, `max_labels_count`, `max_boxes_count`, `max_polylines_count`. */\nexport const DEFAULT_MAX_COUNT = 50;\n/** Objects above the maximum that PineScript keeps before it deletes the oldest ones. */\nconst SLACK = 5;\n\nexport type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill'>, number>>;\n\nconst live: { [K in DrawingKind]: Array<DrawingTypes[K]> } = { line: [], label: [], box: [], polyline: [], linefill: [] };\nlet limits: Required<DrawingLimits> = {\n line: DEFAULT_MAX_COUNT,\n label: DEFAULT_MAX_COUNT,\n box: DEFAULT_MAX_COUNT,\n polyline: DEFAULT_MAX_COUNT,\n};\nconst deleted = new WeakSet<object>();\n\n/** Numeric fields that become NaN when an object is deleted, so that its getters return `na`. */\nconst COORDINATES: { [K in DrawingKind]: Array<keyof DrawingTypes[K]> } = {\n line: ['x1', 'y1', 'x2', 'y2'],\n label: ['x', 'y'],\n box: ['left', 'top', 'right', 'bottom'],\n polyline: [],\n linefill: [],\n};\n\nfunction markDeleted<K extends DrawingKind>(kind: K, obj: DrawingTypes[K], explicit: boolean): void {\n deleted.add(obj);\n for (const field of COORDINATES[kind]) (obj as unknown as Record<string, unknown>)[field as string] = NaN;\n if (kind === 'line' && explicit) {\n for (const fill of live.linefill.filter((f) => f.line1 === obj || f.line2 === obj)) remove('linefill', fill);\n }\n}\n\n/** Records a new object and deletes the oldest objects of its kind when the count is too high. */\nexport function register<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): DrawingTypes[K] {\n const list = live[kind];\n list.push(obj);\n const max = limits[kind === 'linefill' ? 'line' : (kind as Exclude<DrawingKind, 'linefill'>)];\n if (list.length > max + SLACK) {\n for (const old of list.splice(0, list.length - max)) markDeleted(kind, old, false);\n }\n return obj;\n}\n\n/** Deletes an object (no effect when it is already deleted). */\nexport function remove<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): void {\n const list = live[kind];\n const index = list.indexOf(obj);\n if (index !== -1) list.splice(index, 1);\n if (!deleted.has(obj)) markDeleted(kind, obj, true);\n}\n\n/** True when the object was deleted (by `delete` or by the maximum count). */\nexport function isDeleted(obj: unknown): boolean {\n return typeof obj === 'object' && obj !== null && deleted.has(obj);\n}\n\n/** The live objects of a kind, in creation order (a new array). */\nexport function all<K extends DrawingKind>(kind: K): Array<DrawingTypes[K]> {\n return [...live[kind]] as Array<DrawingTypes[K]>;\n}\n\n/** Forgets all objects (without deleting them) and sets the maximum counts (default 50). */\nexport function resetDrawings(newLimits: DrawingLimits = {}): void {\n for (const kind of Object.keys(live) as DrawingKind[]) live[kind].length = 0;\n limits = {\n line: newLimits.line ?? DEFAULT_MAX_COUNT,\n label: newLimits.label ?? DEFAULT_MAX_COUNT,\n box: newLimits.box ?? DEFAULT_MAX_COUNT,\n polyline: newLimits.polyline ?? DEFAULT_MAX_COUNT,\n };\n}\n\n/** Changes the maximum counts without forgetting the objects (PineScript `indicator(max_*_count)`). */\nexport function setDrawingLimits(newLimits: DrawingLimits): void {\n limits = { ...limits, ...Object.fromEntries(Object.entries(newLimits).filter(([, v]) => v !== undefined)) };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BO,MAAM,oBAAoB;AAEjC,MAAM,QAAQ;AAId,MAAM,OAAuD,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,KAAK,CAAC,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC,EAAE;AACxH,IAAI,SAAkC;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AACZ;AACA,MAAM,UAAU,oBAAI,QAAgB;AAGpC,MAAM,cAAoE;AAAA,EACxE,MAAM,CAAC,MAAM,MAAM,MAAM,IAAI;AAAA,EAC7B,OAAO,CAAC,KAAK,GAAG;AAAA,EAChB,KAAK,CAAC,QAAQ,OAAO,SAAS,QAAQ;AAAA,EACtC,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AACb;AAEA,SAAS,YAAmC,MAAS,KAAsB,UAAyB;AAClG,UAAQ,IAAI,GAAG;AACf,aAAW,SAAS,YAAY,IAAI,EAAG,CAAC,IAA2C,KAAe,IAAI;AACtG,MAAI,SAAS,UAAU,UAAU;AAC/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5G;",
4
+ "sourcesContent": ["/**\n * Registry of the live drawing objects (lines, labels, boxes, polylines, linefills, tables), as PineScript\n * keeps them. PineScript rules:\n *\n * - `line.all`, `label.all`, ... list the live objects in creation order (a copy of the list)\n * - `delete` removes an object; the object becomes `na`: its getters return NaN and its setters\n * do nothing. Deleting a line with `line.delete` also deletes the linefills that use it\n * - when a creation brings the count above `max_*_count + 5`, the oldest objects are deleted until\n * `max_*_count` remain (default 50). Copies count as creations. Linefills follow the same rule with\n * `max_lines_count`; lines deleted by this rule do not delete their linefills\n *\n * The script API (`executeScript`) resets the registry at the start of every run and applies the\n * `max_*_count` values of `indicator()`. Outside a script run the registry is global to the module.\n *\n * @module drawing/registry\n */\n\nimport type { Box, Label, Line, Linefill, Polyline, Table } from '../types/index.js';\n\nexport type DrawingKind = 'line' | 'label' | 'box' | 'polyline' | 'linefill' | 'table';\n\ninterface DrawingTypes {\n line: Line;\n label: Label;\n box: Box;\n polyline: Polyline;\n linefill: Linefill;\n table: Table;\n}\n\n/** Default `max_lines_count`, `max_labels_count`, `max_boxes_count`, `max_polylines_count`. */\nexport const DEFAULT_MAX_COUNT = 50;\n/** Objects above the maximum that PineScript keeps before it deletes the oldest ones. */\nconst SLACK = 5;\n\nexport type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill' | 'table'>, number>>;\n\nconst live: { [K in DrawingKind]: Array<DrawingTypes[K]> } = {\n line: [],\n label: [],\n box: [],\n polyline: [],\n linefill: [],\n table: [],\n};\nlet limits: Required<DrawingLimits> = {\n line: DEFAULT_MAX_COUNT,\n label: DEFAULT_MAX_COUNT,\n box: DEFAULT_MAX_COUNT,\n polyline: DEFAULT_MAX_COUNT,\n};\nconst deleted = new WeakSet<object>();\n\n/** Numeric fields that become NaN when an object is deleted, so that its getters return `na`. */\nconst COORDINATES: { [K in DrawingKind]: Array<keyof DrawingTypes[K]> } = {\n line: ['x1', 'y1', 'x2', 'y2'],\n label: ['x', 'y'],\n box: ['left', 'top', 'right', 'bottom'],\n polyline: [],\n linefill: [],\n table: [],\n};\n\nfunction markDeleted<K extends DrawingKind>(kind: K, obj: DrawingTypes[K], explicit: boolean): void {\n deleted.add(obj);\n for (const field of COORDINATES[kind]) (obj as unknown as Record<string, unknown>)[field as string] = NaN;\n if (kind === 'line' && explicit) {\n for (const fill of live.linefill.filter((f) => f.line1 === obj || f.line2 === obj)) remove('linefill', fill);\n }\n}\n\n/** Records a new object and deletes the oldest objects of its kind when the count is too high. */\nexport function register<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): DrawingTypes[K] {\n const list = live[kind];\n list.push(obj);\n if (kind === 'table') return obj; // tables have no maximum count\n const max = limits[kind === 'linefill' ? 'line' : (kind as keyof DrawingLimits)];\n if (list.length > max + SLACK) {\n for (const old of list.splice(0, list.length - max)) markDeleted(kind, old, false);\n }\n return obj;\n}\n\n/** Deletes an object (no effect when it is already deleted). */\nexport function remove<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): void {\n const list = live[kind];\n const index = list.indexOf(obj);\n if (index !== -1) list.splice(index, 1);\n if (!deleted.has(obj)) markDeleted(kind, obj, true);\n}\n\n/** True when the object was deleted (by `delete` or by the maximum count). */\nexport function isDeleted(obj: unknown): boolean {\n return typeof obj === 'object' && obj !== null && deleted.has(obj);\n}\n\n/** The live objects of a kind, in creation order (a new array). */\nexport function all<K extends DrawingKind>(kind: K): Array<DrawingTypes[K]> {\n return [...live[kind]] as Array<DrawingTypes[K]>;\n}\n\n/** Forgets all objects (without deleting them) and sets the maximum counts (default 50). */\nexport function resetDrawings(newLimits: DrawingLimits = {}): void {\n for (const kind of Object.keys(live) as DrawingKind[]) live[kind].length = 0;\n limits = {\n line: newLimits.line ?? DEFAULT_MAX_COUNT,\n label: newLimits.label ?? DEFAULT_MAX_COUNT,\n box: newLimits.box ?? DEFAULT_MAX_COUNT,\n polyline: newLimits.polyline ?? DEFAULT_MAX_COUNT,\n };\n}\n\n/** Changes the maximum counts without forgetting the objects (PineScript `indicator(max_*_count)`). */\nexport function setDrawingLimits(newLimits: DrawingLimits): void {\n limits = { ...limits, ...Object.fromEntries(Object.entries(newLimits).filter(([, v]) => v !== undefined)) };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BO,MAAM,oBAAoB;AAEjC,MAAM,QAAQ;AAId,MAAM,OAAuD;AAAA,EAC3D,MAAM,CAAC;AAAA,EACP,OAAO,CAAC;AAAA,EACR,KAAK,CAAC;AAAA,EACN,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,OAAO,CAAC;AACV;AACA,IAAI,SAAkC;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AACZ;AACA,MAAM,UAAU,oBAAI,QAAgB;AAGpC,MAAM,cAAoE;AAAA,EACxE,MAAM,CAAC,MAAM,MAAM,MAAM,IAAI;AAAA,EAC7B,OAAO,CAAC,KAAK,GAAG;AAAA,EAChB,KAAK,CAAC,QAAQ,OAAO,SAAS,QAAQ;AAAA,EACtC,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,OAAO,CAAC;AACV;AAEA,SAAS,YAAmC,MAAS,KAAsB,UAAyB;AAClG,UAAQ,IAAI,GAAG;AACf,aAAW,SAAS,YAAY,IAAI,EAAG,CAAC,IAA2C,KAAe,IAAI;AACtG,MAAI,SAAS,UAAU,UAAU;AAC/B,eAAW,QAAQ,KAAK,SAAS,OAAO,CAAC,MAAM,EAAE,UAAU,OAAO,EAAE,UAAU,GAAG,EAAG,QAAO,YAAY,IAAI;AAAA,EAC7G;AACF;AAGO,SAAS,SAAgC,MAAS,KAAuC;AAC9F,QAAM,OAAO,KAAK,IAAI;AACtB,OAAK,KAAK,GAAG;AACb,MAAI,SAAS,QAAS,QAAO;AAC7B,QAAM,MAAM,OAAO,SAAS,aAAa,SAAU,IAA4B;AAC/E,MAAI,KAAK,SAAS,MAAM,OAAO;AAC7B,eAAW,OAAO,KAAK,OAAO,GAAG,KAAK,SAAS,GAAG,EAAG,aAAY,MAAM,KAAK,KAAK;AAAA,EACnF;AACA,SAAO;AACT;AAGO,SAAS,OAA8B,MAAS,KAA4B;AACjF,QAAM,OAAO,KAAK,IAAI;AACtB,QAAM,QAAQ,KAAK,QAAQ,GAAG;AAC9B,MAAI,UAAU,GAAI,MAAK,OAAO,OAAO,CAAC;AACtC,MAAI,CAAC,QAAQ,IAAI,GAAG,EAAG,aAAY,MAAM,KAAK,IAAI;AACpD;AAGO,SAAS,UAAU,KAAuB;AAC/C,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,QAAQ,IAAI,GAAG;AACnE;AAGO,SAAS,IAA2B,MAAiC;AAC1E,SAAO,CAAC,GAAG,KAAK,IAAI,CAAC;AACvB;AAGO,SAAS,cAAc,YAA2B,CAAC,GAAS;AACjE,aAAW,QAAQ,OAAO,KAAK,IAAI,EAAoB,MAAK,IAAI,EAAE,SAAS;AAC3E,WAAS;AAAA,IACP,MAAM,UAAU,QAAQ;AAAA,IACxB,OAAO,UAAU,SAAS;AAAA,IAC1B,KAAK,UAAU,OAAO;AAAA,IACtB,UAAU,UAAU,YAAY;AAAA,EAClC;AACF;AAGO,SAAS,iBAAiB,WAAgC;AAC/D,WAAS,EAAE,GAAG,QAAQ,GAAG,OAAO,YAAY,OAAO,QAAQ,SAAS,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS,CAAC,EAAE;AAC5G;",
6
6
  "names": []
7
7
  }
@@ -28,10 +28,13 @@ import * as label from './label/index.js';
28
28
  import * as linefill from './linefill/index.js';
29
29
  import * as chartPoint from './chartpoint/index.js';
30
30
  import * as polyline from './polyline/index.js';
31
+ import * as table from './table/index.js';
31
32
  import * as text from './text/index.js';
32
33
  import * as compare from './compare/index.js';
33
34
  import * as callsite from './callsite/index.js';
34
- export { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, text, compare, callsite };
35
+ export { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };
36
+ export { drawingOutputs, type DrawingOutputs } from './drawing/output.js';
37
+ export { barInterval, barTime } from './drawing/bar-time.js';
35
38
  export { Series, BarData } from './runtime/series.js';
36
39
  export type { SeriesExtractor } from './runtime/series.js';
37
40
  import * as ta from './ta-series.js';
@@ -48,13 +51,13 @@ export { input, type InputValue, type IntInputOptions, type FloatInputOptions, t
48
51
  export { plot as plotHelper, createPlot, type Time, type TimeValuePair, type PlotOptions as PlotHelperOptions, type PlotResult, } from './plot.js';
49
52
  export { setContext, clearContext, getContext, registerCalculate, recalculate, plot, hline, clearPlots, } from './runtime/runtime.js';
50
53
  export { input_int, input_float, input_bool, input_string, input_source, input_timeframe, input_session, input_time, } from './runtime/inputs.js';
51
- export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputOptions, OhlcvData, PlotConfig, HLineConfig, FillConfig, ArrowConfig, } from './runtime/types.js';
54
+ export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputOptions, OhlcvData, PlotConfig, HLineConfig, FillConfig, ArrowConfig, CandleConfig, } from './runtime/types.js';
52
55
  export { STRATEGY_CONSTANTS, STRATEGY_DEFAULTS, STRATEGY_NUMBER_VARIABLES, STRATEGY_TEXT_VARIABLES, } from './strategy/index.js';
53
56
  export type * from './strategy/index.js';
54
57
  export { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';
55
58
  export type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';
56
59
  export { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';
57
- export declare const VERSION = "0.9.5";
60
+ export declare const VERSION = "0.10.0";
58
61
  /**
59
62
  * Library information
60
63
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":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