@invinite-org/chartlang-runtime 1.0.2 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (567) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +10 -2
  3. package/dist/buildComputeContext.js.map +1 -1
  4. package/dist/createScriptRunner.d.ts +55 -4
  5. package/dist/createScriptRunner.d.ts.map +1 -1
  6. package/dist/createScriptRunner.js +103 -35
  7. package/dist/createScriptRunner.js.map +1 -1
  8. package/dist/dep/DepOutputStore.d.ts +92 -0
  9. package/dist/dep/DepOutputStore.d.ts.map +1 -0
  10. package/dist/dep/DepOutputStore.js +0 -0
  11. package/dist/dep/DepOutputStore.js.map +1 -0
  12. package/dist/dep/DepRunner.d.ts +146 -0
  13. package/dist/dep/DepRunner.d.ts.map +1 -0
  14. package/dist/dep/DepRunner.js +243 -0
  15. package/dist/dep/DepRunner.js.map +1 -0
  16. package/dist/dep/depOutput.d.ts +50 -0
  17. package/dist/dep/depOutput.d.ts.map +1 -0
  18. package/dist/dep/depOutput.js +92 -0
  19. package/dist/dep/depOutput.js.map +1 -0
  20. package/dist/dep/emissionFilter.d.ts +70 -0
  21. package/dist/dep/emissionFilter.d.ts.map +1 -0
  22. package/dist/dep/emissionFilter.js +105 -0
  23. package/dist/dep/emissionFilter.js.map +1 -0
  24. package/dist/dep/index.d.ts +8 -0
  25. package/dist/dep/index.d.ts.map +1 -0
  26. package/dist/dep/index.js +7 -0
  27. package/dist/dep/index.js.map +1 -0
  28. package/dist/emit/alert.js.map +1 -1
  29. package/dist/emit/alertConditionEmission.js.map +1 -1
  30. package/dist/emit/applyPlotOverride.d.ts +24 -0
  31. package/dist/emit/applyPlotOverride.d.ts.map +1 -0
  32. package/dist/emit/applyPlotOverride.js +48 -0
  33. package/dist/emit/applyPlotOverride.js.map +1 -0
  34. package/dist/emit/draw/annotations/arrow.js +1 -1
  35. package/dist/emit/draw/annotations/arrow.js.map +1 -1
  36. package/dist/emit/draw/annotations/arrowMarkDown.js +1 -1
  37. package/dist/emit/draw/annotations/arrowMarkDown.js.map +1 -1
  38. package/dist/emit/draw/annotations/arrowMarkUp.js +1 -1
  39. package/dist/emit/draw/annotations/arrowMarkUp.js.map +1 -1
  40. package/dist/emit/draw/annotations/arrowMarker.js +1 -1
  41. package/dist/emit/draw/annotations/arrowMarker.js.map +1 -1
  42. package/dist/emit/draw/annotations/text.js +1 -1
  43. package/dist/emit/draw/annotations/text.js.map +1 -1
  44. package/dist/emit/draw/boxes/circle.js +1 -1
  45. package/dist/emit/draw/boxes/circle.js.map +1 -1
  46. package/dist/emit/draw/boxes/ellipse.d.ts +1 -1
  47. package/dist/emit/draw/boxes/ellipse.js +1 -1
  48. package/dist/emit/draw/boxes/ellipse.js.map +1 -1
  49. package/dist/emit/draw/boxes/marker.js +1 -1
  50. package/dist/emit/draw/boxes/marker.js.map +1 -1
  51. package/dist/emit/draw/boxes/path.d.ts +1 -1
  52. package/dist/emit/draw/boxes/path.js +1 -1
  53. package/dist/emit/draw/boxes/path.js.map +1 -1
  54. package/dist/emit/draw/boxes/polyline.d.ts +1 -1
  55. package/dist/emit/draw/boxes/polyline.js +1 -1
  56. package/dist/emit/draw/boxes/polyline.js.map +1 -1
  57. package/dist/emit/draw/boxes/rectangle.js +1 -1
  58. package/dist/emit/draw/boxes/rectangle.js.map +1 -1
  59. package/dist/emit/draw/boxes/rotatedRectangle.js +1 -1
  60. package/dist/emit/draw/boxes/rotatedRectangle.js.map +1 -1
  61. package/dist/emit/draw/boxes/triangle.d.ts +1 -1
  62. package/dist/emit/draw/boxes/triangle.js +1 -1
  63. package/dist/emit/draw/boxes/triangle.js.map +1 -1
  64. package/dist/emit/draw/channels/disjointChannel.js +1 -1
  65. package/dist/emit/draw/channels/disjointChannel.js.map +1 -1
  66. package/dist/emit/draw/channels/flatTopBottom.d.ts +1 -2
  67. package/dist/emit/draw/channels/flatTopBottom.d.ts.map +1 -1
  68. package/dist/emit/draw/channels/flatTopBottom.js +1 -1
  69. package/dist/emit/draw/channels/flatTopBottom.js.map +1 -1
  70. package/dist/emit/draw/channels/regressionTrend.d.ts +3 -4
  71. package/dist/emit/draw/channels/regressionTrend.d.ts.map +1 -1
  72. package/dist/emit/draw/channels/regressionTrend.js +1 -1
  73. package/dist/emit/draw/channels/regressionTrend.js.map +1 -1
  74. package/dist/emit/draw/channels/trendChannel.js +1 -1
  75. package/dist/emit/draw/channels/trendChannel.js.map +1 -1
  76. package/dist/emit/draw/containers/frame.d.ts +1 -1
  77. package/dist/emit/draw/containers/frame.js +2 -2
  78. package/dist/emit/draw/containers/frame.js.map +1 -1
  79. package/dist/emit/draw/containers/group.d.ts +1 -2
  80. package/dist/emit/draw/containers/group.d.ts.map +1 -1
  81. package/dist/emit/draw/containers/group.js +2 -2
  82. package/dist/emit/draw/containers/group.js.map +1 -1
  83. package/dist/emit/draw/curves/arc.js +1 -1
  84. package/dist/emit/draw/curves/arc.js.map +1 -1
  85. package/dist/emit/draw/curves/brush.js +1 -1
  86. package/dist/emit/draw/curves/brush.js.map +1 -1
  87. package/dist/emit/draw/curves/curve.js +1 -1
  88. package/dist/emit/draw/curves/curve.js.map +1 -1
  89. package/dist/emit/draw/curves/doubleCurve.js +1 -1
  90. package/dist/emit/draw/curves/doubleCurve.js.map +1 -1
  91. package/dist/emit/draw/curves/highlighter.js +1 -1
  92. package/dist/emit/draw/curves/highlighter.js.map +1 -1
  93. package/dist/emit/draw/curves/pen.js +1 -1
  94. package/dist/emit/draw/curves/pen.js.map +1 -1
  95. package/dist/emit/draw/cycles/cyclicLines.js +1 -1
  96. package/dist/emit/draw/cycles/cyclicLines.js.map +1 -1
  97. package/dist/emit/draw/cycles/sineLine.js +1 -1
  98. package/dist/emit/draw/cycles/sineLine.js.map +1 -1
  99. package/dist/emit/draw/cycles/timeCycles.js +1 -1
  100. package/dist/emit/draw/cycles/timeCycles.js.map +1 -1
  101. package/dist/emit/draw/elliott/elliottCorrectionWave.js +1 -1
  102. package/dist/emit/draw/elliott/elliottCorrectionWave.js.map +1 -1
  103. package/dist/emit/draw/elliott/elliottDoubleCombo.js +1 -1
  104. package/dist/emit/draw/elliott/elliottDoubleCombo.js.map +1 -1
  105. package/dist/emit/draw/elliott/elliottImpulseWave.js +1 -1
  106. package/dist/emit/draw/elliott/elliottImpulseWave.js.map +1 -1
  107. package/dist/emit/draw/elliott/elliottTriangleWave.js +1 -1
  108. package/dist/emit/draw/elliott/elliottTriangleWave.js.map +1 -1
  109. package/dist/emit/draw/elliott/elliottTripleCombo.js +1 -1
  110. package/dist/emit/draw/elliott/elliottTripleCombo.js.map +1 -1
  111. package/dist/emit/draw/fibA/fibChannel.js +1 -1
  112. package/dist/emit/draw/fibA/fibChannel.js.map +1 -1
  113. package/dist/emit/draw/fibA/fibRetracement.js +1 -1
  114. package/dist/emit/draw/fibA/fibRetracement.js.map +1 -1
  115. package/dist/emit/draw/fibA/fibTimeZone.d.ts +1 -2
  116. package/dist/emit/draw/fibA/fibTimeZone.d.ts.map +1 -1
  117. package/dist/emit/draw/fibA/fibTimeZone.js +1 -1
  118. package/dist/emit/draw/fibA/fibTimeZone.js.map +1 -1
  119. package/dist/emit/draw/fibA/fibTrendExtension.js +1 -1
  120. package/dist/emit/draw/fibA/fibTrendExtension.js.map +1 -1
  121. package/dist/emit/draw/fibA/fibWedge.js +1 -1
  122. package/dist/emit/draw/fibA/fibWedge.js.map +1 -1
  123. package/dist/emit/draw/fibB/fibCircles.d.ts +1 -2
  124. package/dist/emit/draw/fibB/fibCircles.d.ts.map +1 -1
  125. package/dist/emit/draw/fibB/fibCircles.js +1 -1
  126. package/dist/emit/draw/fibB/fibCircles.js.map +1 -1
  127. package/dist/emit/draw/fibB/fibSpeedArcs.js +1 -1
  128. package/dist/emit/draw/fibB/fibSpeedArcs.js.map +1 -1
  129. package/dist/emit/draw/fibB/fibSpeedFan.js +1 -1
  130. package/dist/emit/draw/fibB/fibSpeedFan.js.map +1 -1
  131. package/dist/emit/draw/fibB/fibSpiral.d.ts +1 -2
  132. package/dist/emit/draw/fibB/fibSpiral.d.ts.map +1 -1
  133. package/dist/emit/draw/fibB/fibSpiral.js +1 -1
  134. package/dist/emit/draw/fibB/fibSpiral.js.map +1 -1
  135. package/dist/emit/draw/fibB/fibTrendTime.d.ts +1 -2
  136. package/dist/emit/draw/fibB/fibTrendTime.d.ts.map +1 -1
  137. package/dist/emit/draw/fibB/fibTrendTime.js +1 -1
  138. package/dist/emit/draw/fibB/fibTrendTime.js.map +1 -1
  139. package/dist/emit/draw/gann/gannBox.js +1 -1
  140. package/dist/emit/draw/gann/gannBox.js.map +1 -1
  141. package/dist/emit/draw/gann/gannFan.js +1 -1
  142. package/dist/emit/draw/gann/gannFan.js.map +1 -1
  143. package/dist/emit/draw/gann/gannSquare.js +1 -1
  144. package/dist/emit/draw/gann/gannSquare.js.map +1 -1
  145. package/dist/emit/draw/gann/gannSquareFixed.js +1 -1
  146. package/dist/emit/draw/gann/gannSquareFixed.js.map +1 -1
  147. package/dist/emit/draw/handle.d.ts +2 -2
  148. package/dist/emit/draw/handle.js +2 -2
  149. package/dist/emit/draw/handle.js.map +1 -1
  150. package/dist/emit/draw/index.js.map +1 -1
  151. package/dist/emit/draw/lines/crossLine.js +1 -1
  152. package/dist/emit/draw/lines/crossLine.js.map +1 -1
  153. package/dist/emit/draw/lines/horizontalLine.d.ts +1 -1
  154. package/dist/emit/draw/lines/horizontalLine.js +1 -1
  155. package/dist/emit/draw/lines/horizontalLine.js.map +1 -1
  156. package/dist/emit/draw/lines/horizontalRay.js +1 -1
  157. package/dist/emit/draw/lines/horizontalRay.js.map +1 -1
  158. package/dist/emit/draw/lines/line.d.ts +1 -1
  159. package/dist/emit/draw/lines/line.d.ts.map +1 -1
  160. package/dist/emit/draw/lines/line.js +2 -3
  161. package/dist/emit/draw/lines/line.js.map +1 -1
  162. package/dist/emit/draw/lines/trendAngle.js +1 -1
  163. package/dist/emit/draw/lines/trendAngle.js.map +1 -1
  164. package/dist/emit/draw/lines/verticalLine.js +1 -1
  165. package/dist/emit/draw/lines/verticalLine.js.map +1 -1
  166. package/dist/emit/draw/namespace.d.ts +1 -1
  167. package/dist/emit/draw/namespace.js +1 -1
  168. package/dist/emit/draw/namespace.js.map +1 -1
  169. package/dist/emit/draw/patterns/abcdPattern.js +1 -1
  170. package/dist/emit/draw/patterns/abcdPattern.js.map +1 -1
  171. package/dist/emit/draw/patterns/cypherPattern.d.ts +1 -2
  172. package/dist/emit/draw/patterns/cypherPattern.d.ts.map +1 -1
  173. package/dist/emit/draw/patterns/cypherPattern.js +1 -1
  174. package/dist/emit/draw/patterns/cypherPattern.js.map +1 -1
  175. package/dist/emit/draw/patterns/headAndShoulders.js +1 -1
  176. package/dist/emit/draw/patterns/headAndShoulders.js.map +1 -1
  177. package/dist/emit/draw/patterns/threeDrivesPattern.js +1 -1
  178. package/dist/emit/draw/patterns/threeDrivesPattern.js.map +1 -1
  179. package/dist/emit/draw/patterns/trianglePattern.d.ts +1 -1
  180. package/dist/emit/draw/patterns/trianglePattern.js +1 -1
  181. package/dist/emit/draw/patterns/trianglePattern.js.map +1 -1
  182. package/dist/emit/draw/patterns/xabcdPattern.js +1 -1
  183. package/dist/emit/draw/patterns/xabcdPattern.js.map +1 -1
  184. package/dist/emit/draw/pitchforks/pitchfan.js +1 -1
  185. package/dist/emit/draw/pitchforks/pitchfan.js.map +1 -1
  186. package/dist/emit/draw/pitchforks/pitchfork.d.ts +1 -1
  187. package/dist/emit/draw/pitchforks/pitchfork.js +2 -2
  188. package/dist/emit/draw/pitchforks/pitchfork.js.map +1 -1
  189. package/dist/emit/draw/pushDrawing.js.map +1 -1
  190. package/dist/emit/draw/subIdAllocator.d.ts +1 -1
  191. package/dist/emit/draw/subIdAllocator.js +1 -1
  192. package/dist/emit/draw/subIdAllocator.js.map +1 -1
  193. package/dist/emit/draw/table/table.d.ts +1 -1
  194. package/dist/emit/draw/table/table.js.map +1 -1
  195. package/dist/emit/emissionsQueue.js.map +1 -1
  196. package/dist/emit/hash.js.map +1 -1
  197. package/dist/emit/hline.d.ts +6 -4
  198. package/dist/emit/hline.d.ts.map +1 -1
  199. package/dist/emit/hline.js +5 -2
  200. package/dist/emit/hline.js.map +1 -1
  201. package/dist/emit/index.d.ts +2 -1
  202. package/dist/emit/index.d.ts.map +1 -1
  203. package/dist/emit/index.js +2 -1
  204. package/dist/emit/index.js.map +1 -1
  205. package/dist/emit/logEmission.js.map +1 -1
  206. package/dist/emit/paneResolver.d.ts +52 -11
  207. package/dist/emit/paneResolver.d.ts.map +1 -1
  208. package/dist/emit/paneResolver.js +69 -26
  209. package/dist/emit/paneResolver.js.map +1 -1
  210. package/dist/emit/plot.d.ts.map +1 -1
  211. package/dist/emit/plot.js +2 -1
  212. package/dist/emit/plot.js.map +1 -1
  213. package/dist/emit/runtimeError.js.map +1 -1
  214. package/dist/execution/dispose.d.ts.map +1 -1
  215. package/dist/execution/dispose.js +7 -0
  216. package/dist/execution/dispose.js.map +1 -1
  217. package/dist/execution/drain.js.map +1 -1
  218. package/dist/execution/index.js.map +1 -1
  219. package/dist/execution/onBarClose.d.ts +9 -13
  220. package/dist/execution/onBarClose.d.ts.map +1 -1
  221. package/dist/execution/onBarClose.js +28 -59
  222. package/dist/execution/onBarClose.js.map +1 -1
  223. package/dist/execution/onBarTick.d.ts +4 -10
  224. package/dist/execution/onBarTick.d.ts.map +1 -1
  225. package/dist/execution/onBarTick.js +24 -57
  226. package/dist/execution/onBarTick.js.map +1 -1
  227. package/dist/execution/onHistory.js.map +1 -1
  228. package/dist/execution/runComputeStep.d.ts +68 -0
  229. package/dist/execution/runComputeStep.d.ts.map +1 -0
  230. package/dist/execution/runComputeStep.js +96 -0
  231. package/dist/execution/runComputeStep.js.map +1 -0
  232. package/dist/execution/secondaryStream.js.map +1 -1
  233. package/dist/index.d.ts +3 -1
  234. package/dist/index.d.ts.map +1 -1
  235. package/dist/index.js +2 -1
  236. package/dist/index.js.map +1 -1
  237. package/dist/inputs/index.js.map +1 -1
  238. package/dist/inputs/resolveInputs.js.map +1 -1
  239. package/dist/internal.d.ts +12 -0
  240. package/dist/internal.d.ts.map +1 -0
  241. package/dist/internal.js +14 -0
  242. package/dist/internal.js.map +1 -0
  243. package/dist/persistentStateStore.js.map +1 -1
  244. package/dist/persistentStateStore.runtime.d.ts +18 -4
  245. package/dist/persistentStateStore.runtime.d.ts.map +1 -1
  246. package/dist/persistentStateStore.runtime.js +111 -18
  247. package/dist/persistentStateStore.runtime.js.map +1 -1
  248. package/dist/persistentStateStore.validate.d.ts +11 -1
  249. package/dist/persistentStateStore.validate.d.ts.map +1 -1
  250. package/dist/persistentStateStore.validate.js +32 -3
  251. package/dist/persistentStateStore.validate.js.map +1 -1
  252. package/dist/primitives.js.map +1 -1
  253. package/dist/request/alignHtfSeriesCache.js.map +1 -1
  254. package/dist/request/alignHtfSeriesToLtf.d.ts +2 -2
  255. package/dist/request/alignHtfSeriesToLtf.js +2 -2
  256. package/dist/request/alignHtfSeriesToLtf.js.map +1 -1
  257. package/dist/request/bucketLtfBarsByMainContainment.js.map +1 -1
  258. package/dist/request/bucketLtfBarsCache.js.map +1 -1
  259. package/dist/request/index.js.map +1 -1
  260. package/dist/request/lowerTf.js.map +1 -1
  261. package/dist/request/pushOnce.js.map +1 -1
  262. package/dist/request/requestNamespace.js.map +1 -1
  263. package/dist/request/security.js.map +1 -1
  264. package/dist/request/streamBars.js.map +1 -1
  265. package/dist/ringBuffer.d.ts +2 -2
  266. package/dist/ringBuffer.js +1 -1
  267. package/dist/ringBuffer.js.map +1 -1
  268. package/dist/runtimeContext.d.ts +65 -7
  269. package/dist/runtimeContext.d.ts.map +1 -1
  270. package/dist/runtimeContext.js.map +1 -1
  271. package/dist/seriesView.d.ts +1 -1
  272. package/dist/seriesView.js +1 -1
  273. package/dist/seriesView.js.map +1 -1
  274. package/dist/state/index.js.map +1 -1
  275. package/dist/state/lifecycle.js.map +1 -1
  276. package/dist/state/stateNamespace.d.ts.map +1 -1
  277. package/dist/state/stateNamespace.js +13 -2
  278. package/dist/state/stateNamespace.js.map +1 -1
  279. package/dist/state/stateSlot.js.map +1 -1
  280. package/dist/stateStore.d.ts +7 -4
  281. package/dist/stateStore.d.ts.map +1 -1
  282. package/dist/stateStore.js.map +1 -1
  283. package/dist/streamState.d.ts +1 -1
  284. package/dist/streamState.js +1 -1
  285. package/dist/streamState.js.map +1 -1
  286. package/dist/ta/adl.js +2 -2
  287. package/dist/ta/adl.js.map +1 -1
  288. package/dist/ta/adr.d.ts +3 -3
  289. package/dist/ta/adr.js +5 -5
  290. package/dist/ta/adr.js.map +1 -1
  291. package/dist/ta/adx.d.ts +1 -1
  292. package/dist/ta/adx.js +3 -3
  293. package/dist/ta/adx.js.map +1 -1
  294. package/dist/ta/alma.d.ts +3 -3
  295. package/dist/ta/alma.js +5 -5
  296. package/dist/ta/alma.js.map +1 -1
  297. package/dist/ta/anchoredVolumeProfile.js.map +1 -1
  298. package/dist/ta/anchoredVwap.d.ts +1 -1
  299. package/dist/ta/anchoredVwap.js +3 -3
  300. package/dist/ta/anchoredVwap.js.map +1 -1
  301. package/dist/ta/ao.js +2 -2
  302. package/dist/ta/ao.js.map +1 -1
  303. package/dist/ta/aroon.js +2 -2
  304. package/dist/ta/aroon.js.map +1 -1
  305. package/dist/ta/aroonOsc.js +2 -2
  306. package/dist/ta/aroonOsc.js.map +1 -1
  307. package/dist/ta/atr.d.ts +1 -1
  308. package/dist/ta/atr.js +3 -3
  309. package/dist/ta/atr.js.map +1 -1
  310. package/dist/ta/barssince.js +1 -1
  311. package/dist/ta/barssince.js.map +1 -1
  312. package/dist/ta/bb.d.ts +1 -1
  313. package/dist/ta/bb.js +3 -3
  314. package/dist/ta/bb.js.map +1 -1
  315. package/dist/ta/bbPercentB.js +2 -2
  316. package/dist/ta/bbPercentB.js.map +1 -1
  317. package/dist/ta/bbw.js +2 -2
  318. package/dist/ta/bbw.js.map +1 -1
  319. package/dist/ta/bop.js +2 -2
  320. package/dist/ta/bop.js.map +1 -1
  321. package/dist/ta/cci.js +2 -2
  322. package/dist/ta/cci.js.map +1 -1
  323. package/dist/ta/chaikinOsc.d.ts +1 -1
  324. package/dist/ta/chaikinOsc.js +3 -3
  325. package/dist/ta/chaikinOsc.js.map +1 -1
  326. package/dist/ta/chandeKrollStop.d.ts +1 -1
  327. package/dist/ta/chandeKrollStop.js +3 -3
  328. package/dist/ta/chandeKrollStop.js.map +1 -1
  329. package/dist/ta/chandelier.d.ts +1 -1
  330. package/dist/ta/chandelier.js +3 -3
  331. package/dist/ta/chandelier.js.map +1 -1
  332. package/dist/ta/change.js +1 -1
  333. package/dist/ta/change.js.map +1 -1
  334. package/dist/ta/chop.js +2 -2
  335. package/dist/ta/chop.js.map +1 -1
  336. package/dist/ta/cmf.js +2 -2
  337. package/dist/ta/cmf.js.map +1 -1
  338. package/dist/ta/cmo.js +2 -2
  339. package/dist/ta/cmo.js.map +1 -1
  340. package/dist/ta/connorsRsi.d.ts +1 -1
  341. package/dist/ta/connorsRsi.js +3 -3
  342. package/dist/ta/connorsRsi.js.map +1 -1
  343. package/dist/ta/coppock.js +2 -2
  344. package/dist/ta/coppock.js.map +1 -1
  345. package/dist/ta/crossover.d.ts +1 -1
  346. package/dist/ta/crossover.js +2 -2
  347. package/dist/ta/crossover.js.map +1 -1
  348. package/dist/ta/crossunder.d.ts +1 -1
  349. package/dist/ta/crossunder.js +2 -2
  350. package/dist/ta/crossunder.js.map +1 -1
  351. package/dist/ta/dema.js +2 -2
  352. package/dist/ta/dema.js.map +1 -1
  353. package/dist/ta/dmi.d.ts +1 -1
  354. package/dist/ta/dmi.js +3 -3
  355. package/dist/ta/dmi.js.map +1 -1
  356. package/dist/ta/donchian.js +2 -2
  357. package/dist/ta/donchian.js.map +1 -1
  358. package/dist/ta/dpo.js +2 -2
  359. package/dist/ta/dpo.js.map +1 -1
  360. package/dist/ta/ema.d.ts +1 -1
  361. package/dist/ta/ema.js +3 -3
  362. package/dist/ta/ema.js.map +1 -1
  363. package/dist/ta/envelope.js +2 -2
  364. package/dist/ta/envelope.js.map +1 -1
  365. package/dist/ta/eom.d.ts +1 -1
  366. package/dist/ta/eom.js +3 -3
  367. package/dist/ta/eom.js.map +1 -1
  368. package/dist/ta/fisher.js +2 -2
  369. package/dist/ta/fisher.js.map +1 -1
  370. package/dist/ta/fixedRangeVolumeProfile.js.map +1 -1
  371. package/dist/ta/highest.js +1 -1
  372. package/dist/ta/highest.js.map +1 -1
  373. package/dist/ta/historicalVolatility.d.ts +1 -1
  374. package/dist/ta/historicalVolatility.js +3 -3
  375. package/dist/ta/historicalVolatility.js.map +1 -1
  376. package/dist/ta/hma.js +2 -2
  377. package/dist/ta/hma.js.map +1 -1
  378. package/dist/ta/ichimoku.d.ts +1 -1
  379. package/dist/ta/ichimoku.js +3 -3
  380. package/dist/ta/ichimoku.js.map +1 -1
  381. package/dist/ta/index.js.map +1 -1
  382. package/dist/ta/kama.js +2 -2
  383. package/dist/ta/kama.js.map +1 -1
  384. package/dist/ta/keltner.js +2 -2
  385. package/dist/ta/keltner.js.map +1 -1
  386. package/dist/ta/klinger.js +2 -2
  387. package/dist/ta/klinger.js.map +1 -1
  388. package/dist/ta/kst.js +2 -2
  389. package/dist/ta/kst.js.map +1 -1
  390. package/dist/ta/lib/adxFromDi.js +2 -2
  391. package/dist/ta/lib/adxFromDi.js.map +1 -1
  392. package/dist/ta/lib/applyOffset.js +2 -2
  393. package/dist/ta/lib/applyOffset.js.map +1 -1
  394. package/dist/ta/lib/computeMa.js +2 -2
  395. package/dist/ta/lib/computeMa.js.map +1 -1
  396. package/dist/ta/lib/computeMaOfFloat64.js +2 -2
  397. package/dist/ta/lib/computeMaOfFloat64.js.map +1 -1
  398. package/dist/ta/lib/directionalState.js +2 -2
  399. package/dist/ta/lib/directionalState.js.map +1 -1
  400. package/dist/ta/lib/donchianMid.js +2 -2
  401. package/dist/ta/lib/donchianMid.js.map +1 -1
  402. package/dist/ta/lib/emaFloat64.js +2 -2
  403. package/dist/ta/lib/emaFloat64.js.map +1 -1
  404. package/dist/ta/lib/linearRegression.js +2 -2
  405. package/dist/ta/lib/linearRegression.js.map +1 -1
  406. package/dist/ta/lib/maTypes.js.map +1 -1
  407. package/dist/ta/lib/pearson.js +2 -2
  408. package/dist/ta/lib/pearson.js.map +1 -1
  409. package/dist/ta/lib/pickCandleSource.js +2 -2
  410. package/dist/ta/lib/pickCandleSource.js.map +1 -1
  411. package/dist/ta/lib/readSourceField.js +2 -2
  412. package/dist/ta/lib/readSourceField.js.map +1 -1
  413. package/dist/ta/lib/rollingStddev.js +2 -2
  414. package/dist/ta/lib/rollingStddev.js.map +1 -1
  415. package/dist/ta/lib/smaFloat64.js +2 -2
  416. package/dist/ta/lib/smaFloat64.js.map +1 -1
  417. package/dist/ta/lib/smmaFloat64.js +2 -2
  418. package/dist/ta/lib/smmaFloat64.js.map +1 -1
  419. package/dist/ta/lib/sourceValue.js.map +1 -1
  420. package/dist/ta/lib/trSeries.js +2 -2
  421. package/dist/ta/lib/trSeries.js.map +1 -1
  422. package/dist/ta/lib/volume-profile/bucketEdges.js.map +1 -1
  423. package/dist/ta/lib/volume-profile/bucketizeVolume.js.map +1 -1
  424. package/dist/ta/lib/volume-profile/developingSeries.js.map +1 -1
  425. package/dist/ta/lib/volume-profile/index.js.map +1 -1
  426. package/dist/ta/lib/volume-profile/intercept.js.map +1 -1
  427. package/dist/ta/lib/volume-profile/scaffold.js.map +1 -1
  428. package/dist/ta/lib/volume-profile/tooHeavy.js.map +1 -1
  429. package/dist/ta/lib/volume-profile/types.js.map +1 -1
  430. package/dist/ta/lib/volume-profile/valueArea.js.map +1 -1
  431. package/dist/ta/lib/volume-profile/volumeProfileShared.js.map +1 -1
  432. package/dist/ta/lib/vwmaFloat64.js +2 -2
  433. package/dist/ta/lib/vwmaFloat64.js.map +1 -1
  434. package/dist/ta/lib/wilderDirectional.js +2 -2
  435. package/dist/ta/lib/wilderDirectional.js.map +1 -1
  436. package/dist/ta/lib/wilderSmoothing.js +2 -2
  437. package/dist/ta/lib/wilderSmoothing.js.map +1 -1
  438. package/dist/ta/lib/wmaFloat64.js +2 -2
  439. package/dist/ta/lib/wmaFloat64.js.map +1 -1
  440. package/dist/ta/lowest.js +1 -1
  441. package/dist/ta/lowest.js.map +1 -1
  442. package/dist/ta/lsma.js +2 -2
  443. package/dist/ta/lsma.js.map +1 -1
  444. package/dist/ta/maRibbon.js +2 -2
  445. package/dist/ta/maRibbon.js.map +1 -1
  446. package/dist/ta/macd.d.ts +1 -1
  447. package/dist/ta/macd.js +4 -4
  448. package/dist/ta/macd.js.map +1 -1
  449. package/dist/ta/massIndex.d.ts +1 -1
  450. package/dist/ta/massIndex.js +3 -3
  451. package/dist/ta/massIndex.js.map +1 -1
  452. package/dist/ta/mcginley.js +2 -2
  453. package/dist/ta/mcginley.js.map +1 -1
  454. package/dist/ta/median.js +2 -2
  455. package/dist/ta/median.js.map +1 -1
  456. package/dist/ta/mfi.d.ts +1 -1
  457. package/dist/ta/mfi.js +3 -3
  458. package/dist/ta/mfi.js.map +1 -1
  459. package/dist/ta/momentum.js +2 -2
  460. package/dist/ta/momentum.js.map +1 -1
  461. package/dist/ta/netVolume.d.ts +1 -1
  462. package/dist/ta/netVolume.js +3 -3
  463. package/dist/ta/netVolume.js.map +1 -1
  464. package/dist/ta/nvi.d.ts +1 -1
  465. package/dist/ta/nvi.js +3 -3
  466. package/dist/ta/nvi.js.map +1 -1
  467. package/dist/ta/nz.js +1 -1
  468. package/dist/ta/nz.js.map +1 -1
  469. package/dist/ta/obv.js +2 -2
  470. package/dist/ta/obv.js.map +1 -1
  471. package/dist/ta/persistence.js.map +1 -1
  472. package/dist/ta/pivotsHighLow.js +2 -2
  473. package/dist/ta/pivotsHighLow.js.map +1 -1
  474. package/dist/ta/pivotsStandard.d.ts +1 -1
  475. package/dist/ta/pivotsStandard.js +3 -3
  476. package/dist/ta/pivotsStandard.js.map +1 -1
  477. package/dist/ta/pmo.js +2 -2
  478. package/dist/ta/pmo.js.map +1 -1
  479. package/dist/ta/ppo.d.ts +1 -1
  480. package/dist/ta/ppo.js +3 -3
  481. package/dist/ta/ppo.js.map +1 -1
  482. package/dist/ta/psar.js +2 -2
  483. package/dist/ta/psar.js.map +1 -1
  484. package/dist/ta/pvi.d.ts +1 -1
  485. package/dist/ta/pvi.js +3 -3
  486. package/dist/ta/pvi.js.map +1 -1
  487. package/dist/ta/pvo.d.ts +1 -1
  488. package/dist/ta/pvo.js +3 -3
  489. package/dist/ta/pvo.js.map +1 -1
  490. package/dist/ta/pvt.d.ts +1 -1
  491. package/dist/ta/pvt.js +3 -3
  492. package/dist/ta/pvt.js.map +1 -1
  493. package/dist/ta/registry.js.map +1 -1
  494. package/dist/ta/roc.js +2 -2
  495. package/dist/ta/roc.js.map +1 -1
  496. package/dist/ta/rsi.d.ts +1 -1
  497. package/dist/ta/rsi.js +3 -3
  498. package/dist/ta/rsi.js.map +1 -1
  499. package/dist/ta/rvgi.js +2 -2
  500. package/dist/ta/rvgi.js.map +1 -1
  501. package/dist/ta/rvi.d.ts +1 -1
  502. package/dist/ta/rvi.js +3 -3
  503. package/dist/ta/rvi.js.map +1 -1
  504. package/dist/ta/sessionVolumeProfile.js.map +1 -1
  505. package/dist/ta/sma.d.ts +1 -1
  506. package/dist/ta/sma.js +3 -3
  507. package/dist/ta/sma.js.map +1 -1
  508. package/dist/ta/smi.js +2 -2
  509. package/dist/ta/smi.js.map +1 -1
  510. package/dist/ta/smma.js +2 -2
  511. package/dist/ta/smma.js.map +1 -1
  512. package/dist/ta/stdev.d.ts +1 -1
  513. package/dist/ta/stdev.js +3 -3
  514. package/dist/ta/stdev.js.map +1 -1
  515. package/dist/ta/stoch.js +2 -2
  516. package/dist/ta/stoch.js.map +1 -1
  517. package/dist/ta/stochRsi.js +2 -2
  518. package/dist/ta/stochRsi.js.map +1 -1
  519. package/dist/ta/supertrend.d.ts +1 -1
  520. package/dist/ta/supertrend.js +3 -3
  521. package/dist/ta/supertrend.js.map +1 -1
  522. package/dist/ta/tema.js +2 -2
  523. package/dist/ta/tema.js.map +1 -1
  524. package/dist/ta/trendStrengthIndex.d.ts +2 -2
  525. package/dist/ta/trendStrengthIndex.js +4 -4
  526. package/dist/ta/trendStrengthIndex.js.map +1 -1
  527. package/dist/ta/trix.d.ts +1 -1
  528. package/dist/ta/trix.js +3 -3
  529. package/dist/ta/trix.js.map +1 -1
  530. package/dist/ta/tsi.js +2 -2
  531. package/dist/ta/tsi.js.map +1 -1
  532. package/dist/ta/ulcerIndex.js +2 -2
  533. package/dist/ta/ulcerIndex.js.map +1 -1
  534. package/dist/ta/ultimateOsc.js +2 -2
  535. package/dist/ta/ultimateOsc.js.map +1 -1
  536. package/dist/ta/valuewhen.js +1 -1
  537. package/dist/ta/valuewhen.js.map +1 -1
  538. package/dist/ta/visibleRangeVolumeProfile.d.ts +2 -2
  539. package/dist/ta/visibleRangeVolumeProfile.js +2 -2
  540. package/dist/ta/visibleRangeVolumeProfile.js.map +1 -1
  541. package/dist/ta/vol.js +2 -2
  542. package/dist/ta/vol.js.map +1 -1
  543. package/dist/ta/volatilityStop.d.ts +1 -1
  544. package/dist/ta/volatilityStop.js +3 -3
  545. package/dist/ta/volatilityStop.js.map +1 -1
  546. package/dist/ta/vortex.d.ts +1 -1
  547. package/dist/ta/vortex.js +3 -3
  548. package/dist/ta/vortex.js.map +1 -1
  549. package/dist/ta/vwap.d.ts +3 -3
  550. package/dist/ta/vwap.js +5 -5
  551. package/dist/ta/vwap.js.map +1 -1
  552. package/dist/ta/vwma.js +2 -2
  553. package/dist/ta/vwma.js.map +1 -1
  554. package/dist/ta/williamsFractal.js +2 -2
  555. package/dist/ta/williamsFractal.js.map +1 -1
  556. package/dist/ta/williamsR.js +2 -2
  557. package/dist/ta/williamsR.js.map +1 -1
  558. package/dist/ta/wma.js +2 -2
  559. package/dist/ta/wma.js.map +1 -1
  560. package/dist/ta/zigZag.js +2 -2
  561. package/dist/ta/zigZag.js.map +1 -1
  562. package/dist/views/barstateView.js.map +1 -1
  563. package/dist/views/index.js.map +1 -1
  564. package/dist/views/refreshRuntimeViews.js.map +1 -1
  565. package/dist/views/symInfoView.js.map +1 -1
  566. package/dist/views/timeframeView.js.map +1 -1
  567. package/package.json +7 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DepOutputStore.js","sourceRoot":"","sources":["../../src/dep/DepOutputStore.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAsElD,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,SAAS,QAAQ,CAAC,UAAkB,EAAE,KAAa;IAC/C,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,KAAK,EAAE,CAAC;AACnD,CAAC;AAOD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAGpC;IACG,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC9C,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACpC,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACpC,MAAM,GAAG,GAAG,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YACxD,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,SAAS;YAC/B,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,CAAS,MAAM,CAAC,EAAE,CAAC,CAAC;QACvE,CAAC;IACL,CAAC;IAED,SAAS,MAAM,CAAC,UAAkB,EAAE,KAAa;QAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;QACvD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,IAAI,KAAK,mBAAmB,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK;YACzB,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,CAAC,UAAU,EAAE,KAAK;YAClB,OAAO,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC;QAC1C,CAAC;QACD,QAAQ;YACJ,+DAA+D;QACnE,CAAC;QACD,OAAO;YACH,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;gBACnC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACzB,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;KACJ,CAAC,CAAC;AACP,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 { Series } from \"@invinite-org/chartlang-core\";\n\nimport { Float64RingBuffer } from \"../ringBuffer.js\";\nimport { makeSeriesView } from \"../seriesView.js\";\n\n/**\n * One producer's contribution to a {@link DepOutputStore}. `producerId`\n * is the dep's `localId` (private dep) or the sibling's `exportName`\n * (drawn export). `outputs` mirrors the producer manifest's titled\n * `plot(value, { title })` declarations.\n *\n * @since 0.7\n * @stable\n * @example\n * const decl: DepOutputDeclaration = {\n * producerId: \"fastTrend\",\n * outputs: [{ title: \"line\" }],\n * };\n * void decl;\n */\nexport type DepOutputDeclaration = Readonly<{\n readonly producerId: string;\n readonly outputs: ReadonlyArray<{ readonly title: string }>;\n}>;\n\n/**\n * Per-bar titled-output buffer shared by the primary script and every\n * sibling drawn export within a `CompiledScriptBundle`. Each\n * `(producerId, title)` pair owns a `Float64RingBuffer`; the runtime\n * appends to it once per bar via {@link applyDepEmissionPolicy}, and\n * consumers read it through `__chartlang_depOutput`.\n *\n * The store pre-allocates a buffer for every declared output of every\n * dep + sibling at mount time. Buffer capacity is sized for the\n * consumer's `manifest.maxLookback + 1`, so `series[n]` lookback works\n * up to the script's declared horizon.\n *\n * @since 0.7\n * @stable\n * @example\n * // import { createDepOutputStore } from \"@invinite-org/chartlang-runtime\";\n * // const store = createDepOutputStore({\n * // producers: [{ producerId: \"fast\", outputs: [{ title: \"line\" }] }],\n * // capacity: 32,\n * // });\n */\nexport type DepOutputStore = Readonly<{\n /**\n * Append `value` to the producer's titled buffer for the current\n * bar. Throws when `(producerId, title)` is not declared. Called by\n * {@link applyDepEmissionPolicy} after each dep/sibling's compute.\n */\n push(producerId: string, title: string, value: number): void;\n /**\n * Return the producer's stable `Series<number>` view for `title`.\n * Throws when `(producerId, title)` is not declared. Called by the\n * compiler-emitted `__chartlang_depOutput` helper during the\n * consumer's compute.\n */\n read(producerId: string, title: string): Series<number>;\n /**\n * Called by the executor before any dep/sibling/primary compute on\n * a new bar. Reserved for per-bar reset state; the current\n * implementation has no per-bar bookkeeping but the hook stays\n * stable so Task 5 can extend it.\n */\n beginBar(): void;\n /**\n * Drop every entry. Called by `dispose`.\n */\n dispose(): void;\n}>;\n\nconst ENTRY_KEY_SEP = \"\u0000\";\n\nfunction entryKey(producerId: string, title: string): string {\n return `${producerId}${ENTRY_KEY_SEP}${title}`;\n}\n\ntype StoreEntry = Readonly<{\n readonly buffer: Float64RingBuffer;\n readonly view: Series<number>;\n}>;\n\n/**\n * Construct a fresh {@link DepOutputStore}. Pre-allocates one buffer +\n * one `Series<number>` Proxy per declared `(producerId, title)`. The\n * proxy identity is stable for the store's lifetime so a\n * `const fast = baseTrend.output(\"line\")` at the top of the consumer's\n * compute keeps seeing the live values.\n *\n * @since 0.7\n * @stable\n * @example\n * // const store = createDepOutputStore({\n * // producers: [{ producerId: \"fast\", outputs: [{ title: \"line\" }] }],\n * // capacity: 100,\n * // });\n * // store.beginBar();\n * // store.push(\"fast\", \"line\", 42);\n * // store.read(\"fast\", \"line\").current; // 42\n */\nexport function createDepOutputStore(args: {\n readonly producers: ReadonlyArray<DepOutputDeclaration>;\n readonly capacity: number;\n}): DepOutputStore {\n const capacity = Math.max(1, args.capacity);\n const entries = new Map<string, StoreEntry>();\n for (const producer of args.producers) {\n for (const output of producer.outputs) {\n const key = entryKey(producer.producerId, output.title);\n if (entries.has(key)) continue;\n const buffer = new Float64RingBuffer(capacity);\n entries.set(key, { buffer, view: makeSeriesView<number>(buffer) });\n }\n }\n\n function lookup(producerId: string, title: string): StoreEntry {\n const entry = entries.get(entryKey(producerId, title));\n if (entry === undefined) {\n throw new Error(`dep output \"${producerId}.${title}\" is not declared`);\n }\n return entry;\n }\n\n return Object.freeze({\n push(producerId, title, value): void {\n lookup(producerId, title).buffer.append(value);\n },\n read(producerId, title): Series<number> {\n return lookup(producerId, title).view;\n },\n beginBar(): void {\n // Reserved hook — Task 5 will use it for snapshot bookkeeping.\n },\n dispose(): void {\n for (const entry of entries.values()) {\n entry.buffer.reset();\n }\n entries.clear();\n },\n });\n}\n"]}
