oakscriptjs 0.24.0 → 0.25.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 (300) hide show
  1. package/README.md +25 -1
  2. package/bin/oakscript.mjs +10 -3
  3. package/dist/cjs/box/index.d.ts +348 -289
  4. package/dist/cjs/box/index.d.ts.map +1 -1
  5. package/dist/cjs/box/index.js.map +2 -2
  6. package/dist/cjs/check/node.d.ts.map +1 -1
  7. package/dist/cjs/check/node.js +1 -0
  8. package/dist/cjs/check/node.js.map +2 -2
  9. package/dist/cjs/check/preview.d.ts +31 -0
  10. package/dist/cjs/check/preview.d.ts.map +1 -0
  11. package/dist/cjs/check/preview.js +303 -0
  12. package/dist/cjs/check/preview.js.map +7 -0
  13. package/dist/cjs/color/index.d.ts +11 -11
  14. package/dist/cjs/color/index.js.map +1 -1
  15. package/dist/cjs/color/parse.d.ts +2 -0
  16. package/dist/cjs/color/parse.d.ts.map +1 -1
  17. package/dist/cjs/color/parse.js +6 -0
  18. package/dist/cjs/color/parse.js.map +2 -2
  19. package/dist/cjs/compare/index.d.ts +76 -12
  20. package/dist/cjs/compare/index.d.ts.map +1 -1
  21. package/dist/cjs/compare/index.js.map +2 -2
  22. package/dist/cjs/drawing/registry.d.ts +28 -5
  23. package/dist/cjs/drawing/registry.d.ts.map +1 -1
  24. package/dist/cjs/drawing/registry.js +14 -0
  25. package/dist/cjs/drawing/registry.js.map +2 -2
  26. package/dist/cjs/index.d.ts +1 -1
  27. package/dist/cjs/index.js +1 -1
  28. package/dist/cjs/index.js.map +1 -1
  29. package/dist/cjs/label/index.d.ts +265 -187
  30. package/dist/cjs/label/index.d.ts.map +1 -1
  31. package/dist/cjs/label/index.js +1 -1
  32. package/dist/cjs/label/index.js.map +2 -2
  33. package/dist/cjs/line/index.d.ts +247 -207
  34. package/dist/cjs/line/index.d.ts.map +1 -1
  35. package/dist/cjs/line/index.js.map +2 -2
  36. package/dist/cjs/linefill/index.d.ts +61 -89
  37. package/dist/cjs/linefill/index.d.ts.map +1 -1
  38. package/dist/cjs/linefill/index.js.map +2 -2
  39. package/dist/cjs/math/index.d.ts +49 -40
  40. package/dist/cjs/math/index.d.ts.map +1 -1
  41. package/dist/cjs/math/index.js.map +2 -2
  42. package/dist/cjs/polyline/index.d.ts +57 -78
  43. package/dist/cjs/polyline/index.d.ts.map +1 -1
  44. package/dist/cjs/polyline/index.js.map +2 -2
  45. package/dist/cjs/runtime/input-active.d.ts +2 -2
  46. package/dist/cjs/runtime/input-active.js.map +1 -1
  47. package/dist/cjs/runtime/series.d.ts +241 -161
  48. package/dist/cjs/runtime/series.d.ts.map +1 -1
  49. package/dist/cjs/runtime/series.js +223 -127
  50. package/dist/cjs/runtime/series.js.map +2 -2
  51. package/dist/cjs/script/api/alert.d.ts +37 -0
  52. package/dist/cjs/script/api/alert.d.ts.map +1 -0
  53. package/dist/cjs/script/api/alert.js +17 -0
  54. package/dist/cjs/script/api/alert.js.map +7 -0
  55. package/dist/cjs/script/api/calc.d.ts +232 -0
  56. package/dist/cjs/script/api/calc.d.ts.map +1 -0
  57. package/dist/cjs/script/api/calc.js +17 -0
  58. package/dist/cjs/script/api/calc.js.map +7 -0
  59. package/dist/cjs/script/api/color.d.ts +213 -0
  60. package/dist/cjs/script/api/color.d.ts.map +1 -0
  61. package/dist/cjs/script/api/color.js +17 -0
  62. package/dist/cjs/script/api/color.js.map +7 -0
  63. package/dist/cjs/script/api/context.d.ts +764 -0
  64. package/dist/cjs/script/api/context.d.ts.map +1 -0
  65. package/dist/cjs/script/api/context.js +17 -0
  66. package/dist/cjs/script/api/context.js.map +7 -0
  67. package/dist/cjs/script/api/log.d.ts +58 -0
  68. package/dist/cjs/script/api/log.d.ts.map +1 -0
  69. package/dist/cjs/script/api/log.js +17 -0
  70. package/dist/cjs/script/api/log.js.map +7 -0
  71. package/dist/cjs/script/api/strategy.d.ts +391 -0
  72. package/dist/cjs/script/api/strategy.d.ts.map +1 -0
  73. package/dist/cjs/script/api/strategy.js +17 -0
  74. package/dist/cjs/script/api/strategy.js.map +7 -0
  75. package/dist/cjs/script/api/ta.d.ts +1012 -0
  76. package/dist/cjs/script/api/ta.d.ts.map +1 -0
  77. package/dist/cjs/script/api/ta.js +17 -0
  78. package/dist/cjs/script/api/ta.js.map +7 -0
  79. package/dist/cjs/script/api/table.d.ts +479 -0
  80. package/dist/cjs/script/api/table.d.ts.map +1 -0
  81. package/dist/cjs/script/api/table.js +17 -0
  82. package/dist/cjs/script/api/table.js.map +7 -0
  83. package/dist/cjs/script/constants.d.ts +228 -83
  84. package/dist/cjs/script/constants.d.ts.map +1 -1
  85. package/dist/cjs/script/constants.js +87 -0
  86. package/dist/cjs/script/constants.js.map +2 -2
  87. package/dist/cjs/script/define.d.ts +94 -0
  88. package/dist/cjs/script/define.d.ts.map +1 -0
  89. package/dist/cjs/script/define.js +127 -0
  90. package/dist/cjs/script/define.js.map +7 -0
  91. package/dist/cjs/script/drawing-args.d.ts.map +1 -1
  92. package/dist/cjs/script/drawing-args.js +1 -1
  93. package/dist/cjs/script/drawing-args.js.map +2 -2
  94. package/dist/cjs/script/formula.d.ts +53 -0
  95. package/dist/cjs/script/formula.d.ts.map +1 -0
  96. package/dist/cjs/script/formula.js +402 -0
  97. package/dist/cjs/script/formula.js.map +7 -0
  98. package/dist/cjs/script/globals.d.ts +10 -0
  99. package/dist/cjs/script/globals.d.ts.map +1 -1
  100. package/dist/cjs/script/globals.js.map +1 -1
  101. package/dist/cjs/script/index.d.ts +1065 -1006
  102. package/dist/cjs/script/index.d.ts.map +1 -1
  103. package/dist/cjs/script/index.js +530 -60
  104. package/dist/cjs/script/index.js.map +3 -3
  105. package/dist/cjs/script/json.d.ts +117 -0
  106. package/dist/cjs/script/json.d.ts.map +1 -0
  107. package/dist/cjs/script/json.js +321 -0
  108. package/dist/cjs/script/json.js.map +7 -0
  109. package/dist/cjs/str/index.d.ts +50 -75
  110. package/dist/cjs/str/index.d.ts.map +1 -1
  111. package/dist/cjs/str/index.js +2 -2
  112. package/dist/cjs/str/index.js.map +2 -2
  113. package/dist/cjs/strategy/index.d.ts +102 -1
  114. package/dist/cjs/strategy/index.d.ts.map +1 -1
  115. package/dist/cjs/strategy/index.js.map +2 -2
  116. package/dist/cjs/table/index.d.ts +330 -49
  117. package/dist/cjs/table/index.d.ts.map +1 -1
  118. package/dist/cjs/table/index.js +55 -27
  119. package/dist/cjs/table/index.js.map +2 -2
  120. package/dist/cjs/text/index.d.ts +12 -14
  121. package/dist/cjs/text/index.d.ts.map +1 -1
  122. package/dist/cjs/text/index.js.map +2 -2
  123. package/dist/cjs/types/index.d.ts +15 -8
  124. package/dist/cjs/types/index.d.ts.map +1 -1
  125. package/dist/cjs/types/index.js +12 -3
  126. package/dist/cjs/types/index.js.map +2 -2
  127. package/dist/esm/box/index.d.ts +348 -289
  128. package/dist/esm/box/index.d.ts.map +1 -1
  129. package/dist/esm/box/index.js +276 -276
  130. package/dist/esm/box/index.js.map +1 -1
  131. package/dist/esm/check/node.d.ts.map +1 -1
  132. package/dist/esm/check/node.js +1 -0
  133. package/dist/esm/check/node.js.map +1 -1
  134. package/dist/esm/check/preview.d.ts +31 -0
  135. package/dist/esm/check/preview.d.ts.map +1 -0
  136. package/dist/esm/check/preview.js +296 -0
  137. package/dist/esm/check/preview.js.map +1 -0
  138. package/dist/esm/color/index.d.ts +11 -11
  139. package/dist/esm/color/index.js +11 -11
  140. package/dist/esm/color/parse.d.ts +2 -0
  141. package/dist/esm/color/parse.d.ts.map +1 -1
  142. package/dist/esm/color/parse.js +7 -0
  143. package/dist/esm/color/parse.js.map +1 -1
  144. package/dist/esm/compare/index.d.ts +76 -12
  145. package/dist/esm/compare/index.d.ts.map +1 -1
  146. package/dist/esm/compare/index.js +76 -12
  147. package/dist/esm/compare/index.js.map +1 -1
  148. package/dist/esm/drawing/registry.d.ts +28 -5
  149. package/dist/esm/drawing/registry.d.ts.map +1 -1
  150. package/dist/esm/drawing/registry.js +39 -3
  151. package/dist/esm/drawing/registry.js.map +1 -1
  152. package/dist/esm/index.d.ts +1 -1
  153. package/dist/esm/index.js +1 -1
  154. package/dist/esm/label/index.d.ts +265 -187
  155. package/dist/esm/label/index.d.ts.map +1 -1
  156. package/dist/esm/label/index.js +207 -177
  157. package/dist/esm/label/index.js.map +1 -1
  158. package/dist/esm/line/index.d.ts +247 -207
  159. package/dist/esm/line/index.d.ts.map +1 -1
  160. package/dist/esm/line/index.js +202 -194
  161. package/dist/esm/line/index.js.map +1 -1
  162. package/dist/esm/linefill/index.d.ts +61 -89
  163. package/dist/esm/linefill/index.d.ts.map +1 -1
  164. package/dist/esm/linefill/index.js +61 -89
  165. package/dist/esm/linefill/index.js.map +1 -1
  166. package/dist/esm/math/index.d.ts +49 -40
  167. package/dist/esm/math/index.d.ts.map +1 -1
  168. package/dist/esm/math/index.js +22 -9
  169. package/dist/esm/math/index.js.map +1 -1
  170. package/dist/esm/polyline/index.d.ts +57 -78
  171. package/dist/esm/polyline/index.d.ts.map +1 -1
  172. package/dist/esm/polyline/index.js +57 -78
  173. package/dist/esm/polyline/index.js.map +1 -1
  174. package/dist/esm/runtime/input-active.d.ts +2 -2
  175. package/dist/esm/runtime/input-active.js +2 -2
  176. package/dist/esm/runtime/series.d.ts +241 -161
  177. package/dist/esm/runtime/series.d.ts.map +1 -1
  178. package/dist/esm/runtime/series.js +241 -161
  179. package/dist/esm/runtime/series.js.map +1 -1
  180. package/dist/esm/script/api/alert.d.ts +37 -0
  181. package/dist/esm/script/api/alert.d.ts.map +1 -0
  182. package/dist/esm/script/api/alert.js +7 -0
  183. package/dist/esm/script/api/alert.js.map +1 -0
  184. package/dist/esm/script/api/calc.d.ts +232 -0
  185. package/dist/esm/script/api/calc.d.ts.map +1 -0
  186. package/dist/esm/script/api/calc.js +6 -0
  187. package/dist/esm/script/api/calc.js.map +1 -0
  188. package/dist/esm/script/api/color.d.ts +213 -0
  189. package/dist/esm/script/api/color.d.ts.map +1 -0
  190. package/dist/esm/script/api/color.js +6 -0
  191. package/dist/esm/script/api/color.js.map +1 -0
  192. package/dist/esm/script/api/context.d.ts +764 -0
  193. package/dist/esm/script/api/context.d.ts.map +1 -0
  194. package/dist/esm/script/api/context.js +7 -0
  195. package/dist/esm/script/api/context.js.map +1 -0
  196. package/dist/esm/script/api/log.d.ts +58 -0
  197. package/dist/esm/script/api/log.d.ts.map +1 -0
  198. package/dist/esm/script/api/log.js +6 -0
  199. package/dist/esm/script/api/log.js.map +1 -0
  200. package/dist/esm/script/api/strategy.d.ts +391 -0
  201. package/dist/esm/script/api/strategy.d.ts.map +1 -0
  202. package/dist/esm/script/api/strategy.js +7 -0
  203. package/dist/esm/script/api/strategy.js.map +1 -0
  204. package/dist/esm/script/api/ta.d.ts +1012 -0
  205. package/dist/esm/script/api/ta.d.ts.map +1 -0
  206. package/dist/esm/script/api/ta.js +6 -0
  207. package/dist/esm/script/api/ta.js.map +1 -0
  208. package/dist/esm/script/api/table.d.ts +479 -0
  209. package/dist/esm/script/api/table.d.ts.map +1 -0
  210. package/dist/esm/script/api/table.js +7 -0
  211. package/dist/esm/script/api/table.js.map +1 -0
  212. package/dist/esm/script/constants.d.ts +228 -83
  213. package/dist/esm/script/constants.d.ts.map +1 -1
  214. package/dist/esm/script/constants.js +110 -24
  215. package/dist/esm/script/constants.js.map +1 -1
  216. package/dist/esm/script/define.d.ts +94 -0
  217. package/dist/esm/script/define.d.ts.map +1 -0
  218. package/dist/esm/script/define.js +136 -0
  219. package/dist/esm/script/define.js.map +1 -0
  220. package/dist/esm/script/drawing-args.d.ts.map +1 -1
  221. package/dist/esm/script/drawing-args.js +2 -1
  222. package/dist/esm/script/drawing-args.js.map +1 -1
  223. package/dist/esm/script/formula.d.ts +53 -0
  224. package/dist/esm/script/formula.d.ts.map +1 -0
  225. package/dist/esm/script/formula.js +408 -0
  226. package/dist/esm/script/formula.js.map +1 -0
  227. package/dist/esm/script/globals.d.ts +10 -0
  228. package/dist/esm/script/globals.d.ts.map +1 -1
  229. package/dist/esm/script/globals.js.map +1 -1
  230. package/dist/esm/script/index.d.ts +1065 -1006
  231. package/dist/esm/script/index.d.ts.map +1 -1
  232. package/dist/esm/script/index.js +1096 -151
  233. package/dist/esm/script/index.js.map +1 -1
  234. package/dist/esm/script/json.d.ts +117 -0
  235. package/dist/esm/script/json.d.ts.map +1 -0
  236. package/dist/esm/script/json.js +375 -0
  237. package/dist/esm/script/json.js.map +1 -0
  238. package/dist/esm/str/index.d.ts +50 -75
  239. package/dist/esm/str/index.d.ts.map +1 -1
  240. package/dist/esm/str/index.js +51 -76
  241. package/dist/esm/str/index.js.map +1 -1
  242. package/dist/esm/strategy/index.d.ts +102 -1
  243. package/dist/esm/strategy/index.d.ts.map +1 -1
  244. package/dist/esm/strategy/index.js +1 -1
  245. package/dist/esm/strategy/index.js.map +1 -1
  246. package/dist/esm/table/index.d.ts +330 -49
  247. package/dist/esm/table/index.d.ts.map +1 -1
  248. package/dist/esm/table/index.js +372 -61
  249. package/dist/esm/table/index.js.map +1 -1
  250. package/dist/esm/text/index.d.ts +12 -14
  251. package/dist/esm/text/index.d.ts.map +1 -1
  252. package/dist/esm/text/index.js +12 -14
  253. package/dist/esm/text/index.js.map +1 -1
  254. package/dist/esm/types/index.d.ts +15 -8
  255. package/dist/esm/types/index.d.ts.map +1 -1
  256. package/dist/esm/types/index.js +15 -8
  257. package/dist/esm/types/index.js.map +1 -1
  258. package/docs/first-indicator.md +152 -0
  259. package/docs/guide.md +1185 -0
  260. package/docs/inventory.md +772 -0
  261. package/docs/no-code.md +207 -0
  262. package/docs/recipes.md +202 -0
  263. package/package.json +2 -1
  264. package/skills/oakscript/SKILL.md +8 -0
  265. package/skills/oakscript/reference/errors.md +3 -2
  266. package/src/box/index.ts +348 -289
  267. package/src/check/node.ts +1 -0
  268. package/src/check/preview.ts +307 -0
  269. package/src/color/index.ts +11 -11
  270. package/src/color/parse.ts +7 -0
  271. package/src/compare/index.ts +76 -12
  272. package/src/drawing/registry.ts +44 -5
  273. package/src/index.ts +1 -1
  274. package/src/label/index.ts +267 -189
  275. package/src/line/index.ts +248 -208
  276. package/src/linefill/index.ts +61 -89
  277. package/src/math/index.ts +51 -42
  278. package/src/polyline/index.ts +57 -78
  279. package/src/runtime/input-active.ts +2 -2
  280. package/src/runtime/series.ts +243 -163
  281. package/src/script/api/alert.ts +43 -0
  282. package/src/script/api/calc.ts +250 -0
  283. package/src/script/api/color.ts +245 -0
  284. package/src/script/api/context.ts +944 -0
  285. package/src/script/api/log.ts +60 -0
  286. package/src/script/api/strategy.ts +410 -0
  287. package/src/script/api/ta.ts +1115 -0
  288. package/src/script/api/table.ts +538 -0
  289. package/src/script/constants.ts +229 -25
  290. package/src/script/define.ts +221 -0
  291. package/src/script/drawing-args.ts +2 -1
  292. package/src/script/formula.ts +438 -0
  293. package/src/script/globals.ts +10 -0
  294. package/src/script/index.ts +1517 -239
  295. package/src/script/json.ts +457 -0
  296. package/src/str/index.ts +51 -76
  297. package/src/strategy/index.ts +102 -1
  298. package/src/table/index.ts +388 -62
  299. package/src/text/index.ts +12 -14
  300. package/src/types/index.ts +15 -8
