@invinite-org/chartlang-runtime 1.1.1 → 1.3.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 (294) hide show
  1. package/CHANGELOG.md +307 -0
  2. package/dist/barPoint.d.ts +20 -0
  3. package/dist/barPoint.d.ts.map +1 -0
  4. package/dist/barPoint.js +72 -0
  5. package/dist/barPoint.js.map +1 -0
  6. package/dist/bufferSnapshot.d.ts +102 -0
  7. package/dist/bufferSnapshot.d.ts.map +1 -0
  8. package/dist/bufferSnapshot.js +119 -0
  9. package/dist/bufferSnapshot.js.map +1 -0
  10. package/dist/buildComputeContext.d.ts.map +1 -1
  11. package/dist/buildComputeContext.js +6 -1
  12. package/dist/buildComputeContext.js.map +1 -1
  13. package/dist/createScriptRunner.d.ts +6 -3
  14. package/dist/createScriptRunner.d.ts.map +1 -1
  15. package/dist/createScriptRunner.js +65 -11
  16. package/dist/createScriptRunner.js.map +1 -1
  17. package/dist/dep/DepRunner.d.ts +7 -0
  18. package/dist/dep/DepRunner.d.ts.map +1 -1
  19. package/dist/dep/DepRunner.js +4 -0
  20. package/dist/dep/DepRunner.js.map +1 -1
  21. package/dist/emit/barcolor.d.ts +44 -0
  22. package/dist/emit/barcolor.d.ts.map +1 -0
  23. package/dist/emit/barcolor.js +40 -0
  24. package/dist/emit/barcolor.js.map +1 -0
  25. package/dist/emit/bgcolor.d.ts +44 -0
  26. package/dist/emit/bgcolor.d.ts.map +1 -0
  27. package/dist/emit/bgcolor.js +45 -0
  28. package/dist/emit/bgcolor.js.map +1 -0
  29. package/dist/emit/draw/boxes/fillBetween.d.ts +45 -0
  30. package/dist/emit/draw/boxes/fillBetween.d.ts.map +1 -0
  31. package/dist/emit/draw/boxes/fillBetween.js +36 -0
  32. package/dist/emit/draw/boxes/fillBetween.js.map +1 -0
  33. package/dist/emit/draw/handle.d.ts +9 -0
  34. package/dist/emit/draw/handle.d.ts.map +1 -1
  35. package/dist/emit/draw/handle.js +65 -10
  36. package/dist/emit/draw/handle.js.map +1 -1
  37. package/dist/emit/draw/namespace.d.ts +4 -3
  38. package/dist/emit/draw/namespace.d.ts.map +1 -1
  39. package/dist/emit/draw/namespace.js +6 -3
  40. package/dist/emit/draw/namespace.js.map +1 -1
  41. package/dist/emit/index.d.ts +2 -0
  42. package/dist/emit/index.d.ts.map +1 -1
  43. package/dist/emit/index.js +2 -0
  44. package/dist/emit/index.js.map +1 -1
  45. package/dist/emit/plot.d.ts +30 -1
  46. package/dist/emit/plot.d.ts.map +1 -1
  47. package/dist/emit/plot.js +45 -1
  48. package/dist/emit/plot.js.map +1 -1
  49. package/dist/execution/dispose.d.ts.map +1 -1
  50. package/dist/execution/dispose.js +18 -0
  51. package/dist/execution/dispose.js.map +1 -1
  52. package/dist/execution/runComputeStep.d.ts.map +1 -1
  53. package/dist/execution/runComputeStep.js +12 -1
  54. package/dist/execution/runComputeStep.js.map +1 -1
  55. package/dist/index.d.ts +1 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +1 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/inputs/resolveInputs.js +1 -0
  60. package/dist/inputs/resolveInputs.js.map +1 -1
  61. package/dist/persistentStateStore.runtime.d.ts.map +1 -1
  62. package/dist/persistentStateStore.runtime.js +26 -7
  63. package/dist/persistentStateStore.runtime.js.map +1 -1
  64. package/dist/primitives.d.ts +1 -1
  65. package/dist/primitives.d.ts.map +1 -1
  66. package/dist/primitives.js +7 -1
  67. package/dist/primitives.js.map +1 -1
  68. package/dist/request/index.d.ts +2 -1
  69. package/dist/request/index.d.ts.map +1 -1
  70. package/dist/request/index.js +2 -1
  71. package/dist/request/index.js.map +1 -1
  72. package/dist/request/lowerTf.d.ts.map +1 -1
  73. package/dist/request/lowerTf.js +6 -0
  74. package/dist/request/lowerTf.js.map +1 -1
  75. package/dist/request/requestNamespace.d.ts.map +1 -1
  76. package/dist/request/requestNamespace.js +30 -3
  77. package/dist/request/requestNamespace.js.map +1 -1
  78. package/dist/request/security.d.ts +40 -4
  79. package/dist/request/security.d.ts.map +1 -1
  80. package/dist/request/security.js +114 -40
  81. package/dist/request/security.js.map +1 -1
  82. package/dist/request/securityExprRunner.d.ts +137 -0
  83. package/dist/request/securityExprRunner.d.ts.map +1 -0
  84. package/dist/request/securityExprRunner.js +253 -0
  85. package/dist/request/securityExprRunner.js.map +1 -0
  86. package/dist/request/streamBars.d.ts +14 -1
  87. package/dist/request/streamBars.d.ts.map +1 -1
  88. package/dist/request/streamBars.js +39 -1
  89. package/dist/request/streamBars.js.map +1 -1
  90. package/dist/ringBuffer.d.ts +19 -0
  91. package/dist/ringBuffer.d.ts.map +1 -1
  92. package/dist/ringBuffer.js +23 -0
  93. package/dist/ringBuffer.js.map +1 -1
  94. package/dist/runtimeContext.d.ts +90 -5
  95. package/dist/runtimeContext.d.ts.map +1 -1
  96. package/dist/runtimeContext.js.map +1 -1
  97. package/dist/seriesView.d.ts +42 -17
  98. package/dist/seriesView.d.ts.map +1 -1
  99. package/dist/seriesView.js +65 -42
  100. package/dist/seriesView.js.map +1 -1
  101. package/dist/state/arrayPersistence.d.ts +48 -0
  102. package/dist/state/arrayPersistence.d.ts.map +1 -0
  103. package/dist/state/arrayPersistence.js +88 -0
  104. package/dist/state/arrayPersistence.js.map +1 -0
  105. package/dist/state/arrayStateSlot.d.ts +78 -0
  106. package/dist/state/arrayStateSlot.d.ts.map +1 -0
  107. package/dist/state/arrayStateSlot.js +116 -0
  108. package/dist/state/arrayStateSlot.js.map +1 -0
  109. package/dist/state/index.d.ts +4 -1
  110. package/dist/state/index.d.ts.map +1 -1
  111. package/dist/state/index.js +4 -1
  112. package/dist/state/index.js.map +1 -1
  113. package/dist/state/lifecycle.d.ts +68 -0
  114. package/dist/state/lifecycle.d.ts.map +1 -1
  115. package/dist/state/lifecycle.js +89 -0
  116. package/dist/state/lifecycle.js.map +1 -1
  117. package/dist/state/seriesPersistence.d.ts +48 -0
  118. package/dist/state/seriesPersistence.d.ts.map +1 -0
  119. package/dist/state/seriesPersistence.js +87 -0
  120. package/dist/state/seriesPersistence.js.map +1 -0
  121. package/dist/state/seriesSlot.d.ts +105 -0
  122. package/dist/state/seriesSlot.d.ts.map +1 -0
  123. package/dist/state/seriesSlot.js +123 -0
  124. package/dist/state/seriesSlot.js.map +1 -0
  125. package/dist/state/stateNamespace.d.ts.map +1 -1
  126. package/dist/state/stateNamespace.js +55 -0
  127. package/dist/state/stateNamespace.js.map +1 -1
  128. package/dist/streamState.d.ts +25 -19
  129. package/dist/streamState.d.ts.map +1 -1
  130. package/dist/streamState.js +40 -66
  131. package/dist/streamState.js.map +1 -1
  132. package/dist/ta/adx.d.ts +3 -2
  133. package/dist/ta/adx.d.ts.map +1 -1
  134. package/dist/ta/adx.js +3 -2
  135. package/dist/ta/adx.js.map +1 -1
  136. package/dist/ta/alma.d.ts +6 -4
  137. package/dist/ta/alma.d.ts.map +1 -1
  138. package/dist/ta/alma.js +19 -6
  139. package/dist/ta/alma.js.map +1 -1
  140. package/dist/ta/atr.d.ts +3 -2
  141. package/dist/ta/atr.d.ts.map +1 -1
  142. package/dist/ta/atr.js +3 -2
  143. package/dist/ta/atr.js.map +1 -1
  144. package/dist/ta/bb.d.ts +3 -2
  145. package/dist/ta/bb.d.ts.map +1 -1
  146. package/dist/ta/bb.js +3 -2
  147. package/dist/ta/bb.js.map +1 -1
  148. package/dist/ta/chaikinOsc.d.ts +3 -2
  149. package/dist/ta/chaikinOsc.d.ts.map +1 -1
  150. package/dist/ta/chaikinOsc.js +3 -2
  151. package/dist/ta/chaikinOsc.js.map +1 -1
  152. package/dist/ta/crossover.d.ts +3 -2
  153. package/dist/ta/crossover.d.ts.map +1 -1
  154. package/dist/ta/crossover.js +3 -2
  155. package/dist/ta/crossover.js.map +1 -1
  156. package/dist/ta/crossunder.d.ts +3 -2
  157. package/dist/ta/crossunder.d.ts.map +1 -1
  158. package/dist/ta/crossunder.js +3 -2
  159. package/dist/ta/crossunder.js.map +1 -1
  160. package/dist/ta/dmi.d.ts +4 -3
  161. package/dist/ta/dmi.d.ts.map +1 -1
  162. package/dist/ta/dmi.js +4 -3
  163. package/dist/ta/dmi.js.map +1 -1
  164. package/dist/ta/ema.d.ts +3 -2
  165. package/dist/ta/ema.d.ts.map +1 -1
  166. package/dist/ta/ema.js +3 -2
  167. package/dist/ta/ema.js.map +1 -1
  168. package/dist/ta/eom.d.ts +3 -1
  169. package/dist/ta/eom.d.ts.map +1 -1
  170. package/dist/ta/eom.js +3 -1
  171. package/dist/ta/eom.js.map +1 -1
  172. package/dist/ta/highestbars.d.ts +25 -0
  173. package/dist/ta/highestbars.d.ts.map +1 -0
  174. package/dist/ta/highestbars.js +106 -0
  175. package/dist/ta/highestbars.js.map +1 -0
  176. package/dist/ta/historicalVolatility.d.ts +3 -2
  177. package/dist/ta/historicalVolatility.d.ts.map +1 -1
  178. package/dist/ta/historicalVolatility.js +3 -2
  179. package/dist/ta/historicalVolatility.js.map +1 -1
  180. package/dist/ta/ichimoku.d.ts +3 -1
  181. package/dist/ta/ichimoku.d.ts.map +1 -1
  182. package/dist/ta/ichimoku.js +3 -1
  183. package/dist/ta/ichimoku.js.map +1 -1
  184. package/dist/ta/lowestbars.d.ts +25 -0
  185. package/dist/ta/lowestbars.d.ts.map +1 -0
  186. package/dist/ta/lowestbars.js +102 -0
  187. package/dist/ta/lowestbars.js.map +1 -0
  188. package/dist/ta/macd.d.ts +3 -2
  189. package/dist/ta/macd.d.ts.map +1 -1
  190. package/dist/ta/macd.js +3 -2
  191. package/dist/ta/macd.js.map +1 -1
  192. package/dist/ta/massIndex.d.ts +3 -2
  193. package/dist/ta/massIndex.d.ts.map +1 -1
  194. package/dist/ta/massIndex.js +3 -2
  195. package/dist/ta/massIndex.js.map +1 -1
  196. package/dist/ta/mfi.d.ts +3 -1
  197. package/dist/ta/mfi.d.ts.map +1 -1
  198. package/dist/ta/mfi.js +3 -1
  199. package/dist/ta/mfi.js.map +1 -1
  200. package/dist/ta/netVolume.d.ts +3 -1
  201. package/dist/ta/netVolume.d.ts.map +1 -1
  202. package/dist/ta/netVolume.js +3 -1
  203. package/dist/ta/netVolume.js.map +1 -1
  204. package/dist/ta/nvi.d.ts +3 -1
  205. package/dist/ta/nvi.d.ts.map +1 -1
  206. package/dist/ta/nvi.js +3 -1
  207. package/dist/ta/nvi.js.map +1 -1
  208. package/dist/ta/persistence.d.ts.map +1 -1
  209. package/dist/ta/persistence.js +1 -40
  210. package/dist/ta/persistence.js.map +1 -1
  211. package/dist/ta/ppo.d.ts +3 -2
  212. package/dist/ta/ppo.d.ts.map +1 -1
  213. package/dist/ta/ppo.js +3 -2
  214. package/dist/ta/ppo.js.map +1 -1
  215. package/dist/ta/pvi.d.ts +3 -1
  216. package/dist/ta/pvi.d.ts.map +1 -1
  217. package/dist/ta/pvi.js +3 -1
  218. package/dist/ta/pvi.js.map +1 -1
  219. package/dist/ta/pvo.d.ts +3 -1
  220. package/dist/ta/pvo.d.ts.map +1 -1
  221. package/dist/ta/pvo.js +3 -1
  222. package/dist/ta/pvo.js.map +1 -1
  223. package/dist/ta/pvt.d.ts +3 -1
  224. package/dist/ta/pvt.d.ts.map +1 -1
  225. package/dist/ta/pvt.js +3 -1
  226. package/dist/ta/pvt.js.map +1 -1
  227. package/dist/ta/registry.d.ts +7 -1
  228. package/dist/ta/registry.d.ts.map +1 -1
  229. package/dist/ta/registry.js +4 -0
  230. package/dist/ta/registry.js.map +1 -1
  231. package/dist/ta/rsi.d.ts +3 -2
  232. package/dist/ta/rsi.d.ts.map +1 -1
  233. package/dist/ta/rsi.js +3 -2
  234. package/dist/ta/rsi.js.map +1 -1
  235. package/dist/ta/rvi.d.ts +3 -2
  236. package/dist/ta/rvi.d.ts.map +1 -1
  237. package/dist/ta/rvi.js +3 -2
  238. package/dist/ta/rvi.js.map +1 -1
  239. package/dist/ta/sessionVolumeProfile.d.ts.map +1 -1
  240. package/dist/ta/sessionVolumeProfile.js +1 -17
  241. package/dist/ta/sessionVolumeProfile.js.map +1 -1
  242. package/dist/ta/sma.d.ts +6 -3
  243. package/dist/ta/sma.d.ts.map +1 -1
  244. package/dist/ta/sma.js +6 -3
  245. package/dist/ta/sma.js.map +1 -1
  246. package/dist/ta/stdev.d.ts +3 -2
  247. package/dist/ta/stdev.d.ts.map +1 -1
  248. package/dist/ta/stdev.js +3 -2
  249. package/dist/ta/stdev.js.map +1 -1
  250. package/dist/ta/trendStrengthIndex.d.ts +3 -2
  251. package/dist/ta/trendStrengthIndex.d.ts.map +1 -1
  252. package/dist/ta/trendStrengthIndex.js +3 -2
  253. package/dist/ta/trendStrengthIndex.js.map +1 -1
  254. package/dist/ta/trix.d.ts +4 -3
  255. package/dist/ta/trix.d.ts.map +1 -1
  256. package/dist/ta/trix.js +4 -3
  257. package/dist/ta/trix.js.map +1 -1
  258. package/dist/ta/vortex.d.ts +3 -2
  259. package/dist/ta/vortex.d.ts.map +1 -1
  260. package/dist/ta/vortex.js +3 -2
  261. package/dist/ta/vortex.js.map +1 -1
  262. package/dist/time-accessors/civil.d.ts +73 -0
  263. package/dist/time-accessors/civil.d.ts.map +1 -0
  264. package/dist/time-accessors/civil.js +105 -0
  265. package/dist/time-accessors/civil.js.map +1 -0
  266. package/dist/time-accessors/index.d.ts +8 -0
  267. package/dist/time-accessors/index.d.ts.map +1 -0
  268. package/dist/time-accessors/index.js +9 -0
  269. package/dist/time-accessors/index.js.map +1 -0
  270. package/dist/time-accessors/sessionAccessors.d.ts +50 -0
  271. package/dist/time-accessors/sessionAccessors.d.ts.map +1 -0
  272. package/dist/time-accessors/sessionAccessors.js +79 -0
  273. package/dist/time-accessors/sessionAccessors.js.map +1 -0
  274. package/dist/time-accessors/sessionWindow.d.ts +17 -0
  275. package/dist/time-accessors/sessionWindow.d.ts.map +1 -0
  276. package/dist/time-accessors/sessionWindow.js +41 -0
  277. package/dist/time-accessors/sessionWindow.js.map +1 -0
  278. package/dist/time-accessors/timeAccessors.d.ts +54 -0
  279. package/dist/time-accessors/timeAccessors.d.ts.map +1 -0
  280. package/dist/time-accessors/timeAccessors.js +132 -0
  281. package/dist/time-accessors/timeAccessors.js.map +1 -0
  282. package/dist/time-accessors/tzDiagnostic.d.ts +17 -0
  283. package/dist/time-accessors/tzDiagnostic.d.ts.map +1 -0
  284. package/dist/time-accessors/tzDiagnostic.js +34 -0
  285. package/dist/time-accessors/tzDiagnostic.js.map +1 -0
  286. package/dist/time-accessors/tzOffset.d.ts +31 -0
  287. package/dist/time-accessors/tzOffset.d.ts.map +1 -0
  288. package/dist/time-accessors/tzOffset.js +67 -0
  289. package/dist/time-accessors/tzOffset.js.map +1 -0
  290. package/package.json +3 -3
  291. package/dist/ta/lib/applyOffset.d.ts +0 -19
  292. package/dist/ta/lib/applyOffset.d.ts.map +0 -1
  293. package/dist/ta/lib/applyOffset.js +0 -38
  294. package/dist/ta/lib/applyOffset.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/emit/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACH,mBAAmB,EACnB,IAAI,EACJ,SAAS,EACT,WAAW,EACX,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,QAAQ,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nexport { alert } from \"./alert.js\";\nexport { emitAlertCondition } from \"./alertConditionEmission.js\";\nexport { applyPlotOverride } from \"./applyPlotOverride.js\";\nexport {\n createDrawingHandle,\n draw,\n nextSubId,\n pushDrawing,\n resetSubIdCounters,\n} from \"./draw/index.js\";\nexport {\n pushAlert,\n pushAlertCondition,\n pushDiagnostic,\n pushLog,\n pushPlot,\n} from \"./emissionsQueue.js\";\nexport { hashStringStable } from \"./hash.js\";\nexport { hline } from \"./hline.js\";\nexport { buildRuntimeNamespace, emitLog } from \"./logEmission.js\";\nexport { resolveDefaultPane, resolvePane, resolveScriptPane } from \"./paneResolver.js\";\nexport { plot } from \"./plot.js\";\nexport { isRuntimeErrorHalt, makeRuntimeErrorHalt } from \"./runtimeError.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/emit/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACH,mBAAmB,EACnB,IAAI,EACJ,SAAS,EACT,WAAW,EACX,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,QAAQ,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nexport { alert } from \"./alert.js\";\nexport { emitAlertCondition } from \"./alertConditionEmission.js\";\nexport { applyPlotOverride } from \"./applyPlotOverride.js\";\nexport { barcolor } from \"./barcolor.js\";\nexport { bgcolor } from \"./bgcolor.js\";\nexport {\n createDrawingHandle,\n draw,\n nextSubId,\n pushDrawing,\n resetSubIdCounters,\n} from \"./draw/index.js\";\nexport {\n pushAlert,\n pushAlertCondition,\n pushDiagnostic,\n pushLog,\n pushPlot,\n} from \"./emissionsQueue.js\";\nexport { hashStringStable } from \"./hash.js\";\nexport { hline } from \"./hline.js\";\nexport { buildRuntimeNamespace, emitLog } from \"./logEmission.js\";\nexport { resolveDefaultPane, resolvePane, resolveScriptPane } from \"./paneResolver.js\";\nexport { plot } from \"./plot.js\";\nexport { isRuntimeErrorHalt, makeRuntimeErrorHalt } from \"./runtimeError.js\";\n"]}