@@ -0,0 +1,146 @@
1
+ import type { Capabilities } from "@invinite-org/chartlang-adapter-kit";
2
+ import type { Bar, CompiledScriptObject } from "@invinite-org/chartlang-core";
3
+ import type { RunnerState } from "../createScriptRunner.js";
4
+ import type { StreamState } from "../streamState.js";
5
+ import type { EventKind } from "../views/index.js";
6
+ import type { DepOutputStore } from "./DepOutputStore.js";
7
+ /**
8
+ * One mounted private dep — a `const X = defineIndicator(...)` binding
9
+ * that another script in the same compiled bundle references via
10
+ * `X.output("title")`. Owns its own `RunnerState`; shares the parent's
11
+ * `mainStream` + `secondaryStreams`. Plot emissions are dropped from
12
+ * the parent's queue and captured into the shared
13
+ * {@link DepOutputStore}.
14
+ *
15
+ * @since 0.7
16
+ * @stable
17
+ * @example
18
+ * // const dep = createDepRunner({ compiled, localId: "fast", ... });
19
+ * // await runDepStep(dep, parent, rawBar, "close", false);
20
+ * const x: number = 1;
21
+ * void x;
22
+ */
23
+ export type DepRunner = Readonly<{
24
+ readonly kind: "dep";
25
+ readonly localId: string;
26
+ readonly slotIdPrefix: string;
27
+ readonly declaredOutputs: ReadonlyArray<string>;
28
+ readonly state: RunnerState;
29
+ }>;
30
+ /**
31
+ * One mounted drawn sibling — a `export const X = defineIndicator(...)`
32
+ * binding whose emissions ARE forwarded to the parent's queue, with
33
+ * slot ids prefixed by `export:<exportName>/`. Siblings can also expose
34
+ * outputs consumed by the primary or by other siblings.
35
+ *
36
+ * @since 0.7
37
+ * @stable
38
+ * @example
39
+ * // const sib = createSiblingRunner({ compiled, exportName: "slow", ... });
40
+ * // await runSiblingStep(sib, parent, rawBar, "close", false);
41
+ * const x: number = 1;
42
+ * void x;
43
+ */
44
+ export type SiblingRunner = Readonly<{
45
+ readonly kind: "sibling";
46
+ readonly exportName: string;
47
+ readonly slotIdPrefix: string;
48
+ readonly declaredOutputs: ReadonlyArray<string>;
49
+ readonly state: RunnerState;
50
+ }>;
51
+ /**
52
+ * Constructor arguments for {@link createDepRunner} /
53
+ * {@link createSiblingRunner}.
54
+ *
55
+ * `mainStream` + `secondaryStreams` are SHARED with the parent runner
56
+ * (same OHLCV history); `depOutputStore` is also shared so every
57
+ * sibling + dep + primary read from the same store. `inputOverrides`
58
+ * is the merged effective-inputs record the compiler attached to the
59
+ * dep's `DependencyDeclaration`.
60
+ *
61
+ * @since 0.7
62
+ * @stable
63
+ * @example
64
+ * // const args: CreateDepRunnerArgs = {
65
+ * // compiled, localId: "x",
66
+ * // parentCapabilities, mainStream, secondaryStreams,
67
+ * // depOutputStore, inputOverrides: {}, now: Date.now,
68
+ * // };
69
+ * const x: number = 1;
70
+ * void x;
71
+ */
72
+ export type CreateDepRunnerArgs = Readonly<{
73
+ readonly compiled: CompiledScriptObject;
74
+ readonly parentCapabilities: Capabilities;
75
+ readonly mainStream: StreamState;
76
+ readonly secondaryStreams: Map<string, StreamState>;
77
+ readonly depOutputStore: DepOutputStore;
78
+ readonly inputOverrides: Readonly<Record<string, unknown>>;
79
+ readonly now: () => number;
80
+ }>;
81
+ /**
82
+ * Construct a {@link DepRunner} for one private dep entry of a
83
+ * `CompiledScriptBundle`. The runner shares the parent's `mainStream`
84
+ * + `secondaryStreams`, owns a fresh `inMemoryStateStore`, and feeds
85
+ * its plot emissions into the shared `DepOutputStore`.
86
+ *
87
+ * @since 0.7
88
+ * @stable
89
+ * @example
90
+ * // const dep = createDepRunner({ compiled, localId: "fast",
91
+ * // parentCapabilities, mainStream, secondaryStreams,
92
+ * // depOutputStore, inputOverrides: { length: 20 }, now: Date.now });
93
+ * const x: number = 1;
94
+ * void x;
95
+ */
96
+ export declare function createDepRunner(args: CreateDepRunnerArgs & {
97
+ readonly localId: string;
98
+ }): DepRunner;
99
+ /**
100
+ * Construct a {@link SiblingRunner} for one drawn named-export entry of
101
+ * a `CompiledScriptBundle`. Shares streams + store with the parent;
102
+ * emissions forward to the parent with `export:<exportName>/` slot-id
103
+ * prefixes.
104
+ *
105
+ * @since 0.7
106
+ * @stable
107
+ * @example
108
+ * // const sib = createSiblingRunner({ compiled, exportName: "slow", ... });
109
+ * const x: number = 1;
110
+ * void x;
111
+ */
112
+ export declare function createSiblingRunner(args: CreateDepRunnerArgs & {
113
+ readonly exportName: string;
114
+ }): SiblingRunner;
115
+ /**
116
+ * Drive one bar of execution for a {@link DepRunner}. Runs the dep's
117
+ * `compute`, captures its titled-plot output into the shared
118
+ * `DepOutputStore` via {@link applyDepEmissionPolicy}, namespaces
119
+ * diagnostics with `dep:<localId>/`, and on halt sets
120
+ * `parentState.depErroredThisBar = true` so the parent's primary
121
+ * step drops its emissions for the bar (per task spec §6).
122
+ *
123
+ * @since 0.7
124
+ * @stable
125
+ * @example
126
+ * // await runDepStep(dep, parent, rawBar, "close", false);
127
+ * const x: number = 1;
128
+ * void x;
129
+ */
130
+ export declare function runDepStep(dep: DepRunner, parentState: RunnerState, rawBar: Bar, eventKind: EventKind, isTick: boolean): Promise<void>;
131
+ /**
132
+ * Drive one bar of execution for a {@link SiblingRunner}. Same shape
133
+ * as {@link runDepStep} but the sibling's emissions are forwarded to
134
+ * the parent with `export:<exportName>/` slot-id prefixes, and a
135
+ * sibling halt does NOT clear the primary's emissions — only the
136
+ * sibling's own bar emissions are lost.
137
+ *
138
+ * @since 0.7
139
+ * @stable
140
+ * @example
141
+ * // await runSiblingStep(sibling, parent, rawBar, "close", false);
142
+ * const x: number = 1;
143
+ * void x;
144
+ */
145
+ export declare function runSiblingStep(sibling: SiblingRunner, parentState: RunnerState, rawBar: Bar, eventKind: EventKind, isTick: boolean): Promise<void>;
146
+ //# sourceMappingURL=DepRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DepRunner.d.ts","sourceRoot":"","sources":["../../src/dep/DepRunner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,KAAK,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAO5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAO1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,Q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AI,EAAE,mBAAmB,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC5D,aAAa,CASf;AAuCD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAC5B,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,GAAG,EACX,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,OAAO,GAChB,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAChC,OAAO,EAAE,aAAa,EACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,GAAG,EACX,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,OAAO,GAChB,OAAO,CAAC,IAAI,CAAC,CAyBf"}
@@ -0,0 +1,243 @@
1
+ // Copyright (c) 2026 Invinite. Licensed under the MIT License.
2
+ // See the LICENSE file in the repo root for full license text.
3
+ import { pushDiagnostic } from "../emit/emissionsQueue.js";
4
+ import { resolveDefaultPane, resolveScriptPane } from "../emit/paneResolver.js";
5
+ import { resetBarEmissions, runComputeBody } from "../execution/runComputeStep.js";
6
+ import { resolveInputs } from "../inputs/resolveInputs.js";
7
+ import { inMemoryStateStore } from "../stateStore.js";
8
+ import { createRuntimeViews } from "../views/index.js";
9
+ import { applyDepEmissionPolicy, } from "./emissionFilter.js";
10
+ function freshEmissions(barIndex) {
11
+ return {
12
+ plots: [],
13
+ drawings: [],
14
+ alerts: [],
15
+ alertConditions: [],
16
+ logs: [],
17
+ diagnostics: [],
18
+ fromBar: barIndex,
19
+ toBar: barIndex,
20
+ };
21
+ }
22
+ function buildSubRunnerState(args, slotIdPrefix, isDep) {
23
+ const stateStore = inMemoryStateStore();
24
+ const emissions = freshEmissions(0);
25
+ const alertConditions = new Map((args.compiled.manifest.alertConditions ?? []).map((c) => [c.id, c]));
26
+ const state = {
27
+ manifest: args.compiled.manifest,
28
+ compute: args.compiled.compute,
29
+ capabilities: args.parentCapabilities,
30
+ stateStore,
31
+ persistenceIntervalMs: Number.POSITIVE_INFINITY,
32
+ now: args.now,
33
+ mainStream: args.mainStream,
34
+ runtimeContext: {
35
+ stream: args.mainStream,
36
+ stateStore,
37
+ lastPersistTime: 0,
38
+ capabilities: args.parentCapabilities,
39
+ emissions,
40
+ barIndex: () => state.barIndex,
41
+ isTick: false,
42
+ drawingSlots: new Map(),
43
+ drawingSubIdCounters: new Map(),
44
+ drawingBucketCounters: {
45
+ lines: 0,
46
+ labels: 0,
47
+ boxes: 0,
48
+ polylines: 0,
49
+ other: 0,
50
+ },
51
+ scriptMaxDrawings: args.compiled.manifest.maxDrawings ?? null,
52
+ stateSlots: new Map(),
53
+ secondaryStreams: args.secondaryStreams,
54
+ requestSecurityBars: new Map(),
55
+ requestSecurityAlignments: new Map(),
56
+ requestSecurityAscendingBars: new Map(),
57
+ requestLowerTfViews: new Map(),
58
+ diagnosedRequestKeys: new Set(),
59
+ alertConditions,
60
+ diagnosedAlertConditionKeys: new Set(),
61
+ logBudget: 0,
62
+ logBudgetExceededDiagnosed: false,
63
+ resolvedInputs: Object.freeze({}),
64
+ defaultPane: resolveDefaultPane(args.compiled.manifest),
65
+ scriptPane: resolveScriptPane(args.compiled.manifest),
66
+ // Overrides target the primary script's slots only in v1;
67
+ // dep-output plots are not host-overridable.
68
+ plotOverrides: Object.freeze({}),
69
+ diagnosedInputKeys: new Set(),
70
+ views: createRuntimeViews(),
71
+ slotIdPrefix,
72
+ isDep,
73
+ depOutputStore: args.depOutputStore,
74
+ },
75
+ emissions,
76
+ depRunners: [],
77
+ siblingRunners: [],
78
+ depOutputStore: args.depOutputStore,
79
+ depErroredThisBar: false,
80
+ barIndex: 0,
81
+ };
82
+ state.runtimeContext.resolvedInputs = resolveInputs(args.compiled.manifest, args.inputOverrides, state.runtimeContext);
83
+ return state;
84
+ }
85
+ function declaredOutputTitles(compiled) {
86
+ return (compiled.manifest.outputs ?? []).map((o) => o.title);
87
+ }
88
+ /**
89
+ * Construct a {@link DepRunner} for one private dep entry of a
90
+ * `CompiledScriptBundle`. The runner shares the parent's `mainStream`
91
+ * + `secondaryStreams`, owns a fresh `inMemoryStateStore`, and feeds
92
+ * its plot emissions into the shared `DepOutputStore`.
93
+ *
94
+ * @since 0.7
95
+ * @stable
96
+ * @example
97
+ * // const dep = createDepRunner({ compiled, localId: "fast",
98
+ * // parentCapabilities, mainStream, secondaryStreams,
99
+ * // depOutputStore, inputOverrides: { length: 20 }, now: Date.now });
100
+ * const x: number = 1;
101
+ * void x;
102
+ */
103
+ export function createDepRunner(args) {
104
+ const slotIdPrefix = `dep:${args.localId}/`;
105
+ return Object.freeze({
106
+ kind: "dep",
107
+ localId: args.localId,
108
+ slotIdPrefix,
109
+ declaredOutputs: declaredOutputTitles(args.compiled),
110
+ state: buildSubRunnerState(args, slotIdPrefix, true),
111
+ });
112
+ }
113
+ /**
114
+ * Construct a {@link SiblingRunner} for one drawn named-export entry of
115
+ * a `CompiledScriptBundle`. Shares streams + store with the parent;
116
+ * emissions forward to the parent with `export:<exportName>/` slot-id
117
+ * prefixes.
118
+ *
119
+ * @since 0.7
120
+ * @stable
121
+ * @example
122
+ * // const sib = createSiblingRunner({ compiled, exportName: "slow", ... });
123
+ * const x: number = 1;
124
+ * void x;
125
+ */
126
+ export function createSiblingRunner(args) {
127
+ const slotIdPrefix = `export:${args.exportName}/`;
128
+ return Object.freeze({
129
+ kind: "sibling",
130
+ exportName: args.exportName,
131
+ slotIdPrefix,
132
+ declaredOutputs: declaredOutputTitles(args.compiled),
133
+ state: buildSubRunnerState(args, slotIdPrefix, false),
134
+ });
135
+ }
136
+ function depRunnerLike(dep) {
137
+ return {
138
+ kind: "dep",
139
+ localId: dep.localId,
140
+ slotIdPrefix: dep.slotIdPrefix,
141
+ declaredOutputs: dep.declaredOutputs,
142
+ emissions: dep.state.emissions,
143
+ };
144
+ }
145
+ function siblingRunnerLike(sib) {
146
+ return {
147
+ kind: "sibling",
148
+ exportName: sib.exportName,
149
+ slotIdPrefix: sib.slotIdPrefix,
150
+ declaredOutputs: sib.declaredOutputs,
151
+ emissions: sib.state.emissions,
152
+ };
153
+ }
154
+ async function executeSubStep(state, eventKind, isTick) {
155
+ resetBarEmissions(state);
156
+ try {
157
+ const outcome = await runComputeBody({ state, eventKind, isTick });
158
+ return outcome.kind === "halt"
159
+ ? { halted: true, message: outcome.message }
160
+ : { halted: false, message: "" };
161
+ }
162
+ catch (err) {
163
+ const message = err instanceof Error ? err.message : String(err);
164
+ return { halted: true, message };
165
+ }
166
+ }
167
+ /**
168
+ * Drive one bar of execution for a {@link DepRunner}. Runs the dep's
169
+ * `compute`, captures its titled-plot output into the shared
170
+ * `DepOutputStore` via {@link applyDepEmissionPolicy}, namespaces
171
+ * diagnostics with `dep:<localId>/`, and on halt sets
172
+ * `parentState.depErroredThisBar = true` so the parent's primary
173
+ * step drops its emissions for the bar (per task spec §6).
174
+ *
175
+ * @since 0.7
176
+ * @stable
177
+ * @example
178
+ * // await runDepStep(dep, parent, rawBar, "close", false);
179
+ * const x: number = 1;
180
+ * void x;
181
+ */
182
+ export async function runDepStep(dep, parentState, rawBar, eventKind, isTick) {
183
+ if (parentState.depOutputStore === null) {
184
+ throw new Error("runDepStep called on a runner with no dep output store");
185
+ }
186
+ void rawBar;
187
+ const result = await executeSubStep(dep.state, eventKind, isTick);
188
+ if (result.halted) {
189
+ // Use an empty slot id so the filter's prefix call produces the
190
+ // runner's slotIdPrefix (`dep:<localId>/`) — preserves the
191
+ // distinguished slotId in the parent's diagnostic queue.
192
+ pushDiagnostic(dep.state.emissions, {
193
+ kind: "diagnostic",
194
+ severity: "error",
195
+ code: "dep-error",
196
+ message: result.message,
197
+ slotId: "",
198
+ bar: dep.state.barIndex,
199
+ });
200
+ parentState.depErroredThisBar = true;
201
+ }
202
+ if (!isTick) {
203
+ dep.state.barIndex += 1;
204
+ }
205
+ applyDepEmissionPolicy(depRunnerLike(dep), parentState.emissions, parentState.depOutputStore);
206
+ }
207
+ /**
208
+ * Drive one bar of execution for a {@link SiblingRunner}. Same shape
209
+ * as {@link runDepStep} but the sibling's emissions are forwarded to
210
+ * the parent with `export:<exportName>/` slot-id prefixes, and a
211
+ * sibling halt does NOT clear the primary's emissions — only the
212
+ * sibling's own bar emissions are lost.
213
+ *
214
+ * @since 0.7
215
+ * @stable
216
+ * @example
217
+ * // await runSiblingStep(sibling, parent, rawBar, "close", false);
218
+ * const x: number = 1;
219
+ * void x;
220
+ */
221
+ export async function runSiblingStep(sibling, parentState, rawBar, eventKind, isTick) {
222
+ if (parentState.depOutputStore === null) {
223
+ throw new Error("runSiblingStep called on a runner with no dep output store");
224
+ }
225
+ void rawBar;
226
+ const result = await executeSubStep(sibling.state, eventKind, isTick);
227
+ if (result.halted) {
228
+ pushDiagnostic(sibling.state.emissions, {
229
+ kind: "diagnostic",
230
+ severity: "error",
231
+ code: "dep-error",
232
+ message: result.message,
233
+ slotId: "",
234
+ bar: sibling.state.barIndex,
235
+ });
236
+ // sibling halt does NOT set parentState.depErroredThisBar.
237
+ }
238
+ if (!isTick) {
239
+ sibling.state.barIndex += 1;
240
+ }
241
+ applyDepEmissionPolicy(siblingRunnerLike(sibling), parentState.emissions, parentState.depOutputStore);
242
+ }
243
+ //# sourceMappingURL=DepRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DepRunner.js","sourceRoot":"","sources":["../../src/dep/DepRunner.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAM/D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,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C;QAChB,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE;YACpC,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,MAAM,EAAE,EAAE;YACV,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ;SAC9B,CAAC,CAAC;QACH,2DAA2D;IAC/D,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC;IAChC,CAAC;IACD,sBAAsB,CAClB,iBAAiB,CAAC,OAAO,CAAC,EAC1B,WAAW,CAAC,SAAS,EACrB,WAAW,CAAC,cAAc,CAC7B,CAAC;AACN,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 { Capabilities } from \"@invinite-org/chartlang-adapter-kit\";\nimport type { Bar, CompiledScriptObject } from \"@invinite-org/chartlang-core\";\n\nimport type { RunnerState } from \"../createScriptRunner.js\";\nimport { pushDiagnostic } from \"../emit/emissionsQueue.js\";\nimport { resolveDefaultPane, resolveScriptPane } from \"../emit/paneResolver.js\";\nimport { resetBarEmissions, runComputeBody } from \"../execution/runComputeStep.js\";\nimport { resolveInputs } from \"../inputs/resolveInputs.js\";\nimport type { MutableRunnerEmissions } from \"../runtimeContext.js\";\nimport { inMemoryStateStore } from \"../stateStore.js\";\nimport type { StreamState } from \"../streamState.js\";\nimport { createRuntimeViews } from \"../views/index.js\";\nimport type { EventKind } from \"../views/index.js\";\nimport type { DepOutputStore } from \"./DepOutputStore.js\";\nimport {\n type DepRunnerLike,\n type SiblingRunnerLike,\n applyDepEmissionPolicy,\n} from \"./emissionFilter.js\";\n\n/**\n * One mounted private dep — a `const X = defineIndicator(...)` binding\n * that another script in the same compiled bundle references via\n * `X.output(\"title\")`. Owns its own `RunnerState`; shares the parent's\n * `mainStream` + `secondaryStreams`. Plot emissions are dropped from\n * the parent's queue and captured into the shared\n * {@link DepOutputStore}.\n *\n * @since 0.7\n * @stable\n * @example\n * // const dep = createDepRunner({ compiled, localId: \"fast\", ... });\n * // await runDepStep(dep, parent, rawBar, \"close\", false);\n * const x: number = 1;\n * void x;\n */\nexport type DepRunner = Readonly<{\n readonly kind: \"dep\";\n readonly localId: string;\n readonly slotIdPrefix: string;\n readonly declaredOutputs: ReadonlyArray<string>;\n readonly state: RunnerState;\n}>;\n\n/**\n * One mounted drawn sibling — a `export const X = defineIndicator(...)`\n * binding whose emissions ARE forwarded to the parent's queue, with\n * slot ids prefixed by `export:<exportName>/`. Siblings can also expose\n * outputs consumed by the primary or by other siblings.\n *\n * @since 0.7\n * @stable\n * @example\n * // const sib = createSiblingRunner({ compiled, exportName: \"slow\", ... });\n * // await runSiblingStep(sib, parent, rawBar, \"close\", false);\n * const x: number = 1;\n * void x;\n */\nexport type SiblingRunner = Readonly<{\n readonly kind: \"sibling\";\n readonly exportName: string;\n readonly slotIdPrefix: string;\n readonly declaredOutputs: ReadonlyArray<string>;\n readonly state: RunnerState;\n}>;\n\n/**\n * Constructor arguments for {@link createDepRunner} /\n * {@link createSiblingRunner}.\n *\n * `mainStream` + `secondaryStreams` are SHARED with the parent runner\n * (same OHLCV history); `depOutputStore` is also shared so every\n * sibling + dep + primary read from the same store. `inputOverrides`\n * is the merged effective-inputs record the compiler attached to the\n * dep's `DependencyDeclaration`.\n *\n * @since 0.7\n * @stable\n * @example\n * // const args: CreateDepRunnerArgs = {\n * // compiled, localId: \"x\",\n * // parentCapabilities, mainStream, secondaryStreams,\n * // depOutputStore, inputOverrides: {}, now: Date.now,\n * // };\n * const x: number = 1;\n * void x;\n */\nexport type CreateDepRunnerArgs = Readonly<{\n readonly compiled: CompiledScriptObject;\n readonly parentCapabilities: Capabilities;\n readonly mainStream: StreamState;\n readonly secondaryStreams: Map<string, StreamState>;\n readonly depOutputStore: DepOutputStore;\n readonly inputOverrides: Readonly<Record<string, unknown>>;\n readonly now: () => number;\n}>;\n\nfunction freshEmissions(barIndex: number): MutableRunnerEmissions {\n return {\n plots: [],\n drawings: [],\n alerts: [],\n alertConditions: [],\n logs: [],\n diagnostics: [],\n fromBar: barIndex,\n toBar: barIndex,\n };\n}\n\nfunction buildSubRunnerState(\n args: CreateDepRunnerArgs,\n slotIdPrefix: string,\n isDep: boolean,\n): RunnerState {\n const stateStore = inMemoryStateStore();\n const emissions = freshEmissions(0);\n const alertConditions = new Map(\n (args.compiled.manifest.alertConditions ?? []).map((c) => [c.id, c]),\n );\n const state: RunnerState = {\n manifest: args.compiled.manifest,\n compute: args.compiled.compute,\n capabilities: args.parentCapabilities,\n stateStore,\n persistenceIntervalMs: Number.POSITIVE_INFINITY,\n now: args.now,\n mainStream: args.mainStream,\n runtimeContext: {\n stream: args.mainStream,\n stateStore,\n lastPersistTime: 0,\n capabilities: args.parentCapabilities,\n emissions,\n barIndex: () => state.barIndex,\n isTick: false,\n drawingSlots: new Map(),\n drawingSubIdCounters: new Map(),\n drawingBucketCounters: {\n lines: 0,\n labels: 0,\n boxes: 0,\n polylines: 0,\n other: 0,\n },\n scriptMaxDrawings: args.compiled.manifest.maxDrawings ?? null,\n stateSlots: new Map(),\n secondaryStreams: args.secondaryStreams,\n requestSecurityBars: new Map(),\n requestSecurityAlignments: new Map(),\n requestSecurityAscendingBars: new Map(),\n requestLowerTfViews: new Map(),\n diagnosedRequestKeys: new Set(),\n alertConditions,\n diagnosedAlertConditionKeys: new Set(),\n logBudget: 0,\n logBudgetExceededDiagnosed: false,\n resolvedInputs: Object.freeze({}),\n defaultPane: resolveDefaultPane(args.compiled.manifest),\n scriptPane: resolveScriptPane(args.compiled.manifest),\n // Overrides target the primary script's slots only in v1;\n // dep-output plots are not host-overridable.\n plotOverrides: Object.freeze({}),\n diagnosedInputKeys: new Set(),\n views: createRuntimeViews(),\n slotIdPrefix,\n isDep,\n depOutputStore: args.depOutputStore,\n },\n emissions,\n depRunners: [],\n siblingRunners: [],\n depOutputStore: args.depOutputStore,\n depErroredThisBar: false,\n barIndex: 0,\n };\n state.runtimeContext.resolvedInputs = resolveInputs(\n args.compiled.manifest,\n args.inputOverrides,\n state.runtimeContext,\n );\n return state;\n}\n\nfunction declaredOutputTitles(compiled: CompiledScriptObject): ReadonlyArray<string> {\n return (compiled.manifest.outputs ?? []).map((o) => o.title);\n}\n\n/**\n * Construct a {@link DepRunner} for one private dep entry of a\n * `CompiledScriptBundle`. The runner shares the parent's `mainStream`\n * + `secondaryStreams`, owns a fresh `inMemoryStateStore`, and feeds\n * its plot emissions into the shared `DepOutputStore`.\n *\n * @since 0.7\n * @stable\n * @example\n * // const dep = createDepRunner({ compiled, localId: \"fast\",\n * // parentCapabilities, mainStream, secondaryStreams,\n * // depOutputStore, inputOverrides: { length: 20 }, now: Date.now });\n * const x: number = 1;\n * void x;\n */\nexport function createDepRunner(\n args: CreateDepRunnerArgs & { readonly localId: string },\n): DepRunner {\n const slotIdPrefix = `dep:${args.localId}/`;\n return Object.freeze({\n kind: \"dep\" as const,\n localId: args.localId,\n slotIdPrefix,\n declaredOutputs: declaredOutputTitles(args.compiled),\n state: buildSubRunnerState(args, slotIdPrefix, true),\n });\n}\n\n/**\n * Construct a {@link SiblingRunner} for one drawn named-export entry of\n * a `CompiledScriptBundle`. Shares streams + store with the parent;\n * emissions forward to the parent with `export:<exportName>/` slot-id\n * prefixes.\n *\n * @since 0.7\n * @stable\n * @example\n * // const sib = createSiblingRunner({ compiled, exportName: \"slow\", ... });\n * const x: number = 1;\n * void x;\n */\nexport function createSiblingRunner(\n args: CreateDepRunnerArgs & { readonly exportName: string },\n): SiblingRunner {\n const slotIdPrefix = `export:${args.exportName}/`;\n return Object.freeze({\n kind: \"sibling\" as const,\n exportName: args.exportName,\n slotIdPrefix,\n declaredOutputs: declaredOutputTitles(args.compiled),\n state: buildSubRunnerState(args, slotIdPrefix, false),\n });\n}\n\nfunction depRunnerLike(dep: DepRunner): DepRunnerLike {\n return {\n kind: \"dep\",\n localId: dep.localId,\n slotIdPrefix: dep.slotIdPrefix,\n declaredOutputs: dep.declaredOutputs,\n emissions: dep.state.emissions,\n };\n}\n\nfunction siblingRunnerLike(sib: SiblingRunner): SiblingRunnerLike {\n return {\n kind: \"sibling\",\n exportName: sib.exportName,\n slotIdPrefix: sib.slotIdPrefix,\n declaredOutputs: sib.declaredOutputs,\n emissions: sib.state.emissions,\n };\n}\n\nasync function executeSubStep(\n state: RunnerState,\n eventKind: EventKind,\n isTick: boolean,\n): Promise<{ readonly halted: boolean; readonly message: string }> {\n resetBarEmissions(state);\n try {\n const outcome = await runComputeBody({ state, eventKind, isTick });\n return outcome.kind === \"halt\"\n ? { halted: true, message: outcome.message }\n : { halted: false, message: \"\" };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n return { halted: true, message };\n }\n}\n\n/**\n * Drive one bar of execution for a {@link DepRunner}. Runs the dep's\n * `compute`, captures its titled-plot output into the shared\n * `DepOutputStore` via {@link applyDepEmissionPolicy}, namespaces\n * diagnostics with `dep:<localId>/`, and on halt sets\n * `parentState.depErroredThisBar = true` so the parent's primary\n * step drops its emissions for the bar (per task spec §6).\n *\n * @since 0.7\n * @stable\n * @example\n * // await runDepStep(dep, parent, rawBar, \"close\", false);\n * const x: number = 1;\n * void x;\n */\nexport async function runDepStep(\n dep: DepRunner,\n parentState: RunnerState,\n rawBar: Bar,\n eventKind: EventKind,\n isTick: boolean,\n): Promise<void> {\n if (parentState.depOutputStore === null) {\n throw new Error(\"runDepStep called on a runner with no dep output store\");\n }\n void rawBar;\n const result = await executeSubStep(dep.state, eventKind, isTick);\n if (result.halted) {\n // Use an empty slot id so the filter's prefix call produces the\n // runner's slotIdPrefix (`dep:<localId>/`) — preserves the\n // distinguished slotId in the parent's diagnostic queue.\n pushDiagnostic(dep.state.emissions, {\n kind: \"diagnostic\",\n severity: \"error\",\n code: \"dep-error\",\n message: result.message,\n slotId: \"\",\n bar: dep.state.barIndex,\n });\n parentState.depErroredThisBar = true;\n }\n if (!isTick) {\n dep.state.barIndex += 1;\n }\n applyDepEmissionPolicy(depRunnerLike(dep), parentState.emissions, parentState.depOutputStore);\n}\n\n/**\n * Drive one bar of execution for a {@link SiblingRunner}. Same shape\n * as {@link runDepStep} but the sibling's emissions are forwarded to\n * the parent with `export:<exportName>/` slot-id prefixes, and a\n * sibling halt does NOT clear the primary's emissions — only the\n * sibling's own bar emissions are lost.\n *\n * @since 0.7\n * @stable\n * @example\n * // await runSiblingStep(sibling, parent, rawBar, \"close\", false);\n * const x: number = 1;\n * void x;\n */\nexport async function runSiblingStep(\n sibling: SiblingRunner,\n parentState: RunnerState,\n rawBar: Bar,\n eventKind: EventKind,\n isTick: boolean,\n): Promise<void> {\n if (parentState.depOutputStore === null) {\n throw new Error(\"runSiblingStep called on a runner with no dep output store\");\n }\n void rawBar;\n const result = await executeSubStep(sibling.state, eventKind, isTick);\n if (result.halted) {\n pushDiagnostic(sibling.state.emissions, {\n kind: \"diagnostic\",\n severity: \"error\",\n code: \"dep-error\",\n message: result.message,\n slotId: \"\",\n bar: sibling.state.barIndex,\n });\n // sibling halt does NOT set parentState.depErroredThisBar.\n }\n if (!isTick) {\n sibling.state.barIndex += 1;\n }\n applyDepEmissionPolicy(\n siblingRunnerLike(sibling),\n parentState.emissions,\n parentState.depOutputStore,\n );\n}\n"]}
@@ -0,0 +1,50 @@
1
+ import type { Series } from "@invinite-org/chartlang-core";
2
+ /**
3
+ * The well-known property on `globalThis` the compiler-emitted bundle's
4
+ * inline shim looks for. Set once by {@link installDepOutputGlobal}.
5
+ *
6
+ * @since 0.7
7
+ * @stable
8
+ * @example
9
+ * // import { DEP_OUTPUT_GLOBAL_KEY } from "@invinite-org/chartlang-runtime/internal";
10
+ * // const fn = (globalThis as Record<string, unknown>)[DEP_OUTPUT_GLOBAL_KEY];
11
+ * // void fn;
12
+ */
13
+ export declare const DEP_OUTPUT_GLOBAL_KEY: "__chartlang_depOutput";
14
+ /**
15
+ * Runtime helper invoked by the compiler-emitted bundle in place of
16
+ * every consumer-side `<binding>.output("title")` call. Tasks 2 + 3
17
+ * rewrite each call site to
18
+ * `__chartlang_depOutput(slotId, localId, title)`; the runtime returns
19
+ * the producer's stable `Series<number>` view from the active runner's
20
+ * `DepOutputStore`.
21
+ *
22
+ * The helper is exposed via the `@invinite-org/chartlang-runtime/internal`
23
+ * subpath only — user scripts can't import it. {@link installDepOutputGlobal}
24
+ * also assigns it to `globalThis.__chartlang_depOutput` so the bundle's
25
+ * inline shim picks it up automatically.
26
+ *
27
+ * @since 0.7
28
+ * @stable
29
+ * @example
30
+ * // import { __chartlang_depOutput } from "@invinite-org/chartlang-runtime/internal";
31
+ * // const line = __chartlang_depOutput("demo.chart.ts:5:13#0", "fast", "line");
32
+ * // void line;
33
+ */
34
+ export declare function __chartlang_depOutput(slotId: string, localId: string, title: string): Series<number>;
35
+ /**
36
+ * Install {@link __chartlang_depOutput} on `globalThis` under the
37
+ * {@link DEP_OUTPUT_GLOBAL_KEY} property. Compiler-emitted bundles
38
+ * reference the global via an inline shim; the runtime calls
39
+ * `installDepOutputGlobal` from `createScriptRunner` when mounting a
40
+ * `CompiledScriptBundle`. The assignment is idempotent — subsequent
41
+ * calls leave the existing value untouched.
42
+ *
43
+ * @since 0.7
44
+ * @stable
45
+ * @example
46
+ * // import { installDepOutputGlobal } from "@invinite-org/chartlang-runtime/internal";
47
+ * // installDepOutputGlobal();
48
+ */
49
+ export declare function installDepOutputGlobal(): void;
50
+ //# sourceMappingURL=depOutput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depOutput.d.ts","sourceRoot":"","sources":["../../src/dep/depOutput.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAO3D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,EAAG,uBAAgC,CAAC;AAatE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACd,MAAM,CAAC,MAAM,CAAC,CAsBhB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAK7C"}
@@ -0,0 +1,92 @@
1
+ // Copyright (c) 2026 Invinite. Licensed under the MIT License.
2
+ // See the LICENSE file in the repo root for full license text.
3
+ import { pushDiagnostic } from "../emit/emissionsQueue.js";
4
+ import { Float64RingBuffer } from "../ringBuffer.js";
5
+ import { ACTIVE_RUNTIME_CONTEXT } from "../runtimeContext.js";
6
+ import { makeSeriesView } from "../seriesView.js";
7
+ /**
8
+ * The well-known property on `globalThis` the compiler-emitted bundle's
9
+ * inline shim looks for. Set once by {@link installDepOutputGlobal}.
10
+ *
11
+ * @since 0.7
12
+ * @stable
13
+ * @example
14
+ * // import { DEP_OUTPUT_GLOBAL_KEY } from "@invinite-org/chartlang-runtime/internal";
15
+ * // const fn = (globalThis as Record<string, unknown>)[DEP_OUTPUT_GLOBAL_KEY];
16
+ * // void fn;
17
+ */
18
+ export const DEP_OUTPUT_GLOBAL_KEY = "__chartlang_depOutput";
19
+ const OUTSIDE_CTX_MESSAGE = "__chartlang_depOutput called outside an active script step";
20
+ const NO_STORE_MESSAGE = "__chartlang_depOutput called on a runner with no dep output store";
21
+ /**
22
+ * Sentinel `Series<number>` whose every read returns `NaN`. Returned by
23
+ * the helper when the consumer asks for an output that the producer
24
+ * never declared (compile-time error from Task 2; runtime sanity
25
+ * fallback). The buffer never receives a write, so all reads stay NaN.
26
+ */
27
+ const NAN_SERIES = makeSeriesView(new Float64RingBuffer(1));
28
+ /**
29
+ * Runtime helper invoked by the compiler-emitted bundle in place of
30
+ * every consumer-side `<binding>.output("title")` call. Tasks 2 + 3
31
+ * rewrite each call site to
32
+ * `__chartlang_depOutput(slotId, localId, title)`; the runtime returns
33
+ * the producer's stable `Series<number>` view from the active runner's
34
+ * `DepOutputStore`.
35
+ *
36
+ * The helper is exposed via the `@invinite-org/chartlang-runtime/internal`
37
+ * subpath only — user scripts can't import it. {@link installDepOutputGlobal}
38
+ * also assigns it to `globalThis.__chartlang_depOutput` so the bundle's
39
+ * inline shim picks it up automatically.
40
+ *
41
+ * @since 0.7
42
+ * @stable
43
+ * @example
44
+ * // import { __chartlang_depOutput } from "@invinite-org/chartlang-runtime/internal";
45
+ * // const line = __chartlang_depOutput("demo.chart.ts:5:13#0", "fast", "line");
46
+ * // void line;
47
+ */
48
+ export function __chartlang_depOutput(slotId, localId, title) {
49
+ const ctx = ACTIVE_RUNTIME_CONTEXT.current;
50
+ if (ctx === null) {
51
+ throw new Error(OUTSIDE_CTX_MESSAGE);
52
+ }
53
+ const store = ctx.depOutputStore;
54
+ if (store === undefined || store === null) {
55
+ throw new Error(NO_STORE_MESSAGE);
56
+ }
57
+ try {
58
+ return store.read(localId, title);
59
+ }
60
+ catch {
61
+ pushDiagnostic(ctx.emissions, {
62
+ kind: "diagnostic",
63
+ severity: "error",
64
+ code: "dep-unknown-output",
65
+ message: `dep "${localId}" did not declare output "${title}"`,
66
+ slotId,
67
+ bar: ctx.barIndex(),
68
+ });
69
+ return NAN_SERIES;
70
+ }
71
+ }
72
+ /**
73
+ * Install {@link __chartlang_depOutput} on `globalThis` under the
74
+ * {@link DEP_OUTPUT_GLOBAL_KEY} property. Compiler-emitted bundles
75
+ * reference the global via an inline shim; the runtime calls
76
+ * `installDepOutputGlobal` from `createScriptRunner` when mounting a
77
+ * `CompiledScriptBundle`. The assignment is idempotent — subsequent
78
+ * calls leave the existing value untouched.
79
+ *
80
+ * @since 0.7
81
+ * @stable
82
+ * @example
83
+ * // import { installDepOutputGlobal } from "@invinite-org/chartlang-runtime/internal";
84
+ * // installDepOutputGlobal();
85
+ */
86
+ export function installDepOutputGlobal() {
87
+ const holder = globalThis;
88
+ if (holder[DEP_OUTPUT_GLOBAL_KEY] === undefined) {
89
+ holder[DEP_OUTPUT_GLOBAL_KEY] = __chartlang_depOutput;
90
+ }
91
+ }
92
+ //# sourceMappingURL=depOutput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depOutput.js","sourceRoot":"","sources":["../../src/dep/depOutput.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAgC,CAAC;AAEtE,MAAM,mBAAmB,GAAG,4DAA4D,CAAC;AACzF,MAAM,gBAAgB,GAAG,mEAAmE,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,UAAU,GAAmB,cAAc,CAAS,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,qBAAqB,CACjC,MAAc,EACd,OAAe,EACf,KAAa;IAEb,MAAM,GAAG,GAAG,sBAAsB,CAAC,OAAO,CAAC;IAC3C,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,cAAc,CAAC;IACjC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACL,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE;YAC1B,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,oBAAoB;YAC1B,OAAO,EAAE,QAAQ,OAAO,6BAA6B,KAAK,GAAG;YAC7D,MAAM;YACN,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;SACtB,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACtB,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB;IAClC,MAAM,MAAM,GAAG,UAAqC,CAAC;IACrD,IAAI,MAAM,CAAC,qBAAqB,CAAC,KAAK,SAAS,EAAE,CAAC;QAC9C,MAAM,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;IAC1D,CAAC;AACL,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 { Series } from \"@invinite-org/chartlang-core\";\n\nimport { pushDiagnostic } from \"../emit/emissionsQueue.js\";\nimport { Float64RingBuffer } from \"../ringBuffer.js\";\nimport { ACTIVE_RUNTIME_CONTEXT } from \"../runtimeContext.js\";\nimport { makeSeriesView } from \"../seriesView.js\";\n\n/**\n * The well-known property on `globalThis` the compiler-emitted bundle's\n * inline shim looks for. Set once by {@link installDepOutputGlobal}.\n *\n * @since 0.7\n * @stable\n * @example\n * // import { DEP_OUTPUT_GLOBAL_KEY } from \"@invinite-org/chartlang-runtime/internal\";\n * // const fn = (globalThis as Record<string, unknown>)[DEP_OUTPUT_GLOBAL_KEY];\n * // void fn;\n */\nexport const DEP_OUTPUT_GLOBAL_KEY = \"__chartlang_depOutput\" as const;\n\nconst OUTSIDE_CTX_MESSAGE = \"__chartlang_depOutput called outside an active script step\";\nconst NO_STORE_MESSAGE = \"__chartlang_depOutput called on a runner with no dep output store\";\n\n/**\n * Sentinel `Series<number>` whose every read returns `NaN`. Returned by\n * the helper when the consumer asks for an output that the producer\n * never declared (compile-time error from Task 2; runtime sanity\n * fallback). The buffer never receives a write, so all reads stay NaN.\n */\nconst NAN_SERIES: Series<number> = makeSeriesView<number>(new Float64RingBuffer(1));\n\n/**\n * Runtime helper invoked by the compiler-emitted bundle in place of\n * every consumer-side `<binding>.output(\"title\")` call. Tasks 2 + 3\n * rewrite each call site to\n * `__chartlang_depOutput(slotId, localId, title)`; the runtime returns\n * the producer's stable `Series<number>` view from the active runner's\n * `DepOutputStore`.\n *\n * The helper is exposed via the `@invinite-org/chartlang-runtime/internal`\n * subpath only — user scripts can't import it. {@link installDepOutputGlobal}\n * also assigns it to `globalThis.__chartlang_depOutput` so the bundle's\n * inline shim picks it up automatically.\n *\n * @since 0.7\n * @stable\n * @example\n * // import { __chartlang_depOutput } from \"@invinite-org/chartlang-runtime/internal\";\n * // const line = __chartlang_depOutput(\"demo.chart.ts:5:13#0\", \"fast\", \"line\");\n * // void line;\n */\nexport function __chartlang_depOutput(\n slotId: string,\n localId: string,\n title: string,\n): Series<number> {\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (ctx === null) {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n const store = ctx.depOutputStore;\n if (store === undefined || store === null) {\n throw new Error(NO_STORE_MESSAGE);\n }\n try {\n return store.read(localId, title);\n } catch {\n pushDiagnostic(ctx.emissions, {\n kind: \"diagnostic\",\n severity: \"error\",\n code: \"dep-unknown-output\",\n message: `dep \"${localId}\" did not declare output \"${title}\"`,\n slotId,\n bar: ctx.barIndex(),\n });\n return NAN_SERIES;\n }\n}\n\n/**\n * Install {@link __chartlang_depOutput} on `globalThis` under the\n * {@link DEP_OUTPUT_GLOBAL_KEY} property. Compiler-emitted bundles\n * reference the global via an inline shim; the runtime calls\n * `installDepOutputGlobal` from `createScriptRunner` when mounting a\n * `CompiledScriptBundle`. The assignment is idempotent — subsequent\n * calls leave the existing value untouched.\n *\n * @since 0.7\n * @stable\n * @example\n * // import { installDepOutputGlobal } from \"@invinite-org/chartlang-runtime/internal\";\n * // installDepOutputGlobal();\n */\nexport function installDepOutputGlobal(): void {\n const holder = globalThis as Record<string, unknown>;\n if (holder[DEP_OUTPUT_GLOBAL_KEY] === undefined) {\n holder[DEP_OUTPUT_GLOBAL_KEY] = __chartlang_depOutput;\n }\n}\n"]}