@363045841yyt/klinechart-core 0.7.6 → 0.7.7

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 (191) hide show
  1. package/dist/config/chartSettings.d.ts +27 -2
  2. package/dist/config/chartSettings.d.ts.map +1 -1
  3. package/dist/config/chartSettings.js +6 -0
  4. package/dist/config/chartSettings.js.map +1 -1
  5. package/dist/engine/chart.d.ts.map +1 -1
  6. package/dist/engine/chart.js +4 -0
  7. package/dist/engine/chart.js.map +1 -1
  8. package/dist/engine/draw/pixelAlign.d.ts.map +1 -1
  9. package/dist/engine/draw/pixelAlign.js.map +1 -1
  10. package/dist/engine/drawing/plugin.js +1 -1
  11. package/dist/engine/drawing/plugin.js.map +1 -1
  12. package/dist/engine/renderers/Indicator/atr.d.ts.map +1 -1
  13. package/dist/engine/renderers/Indicator/atr.js +7 -4
  14. package/dist/engine/renderers/Indicator/atr.js.map +1 -1
  15. package/dist/engine/renderers/Indicator/boll.js +12 -12
  16. package/dist/engine/renderers/Indicator/boll.js.map +1 -1
  17. package/dist/engine/renderers/Indicator/cci.d.ts +1 -2
  18. package/dist/engine/renderers/Indicator/cci.d.ts.map +1 -1
  19. package/dist/engine/renderers/Indicator/cci.js +9 -9
  20. package/dist/engine/renderers/Indicator/cci.js.map +1 -1
  21. package/dist/engine/renderers/Indicator/ene.js +12 -12
  22. package/dist/engine/renderers/Indicator/ene.js.map +1 -1
  23. package/dist/engine/renderers/Indicator/expma.js +6 -6
  24. package/dist/engine/renderers/Indicator/expma.js.map +1 -1
  25. package/dist/engine/renderers/Indicator/fastk.d.ts +1 -2
  26. package/dist/engine/renderers/Indicator/fastk.d.ts.map +1 -1
  27. package/dist/engine/renderers/Indicator/fastk.js +7 -7
  28. package/dist/engine/renderers/Indicator/fastk.js.map +1 -1
  29. package/dist/engine/renderers/Indicator/kst.d.ts +1 -2
  30. package/dist/engine/renderers/Indicator/kst.d.ts.map +1 -1
  31. package/dist/engine/renderers/Indicator/kst.js +10 -10
  32. package/dist/engine/renderers/Indicator/kst.js.map +1 -1
  33. package/dist/engine/renderers/Indicator/ma.js +5 -5
  34. package/dist/engine/renderers/Indicator/ma.js.map +1 -1
  35. package/dist/engine/renderers/Indicator/macd.d.ts +1 -2
  36. package/dist/engine/renderers/Indicator/macd.d.ts.map +1 -1
  37. package/dist/engine/renderers/Indicator/macd.js +24 -24
  38. package/dist/engine/renderers/Indicator/macd.js.map +1 -1
  39. package/dist/engine/renderers/Indicator/macdLegend.js +6 -6
  40. package/dist/engine/renderers/Indicator/macdLegend.js.map +1 -1
  41. package/dist/engine/renderers/Indicator/mainIndicatorLegend.js +16 -16
  42. package/dist/engine/renderers/Indicator/mainIndicatorLegend.js.map +1 -1
  43. package/dist/engine/renderers/Indicator/mom.d.ts +1 -2
  44. package/dist/engine/renderers/Indicator/mom.d.ts.map +1 -1
  45. package/dist/engine/renderers/Indicator/mom.js +8 -8
  46. package/dist/engine/renderers/Indicator/mom.js.map +1 -1
  47. package/dist/engine/renderers/Indicator/rsi.d.ts +2 -3
  48. package/dist/engine/renderers/Indicator/rsi.d.ts.map +1 -1
  49. package/dist/engine/renderers/Indicator/rsi.js +15 -15
  50. package/dist/engine/renderers/Indicator/rsi.js.map +1 -1
  51. package/dist/engine/renderers/Indicator/scale/indicator_scale.d.ts +1 -2
  52. package/dist/engine/renderers/Indicator/scale/indicator_scale.d.ts.map +1 -1
  53. package/dist/engine/renderers/Indicator/scale/indicator_scale.js +5 -5
  54. package/dist/engine/renderers/Indicator/scale/indicator_scale.js.map +1 -1
  55. package/dist/engine/renderers/Indicator/stoch.d.ts +1 -2
  56. package/dist/engine/renderers/Indicator/stoch.d.ts.map +1 -1
  57. package/dist/engine/renderers/Indicator/stoch.js +10 -10
  58. package/dist/engine/renderers/Indicator/stoch.js.map +1 -1
  59. package/dist/engine/renderers/Indicator/structure.js +5 -5
  60. package/dist/engine/renderers/Indicator/structure.js.map +1 -1
  61. package/dist/engine/renderers/Indicator/wmsr.d.ts +1 -2
  62. package/dist/engine/renderers/Indicator/wmsr.d.ts.map +1 -1
  63. package/dist/engine/renderers/Indicator/wmsr.js +10 -10
  64. package/dist/engine/renderers/Indicator/wmsr.js.map +1 -1
  65. package/dist/engine/renderers/Indicator/zones.js +6 -6
  66. package/dist/engine/renderers/Indicator/zones.js.map +1 -1
  67. package/dist/engine/renderers/candle.d.ts +1 -1
  68. package/dist/engine/renderers/candle.d.ts.map +1 -1
  69. package/dist/engine/renderers/candle.js +21 -21
  70. package/dist/engine/renderers/candle.js.map +1 -1
  71. package/dist/engine/renderers/crosshair.js +3 -3
  72. package/dist/engine/renderers/crosshair.js.map +1 -1
  73. package/dist/engine/renderers/extremaMarkers.d.ts.map +1 -1
  74. package/dist/engine/renderers/extremaMarkers.js +12 -12
  75. package/dist/engine/renderers/extremaMarkers.js.map +1 -1
  76. package/dist/engine/renderers/gridLines.js +3 -3
  77. package/dist/engine/renderers/gridLines.js.map +1 -1
  78. package/dist/engine/renderers/lastPrice.js +7 -7
  79. package/dist/engine/renderers/lastPrice.js.map +1 -1
  80. package/dist/engine/renderers/paneTitle.js +6 -6
  81. package/dist/engine/renderers/paneTitle.js.map +1 -1
  82. package/dist/engine/renderers/subVolume.d.ts.map +1 -1
  83. package/dist/engine/renderers/subVolume.js +23 -20
  84. package/dist/engine/renderers/subVolume.js.map +1 -1
  85. package/dist/engine/renderers/timeAxis.js +9 -9
  86. package/dist/engine/renderers/timeAxis.js.map +1 -1
  87. package/dist/engine/renderers/webgl/candleSurface.d.ts.map +1 -1
  88. package/dist/engine/renderers/webgl/candleSurface.js +39 -7
  89. package/dist/engine/renderers/webgl/candleSurface.js.map +1 -1
  90. package/dist/engine/renderers/yAxis.d.ts.map +1 -1
  91. package/dist/engine/renderers/yAxis.js +5 -5
  92. package/dist/engine/renderers/yAxis.js.map +1 -1
  93. package/dist/index.d.ts +1 -0
  94. package/dist/index.d.ts.map +1 -1
  95. package/dist/index.js +1 -0
  96. package/dist/index.js.map +1 -1
  97. package/dist/plugin/types.d.ts +5 -1
  98. package/dist/plugin/types.d.ts.map +1 -1
  99. package/dist/plugin/types.js.map +1 -1
  100. package/dist/tokens/colorPresetSettings.d.ts +15 -0
  101. package/dist/tokens/colorPresetSettings.d.ts.map +1 -0
  102. package/dist/tokens/colorPresetSettings.js +65 -0
  103. package/dist/tokens/colorPresetSettings.js.map +1 -0
  104. package/dist/tokens/index.d.ts +17 -0
  105. package/dist/tokens/index.d.ts.map +1 -0
  106. package/dist/tokens/index.js +16 -0
  107. package/dist/tokens/index.js.map +1 -0
  108. package/dist/tokens/mergeTheme.d.ts +17 -0
  109. package/dist/tokens/mergeTheme.d.ts.map +1 -0
  110. package/dist/tokens/mergeTheme.js +43 -0
  111. package/dist/tokens/mergeTheme.js.map +1 -0
  112. package/dist/tokens/theme-china.d.ts +45 -0
  113. package/dist/tokens/theme-china.d.ts.map +1 -0
  114. package/dist/tokens/theme-china.js +116 -0
  115. package/dist/tokens/theme-china.js.map +1 -0
  116. package/dist/tokens/theme-dark.d.ts +21 -0
  117. package/dist/tokens/theme-dark.d.ts.map +1 -0
  118. package/dist/tokens/theme-dark.js +228 -0
  119. package/dist/tokens/theme-dark.js.map +1 -0
  120. package/dist/tokens/theme-light.d.ts +23 -0
  121. package/dist/tokens/theme-light.d.ts.map +1 -0
  122. package/dist/tokens/theme-light.js +234 -0
  123. package/dist/tokens/theme-light.js.map +1 -0
  124. package/dist/tokens/themeToCssVars.d.ts +74 -0
  125. package/dist/tokens/themeToCssVars.d.ts.map +1 -0
  126. package/dist/tokens/themeToCssVars.js +108 -0
  127. package/dist/tokens/themeToCssVars.js.map +1 -0
  128. package/dist/tokens/types.d.ts +335 -0
  129. package/dist/tokens/types.d.ts.map +1 -0
  130. package/dist/tokens/types.js +20 -0
  131. package/dist/tokens/types.js.map +1 -0
  132. package/dist/utils/kLineDraw/axis.d.ts +8 -7
  133. package/dist/utils/kLineDraw/axis.d.ts.map +1 -1
  134. package/dist/utils/kLineDraw/axis.js +24 -24
  135. package/dist/utils/kLineDraw/axis.js.map +1 -1
  136. package/dist/version.d.ts +1 -1
  137. package/dist/version.js +1 -1
  138. package/package.json +1 -1
  139. package/src/config/chartSettings.ts +11 -2
  140. package/src/engine/chart.ts +4 -0
  141. package/src/engine/draw/pixelAlign.ts +0 -2
  142. package/src/engine/drawing/plugin.ts +1 -1
  143. package/src/engine/renderers/Indicator/atr.ts +7 -3
  144. package/src/engine/renderers/Indicator/boll.ts +12 -12
  145. package/src/engine/renderers/Indicator/cci.ts +11 -10
  146. package/src/engine/renderers/Indicator/ene.ts +12 -12
  147. package/src/engine/renderers/Indicator/expma.ts +6 -6
  148. package/src/engine/renderers/Indicator/fastk.ts +9 -8
  149. package/src/engine/renderers/Indicator/kst.ts +12 -11
  150. package/src/engine/renderers/Indicator/ma.ts +5 -5
  151. package/src/engine/renderers/Indicator/macd.ts +27 -25
  152. package/src/engine/renderers/Indicator/macdLegend.ts +6 -6
  153. package/src/engine/renderers/Indicator/mainIndicatorLegend.ts +16 -16
  154. package/src/engine/renderers/Indicator/mom.ts +11 -10
  155. package/src/engine/renderers/Indicator/rsi.ts +18 -15
  156. package/src/engine/renderers/Indicator/scale/indicator_scale.ts +6 -6
  157. package/src/engine/renderers/Indicator/stoch.ts +12 -11
  158. package/src/engine/renderers/Indicator/structure.ts +5 -5
  159. package/src/engine/renderers/Indicator/wmsr.ts +13 -12
  160. package/src/engine/renderers/Indicator/zones.ts +7 -7
  161. package/src/engine/renderers/candle.ts +21 -21
  162. package/src/engine/renderers/crosshair.ts +3 -3
  163. package/src/engine/renderers/extremaMarkers.ts +13 -12
  164. package/src/engine/renderers/gridLines.ts +3 -3
  165. package/src/engine/renderers/lastPrice.ts +7 -7
  166. package/src/engine/renderers/paneTitle.ts +6 -6
  167. package/src/engine/renderers/subVolume.ts +23 -20
  168. package/src/engine/renderers/timeAxis.ts +9 -9
  169. package/src/engine/renderers/webgl/candleSurface.ts +43 -7
  170. package/src/engine/renderers/yAxis.ts +6 -5
  171. package/src/index.ts +1 -0
  172. package/src/plugin/types.ts +5 -1
  173. package/src/tokens/__tests__/__snapshots__/baseline.test.ts.snap +393 -0
  174. package/src/tokens/__tests__/baseline.test.ts +183 -0
  175. package/src/tokens/__tests__/themeToCssVars.test.ts +175 -0
  176. package/src/tokens/__tests__/tokens.test.ts +215 -0
  177. package/src/tokens/colorPresetSettings.ts +128 -0
  178. package/src/tokens/index.ts +65 -0
  179. package/src/tokens/mergeTheme.ts +48 -0
  180. package/src/tokens/theme-china.ts +132 -0
  181. package/src/tokens/theme-dark.ts +244 -0
  182. package/src/tokens/theme-light.ts +250 -0
  183. package/src/tokens/themeToCssVars.ts +138 -0
  184. package/src/tokens/types.ts +394 -0
  185. package/src/utils/kLineDraw/axis.ts +31 -30
  186. package/src/version.ts +1 -1
  187. package/dist/engine/theme/colors.d.ts +0 -223
  188. package/dist/engine/theme/colors.d.ts.map +0 -1
  189. package/dist/engine/theme/colors.js +0 -375
  190. package/dist/engine/theme/colors.js.map +0 -1
  191. package/src/engine/theme/colors.ts +0 -642
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Theme → CSS custom-property emitter.
3
+ *
4
+ * Bridges the typed tokens in `theme-light.ts` / `theme-dark.ts` to the
5
+ * actual stylesheet, so any framework can apply a theme by inserting a
6
+ * `:root { ... }` block or attaching a `style="..."` attribute.
7
+ *
8
+ * Naming convention (kebab-case, dot-paths flattened with `-`):
9
+ *
10
+ * Theme key CSS variable
11
+ * ─────────────────────────────────────── ────────────────────────────
12
+ * colors.background `--klc-color-background`
13
+ * colors.candleUpBody `--klc-color-candle-up-body`
14
+ * colors.palette.i1 `--klc-color-palette-i1`
15
+ * spacing.md `--klc-spacing-md`
16
+ * typography.fontFamily `--klc-typography-font-family`
17
+ * typography.fontWeightRegular `--klc-typography-font-weight-regular`
18
+ * motion.durationFast `--klc-motion-duration-fast`
19
+ *
20
+ * Numeric tokens (font weights, line heights) emit as strings — CSS doesn't
21
+ * care, and consumers consume them through `var(...)` so the type tag is
22
+ * lost in the round-trip anyway.
23
+ *
24
+ * Prefix is configurable. Default `--klc-` (KLineChart Quant) is short
25
+ * enough to type and unique enough to coexist with other token systems
26
+ * (Tailwind, MUI, Radix) on the same page.
27
+ */
28
+
29
+ import type { Theme } from './types'
30
+
31
+ export interface ThemeToCssVarsOptions {
32
+ /**
33
+ * CSS custom-property prefix. Default `'--klc-'`. Must start with `--`.
34
+ * Including the trailing dash is recommended (kebab-case continues
35
+ * cleanly from there).
36
+ */
37
+ readonly prefix?: string
38
+ }
39
+
40
+ const DEFAULT_PREFIX = '--klc-'
41
+
42
+ /**
43
+ * camelCase → kebab-case.
44
+ *
45
+ * 'candleUpBody' → 'candle-up-body'
46
+ * 'fontWeightRegular' → 'font-weight-regular'
47
+ * 'i1' → 'i1' (already kebab-safe)
48
+ */
49
+ export function camelToKebab(s: string): string {
50
+ return s.replace(/[A-Z]/g, (m, i) => (i === 0 ? m.toLowerCase() : '-' + m.toLowerCase()))
51
+ }
52
+
53
+ function flattenColors(
54
+ colors: Theme['colors'],
55
+ prefix: string,
56
+ ): Record<string, string> {
57
+ const out: Record<string, string> = {}
58
+ for (const [k, v] of Object.entries(colors)) {
59
+ if (typeof v === 'object' && v !== null) {
60
+ const ns = camelToKebab(k)
61
+ for (const [nk, nv] of Object.entries(v as Record<string, string>)) {
62
+ out[`${prefix}color-${ns}-${camelToKebab(nk)}`] = nv
63
+ }
64
+ } else {
65
+ out[`${prefix}color-${camelToKebab(k)}`] = v as string
66
+ }
67
+ }
68
+ return out
69
+ }
70
+
71
+ function flattenFamily(
72
+ family: Record<string, string | number>,
73
+ prefix: string,
74
+ namespace: string,
75
+ ): Record<string, string> {
76
+ const out: Record<string, string> = {}
77
+ for (const [k, v] of Object.entries(family)) {
78
+ out[`${prefix}${namespace}-${camelToKebab(k)}`] = String(v)
79
+ }
80
+ return out
81
+ }
82
+
83
+ /**
84
+ * Emit a `{ [cssVarName]: value }` map for the given theme.
85
+ *
86
+ * Hand the result to:
87
+ *
88
+ * - React: `<div style={vars as React.CSSProperties}>...`
89
+ * - Vue: `:style="vars"`
90
+ * - Angular: `[ngStyle]="vars"`
91
+ * - Vanilla: `Object.assign(el.style, vars)` or emit
92
+ * `':root { ... }'` directly via {@link toCssDeclarationBlock}.
93
+ *
94
+ * The shape is stable: the same theme produces the same map across calls,
95
+ * and `mergeTheme(base, override)` produces a superset emit (keys are the
96
+ * same; values may differ).
97
+ */
98
+ export function themeToCssVars(
99
+ theme: Theme,
100
+ opts?: ThemeToCssVarsOptions,
101
+ ): Record<string, string> {
102
+ const prefix = opts?.prefix ?? DEFAULT_PREFIX
103
+ if (!prefix.startsWith('--')) {
104
+ // Misuse caught here is much friendlier than the silent no-op CSS
105
+ // would give downstream.
106
+ throw new Error(
107
+ `themeToCssVars: prefix must start with '--', got ${JSON.stringify(prefix)}`,
108
+ )
109
+ }
110
+ return {
111
+ ...flattenColors(theme.colors, prefix),
112
+ ...flattenFamily(theme.spacing as unknown as Record<string, string>, prefix, 'spacing'),
113
+ ...flattenFamily(theme.typography as unknown as Record<string, string | number>, prefix, 'typography'),
114
+ ...flattenFamily(theme.motion as unknown as Record<string, string>, prefix, 'motion'),
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Render the emitted map as a `:root { ... }` CSS declaration block.
120
+ * Useful for SSR scenarios where you want to inject a `<style>` element
121
+ * server-side so the first paint already carries the theme.
122
+ *
123
+ * const css = toCssDeclarationBlock(themeToCssVars(darkTheme))
124
+ * // → ":root {\n --klc-color-background: #0E1116;\n ...\n}"
125
+ *
126
+ * The selector defaults to `:root` but can be overridden — common
127
+ * alternatives are `[data-theme="dark"]` for runtime theme switching
128
+ * or `.klc-theme-dark` for scoped overrides.
129
+ */
130
+ export function toCssDeclarationBlock(
131
+ vars: Record<string, string>,
132
+ selector: string = ':root',
133
+ ): string {
134
+ const decls = Object.entries(vars)
135
+ .map(([k, v]) => ` ${k}: ${v};`)
136
+ .join('\n')
137
+ return `${selector} {\n${decls}\n}`
138
+ }
@@ -0,0 +1,394 @@
1
+ /**
2
+ * Design token contract — the typed surface every theme must satisfy.
3
+ *
4
+ * Tokens are **semantic** (named by role: `candleUpBody`, not by value:
5
+ * `green500`). Themes are concrete `Record<TokenKey, string>` objects
6
+ * conforming to {@link Theme}. Two presets ship: {@link lightTheme}
7
+ * and {@link darkTheme}. Consumers compose their own theme by spreading
8
+ * a preset and overriding the keys they care about.
9
+ *
10
+ * Rationale: TradingView's customisation surface is ad-hoc settings
11
+ * sprawl. A token contract is the foundation for (1) a coherent default
12
+ * look, (2) a no-code theme editor, (3) visual regression baselines,
13
+ * and (4) WCAG audits that run in CI.
14
+ *
15
+ * Scope of v1: chart-visible roles only. We do **not** ship UI-chrome
16
+ * tokens (button colors, modal background, etc.) — those live with the
17
+ * host app. The contract is the chart canvas surface.
18
+ */
19
+
20
+ /**
21
+ * Concrete color value. Always a CSS color string — `#rrggbb`, `#rrggbbaa`,
22
+ * `rgb(...)`, `rgba(...)`, or named CSS color. Themes typically use 6- or
23
+ * 8-digit hex for renderer-friendly parsing.
24
+ */
25
+ export type ColorValue = string
26
+
27
+ /**
28
+ * CSS length. Always a string with a unit (`'8px'`, `'0.5rem'`, `'1.25em'`).
29
+ * Renderers parse with the host CSSOM; bench-time renderers may use a
30
+ * px-only fast path.
31
+ */
32
+ export type CssLength = string
33
+
34
+ /**
35
+ * CSS duration string (`'120ms'`, `'0.2s'`). For motion tokens.
36
+ */
37
+ export type CssDuration = string
38
+
39
+ /**
40
+ * CSS easing function (`'ease-out'`, `'cubic-bezier(0.4, 0, 0.2, 1)'`).
41
+ */
42
+ export type CssEasing = string
43
+
44
+ /**
45
+ * Indicator palette. Ten distinguishable colors for overlay/separate-pane
46
+ * indicators (MA1, MA2, ..., MA10). The palette is *qualitative* — perceptual
47
+ * distance optimised for category distinction, not for ordinal scale. WCAG
48
+ * AA contrast against both light- and dark-pane backgrounds.
49
+ */
50
+ export interface IndicatorPalette {
51
+ readonly i1: ColorValue
52
+ readonly i2: ColorValue
53
+ readonly i3: ColorValue
54
+ readonly i4: ColorValue
55
+ readonly i5: ColorValue
56
+ readonly i6: ColorValue
57
+ readonly i7: ColorValue
58
+ readonly i8: ColorValue
59
+ readonly i9: ColorValue
60
+ readonly i10: ColorValue
61
+ readonly indicatorAtr: ColorValue
62
+ }
63
+
64
+ /**
65
+ * Semantic color roles every renderable surface element claims.
66
+ *
67
+ * "Up" / "Down" is the bull / bear axis. We deliberately do **not**
68
+ * call them green / red — Asian markets use the opposite convention
69
+ * and the token must let that flip with a single override.
70
+ */
71
+ /**
72
+ * Text colors — importance levels for UI labels & annotations.
73
+ */
74
+ export interface TextColors {
75
+ readonly primary: ColorValue
76
+ readonly secondary: ColorValue
77
+ readonly tertiary: ColorValue
78
+ readonly weak: ColorValue
79
+ readonly white: ColorValue
80
+ }
81
+
82
+ /**
83
+ * Price accent colors — tick highlights, last-price marker, etc.
84
+ * The main up/down body colors live on the top-level ColorTokens
85
+ * (candleUpBody / candleDownBody); this group covers extras.
86
+ */
87
+ export interface PriceColors {
88
+ readonly upLight: ColorValue
89
+ readonly upTick: ColorValue
90
+ readonly downLight: ColorValue
91
+ readonly downTick: ColorValue
92
+ readonly lastPrice: ColorValue
93
+ }
94
+
95
+ /**
96
+ * Tag / label background colours — toolbar buttons, active states.
97
+ */
98
+ export interface TagBgColors {
99
+ readonly white: ColorValue
100
+ readonly lightGray: ColorValue
101
+ readonly pureWhite: ColorValue
102
+ readonly transparent: ColorValue
103
+ readonly active: ColorValue
104
+ readonly activeHover: ColorValue
105
+ readonly hover: ColorValue
106
+ }
107
+
108
+ /**
109
+ * Border / stroke colours for UI chrome.
110
+ */
111
+ export interface BorderColors {
112
+ readonly dark: ColorValue
113
+ readonly medium: ColorValue
114
+ readonly light: ColorValue
115
+ readonly separator: ColorValue
116
+ readonly button: ColorValue
117
+ readonly chart: ColorValue
118
+ }
119
+
120
+ /** Moving-average line colours (MA5 / MA10 / MA20 / MA30 / MA60). */
121
+ export interface MAColors {
122
+ readonly ma5: ColorValue
123
+ readonly ma10: ColorValue
124
+ readonly ma20: ColorValue
125
+ readonly ma30: ColorValue
126
+ readonly ma60: ColorValue
127
+ }
128
+
129
+ /** Bollinger Bands stroke & fill colours. */
130
+ export interface BOLLColors {
131
+ readonly upper: ColorValue
132
+ readonly middle: ColorValue
133
+ readonly lower: ColorValue
134
+ readonly bandFill: ColorValue
135
+ }
136
+
137
+ /** MACD indicator colours. */
138
+ export interface MACDColors {
139
+ readonly dif: ColorValue
140
+ readonly dea: ColorValue
141
+ readonly barUp: ColorValue
142
+ readonly barUpLight: ColorValue
143
+ readonly barDown: ColorValue
144
+ readonly barDownLight: ColorValue
145
+ }
146
+
147
+ /** RSI indicator colours. */
148
+ export interface RSIColors {
149
+ readonly rsi1: ColorValue
150
+ readonly rsi2: ColorValue
151
+ readonly rsi3: ColorValue
152
+ }
153
+
154
+ /** CCI indicator colours. */
155
+ export interface CCIColors {
156
+ readonly cci: ColorValue
157
+ readonly overbought: ColorValue
158
+ readonly oversold: ColorValue
159
+ }
160
+
161
+ /** KDJ / Stochastic indicator colours. */
162
+ export interface KDJColors {
163
+ readonly k: ColorValue
164
+ readonly d: ColorValue
165
+ readonly j: ColorValue
166
+ }
167
+
168
+ /** MOM (Momentum) indicator colours. */
169
+ export interface MOMColors {
170
+ readonly mom: ColorValue
171
+ readonly zero: ColorValue
172
+ }
173
+
174
+ /** WMSR (Williams %R) indicator colours. */
175
+ export interface WMSRColors {
176
+ readonly wmsr: ColorValue
177
+ readonly overbought: ColorValue
178
+ readonly oversold: ColorValue
179
+ }
180
+
181
+ /** KST (Know Sure Thing) indicator colours. */
182
+ export interface KSTColors {
183
+ readonly kst: ColorValue
184
+ readonly signal: ColorValue
185
+ }
186
+
187
+ /** EXPMA (Exponential MA) indicator colours. */
188
+ export interface EXPMAColors {
189
+ readonly fast: ColorValue
190
+ readonly slow: ColorValue
191
+ }
192
+
193
+ /** ENE (Envelope) indicator colours. */
194
+ export interface ENEColors {
195
+ readonly upper: ColorValue
196
+ readonly middle: ColorValue
197
+ readonly lower: ColorValue
198
+ readonly bandFill: ColorValue
199
+ }
200
+
201
+ /** Generic label colours (tooltip-like overlays). */
202
+ export interface LabelColors {
203
+ readonly bg: ColorValue
204
+ readonly text: ColorValue
205
+ }
206
+
207
+ /** Last-price marker label colours. */
208
+ export interface LastPriceLabelColors {
209
+ readonly bg: ColorValue
210
+ }
211
+
212
+ /** Volume-price relationship markers. */
213
+ export interface VolumePriceColors {
214
+ readonly riseWith: ColorValue
215
+ readonly riseWithout: ColorValue
216
+ readonly fallWith: ColorValue
217
+ readonly fallWithout: ColorValue
218
+ }
219
+
220
+ /** Structure (SMC) indicator — HH/HL/LH/LL/CHoCH/BOS. */
221
+ export interface StructureColors {
222
+ readonly hh: ColorValue
223
+ readonly hl: ColorValue
224
+ readonly lh: ColorValue
225
+ readonly ll: ColorValue
226
+ readonly choch: ColorValue
227
+ readonly bos: ColorValue
228
+ }
229
+
230
+ /** Zones / FVG / Order-Block indicator colours. */
231
+ export interface ZonesColors {
232
+ readonly fvgBullFill: ColorValue
233
+ readonly fvgBearFill: ColorValue
234
+ readonly fvgBullBorder: ColorValue
235
+ readonly fvgBearBorder: ColorValue
236
+ readonly obBullFill: ColorValue
237
+ readonly obBearFill: ColorValue
238
+ }
239
+
240
+ export interface ColorTokens {
241
+ // Chart-wide background + foreground
242
+ readonly background: ColorValue
243
+ readonly foreground: ColorValue
244
+ readonly chartBackground: ColorValue
245
+
246
+ // Candle / OHLC bar
247
+ readonly candleUpBody: ColorValue
248
+ readonly candleUpBorder: ColorValue
249
+ readonly candleUpWick: ColorValue
250
+ readonly candleDownBody: ColorValue
251
+ readonly candleDownBorder: ColorValue
252
+ readonly candleDownWick: ColorValue
253
+ readonly candleDojiBorder: ColorValue
254
+
255
+ // Volume bars (paired with candle bull/bear)
256
+ readonly volumeUp: ColorValue
257
+ readonly volumeDown: ColorValue
258
+
259
+ // Price + time axes
260
+ readonly axisText: ColorValue
261
+ readonly axisLine: ColorValue
262
+ readonly axisTick: ColorValue
263
+
264
+ // Grid
265
+ readonly gridMajor: ColorValue
266
+ readonly gridMinor: ColorValue
267
+
268
+ // Crosshair
269
+ readonly crosshairLine: ColorValue
270
+ readonly crosshairLabelBg: ColorValue
271
+ readonly crosshairLabelText: ColorValue
272
+
273
+ // Selection / hover
274
+ readonly selectionFill: ColorValue
275
+ readonly selectionStroke: ColorValue
276
+
277
+ // Tooltip / legend
278
+ readonly tooltipBg: ColorValue
279
+ readonly tooltipText: ColorValue
280
+ readonly tooltipBorder: ColorValue
281
+
282
+ // Footprint / heatmap / volume profile (specialised components)
283
+ readonly heatmapColdest: ColorValue
284
+ readonly heatmapHottest: ColorValue
285
+ readonly volumeProfileFill: ColorValue
286
+ readonly volumeProfilePoc: ColorValue
287
+ readonly volumeProfileValueArea: ColorValue
288
+ readonly footprintAsk: ColorValue
289
+ readonly footprintBid: ColorValue
290
+ readonly footprintImbalance: ColorValue
291
+
292
+ // Alerts
293
+ readonly alertActive: ColorValue
294
+ readonly alertTriggered: ColorValue
295
+ readonly alertMuted: ColorValue
296
+
297
+ // Anchored VWAP / MTF overlay accents
298
+ readonly avwapLine: ColorValue
299
+ readonly avwapBand: ColorValue
300
+ readonly mtfOverlay: ColorValue
301
+
302
+ // Indicator palette (composes ColorTokens)
303
+ readonly palette: IndicatorPalette
304
+
305
+ // ── Legacy indicator colours (from engine/theme/colors) ──
306
+ readonly text: TextColors
307
+ readonly price: PriceColors
308
+ readonly tagBg: TagBgColors
309
+ readonly border: BorderColors
310
+ readonly ma: MAColors
311
+ readonly boll: BOLLColors
312
+ readonly macd: MACDColors
313
+ readonly rsi: RSIColors
314
+ readonly cci: CCIColors
315
+ readonly kdj: KDJColors
316
+ readonly mom: MOMColors
317
+ readonly wmsr: WMSRColors
318
+ readonly kst: KSTColors
319
+ readonly expma: EXPMAColors
320
+ readonly ene: ENEColors
321
+ readonly label: LabelColors
322
+ readonly lastPriceLabel: LastPriceLabelColors
323
+ readonly volumePrice: VolumePriceColors
324
+ readonly structure: StructureColors
325
+ readonly zones: ZonesColors
326
+ readonly wmsrGrid: ColorValue
327
+ }
328
+
329
+ /**
330
+ * Spatial rhythm. All tokens are CSS length strings with units; renderers
331
+ * parse to px at apply time. The progression is a 4-px base scale that
332
+ * scales linearly up to 32px, then doubles.
333
+ */
334
+ export interface SpacingTokens {
335
+ readonly none: CssLength // '0'
336
+ readonly xxs: CssLength // '2px'
337
+ readonly xs: CssLength // '4px'
338
+ readonly sm: CssLength // '8px'
339
+ readonly md: CssLength // '12px'
340
+ readonly lg: CssLength // '16px'
341
+ readonly xl: CssLength // '24px'
342
+ readonly xxl: CssLength // '32px'
343
+ readonly xxxl: CssLength // '64px'
344
+ }
345
+
346
+ /**
347
+ * Typography stack. Renderers compose a font shorthand from these.
348
+ */
349
+ export interface TypographyTokens {
350
+ readonly fontFamily: string // Includes fallbacks
351
+ readonly fontFamilyMono: string // For numeric tick labels
352
+ readonly fontSizeSm: CssLength // '10px' (axis ticks)
353
+ readonly fontSizeMd: CssLength // '12px' (default body)
354
+ readonly fontSizeLg: CssLength // '14px' (legends)
355
+ readonly fontWeightRegular: number // 400
356
+ readonly fontWeightMedium: number // 500
357
+ readonly fontWeightBold: number // 700
358
+ readonly lineHeightTight: number // 1.2
359
+ readonly lineHeightStandard: number // 1.4
360
+ }
361
+
362
+ /**
363
+ * Animation. We use them sparingly (zoom inertia, crosshair fade)
364
+ * but the tokens exist so the same easing is reused everywhere.
365
+ */
366
+ export interface MotionTokens {
367
+ readonly durationInstant: CssDuration // '0ms' (default for finance — no jitter)
368
+ readonly durationFast: CssDuration // '120ms'
369
+ readonly durationModerate: CssDuration // '200ms'
370
+ readonly easingStandard: CssEasing // 'cubic-bezier(0.4, 0, 0.2, 1)'
371
+ readonly easingDecelerate: CssEasing // 'cubic-bezier(0, 0, 0.2, 1)'
372
+ }
373
+
374
+ /**
375
+ * Complete theme — all four token families.
376
+ */
377
+ export interface Theme {
378
+ readonly name: string
379
+ readonly colors: ColorTokens
380
+ readonly spacing: SpacingTokens
381
+ readonly typography: TypographyTokens
382
+ readonly motion: MotionTokens
383
+ }
384
+
385
+ /**
386
+ * Convenience: deep-Partial used for `mergeTheme(base, override)`.
387
+ */
388
+ export type ThemeOverride = {
389
+ readonly [K in keyof Theme]?: K extends 'name'
390
+ ? string
391
+ : Theme[K] extends object
392
+ ? Partial<Theme[K]>
393
+ : Theme[K]
394
+ }