@@ -37,80 +37,133 @@ __export(constants_exports, {
37
37
  });
38
38
  module.exports = __toCommonJS(constants_exports);
39
39
  const shape = {
40
+ /** A diagonal cross (x). */
40
41
  xcross: "xcross",
42
+ /** An upright cross (+). */
41
43
  cross: "cross",
44
+ /** A triangle pointing up. */
42
45
  triangleup: "triangleup",
46
+ /** A triangle pointing down. */
43
47
  triangledown: "triangledown",
48
+ /** A small flag. */
44
49
  flag: "flag",
50
+ /** A filled circle. */
45
51
  circle: "circle",
52
+ /** An arrow pointing up. */
46
53
  arrowup: "arrowup",
54
+ /** An arrow pointing down. */
47
55
  arrowdown: "arrowdown",
56
+ /** A label box pointing up (its tip at the value): put it below the bar. */
48
57
  labelup: "labelup",
58
+ /** A label box pointing down (its tip at the value): put it above the bar. */
49
59
  labeldown: "labeldown",
60
+ /** A filled square. */
50
61
  square: "square",
62
+ /** A filled diamond. */
51
63
  diamond: "diamond"
52
64
  };
53
65
  const location = {
66
+ /** Above the high of the bar (the default of `plotshape()` and `plotchar()`). */
54
67
  abovebar: "abovebar",
68
+ /** Below the low of the bar. */
55
69
  belowbar: "belowbar",
70
+ /** At the top edge of the pane. */
56
71
  top: "top",
72
+ /** At the bottom edge of the pane. */
57
73
  bottom: "bottom",
74
+ /** At the value of the series itself, read as a price (bars where it is na or 0 get no marker). */
58
75
  absolute: "absolute"
59
76
  };
