@orangecharts/wrun-chart-host 0.1.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 (198) hide show
  1. package/README.md +72 -0
  2. package/dist/constants/governed-exchanges.constants.d.ts +11 -0
  3. package/dist/constants/governed-exchanges.constants.js +11 -0
  4. package/dist/constants/indicator-sets.constants.d.ts +8 -0
  5. package/dist/constants/indicator-sets.constants.js +8 -0
  6. package/dist/constants/interval.constants.d.ts +34 -0
  7. package/dist/constants/interval.constants.js +121 -0
  8. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +28 -0
  9. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +65 -0
  10. package/dist/constants/tpo-color-schemes.constants.d.ts +30 -0
  11. package/dist/constants/tpo-color-schemes.constants.js +32 -0
  12. package/dist/host-env.d.ts +102 -0
  13. package/dist/host-env.js +26 -0
  14. package/dist/index.d.ts +93 -0
  15. package/dist/index.js +96 -0
  16. package/dist/indicators/controls/tpo-letter.util.d.ts +2 -0
  17. package/dist/indicators/controls/tpo-letter.util.js +13 -0
  18. package/dist/indicators/controls/tpo-session.util.d.ts +99 -0
  19. package/dist/indicators/controls/tpo-session.util.js +389 -0
  20. package/dist/interfaces/kscript-diagnostics.interface.d.ts +64 -0
  21. package/dist/interfaces/kscript-diagnostics.interface.js +1 -0
  22. package/dist/interfaces/om-panel-data.interface.d.ts +103 -0
  23. package/dist/interfaces/om-panel-data.interface.js +7 -0
  24. package/dist/interfaces/wrun-runtime.interface.d.ts +2659 -0
  25. package/dist/interfaces/wrun-runtime.interface.js +55 -0
  26. package/dist/utility/chart/calendar-interval.util.d.ts +24 -0
  27. package/dist/utility/chart/calendar-interval.util.js +81 -0
  28. package/dist/utility/chart/candle-bar-end.util.d.ts +15 -0
  29. package/dist/utility/chart/candle-bar-end.util.js +23 -0
  30. package/dist/utility/chart/cme-realtime.util.d.ts +24 -0
  31. package/dist/utility/chart/cme-realtime.util.js +53 -0
  32. package/dist/utility/chart/interval-ladder.util.d.ts +27 -0
  33. package/dist/utility/chart/interval-ladder.util.js +92 -0
  34. package/dist/utility/chart/kscript-drawing-prep.util.d.ts +40 -0
  35. package/dist/utility/chart/kscript-drawing-prep.util.js +184 -0
  36. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +95 -0
  37. package/dist/utility/chart/kscript-drawing-safe-area.util.js +805 -0
  38. package/dist/utility/chart/kscript-legend-entries.util.d.ts +166 -0
  39. package/dist/utility/chart/kscript-legend-entries.util.js +538 -0
  40. package/dist/utility/chart/kscript-output-role.util.d.ts +32 -0
  41. package/dist/utility/chart/kscript-output-role.util.js +215 -0
  42. package/dist/utility/chart/kscript-provenance-keys.util.d.ts +22 -0
  43. package/dist/utility/chart/kscript-provenance-keys.util.js +56 -0
  44. package/dist/utility/chart/kscript-run-result-normalize.util.d.ts +53 -0
  45. package/dist/utility/chart/kscript-run-result-normalize.util.js +476 -0
  46. package/dist/utility/chart/kscript-run-result-shape.util.d.ts +14 -0
  47. package/dist/utility/chart/kscript-run-result-shape.util.js +66 -0
  48. package/dist/utility/chart/kscript-titancharts-container.util.d.ts +29 -0
  49. package/dist/utility/chart/kscript-titancharts-container.util.js +151 -0
  50. package/dist/utility/chart/kscript-viewport-overlays.util.d.ts +83 -0
  51. package/dist/utility/chart/kscript-viewport-overlays.util.js +443 -0
  52. package/dist/utility/chart/om-panel-push-style.util.d.ts +78 -0
  53. package/dist/utility/chart/om-panel-push-style.util.js +301 -0
  54. package/dist/utility/chart/om-panel.util.d.ts +166 -0
  55. package/dist/utility/chart/om-panel.util.js +815 -0
  56. package/dist/utility/chart/om-series.util.d.ts +42 -0
  57. package/dist/utility/chart/om-series.util.js +330 -0
  58. package/dist/utility/chart/om-target.util.d.ts +11 -0
  59. package/dist/utility/chart/om-target.util.js +24 -0
  60. package/dist/utility/chart/om-widget.util.d.ts +148 -0
  61. package/dist/utility/chart/om-widget.util.js +413 -0
  62. package/dist/utility/chart/overlay-output-budget.util.d.ts +16 -0
  63. package/dist/utility/chart/overlay-output-budget.util.js +109 -0
  64. package/dist/utility/chart/overlay-paint-flags.util.d.ts +24 -0
  65. package/dist/utility/chart/overlay-paint-flags.util.js +55 -0
  66. package/dist/utility/chart/profile-row-height.util.d.ts +21 -0
  67. package/dist/utility/chart/profile-row-height.util.js +110 -0
  68. package/dist/utility/chart/session-interval.util.d.ts +1 -0
  69. package/dist/utility/chart/session-interval.util.js +35 -0
  70. package/dist/utility/chart/technical-script-legend-value.util.d.ts +18 -0
  71. package/dist/utility/chart/technical-script-legend-value.util.js +53 -0
  72. package/dist/utility/chart/trading-day.util.d.ts +70 -0
  73. package/dist/utility/chart/trading-day.util.js +238 -0
  74. package/dist/utility/chart/wrun-legend-name.util.d.ts +25 -0
  75. package/dist/utility/chart/wrun-legend-name.util.js +87 -0
  76. package/dist/utility/chart/wrun-run-result.util.d.ts +977 -0
  77. package/dist/utility/chart/wrun-run-result.util.js +5179 -0
  78. package/dist/utility/chart/wrun-visibility-chart.util.d.ts +25 -0
  79. package/dist/utility/chart/wrun-visibility-chart.util.js +22 -0
  80. package/dist/utility/indicators/heatmap-sensitivity.util.d.ts +62 -0
  81. package/dist/utility/indicators/heatmap-sensitivity.util.js +82 -0
  82. package/dist/utility/number-format.util.d.ts +68 -0
  83. package/dist/utility/number-format.util.js +188 -0
  84. package/dist/utility/v2/opra-governed.util.d.ts +1 -0
  85. package/dist/utility/v2/opra-governed.util.js +13 -0
  86. package/dist/utility/wrun/wrun-auto-row.util.d.ts +54 -0
  87. package/dist/utility/wrun/wrun-auto-row.util.js +96 -0
  88. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +341 -0
  89. package/dist/utility/wrun/wrun-batched-marks.util.js +938 -0
  90. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +75 -0
  91. package/dist/utility/wrun/wrun-batched-readout.util.js +171 -0
  92. package/dist/utility/wrun/wrun-box-segment.util.d.ts +185 -0
  93. package/dist/utility/wrun/wrun-box-segment.util.js +570 -0
  94. package/dist/utility/wrun/wrun-build-memo.util.d.ts +133 -0
  95. package/dist/utility/wrun/wrun-build-memo.util.js +301 -0
  96. package/dist/utility/wrun/wrun-builtin-twin-ports.util.d.ts +25 -0
  97. package/dist/utility/wrun/wrun-builtin-twin-ports.util.js +75 -0
  98. package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +9 -0
  99. package/dist/utility/wrun/wrun-builtin-twin.util.js +40 -0
  100. package/dist/utility/wrun/wrun-canvas-cache.util.d.ts +28 -0
  101. package/dist/utility/wrun/wrun-canvas-cache.util.js +56 -0
  102. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +69 -0
  103. package/dist/utility/wrun/wrun-canvas-readout.util.js +53 -0
  104. package/dist/utility/wrun/wrun-canvases.util.d.ts +295 -0
  105. package/dist/utility/wrun/wrun-canvases.util.js +1432 -0
  106. package/dist/utility/wrun/wrun-cap-notice.util.d.ts +77 -0
  107. package/dist/utility/wrun/wrun-cap-notice.util.js +296 -0
  108. package/dist/utility/wrun/wrun-card-style.util.d.ts +154 -0
  109. package/dist/utility/wrun/wrun-card-style.util.js +539 -0
  110. package/dist/utility/wrun/wrun-chart-context.util.d.ts +89 -0
  111. package/dist/utility/wrun/wrun-chart-context.util.js +213 -0
  112. package/dist/utility/wrun/wrun-chart-names.util.d.ts +23 -0
  113. package/dist/utility/wrun/wrun-chart-names.util.js +33 -0
  114. package/dist/utility/wrun/wrun-chart-time.util.d.ts +12 -0
  115. package/dist/utility/wrun/wrun-chart-time.util.js +23 -0
  116. package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +13 -0
  117. package/dist/utility/wrun/wrun-child-overlay-id.util.js +44 -0
  118. package/dist/utility/wrun/wrun-color-facts.util.d.ts +40 -0
  119. package/dist/utility/wrun/wrun-color-facts.util.js +88 -0
  120. package/dist/utility/wrun/wrun-color-settings.lazy.d.ts +26 -0
  121. package/dist/utility/wrun/wrun-color-settings.lazy.js +9 -0
  122. package/dist/utility/wrun/wrun-color-settings.util.d.ts +351 -0
  123. package/dist/utility/wrun/wrun-color-settings.util.js +1363 -0
  124. package/dist/utility/wrun/wrun-footprint-modes.util.d.ts +23 -0
  125. package/dist/utility/wrun/wrun-footprint-modes.util.js +24 -0
  126. package/dist/utility/wrun/wrun-frames.d.ts +217 -0
  127. package/dist/utility/wrun/wrun-frames.js +1021 -0
  128. package/dist/utility/wrun/wrun-handles.util.d.ts +792 -0
  129. package/dist/utility/wrun/wrun-handles.util.js +2050 -0
  130. package/dist/utility/wrun/wrun-heatmap-cell-budget.util.d.ts +156 -0
  131. package/dist/utility/wrun/wrun-heatmap-cell-budget.util.js +342 -0
  132. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +218 -0
  133. package/dist/utility/wrun/wrun-hosted-wire-caps.js +667 -0
  134. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +40 -0
  135. package/dist/utility/wrun/wrun-hosted-wire.util.js +27 -0
  136. package/dist/utility/wrun/wrun-hover.util.d.ts +182 -0
  137. package/dist/utility/wrun/wrun-hover.util.js +534 -0
  138. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +246 -0
  139. package/dist/utility/wrun/wrun-hud-looks.util.js +587 -0
  140. package/dist/utility/wrun/wrun-integration-budget.util.d.ts +47 -0
  141. package/dist/utility/wrun/wrun-integration-budget.util.js +122 -0
  142. package/dist/utility/wrun/wrun-latest-snapshot.d.ts +19 -0
  143. package/dist/utility/wrun/wrun-latest-snapshot.js +7 -0
  144. package/dist/utility/wrun/wrun-levels-child.util.d.ts +131 -0
  145. package/dist/utility/wrun/wrun-levels-child.util.js +514 -0
  146. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +75 -0
  147. package/dist/utility/wrun/wrun-lifecycle.contract.js +9 -0
  148. package/dist/utility/wrun/wrun-market-facts.util.d.ts +116 -0
  149. package/dist/utility/wrun/wrun-market-facts.util.js +238 -0
  150. package/dist/utility/wrun/wrun-output-style.util.d.ts +344 -0
  151. package/dist/utility/wrun/wrun-output-style.util.js +1239 -0
  152. package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +84 -0
  153. package/dist/utility/wrun/wrun-overlay-identity.util.js +142 -0
  154. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +120 -0
  155. package/dist/utility/wrun/wrun-overlay-result.util.js +219 -0
  156. package/dist/utility/wrun/wrun-pack.util.d.ts +70 -0
  157. package/dist/utility/wrun/wrun-pack.util.js +301 -0
  158. package/dist/utility/wrun/wrun-pane-format.util.d.ts +180 -0
  159. package/dist/utility/wrun/wrun-pane-format.util.js +299 -0
  160. package/dist/utility/wrun/wrun-panel-style.lazy.d.ts +25 -0
  161. package/dist/utility/wrun/wrun-panel-style.lazy.js +15 -0
  162. package/dist/utility/wrun/wrun-panel-style.util.d.ts +174 -0
  163. package/dist/utility/wrun/wrun-panel-style.util.js +726 -0
  164. package/dist/utility/wrun/wrun-param-values.util.d.ts +69 -0
  165. package/dist/utility/wrun/wrun-param-values.util.js +230 -0
  166. package/dist/utility/wrun/wrun-refusal.util.d.ts +263 -0
  167. package/dist/utility/wrun/wrun-refusal.util.js +1259 -0
  168. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +199 -0
  169. package/dist/utility/wrun/wrun-registry-errors.util.js +257 -0
  170. package/dist/utility/wrun/wrun-render-select.util.d.ts +336 -0
  171. package/dist/utility/wrun/wrun-render-select.util.js +1157 -0
  172. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +434 -0
  173. package/dist/utility/wrun/wrun-script-inputs.util.js +1971 -0
  174. package/dist/utility/wrun/wrun-setting-words.lazy.d.ts +20 -0
  175. package/dist/utility/wrun/wrun-setting-words.lazy.js +9 -0
  176. package/dist/utility/wrun/wrun-setting-words.util.d.ts +79 -0
  177. package/dist/utility/wrun/wrun-setting-words.util.js +176 -0
  178. package/dist/utility/wrun/wrun-socket-row-store.d.ts +98 -0
  179. package/dist/utility/wrun/wrun-socket-row-store.js +417 -0
  180. package/dist/utility/wrun/wrun-style-flags.util.d.ts +18 -0
  181. package/dist/utility/wrun/wrun-style-flags.util.js +21 -0
  182. package/dist/utility/wrun/wrun-style-words.util.d.ts +148 -0
  183. package/dist/utility/wrun/wrun-style-words.util.js +439 -0
  184. package/dist/utility/wrun/wrun-table-look.util.d.ts +125 -0
  185. package/dist/utility/wrun/wrun-table-look.util.js +225 -0
  186. package/dist/utility/wrun/wrun-text-look.util.d.ts +51 -0
  187. package/dist/utility/wrun/wrun-text-look.util.js +227 -0
  188. package/dist/utility/wrun/wrun-text-params.util.d.ts +106 -0
  189. package/dist/utility/wrun/wrun-text-params.util.js +171 -0
  190. package/dist/utility/wrun/wrun-tpo-rows.util.d.ts +71 -0
  191. package/dist/utility/wrun/wrun-tpo-rows.util.js +438 -0
  192. package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +14 -0
  193. package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +58 -0
  194. package/dist/utility/wrun/wrun-visibility-table.d.ts +437 -0
  195. package/dist/utility/wrun/wrun-visibility-table.js +237 -0
  196. package/dist/utility/wrun/wrun-volume-profile.util.d.ts +37 -0
  197. package/dist/utility/wrun/wrun-volume-profile.util.js +278 -0
  198. package/package.json +38 -0