@@ -1,4 +1,26 @@
1
- import type { PlotOpts, Series } from "@invinite-org/chartlang-core";
1
+ import type { Color, PlotOpts, Series } from "@invinite-org/chartlang-core";
2
+ import { type RuntimeContext } from "../runtimeContext.js";
3
+ /**
4
+ * Shared emission core for `plot` and its Pine-ergonomic aliases
5
+ * (`bgcolor` / `barcolor`). Builds the {@link PlotStyle} from `opts.style`,
6
+ * capability-gates, resolves the pane + `xShift` + `z`, and pushes the
7
+ * deduped, override-applied {@link PlotEmission}.
8
+ *
9
+ * `dynamicColor` is the per-bar dynamic-color channel: when supplied (only
10
+ * the `bgcolor` / `barcolor` aliases do — `plot` never does) it resolves to
11
+ * {@link PlotEmission.colorValue} (a non-empty color string, or `null` for an
12
+ * empty-string gap) and rides the same `(slotId, bar)` last-write-wins dedup
13
+ * as `value`. When omitted, no `colorValue` own-key is emitted, so the
14
+ * static-color `plot` wire stays byte-identical to the pre-Deliverable-2
15
+ * baseline (every pinned plot golden / conformance hash holds).
16
+ *
17
+ * @since 1.4
18
+ * @example
19
+ * // Internal — `bgcolor` / `barcolor` reuse this; scripts call `plot`.
20
+ * // const fn: typeof plotImpl = plotImpl;
21
+ * // void fn;
22
+ */
23
+ export declare function plotImpl(ctx: RuntimeContext, slotId: string, value: number | Series<number>, opts: PlotOpts, dynamicColor?: Color): void;
2
24
  /**
3
25
  * Emit a plot line for the current bar (script-facing overload).
4
26
  *
@@ -14,6 +36,13 @@ import type { PlotOpts, Series } from "@invinite-org/chartlang-core";
14
36
  * via the sibling {@link hline} primitive. Phase 2+ extends the `kind`
15
37
  * variants additively.
16
38
  *
39
+ * When the plotted value is a `ta.*` series declared with an `offset`
40
+ * (or ALMA's `barShift`), that signed bar count rides the emission as
41
+ * `PlotEmission.xShift` (presentation-only — `+n` renders the series `n`
42
+ * bars right, `−n` `n` bars left); the emitted `value` itself is
43
+ * unshifted, so alerts and `state.*` see the value computed at the
44
+ * current bar.
45
+ *
17
46
  * @since 0.1
18
47
  * @example
19
48
  * import { defineIndicator, ta, plot } from "@invinite-org/chartlang-core";
@@ -1 +1 @@
1
- {"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../../src/emit/plot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAwHrE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;AAC5E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC"}
1
+ {"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../../src/emit/plot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAE5E,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAiFnF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CACpB,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAC9B,IAAI,EAAE,QAAQ,EACd,YAAY,CAAC,EAAE,KAAK,GACrB,IAAI,CAyDN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;AAC5E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC"}
package/dist/emit/plot.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) 2026 Invinite. Licensed under the MIT License.
2
2
  // See the LICENSE file in the repo root for full license text.
3
3
  import { ACTIVE_RUNTIME_CONTEXT } from "../runtimeContext.js";
4
+ import { seriesOffsetOf } from "../seriesView.js";
4
5
  import { applyPlotOverride } from "./applyPlotOverride.js";
5
6
  import { pushDiagnostic, pushPlot } from "./emissionsQueue.js";
6
7
  import { resolvePane } from "./paneResolver.js";
@@ -74,7 +75,27 @@ function buildStyle(opts) {
74
75
  };
75
76
  }
76
77
  }
77
- function plotImpl(ctx, slotId, value, opts) {
78
+ /**
79
+ * Shared emission core for `plot` and its Pine-ergonomic aliases
80
+ * (`bgcolor` / `barcolor`). Builds the {@link PlotStyle} from `opts.style`,
81
+ * capability-gates, resolves the pane + `xShift` + `z`, and pushes the
82
+ * deduped, override-applied {@link PlotEmission}.
83
+ *
84
+ * `dynamicColor` is the per-bar dynamic-color channel: when supplied (only
85
+ * the `bgcolor` / `barcolor` aliases do — `plot` never does) it resolves to
86
+ * {@link PlotEmission.colorValue} (a non-empty color string, or `null` for an
87
+ * empty-string gap) and rides the same `(slotId, bar)` last-write-wins dedup
88
+ * as `value`. When omitted, no `colorValue` own-key is emitted, so the
89
+ * static-color `plot` wire stays byte-identical to the pre-Deliverable-2
90
+ * baseline (every pinned plot golden / conformance hash holds).
91
+ *
92
+ * @since 1.4
93
+ * @example
94
+ * // Internal — `bgcolor` / `barcolor` reuse this; scripts call `plot`.
95
+ * // const fn: typeof plotImpl = plotImpl;
96
+ * // void fn;
97
+ */
98
+ export function plotImpl(ctx, slotId, value, opts, dynamicColor) {
78
99
  const style = buildStyle(opts);
79
100
  if (!ctx.capabilities.plots.has(style.kind)) {
80
101
  pushDiagnostic(ctx.emissions, {
@@ -88,6 +109,26 @@ function plotImpl(ctx, slotId, value, opts) {
88
109
  return;
89
110
  }
90
111
  const pane = resolvePane(opts.pane, ctx, slotId);
112
+ // A `ta.*` series carries its declared `offset` (ALMA: `barShift`) as a
113
+ // presentation x-shift recorded on the series view; thread it onto the
114
+ // emission. A plain numeric value or an untagged series omits `xShift`,
115
+ // keeping the no-offset wire byte-identical to the pre-feature baseline.
116
+ const xShift = typeof value === "number" ? 0 : seriesOffsetOf(value);
117
+ // `z` is a direct plot-call option (a render-order key), unlike
118
+ // `xShift` (derived from the series view). Normalize undefined → `0`
119
+ // and append it with the same omit-when-`0` conditional spread so a
120
+ // no-`z` plot stays byte-identical to the pre-feature baseline.
121
+ const z = opts.z ?? 0;
122
+ // The per-bar dynamic color (only `bgcolor` / `barcolor` pass it) rides the
123
+ // wire as `colorValue`, appended LAST so an omitted-`colorValue` emission
124
+ // is byte-identical to the pre-Deliverable-2 wire. `plot` passes nothing,
125
+ // so its static-color wire is untouched and its goldens / hashes do not
126
+ // move. The color flows through unchanged: the alias mirrors it onto the
127
+ // static `style.color` too, so a malformed (empty) color trips the style
128
+ // validator and `pushPlot` drops the whole emission — the validator's
129
+ // `colorValue: null` arm is the wire contract for an explicit gap a future
130
+ // producer may emit, not something the aliases manufacture.
131
+ const colorValue = dynamicColor;
91
132
  const emission = {
92
133
  kind: "plot",
93
134
  slotId,
@@ -99,6 +140,9 @@ function plotImpl(ctx, slotId, value, opts) {
99
140
  color: opts.color ?? null,
100
141
  meta: {},
101
142
  pane,
143
+ ...(xShift === 0 ? {} : { xShift }),
144
+ ...(z === 0 ? {} : { z }),
145
+ ...(colorValue === undefined ? {} : { colorValue }),
102
146
  };
103
147
  pushPlot(ctx.emissions, applyPlotOverride(emission, ctx.plotOverrides[slotId]));
104
148
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plot.js","sourceRoot":"","sources":["../../src/emit/plot.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAK/D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,mBAAmB,GAAG,2CAA2C,CAAC;AAExE,SAAS,cAAc,CAAC,CAAU;IAC9B,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,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI;QACzB,IAAI,EAAE,EAAE;QACR,IAAI;KACP,CAAC;IAEF,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,iBAAiB,CAAC,QAAQ,EAAE,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC;AA6CD;;;;;;;;;GASG;AACH,MAAM,UAAU,IAAI,CAChB,IAAsC,EACtC,IAAyC,EACzC,IAAe;IAEf,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,GAAG,GAAG,sBAAsB,CAAC,OAAO,CAAC;IAC3C,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC/C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IACD,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { PlotEmission, PlotStyle } from \"@invinite-org/chartlang-adapter-kit\";\nimport type { PlotOpts, Series } from \"@invinite-org/chartlang-core\";\n\nimport { ACTIVE_RUNTIME_CONTEXT, type RuntimeContext } from \"../runtimeContext.js\";\nimport { applyPlotOverride } from \"./applyPlotOverride.js\";\nimport { pushDiagnostic, pushPlot } from \"./emissionsQueue.js\";\nimport { resolvePane } from \"./paneResolver.js\";\n\nconst OUTSIDE_CTX_MESSAGE = \"plot called outside an active script step\";\n\nfunction isSeriesNumber(v: unknown): v is Series<number> {\n return typeof v === \"object\" && v !== null && \"current\" in v;\n}\n\nfunction isNumberOrSeries(v: unknown): v is number | Series<number> {\n return typeof v === \"number\" || isSeriesNumber(v);\n}\n\nfunction resolveValue(value: number | Series<number>): number | null {\n const resolved = typeof value === \"number\" ? value : value.current;\n return Number.isFinite(resolved) ? resolved : null;\n}\n\nfunction buildStyle(opts: PlotOpts): PlotStyle {\n const style = opts.style;\n if (style === undefined) {\n return {\n kind: \"line\",\n lineWidth: opts.lineWidth ?? 1,\n lineStyle: opts.lineStyle ?? \"solid\",\n };\n }\n switch (style.kind) {\n case \"histogram\":\n return { kind: \"histogram\", baseline: style.baseline ?? 0 };\n case \"marker\":\n return { kind: \"marker\", shape: style.shape, size: style.size };\n case \"shape\":\n return {\n kind: \"shape\",\n shape: style.shape,\n size: style.size,\n ...(style.location === undefined ? {} : { location: style.location }),\n };\n case \"character\":\n return {\n kind: \"character\",\n char: style.char,\n size: style.size,\n ...(style.location === undefined ? {} : { location: style.location }),\n };\n case \"arrow\":\n return { kind: \"arrow\", direction: style.direction, size: style.size };\n case \"candle-override\":\n return {\n kind: \"candle-override\",\n bull: style.bull,\n bear: style.bear,\n ...(style.doji === undefined ? {} : { doji: style.doji }),\n };\n case \"bar-override\":\n return { kind: \"bar-override\", color: style.color };\n case \"bg-color\":\n return {\n kind: \"bg-color\",\n color: style.color,\n ...(style.transp === undefined ? {} : { transp: style.transp }),\n };\n case \"bar-color\":\n return { kind: \"bar-color\", color: style.color };\n case \"horizontal-histogram\":\n return { kind: \"horizontal-histogram\", buckets: style.buckets };\n case \"line\":\n case \"step-line\":\n case \"horizontal-line\":\n return {\n kind: style.kind,\n lineWidth: opts.lineWidth ?? 1,\n lineStyle: opts.lineStyle ?? \"solid\",\n };\n }\n}\n\nfunction plotImpl(\n ctx: RuntimeContext,\n slotId: string,\n value: number | Series<number>,\n opts: PlotOpts,\n): void {\n const style: PlotStyle = buildStyle(opts);\n\n if (!ctx.capabilities.plots.has(style.kind)) {\n pushDiagnostic(ctx.emissions, {\n kind: \"diagnostic\",\n severity: \"warning\",\n code: \"unsupported-plot-kind\",\n message: `Adapter cannot render plot kind \"${style.kind}\".`,\n slotId,\n bar: ctx.barIndex(),\n });\n return;\n }\n\n const pane = resolvePane(opts.pane, ctx, slotId);\n\n const emission: PlotEmission = {\n kind: \"plot\",\n slotId,\n title: opts.title ?? \"\",\n style,\n bar: ctx.barIndex(),\n time: ctx.stream.bar.time,\n value: resolveValue(value),\n color: opts.color ?? null,\n meta: {},\n pane,\n };\n\n pushPlot(ctx.emissions, applyPlotOverride(emission, ctx.plotOverrides[slotId]));\n}\n\n/**\n * Emit a plot line for the current bar (script-facing overload).\n *\n * The runtime export is dual-signature: scripts call `plot(value, opts?)`\n * (the surface declared on `@invinite-org/chartlang-core`'s\n * `ComputeContext`), and Task 2's compiler transformer rewrites every\n * callsite to inject the compiler-issued slot id as the leading\n * argument — see the sibling `plot(slotId, value, opts?)` overload.\n * A direct invocation without a slot id (i.e. outside a compiled\n * bundle) throws the sentinel error.\n *\n * Plot kind is always `\"line\"` in Phase 1; `\"horizontal-line\"` ships\n * via the sibling {@link hline} primitive. Phase 2+ extends the `kind`\n * variants additively.\n *\n * @since 0.1\n * @example\n * import { defineIndicator, ta, plot } from \"@invinite-org/chartlang-core\";\n * export default defineIndicator({\n * name: \"EMA(20)\",\n * apiVersion: 1,\n * compute({ bar, ta, plot }) {\n * plot(ta.ema(bar.close, 20), { color: \"#26a69a\", title: \"EMA\" });\n * },\n * });\n */\nexport function plot(value: number | Series<number>, opts?: PlotOpts): void;\n/**\n * Emit a plot line for the current bar (compiler-injected overload).\n *\n * Task 2's callsite-id transformer rewrites every script-side\n * `plot(value, opts?)` into `plot(slotId, value, opts?)`. The runtime\n * branches on `typeof arg1 === \"string\"` so the compiler-emitted\n * bundle dispatches here directly.\n *\n * @since 0.1\n * @example\n * // Internal — the compiler rewrites every script callsite, e.g.\n * // `plot(close)` becomes `plot(\"demo.chart.ts:5:13#0\", close)`.\n * // const fn: typeof plot = plot;\n * // void fn;\n */\nexport function plot(slotId: string, value: number | Series<number>, opts?: PlotOpts): void;\n/**\n * Implementation signature for {@link plot}. Branches on\n * `typeof arg1 === \"string\"` to dispatch the script-facing vs\n * compiler-injected overload.\n *\n * @since 0.1\n * @example\n * // const fn: typeof plot = plot;\n * // void fn;\n */\nexport function plot(\n arg1: string | number | Series<number>,\n arg2?: number | Series<number> | PlotOpts,\n arg3?: PlotOpts,\n): void {\n if (typeof arg1 !== \"string\") {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (!ctx) throw new Error(OUTSIDE_CTX_MESSAGE);\n if (!isNumberOrSeries(arg2)) {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n plotImpl(ctx, arg1, arg2, arg3 ?? {});\n}\n"]}
1
+ {"version":3,"file":"plot.js","sourceRoot":"","sources":["../../src/emit/plot.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAK/D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,mBAAmB,GAAG,2CAA2C,CAAC;AAExE,SAAS,cAAc,CAAC,CAAU;IAC9B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,SAAS,IAAI,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,gBAAgB,CAAC,CAAU;IAChC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,YAAY,CAAC,KAA8B;IAChD,MAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,C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AAI,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { PlotEmission, PlotStyle } from \"@invinite-org/chartlang-adapter-kit\";\nimport type { Color, PlotOpts, Series } from \"@invinite-org/chartlang-core\";\n\nimport { ACTIVE_RUNTIME_CONTEXT, type RuntimeContext } from \"../runtimeContext.js\";\nimport { seriesOffsetOf } from \"../seriesView.js\";\nimport { applyPlotOverride } from \"./applyPlotOverride.js\";\nimport { pushDiagnostic, pushPlot } from \"./emissionsQueue.js\";\nimport { resolvePane } from \"./paneResolver.js\";\n\nconst OUTSIDE_CTX_MESSAGE = \"plot called outside an active script step\";\n\nfunction isSeriesNumber(v: unknown): v is Series<number> {\n return typeof v === \"object\" && v !== null && \"current\" in v;\n}\n\nfunction isNumberOrSeries(v: unknown): v is number | Series<number> {\n return typeof v === \"number\" || isSeriesNumber(v);\n}\n\nfunction resolveValue(value: number | Series<number>): number | null {\n const resolved = typeof value === \"number\" ? value : value.current;\n return Number.isFinite(resolved) ? resolved : null;\n}\n\nfunction buildStyle(opts: PlotOpts): PlotStyle {\n const style = opts.style;\n if (style === undefined) {\n return {\n kind: \"line\",\n lineWidth: opts.lineWidth ?? 1,\n lineStyle: opts.lineStyle ?? \"solid\",\n };\n }\n switch (style.kind) {\n case \"histogram\":\n return { kind: \"histogram\", baseline: style.baseline ?? 0 };\n case \"marker\":\n return { kind: \"marker\", shape: style.shape, size: style.size };\n case \"shape\":\n return {\n kind: \"shape\",\n shape: style.shape,\n size: style.size,\n ...(style.location === undefined ? {} : { location: style.location }),\n };\n case \"character\":\n return {\n kind: \"character\",\n char: style.char,\n size: style.size,\n ...(style.location === undefined ? {} : { location: style.location }),\n };\n case \"arrow\":\n return { kind: \"arrow\", direction: style.direction, size: style.size };\n case \"candle-override\":\n return {\n kind: \"candle-override\",\n bull: style.bull,\n bear: style.bear,\n ...(style.doji === undefined ? {} : { doji: style.doji }),\n };\n case \"bar-override\":\n return { kind: \"bar-override\", color: style.color };\n case \"bg-color\":\n return {\n kind: \"bg-color\",\n color: style.color,\n ...(style.transp === undefined ? {} : { transp: style.transp }),\n };\n case \"bar-color\":\n return { kind: \"bar-color\", color: style.color };\n case \"horizontal-histogram\":\n return { kind: \"horizontal-histogram\", buckets: style.buckets };\n case \"line\":\n case \"step-line\":\n case \"horizontal-line\":\n return {\n kind: style.kind,\n lineWidth: opts.lineWidth ?? 1,\n lineStyle: opts.lineStyle ?? \"solid\",\n };\n }\n}\n\n/**\n * Shared emission core for `plot` and its Pine-ergonomic aliases\n * (`bgcolor` / `barcolor`). Builds the {@link PlotStyle} from `opts.style`,\n * capability-gates, resolves the pane + `xShift` + `z`, and pushes the\n * deduped, override-applied {@link PlotEmission}.\n *\n * `dynamicColor` is the per-bar dynamic-color channel: when supplied (only\n * the `bgcolor` / `barcolor` aliases do — `plot` never does) it resolves to\n * {@link PlotEmission.colorValue} (a non-empty color string, or `null` for an\n * empty-string gap) and rides the same `(slotId, bar)` last-write-wins dedup\n * as `value`. When omitted, no `colorValue` own-key is emitted, so the\n * static-color `plot` wire stays byte-identical to the pre-Deliverable-2\n * baseline (every pinned plot golden / conformance hash holds).\n *\n * @since 1.4\n * @example\n * // Internal — `bgcolor` / `barcolor` reuse this; scripts call `plot`.\n * // const fn: typeof plotImpl = plotImpl;\n * // void fn;\n */\nexport function plotImpl(\n ctx: RuntimeContext,\n slotId: string,\n value: number | Series<number>,\n opts: PlotOpts,\n dynamicColor?: Color,\n): void {\n const style: PlotStyle = buildStyle(opts);\n\n if (!ctx.capabilities.plots.has(style.kind)) {\n pushDiagnostic(ctx.emissions, {\n kind: \"diagnostic\",\n severity: \"warning\",\n code: \"unsupported-plot-kind\",\n message: `Adapter cannot render plot kind \"${style.kind}\".`,\n slotId,\n bar: ctx.barIndex(),\n });\n return;\n }\n\n const pane = resolvePane(opts.pane, ctx, slotId);\n\n // A `ta.*` series carries its declared `offset` (ALMA: `barShift`) as a\n // presentation x-shift recorded on the series view; thread it onto the\n // emission. A plain numeric value or an untagged series omits `xShift`,\n // keeping the no-offset wire byte-identical to the pre-feature baseline.\n const xShift = typeof value === \"number\" ? 0 : seriesOffsetOf(value);\n\n // `z` is a direct plot-call option (a render-order key), unlike\n // `xShift` (derived from the series view). Normalize undefined → `0`\n // and append it with the same omit-when-`0` conditional spread so a\n // no-`z` plot stays byte-identical to the pre-feature baseline.\n const z = opts.z ?? 0;\n\n // The per-bar dynamic color (only `bgcolor` / `barcolor` pass it) rides the\n // wire as `colorValue`, appended LAST so an omitted-`colorValue` emission\n // is byte-identical to the pre-Deliverable-2 wire. `plot` passes nothing,\n // so its static-color wire is untouched and its goldens / hashes do not\n // move. The color flows through unchanged: the alias mirrors it onto the\n // static `style.color` too, so a malformed (empty) color trips the style\n // validator and `pushPlot` drops the whole emission — the validator's\n // `colorValue: null` arm is the wire contract for an explicit gap a future\n // producer may emit, not something the aliases manufacture.\n const colorValue = dynamicColor;\n\n const emission: PlotEmission = {\n kind: \"plot\",\n slotId,\n title: opts.title ?? \"\",\n style,\n bar: ctx.barIndex(),\n time: ctx.stream.bar.time,\n value: resolveValue(value),\n color: opts.color ?? null,\n meta: {},\n pane,\n ...(xShift === 0 ? {} : { xShift }),\n ...(z === 0 ? {} : { z }),\n ...(colorValue === undefined ? {} : { colorValue }),\n };\n\n pushPlot(ctx.emissions, applyPlotOverride(emission, ctx.plotOverrides[slotId]));\n}\n\n/**\n * Emit a plot line for the current bar (script-facing overload).\n *\n * The runtime export is dual-signature: scripts call `plot(value, opts?)`\n * (the surface declared on `@invinite-org/chartlang-core`'s\n * `ComputeContext`), and Task 2's compiler transformer rewrites every\n * callsite to inject the compiler-issued slot id as the leading\n * argument — see the sibling `plot(slotId, value, opts?)` overload.\n * A direct invocation without a slot id (i.e. outside a compiled\n * bundle) throws the sentinel error.\n *\n * Plot kind is always `\"line\"` in Phase 1; `\"horizontal-line\"` ships\n * via the sibling {@link hline} primitive. Phase 2+ extends the `kind`\n * variants additively.\n *\n * When the plotted value is a `ta.*` series declared with an `offset`\n * (or ALMA's `barShift`), that signed bar count rides the emission as\n * `PlotEmission.xShift` (presentation-only — `+n` renders the series `n`\n * bars right, `−n` `n` bars left); the emitted `value` itself is\n * unshifted, so alerts and `state.*` see the value computed at the\n * current bar.\n *\n * @since 0.1\n * @example\n * import { defineIndicator, ta, plot } from \"@invinite-org/chartlang-core\";\n * export default defineIndicator({\n * name: \"EMA(20)\",\n * apiVersion: 1,\n * compute({ bar, ta, plot }) {\n * plot(ta.ema(bar.close, 20), { color: \"#26a69a\", title: \"EMA\" });\n * },\n * });\n */\nexport function plot(value: number | Series<number>, opts?: PlotOpts): void;\n/**\n * Emit a plot line for the current bar (compiler-injected overload).\n *\n * Task 2's callsite-id transformer rewrites every script-side\n * `plot(value, opts?)` into `plot(slotId, value, opts?)`. The runtime\n * branches on `typeof arg1 === \"string\"` so the compiler-emitted\n * bundle dispatches here directly.\n *\n * @since 0.1\n * @example\n * // Internal — the compiler rewrites every script callsite, e.g.\n * // `plot(close)` becomes `plot(\"demo.chart.ts:5:13#0\", close)`.\n * // const fn: typeof plot = plot;\n * // void fn;\n */\nexport function plot(slotId: string, value: number | Series<number>, opts?: PlotOpts): void;\n/**\n * Implementation signature for {@link plot}. Branches on\n * `typeof arg1 === \"string\"` to dispatch the script-facing vs\n * compiler-injected overload.\n *\n * @since 0.1\n * @example\n * // const fn: typeof plot = plot;\n * // void fn;\n */\nexport function plot(\n arg1: string | number | Series<number>,\n arg2?: number | Series<number> | PlotOpts,\n arg3?: PlotOpts,\n): void {\n if (typeof arg1 !== \"string\") {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (!ctx) throw new Error(OUTSIDE_CTX_MESSAGE);\n if (!isNumberOrSeries(arg2)) {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n plotImpl(ctx, arg1, arg2, arg3 ?? {});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"dispose.d.ts","sourceRoot":"","sources":["../../src/execution/dispose.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAuChD"}
1
+ {"version":3,"file":"dispose.d.ts","sourceRoot":"","sources":["../../src/execution/dispose.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAyDhD"}
@@ -47,12 +47,30 @@ export function dispose(state) {
47
47
  state.runtimeContext.drawingSlots.clear();
48
48
  state.runtimeContext.drawingSubIdCounters.clear();
49
49
  state.runtimeContext.stateSlots.clear();
50
+ state.runtimeContext.seriesSlots.clear();
51
+ state.runtimeContext.arraySlots.clear();
50
52
  state.runtimeContext.secondaryStreams.clear();
51
53
  state.runtimeContext.requestSecurityBars.clear();
52
54
  state.runtimeContext.requestSecurityAlignments.clear();
53
55
  state.runtimeContext.requestSecurityAscendingBars.clear();
56
+ state.runtimeContext.requestSecurityExprSeries?.clear();
57
+ const exprRunners = state.runtimeContext.securityExprRunners;
58
+ if (exprRunners !== undefined) {
59
+ for (const runner of exprRunners.values()) {
60
+ for (const buf of Object.values(runner.foldStream.ohlcv)) {
61
+ buf.reset();
62
+ }
63
+ runner.foldStream.taSlots.clear();
64
+ runner.output.reset();
65
+ }
66
+ // Drops every runner reference; the per-feed index holds the same
67
+ // (now-reset) objects, so clearing `bySlot` is the authoritative
68
+ // teardown. The whole `RuntimeContext` is discarded after dispose.
69
+ exprRunners.clear();
70
+ }
54
71
  state.runtimeContext.requestLowerTfViews.clear();
55
72
  state.runtimeContext.diagnosedRequestKeys.clear();
73
+ state.runtimeContext.diagnosedTzKeys.clear();
56
74
  state.runtimeContext.diagnosedInputKeys.clear();
57
75
  const counters = state.runtimeContext.drawingBucketCounters;
58
76
  counters.lines = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"dispose.js","sourceRoot":"","sources":["../../src/execution/dispose.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,OAAO,CAAC,KAAkB;IACtC,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QACzC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;IAChC,eAAe,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACtD,GAAG,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC;QAClE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5C,GAAG,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACjC,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE,CAAC;IAC3B,KAAK,CAAC,SAAS,CAAC,QAAQ,GAAG,EAAE,CAAC;IAC9B,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,EAAE,CAAC;IAC5B,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,EAAE,CAAC;IACjC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC1C,KAAK,CAAC,cAAc,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;IAClD,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACxC,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAC9C,KAAK,CAAC,cAAc,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;IACjD,KAAK,CAAC,cAAc,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC;IACvD,KAAK,CAAC,cAAc,CAAC,4BAA4B,CAAC,KAAK,EAAE,CAAC;IAC1D,KAAK,CAAC,cAAc,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;IACjD,KAAK,CAAC,cAAc,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;IAClD,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;IAChD,MAAM,QAAQ,GAAG,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC;IAC5D,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAC;IACvB,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;AACvB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { RunnerState } from \"../createScriptRunner.js\";\nimport { flushStateSlots } from \"../state/index.js\";\n\n/**\n * Tear down the runner's buffers and state. After `dispose`:\n *\n * - Every OHLCV ring buffer's `length` is 0 (via `RingBufferLike.reset`).\n * - The `taSlots` map is empty (Task 7 primitives lose their hidden\n * state).\n * - Runtime `state.*` slots are flushed into `StateStore`, then the\n * runner-local slot map is cleared. The backing `StateStore` remains\n * host-owned so warm restart can restore the snapshot.\n * - The four emission arrays are reset to empty (`drain()` after\n * `dispose` returns empty arrays).\n *\n * `state.barIndex` is NOT reset — `dispose` is one-shot. Re-use after\n * `dispose` is not supported and not tested.\n *\n * @since 0.1\n * @example\n * // import { dispose } from \"@invinite-org/chartlang-runtime\";\n * // dispose(state);\n */\nexport function dispose(state: RunnerState): void {\n for (const dep of state.depRunners) {\n dispose(dep.state);\n }\n for (const sibling of state.siblingRunners) {\n dispose(sibling.state);\n }\n state.depOutputStore?.dispose();\n flushStateSlots(state.runtimeContext);\n for (const buf of Object.values(state.mainStream.ohlcv)) {\n buf.reset();\n }\n for (const stream of state.runtimeContext.secondaryStreams.values()) {\n for (const buf of Object.values(stream.ohlcv)) {\n buf.reset();\n }\n stream.taSlots.clear();\n }\n state.mainStream.taSlots.clear();\n state.emissions.plots = [];\n state.emissions.drawings = [];\n state.emissions.alerts = [];\n state.emissions.diagnostics = [];\n state.runtimeContext.drawingSlots.clear();\n state.runtimeContext.drawingSubIdCounters.clear();\n state.runtimeContext.stateSlots.clear();\n state.runtimeContext.secondaryStreams.clear();\n state.runtimeContext.requestSecurityBars.clear();\n state.runtimeContext.requestSecurityAlignments.clear();\n state.runtimeContext.requestSecurityAscendingBars.clear();\n state.runtimeContext.requestLowerTfViews.clear();\n state.runtimeContext.diagnosedRequestKeys.clear();\n state.runtimeContext.diagnosedInputKeys.clear();\n const counters = state.runtimeContext.drawingBucketCounters;\n counters.lines = 0;\n counters.labels = 0;\n counters.boxes = 0;\n counters.polylines = 0;\n counters.other = 0;\n}\n"]}
1
+ {"version":3,"file":"dispose.js","sourceRoot":"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;IACjD,KAAK,CAAC,cAAc,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAC;IAClD,KAAK,CAAC,cAAc,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC7C,KAAK,CAAC,cAAc,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;IAChD,MAAM,QAAQ,GAAG,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC;IAC5D,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAC;IACvB,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC;AACvB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { RunnerState } from \"../createScriptRunner.js\";\nimport { flushStateSlots } from \"../state/index.js\";\n\n/**\n * Tear down the runner's buffers and state. After `dispose`:\n *\n * - Every OHLCV ring buffer's `length` is 0 (via `RingBufferLike.reset`).\n * - The `taSlots` map is empty (Task 7 primitives lose their hidden\n * state).\n * - Runtime `state.*` slots are flushed into `StateStore`, then the\n * runner-local slot map is cleared. The backing `StateStore` remains\n * host-owned so warm restart can restore the snapshot.\n * - The four emission arrays are reset to empty (`drain()` after\n * `dispose` returns empty arrays).\n *\n * `state.barIndex` is NOT reset — `dispose` is one-shot. Re-use after\n * `dispose` is not supported and not tested.\n *\n * @since 0.1\n * @example\n * // import { dispose } from \"@invinite-org/chartlang-runtime\";\n * // dispose(state);\n */\nexport function dispose(state: RunnerState): void {\n for (const dep of state.depRunners) {\n dispose(dep.state);\n }\n for (const sibling of state.siblingRunners) {\n dispose(sibling.state);\n }\n state.depOutputStore?.dispose();\n flushStateSlots(state.runtimeContext);\n for (const buf of Object.values(state.mainStream.ohlcv)) {\n buf.reset();\n }\n for (const stream of state.runtimeContext.secondaryStreams.values()) {\n for (const buf of Object.values(stream.ohlcv)) {\n buf.reset();\n }\n stream.taSlots.clear();\n }\n state.mainStream.taSlots.clear();\n state.emissions.plots = [];\n state.emissions.drawings = [];\n state.emissions.alerts = [];\n state.emissions.diagnostics = [];\n state.runtimeContext.drawingSlots.clear();\n state.runtimeContext.drawingSubIdCounters.clear();\n state.runtimeContext.stateSlots.clear();\n state.runtimeContext.seriesSlots.clear();\n state.runtimeContext.arraySlots.clear();\n state.runtimeContext.secondaryStreams.clear();\n state.runtimeContext.requestSecurityBars.clear();\n state.runtimeContext.requestSecurityAlignments.clear();\n state.runtimeContext.requestSecurityAscendingBars.clear();\n state.runtimeContext.requestSecurityExprSeries?.clear();\n const exprRunners = state.runtimeContext.securityExprRunners;\n if (exprRunners !== undefined) {\n for (const runner of exprRunners.values()) {\n for (const buf of Object.values(runner.foldStream.ohlcv)) {\n buf.reset();\n }\n runner.foldStream.taSlots.clear();\n runner.output.reset();\n }\n // Drops every runner reference; the per-feed index holds the same\n // (now-reset) objects, so clearing `bySlot` is the authoritative\n // teardown. The whole `RuntimeContext` is discarded after dispose.\n exprRunners.clear();\n }\n state.runtimeContext.requestLowerTfViews.clear();\n state.runtimeContext.diagnosedRequestKeys.clear();\n state.runtimeContext.diagnosedTzKeys.clear();\n state.runtimeContext.diagnosedInputKeys.clear();\n const counters = state.runtimeContext.drawingBucketCounters;\n counters.lines = 0;\n counters.labels = 0;\n counters.boxes = 0;\n counters.polylines = 0;\n counters.other = 0;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"runComputeStep.d.ts","sourceRoot":"","sources":["../../src/execution/runComputeStep.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAK5D,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,mBAAmB,CAAC;AAExE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,qBAAqB,GAC3B,QAAQ,CAAC;IAAE,IAAI,EAA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,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAc1D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAgD7F"}
@@ -4,7 +4,7 @@ import { buildComputeContext } from "../buildComputeContext.js";
4
4
  import { resetSubIdCounters } from "../emit/draw/index.js";
5
5
  import { isRuntimeErrorHalt, pushDiagnostic } from "../emit/index.js";
6
6
  import { ACTIVE_RUNTIME_CONTEXT } from "../runtimeContext.js";
7
- import { commitStateSlots, flushStateSlots, resetTentativeStateSlots } from "../state/index.js";
7
+ import { advanceSeriesSlots, commitArraySlots, commitSeriesSlots, commitStateSlots, flushStateSlots, resetSeriesHeads, resetTentativeArraySlots, resetTentativeStateSlots, } from "../state/index.js";
8
8
  import { refreshRuntimeViews } from "../views/index.js";
9
9
  /**
10
10
  * Reset the per-bar emission queues on a runner before its compute
@@ -28,6 +28,7 @@ export function resetBarEmissions(state) {
28
28
  state.emissions.toBar = state.barIndex;
29
29
  state.runtimeContext.requestSecurityAlignments.clear();
30
30
  state.runtimeContext.requestSecurityAscendingBars.clear();
31
+ state.runtimeContext.requestSecurityExprSeries?.clear();
31
32
  state.runtimeContext.logBudget = 0;
32
33
  state.runtimeContext.logBudgetExceededDiagnosed = false;
33
34
  }
@@ -58,6 +59,14 @@ export async function runComputeBody(args) {
58
59
  resetSubIdCounters(state.runtimeContext);
59
60
  if (isTick) {
60
61
  resetTentativeStateSlots(state.runtimeContext);
62
+ resetSeriesHeads(state.runtimeContext);
63
+ resetTentativeArraySlots(state.runtimeContext);
64
+ }
65
+ else {
66
+ // Advance every already-allocated series ring with a fresh NaN
67
+ // head BEFORE compute, so a slot first allocated mid-compute (it
68
+ // already holds its seeded head) is not double-advanced.
69
+ advanceSeriesSlots(state.runtimeContext);
61
70
  }
62
71
  refreshRuntimeViews(state, eventKind);
63
72
  try {
@@ -65,6 +74,8 @@ export async function runComputeBody(args) {
65
74
  if (!isTick) {
66
75
  commitStateSlots(state.runtimeContext);
67
76
  flushStateSlots(state.runtimeContext);
77
+ commitSeriesSlots(state.runtimeContext);
78
+ commitArraySlots(state.runtimeContext);
68
79
  }
69
80
  }
70
81
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"runComputeStep.js","sourceRoot":"","sources":["../../src/execution/runComputeStep.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAmCxE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAkB;IAChD,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE,CAAC;IAC3B,KAAK,CAAC,SAAS,CAAC,QAAQ,GAAG,EAAE,CAAC;IAC9B,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,EAAE,CAAC;IAC5B,KAAK,CAAC,SAAS,CAAC,eAAe,GAAG,EAAE,CAAC;IACrC,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,EAAE,CAAC;IAC1B,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,EAAE,CAAC;IACjC,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC;IACzC,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC;IACvC,KAAK,CAAC,cAAc,CAAC,yBAAyB,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AC;YAC9B,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,EAAE,CAAC;YAC5B,KAAK,CAAC,SAAS,CAAC,eAAe,GAAG,EAAE,CAAC;YACrC,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,EAAE,CAAC;YAC1B,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE;gBAC5B,IAAI,EAAE,YAAY;gBAClB,QAAQ,EAAE,OAAO;gBACjB,IAAI,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,MAAM,EAAE,IAAI;gBACZ,GAAG,EAAE,KAAK,CAAC,QAAQ;aACtB,CAAC,CAAC;YACH,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QACrD,CAAC;IACL,CAAC;YAAS,CAAC;QACP,IAAI,MAAM;YAAE,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,KAAK,CAAC;QAChD,sBAAsB,CAAC,OAAO,GAAG,IAAI,CAAC;IAC1C,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport { buildComputeContext } from \"../buildComputeContext.js\";\nimport type { RunnerState } from \"../createScriptRunner.js\";\nimport { resetSubIdCounters } from \"../emit/draw/index.js\";\nimport { isRuntimeErrorHalt, pushDiagnostic } from \"../emit/index.js\";\nimport { ACTIVE_RUNTIME_CONTEXT } from \"../runtimeContext.js\";\nimport { commitStateSlots, flushStateSlots, resetTentativeStateSlots } from \"../state/index.js\";\nimport { type EventKind, refreshRuntimeViews } from \"../views/index.js\";\n\n/**\n * Outcome of a single compute step. `ok` means the script's `compute`\n * returned normally; `halt` means `runtime.error(...)` was thrown (the\n * compute body deliberately aborted the bar). Non-halt throws propagate\n * out of {@link runComputeStep} unchanged.\n *\n * @since 0.7\n * @stable\n * @example\n * const r: RunComputeStepOutcome = { kind: \"ok\" };\n * void r;\n */\nexport type RunComputeStepOutcome =\n | Readonly<{ kind: \"ok\" }>\n | Readonly<{ kind: \"halt\"; readonly message: string }>;\n\n/**\n * Configuration for {@link runComputeStep}. `eventKind` reaches the\n * runtime views so `barstate.*` picks up the right snapshot; `isTick`\n * discriminates the close-vs-tick state-slot lifecycle.\n *\n * @since 0.7\n * @stable\n * @example\n * const args = { state, eventKind: \"close\" as const, isTick: false };\n * void args;\n */\nexport type RunComputeStepArgs = Readonly<{\n readonly state: RunnerState;\n readonly eventKind: EventKind;\n readonly isTick: boolean;\n}>;\n\n/**\n * Reset the per-bar emission queues on a runner before its compute\n * runs. Exported for the dep / sibling step driver — single-script\n * callers go through {@link runComputeStep} which calls this\n * internally.\n *\n * @since 0.7\n * @stable\n * @example\n * // resetBarEmissions(state);\n */\nexport function resetBarEmissions(state: RunnerState): void {\n state.emissions.plots = [];\n state.emissions.drawings = [];\n state.emissions.alerts = [];\n state.emissions.alertConditions = [];\n state.emissions.logs = [];\n state.emissions.diagnostics = [];\n state.emissions.fromBar = state.barIndex;\n state.emissions.toBar = state.barIndex;\n state.runtimeContext.requestSecurityAlignments.clear();\n state.runtimeContext.requestSecurityAscendingBars.clear();\n state.runtimeContext.logBudget = 0;\n state.runtimeContext.logBudgetExceededDiagnosed = false;\n}\n\n/**\n * Run the inner compute body of `state.compute` — set\n * `ACTIVE_RUNTIME_CONTEXT`, reset sub-id counters, optionally reset\n * tentative state slots, refresh views, invoke `compute`, commit /\n * flush state slots on close. Does NOT reset the per-bar emission\n * queues; callers do that exactly once via {@link resetBarEmissions}.\n *\n * `runtime.error(...)` halts clear the runner's visual emissions and\n * push a `runtime-error-thrown` diagnostic, matching the Phase-1\n * single-script behaviour byte-for-byte. Non-halt throws propagate\n * out unchanged.\n *\n * @since 0.7\n * @stable\n * @example\n * // const outcome = await runComputeBody({ state, eventKind: \"close\", isTick: false });\n * // void outcome;\n */\nexport async function runComputeBody(args: RunComputeStepArgs): Promise<RunComputeStepOutcome> {\n const { state, eventKind, isTick } = args;\n ACTIVE_RUNTIME_CONTEXT.current = state.runtimeContext;\n state.runtimeContext.isTick = isTick;\n let outcome: RunComputeStepOutcome = { kind: \"ok\" };\n try {\n resetSubIdCounters(state.runtimeContext);\n if (isTick) {\n resetTentativeStateSlots(state.runtimeContext);\n }\n refreshRuntimeViews(state, eventKind);\n try {\n await Promise.resolve(state.compute(buildComputeContext(state)));\n if (!isTick) {\n commitStateSlots(state.runtimeContext);\n flushStateSlots(state.runtimeContext);\n }\n } catch (err) {\n if (!isRuntimeErrorHalt(err)) throw err;\n state.emissions.plots = [];\n state.emissions.drawings = [];\n state.emissions.alerts = [];\n state.emissions.alertConditions = [];\n state.emissions.logs = [];\n pushDiagnostic(state.emissions, {\n kind: \"diagnostic\",\n severity: \"error\",\n code: \"runtime-error-thrown\",\n message: err.message,\n slotId: null,\n bar: state.barIndex,\n });\n outcome = { kind: \"halt\", message: err.message };\n }\n } finally {\n if (isTick) state.runtimeContext.isTick = false;\n ACTIVE_RUNTIME_CONTEXT.current = null;\n }\n return outcome;\n}\n"]}
1
+ {"version":3,"file":"runComputeStep.js","sourceRoot":"","sources":["../../src/execution/runComputeStep.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;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I,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,MAAM,EAAE,IAAI;gBACZ,GAAG,EAAE,KAAK,CAAC,QAAQ;aACtB,CAAC,CAAC;YACH,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QACrD,CAAC;IACL,CAAC;YAAS,CAAC;QACP,IAAI,MAAM;YAAE,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,KAAK,CAAC;QAChD,sBAAsB,CAAC,OAAO,GAAG,IAAI,CAAC;IAC1C,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport { buildComputeContext } from \"../buildComputeContext.js\";\nimport type { RunnerState } from \"../createScriptRunner.js\";\nimport { resetSubIdCounters } from \"../emit/draw/index.js\";\nimport { isRuntimeErrorHalt, pushDiagnostic } from \"../emit/index.js\";\nimport { ACTIVE_RUNTIME_CONTEXT } from \"../runtimeContext.js\";\nimport {\n advanceSeriesSlots,\n commitArraySlots,\n commitSeriesSlots,\n commitStateSlots,\n flushStateSlots,\n resetSeriesHeads,\n resetTentativeArraySlots,\n resetTentativeStateSlots,\n} from \"../state/index.js\";\nimport { type EventKind, refreshRuntimeViews } from \"../views/index.js\";\n\n/**\n * Outcome of a single compute step. `ok` means the script's `compute`\n * returned normally; `halt` means `runtime.error(...)` was thrown (the\n * compute body deliberately aborted the bar). Non-halt throws propagate\n * out of {@link runComputeStep} unchanged.\n *\n * @since 0.7\n * @stable\n * @example\n * const r: RunComputeStepOutcome = { kind: \"ok\" };\n * void r;\n */\nexport type RunComputeStepOutcome =\n | Readonly<{ kind: \"ok\" }>\n | Readonly<{ kind: \"halt\"; readonly message: string }>;\n\n/**\n * Configuration for {@link runComputeStep}. `eventKind` reaches the\n * runtime views so `barstate.*` picks up the right snapshot; `isTick`\n * discriminates the close-vs-tick state-slot lifecycle.\n *\n * @since 0.7\n * @stable\n * @example\n * const args = { state, eventKind: \"close\" as const, isTick: false };\n * void args;\n */\nexport type RunComputeStepArgs = Readonly<{\n readonly state: RunnerState;\n readonly eventKind: EventKind;\n readonly isTick: boolean;\n}>;\n\n/**\n * Reset the per-bar emission queues on a runner before its compute\n * runs. Exported for the dep / sibling step driver — single-script\n * callers go through {@link runComputeStep} which calls this\n * internally.\n *\n * @since 0.7\n * @stable\n * @example\n * // resetBarEmissions(state);\n */\nexport function resetBarEmissions(state: RunnerState): void {\n state.emissions.plots = [];\n state.emissions.drawings = [];\n state.emissions.alerts = [];\n state.emissions.alertConditions = [];\n state.emissions.logs = [];\n state.emissions.diagnostics = [];\n state.emissions.fromBar = state.barIndex;\n state.emissions.toBar = state.barIndex;\n state.runtimeContext.requestSecurityAlignments.clear();\n state.runtimeContext.requestSecurityAscendingBars.clear();\n state.runtimeContext.requestSecurityExprSeries?.clear();\n state.runtimeContext.logBudget = 0;\n state.runtimeContext.logBudgetExceededDiagnosed = false;\n}\n\n/**\n * Run the inner compute body of `state.compute` — set\n * `ACTIVE_RUNTIME_CONTEXT`, reset sub-id counters, optionally reset\n * tentative state slots, refresh views, invoke `compute`, commit /\n * flush state slots on close. Does NOT reset the per-bar emission\n * queues; callers do that exactly once via {@link resetBarEmissions}.\n *\n * `runtime.error(...)` halts clear the runner's visual emissions and\n * push a `runtime-error-thrown` diagnostic, matching the Phase-1\n * single-script behaviour byte-for-byte. Non-halt throws propagate\n * out unchanged.\n *\n * @since 0.7\n * @stable\n * @example\n * // const outcome = await runComputeBody({ state, eventKind: \"close\", isTick: false });\n * // void outcome;\n */\nexport async function runComputeBody(args: RunComputeStepArgs): Promise<RunComputeStepOutcome> {\n const { state, eventKind, isTick } = args;\n ACTIVE_RUNTIME_CONTEXT.current = state.runtimeContext;\n state.runtimeContext.isTick = isTick;\n let outcome: RunComputeStepOutcome = { kind: \"ok\" };\n try {\n resetSubIdCounters(state.runtimeContext);\n if (isTick) {\n resetTentativeStateSlots(state.runtimeContext);\n resetSeriesHeads(state.runtimeContext);\n resetTentativeArraySlots(state.runtimeContext);\n } else {\n // Advance every already-allocated series ring with a fresh NaN\n // head BEFORE compute, so a slot first allocated mid-compute (it\n // already holds its seeded head) is not double-advanced.\n advanceSeriesSlots(state.runtimeContext);\n }\n refreshRuntimeViews(state, eventKind);\n try {\n await Promise.resolve(state.compute(buildComputeContext(state)));\n if (!isTick) {\n commitStateSlots(state.runtimeContext);\n flushStateSlots(state.runtimeContext);\n commitSeriesSlots(state.runtimeContext);\n commitArraySlots(state.runtimeContext);\n }\n } catch (err) {\n if (!isRuntimeErrorHalt(err)) throw err;\n state.emissions.plots = [];\n state.emissions.drawings = [];\n state.emissions.alerts = [];\n state.emissions.alertConditions = [];\n state.emissions.logs = [];\n pushDiagnostic(state.emissions, {\n kind: \"diagnostic\",\n severity: \"error\",\n code: \"runtime-error-thrown\",\n message: err.message,\n slotId: null,\n bar: state.barIndex,\n });\n outcome = { kind: \"halt\", message: err.message };\n }\n } finally {\n if (isTick) state.runtimeContext.isTick = false;\n ACTIVE_RUNTIME_CONTEXT.current = null;\n }\n return outcome;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { Float64RingBuffer, RingBuffer } from "./ringBuffer.js";
2
2
  export type { RingBufferLike } from "./ringBuffer.js";
3
- export { makeSeriesView, makeShiftedSeriesView } from "./seriesView.js";
3
+ export { makeSeriesView, makeShiftedSeriesView, seriesOffsetOf } from "./seriesView.js";
4
4
  export type { BarView, OhlcvBuffers, StreamState } from "./streamState.js";
5
5
  export { createStreamState } from "./streamState.js";
6
6
  export type { StateStore } from "./stateStore.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,YAAY,EAAE,cA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E,MAAM,oBAAoB,CAAC;AAC/E,YAAY,EAAE,WAAW,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAOxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,YAAY,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,YAAY,EACR,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,SAAS,EACT,aAAa,EACb,aAAa,EACb,iBAAiB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,cAAc,GACjB,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) 2026 Invinite. Licensed under the MIT License.
2
2
  // See the LICENSE file in the repo root for full license text.
3
3
  export { Float64RingBuffer, RingBuffer } from "./ringBuffer.js";
4
- export { makeSeriesView, makeShiftedSeriesView } from "./seriesView.js";
4
+ export { makeSeriesView, makeShiftedSeriesView, seriesOffsetOf } from "./seriesView.js";
5
5
  export { createStreamState } from "./streamState.js";
6
6
  export { inMemoryStateStore } from "./stateStore.js";
7
7
  export { inMemoryPersistentStateStore } from "./persistentStateStore.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,sEAAsE;AACtE,gEAAgE;AAChE,uDAAuD;AACvD,oEAAoE;AACpE,mEAAmE;AACnE,uEAAuE;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAYhE,OAAO,EACH,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,cAAc,GACjB,MAAM,gBAAgB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nexport { Float64RingBuffer, RingBuffer } from \"./ringBuffer.js\";\nexport type { RingBufferLike } from \"./ringBuffer.js\";\nexport { makeSeriesView, makeShiftedSeriesView } from \"./seriesView.js\";\nexport type { BarView, OhlcvBuffers, StreamState } from \"./streamState.js\";\nexport { createStreamState } from \"./streamState.js\";\nexport type { StateStore } from \"./stateStore.js\";\nexport { inMemoryStateStore } from \"./stateStore.js\";\nexport type { PersistentStateStore } from \"./persistentStateStore.js\";\nexport { inMemoryPersistentStateStore } from \"./persistentStateStore.js\";\nexport { asMutableSlot, buildStateNamespace, StateSlot } from \"./state/index.js\";\nexport { resolveInputs } from \"./inputs/index.js\";\nexport { buildRequestNamespace, makeNanSecurityBar } from \"./request/index.js\";\nexport type { DrawingSlot, MutableRunnerEmissions, RuntimeContext } from \"./runtimeContext.js\";\nexport {\n createRuntimeViews,\n makeBarStateView,\n makeSymInfoView,\n makeTimeframeView,\n} from \"./views/index.js\";\nexport type { AdapterSymInfo, BarStateInputs, EventKind, RuntimeViews } from \"./views/index.js\";\nexport { ACTIVE_RUNTIME_CONTEXT } from \"./runtimeContext.js\";\nexport { createScriptRunner } from \"./createScriptRunner.js\";\nexport type { CreateScriptRunnerArgs, ScriptRunner } from \"./createScriptRunner.js\";\nexport { alert, applyPlotOverride, draw, hline, plot, pushDrawing } from \"./emit/index.js\";\nexport { TA_REGISTRY, ta } from \"./ta/index.js\";\nexport { maRibbonOutputKeys } from \"./ta/index.js\";\nexport type { RuntimeTaNamespace, ScalarOrSeries } from \"./ta/index.js\";\n// Public re-export added in Phase 3 Task 10 so consumer adapters that\n// render `draw.regressionTrend` can compute the OLS fit without\n// duplicating math. The Phase-2 helper signature stays\n// `(source: Float64Array, length: number): LinearRegressionFrame` —\n// pass `length === source.length` for a single-window fit over the\n// bar range; the line value at the last index is the end-of-range fit.\nexport { linearRegression } from \"./ta/lib/linearRegression.js\";\nexport type { LinearRegressionFrame } from \"./ta/lib/linearRegression.js\";\n// Indicator-composition surface (Phase 7).\nexport type {\n CreateDepRunnerArgs,\n DepOutputDeclaration,\n DepOutputStore,\n DepRunner,\n DepRunnerLike,\n SiblingRunner,\n SiblingRunnerLike,\n} from \"./dep/index.js\";\nexport {\n applyDepEmissionPolicy,\n createDepOutputStore,\n createDepRunner,\n createSiblingRunner,\n runDepStep,\n runSiblingStep,\n} from \"./dep/index.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAExF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,sEAAsE;AACtE,gEAAgE;AAChE,uDAAuD;AACvD,oEAAoE;AACpE,mEAAmE;AACnE,uEAAuE;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAYhE,OAAO,EACH,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,cAAc,GACjB,MAAM,gBAAgB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nexport { Float64RingBuffer, RingBuffer } from \"./ringBuffer.js\";\nexport type { RingBufferLike } from \"./ringBuffer.js\";\nexport { makeSeriesView, makeShiftedSeriesView, seriesOffsetOf } from \"./seriesView.js\";\nexport type { BarView, OhlcvBuffers, StreamState } from \"./streamState.js\";\nexport { createStreamState } from \"./streamState.js\";\nexport type { StateStore } from \"./stateStore.js\";\nexport { inMemoryStateStore } from \"./stateStore.js\";\nexport type { PersistentStateStore } from \"./persistentStateStore.js\";\nexport { inMemoryPersistentStateStore } from \"./persistentStateStore.js\";\nexport { asMutableSlot, buildStateNamespace, StateSlot } from \"./state/index.js\";\nexport { resolveInputs } from \"./inputs/index.js\";\nexport { buildRequestNamespace, makeNanSecurityBar } from \"./request/index.js\";\nexport type { DrawingSlot, MutableRunnerEmissions, RuntimeContext } from \"./runtimeContext.js\";\nexport {\n createRuntimeViews,\n makeBarStateView,\n makeSymInfoView,\n makeTimeframeView,\n} from \"./views/index.js\";\nexport type { AdapterSymInfo, BarStateInputs, EventKind, RuntimeViews } from \"./views/index.js\";\nexport { ACTIVE_RUNTIME_CONTEXT } from \"./runtimeContext.js\";\nexport { createScriptRunner } from \"./createScriptRunner.js\";\nexport type { CreateScriptRunnerArgs, ScriptRunner } from \"./createScriptRunner.js\";\nexport { alert, applyPlotOverride, draw, hline, plot, pushDrawing } from \"./emit/index.js\";\nexport { TA_REGISTRY, ta } from \"./ta/index.js\";\nexport { maRibbonOutputKeys } from \"./ta/index.js\";\nexport type { RuntimeTaNamespace, ScalarOrSeries } from \"./ta/index.js\";\n// Public re-export added in Phase 3 Task 10 so consumer adapters that\n// render `draw.regressionTrend` can compute the OLS fit without\n// duplicating math. The Phase-2 helper signature stays\n// `(source: Float64Array, length: number): LinearRegressionFrame` —\n// pass `length === source.length` for a single-window fit over the\n// bar range; the line value at the last index is the end-of-range fit.\nexport { linearRegression } from \"./ta/lib/linearRegression.js\";\nexport type { LinearRegressionFrame } from \"./ta/lib/linearRegression.js\";\n// Indicator-composition surface (Phase 7).\nexport type {\n CreateDepRunnerArgs,\n DepOutputDeclaration,\n DepOutputStore,\n DepRunner,\n DepRunnerLike,\n SiblingRunner,\n SiblingRunnerLike,\n} from \"./dep/index.js\";\nexport {\n applyDepEmissionPolicy,\n createDepOutputStore,\n createDepRunner,\n createSiblingRunner,\n runDepStep,\n runSiblingStep,\n} from \"./dep/index.js\";\n"]}
@@ -61,6 +61,7 @@ function matchesDescriptor(descriptor, value) {
61
61
  case "color":
62
62
  case "symbol":
63
63
  case "interval":
64
+ case "session":
64
65
  return typeof value === "string";
65
66
  case "enum":
66
67
  return typeof value === "string" && descriptor.options.includes(value);
@@ -1 +1 @@
1
- {"version":3,"file":"resolveInputs.js","sourceRoot":"","sources":["../../src/inputs/resolveInputs.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAM/D,MAAM,aAAa,GAAG,I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ACX,GAAG,EAAE,IAAI;KACZ,CAAC,CAAC;AACP,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACjC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnE,OAAO,OAAO,KAAK,CAAC;AACxB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { InputDescriptor, ScriptManifest } from \"@invinite-org/chartlang-core\";\n\nimport type { RuntimeContext } from \"../runtimeContext.js\";\n\nconst SOURCE_FIELDS = new Set<string>([\n \"open\",\n \"high\",\n \"low\",\n \"close\",\n \"hl2\",\n \"hlc3\",\n \"ohlc4\",\n \"hlcc4\",\n]);\n\n/**\n * Resolve the script's effective `inputs` bag from manifest defaults plus\n * optional adapter-supplied overrides. Type-incompatible overrides fall back\n * to the descriptor default and emit `input-coercion-failed` once per\n * mount/key.\n *\n * @since 0.4\n * @stable\n * @example\n * // import { resolveInputs } from \"@invinite-org/chartlang-runtime\";\n * // const inputs = resolveInputs(manifest, { length: 20 }, ctx);\n * const fn: typeof resolveInputs = resolveInputs;\n * void fn;\n */\nexport function resolveInputs(\n manifest: ScriptManifest,\n overrides: Readonly<Record<string, unknown>>,\n ctx: RuntimeContext,\n): Readonly<Record<string, unknown>> {\n const out: Record<string, unknown> = {};\n for (const [key, descriptor] of Object.entries(manifest.inputs)) {\n const fallback = defaultValueFor(descriptor);\n if (!Object.hasOwn(overrides, key) || overrides[key] === undefined) {\n out[key] = fallback;\n continue;\n }\n const override = overrides[key];\n if (matchesDescriptor(descriptor, override)) {\n out[key] = override;\n continue;\n }\n pushInputDiagnostic(ctx, key, descriptor.kind, override);\n out[key] = fallback;\n }\n return Object.freeze(out);\n}\n\nfunction defaultValueFor(descriptor: InputDescriptor<unknown>): unknown {\n if (\"defaultValue\" in descriptor) return descriptor.defaultValue;\n return undefined;\n}\n\nfunction matchesDescriptor(descriptor: InputDescriptor<unknown>, value: unknown): boolean {\n switch (descriptor.kind) {\n case \"int\":\n return typeof value === \"number\" && Number.isInteger(value);\n case \"float\":\n case \"time\":\n case \"price\":\n return typeof value === \"number\" && Number.isFinite(value);\n case \"bool\":\n return typeof value === \"boolean\";\n case \"string\":\n case \"color\":\n case \"symbol\":\n case \"interval\":\n return typeof value === \"string\";\n case \"enum\":\n return typeof value === \"string\" && descriptor.options.includes(value);\n case \"source\":\n return typeof value === \"string\" && SOURCE_FIELDS.has(value);\n case \"external-series\":\n return value !== null && typeof value === \"object\";\n }\n}\n\nfunction pushInputDiagnostic(\n ctx: RuntimeContext,\n key: string,\n expected: string,\n value: unknown,\n): void {\n if (ctx.diagnosedInputKeys.has(key)) return;\n ctx.diagnosedInputKeys.add(key);\n ctx.emissions.diagnostics.push({\n kind: \"diagnostic\",\n severity: \"warning\",\n code: \"input-coercion-failed\",\n message: `input \"${key}\" expected ${expected}, got ${describeValue(value)}`,\n slotId: key,\n bar: null,\n });\n}\n\nfunction describeValue(value: unknown): string {\n if (value === null) return \"null\";\n if (typeof value === \"number\" && Number.isNaN(value)) return \"NaN\";\n return typeof value;\n}\n"]}
1
+ {"version":3,"file":"resolveInputs.js","sourceRoot":"","sources":["../../src/inputs/resolveInputs.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAM/D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAS;IAClC,MAAM;IACN,MAAM;IACN,KAAK;IACL,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;CACV,CAAC,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,aAAa,CACzB,QAAwB,EACxB,SAA4C,EAC5C,GAAmB;IAEnB,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAA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","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { InputDescriptor, ScriptManifest } from \"@invinite-org/chartlang-core\";\n\nimport type { RuntimeContext } from \"../runtimeContext.js\";\n\nconst SOURCE_FIELDS = new Set<string>([\n \"open\",\n \"high\",\n \"low\",\n \"close\",\n \"hl2\",\n \"hlc3\",\n \"ohlc4\",\n \"hlcc4\",\n]);\n\n/**\n * Resolve the script's effective `inputs` bag from manifest defaults plus\n * optional adapter-supplied overrides. Type-incompatible overrides fall back\n * to the descriptor default and emit `input-coercion-failed` once per\n * mount/key.\n *\n * @since 0.4\n * @stable\n * @example\n * // import { resolveInputs } from \"@invinite-org/chartlang-runtime\";\n * // const inputs = resolveInputs(manifest, { length: 20 }, ctx);\n * const fn: typeof resolveInputs = resolveInputs;\n * void fn;\n */\nexport function resolveInputs(\n manifest: ScriptManifest,\n overrides: Readonly<Record<string, unknown>>,\n ctx: RuntimeContext,\n): Readonly<Record<string, unknown>> {\n const out: Record<string, unknown> = {};\n for (const [key, descriptor] of Object.entries(manifest.inputs)) {\n const fallback = defaultValueFor(descriptor);\n if (!Object.hasOwn(overrides, key) || overrides[key] === undefined) {\n out[key] = fallback;\n continue;\n }\n const override = overrides[key];\n if (matchesDescriptor(descriptor, override)) {\n out[key] = override;\n continue;\n }\n pushInputDiagnostic(ctx, key, descriptor.kind, override);\n out[key] = fallback;\n }\n return Object.freeze(out);\n}\n\nfunction defaultValueFor(descriptor: InputDescriptor<unknown>): unknown {\n if (\"defaultValue\" in descriptor) return descriptor.defaultValue;\n return undefined;\n}\n\nfunction matchesDescriptor(descriptor: InputDescriptor<unknown>, value: unknown): boolean {\n switch (descriptor.kind) {\n case \"int\":\n return typeof value === \"number\" && Number.isInteger(value);\n case \"float\":\n case \"time\":\n case \"price\":\n return typeof value === \"number\" && Number.isFinite(value);\n case \"bool\":\n return typeof value === \"boolean\";\n case \"string\":\n case \"color\":\n case \"symbol\":\n case \"interval\":\n case \"session\":\n return typeof value === \"string\";\n case \"enum\":\n return typeof value === \"string\" && descriptor.options.includes(value);\n case \"source\":\n return typeof value === \"string\" && SOURCE_FIELDS.has(value);\n case \"external-series\":\n return value !== null && typeof value === \"object\";\n }\n}\n\nfunction pushInputDiagnostic(\n ctx: RuntimeContext,\n key: string,\n expected: string,\n value: unknown,\n): void {\n if (ctx.diagnosedInputKeys.has(key)) return;\n ctx.diagnosedInputKeys.add(key);\n ctx.emissions.diagnostics.push({\n kind: \"diagnostic\",\n severity: \"warning\",\n code: \"input-coercion-failed\",\n message: `input \"${key}\" expected ${expected}, got ${describeValue(value)}`,\n slotId: key,\n bar: null,\n });\n}\n\nfunction describeValue(value: unknown): string {\n if (value === null) return \"null\";\n if (typeof value === \"number\" && Number.isNaN(value)) return \"NaN\";\n return typeof value;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"persistentStateStore.runtime.d.ts","sourceRoot":"","sources":["../src/persistentStateStore.runtime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGR,aAAa,EAEhB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAO3D;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAoD9C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAe9F;AAyED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAuBtF;AA2BD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA8B7F;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CACxC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf"}
1
+ {"version":3,"file":"persistentStateStore.runtime.d.ts","sourceRoot":"","sources":["../src/persistentStateStore.runtime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGR,aAAa,EAEhB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAgB3D;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,QAAS,CAAC;AA0D9C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAe9F;AAqGD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAuBtF;AA2BD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA8B7F;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CACxC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf"}
@@ -2,7 +2,7 @@
2
2
  // See the LICENSE file in the repo root for full license text.
3
3
  import { pushDiagnostic } from "./emit/index.js";
4
4
  import { validateSnapshot } from "./persistentStateStore.validate.js";
5
- import { restoreStateSlots, serialiseStateSlots } from "./state/index.js";
5
+ import { isArraySlotSnapshotKey, isSeriesSlotSnapshotKey, restoreArraySlots, restoreSeriesSlots, restoreStateSlots, serialiseArraySlots, serialiseSeriesSlots, serialiseStateSlots, } from "./state/index.js";
6
6
  import { isTaSlotSnapshotKey, restoreTaSlots, serialiseTaSlots } from "./ta/persistence.js";
7
7
  /**
8
8
  * Default PLAN §6.9 write cadence for persistent snapshots.
@@ -32,12 +32,18 @@ function captureStreams(state) {
32
32
  function primarySectionSlots(state) {
33
33
  return Object.freeze({
34
34
  ...serialiseStateSlots(state.runtimeContext),
35
+ ...serialiseSeriesSlots(state.runtimeContext),
36
+ ...serialiseArraySlots(state.runtimeContext),
35
37
  ...serialiseTaSlots(state.mainStream),
36
38
  });
37
39
  }
38
40
  function runnerSection(ctx) {
39
41
  return Object.freeze({
40
- slots: Object.freeze({ ...serialiseStateSlots(ctx) }),
42
+ slots: Object.freeze({
43
+ ...serialiseStateSlots(ctx),
44
+ ...serialiseSeriesSlots(ctx),
45
+ ...serialiseArraySlots(ctx),
46
+ }),
41
47
  });
42
48
  }
43
49
  function captureSiblings(state) {
@@ -101,15 +107,28 @@ function resolveMainStreamSnapshot(snapshot, mainInterval) {
101
107
  const fallback = firstStreamKey(snapshot);
102
108
  return fallback === null ? undefined : snapshot.streams[fallback];
103
109
  }
104
- function nonTaSlots(slots) {
110
+ // Scalar `state.*` keys only — strip `ta:` (restored onto the stream),
111
+ // `:series` (restored into `ctx.seriesSlots`), and `:array` (restored into
112
+ // `ctx.arraySlots`) so the scalar slot store receives none of them.
113
+ function scalarStateSlots(slots) {
105
114
  const out = {};
106
115
  for (const [slotKey, value] of Object.entries(slots)) {
107
- if (!isTaSlotSnapshotKey(slotKey)) {
116
+ if (!isTaSlotSnapshotKey(slotKey) &&
117
+ !isSeriesSlotSnapshotKey(slotKey) &&
118
+ !isArraySlotSnapshotKey(slotKey)) {
108
119
  out[slotKey] = value;
109
120
  }
110
121
  }
111
122
  return out;
112
123
  }
124
+ // Restore a runner's scalar `state.*` slots and `state.series` slots from
125
+ // one merged `slots` record. Series rings are sized to the runner's current
126
+ // ring capacity (the close buffer's capacity).
127
+ function restoreRunnerSlots(ctx, slots, capacity) {
128
+ restoreStateSlots(ctx, scalarStateSlots(slots));
129
+ restoreSeriesSlots(ctx, slots, capacity);
130
+ restoreArraySlots(ctx, slots);
131
+ }
113
132
  function pushMalformedSection(state, message) {
114
133
  pushDiagnostic(state.emissions, {
115
134
  kind: "diagnostic",
@@ -128,7 +147,7 @@ function restoreSiblingSections(state, siblings) {
128
147
  pushMalformedSection(state, `persistent state snapshot referenced unknown sibling "${exportName}"`);
129
148
  continue;
130
149
  }
131
- restoreStateSlots(sibling.state.runtimeContext, section.slots);
150
+ restoreRunnerSlots(sibling.state.runtimeContext, section.slots, state.mainStream.ohlcv.close.capacity);
132
151
  }
133
152
  }
134
153
  function restoreDependencySections(state, dependencies) {
@@ -139,7 +158,7 @@ function restoreDependencySections(state, dependencies) {
139
158
  pushMalformedSection(state, `persistent state snapshot referenced unknown dependency "${localId}"`);
140
159
  continue;
141
160
  }
142
- restoreStateSlots(dep.state.runtimeContext, section.slots);
161
+ restoreRunnerSlots(dep.state.runtimeContext, section.slots, state.mainStream.ohlcv.close.capacity);
143
162
  }
144
163
  }
145
164
  /**
@@ -175,7 +194,7 @@ export function restoreStateSnapshot(state, snapshot) {
175
194
  }
176
195
  const primarySlots = primarySlotsOf(snapshot);
177
196
  restoreTaSlots(state.mainStream, primarySlots);
178
- restoreStateSlots(state.runtimeContext, nonTaSlots(primarySlots));
197
+ restoreRunnerSlots(state.runtimeContext, primarySlots, state.mainStream.ohlcv.close.capacity);
179
198
  if (snapshot.siblings !== undefined) {
180
199
  restoreSiblingSections(state, snapshot.siblings);
181
200
  }