60
77
  const size = {
78
+ /** Size chosen by the chart to fit the space. */
61
79
  auto: "auto",
80
+ /** The smallest size. */
62
81
  tiny: "tiny",
82
+ /** Small size. */
63
83
  small: "small",
84
+ /** Normal size. */
64
85
  normal: "normal",
86
+ /** Large size. */
65
87
  large: "large",
88
+ /** The largest size. */
66
89
  huge: "huge"
67
90
  };
68
91
  const xloc = {
92
+ /** Bar indexes: 0 is the first bar, `bar_index` the current one (the default). */
69
93
  bar_index: "bar_index",
94
+ /** UNIX times in milliseconds, such as `time` or `time_close`. */
70
95
  bar_time: "bar_time",
96
+ /** Percents of the pane's width (0 left edge, 100 right edge): the drawing stays in place while the user scrolls and zooms. */
71
97
  pane: "pane"
72
98
  };
73
99
  const yloc = {
100
+ /** At the y value given to the label (the default). */
74
101
  price: "price",
102
+ /** Above the high of the bar at the label's x; the y value is not used. */
75
103
  abovebar: "abovebar",
104
+ /** Below the low of the bar at the label's x; the y value is not used. */
76
105
  belowbar: "belowbar"
77
106
  };
78
107
  const extend = {
108
+ /** Not extended: drawn between its two points only (the default). */
79
109
  none: "none",
110
+ /** Extended to the left edge of the chart, past the first point. */
80
111
  left: "left",
112
+ /** Extended to the right edge of the chart, past the second point. */
81
113
  right: "right",
114
+ /** Extended in both directions. */
82
115
  both: "both"
83
116
  };
84
117
  const display = {
118
+ /** Not shown anywhere; the values still exist for alerts and other scripts. */
85
119
  none: "none",
120
+ /** Shown everywhere: on the pane, in the status line and in the data window. */
86
121
  all: "all",
122
+ /** Shown only in the data window. */
87
123
  data_window: "data_window",
124
+ /** Shown only in the status line of the script. */
88
125
  status_line: "status_line",
126
+ /** Drawn only on the pane, not in the status line or the data window. */
89
127
  pane: "pane"
90
128
  };
91
129
  const format = {
130
+ /** The same format as the chart symbol. */
92
131
  inherit: "inherit",
132
+ /** A price, with the precision of the script or of the symbol. */
93
133
  price: "price",
134
+ /** A volume, shortened with K, M, B, T (12345 shows as "12.345K"). */
94
135
  volume: "volume",
136
+ /** A percentage: two decimals and a "%" sign; the value is not multiplied by 100. */
95
137
  percent: "percent",
138
+ /** Rounded to the tick size of the symbol (`syminfo.mintick`). */
96
139
  mintick: "mintick"
97
140
  };
98
141
  const font = {
142
+ /** The default font of the chart. */
99
143
  family_default: "default",
144
+ /** A monospace font: every character has the same width. */
100
145
  family_monospace: "monospace"
101
146
  };
102
147
  const scale = {
148
+ /** The right price scale. */
103
149
  right: "right",
150
+ /** The left price scale. */
104
151
  left: "left",
152
+ /** No price scale of its own (for overlay scripts). */
105
153
  none: "none"
106
154
  };
107
155
  const order = {
156
+ /** Smallest value first (the default). */
108
157
  ascending: "ascending",
158
+ /** Largest value first. */
109
159
  descending: "descending"
110
160
  };
111
161
  const adjustment = {
162
+ /** Prices not adjusted. */
112
163
  none: "none",
164
+ /** Prices adjusted for splits. */
113
165
  splits: "splits",
166
+ /** Prices adjusted for dividends. */
114
167
  dividends: "dividends"
115
168
  };