@@ -0,0 +1,237 @@
1
+ /** Every plot word the kit's schema accepts. A data-only `''` draws nothing (its `barcolor: true` form is the
2
+ * candle tint, WRUN_BARCOLOR_OUTPUT_RULE); an inset output is the inset child the run result builds from it. */
3
+ export const WRUN_OUTPUT_PLOT_RULES = Object.freeze({
4
+ line: { group: 'nested', style: 'line', titan: 'spline', paint: 'line' },
5
+ area: { group: 'nested', style: 'area', titan: 'area', paint: 'area' },
6
+ bar: { group: 'nested', style: 'bar', titan: 'bar', paint: 'bar' },
7
+ histogram: { group: 'nested', style: 'bar', titan: 'bar', paint: 'bar' },
8
+ candle: { group: 'nested', style: 'candle', titan: 'spline', paint: 'candle' },
9
+ shape: { group: 'nested', style: 'mark', titan: 'point', paint: 'shape' },
10
+ scatter: { group: 'nested', style: 'mark', titan: 'point', paint: 'scatter' },
11
+ inset: { group: 'skip' },
12
+ '': 'not-drawn',
13
+ });
14
+ /** The candle tint: mounted under the `barcolor` plot, whose own `isHidden` titan tints the candles by. */
15
+ export const WRUN_BARCOLOR_OUTPUT_RULE = Object.freeze({ group: 'nested' });
16
+ export const WRUN_BARCOLOR_PLOT_KEY = 'barcolor';
17
+ export const WRUN_RENDERER_KIND_RULES = Object.freeze({
18
+ inset: { group: 'skip' },
19
+ text: { group: 'skip' },
20
+ label: { group: 'skip' },
21
+ table: { group: 'skip' },
22
+ shape: { group: 'skip' },
23
+ stats_row: { group: 'skip' },
24
+ bgcolor: { group: 'skip' },
25
+ barcolor: { group: 'skip' },
26
+ });
27
+ /** The mini-chart grid rides the outputs as one plot the integration lifts into the grid overlay: `skip`. */
28
+ export const WRUN_DRAWING_KIND_RULES = Object.freeze({
29
+ ladder: { group: 'drawing' },
30
+ feed: { group: 'drawing' },
31
+ meter: { group: 'drawing' },
32
+ line: { group: 'drawing' },
33
+ box: { group: 'drawing' },
34
+ polyline: { group: 'drawing' },
35
+ label: { group: 'drawing' },
36
+ card: { group: 'drawing' },
37
+ minicharts: { group: 'skip' },
38
+ });
39
+ export const WRUN_PROFILE_KIND_RULES = Object.freeze({
40
+ footprint: { group: 'skip' },
41
+ tpo: { group: 'skip' },
42
+ volume: { group: 'skip' },
43
+ });
44
+ /** A line's `fill_to` shading follows its line's row. */
45
+ export const WRUN_HANDLE_KIND_RULES = Object.freeze({
46
+ line: { group: 'drawing' },
47
+ box: { group: 'drawing' },
48
+ label: { group: 'drawing' },
49
+ polyline: { group: 'drawing' },
50
+ });
51
+ /** THE table, in Style page order (its key order is the order a sheet's targets are offered). */
52
+ export const WRUN_VISIBILITY_RULES = Object.freeze({
53
+ outputs: { prefix: '', kinds: WRUN_OUTPUT_PLOT_RULES },
54
+ ranges: { prefix: 'range', group: 'nested' },
55
+ fills: { prefix: 'fill', group: 'nested' },
56
+ boxes: { prefix: 'box', group: 'nested' },
57
+ renderers: { prefix: 'text', kinds: WRUN_RENDERER_KIND_RULES },
58
+ segments: { prefix: 'segment', group: 'drawing' },
59
+ drawings: { prefix: 'drawing', kinds: WRUN_DRAWING_KIND_RULES },
60
+ handles: { prefix: 'handles', kinds: WRUN_HANDLE_KIND_RULES },
61
+ heatmaps: { prefix: 'heatmap', group: 'skip' },
62
+ profiles: { prefix: 'profile', kinds: WRUN_PROFILE_KIND_RULES },
63
+ levels: { prefix: 'levels', group: 'skip' },
64
+ matrices: { prefix: 'matrix', group: 'skip' },
65
+ panels: { prefix: 'panel', group: 'skip' },
66
+ marks: { prefix: 'marks', group: 'skip' },
67
+ spans: { prefix: 'spans', group: 'skip' },
68
+ rays: { prefix: 'rays', group: 'skip' },
69
+ strategy: 'not-drawn',
70
+ presentation: 'not-drawn',
71
+ stats_strip: 'not-drawn',
72
+ panes: 'not-drawn',
73
+ });
74
+ function isRecord(value) {
75
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
76
+ }
77
+ function nameOf(entry) {
78
+ return typeof entry.name === 'string' && entry.name.trim() !== '' ? entry.name : undefined;
79
+ }
80
+ /** A target's Visible row key (frozen `__style__<target>__visible`). */
81
+ export function wrunVisibleRowKey(target) {
82
+ return `__style__${target}__visible`;
83
+ }
84
+ /** An output word's rule; a word the schema does not list (an older or hand-written sheet) is a line, the
85
+ * adapter's default. */
86
+ export function wrunOutputPlotRule(plot) {
87
+ if (plot === '')
88
+ return 'not-drawn';
89
+ return typeof plot === 'string' && Object.prototype.hasOwnProperty.call(WRUN_OUTPUT_PLOT_RULES, plot)
90
+ ? WRUN_OUTPUT_PLOT_RULES[plot]
91
+ : WRUN_OUTPUT_PLOT_RULES.line;
92
+ }
93
+ /** A fully transparent output (opacity 0 on its static colour, no per-bar colour, no bar palette): a range's
94
+ * edge helper, which mounts no plot. */
95
+ export function isWrunTransparentOutput(output) {
96
+ const rule = wrunOutputPlotRule(output.plot);
97
+ return (output.plot !== 'candle' &&
98
+ output.opacity === 0 &&
99
+ output.color_by === undefined &&
100
+ output.color_packed_by === undefined &&
101
+ !(rule !== 'not-drawn' && rule.titan === 'bar' && output.colors !== undefined));
102
+ }
103
+ const DRAW_OF_RULE = new Map();
104
+ const BARCOLOR_DRAW = Object.freeze({ ...WRUN_BARCOLOR_OUTPUT_RULE, barcolor: true });
105
+ /** THE drawn / transparent classifier every reader of an output's plot word asks (the Style rows, the run
106
+ * result's mount, the in-place patch, the pane plan): undefined for an output that draws nothing. */
107
+ export function wrunOutputDraw(output) {
108
+ if (output.barcolor === true)
109
+ return BARCOLOR_DRAW;
110
+ const rule = wrunOutputPlotRule(output.plot);
111
+ if (rule === 'not-drawn' || isWrunTransparentOutput(output))
112
+ return undefined;
113
+ let draw = DRAW_OF_RULE.get(rule);
114
+ if (draw === undefined) {
115
+ draw = Object.freeze({ ...rule, barcolor: false });
116
+ DRAW_OF_RULE.set(rule, draw);
117
+ }
118
+ return draw;
119
+ }
120
+ /** The frozen identities past an output's name. */
121
+ export const wrunFillTarget = (first, second, ordinal) => `fill:${first}/${second}#${ordinal}`;
122
+ export const wrunRangeTarget = (upper, lower, ordinal) => `range:${upper}/${lower}#${ordinal}`;
123
+ export const wrunBoxTarget = (nameOrIndex) => `box:${nameOrIndex}`;
124
+ export const wrunSegmentTarget = (nameOrIndex) => `segment:${nameOrIndex}`;
125
+ export const wrunDrawingTarget = (kind, nameOrIndex) => `drawing:${kind}:${nameOrIndex}`;
126
+ export const wrunHandlesTarget = (kind) => `handles:${kind}`;
127
+ const SECTION_BY_PREFIX = new Map(Object.entries(WRUN_VISIBILITY_RULES)
128
+ .filter((entry) => entry[1] !== 'not-drawn')
129
+ .filter(([, rule]) => rule.prefix !== '')
130
+ .map(([section, rule]) => [rule.prefix, section]));
131
+ /** A target prefix's section (undefined: a word the table lists no section under). */
132
+ export function wrunVisibilitySectionOfPrefix(prefix) {
133
+ return SECTION_BY_PREFIX.get(prefix);
134
+ }
135
+ function entriesOf(sheet, section) {
136
+ const entries = sheet[section];
137
+ return Array.isArray(entries) ? entries : [];
138
+ }
139
+ /**
140
+ * The target of one entry of a section (`at`: its place; a handle kind: its place in the kit's kind list), its
141
+ * group by its section or kind; undefined when the entry draws nothing (an output the classifier leaves out, a
142
+ * kind with no rule, a declaration missing what its identity names). A band's ordinal counts the section's bands
143
+ * over the same pair before it. One entry only: the sheet walk (wrunVisibilityTargets) adds the checks that need
144
+ * the whole sheet (a candle group's members, a tooltip source).
145
+ */
146
+ export function wrunVisibilityEntryTarget(sheet, section, at) {
147
+ if (section === 'handles') {
148
+ const kind = Object.keys(WRUN_HANDLE_KIND_RULES)[at];
149
+ const declared = sheet.handles;
150
+ if (kind === undefined || !isRecord(declared) || declared[kind] === undefined)
151
+ return undefined;
152
+ const defaults = declared[kind];
153
+ const entry = isRecord(defaults) ? defaults : {};
154
+ return { target: wrunHandlesTarget(kind), section, at, kind, group: WRUN_HANDLE_KIND_RULES[kind].group, entry };
155
+ }
156
+ const entries = entriesOf(sheet, section);
157
+ const entry = entries[at];
158
+ if (!isRecord(entry))
159
+ return undefined;
160
+ const name = nameOf(entry);
161
+ if (section === 'outputs') {
162
+ const draw = name === undefined ? undefined : wrunOutputDraw(entry);
163
+ if (draw === undefined)
164
+ return undefined;
165
+ const plot = typeof entry.plot === 'string' ? entry.plot : undefined;
166
+ return {
167
+ target: name,
168
+ section,
169
+ at,
170
+ ...(plot !== undefined ? { kind: plot } : {}),
171
+ group: draw.group,
172
+ entry,
173
+ draw,
174
+ };
175
+ }
176
+ const rule = WRUN_VISIBILITY_RULES[section];
177
+ const kind = typeof entry.kind === 'string' ? entry.kind : undefined;
178
+ const kinds = 'kinds' in rule ? rule.kinds : undefined;
179
+ const kindRule = kinds === undefined ? undefined : kind !== undefined && Object.hasOwn(kinds, kind) ? kinds[kind] : 'not-drawn';
180
+ if (kindRule === 'not-drawn')
181
+ return undefined;
182
+ const group = kindRule?.group ?? rule.group;
183
+ const pair = (a, b) => {
184
+ if (typeof a !== 'string' || typeof b !== 'string')
185
+ return undefined;
186
+ let ordinal = 0;
187
+ for (const earlier of entries.slice(0, at)) {
188
+ const sides = !isRecord(earlier) ? [] : section === 'fills' ? earlier.between : [earlier.upper, earlier.lower];
189
+ if (Array.isArray(sides) && sides[0] === a && sides[1] === b)
190
+ ordinal += 1;
191
+ }
192
+ return section === 'fills' ? wrunFillTarget(a, b, ordinal) : wrunRangeTarget(a, b, ordinal);
193
+ };
194
+ let target;
195
+ if (section === 'fills')
196
+ target = Array.isArray(entry.between) ? pair(entry.between[0], entry.between[1]) : undefined;
197
+ else if (section === 'ranges')
198
+ target = pair(entry.upper, entry.lower);
199
+ else if (section === 'boxes')
200
+ target = wrunBoxTarget(name ?? at);
201
+ else if (section === 'segments')
202
+ target = wrunSegmentTarget(name ?? at);
203
+ else if (section === 'drawings')
204
+ target = kind === undefined ? undefined : wrunDrawingTarget(kind, name ?? at);
205
+ else
206
+ target = name === undefined ? undefined : `${rule.prefix}:${name}`;
207
+ return target === undefined
208
+ ? undefined
209
+ : { target, section, at, ...(kind !== undefined ? { kind } : {}), group, entry };
210
+ }
211
+ /** The target of the entry a style-target path names (`[section, name or index]`; a handle kind by its kind). */
212
+ export function wrunVisibilityTargetAt(sheet, section, nameOrIndex) {
213
+ const rule = WRUN_VISIBILITY_RULES[section];
214
+ if (rule === undefined || rule === 'not-drawn')
215
+ return undefined;
216
+ const drawn = section;
217
+ const at = section === 'handles'
218
+ ? Object.keys(WRUN_HANDLE_KIND_RULES).indexOf(String(nameOrIndex))
219
+ : typeof nameOrIndex === 'number'
220
+ ? nameOrIndex
221
+ : entriesOf(sheet, section).findIndex((entry) => isRecord(entry) && entry.name === nameOrIndex);
222
+ return at < 0 ? undefined : wrunVisibilityEntryTarget(sheet, drawn, at);
223
+ }
224
+ /** A Style row's target found in a sheet (undefined: an unknown prefix, or no entry draws under it). */
225
+ export function findWrunVisibilityTarget(sheet, target) {
226
+ const colon = target.indexOf(':');
227
+ const section = colon === -1 ? 'outputs' : SECTION_BY_PREFIX.get(target.slice(0, colon));
228
+ if (section === undefined)
229
+ return undefined;
230
+ const count = section === 'handles' ? Object.keys(WRUN_HANDLE_KIND_RULES).length : entriesOf(sheet, section).length;
231
+ for (let at = 0; at < count; at += 1) {
232
+ const found = wrunVisibilityEntryTarget(sheet, section, at);
233
+ if (found?.target === target)
234
+ return found;
235
+ }
236
+ return undefined;
237
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The time-anchored volume profile child (WRUN-STYLE g6 DL-time-anchored,
3
+ * `plot.profile` = `profiles[]` kind "volume"): a volume profile the chart
4
+ * draws from the cells of a declared volume_profile input, anchored to a
5
+ * session, an output-bounded range, the developing session or the visible
6
+ * range. The canvases module's `wrunProfileChildren` delegates kind "volume"
7
+ * here (X31); the child mounts through `wrunCanvasChildConfig`, which resolves
8
+ * the colour words this builder leaves unresolved.
9
+ *
10
+ * Data: the volume_profile lane's array-celled rows as the engine's native
11
+ * profile row shape (`[ts, [low, high, buy, sell], ...]`, one row per bar,
12
+ * buckets ascending), never re-shaped. Settings: the native session profile
13
+ * control's engine keys (session-volume-profile/index.ts) under the sheet's
14
+ * words; every colour stays a word (a theme token resolves at the mount
15
+ * door), every font word becomes its CSS stack (X14).
16
+ */
17
+ import type { WrunMetadataOutput, WrunOutputRow, WrunVolumeProfile } from '../../interfaces/wrun-runtime.interface.js';
18
+ import type { WrunCanvasChildOverlay, WrunCellRows } from './wrun-canvases.util.js';
19
+ /** What the run hands the builder: the chart interval (ms), the run's output
20
+ * rows (a range reads its `start` / `end` outputs on the last ready row)
21
+ * and, optionally, the sheet's outputs so the names resolve to columns (a
22
+ * range profile mounts nothing without them). */
23
+ export interface WrunVolumeProfileContext {
24
+ intervalMs: number;
25
+ outputRows: ReadonlyArray<WrunOutputRow>;
26
+ outputs?: ReadonlyArray<Pick<WrunMetadataOutput, 'name' | 'index'>>;
27
+ }
28
+ /**
29
+ * The profile child of one `profiles[]` kind "volume" entry over the run's
30
+ * volume_profile rows: `{ kind: 'profile', name, data, settings }` with the
31
+ * span's variant (session, with explicit windows for a range), the data
32
+ * window (the developing session's rows, every row for the visible range)
33
+ * and the sheet's words mapped to the engine's profile keys. Null without
34
+ * rows, and for a range whose `start` is not finite or whose `end` is not
35
+ * after it.
36
+ */
37
+ export declare function wrunVolumeProfileChild(profile: WrunVolumeProfile, cellRows: WrunCellRows | undefined, ctx: WrunVolumeProfileContext): WrunCanvasChildOverlay | null;
@@ -0,0 +1,278 @@
1
+ /**
2
+ * The time-anchored volume profile child (WRUN-STYLE g6 DL-time-anchored,
3
+ * `plot.profile` = `profiles[]` kind "volume"): a volume profile the chart
4
+ * draws from the cells of a declared volume_profile input, anchored to a
5
+ * session, an output-bounded range, the developing session or the visible
6
+ * range. The canvases module's `wrunProfileChildren` delegates kind "volume"
7
+ * here (X31); the child mounts through `wrunCanvasChildConfig`, which resolves
8
+ * the colour words this builder leaves unresolved.
9
+ *
10
+ * Data: the volume_profile lane's array-celled rows as the engine's native
11
+ * profile row shape (`[ts, [low, high, buy, sell], ...]`, one row per bar,
12
+ * buckets ascending), never re-shaped. Settings: the native session profile
13
+ * control's engine keys (session-volume-profile/index.ts) under the sheet's
14
+ * words; every colour stays a word (a theme token resolves at the mount
15
+ * door), every font word becomes its CSS stack (X14).
16
+ */
17
+ import { Intervals } from '../../constants/interval.constants.js';
18
+ import { barEndMs, barStartMs } from '../chart/calendar-interval.util.js';
19
+ import { intervalLabelForMs } from '../chart/interval-ladder.util.js';
20
+ import { profileRowMultiplier } from '../chart/profile-row-height.util.js';
21
+ import { getSessionInterval } from '../chart/session-interval.util.js';
22
+ import { parseWrunThemeToken, wrunFontFamilyCss, wrunThemeTokenScaleAlpha } from './wrun-style-words.util.js';
23
+ /** The sheet's mode words to the engine's display modes; "delta" is the
24
+ * stacked bar with the delta pass on. */
25
+ const WRUN_PROFILE_DISPLAY_MODES = {
26
+ stacked_bar: 'stacked-bar',
27
+ split_bar: 'split-bar',
28
+ outline: 'outline',
29
+ delta: 'stacked-bar',
30
+ };
31
+ /** The default session box fill (`background_color` x `background_opacity`). */
32
+ const WRUN_PROFILE_BACKGROUND_COLOR = 'theme.text';
33
+ const WRUN_PROFILE_BACKGROUND_OPACITY = 0.08;
34
+ /** The default level inks. */
35
+ const WRUN_PROFILE_LEVEL_COLOR = 'theme.text';
36
+ function rowTs(row) {
37
+ const ts = Array.isArray(row) ? row[0] : undefined;
38
+ return typeof ts === 'number' && Number.isFinite(ts) ? ts : undefined;
39
+ }
40
+ /** The lane's bucket width in price units: the smallest positive
41
+ * `high - low` over the rows' buckets (the served grid), undefined when no
42
+ * bucket is readable. */
43
+ function bucketWidthOf(rows) {
44
+ let width;
45
+ for (const row of rows) {
46
+ if (!Array.isArray(row))
47
+ continue;
48
+ for (let at = 1; at < row.length; at += 1) {
49
+ const bucket = row[at];
50
+ if (!Array.isArray(bucket))
51
+ continue;
52
+ const low = Number(bucket[0]);
53
+ const high = Number(bucket[1]);
54
+ if (!Number.isFinite(low) || !Number.isFinite(high) || high <= low)
55
+ continue;
56
+ const candidate = high - low;
57
+ if (width === undefined || candidate < width)
58
+ width = candidate;
59
+ }
60
+ }
61
+ return width;
62
+ }
63
+ /** The decimals a price step prints with (the profile's `digits`): the
64
+ * fewest that write the step exactly, at most 8. */
65
+ function decimalsOf(step) {
66
+ for (let digits = 0; digits < 8; digits += 1) {
67
+ if (Number(step.toFixed(digits)) === step)
68
+ return digits;
69
+ }
70
+ return 8;
71
+ }
72
+ /** The chart interval's label for the native tables; an odd length takes the
73
+ * largest standard label no longer than it. */
74
+ function intervalLabelOf(intervalMs) {
75
+ const exact = intervalLabelForMs(intervalMs);
76
+ if (exact !== undefined)
77
+ return exact;
78
+ let best;
79
+ let bestMs = -1;
80
+ for (const [label, length] of Object.entries(Intervals.map_unit)) {
81
+ if (length <= intervalMs && length > bestMs) {
82
+ best = label;
83
+ bestMs = length;
84
+ }
85
+ }
86
+ return best ?? '1d';
87
+ }
88
+ /** The engine's `session` setting for a session word: "auto" is the native
89
+ * Targeted mapping for the chart interval, a length word its milliseconds,
90
+ * a region word the engine's region name. */
91
+ function sessionSettingOf(word, intervalLabel) {
92
+ switch (word ?? 'auto') {
93
+ case 'auto':
94
+ return getSessionInterval('Targeted', intervalLabel);
95
+ case 'us':
96
+ return 'US';
97
+ case 'eu':
98
+ return 'EU';
99
+ case 'asia':
100
+ return 'Asia';
101
+ default: {
102
+ const length = Intervals.map_unit[word];
103
+ return typeof length === 'number' ? length : getSessionInterval('Targeted', intervalLabel);
104
+ }
105
+ }
106
+ }
107
+ /** A colour word at a fraction of its own alpha: a token keeps its word
108
+ * (`theme.text/14`), a hex colour becomes `rgba(r, g, b, a)`; any other
109
+ * string comes back unchanged. */
110
+ function wordAtOpacity(word, opacity) {
111
+ if (parseWrunThemeToken(word) !== null)
112
+ return wrunThemeTokenScaleAlpha(word, opacity);
113
+ const hex = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i.exec(word);
114
+ if (!hex)
115
+ return word;
116
+ const own = hex[4] === undefined ? 1 : parseInt(hex[4], 16) / 255;
117
+ const alpha = Number((own * opacity).toFixed(3));
118
+ return `rgba(${parseInt(hex[1], 16)}, ${parseInt(hex[2], 16)}, ${parseInt(hex[3], 16)}, ${alpha})`;
119
+ }
120
+ /** An output's value on the last ready row, by name. */
121
+ function lastReadyValue(ctx, name) {
122
+ const index = ctx.outputs?.find((output) => output.name === name)?.index;
123
+ if (index === undefined)
124
+ return undefined;
125
+ for (let at = ctx.outputRows.length - 1; at >= 0; at -= 1) {
126
+ const row = ctx.outputRows[at];
127
+ if (row.outputs === null)
128
+ continue;
129
+ const value = row.outputs[index];
130
+ return typeof value === 'number' ? value : undefined;
131
+ }
132
+ return undefined;
133
+ }
134
+ /** The newest bar's close time: the last output row's close (the lane rows'
135
+ * newest bar when the run holds no rows), a calendar bar's own end on a
136
+ * month, quarter, half-year or year chart (`barEndMs`), else its open plus
137
+ * one interval. */
138
+ function newestCloseMs(ctx, rows) {
139
+ const last = ctx.outputRows.length > 0 ? ctx.outputRows[ctx.outputRows.length - 1].ts : undefined;
140
+ if (typeof last === 'number' && Number.isFinite(last))
141
+ return barEndMs(last, ctx.intervalMs);
142
+ let newest;
143
+ for (const row of rows) {
144
+ const ts = rowTs(row);
145
+ if (ts !== undefined && (newest === undefined || ts > newest))
146
+ newest = ts;
147
+ }
148
+ return newest === undefined ? undefined : barEndMs(newest, ctx.intervalMs);
149
+ }
150
+ /** The rows of the session holding the newest bar (span "developing"): the
151
+ * window of the session length (a region session reads as a day) that
152
+ * contains the newest row's timestamp. A month, quarter, half-year or year
153
+ * session is its calendar bar (`barStartMs` to `barEndMs`): the epoch floor
154
+ * of the average length opened the March 2026 session on January 31 10:30
155
+ * and handed it February's row too. */
156
+ function developingRows(rows, session) {
157
+ const sessionMs = typeof session === 'number' && session > 0 ? session : Intervals.DAY;
158
+ let newest;
159
+ for (const row of rows) {
160
+ const ts = rowTs(row);
161
+ if (ts !== undefined && (newest === undefined || ts > newest))
162
+ newest = ts;
163
+ }
164
+ if (newest === undefined)
165
+ return [];
166
+ const start = barStartMs(newest, sessionMs);
167
+ const end = barEndMs(start, sessionMs);
168
+ return rows.filter((row) => {
169
+ const ts = rowTs(row);
170
+ return ts !== undefined && ts >= start && ts < end;
171
+ });
172
+ }
173
+ /**
174
+ * The profile child of one `profiles[]` kind "volume" entry over the run's
175
+ * volume_profile rows: `{ kind: 'profile', name, data, settings }` with the
176
+ * span's variant (session, with explicit windows for a range), the data
177
+ * window (the developing session's rows, every row for the visible range)
178
+ * and the sheet's words mapped to the engine's profile keys. Null without
179
+ * rows, and for a range whose `start` is not finite or whose `end` is not
180
+ * after it.
181
+ */
182
+ export function wrunVolumeProfileChild(profile, cellRows, ctx) {
183
+ const rows = cellRows?.volumeProfileRows;
184
+ if (rows === undefined || rows.length === 0)
185
+ return null;
186
+ const span = profile.span ?? 'session';
187
+ const intervalLabel = intervalLabelOf(ctx.intervalMs);
188
+ const session = sessionSettingOf(profile.session, intervalLabel);
189
+ let data;
190
+ const anchor = {};
191
+ switch (span) {
192
+ case 'range': {
193
+ const startValue = profile.start === undefined ? undefined : lastReadyValue(ctx, profile.start);
194
+ if (startValue === undefined || !Number.isFinite(startValue))
195
+ return null;
196
+ const endValue = profile.end === undefined ? undefined : lastReadyValue(ctx, profile.end);
197
+ const startMs = startValue * 1000;
198
+ const endMs = profile.end === undefined
199
+ ? newestCloseMs(ctx, rows)
200
+ : endValue !== undefined && Number.isFinite(endValue)
201
+ ? endValue * 1000
202
+ : undefined;
203
+ if (endMs === undefined || endMs <= startMs)
204
+ return null;
205
+ data = [...rows];
206
+ anchor.variant = 'session';
207
+ anchor.sessionWindows = [[startMs, endMs]];
208
+ break;
209
+ }
210
+ case 'developing':
211
+ data = developingRows(rows, session);
212
+ anchor.profileWindow = 'data';
213
+ anchor.lineBounds = 'profile';
214
+ break;
215
+ case 'visible':
216
+ data = [...rows];
217
+ break;
218
+ default:
219
+ data = [...rows];
220
+ anchor.variant = 'session';
221
+ anchor.session = session;
222
+ }
223
+ const bucketWidth = bucketWidthOf(rows);
224
+ const rowHeight = profile.row_height ?? 'auto';
225
+ const multiplier = rowHeight === 'auto' ? profileRowMultiplier('session', intervalLabel) : undefined;
226
+ const barHeight = rowHeight === 'auto' ? (bucketWidth === undefined ? undefined : bucketWidth * (multiplier ?? 1)) : rowHeight;
227
+ const dockLeft = (profile.dock ?? (span === 'visible' ? 'right' : 'left')) === 'left';
228
+ const widthFrac = profile.width_frac ?? (span === 'session' || span === 'range' ? 0.7 : 0.2);
229
+ const mode = profile.mode ?? 'stacked_bar';
230
+ const extend = profile.extend ?? (span === 'developing' ? 'right' : 'none');
231
+ const levelLabels = profile.level_labels ?? false;
232
+ const naked = profile.naked ?? false;
233
+ const background = profile.background ?? false;
234
+ const fontFamily = wrunFontFamilyCss(profile.font_family);
235
+ const settings = {
236
+ ...anchor,
237
+ displayMode: WRUN_PROFILE_DISPLAY_MODES[mode],
238
+ showDelta: mode === 'delta',
239
+ ...(profile.buy_color !== undefined || profile.sell_color !== undefined
240
+ ? { colors: [profile.buy_color ?? 'theme.up', profile.sell_color ?? 'theme.down'] }
241
+ : {}),
242
+ stickToLeft: dockLeft,
243
+ barWidth: widthFrac,
244
+ ...(bucketWidth !== undefined ? { minimumBarHeight: bucketWidth, digits: decimalsOf(bucketWidth) } : {}),
245
+ ...(barHeight !== undefined ? { barHeight } : {}),
246
+ ...(barHeight !== undefined && bucketWidth !== undefined ? { barHeightMultiplier: barHeight / bucketWidth } : {}),
247
+ showValueArea: true,
248
+ valueArea: profile.value_area ?? 0.7,
249
+ valueAreaContrast: profile.value_area_shade ?? true,
250
+ ...(profile.outside_buy_color !== undefined ? { outsideVABuyColor: profile.outside_buy_color } : {}),
251
+ ...(profile.outside_sell_color !== undefined ? { outsideVASellColor: profile.outside_sell_color } : {}),
252
+ showPOC: profile.poc ?? true,
253
+ pocColor: profile.poc_color ?? WRUN_PROFILE_LEVEL_COLOR,
254
+ pocThickness: profile.poc_width ?? 1,
255
+ showVAH: profile.vah ?? true,
256
+ showVAL: profile.val ?? true,
257
+ vahColor: profile.vah_color ?? WRUN_PROFILE_LEVEL_COLOR,
258
+ valColor: profile.val_color ?? WRUN_PROFILE_LEVEL_COLOR,
259
+ showPOCLabel: levelLabels,
260
+ showVAHLabel: levelLabels,
261
+ showVALLabel: levelLabels,
262
+ showPOCNaked: naked,
263
+ showVAHNaked: naked,
264
+ showVALNaked: naked,
265
+ lineExtend: extend === 'right',
266
+ behindCandles: profile.behind_candles ?? false,
267
+ showBackground: background,
268
+ ...(background
269
+ ? {
270
+ backgroundColor: wordAtOpacity(profile.background_color ?? WRUN_PROFILE_BACKGROUND_COLOR, profile.background_opacity ?? WRUN_PROFILE_BACKGROUND_OPACITY),
271
+ }
272
+ : {}),
273
+ ...(fontFamily !== undefined ? { fontFamily } : {}),
274
+ ...(profile.font_weight !== undefined ? { fontWeight: profile.font_weight } : {}),
275
+ cellHover: profile.cell_hover ?? true,
276
+ };
277
+ return { kind: 'profile', name: profile.name, data, settings };
278
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@orangecharts/wrun-chart-host",
3
+ "version": "0.1.0",
4
+ "description": "The wrun chart-host layer shared by the kiyotaka web app and the mobile app: the wrun result reader and painter model, cut from the web app (its reference implementation).",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "./*": {
17
+ "types": "./dist/*.d.ts",
18
+ "default": "./dist/*.js"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "build": "rm -rf dist && tsc -p tsconfig.build.json && node scripts/esm-dist.mjs dist",
23
+ "consumer-check": "node scripts/consumer-check.mjs",
24
+ "typecheck": "tsc -p tsconfig.json --noEmit"
25
+ },
26
+ "peerDependencies": {
27
+ "@orangecharts/indicator-kit": "0.78.1",
28
+ "dayjs": "1.11.23",
29
+ "lodash-es": "4.18.1"
30
+ },
31
+ "devDependencies": {
32
+ "@orangecharts/indicator-kit": "0.78.1",
33
+ "@types/lodash-es": "4.17.12",
34
+ "dayjs": "1.11.23",
35
+ "lodash-es": "4.18.1",
36
+ "typescript": "5.9.3"
37
+ }
38
+ }