116
169
  const CURRENCIES = [
@@ -176,43 +229,77 @@ const currency = {
176
229
  NONE: "NONE"
177
230
  };
178
231
  const labelStyles = {
232
+ /** No shape: the text only. */
179
233
  style_none: "none",
234
+ /** A diagonal cross (x) on the point. */
180
235
  style_xcross: "xcross",
236
+ /** An upright cross (+) on the point. */
181
237
  style_cross: "cross",
238
+ /** A triangle pointing up. */
182
239
  style_triangleup: "triangleup",
240
+ /** A triangle pointing down. */
183
241
  style_triangledown: "triangledown",
242
+ /** A small flag. */
184
243
  style_flag: "flag",
244
+ /** A filled circle. */
185
245
  style_circle: "circle",
246
+ /** An arrow pointing up. */
186
247
  style_arrowup: "arrowup",
248
+ /** An arrow pointing down. */
187
249
  style_arrowdown: "arrowdown",
250
+ /** A text box pointing up: its tip on the point, the box below it. */
188
251
  style_label_up: "label_up",
252
+ /** A text box pointing down: its tip on the point, the box above it. */
189
253
  style_label_down: "label_down",
254
+ /** A text box pointing left: its tip on the point, the box to the right. */
190
255
  style_label_left: "label_left",
256
+ /** A text box pointing right: its tip on the point, the box to the left. */
191
257
  style_label_right: "label_right",
258
+ /** A text box whose lower-left corner is on the point (the box above and to the right). */
192
259
  style_label_lower_left: "label_lower_left",
260
+ /** A text box whose lower-right corner is on the point (the box above and to the left). */
193
261
  style_label_lower_right: "label_lower_right",
262
+ /** A text box whose upper-left corner is on the point (the box below and to the right). */
194
263
  style_label_upper_left: "label_upper_left",
264
+ /** A text box whose upper-right corner is on the point (the box below and to the left). */
195
265
  style_label_upper_right: "label_upper_right",
266
+ /** A text box centred on the point, without a tip. */
196
267
  style_label_center: "label_center",
268
+ /** A filled square. */
197
269
  style_square: "square",
270
+ /** A filled diamond. */
198
271
  style_diamond: "diamond",
272
+ /** The text only, with an outline in the label colour. */
199
273
  style_text_outline: "text_outline"
200
274
  };
201
275
  const lineStyles = {
276
+ /** A solid line (the default). */
202
277
  style_solid: "solid",
278
+ /** A dotted line. */
203
279
  style_dotted: "dotted",
280
+ /** A dashed line. */
204
281
  style_dashed: "dashed",
282
+ /** A solid line with an arrowhead at its first point. */
205
283
  style_arrow_left: "arrow_left",
284
+ /** A solid line with an arrowhead at its second point. */
206
285
  style_arrow_right: "arrow_right",
286
+ /** A solid line with an arrowhead at both ends. */
207
287
  style_arrow_both: "arrow_both"
208
288
  };
209
289
  const daysOfWeek = {
290
+ /** Sunday (1). */
210
291
  sunday: 1,
292
+ /** Monday (2). */
211
293
  monday: 2,
294
+ /** Tuesday (3). */
212
295
  tuesday: 3,
296
+ /** Wednesday (4). */
213
297
  wednesday: 4,
298
+ /** Thursday (5). */
214
299
  thursday: 5,
300
+ /** Friday (6). */
215
301
  friday: 6,
302
+ /** Saturday (7). */
216
303
  saturday: 7
217
304
  };
218
305
  //# sourceMappingURL=constants.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/script/constants.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview PineScript constant namespaces of the script API: `shape.*`, `location.*`, `size.*`, `xloc.*`,\n * `yloc.*`, `extend.*`, `display.*`, `format.*`, `font.*`, `scale.*`, `order.*`, `currency.*`, `adjustment.*`, and the\n * `label.style_*`, `line.style_*`, `dayofweek.*` members. Each constant is the string (or number) the functions take,\n * so `plotshape(cond, \"Buy\", { style: shape.triangleup })` and `{ style: \"triangleup\" }` are the same.\n *\n * @module script/constants\n */\n\n/** PineScript `shape.*`: the shapes of plotshape(). */\nexport const shape = {\n xcross: 'xcross',\n cross: 'cross',\n triangleup: 'triangleup',\n triangledown: 'triangledown',\n flag: 'flag',\n circle: 'circle',\n arrowup: 'arrowup',\n arrowdown: 'arrowdown',\n labelup: 'labelup',\n labeldown: 'labeldown',\n square: 'square',\n diamond: 'diamond',\n} as const;\n\n/** PineScript `location.*`: where plotshape() / plotchar() draw. */\nexport const location = {\n abovebar: 'abovebar',\n belowbar: 'belowbar',\n top: 'top',\n bottom: 'bottom',\n absolute: 'absolute',\n} as const;\n\n/** PineScript `size.*`: sizes of shapes, characters, labels and table texts. */\nexport const size = {\n auto: 'auto',\n tiny: 'tiny',\n small: 'small',\n normal: 'normal',\n large: 'large',\n huge: 'huge',\n} as const;\n\n/**\n * PineScript `xloc.*`: the x coordinate of drawings (bar index or UNIX time in ms). `xloc.pane` is not a Pine value: the x\n * coordinates are percents of the pane's width (0 left edge, 100 right edge), so the drawing stays in place while the\n * user scrolls and zooms.\n */\nexport const xloc = {\n bar_index: 'bar_index',\n bar_time: 'bar_time',\n pane: 'pane',\n} as const;\n\n/** PineScript `yloc.*`: the y position of labels. */\nexport const yloc = {\n price: 'price',\n abovebar: 'abovebar',\n belowbar: 'belowbar',\n} as const;\n\n/** PineScript `extend.*`: line extension. */\nexport const extend = {\n none: 'none',\n left: 'left',\n right: 'right',\n both: 'both',\n} as const;\n\n/** PineScript `display.*`: where a plot or input is shown. */\nexport const display = {\n none: 'none',\n all: 'all',\n data_window: 'data_window',\n status_line: 'status_line',\n pane: 'pane',\n} as const;\n\n/** PineScript `format.*`: the number format of indicator() and str.tostring(). */\nexport const format = {\n inherit: 'inherit',\n price: 'price',\n volume: 'volume',\n percent: 'percent',\n mintick: 'mintick',\n} as const;\n\n/** PineScript `font.*`: font families of labels, boxes and table cells. */\nexport const font = {\n family_default: 'default',\n family_monospace: 'monospace',\n} as const;\n\n/** PineScript `scale.*`: the price scale of indicator() (`scale` option). */\nexport const scale = {\n right: 'right',\n left: 'left',\n none: 'none',\n} as const;\n\n/** PineScript `order.*`: sort order of array.sort() / array.sort_indices() / matrix.sort(). */\nexport const order = {\n ascending: 'ascending',\n descending: 'descending',\n} as const;\n\n/** PineScript `adjustment.*`: price adjustment of a ticker. */\nexport const adjustment = {\n none: 'none',\n splits: 'splits',\n dividends: 'dividends',\n} as const;\n\nconst CURRENCIES = [\n 'AED', 'ARS', 'AUD', 'BDT', 'BHD', 'BRL', 'BTC', 'CAD', 'CHF', 'CLP', 'CNY', 'COP', 'CZK', 'DKK', 'EGP', 'ETH',\n 'EUR', 'GBP', 'GEL', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'ISK', 'JPY', 'KES', 'KRW', 'KWD', 'LKR', 'MAD', 'MXN',\n 'MYR', 'NGN', 'NOK', 'NZD', 'PEN', 'PHP', 'PKR', 'PLN', 'QAR', 'RON', 'RSD', 'RUB', 'SAR', 'SEK', 'SGD', 'THB',\n 'TND', 'TRY', 'TWD', 'USD', 'USDT', 'VES', 'VND', 'ZAR',\n] as const;\n\ntype CurrencyCode = (typeof CURRENCIES)[number];\n\n/** PineScript `currency.*`: currency codes (`strategy(..., { currency })`, `syminfo.currency`); `currency.NONE` is na. */\nexport const currency = {\n ...(Object.fromEntries(CURRENCIES.map((c) => [c, c])) as { readonly [K in CurrencyCode]: K }),\n NONE: 'NONE',\n} as const;\n\n/** PineScript `label.style_*`. */\nexport const labelStyles = {\n style_none: 'none',\n style_xcross: 'xcross',\n style_cross: 'cross',\n style_triangleup: 'triangleup',\n style_triangledown: 'triangledown',\n style_flag: 'flag',\n style_circle: 'circle',\n style_arrowup: 'arrowup',\n style_arrowdown: 'arrowdown',\n style_label_up: 'label_up',\n style_label_down: 'label_down',\n style_label_left: 'label_left',\n style_label_right: 'label_right',\n style_label_lower_left: 'label_lower_left',\n style_label_lower_right: 'label_lower_right',\n style_label_upper_left: 'label_upper_left',\n style_label_upper_right: 'label_upper_right',\n style_label_center: 'label_center',\n style_square: 'square',\n style_diamond: 'diamond',\n style_text_outline: 'text_outline',\n} as const;\n\n/** PineScript `line.style_*` (lines, boxes, polylines). */\nexport const lineStyles = {\n style_solid: 'solid',\n style_dotted: 'dotted',\n style_dashed: 'dashed',\n style_arrow_left: 'arrow_left',\n style_arrow_right: 'arrow_right',\n style_arrow_both: 'arrow_both',\n} as const;\n\n/** PineScript `dayofweek.*`: the values of `dayofweek` (1 = Sunday ... 7 = Saturday). */\nexport const daysOfWeek = {\n sunday: 1,\n monday: 2,\n tuesday: 3,\n wednesday: 4,\n thursday: 5,\n friday: 6,\n saturday: 7,\n} as const;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,QAAQ;AAAA,EACnB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW;AAAA,EACX,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,SAAS;AACX;AAGO,MAAM,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QAAQ;AAAA,EACR,UAAU;AACZ;",
4
+ "sourcesContent": ["/**\n * @fileoverview Constant groups of the script API: `shape.*`, `location.*`, `size.*`, `xloc.*`, `yloc.*`, `extend.*`,\n * `display.*`, `format.*`, `font.*`, `scale.*`, `order.*`, `currency.*`, `adjustment.*`, and the `label.style_*`,\n * `line.style_*`, `dayofweek.*` members. Each constant is the string (or number) the functions take, so\n * `plotshape(cond, \"Buy\", { style: shape.triangleup })` and `{ style: \"triangleup\" }` are the same.\n *\n * @module script/constants\n */\n\n/** Shapes of `plotshape()` (`style` option): `plotshape(cond, \"Buy\", { style: shape.triangleup })`. */\nexport const shape = {\n /** A diagonal cross (x). */\n xcross: 'xcross',\n /** An upright cross (+). */\n cross: 'cross',\n /** A triangle pointing up. */\n triangleup: 'triangleup',\n /** A triangle pointing down. */\n triangledown: 'triangledown',\n /** A small flag. */\n flag: 'flag',\n /** A filled circle. */\n circle: 'circle',\n /** An arrow pointing up. */\n arrowup: 'arrowup',\n /** An arrow pointing down. */\n arrowdown: 'arrowdown',\n /** A label box pointing up (its tip at the value): put it below the bar. */\n labelup: 'labelup',\n /** A label box pointing down (its tip at the value): put it above the bar. */\n labeldown: 'labeldown',\n /** A filled square. */\n square: 'square',\n /** A filled diamond. */\n diamond: 'diamond',\n} as const;\n\n/** Where `plotshape()` and `plotchar()` draw their marker (`location` option). */\nexport const location = {\n /** Above the high of the bar (the default of `plotshape()` and `plotchar()`). */\n abovebar: 'abovebar',\n /** Below the low of the bar. */\n belowbar: 'belowbar',\n /** At the top edge of the pane. */\n top: 'top',\n /** At the bottom edge of the pane. */\n bottom: 'bottom',\n /** At the value of the series itself, read as a price (bars where it is na or 0 get no marker). */\n absolute: 'absolute',\n} as const;\n\n/** Sizes of shapes, characters, labels and table texts (`size` / `text_size` options). */\nexport const size = {\n /** Size chosen by the chart to fit the space. */\n auto: 'auto',\n /** The smallest size. */\n tiny: 'tiny',\n /** Small size. */\n small: 'small',\n /** Normal size. */\n normal: 'normal',\n /** Large size. */\n large: 'large',\n /** The largest size. */\n huge: 'huge',\n} as const;\n\n/** What the x coordinates of a drawing (label, line, box, polyline) are (`xloc` option). */\nexport const xloc = {\n /** Bar indexes: 0 is the first bar, `bar_index` the current one (the default). */\n bar_index: 'bar_index',\n /** UNIX times in milliseconds, such as `time` or `time_close`. */\n bar_time: 'bar_time',\n /** Percents of the pane's width (0 left edge, 100 right edge): the drawing stays in place while the user scrolls and zooms. */\n pane: 'pane',\n} as const;\n\n/** Vertical placement of a label (`label.new(..., { yloc })`). */\nexport const yloc = {\n /** At the y value given to the label (the default). */\n price: 'price',\n /** Above the high of the bar at the label's x; the y value is not used. */\n abovebar: 'abovebar',\n /** Below the low of the bar at the label's x; the y value is not used. */\n belowbar: 'belowbar',\n} as const;\n\n/** How far a line (or a box's top and bottom) is drawn past its two points (`extend` option). */\nexport const extend = {\n /** Not extended: drawn between its two points only (the default). */\n none: 'none',\n /** Extended to the left edge of the chart, past the first point. */\n left: 'left',\n /** Extended to the right edge of the chart, past the second point. */\n right: 'right',\n /** Extended in both directions. */\n both: 'both',\n} as const;\n\n/** Where a plot or an input value is shown (`display` option). */\nexport const display = {\n /** Not shown anywhere; the values still exist for alerts and other scripts. */\n none: 'none',\n /** Shown everywhere: on the pane, in the status line and in the data window. */\n all: 'all',\n /** Shown only in the data window. */\n data_window: 'data_window',\n /** Shown only in the status line of the script. */\n status_line: 'status_line',\n /** Drawn only on the pane, not in the status line or the data window. */\n pane: 'pane',\n} as const;\n\n/** Number formats: the `format` option of `indicator()` and the format of `str.tostring()`. */\nexport const format = {\n /** The same format as the chart symbol. */\n inherit: 'inherit',\n /** A price, with the precision of the script or of the symbol. */\n price: 'price',\n /** A volume, shortened with K, M, B, T (12345 shows as \"12.345K\"). */\n volume: 'volume',\n /** A percentage: two decimals and a \"%\" sign; the value is not multiplied by 100. */\n percent: 'percent',\n /** Rounded to the tick size of the symbol (`syminfo.mintick`). */\n mintick: 'mintick',\n} as const;\n\n/** Font families of labels, boxes and table cells (`text_font_family` option). */\nexport const font = {\n /** The default font of the chart. */\n family_default: 'default',\n /** A monospace font: every character has the same width. */\n family_monospace: 'monospace',\n} as const;\n\n/** Price scale a script is attached to (`indicator(..., { scale })`). */\nexport const scale = {\n /** The right price scale. */\n right: 'right',\n /** The left price scale. */\n left: 'left',\n /** No price scale of its own (for overlay scripts). */\n none: 'none',\n} as const;\n\n/** Sort order of `array.sort()`, `array.sort_indices()` and `matrix.sort()`. */\nexport const order = {\n /** Smallest value first (the default). */\n ascending: 'ascending',\n /** Largest value first. */\n descending: 'descending',\n} as const;\n\n/** Price adjustment of a ticker. Kept for compatibility: no function of the library reads it yet. */\nexport const adjustment = {\n /** Prices not adjusted. */\n none: 'none',\n /** Prices adjusted for splits. */\n splits: 'splits',\n /** Prices adjusted for dividends. */\n dividends: 'dividends',\n} as const;\n\nconst CURRENCIES = [\n 'AED', 'ARS', 'AUD', 'BDT', 'BHD', 'BRL', 'BTC', 'CAD', 'CHF', 'CLP', 'CNY', 'COP', 'CZK', 'DKK', 'EGP', 'ETH',\n 'EUR', 'GBP', 'GEL', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'ISK', 'JPY', 'KES', 'KRW', 'KWD', 'LKR', 'MAD', 'MXN',\n 'MYR', 'NGN', 'NOK', 'NZD', 'PEN', 'PHP', 'PKR', 'PLN', 'QAR', 'RON', 'RSD', 'RUB', 'SAR', 'SEK', 'SGD', 'THB',\n 'TND', 'TRY', 'TWD', 'USD', 'USDT', 'VES', 'VND', 'ZAR',\n] as const;\n\ntype CurrencyCode = (typeof CURRENCIES)[number];\n\n/** The members of `currency`: one constant per currency code, its value the code itself. */\nexport interface CurrencyConstants {\n /** United Arab Emirates dirham. */\n readonly AED: 'AED';\n /** Argentine peso. */\n readonly ARS: 'ARS';\n /** Australian dollar. */\n readonly AUD: 'AUD';\n /** Bangladeshi taka. */\n readonly BDT: 'BDT';\n /** Bahraini dinar. */\n readonly BHD: 'BHD';\n /** Brazilian real. */\n readonly BRL: 'BRL';\n /** Bitcoin. */\n readonly BTC: 'BTC';\n /** Canadian dollar. */\n readonly CAD: 'CAD';\n /** Swiss franc. */\n readonly CHF: 'CHF';\n /** Chilean peso. */\n readonly CLP: 'CLP';\n /** Chinese yuan. */\n readonly CNY: 'CNY';\n /** Colombian peso. */\n readonly COP: 'COP';\n /** Czech koruna. */\n readonly CZK: 'CZK';\n /** Danish krone. */\n readonly DKK: 'DKK';\n /** Egyptian pound. */\n readonly EGP: 'EGP';\n /** Ether. */\n readonly ETH: 'ETH';\n /** Euro. */\n readonly EUR: 'EUR';\n /** Pound sterling. */\n readonly GBP: 'GBP';\n /** Georgian lari. */\n readonly GEL: 'GEL';\n /** Hong Kong dollar. */\n readonly HKD: 'HKD';\n /** Hungarian forint. */\n readonly HUF: 'HUF';\n /** Indonesian rupiah. */\n readonly IDR: 'IDR';\n /** Israeli new shekel. */\n readonly ILS: 'ILS';\n /** Indian rupee. */\n readonly INR: 'INR';\n /** Icelandic krona. */\n readonly ISK: 'ISK';\n /** Japanese yen. */\n readonly JPY: 'JPY';\n /** Kenyan shilling. */\n readonly KES: 'KES';\n /** South Korean won. */\n readonly KRW: 'KRW';\n /** Kuwaiti dinar. */\n readonly KWD: 'KWD';\n /** Sri Lankan rupee. */\n readonly LKR: 'LKR';\n /** Moroccan dirham. */\n readonly MAD: 'MAD';\n /** Mexican peso. */\n readonly MXN: 'MXN';\n /** Malaysian ringgit. */\n readonly MYR: 'MYR';\n /** Nigerian naira. */\n readonly NGN: 'NGN';\n /** Norwegian krone. */\n readonly NOK: 'NOK';\n /** New Zealand dollar. */\n readonly NZD: 'NZD';\n /** Peruvian sol. */\n readonly PEN: 'PEN';\n /** Philippine peso. */\n readonly PHP: 'PHP';\n /** Pakistani rupee. */\n readonly PKR: 'PKR';\n /** Polish zloty. */\n readonly PLN: 'PLN';\n /** Qatari riyal. */\n readonly QAR: 'QAR';\n /** Romanian leu. */\n readonly RON: 'RON';\n /** Serbian dinar. */\n readonly RSD: 'RSD';\n /** Russian ruble. */\n readonly RUB: 'RUB';\n /** Saudi riyal. */\n readonly SAR: 'SAR';\n /** Swedish krona. */\n readonly SEK: 'SEK';\n /** Singapore dollar. */\n readonly SGD: 'SGD';\n /** Thai baht. */\n readonly THB: 'THB';\n /** Tunisian dinar. */\n readonly TND: 'TND';\n /** Turkish lira. */\n readonly TRY: 'TRY';\n /** New Taiwan dollar. */\n readonly TWD: 'TWD';\n /** United States dollar. */\n readonly USD: 'USD';\n /** Tether (USDT). */\n readonly USDT: 'USDT';\n /** Venezuelan bolivar. */\n readonly VES: 'VES';\n /** Vietnamese dong. */\n readonly VND: 'VND';\n /** South African rand. */\n readonly ZAR: 'ZAR';\n /** No currency (na). */\n readonly NONE: 'NONE';\n}\n\n/**\n * Currency codes, such as the `currency` option of `strategy()` or the value of `syminfo.currency`\n * (`currency.USD` is \"USD\"). `currency.NONE` means no currency (na).\n */\nexport const currency: CurrencyConstants = {\n ...(Object.fromEntries(CURRENCIES.map((c) => [c, c])) as { readonly [K in CurrencyCode]: K }),\n NONE: 'NONE',\n} as const;\n\n/** Label styles, available as `label.style_*` (`label.new(..., { style })`). */\nexport const labelStyles = {\n /** No shape: the text only. */\n style_none: 'none',\n /** A diagonal cross (x) on the point. */\n style_xcross: 'xcross',\n /** An upright cross (+) on the point. */\n style_cross: 'cross',\n /** A triangle pointing up. */\n style_triangleup: 'triangleup',\n /** A triangle pointing down. */\n style_triangledown: 'triangledown',\n /** A small flag. */\n style_flag: 'flag',\n /** A filled circle. */\n style_circle: 'circle',\n /** An arrow pointing up. */\n style_arrowup: 'arrowup',\n /** An arrow pointing down. */\n style_arrowdown: 'arrowdown',\n /** A text box pointing up: its tip on the point, the box below it. */\n style_label_up: 'label_up',\n /** A text box pointing down: its tip on the point, the box above it. */\n style_label_down: 'label_down',\n /** A text box pointing left: its tip on the point, the box to the right. */\n style_label_left: 'label_left',\n /** A text box pointing right: its tip on the point, the box to the left. */\n style_label_right: 'label_right',\n /** A text box whose lower-left corner is on the point (the box above and to the right). */\n style_label_lower_left: 'label_lower_left',\n /** A text box whose lower-right corner is on the point (the box above and to the left). */\n style_label_lower_right: 'label_lower_right',\n /** A text box whose upper-left corner is on the point (the box below and to the right). */\n style_label_upper_left: 'label_upper_left',\n /** A text box whose upper-right corner is on the point (the box below and to the left). */\n style_label_upper_right: 'label_upper_right',\n /** A text box centred on the point, without a tip. */\n style_label_center: 'label_center',\n /** A filled square. */\n style_square: 'square',\n /** A filled diamond. */\n style_diamond: 'diamond',\n /** The text only, with an outline in the label colour. */\n style_text_outline: 'text_outline',\n} as const;\n\n/** Line styles, available as `line.style_*` (lines, boxes and polylines). */\nexport const lineStyles = {\n /** A solid line (the default). */\n style_solid: 'solid',\n /** A dotted line. */\n style_dotted: 'dotted',\n /** A dashed line. */\n style_dashed: 'dashed',\n /** A solid line with an arrowhead at its first point. */\n style_arrow_left: 'arrow_left',\n /** A solid line with an arrowhead at its second point. */\n style_arrow_right: 'arrow_right',\n /** A solid line with an arrowhead at both ends. */\n style_arrow_both: 'arrow_both',\n} as const;\n\n/** Days of the week as `dayofweek()` gives them, available as `dayofweek.*` (1 = Sunday ... 7 = Saturday). */\nexport const daysOfWeek = {\n /** Sunday (1). */\n sunday: 1,\n /** Monday (2). */\n monday: 2,\n /** Tuesday (3). */\n tuesday: 3,\n /** Wednesday (4). */\n wednesday: 4,\n /** Thursday (5). */\n thursday: 5,\n /** Friday (6). */\n friday: 6,\n /** Saturday (7). */\n saturday: 7,\n} as const;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,QAAQ;AAAA;AAAA,EAEnB,QAAQ;AAAA;AAAA,EAER,OAAO;AAAA;AAAA,EAEP,YAAY;AAAA;AAAA,EAEZ,cAAc;AAAA;AAAA,EAEd,MAAM;AAAA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e;AAAA;AAAA,EAEf,iBAAiB;AAAA;AAAA,EAEjB,gBAAgB;AAAA;AAAA,EAEhB,kBAAkB;AAAA;AAAA,EAElB,kBAAkB;AAAA;AAAA,EAElB,mBAAmB;AAAA;AAAA,EAEnB,wBAAwB;AAAA;AAAA,EAExB,yBAAyB;AAAA;AAAA,EAEzB,wBAAwB;AAAA;AAAA,EAExB,yBAAyB;AAAA;AAAA,EAEzB,oBAAoB;AAAA;AAAA,EAEpB,cAAc;AAAA;AAAA,EAEd,eAAe;AAAA;AAAA,EAEf,oBAAoB;AACtB;AAGO,MAAM,aAAa;AAAA;AAAA,EAExB,aAAa;AAAA;AAAA,EAEb,cAAc;AAAA;AAAA,EAEd,cAAc;AAAA;AAAA,EAEd,kBAAkB;AAAA;AAAA,EAElB,mBAAmB;AAAA;AAAA,EAEnB,kBAAkB;AACpB;AAGO,MAAM,aAAa;AAAA;AAAA,EAExB,QAAQ;AAAA;AAAA,EAER,QAAQ;AAAA;AAAA,EAER,SAAS;AAAA;AAAA,EAET,WAAW;AAAA;AAAA,EAEX,UAAU;AAAA;AAAA,EAEV,QAAQ;AAAA;AAAA,EAER,UAAU;AACZ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * `defineIndicator()`: a script body made into a ready-to-use indicator. The body is written once (indicator(),
3
+ * input.*(), plot()...); its settings (inputs and their defaults, plots, levels, alerts, title, pane) are read from it
4
+ * and its calculation runs on any bars. Not a PineScript function: a shortcut over executeScript() / createScriptRun().
5
+ */
6
+ import type { Bar } from '../types/index.js';
7
+ import type { IndicatorResult } from '../types/metadata.js';
8
+ import type { ArrowConfig, BarColorConfig, CandleConfig, FillConfig, HLineConfig, InputConfig, PlotConfig, ShapeConfig } from '../runtime/types.js';
9
+ import { type AlertConditionConfig, type ChartContext, type ScriptOutput, type ScriptRunResult } from './index.js';
10
+ export interface DefineIndicatorOptions {
11
+ /**
12
+ * Strict mode (default true): a wrong input value or name, an unknown option of plot()... or a text that is not a
13
+ * colour throws a `ScriptError` that says what to change. false: the PineScript behaviour (mistakes pass silently).
14
+ */
15
+ strict?: boolean;
16
+ /**
17
+ * Called with each warning of a calculation (drawings deleted over their maximum count...). Default: `console.warn`.
18
+ * Give `() => {}` to keep them quiet; `run()` returns them too.
19
+ */
20
+ onWarning?: ((message: string) => void) | null;
21
+ /**
22
+ * Colours of the plots that give none (default true: each takes the next colour of `DEFAULT_PALETTE`; false: all blue,
23
+ * as in PineScript; or a list of colours).
24
+ */
25
+ palette?: boolean | readonly string[];
26
+ /** Plot ids: 'index' (default: plot0, plot1...) or 'title' (made from the titles: "Fast MA" gives fast_ma). */
27
+ plotIds?: 'index' | 'title';
28
+ }
29
+ /** What a calculation returns: the plots by plot id, markers, colours and drawings (`IndicatorResult`). */
30
+ export type IndicatorCalculation = ScriptRunResult['result'];
31
+ /** A live calculation: each update calculates the bars from the forming bar of the previous one when it can. */
32
+ export interface IndicatorLiveRun {
33
+ update(bars: Bar[], chart?: ChartContext): IndicatorCalculation & {
34
+ from: number;
35
+ };
36
+ /** Why the updates calculate every bar (null: they calculate the newest bars only). */
37
+ readonly fullRunReason: string | null;
38
+ }
39
+ /** An indicator made by {@link defineIndicator}. */
40
+ export interface IndicatorDefinition {
41
+ /** A name made from the title ("My RSI" gives "my-rsi"), e.g. for a registry. */
42
+ readonly id: string;
43
+ /** Title, short title, pane (`overlay`: true on the price chart, false in its own pane), price format. */
44
+ readonly metadata: ScriptRunResult['metadata'] & {
45
+ shortTitle: string;
46
+ };
47
+ /** The inputs, as the settings dialog lists them. */
48
+ readonly inputConfig: InputConfig[];
49
+ /** The default value of each input, by input id. */
50
+ readonly defaultInputs: Record<string, unknown>;
51
+ readonly plotConfig: PlotConfig[];
52
+ readonly hlineConfig: HLineConfig[];
53
+ readonly fillConfig: FillConfig[];
54
+ readonly shapeConfig: ShapeConfig[];
55
+ readonly arrowConfig: ArrowConfig[];
56
+ readonly barColorConfig: BarColorConfig[];
57
+ readonly candleConfig: CandleConfig[];
58
+ /** The alertcondition() declarations; a calculation gives the bars on which each one is true (`alerts`). */
59
+ readonly alertConditions: AlertConditionConfig[];
60
+ /** The outputs in declaration order. */
61
+ readonly outputs: ScriptOutput[];
62
+ /**
63
+ * The indicator on `bars` (oldest first, time in UNIX seconds). `inputs`: the values to change, by input id (the
64
+ * others keep their default).
65
+ */
66
+ calculate(bars: Bar[], inputs?: Record<string, unknown>, chart?: ChartContext): IndicatorCalculation;
67
+ /** Everything a run produced: the calculation (`result`), the declarations and the warnings. */
68
+ run(bars: Bar[], inputs?: Record<string, unknown>, chart?: ChartContext): ScriptRunResult;
69
+ /** A live calculation for a chart whose last bar changes (see `createScriptRun`). */
70
+ createRun(inputs?: Record<string, unknown>, chart?: ChartContext): IndicatorLiveRun;
71
+ }
72
+ /**
73
+ * Host-side: makes an indicator of a script body, for a program that runs scripts (a script does not call it):
74
+ *
75
+ * ```js
76
+ * const ewo = defineIndicator(() => {
77
+ * indicator('Elliott Wave Oscillator');
78
+ * const fast = input.int(5, 'Fast length', { minval: 1 });
79
+ * const slow = input.int(35, 'Slow length', { minval: 1 });
80
+ * plot(ta.ema(close, fast).sub(ta.ema(close, slow)), 'EWO', { style: plot.style_histogram });
81
+ * });
82
+ * ewo.inputConfig; // the two inputs, for a settings dialog
83
+ * ewo.calculate(bars, { fast_length: 8 }).plots.plot0;
84
+ * ```
85
+ *
86
+ * The declarations are read from a first run on two sample bars, the first time they are asked for. Strict mode is on
87
+ * by default (see {@link DefineIndicatorOptions}).
88
+ * @param body - The script: a function that runs its statements (`indicator()`, inputs, plots...).
89
+ * @param options - Strict mode and the other run options. Default: `{}`.
90
+ * @returns The indicator: its declarations (title, inputs, outputs) and `calculate` / `run` / `createRun`.
91
+ */
92
+ export declare function defineIndicator(body: () => void, options?: DefineIndicatorOptions): IndicatorDefinition;
93
+ export type { IndicatorResult };
94
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"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AM,IAAI,EAAE,OAAO,GAAE,sBAA2B,GAAG,mBAAmB,CAgG3G;AAED,YAAY,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,127 @@
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 define_exports = {};
20
+ __export(define_exports, {
21
+ defineIndicator: () => defineIndicator
22
+ });
23
+ module.exports = __toCommonJS(define_exports);
24
+ var import_index = require("./index.js");
25
+ const PROBE_BARS = Array.from({ length: 200 }, (_, i) => {
26
+ const close = 5e3 + 300 * Math.sin(i / 9) + 120 * Math.sin(i / 3.1) + i;
27
+ const open = 5e3 + 300 * Math.sin((i - 1) / 9) + 120 * Math.sin((i - 1) / 3.1) + i - 1;
28
+ return { time: 86400 * (i + 1), open, high: Math.max(open, close) + 25, low: Math.min(open, close) - 25, close, volume: 1e6 + 2e5 * Math.sin(i / 5) };
29
+ });
30
+ const slug = (title) => title.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "indicator";
31
+ function defineIndicator(body, options = {}) {
32
+ if (typeof body !== "function") {
33
+ throw new TypeError('defineIndicator(): give the script as a function, e.g. defineIndicator(() => { indicator("My indicator"); plot(close); }).');
34
+ }
35
+ const strict = options.strict ?? true;
36
+ const runOptions = { strict, palette: options.palette ?? true, plotIds: options.plotIds ?? "index" };
37
+ const warn = options.onWarning === void 0 ? (m) => console.warn(m) : options.onWarning;
38
+ let probe = null;
39
+ const declared = () => {
40
+ if (probe) return probe;
41
+ let run;
42
+ try {
43
+ run = (0, import_index.executeScript)(body, PROBE_BARS, {}, {}, runOptions);
44
+ } catch (err) {
45
+ if (err instanceof import_index.ScriptError) throw err;
46
+ const why = err instanceof Error ? err.message : String(err);
47
+ throw new Error(`defineIndicator(): the script could not run on sample bars, so its settings are unknown: ${why}`, { cause: err });
48
+ }
49
+ if (run.strategyConfig) throw new Error('defineIndicator(): this script declares strategy(); write indicator("...") instead.');
50
+ if (run.metadata.title === "Untitled" && run.inputConfig.length + run.plotConfig.length > 0) {
51
+ throw new Error('defineIndicator(): start the script with indicator("Its title"), e.g. indicator("My RSI").');
52
+ }
53
+ probe = run;
54
+ return run;
55
+ };
56
+ const report = (run) => {
57
+ const d = declared();
58
+ if (d.metadata.pane === "auto") {
59
+ run.metadata.overlay = d.metadata.overlay;
60
+ if (run.result.metadata) run.result.metadata.overlay = d.metadata.overlay;
61
+ }
62
+ if (warn) for (const w of run.warnings) warn(`${d.metadata.title}: ${w}`);
63
+ return run;
64
+ };
65
+ const execute = (bars, inputs = {}, chart = {}) => {
66
+ declared();
67
+ return report((0, import_index.executeScript)(body, bars, inputs, chart, runOptions));
68
+ };
69
+ return {
70
+ get id() {
71
+ return slug(declared().metadata.title);
72
+ },
73
+ get metadata() {
74
+ const m = declared().metadata;
75
+ return { ...m, shortTitle: m.shortTitle ?? m.title };
76
+ },
77
+ get inputConfig() {
78
+ return declared().inputConfig;
79
+ },
80
+ get defaultInputs() {
81
+ return { ...declared().defaultInputs };
82
+ },
83
+ get plotConfig() {
84
+ return declared().plotConfig;
85
+ },
86
+ get hlineConfig() {
87
+ return declared().hlineConfig;
88
+ },
89
+ get fillConfig() {
90
+ return declared().fillConfig;
91
+ },
92
+ get shapeConfig() {
93
+ return declared().shapeConfig;
94
+ },
95
+ get arrowConfig() {
96
+ return declared().arrowConfig;
97
+ },
98
+ get barColorConfig() {
99
+ return declared().barColorConfig;
100
+ },
101
+ get candleConfig() {
102
+ return declared().candleConfig;
103
+ },
104
+ get alertConditions() {
105
+ return declared().alertConfig;
106
+ },
107
+ get outputs() {
108
+ return declared().outputs;
109
+ },
110
+ calculate: (bars, inputs, chart) => execute(bars, inputs, chart).result,
111
+ run: execute,
112
+ createRun(inputs = {}, chart = {}) {
113
+ declared();
114
+ const live = (0, import_index.createScriptRun)(body, inputs, chart, runOptions);
115
+ return {
116
+ update(bars, next) {
117
+ const u = report(live.update(bars, next));
118
+ return Object.assign(u.result, { from: u.from });
119
+ },
120
+ get fullRunReason() {
121
+ return live.fullRunReason;
122
+ }
123
+ };
124
+ }
125
+ };
126
+ }
127
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/script/define.ts"],
4
+ "sourcesContent": ["/**\n * `defineIndicator()`: a script body made into a ready-to-use indicator. The body is written once (indicator(),\n * input.*(), plot()...); its settings (inputs and their defaults, plots, levels, alerts, title, pane) are read from it\n * and its calculation runs on any bars. Not a PineScript function: a shortcut over executeScript() / createScriptRun().\n */\nimport type { Bar } from '../types/index.js';\nimport type { IndicatorResult } from '../types/metadata.js';\nimport type {\n ArrowConfig,\n BarColorConfig,\n CandleConfig,\n FillConfig,\n HLineConfig,\n InputConfig,\n PlotConfig,\n ShapeConfig,\n} from '../runtime/types.js';\nimport {\n createScriptRun,\n executeScript,\n ScriptError,\n type AlertConditionConfig,\n type ChartContext,\n type ScriptOutput,\n type ScriptRunResult,\n} from './index.js';\n\nexport interface DefineIndicatorOptions {\n /**\n * Strict mode (default true): a wrong input value or name, an unknown option of plot()... or a text that is not a\n * colour throws a `ScriptError` that says what to change. false: the PineScript behaviour (mistakes pass silently).\n */\n strict?: boolean;\n /**\n * Called with each warning of a calculation (drawings deleted over their maximum count...). Default: `console.warn`.\n * Give `() => {}` to keep them quiet; `run()` returns them too.\n */\n onWarning?: ((message: string) => void) | null;\n /**\n * Colours of the plots that give none (default true: each takes the next colour of `DEFAULT_PALETTE`; false: all blue,\n * as in PineScript; or a list of colours).\n */\n palette?: boolean | readonly string[];\n /** Plot ids: 'index' (default: plot0, plot1...) or 'title' (made from the titles: \"Fast MA\" gives fast_ma). */\n plotIds?: 'index' | 'title';\n}\n\n/** What a calculation returns: the plots by plot id, markers, colours and drawings (`IndicatorResult`). */\nexport type IndicatorCalculation = ScriptRunResult['result'];\n\n/** A live calculation: each update calculates the bars from the forming bar of the previous one when it can. */\nexport interface IndicatorLiveRun {\n update(bars: Bar[], chart?: ChartContext): IndicatorCalculation & { from: number };\n /** Why the updates calculate every bar (null: they calculate the newest bars only). */\n readonly fullRunReason: string | null;\n}\n\n/** An indicator made by {@link defineIndicator}. */\nexport interface IndicatorDefinition {\n /** A name made from the title (\"My RSI\" gives \"my-rsi\"), e.g. for a registry. */\n readonly id: string;\n /** Title, short title, pane (`overlay`: true on the price chart, false in its own pane), price format. */\n readonly metadata: ScriptRunResult['metadata'] & { shortTitle: string };\n /** The inputs, as the settings dialog lists them. */\n readonly inputConfig: InputConfig[];\n /** The default value of each input, by input id. */\n readonly defaultInputs: Record<string, unknown>;\n readonly plotConfig: PlotConfig[];\n readonly hlineConfig: HLineConfig[];\n readonly fillConfig: FillConfig[];\n readonly shapeConfig: ShapeConfig[];\n readonly arrowConfig: ArrowConfig[];\n readonly barColorConfig: BarColorConfig[];\n readonly candleConfig: CandleConfig[];\n /** The alertcondition() declarations; a calculation gives the bars on which each one is true (`alerts`). */\n readonly alertConditions: AlertConditionConfig[];\n /** The outputs in declaration order. */\n readonly outputs: ScriptOutput[];\n /**\n * The indicator on `bars` (oldest first, time in UNIX seconds). `inputs`: the values to change, by input id (the\n * others keep their default).\n */\n calculate(bars: Bar[], inputs?: Record<string, unknown>, chart?: ChartContext): IndicatorCalculation;\n /** Everything a run produced: the calculation (`result`), the declarations and the warnings. */\n run(bars: Bar[], inputs?: Record<string, unknown>, chart?: ChartContext): ScriptRunResult;\n /** A live calculation for a chart whose last bar changes (see `createScriptRun`). */\n createRun(inputs?: Record<string, unknown>, chart?: ChartContext): IndicatorLiveRun;\n}\n\n/**\n * The sample bars on which the declarations are read: 200 days of prices around 5000, far from the 0-100 range of\n * oscillators, so that indicator(..., { pane: 'auto' }) tells a price line from an oscillator.\n */\nconst PROBE_BARS: Bar[] = Array.from({ length: 200 }, (_, i) => {\n const close = 5000 + 300 * Math.sin(i / 9) + 120 * Math.sin(i / 3.1) + i;\n const open = 5000 + 300 * Math.sin((i - 1) / 9) + 120 * Math.sin((i - 1) / 3.1) + i - 1;\n return { time: 86400 * (i + 1), open, high: Math.max(open, close) + 25, low: Math.min(open, close) - 25, close, volume: 1e6 + 2e5 * Math.sin(i / 5) };\n});\n\nconst slug = (title: string): string =>\n title.toLowerCase().normalize('NFKD').replace(/[\u0300-\u036F]/g, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'indicator';\n\n/**\n * Host-side: makes an indicator of a script body, for a program that runs scripts (a script does not call it):\n *\n * ```js\n * const ewo = defineIndicator(() => {\n * indicator('Elliott Wave Oscillator');\n * const fast = input.int(5, 'Fast length', { minval: 1 });\n * const slow = input.int(35, 'Slow length', { minval: 1 });\n * plot(ta.ema(close, fast).sub(ta.ema(close, slow)), 'EWO', { style: plot.style_histogram });\n * });\n * ewo.inputConfig; // the two inputs, for a settings dialog\n * ewo.calculate(bars, { fast_length: 8 }).plots.plot0;\n * ```\n *\n * The declarations are read from a first run on two sample bars, the first time they are asked for. Strict mode is on\n * by default (see {@link DefineIndicatorOptions}).\n * @param body - The script: a function that runs its statements (`indicator()`, inputs, plots...).\n * @param options - Strict mode and the other run options. Default: `{}`.\n * @returns The indicator: its declarations (title, inputs, outputs) and `calculate` / `run` / `createRun`.\n */\nexport function defineIndicator(body: () => void, options: DefineIndicatorOptions = {}): IndicatorDefinition {\n if (typeof body !== 'function') {\n throw new TypeError('defineIndicator(): give the script as a function, e.g. defineIndicator(() => { indicator(\"My indicator\"); plot(close); }).');\n }\n const strict = options.strict ?? true;\n const runOptions = { strict, palette: options.palette ?? true, plotIds: options.plotIds ?? 'index' } as const;\n const warn = options.onWarning === undefined ? (m: string) => console.warn(m) : options.onWarning;\n let probe: ScriptRunResult | null = null;\n const declared = (): ScriptRunResult => {\n if (probe) return probe;\n let run: ScriptRunResult;\n try {\n run = executeScript(body, PROBE_BARS, {}, {}, runOptions);\n } catch (err) {\n if (err instanceof ScriptError) throw err;\n const why = err instanceof Error ? err.message : String(err);\n throw new Error(`defineIndicator(): the script could not run on sample bars, so its settings are unknown: ${why}`, { cause: err });\n }\n if (run.strategyConfig) throw new Error('defineIndicator(): this script declares strategy(); write indicator(\"...\") instead.');\n if (run.metadata.title === 'Untitled' && run.inputConfig.length + run.plotConfig.length > 0) {\n throw new Error('defineIndicator(): start the script with indicator(\"Its title\"), e.g. indicator(\"My RSI\").');\n }\n probe = run;\n return run;\n };\n const report = <R extends ScriptRunResult>(run: R): R => {\n const d = declared();\n // pane 'auto': the pane chosen on the sample bars, whatever the bars of the run\n if (d.metadata.pane === 'auto') {\n run.metadata.overlay = d.metadata.overlay;\n if (run.result.metadata) run.result.metadata.overlay = d.metadata.overlay;\n }\n if (warn) for (const w of run.warnings) warn(`${d.metadata.title}: ${w}`);\n return run;\n };\n const execute = (bars: Bar[], inputs: Record<string, unknown> = {}, chart: ChartContext = {}): ScriptRunResult => {\n declared();\n return report(executeScript(body, bars, inputs, chart, runOptions));\n };\n return {\n get id() {\n return slug(declared().metadata.title);\n },\n get metadata() {\n const m = declared().metadata;\n return { ...m, shortTitle: m.shortTitle ?? m.title };\n },\n get inputConfig() {\n return declared().inputConfig;\n },\n get defaultInputs() {\n return { ...declared().defaultInputs };\n },\n get plotConfig() {\n return declared().plotConfig;\n },\n get hlineConfig() {\n return declared().hlineConfig;\n },\n get fillConfig() {\n return declared().fillConfig;\n },\n get shapeConfig() {\n return declared().shapeConfig;\n },\n get arrowConfig() {\n return declared().arrowConfig;\n },\n get barColorConfig() {\n return declared().barColorConfig;\n },\n get candleConfig() {\n return declared().candleConfig;\n },\n get alertConditions() {\n return declared().alertConfig;\n },\n get outputs() {\n return declared().outputs;\n },\n calculate: (bars, inputs, chart) => execute(bars, inputs, chart).result,\n run: execute,\n createRun(inputs = {}, chart = {}) {\n declared();\n const live = createScriptRun(body, inputs, chart, runOptions);\n return {\n update(bars: Bar[], next?: ChartContext) {\n const u = report(live.update(bars, next));\n return Object.assign(u.result, { from: u.from });\n },\n get fullRunReason() {\n return live.fullRunReason;\n },\n };\n },\n };\n}\n\nexport type { IndicatorResult };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,mBAQO;AAoEP,MAAM,aAAoB,MAAM,KAAK,EAAE,QAAQ,IAAI,GAAG,CAAC,GAAG,MAAM;AAC9D,QAAM,QAAQ,MAAO,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,MAAM,KAAK,IAAI,IAAI,GAAG,IAAI;AACvE,QAAM,OAAO,MAAO,MAAM,KAAK,KAAK,IAAI,KAAK,CAAC,IAAI,MAAM,KAAK,KAAK,IAAI,KAAK,GAAG,IAAI,IAAI;AACtF,SAAO,EAAE,MAAM,SAAS,IAAI,IAAI,MAAM,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,QAAQ,MAAM,MAAM,KAAK,IAAI,IAAI,CAAC,EAAE;AACtJ,CAAC;AAED,MAAM,OAAO,CAAC,UACZ,MAAM,YAAY,EAAE,UAAU,MAAM,EAAE,QAAQ,UAAU,EAAE,EAAE,QAAQ,eAAe,GAAG,EAAE,QAAQ,YAAY,EAAE,KAAK;AAsB9G,SAAS,gBAAgB,MAAkB,UAAkC,CAAC,GAAwB;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AG,CAAC,CAc9H"}
@@ -126,7 +126,7 @@ function closest(name, names) {
126
126
  }
127
127
  return row[b.length];
128
128
  };
129
- return names.map((k) => ({ k, d: dist(n, k) })).filter(({ k, d }) => d <= Math.max(2, Math.floor(name.length / 3)) || k.includes(n) || n.includes(k)).sort((a, b) => a.d - b.d).slice(0, 3).map(({ k }) => k);
129
+ return names.map((k) => ({ k, d: dist(n, k) })).filter(({ k, d }) => d <= Math.max(2, Math.floor(name.length / 3)) && d < k.length || k.includes(n) || n.includes(k)).sort((a, b) => a.d - b.d).slice(0, 3).map(({ k }) => k);
130
130
  }
131
131
  function unknownArgument(name, key, list) {
132
132
  const near = closest(key, list);