openalgo-charts 2.5.9 → 2.6.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 (53) hide show
  1. package/README.md +54 -45
  2. package/dist/draw/index.d.ts +440 -404
  3. package/dist/index.d.ts +4041 -3019
  4. package/dist/indicators/index.d.ts +230 -61
  5. package/dist/openalgo-charts.draw.mjs +1 -1
  6. package/dist/openalgo-charts.draw.mjs.map +1 -1
  7. package/dist/openalgo-charts.draw.standalone.js +1 -0
  8. package/dist/openalgo-charts.indicators.mjs +1 -1
  9. package/dist/openalgo-charts.indicators.mjs.map +1 -1
  10. package/dist/openalgo-charts.indicators.standalone.js +1 -0
  11. package/dist/openalgo-charts.mjs +1 -1
  12. package/dist/openalgo-charts.mjs.map +1 -1
  13. package/dist/openalgo-charts.profile.mjs +1 -1
  14. package/dist/openalgo-charts.profile.mjs.map +1 -1
  15. package/dist/openalgo-charts.profile.standalone.js +1 -0
  16. package/dist/openalgo-charts.standalone.js +1 -1
  17. package/dist/openalgo-charts.standalone.js.map +1 -1
  18. package/dist/openalgo-charts.trade.mjs +1 -1
  19. package/dist/openalgo-charts.trade.mjs.map +1 -1
  20. package/dist/openalgo-charts.trade.standalone.js +1 -0
  21. package/dist/openalgo-charts.transform.mjs +1 -1
  22. package/dist/openalgo-charts.transform.mjs.map +1 -1
  23. package/dist/openalgo-charts.transform.standalone.js +1 -0
  24. package/dist/openalgo-charts.webgl.mjs +1 -1
  25. package/dist/openalgo-charts.webgl.mjs.map +1 -1
  26. package/dist/openalgo-charts.webgl.standalone.js +1 -0
  27. package/dist/openalgo-charts.widget.chart-data-export-dialog-CX6h5-cp.mjs +2 -0
  28. package/dist/openalgo-charts.widget.chart-data-export-dialog-CX6h5-cp.mjs.map +1 -0
  29. package/dist/openalgo-charts.widget.grid-bar-Cm_CyA2j.mjs +2 -0
  30. package/dist/openalgo-charts.widget.grid-bar-Cm_CyA2j.mjs.map +1 -0
  31. package/dist/openalgo-charts.widget.grid-menus-CPZWEiD3.mjs +2 -0
  32. package/dist/openalgo-charts.widget.grid-menus-CPZWEiD3.mjs.map +1 -0
  33. package/dist/openalgo-charts.widget.keymap-editor-Uozy6qFE.mjs +2 -0
  34. package/dist/openalgo-charts.widget.keymap-editor-Uozy6qFE.mjs.map +1 -0
  35. package/dist/openalgo-charts.widget.layouts-menu-B7XYKPAW.mjs +2 -0
  36. package/dist/openalgo-charts.widget.layouts-menu-B7XYKPAW.mjs.map +1 -0
  37. package/dist/openalgo-charts.widget.layouts-templates-menu-DmYVzrWk.mjs +2 -0
  38. package/dist/openalgo-charts.widget.layouts-templates-menu-DmYVzrWk.mjs.map +1 -0
  39. package/dist/openalgo-charts.widget.mjs +1 -1
  40. package/dist/openalgo-charts.widget.mjs.map +1 -1
  41. package/dist/openalgo-charts.widget.standalone.js +1 -0
  42. package/dist/openalgo-charts.widget.storage-idb-WH_o01Wj.mjs +2 -0
  43. package/dist/openalgo-charts.widget.storage-idb-WH_o01Wj.mjs.map +1 -0
  44. package/dist/openalgo-charts.workspace.mjs +1 -1
  45. package/dist/openalgo-charts.workspace.mjs.map +1 -1
  46. package/dist/openalgo-charts.workspace.standalone.js +1 -0
  47. package/dist/profile/index.d.ts +84 -31
  48. package/dist/trade/index.d.ts +202 -175
  49. package/dist/transform/index.d.ts +44 -21
  50. package/dist/webgl/index.d.ts +56 -47
  51. package/dist/widget/index.d.ts +1647 -512
  52. package/dist/workspace/index.d.ts +183 -92
  53. package/package.json +26 -13
@@ -1,170 +1,4 @@
1
- import { AlertDrawingValue, AlertDrawingLevel, PrimitiveRenderContext, Bar, IPrimitive, DataLayer, PlotRect, IndicatorApi, SeriesApi, PriceScaleId, AlertDrawingInfo, PrimitiveHost, ZOrder, PrimitiveHit } from 'openalgo-charts';
2
-
3
- /**
4
- * The per-tool settings schema: what a host may show in a drawing's settings
5
- * dialog, expressed as dot paths into the drawing (`style.color`,
6
- * `text.fontSize`, `props.foo`, `intervals.from`, `zIndex`, `space`) with a
7
- * control kind and a label.
8
- *
9
- * The rule the whole module exists for: a tool declares only fields its `draw`
10
- * actually reads. A schema is not a wish list. A host renders exactly what is
11
- * declared, so an entry with nothing behind it becomes a control that does
12
- * nothing, which is worse than no control at all.
13
- *
14
- * Pure: no DOM, no registry. The registry lookup (`drawingSettingsSchema`)
15
- * lives in tools.ts so this file has no import that could loop back here.
16
- */
17
-
18
- /**
19
- * The control a field wants. `interval` is a chart interval code, which the
20
- * host offers from its own interval list (the engine has none), with an
21
- * empty choice for no limit.
22
- */
23
- type FieldKind = 'color' | 'number' | 'select' | 'lineStyle' | 'boolean' | 'text' | 'opacity' | 'levels' | 'interval';
24
- /** The section a host groups a field under. */
25
- type FieldGroup = 'line' | 'fill' | 'text' | 'levels' | 'behavior' | 'visibility';
26
- interface SettingsField {
27
- /**
28
- * Dot path into the drawing. Two segments under `style`, `text`, `props`
29
- * or `intervals` (`style.lineWidth`, `intervals.to`), or one of the
30
- * top-level fields `locked`, `visible`, `zIndex`, `space`.
31
- */
32
- path: string;
33
- label: string;
34
- kind: FieldKind;
35
- min?: number;
36
- max?: number;
37
- step?: number;
38
- /** For `select` and `lineStyle`: the values a host may offer. */
39
- options?: ReadonlyArray<{
40
- value: string;
41
- label: string;
42
- }>;
43
- group?: FieldGroup;
44
- /** Value displayed when the drawing has not overridden this setting. */
45
- defaultValue?: string | number | boolean;
46
- }
47
- interface SettingsSchema {
48
- fields: SettingsField[];
49
- /**
50
- * The text *is* the drawing (a note, a callout, the text tool) rather than a
51
- * label on a shape, so a host should ask for it the moment the tool is
52
- * placed instead of waiting for a settings dialog.
53
- */
54
- textIsContent?: boolean;
55
- }
56
- declare const LINE_STYLE_OPTIONS: ReadonlyArray<{
57
- value: string;
58
- label: string;
59
- }>;
60
- declare const ALIGN_OPTIONS: ReadonlyArray<{
61
- value: string;
62
- label: string;
63
- }>;
64
- declare const VALIGN_OPTIONS: ReadonlyArray<{
65
- value: string;
66
- label: string;
67
- }>;
68
- declare const TEXT_POSITION_OPTIONS: ReadonlyArray<{
69
- value: string;
70
- label: string;
71
- }>;
72
- /** The two coordinate spaces, as a host offers them: follow the bars, or stay on screen. */
73
- declare const SPACE_OPTIONS: ReadonlyArray<{
74
- value: DrawingSpace;
75
- label: string;
76
- }>;
77
- /**
78
- * Font stacks a host can offer. Values are real CSS stacks, so a drawing's
79
- * `text.fontFamily` needs no translation before it reaches `ctx.font`; a host
80
- * may still accept any stack the user types.
81
- */
82
- declare const FONT_OPTIONS: ReadonlyArray<{
83
- value: string;
84
- label: string;
85
- }>;
86
- declare const COLOR_FIELD: SettingsField;
87
- declare const LINE_WIDTH_FIELD: SettingsField;
88
- declare const LINE_STYLE_FIELD: SettingsField;
89
- /** Colour, width and dash: what every stroked tool reads through `applyStroke`. */
90
- declare const LINE_FIELDS: readonly SettingsField[];
91
- declare const FILL_FIELDS: readonly SettingsField[];
92
- declare const EXTEND_FIELDS: readonly SettingsField[];
93
- /**
94
- * Where the drawing is anchored: to time and price, or to the screen. Declared
95
- * only by tools that set `viewport`, since the controller converts nothing
96
- * else. Writing it converts the anchors at the view on screen, so the drawing
97
- * keeps its place and only stops (or starts) following the bars.
98
- */
99
- declare const SPACE_FIELD: SettingsField;
100
- /**
101
- * The intervals a drawing is shown on (`Drawing.intervals`), as two interval
102
- * codes, each end included and either one left empty for no limit. No tool
103
- * declares them, since the engine cannot list a host's intervals: a host that
104
- * offers visibility per interval adds them to a tool's schema with
105
- * `composeSettings`, and `applyDrawingSettings` writes the pair as the patch's
106
- * `intervals`, with both ends cleared meaning every interval.
107
- */
108
- declare const INTERVAL_FIELDS: readonly SettingsField[];
109
- declare const SHOW_LABELS_FIELD: SettingsField;
110
- declare const LEVEL_FIELDS: readonly SettingsField[];
111
- /**
112
- * The face of any text a tool prints, including readouts it composes itself
113
- * (a fib level's ratio, a measure's chip, a horizontal line's price tag).
114
- * Tools that print nothing do not declare these.
115
- */
116
- declare const FONT_FIELDS: readonly SettingsField[];
117
- declare const TEXT_VALUE_FIELD: SettingsField;
118
- /** The full surface of the text tool: content, face, layout, plate. */
119
- declare const TEXT_FIELDS: readonly SettingsField[];
120
- /**
121
- * A label attached to a shape: it sits inside or just above the outline, so
122
- * it has an alignment and a position but no plate of its own (the shape is
123
- * the plate) and wraps to the shape's width rather than a width of its own.
124
- */
125
- declare const SHAPE_TEXT_FIELDS: readonly SettingsField[];
126
- /**
127
- * An annotation's plate (note, balloon, comment, signpost, price note): always
128
- * drawn, so there is no `background` toggle, only its colour and opacity, plus
129
- * an optional border.
130
- */
131
- declare const PLATE_TEXT_FIELDS: readonly SettingsField[];
132
- /**
133
- * Build a schema from field lists and single fields. Later duplicates of a
134
- * path are dropped so a tool can layer a group over a shared list without
135
- * showing one control twice.
136
- */
137
- declare function composeSettings(parts: ReadonlyArray<readonly SettingsField[] | SettingsField>, opts?: {
138
- textIsContent?: boolean;
139
- }): SettingsSchema;
140
- /** The value at a dot path, or `undefined` when unset or the path is not one the model has. */
141
- declare function readDrawingSetting(d: Drawing, path: string): unknown;
142
- /**
143
- * Every field of a schema read off a drawing, keyed by path. Unset fields use
144
- * their declared default value, or remain `undefined` when no default exists.
145
- */
146
- declare function readDrawingSettings(d: Drawing, schema: SettingsSchema): Record<string, unknown>;
147
- /**
148
- * A raw control value made into what the field's kind stores, or `undefined`
149
- * when it cannot be. Form inputs hand back strings; a settings panel should
150
- * not have to know that `fontSize` is a number and `bold` a boolean.
151
- */
152
- declare function coerceSettingValue(field: SettingsField, raw: unknown): unknown;
153
- /**
154
- * Turn `{ 'style.color': '#f00', 'text.value': 'Hi', zIndex: 2 }` into the
155
- * partial a controller's `update` accepts. Bags come back whole
156
- * (`style: { ...d.style, color }`), so it does not matter whether the
157
- * controller merges or replaces them. A value of `undefined` removes the key,
158
- * which is how a host offers "reset to default". The `intervals` pair comes
159
- * back whole as well, as the range to replace the drawing's; with neither end
160
- * left it is `{}`, which a controller takes as no range, every interval.
161
- *
162
- * With a `schema`, each value is coerced to its field's kind and any path the
163
- * schema does not declare is dropped: a host can hand over its form state as
164
- * is. Without one, values are written verbatim. Paths the model has no home
165
- * for are ignored either way.
166
- */
167
- declare function applyDrawingSettings(d: Drawing, patch: Record<string, unknown>, schema?: SettingsSchema): Partial<Drawing>;
1
+ import { AlertDrawingValue, AlertDrawingLevel, PrimitiveRenderContext, Bar, IPrimitive, DataLayer, PlotRect, IndicatorApi, SeriesApi, PriceScaleId, AlertDrawingInfo, PrimitiveHost, ZOrder, PrimitiveHit, EmptyEvent } from 'openalgo-charts';
168
2
 
169
3
  /**
170
4
  * Drawing model (ARCHITECTURE.md section 8). A drawing is **plain data**: anchors
@@ -542,6 +376,44 @@ interface DrawingValueContext {
542
376
  x: number;
543
377
  fromY(y: number): number | null;
544
378
  }
379
+ /**
380
+ * The control a field wants. `interval` is a chart interval code, which the
381
+ * host offers from its own interval list (the engine has none), with an
382
+ * empty choice for no limit.
383
+ */
384
+ type FieldKind = 'color' | 'number' | 'select' | 'lineStyle' | 'boolean' | 'text' | 'opacity' | 'levels' | 'interval';
385
+ /** The section a host groups a field under. */
386
+ type FieldGroup = 'line' | 'fill' | 'text' | 'levels' | 'behavior' | 'visibility';
387
+ interface SettingsField {
388
+ /**
389
+ * Dot path into the drawing. Two segments under `style`, `text`, `props`
390
+ * or `intervals` (`style.lineWidth`, `intervals.to`), or one of the
391
+ * top-level fields `locked`, `visible`, `zIndex`, `space`.
392
+ */
393
+ path: string;
394
+ label: string;
395
+ kind: FieldKind;
396
+ min?: number;
397
+ max?: number;
398
+ step?: number;
399
+ /** For `select` and `lineStyle`: the values a host may offer. */
400
+ options?: ReadonlyArray<{
401
+ value: string;
402
+ label: string;
403
+ }>;
404
+ group?: FieldGroup;
405
+ /** Value displayed when the drawing has not overridden this setting. */
406
+ defaultValue?: string | number | boolean;
407
+ }
408
+ interface SettingsSchema {
409
+ fields: SettingsField[];
410
+ /**
411
+ * The text *is* the drawing (a note, a callout, the text tool) rather than a
412
+ * label on a shape, so a host should ask for it the moment the tool is
413
+ * placed instead of waiting for a settings dialog.
414
+ */
415
+ textIsContent?: boolean;
416
+ }
545
417
  interface DrawingTool {
546
418
  id: string;
547
419
  name: string;
@@ -864,12 +736,17 @@ declare class DrawingClipboard {
864
736
  interface DrawingChartHost {
865
737
  readonly isDestroyed?: boolean;
866
738
  /**
867
- * The event bus. The controller listens for `click`, `crosshair:move`,
868
- * `drag`, `drag:end` and `dblclick`, and for `hover` (`{ id }`, the hit id
869
- * under the pointer whenever it changes), which is what drives the hover
870
- * state: the chart has already hit-tested the move, so the controller
871
- * reads its answer rather than testing a second time. A host that never
872
- * emits `hover` has drawings that select and drag but do not light up.
739
+ * The event bus, with the names and payloads of `ChartEventMap`. The
740
+ * controller listens for `click`, `crosshair:move`, `drag`, `drag:end`,
741
+ * `drag:cancel`, `dblclick` and `hover` (`{ id }`, the hit id under the pointer
742
+ * whenever it changes), which is what drives the hover state: the chart has
743
+ * already hit-tested the move, so the controller reads its answer rather than
744
+ * testing a second time. A host that never emits `hover` has drawings that
745
+ * select and drag but do not light up. It also follows `data:context`,
746
+ * `drawings:restore`, `pick:start`, `pick:end`, `paneRemoved`, `paneMoved`,
747
+ * `objects:change` and `indicatorRemoved`; a host that moves or removes panes
748
+ * without `paneRemoved` and `paneMoved` leaves drawings on the old slots. It
749
+ * emits the `draw:*` and `drawing:*` names this tier adds to `ChartEventMap`.
873
750
  */
874
751
  on(event: string, handler: (payload: unknown) => void): () => void;
875
752
  emit(event: string, payload: unknown): void;
@@ -1012,7 +889,8 @@ interface DrawingControllerOptions {
1012
889
  * with a `timeKey` and `anchor: true`): a handle at the point the pair
1013
890
  * names that drags both as one settings change and one step of this undo
1014
891
  * history. Default true; false draws none, and the inputs are still edited
1015
- * in settings and picked with `Chart.beginPick('point')`.
892
+ * in settings and picked with `Chart.beginPick('point')`. Read when the
893
+ * controller is built: `setOptions` does not change it.
1016
894
  */
1017
895
  inputAnchors?: boolean;
1018
896
  /**
@@ -1087,6 +965,35 @@ interface DrawingChangeEvent {
1087
965
  */
1088
966
  step?: number;
1089
967
  }
968
+ /**
969
+ * Payload of `draw:add`, `draw:update` and `draw:remove`: the drawing itself.
970
+ * `history` is set when an undo or redo step applied the change.
971
+ */
972
+ interface DrawingEvent {
973
+ drawing: Drawing;
974
+ history?: true | undefined;
975
+ }
976
+ /** Payload of `draw:copy`, `draw:cut`, `draw:paste` and `draw:preview`. */
977
+ interface DrawingListEvent {
978
+ drawings: Drawing[];
979
+ }
980
+ /** Payload of `drawing:select` (the whole selection, in pick order) and `draw:preview-clear`. */
981
+ interface DrawingIdsEvent {
982
+ ids: string[];
983
+ }
984
+ /** Payload of `draw:select` (the primary selection) and `drawing:hover`; null when there is none. */
985
+ interface DrawingIdEvent {
986
+ id: string | null;
987
+ }
988
+ /** Payload of `draw:tool`: the active tool, null when none; `space` only for a screen-pinned placement. */
989
+ interface DrawingToolEvent {
990
+ tool: string | null;
991
+ space?: 'viewport' | undefined;
992
+ }
993
+ /** Payload of `draw:measure` and `draw:eraser`: the mode switched on or off. */
994
+ interface DrawingModeEvent {
995
+ active: boolean;
996
+ }
1090
997
  /** Options for a call that changes, groups or deletes drawings. */
1091
998
  interface DrawingEditOptions {
1092
999
  /**
@@ -1148,8 +1055,8 @@ declare function studyInputTarget(chart: {
1148
1055
  * controller runs placement, selection, dragging, undo, and serialisation.
1149
1056
  *
1150
1057
  * It listens on the chart's event bus (`click`, `crosshair:move`, `drag`,
1151
- * `drag:end`) rather than the single-slot `subscribeClick`/`subscribeDrag`
1152
- * callbacks, so a host keeps using those for its own order lines.
1058
+ * `drag:end`) rather than `subscribeClick`/`subscribeDrag`, which stay the
1059
+ * host's for its own order lines.
1153
1060
  *
1154
1061
  * Selection is a list. Every method that edits takes the whole list into one
1155
1062
  * undo entry, so a multi-drag, a batch delete or a paste of ten shapes is one
@@ -1164,7 +1071,8 @@ declare class DrawingController {
1164
1071
  private readonly _screen;
1165
1072
  /** The gestures that make no drawing: the temporary measure, box select and the eraser. */
1166
1073
  private readonly _gestures;
1167
- private readonly _layers;
1074
+ /** Every pane's drawing layers; see pane-layers.ts. */
1075
+ private readonly _layerSet;
1168
1076
  private _drawings;
1169
1077
  private _groups;
1170
1078
  private _nextGroup;
@@ -1179,44 +1087,20 @@ declare class DrawingController {
1179
1087
  private _selection;
1180
1088
  /** The drawing under the pointer, from the chart's own hit-test. */
1181
1089
  private _hovered;
1182
- /**
1183
- * Drawings that live under the series but are painted on the top layer for
1184
- * the length of a drag. The top layer repaints on the cursor tier; the
1185
- * bottom one costs the series every frame, which is the difference between
1186
- * a drag that follows the hand and one that stutters through the candles.
1187
- */
1188
- private readonly _lifted;
1189
- /** The slots the series-band drawings were last listed in; see `_slotSignature`. */
1190
- private _slotKey;
1191
1090
  /** Shift as of the last pointer report: what angle lock reads mid-preview. */
1192
1091
  private _shift;
1193
1092
  /** Ctrl or Cmd as of the last pointer report: the strong magnet while held. */
1194
1093
  private _strong;
1195
1094
  /** Placement mode as this controller last set it. */
1196
1095
  private _placing;
1197
- /** Drawings an eraser drag has touched: still in the model, left unpainted until it lets go. */
1198
- private _hidden;
1199
1096
  /** The chart interval drawings are shown for; see `interval()`. */
1200
1097
  private _interval;
1201
- /** The drawings the chart's interval hid when the layers were last listed; see `_followInterval`. */
1202
- private _offInterval;
1203
1098
  /** The device behind the last pointer report, for target sizing. */
1204
1099
  private _pointerKind;
1205
- /** Snapshots for undo/redo; each is a full drawing list (they are small). */
1206
- private _undo;
1207
- private _redo;
1208
- private _pendingHistory;
1209
- /** Depth of `untracked` runs, and the drawings as they were before the host's edit in progress. */
1210
- private _untracked;
1211
- private _hostEdit;
1212
- /** The host's patches the recorded steps have yet to take, merged per drawing. */
1213
- private readonly _hostPatches;
1214
- /**
1215
- * One gesture's starting state. `items` are ids rather than objects because
1216
- * an undo mid-drag replaces every drawing object, and a stale reference
1217
- * would move a shape that is no longer in the model.
1218
- */
1219
- private _dragStart;
1100
+ /** Undo, redo and the host's own edits; see drawing-history.ts. */
1101
+ private readonly _history;
1102
+ /** The drag of a drawing or its handle; see drawing-drag.ts. */
1103
+ private readonly _drag;
1220
1104
  private readonly _off;
1221
1105
  private _anchors;
1222
1106
  /** The host's timeline an anchor step goes to instead of this history; see `delegateInputAnchorSteps`. */
@@ -1321,11 +1205,6 @@ declare class DrawingController {
1321
1205
  placeInStack(id: string, target: DrawingStackTarget, where: 'above' | 'below'): boolean;
1322
1206
  /** A pane's series band as the chart reports it, or none on a host that cannot. */
1323
1207
  private _entries;
1324
- /**
1325
- * The slot a drawing paints in: `entry:<id>` while the entry it is placed
1326
- * above is in its pane's series band, else its side of the series by `zIndex`.
1327
- */
1328
- private _slotOf;
1329
1208
  /** The drawings of one slot of a pane, in paint order. */
1330
1209
  private _slotMembers;
1331
1210
  private _remapPanes;
@@ -1570,11 +1449,6 @@ declare class DrawingController {
1570
1449
  delegateInputAnchorSteps(record: (step: InputAnchorStep) => void): () => void;
1571
1450
  undo(): boolean;
1572
1451
  redo(): boolean;
1573
- /**
1574
- * Move the model from one snapshot to the other; false when the policy left
1575
- * nothing to move. Without `kind` it only answers, and moves nothing.
1576
- */
1577
- private _applyHistory;
1578
1452
  /** Drop selected ids the model no longer holds, or that can no longer be selected. */
1579
1453
  private _pruneSelection;
1580
1454
  canUndo(): boolean;
@@ -1600,8 +1474,6 @@ declare class DrawingController {
1600
1474
  * across drawings and its own changes, whose own changes are never steps.
1601
1475
  */
1602
1476
  untracked<T>(fn: () => T): T;
1603
- /** Give every recorded step the host's edit, drawing by drawing and group by group. */
1604
- private _takeInHostEdit;
1605
1477
  /**
1606
1478
  * Serialisable document, the same shape `ChartState.drawings` carries.
1607
1479
  * Transient drawings (`policy.persistent` false) are left out, and so is
@@ -1619,8 +1491,6 @@ declare class DrawingController {
1619
1491
  */
1620
1492
  fromJSON(data: unknown): void;
1621
1493
  destroy(): void;
1622
- /** Every layer of every pane. */
1623
- private _allLayers;
1624
1494
  private _onCrosshair;
1625
1495
  /** The chart's hit-test answer for the pointer position, whenever it changes. */
1626
1496
  private _onHover;
@@ -1702,33 +1572,8 @@ declare class DrawingController {
1702
1572
  private _snapPoint;
1703
1573
  /** Shift and Ctrl (Cmd) as the last pointer report carried them: the angle lock and the strong magnet. */
1704
1574
  private _noteKeys;
1705
- /**
1706
- * The anchor of a grabbed shape the magnet lands: the one nearest the
1707
- * press, since what the hand is closest to is what it means to put down.
1708
- */
1709
- private _grabbedAnchor;
1710
- /**
1711
- * A shape's move with the magnet's pull on its grabbed anchor applied, or
1712
- * null when nothing pulls: the whole shape shifts by what lands that one
1713
- * anchor on the value, so it keeps its form.
1714
- */
1715
- private _pullShape;
1716
- private _onDrag;
1717
- /** Whether a drag has left its press by more than the chart's click slop, on screen. */
1718
- private _travelled;
1719
- /**
1720
- * Copies of `sources` for a drag to move, in the model and selected. A
1721
- * copy is the user's own drawing, as a duplicate is: no policy, a fresh
1722
- * id, and `_insert` drops the link lineage.
1723
- */
1724
- private _copies;
1725
- /** A cancelled copy leaves nothing: its copies go, and the selection is what they were copied from. */
1726
- private _dropCopies;
1727
- private _emitDragPreview;
1728
1575
  /** Roll back an interrupted drag and leave the pre-gesture undo/redo stacks intact. */
1729
1576
  cancelDrag(): boolean;
1730
- /** Apply one drag frame to the model, from the gesture's snapshot. */
1731
- private _moveDrag;
1732
1577
  /**
1733
1578
  * The drawing's anchors in container media px, the space `timeToCoordinate`
1734
1579
  * and `priceToCoordinate` answer in, whichever space it is anchored in. What
@@ -1737,91 +1582,17 @@ declare class DrawingController {
1737
1582
  * a strip, or hidden behind a maximized pane).
1738
1583
  */
1739
1584
  screenPoints(id: string): ScreenPoint[] | null;
1740
- /** Put a drawing's anchors back as a gesture found them. */
1741
- private _restoreAnchors;
1742
- private _onDragEnd;
1743
- /**
1744
- * The pair of layers for a pane, made on first use. The bottom one is added
1745
- * first so a host that lists primitives sees them in paint order; the top one
1746
- * adopts it so handles and hit-tests come from one place.
1747
- */
1748
- private _layerFor;
1749
- /**
1750
- * Whether a drawing paints on the top layer: over the series and outside
1751
- * the series band, or lifted for a drag.
1752
- */
1753
- private _onTop;
1754
1585
  /** Push the current list into each pane's layers and into the chart state. */
1755
1586
  private _sync;
1756
- /** Each drawing placed in the series band, with the slot it resolves to now. */
1757
- private _slotSignature;
1758
- /** List every drawing on the layer of the slot it paints in. */
1759
- private _syncLayers;
1760
- /**
1761
- * One series-band layer per entry a drawing on this pane is placed above,
1762
- * made on first use and dropped when its last drawing leaves, each painted
1763
- * by the chart right after its entry. The top layer answers for them,
1764
- * front to back, then for the layer under the series.
1765
- */
1766
- private _syncSeriesLayers;
1767
- /**
1768
- * The per-frame half of a drag: only the top layers of the panes the
1769
- * gesture touches are re-listed, so the repaint stays on the cursor tier.
1770
- * Everything moving is on a top layer by then (anything under the series
1771
- * was lifted when the gesture began), and the bottom layers have not
1772
- * changed since, so re-listing them would cost a series repaint for
1773
- * nothing.
1774
- */
1775
- private _syncDrag;
1776
- /**
1777
- * Mirror the in-progress anchors (plus the cursor) into the preview slot.
1778
- * The cursor point goes through the same aim as a click would, so the
1779
- * preview shows the locked angle or the snapped anchor before it lands.
1780
- */
1781
- private _syncPreview;
1782
- /**
1783
- * Show where the magnet will land the next click, or nothing. A ring only
1784
- * while a click would place an anchor: a tool armed, not a brush (which
1785
- * inks where the pointer is), and the pull actually applying at the cursor.
1786
- * Angle lock bypasses the magnet, so it hides the ring too.
1787
- */
1788
- private _syncSnapRing;
1789
- /**
1790
- * Record a step that is not a drawing edit, a study anchor's move, in the
1791
- * same history, so Undo walks it and the drawings in the order they were
1792
- * made. Like any new edit it clears the redo branch. An `outside` move was
1793
- * written to the settings by someone else (a settings dialog's Pick point):
1794
- * it ends no drawing drag, and a host timeline the steps are handed to saw
1795
- * that write itself, so only this history takes it.
1796
- */
1797
- private _recordStep;
1798
- /**
1799
- * Announce a move of the history that changed no drawing, with no ids, so
1800
- * a host's Undo and Redo controls, which refresh on `drawing:change`,
1801
- * follow it. Passes `applied` through.
1802
- */
1803
- private _external;
1804
- private _pushUndo;
1805
- /**
1806
- * Open an edit: recorded, or, for a change the history does not hold (a
1807
- * host placing or moving a read-only drawing), not recorded and leaving
1808
- * both branches alone. Either way a drag in progress ends first.
1809
- */
1810
- private _begin;
1811
- /**
1812
- * What the host does (a policy, a forced call) is its own act and never
1813
- * history's to reverse: `edit` makes the same change to every recorded
1814
- * snapshot, as if it had always been so, and a step left with nothing to do
1815
- * is dropped, so `canUndo` and `canRedo` match what a press would do. The
1816
- * step still being recorded stays whatever it holds so far. `edit` may
1817
- * share live objects, since each snapshot is serialised at once. The
1818
- * host's patches still held back go in first, being older. Both snapshots
1819
- * of every step are parsed and written, which is why a forced move of a
1820
- * read-only drawing is held back rather than paying for this.
1821
- */
1822
- private _rebase;
1823
1587
  }
1824
1588
 
1589
+ /**
1590
+ * Drawings shared between linked charts of one instrument: a drawing made,
1591
+ * moved or removed on one chart is made, moved or removed on the others,
1592
+ * each with its own undo history. A shared drawing carries a lineage mark in
1593
+ * its props, so the link finds it again after a restore.
1594
+ */
1595
+
1825
1596
  /** Both fields must be known. A host may use its feed namespace as the exchange. */
1826
1597
  interface DrawingLinkContext {
1827
1598
  symbol?: string;
@@ -2112,22 +1883,139 @@ declare class InstrumentDrawings {
2112
1883
  declare function createInstrumentDrawings(chart: InstrumentDrawingsChart, controller: DrawingController, options?: InstrumentDrawingsOptions): InstrumentDrawings;
2113
1884
 
2114
1885
  /**
2115
- * Built-in drawing tools + the tool registry. Same philosophy as the chart-type
2116
- * and indicator registries: a tool is a descriptor, the layer just runs it, and
2117
- * `registerDrawingTool` makes a custom one first-class.
2118
- *
2119
- * `draw` receives anchors already in device px; `distance` receives them in
2120
- * media px, the same space as the incoming cursor.
1886
+ * The per-tool settings schema: what a host may show in a drawing's settings
1887
+ * dialog, expressed as dot paths into the drawing (`style.color`,
1888
+ * `text.fontSize`, `props.foo`, `intervals.from`, `zIndex`, `space`) with a
1889
+ * control kind and a label.
2121
1890
  *
2122
- * Text lives in `drawing.text` (a `DrawingText`), never in the style bag: a
2123
- * shape's outline colour and its label colour are two decisions, and a tool
2124
- * that prints only a readout (a fib ladder, a measure chip) still reads its
2125
- * face from there. Ladders read `FibLevel[]` and stroke each level in its own
2126
- * colour, taken from the shared palette in levels.ts.
1891
+ * The rule the whole module exists for: a tool declares only fields its `draw`
1892
+ * actually reads. A schema is not a wish list. A host renders exactly what is
1893
+ * declared, so an entry with nothing behind it becomes a control that does
1894
+ * nothing, which is worse than no control at all.
2127
1895
  *
2128
- * Every tool declares `settings`: the fields a host may show for it. The
2129
- * schema is a contract, not a wish list. A field is declared only when this
2130
- * file reads it, because a control with nothing behind it is a defect.
1896
+ * Pure: no DOM, no registry. The registry lookup (`drawingSettingsSchema`)
1897
+ * lives in registry.ts so this file has no import that could loop back here.
1898
+ */
1899
+
1900
+ declare const LINE_STYLE_OPTIONS: ReadonlyArray<{
1901
+ value: string;
1902
+ label: string;
1903
+ }>;
1904
+ declare const ALIGN_OPTIONS: ReadonlyArray<{
1905
+ value: string;
1906
+ label: string;
1907
+ }>;
1908
+ declare const VALIGN_OPTIONS: ReadonlyArray<{
1909
+ value: string;
1910
+ label: string;
1911
+ }>;
1912
+ declare const TEXT_POSITION_OPTIONS: ReadonlyArray<{
1913
+ value: string;
1914
+ label: string;
1915
+ }>;
1916
+ /** The two coordinate spaces, as a host offers them: follow the bars, or stay on screen. */
1917
+ declare const SPACE_OPTIONS: ReadonlyArray<{
1918
+ value: DrawingSpace;
1919
+ label: string;
1920
+ }>;
1921
+ /**
1922
+ * Font stacks a host can offer. Values are real CSS stacks, so a drawing's
1923
+ * `text.fontFamily` needs no translation before it reaches `ctx.font`; a host
1924
+ * may still accept any stack the user types.
1925
+ */
1926
+ declare const FONT_OPTIONS: ReadonlyArray<{
1927
+ value: string;
1928
+ label: string;
1929
+ }>;
1930
+ declare const COLOR_FIELD: SettingsField;
1931
+ declare const LINE_WIDTH_FIELD: SettingsField;
1932
+ declare const LINE_STYLE_FIELD: SettingsField;
1933
+ /** Colour, width and dash: what every stroked tool reads through `applyStroke`. */
1934
+ declare const LINE_FIELDS: readonly SettingsField[];
1935
+ declare const FILL_FIELDS: readonly SettingsField[];
1936
+ declare const EXTEND_FIELDS: readonly SettingsField[];
1937
+ /**
1938
+ * Where the drawing is anchored: to time and price, or to the screen. Declared
1939
+ * only by tools that set `viewport`, since the controller converts nothing
1940
+ * else. Writing it converts the anchors at the view on screen, so the drawing
1941
+ * keeps its place and only stops (or starts) following the bars.
1942
+ */
1943
+ declare const SPACE_FIELD: SettingsField;
1944
+ /**
1945
+ * The intervals a drawing is shown on (`Drawing.intervals`), as two interval
1946
+ * codes, each end included and either one left empty for no limit. No tool
1947
+ * declares them, since the engine cannot list a host's intervals: a host that
1948
+ * offers visibility per interval adds them to a tool's schema with
1949
+ * `composeSettings`, and `applyDrawingSettings` writes the pair as the patch's
1950
+ * `intervals`, with both ends cleared meaning every interval.
1951
+ */
1952
+ declare const INTERVAL_FIELDS: readonly SettingsField[];
1953
+ declare const SHOW_LABELS_FIELD: SettingsField;
1954
+ declare const LEVEL_FIELDS: readonly SettingsField[];
1955
+ /**
1956
+ * The face of any text a tool prints, including readouts it composes itself
1957
+ * (a fib level's ratio, a measure's chip, a horizontal line's price tag).
1958
+ * Tools that print nothing do not declare these.
1959
+ */
1960
+ declare const FONT_FIELDS: readonly SettingsField[];
1961
+ declare const TEXT_VALUE_FIELD: SettingsField;
1962
+ /** The full surface of the text tool: content, face, layout, plate. */
1963
+ declare const TEXT_FIELDS: readonly SettingsField[];
1964
+ /**
1965
+ * A label attached to a shape: it sits inside or just above the outline, so
1966
+ * it has an alignment and a position but no plate of its own (the shape is
1967
+ * the plate) and wraps to the shape's width rather than a width of its own.
1968
+ */
1969
+ declare const SHAPE_TEXT_FIELDS: readonly SettingsField[];
1970
+ /**
1971
+ * An annotation's plate (note, balloon, comment, signpost, price note): always
1972
+ * drawn, so there is no `background` toggle, only its colour and opacity, plus
1973
+ * an optional border.
1974
+ */
1975
+ declare const PLATE_TEXT_FIELDS: readonly SettingsField[];
1976
+ /**
1977
+ * Build a schema from field lists and single fields. Later duplicates of a
1978
+ * path are dropped so a tool can layer a group over a shared list without
1979
+ * showing one control twice.
1980
+ */
1981
+ declare function composeSettings(parts: ReadonlyArray<readonly SettingsField[] | SettingsField>, opts?: {
1982
+ textIsContent?: boolean;
1983
+ }): SettingsSchema;
1984
+ /** The value at a dot path, or `undefined` when unset or the path is not one the model has. */
1985
+ declare function readDrawingSetting(d: Drawing, path: string): unknown;
1986
+ /**
1987
+ * Every field of a schema read off a drawing, keyed by path. Unset fields use
1988
+ * their declared default value, or remain `undefined` when no default exists.
1989
+ */
1990
+ declare function readDrawingSettings(d: Drawing, schema: SettingsSchema): Record<string, unknown>;
1991
+ /**
1992
+ * A raw control value made into what the field's kind stores, or `undefined`
1993
+ * when it cannot be. Form inputs hand back strings; a settings panel should
1994
+ * not have to know that `fontSize` is a number and `bold` a boolean.
1995
+ */
1996
+ declare function coerceSettingValue(field: SettingsField, raw: unknown): unknown;
1997
+ /**
1998
+ * Turn `{ 'style.color': '#f00', 'text.value': 'Hi', zIndex: 2 }` into the
1999
+ * partial a controller's `update` accepts. Bags come back whole
2000
+ * (`style: { ...d.style, color }`), so it does not matter whether the
2001
+ * controller merges or replaces them. A value of `undefined` removes the key,
2002
+ * which is how a host offers "reset to default". The `intervals` pair comes
2003
+ * back whole as well, as the range to replace the drawing's; with neither end
2004
+ * left it is `{}`, which a controller takes as no range, every interval.
2005
+ *
2006
+ * With a `schema`, each value is coerced to its field's kind and any path the
2007
+ * schema does not declare is dropped: a host can hand over its form state as
2008
+ * is. Without one, values are written verbatim. Paths the model has no home
2009
+ * for are ignored either way.
2010
+ */
2011
+ declare function applyDrawingSettings(d: Drawing, patch: Record<string, unknown>, schema?: SettingsSchema): Partial<Drawing>;
2012
+
2013
+ /**
2014
+ * The drawing-tool registry. Same philosophy as the chart-type and indicator
2015
+ * registries: a tool is a descriptor, the layer just runs it, and
2016
+ * `registerDrawingTool` makes a custom one first-class. The built-ins are
2017
+ * listed and registered in tools.ts; everything that only needs to look a
2018
+ * tool up imports this module, not the catalogue.
2131
2019
  */
2132
2020
 
2133
2021
  declare function registerDrawingTool(tool: DrawingTool): void;
@@ -2137,6 +2025,8 @@ declare function registeredDrawingTools(): DrawingTool[];
2137
2025
  /** Keyboard event fields a shortcut is matched against. */
2138
2026
  interface ShortcutEvent {
2139
2027
  key: string;
2028
+ /** The physical key (`KeyT`): under Alt it names the letter when `key` is not one, as macOS Option types a symbol. Since 2.5.10. */
2029
+ code?: string;
2140
2030
  altKey?: boolean;
2141
2031
  ctrlKey?: boolean;
2142
2032
  metaKey?: boolean;
@@ -2154,7 +2044,11 @@ interface ShortcutEvent {
2154
2044
  * treated as Ctrl, which is what a Mac user expects.
2155
2045
  */
2156
2046
  declare function matchDrawingShortcut(e: ShortcutEvent): string | null;
2157
- /** Every registered tool that has a shortcut, as `id -> shortcut`. */
2047
+ /**
2048
+ * Every registered tool that has a shortcut, as `id -> shortcut`. Built as
2049
+ * entries, so an id such as `__proto__` is a key like any other rather than an
2050
+ * assignment to the object's prototype.
2051
+ */
2158
2052
  declare function drawingShortcuts(): Record<string, string>;
2159
2053
  /**
2160
2054
  * The settings a host may show for a tool: the tool's own declaration, else
@@ -2163,6 +2057,28 @@ declare function drawingShortcuts(): Record<string, string>;
2163
2057
  * free of any import that could loop back into this one.
2164
2058
  */
2165
2059
  declare function drawingSettingsSchema(toolId: string): SettingsSchema;
2060
+
2061
+ /**
2062
+ * Built-in drawing tools: the line family, shapes, curves, freehand ink and
2063
+ * cycles, plus the catalogue of every built-in in registration order. The
2064
+ * other families live beside it (fib-tools.ts, measure-tools.ts,
2065
+ * annotation-tools.ts and the advanced, pattern and analysis modules), what
2066
+ * they paint with in tool-paint.ts, and the registry in registry.ts.
2067
+ *
2068
+ * `draw` receives anchors already in device px; `distance` receives them in
2069
+ * media px, the same space as the incoming cursor.
2070
+ *
2071
+ * Text lives in `drawing.text` (a `DrawingText`), never in the style bag: a
2072
+ * shape's outline colour and its label colour are two decisions, and a tool
2073
+ * that prints only a readout (a fib ladder, a measure chip) still reads its
2074
+ * face from there. Ladders read `FibLevel[]` and stroke each level in its own
2075
+ * colour, taken from the shared palette in levels.ts.
2076
+ *
2077
+ * Every tool declares `settings`: the fields a host may show for it. The
2078
+ * schema is a contract, not a wish list. A field is declared only when the
2079
+ * tool reads it, because a control with nothing behind it is a defect.
2080
+ */
2081
+
2166
2082
  declare const TREND_LINE: DrawingTool;
2167
2083
  declare const RAY: DrawingTool;
2168
2084
  declare const EXTENDED_LINE: DrawingTool;
@@ -2174,12 +2090,6 @@ declare const CROSS_LINE: DrawingTool;
2174
2090
  declare const RECTANGLE: DrawingTool;
2175
2091
  declare const ELLIPSE: DrawingTool;
2176
2092
  declare const PARALLEL_CHANNEL: DrawingTool;
2177
- declare const FIB_RETRACEMENT: DrawingTool;
2178
- declare const FIB_EXTENSION: DrawingTool;
2179
- declare const MEASURE: DrawingTool;
2180
- declare const LONG_POSITION: DrawingTool;
2181
- declare const SHORT_POSITION: DrawingTool;
2182
- declare const TEXT: DrawingTool;
2183
2093
  /**
2184
2094
  * Path: click each vertex, double-click to finish, arrowhead on the last leg.
2185
2095
  * The arrow is what separates it from `polyline`: a path points somewhere.
@@ -2218,6 +2128,88 @@ declare const TIME_CYCLES: DrawingTool;
2218
2128
  * period, the vertical offset its amplitude.
2219
2129
  */
2220
2130
  declare const SINE_LINE: DrawingTool;
2131
+ /**
2132
+ * Circle from centre + a radius handle. The radius is measured in *pixels*, so
2133
+ * it stays a circle on screen instead of the ellipse the two axes' differing
2134
+ * scales would otherwise produce.
2135
+ */
2136
+ declare const CIRCLE: DrawingTool;
2137
+ declare const TRIANGLE: DrawingTool;
2138
+ /** Free-form polyline: click each vertex, double-click to finish. */
2139
+ declare const POLYLINE: DrawingTool;
2140
+ /** Arc through three anchors: the middle one is on the curve, not a handle. */
2141
+ declare const ARC: DrawingTool;
2142
+ /** Quadratic curve: the middle anchor is a control handle, off the curve. */
2143
+ declare const CURVE: DrawingTool;
2144
+ /** Highlighter: the brush with a fat, translucent stroke. */
2145
+ declare const HIGHLIGHTER: DrawingTool;
2146
+ declare const BUILTIN_DRAWING_TOOLS: readonly DrawingTool[];
2147
+ /** Register every built-in tool. Idempotent; called on tier import. */
2148
+ declare function registerBuiltinDrawingTools(): void;
2149
+
2150
+ /**
2151
+ * The fibonacci and gann family: retracement and extension, the channel, time
2152
+ * zone and fan, the gann fan and box. Ladders read `FibLevel[]` and stroke each
2153
+ * level in its own colour, taken from the shared palette in levels.ts.
2154
+ */
2155
+
2156
+ declare const FIB_RETRACEMENT: DrawingTool;
2157
+ declare const FIB_EXTENSION: DrawingTool;
2158
+ /** Fib channel: fib levels spread across a trend leg, parallel to it. */
2159
+ declare const FIB_CHANNEL: DrawingTool;
2160
+ /**
2161
+ * Fib time zone: vertical lines at Fibonacci multiples of the base leg's width.
2162
+ * Its levels count bars rather than divide a leg, so they carry no convention
2163
+ * colour and fall back to the drawing's own.
2164
+ */
2165
+ declare const FIB_TIME_ZONE: DrawingTool;
2166
+ /** Rays from the anchor at fib fractions of the leg: the speed resistance fan. */
2167
+ declare const FIB_FAN: DrawingTool;
2168
+ /**
2169
+ * Gann fan: rays from one anchor at the classic price/time angles. A level's
2170
+ * ratio is price per unit of time, so the 1x1 is 1, the 1x2 is 0.5 and the
2171
+ * 2x1 is 2; each angle keeps its own colour from the cycle palette.
2172
+ */
2173
+ declare const GANN_FAN: DrawingTool;
2174
+ /**
2175
+ * Gann box: the drawn rectangle divided at its levels on both axes, plus the
2176
+ * 1x1 diagonal. Ratio 0 is the first anchor's price and time, ratio 1 the
2177
+ * second's, so the box reads like a retracement laid over a date range.
2178
+ */
2179
+ declare const GANN_BOX: DrawingTool;
2180
+
2181
+ /**
2182
+ * Measurement and positions: the measure box, the price and date ranges, the
2183
+ * forecast and the long and short position calculators. Measurers are tinted
2184
+ * by direction, so they read width, dash and opacity but not a colour.
2185
+ */
2186
+
2187
+ declare const MEASURE: DrawingTool;
2188
+ declare const LONG_POSITION: DrawingTool;
2189
+ declare const SHORT_POSITION: DrawingTool;
2190
+ /**
2191
+ * Measurers. `measure` reports price *and* time together; these two constrain it
2192
+ * to one axis, which is what you want when the other one is noise: sizing a
2193
+ * retracement without caring how long it took, or counting bars to an event
2194
+ * without caring where price went.
2195
+ */
2196
+ declare const PRICE_RANGE: DrawingTool;
2197
+ declare const DATE_RANGE: DrawingTool;
2198
+ /**
2199
+ * Position forecast: project a move from an anchor. Two anchors give the
2200
+ * projected leg; the shape extends the same slope past the target as a dashed
2201
+ * cone, so the drawing says "if this continues" rather than just marking a line.
2202
+ */
2203
+ declare const FORECAST: DrawingTool;
2204
+
2205
+ /**
2206
+ * Annotations: the text tool, the price label, callout and flag, the plate
2207
+ * notes (note, balloon, comment, signpost, price note), the table and the
2208
+ * arrow marks. Every one of them puts a human sentence, or a mark pointing at
2209
+ * a bar, on the chart.
2210
+ */
2211
+
2212
+ declare const TEXT: DrawingTool;
2221
2213
  /**
2222
2214
  * Price label: a pill of the anchored price with a tail pointing at the bar.
2223
2215
  * Reads its value off the anchor, so dragging it re-reads rather than going
@@ -2282,64 +2274,10 @@ declare const PRICE_NOTE: DrawingTool;
2282
2274
  * because a table on a chart is nearly always labelled.
2283
2275
  */
2284
2276
  declare const TABLE: DrawingTool;
2285
- /**
2286
- * Measurers. `measure` reports price *and* time together; these two constrain it
2287
- * to one axis, which is what you want when the other one is noise: sizing a
2288
- * retracement without caring how long it took, or counting bars to an event
2289
- * without caring where price went.
2290
- */
2291
- declare const PRICE_RANGE: DrawingTool;
2292
- declare const DATE_RANGE: DrawingTool;
2293
- /**
2294
- * Position forecast: project a move from an anchor. Two anchors give the
2295
- * projected leg; the shape extends the same slope past the target as a dashed
2296
- * cone, so the drawing says "if this continues" rather than just marking a line.
2297
- */
2298
- declare const FORECAST: DrawingTool;
2299
- /**
2300
- * Circle from centre + a radius handle. The radius is measured in *pixels*, so
2301
- * it stays a circle on screen instead of the ellipse the two axes' differing
2302
- * scales would otherwise produce.
2303
- */
2304
- declare const CIRCLE: DrawingTool;
2305
- declare const TRIANGLE: DrawingTool;
2306
- /** Free-form polyline: click each vertex, double-click to finish. */
2307
- declare const POLYLINE: DrawingTool;
2308
- /** Arc through three anchors: the middle one is on the curve, not a handle. */
2309
- declare const ARC: DrawingTool;
2310
- /** Quadratic curve: the middle anchor is a control handle, off the curve. */
2311
- declare const CURVE: DrawingTool;
2312
2277
  declare const ARROW_UP: DrawingTool;
2313
2278
  declare const ARROW_DOWN: DrawingTool;
2314
2279
  declare const ARROW_LEFT: DrawingTool;
2315
2280
  declare const ARROW_RIGHT: DrawingTool;
2316
- /** Highlighter: the brush with a fat, translucent stroke. */
2317
- declare const HIGHLIGHTER: DrawingTool;
2318
- /** Fib channel: fib levels spread across a trend leg, parallel to it. */
2319
- declare const FIB_CHANNEL: DrawingTool;
2320
- /**
2321
- * Fib time zone: vertical lines at Fibonacci multiples of the base leg's width.
2322
- * Its levels count bars rather than divide a leg, so they carry no convention
2323
- * colour and fall back to the drawing's own.
2324
- */
2325
- declare const FIB_TIME_ZONE: DrawingTool;
2326
- /** Rays from the anchor at fib fractions of the leg: the speed resistance fan. */
2327
- declare const FIB_FAN: DrawingTool;
2328
- /**
2329
- * Gann fan: rays from one anchor at the classic price/time angles. A level's
2330
- * ratio is price per unit of time, so the 1x1 is 1, the 1x2 is 0.5 and the
2331
- * 2x1 is 2; each angle keeps its own colour from the cycle palette.
2332
- */
2333
- declare const GANN_FAN: DrawingTool;
2334
- /**
2335
- * Gann box: the drawn rectangle divided at its levels on both axes, plus the
2336
- * 1x1 diagonal. Ratio 0 is the first anchor's price and time, ratio 1 the
2337
- * second's, so the box reads like a retracement laid over a date range.
2338
- */
2339
- declare const GANN_BOX: DrawingTool;
2340
- declare const BUILTIN_DRAWING_TOOLS: readonly DrawingTool[];
2341
- /** Register every built-in tool. Idempotent; called on tier import. */
2342
- declare function registerBuiltinDrawingTools(): void;
2343
2281
 
2344
2282
  /**
2345
2283
  * The shared level palette for the Fibonacci and Gann family.
@@ -2567,13 +2505,18 @@ declare const CHROME_ICON_ATTRS: {
2567
2505
  * They are drawn twice on purpose: a rail button and a toolbar button are
2568
2506
  * different sizes, and the whole point of a second grid is not scaling one
2569
2507
  * drawing to both.
2508
+ *
2509
+ * The tier also carries a glyph for each chart type and transform, under
2510
+ * `chart-<id>` (see `chartTypeIcon`), so a chart-type menu reads from the
2511
+ * same set as the buttons around it. A layout picker's tiles are derived
2512
+ * rather than listed (`layoutIconPath`).
2570
2513
  */
2571
2514
  declare const CHROME_ICONS: Readonly<Record<string, string>>;
2572
2515
  /**
2573
2516
  * The fills of the chrome glyphs' marks, as `DRAWING_TOOL_ACCENTS` is for the
2574
2517
  * tools: each mark is outlined in the glyph's path, and this paints it solid.
2575
2518
  * At 16px a ring of a 2px line is mostly line already, so the fill matters
2576
- * most for the slider knobs.
2519
+ * most for the rings of radius 2: the slider knobs, a head, a line's markers.
2577
2520
  */
2578
2521
  declare const CHROME_ICON_ACCENTS: Readonly<Record<string, string>>;
2579
2522
  /**
@@ -2588,6 +2531,43 @@ declare function chromeIcon(id: string): string | undefined;
2588
2531
  declare function chromeIconAccent(id: string): string | undefined;
2589
2532
  /** Every id the chrome tier covers. */
2590
2533
  declare function chromeIconIds(): string[];
2534
+ /**
2535
+ * The chrome glyph for a chart type or a transform, by its id: a registered
2536
+ * type (`candlestick`, `point-figure`) or one of the transforms that render
2537
+ * as candles (`heikin-ashi`, `renko`, `range-bars`, `line-break`). It is the
2538
+ * `chart-<id>` entry of `CHROME_ICONS`, so `chromeIconSvg('chart-' + id)`
2539
+ * draws the same picture. `undefined` for a type a host registered itself,
2540
+ * which has no glyph until the host draws one.
2541
+ */
2542
+ declare function chartTypeIcon(type: string): string | undefined;
2543
+ /** One chart's place in a layout glyph: a cell, and how many rows and columns it spans. */
2544
+ interface LayoutIconSlot {
2545
+ readonly row: number;
2546
+ readonly column: number;
2547
+ /** Default 1. */
2548
+ readonly rowSpan?: number;
2549
+ /** Default 1. */
2550
+ readonly columnSpan?: number;
2551
+ }
2552
+ /**
2553
+ * A chrome glyph for a grid of charts: the frame, split into `rows` by
2554
+ * `columns` cells, with the dividers inside a spanning slot left out, so a
2555
+ * chart that spans two cells reads as one pane. Cells no slot claims are
2556
+ * drawn as their own panes. Without `slots`, every cell is one chart.
2557
+ *
2558
+ * Derived rather than drawn per layout, so a host's layout picker gets a
2559
+ * tile for every layout it offers, uneven ones included, without an entry in
2560
+ * this registry for each. The path is on the chrome grid and to its rules
2561
+ * (whole units, the 2..14 live area, no presentation attributes), and draws
2562
+ * through the chrome attribute bag like any `CHROME_ICONS` value.
2563
+ *
2564
+ * One to four a side: twelve units split four ways leaves a pixel of clear
2565
+ * between two lines of the 2px stroke, and five would close it up. Throws a
2566
+ * `RangeError` for anything else, and for a slot outside the grid or over
2567
+ * another. A chart grid takes up to eight a side, so a caller that draws the
2568
+ * current layout falls back to the `layout` glyph past four.
2569
+ */
2570
+ declare function layoutIconPath(rows: number, columns: number, slots?: readonly LayoutIconSlot[]): string;
2591
2571
 
2592
2572
  /** Prefix of every `<symbol id>` in the sprite, and of every `<use href>`. */
2593
2573
  declare const ICON_SYMBOL_PREFIX = "oac-icon-";
@@ -2784,8 +2764,6 @@ declare class DrawingLayer implements IPrimitive {
2784
2764
  private _isTouch;
2785
2765
  private _grabRadius;
2786
2766
  private _handleRadius;
2787
- /** Map an anchor to media px on this pane. */
2788
- private _project;
2789
2767
  private _points;
2790
2768
  /** Selected, unlocked drawings of this layer, in paint order. */
2791
2769
  private _handled;
@@ -2955,6 +2933,64 @@ declare function migrateDrawings(input: unknown): DrawingsDocument;
2955
2933
  */
2956
2934
  declare function drawingShownOnInterval(drawing: Pick<Drawing, 'intervals'>, interval: string | null | undefined): boolean;
2957
2935
 
2936
+ /**
2937
+ * The draw tier's events on the chart bus, added to the base's `ChartEventMap`
2938
+ * by declaration merging. The base declares the map and cannot name a
2939
+ * `Drawing` without importing this tier, so the names arrive with the tier: a
2940
+ * host that imports `openalgo-charts/draw` (or the widget, which does) gets
2941
+ * `chart.on('draw:add', ...)` typed.
2942
+ *
2943
+ * Two families, two granularities, both kept. `draw:*` reports per drawing and
2944
+ * per tool or gesture: `draw:add`, `draw:update` and `draw:remove` fire once for
2945
+ * each drawing touched and carry it, and `draw:select` names the primary
2946
+ * selection. `drawing:*` reports per mutation and per selection change:
2947
+ * `drawing:change` fires once after the per-drawing events with every id, and
2948
+ * `drawing:select` carries the whole selection. A host that renders one
2949
+ * drawing's properties listens to the first; one that refreshes a list or an
2950
+ * undo button listens to the second.
2951
+ */
2952
+
2953
+ declare module 'openalgo-charts' {
2954
+ interface ChartEventMap {
2955
+ /** A drawing tool became active, or none is (`tool: null`). */
2956
+ 'draw:tool': DrawingToolEvent;
2957
+ /** A drawing was created, once per drawing. */
2958
+ 'draw:add': DrawingEvent;
2959
+ /** A drawing's anchors, style, text or flags changed, once per drawing. */
2960
+ 'draw:update': DrawingEvent;
2961
+ /** A drawing was deleted, once per drawing. */
2962
+ 'draw:remove': DrawingEvent;
2963
+ /** The selection changed; `id` is the primary (first picked) id. Fires with `drawing:select`. */
2964
+ 'draw:select': DrawingIdEvent;
2965
+ /** A copy reached the clipboard (copies, not the live drawings). */
2966
+ 'draw:copy': DrawingListEvent;
2967
+ /** A cut wrote to the clipboard and then deleted. */
2968
+ 'draw:cut': DrawingListEvent;
2969
+ /** The drawings a paste created, after their own `draw:add`. */
2970
+ 'draw:paste': DrawingListEvent;
2971
+ /** Where a drag is carrying drawings, before it commits (copies). */
2972
+ 'draw:preview': DrawingListEvent;
2973
+ /** A drag preview ended, committed or not. */
2974
+ 'draw:preview-clear': DrawingIdsEvent;
2975
+ /** `fromJSON` or a chart restore replaced every drawing. */
2976
+ 'draw:restore': EmptyEvent;
2977
+ /** A controller was destroyed and let go of the chart. */
2978
+ 'draw:destroy': {
2979
+ controller: DrawingController;
2980
+ };
2981
+ /** The measure gesture started or ended. */
2982
+ 'draw:measure': DrawingModeEvent;
2983
+ /** The eraser was switched on or off. */
2984
+ 'draw:eraser': DrawingModeEvent;
2985
+ /** One per mutation, after the per-drawing `draw:*` events. */
2986
+ 'drawing:change': DrawingChangeEvent;
2987
+ /** The whole selection, when it changed. */
2988
+ 'drawing:select': DrawingIdsEvent;
2989
+ /** The unselected drawing under the pointer changed. */
2990
+ 'drawing:hover': DrawingIdEvent;
2991
+ }
2992
+ }
2993
+
2958
2994
  /**
2959
2995
  * Hit-test geometry for the drawing tier. Everything works in media px and
2960
2996
  * returns a distance, so `DrawingLayer` can pick the nearest shape under the
@@ -3048,4 +3084,4 @@ declare const PATTERN_DRAWING_TOOLS: readonly DrawingTool[];
3048
3084
 
3049
3085
  declare const DRAW_TIER: "draw";
3050
3086
 
3051
- export { ADVANCED_GEOMETRY_TOOLS, ADVANCED_LINE_TOOLS, ALIGN_OPTIONS, ANCHORED_VWAP, ARC, ARROW, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, type AnalysisProfileRow, type AnalysisStatus, type AnchoredVwapOptions, type AnchoredVwapPoint, type AnchoredVwapResult, type AnchoredVwapSource, BALLOON, BRUSH, BUILTIN_DRAWING_TOOLS, CALLOUT, CHROME_ICONS, CHROME_ICON_ACCENTS, CHROME_ICON_ATTRS, CHROME_ICON_FILLED, CHROME_ICON_STROKE, CHROME_ICON_VIEWBOX, CIRCLE, COLOR_FIELD, COMMENT, CROSS_LINE, CURVE, CYCLE_PALETTE, CYCLIC_LINES, type ClipboardPort, DATE_RANGE, DEFAULT_FIB, DEFAULT_FIB_FAN, DEFAULT_FIB_TIME_ZONE, DEFAULT_GANN_BOX, DEFAULT_GANN_FAN, DOUBLE_CURVE, DRAWING_CLIPBOARD_KEY, DRAWING_CLIPBOARD_VERSION, DRAWING_STATE_VERSION, DRAWING_TOOL_ACCENTS, DRAWING_TOOL_ICONS, DRAW_TIER, type DrawContext, type Drawing, type DrawingChangeEvent, type DrawingChangeKind, type DrawingChartHost, DrawingClipboard, type DrawingClipboardOptions, DrawingController, type DrawingControllerOptions, type DrawingDocumentStore, type DrawingEditOptions, type DrawingGestureOptions, type DrawingGroup, type DrawingInput, type DrawingInstrument, type DrawingIntervalRange, type DrawingKeyAction, type DrawingKeyContext, type DrawingKeyEvent, DrawingLayer, type DrawingLayerOrder, type DrawingLinkChart, type DrawingLinkContext, type DrawingLinkContextSource, DrawingLinkGroup, type DrawingLinkOptions, type DrawingPatch, type DrawingPlacementOptions, type DrawingPoint, type DrawingPointerKind, type DrawingPolicy, type DrawingSpace, type DrawingStackTarget, type DrawingStyle, type DrawingText, type DrawingTextStorage, type DrawingTool, type DrawingValueContext, type DrawingsDocument, ELLIPSE, EXTENDED_LINE, EXTEND_FIELDS, type ExpandContext, FIB_CHANNEL, FIB_EXTENSION, FIB_FAN, FIB_RETRACEMENT, FIB_TIME_ZONE, FILL_FIELDS, FIXED_RANGE_VOLUME_PROFILE, FLAG_MARK, FONT_FIELDS, FONT_OPTIONS, FORECAST, type FibLevel, type FieldGroup, type FieldKind, type FixedRangeVolumeProfileOptions, type FixedRangeVolumeProfileResult, GANN_BOX, GANN_FAN, HIGHLIGHTER, HORIZONTAL_LINE, HORIZONTAL_RAY, type HitContext, ICON_ATTRS, ICON_STROKE, ICON_SYMBOL_PREFIX, ICON_VIEWBOX, INTERVAL_FIELDS, type IconAttrs, type IconSvgOptions, type InputAnchorStep, InstrumentDrawings, type InstrumentDrawingsChart, type InstrumentDrawingsError, type InstrumentDrawingsOptions, LEVEL_FIELDS, LEVEL_NEUTRAL, LINE_FIELDS, LINE_STYLE_FIELD, LINE_STYLE_OPTIONS, LINE_WIDTH_FIELD, LONG_POSITION, MEASURE, type MagnetMode, NOTE, NUDGE_STEP_PX, NUDGE_STEP_SHIFT_PX, PARALLEL_CHANNEL, PATH, PATTERN_DRAWING_TOOLS, PLATE_TEXT_FIELDS, POLYLINE, PRICE_LABEL, PRICE_NOTE, PRICE_RANGE, RAY, RECTANGLE, ROTATED_RECTANGLE, SHAPE_TEXT_FIELDS, SHORT_POSITION, SHOW_LABELS_FIELD, SIGNPOST, SINE_LINE, SPACE_FIELD, SPACE_OPTIONS, type ScreenPoint, type SettingsField, type SettingsSchema, type ShortcutEvent, type StudyInputTarget, TABLE, TEXT, TEXT_FIELDS, TEXT_POSITION_OPTIONS, TEXT_VALUE_FIELD, TIME_CYCLES, TREND_LINE, TRIANGLE, type ToolCursorOptions, VALIGN_OPTIONS, VERTICAL_LINE, type ViewportPoint, anchoredVwapAnalysis, applyDrawingSettings, boundsOf, catmullRom, chromeIcon, chromeIconAccent, chromeIconIds, chromeIconSvg, clearMemoryClipboard, cloneDrawing, cloneLevels, coerceSettingValue, composeSettings, createDrawingLinkGroup, createInstrumentDrawings, cycleColor, decodeClipboardPayload, distToEllipse, distToLine, distToPolyline, distToRect, distToSegment, drawingSettingsSchema, drawingShortcuts, drawingShownOnInterval, drawingToolAccent, drawingToolIcon, drawingToolIconIds, encodeClipboardPayload, extendSegment, fixedRangeVolumeProfileAnalysis, formatRatio, gannLabel, getDrawingTool, hasDrawingTool, iconSprite, iconSvg, iconUse, instrumentDrawingsKey, keyToDrawingAction, levelColor, matchDrawingShortcut, memoryDrawingStore, migrateDrawings, migrateUnscopedDrawings, pressureWidth, rdpSimplify, readDrawingSetting, readDrawingSettings, rectOf, registerBuiltinDrawingTools, registerDrawingTool, registeredDrawingTools, sanitizeDrawing, sortByZIndex, studyInputTarget, systemClipboard, toolCursor, webStorageDrawingStore };
3087
+ export { ADVANCED_GEOMETRY_TOOLS, ADVANCED_LINE_TOOLS, ALIGN_OPTIONS, ANCHORED_VWAP, ARC, ARROW, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, type AnalysisProfileRow, type AnalysisStatus, type AnchoredVwapOptions, type AnchoredVwapPoint, type AnchoredVwapResult, type AnchoredVwapSource, BALLOON, BRUSH, BUILTIN_DRAWING_TOOLS, CALLOUT, CHROME_ICONS, CHROME_ICON_ACCENTS, CHROME_ICON_ATTRS, CHROME_ICON_FILLED, CHROME_ICON_STROKE, CHROME_ICON_VIEWBOX, CIRCLE, COLOR_FIELD, COMMENT, CROSS_LINE, CURVE, CYCLE_PALETTE, CYCLIC_LINES, type ClipboardPort, DATE_RANGE, DEFAULT_FIB, DEFAULT_FIB_FAN, DEFAULT_FIB_TIME_ZONE, DEFAULT_GANN_BOX, DEFAULT_GANN_FAN, DOUBLE_CURVE, DRAWING_CLIPBOARD_KEY, DRAWING_CLIPBOARD_VERSION, DRAWING_STATE_VERSION, DRAWING_TOOL_ACCENTS, DRAWING_TOOL_ICONS, DRAW_TIER, type DrawContext, type Drawing, type DrawingChangeEvent, type DrawingChangeKind, type DrawingChartHost, DrawingClipboard, type DrawingClipboardOptions, DrawingController, type DrawingControllerOptions, type DrawingDocumentStore, type DrawingEditOptions, type DrawingEvent, type DrawingGestureOptions, type DrawingGroup, type DrawingIdEvent, type DrawingIdsEvent, type DrawingInput, type DrawingInstrument, type DrawingIntervalRange, type DrawingKeyAction, type DrawingKeyContext, type DrawingKeyEvent, DrawingLayer, type DrawingLayerOrder, type DrawingLinkChart, type DrawingLinkContext, type DrawingLinkContextSource, DrawingLinkGroup, type DrawingLinkOptions, type DrawingListEvent, type DrawingModeEvent, type DrawingPatch, type DrawingPlacementOptions, type DrawingPoint, type DrawingPointerKind, type DrawingPolicy, type DrawingSpace, type DrawingStackTarget, type DrawingStyle, type DrawingText, type DrawingTextStorage, type DrawingTool, type DrawingToolEvent, type DrawingValueContext, type DrawingsDocument, ELLIPSE, EXTENDED_LINE, EXTEND_FIELDS, type ExpandContext, FIB_CHANNEL, FIB_EXTENSION, FIB_FAN, FIB_RETRACEMENT, FIB_TIME_ZONE, FILL_FIELDS, FIXED_RANGE_VOLUME_PROFILE, FLAG_MARK, FONT_FIELDS, FONT_OPTIONS, FORECAST, type FibLevel, type FieldGroup, type FieldKind, type FixedRangeVolumeProfileOptions, type FixedRangeVolumeProfileResult, GANN_BOX, GANN_FAN, HIGHLIGHTER, HORIZONTAL_LINE, HORIZONTAL_RAY, type HitContext, ICON_ATTRS, ICON_STROKE, ICON_SYMBOL_PREFIX, ICON_VIEWBOX, INTERVAL_FIELDS, type IconAttrs, type IconSvgOptions, type InputAnchorStep, InstrumentDrawings, type InstrumentDrawingsChart, type InstrumentDrawingsError, type InstrumentDrawingsOptions, LEVEL_FIELDS, LEVEL_NEUTRAL, LINE_FIELDS, LINE_STYLE_FIELD, LINE_STYLE_OPTIONS, LINE_WIDTH_FIELD, LONG_POSITION, type LayoutIconSlot, MEASURE, type MagnetMode, NOTE, NUDGE_STEP_PX, NUDGE_STEP_SHIFT_PX, PARALLEL_CHANNEL, PATH, PATTERN_DRAWING_TOOLS, PLATE_TEXT_FIELDS, POLYLINE, PRICE_LABEL, PRICE_NOTE, PRICE_RANGE, RAY, RECTANGLE, ROTATED_RECTANGLE, SHAPE_TEXT_FIELDS, SHORT_POSITION, SHOW_LABELS_FIELD, SIGNPOST, SINE_LINE, SPACE_FIELD, SPACE_OPTIONS, type ScreenPoint, type SettingsField, type SettingsSchema, type ShortcutEvent, type StudyInputTarget, TABLE, TEXT, TEXT_FIELDS, TEXT_POSITION_OPTIONS, TEXT_VALUE_FIELD, TIME_CYCLES, TREND_LINE, TRIANGLE, type ToolCursorOptions, VALIGN_OPTIONS, VERTICAL_LINE, type ViewportPoint, anchoredVwapAnalysis, applyDrawingSettings, boundsOf, catmullRom, chartTypeIcon, chromeIcon, chromeIconAccent, chromeIconIds, chromeIconSvg, clearMemoryClipboard, cloneDrawing, cloneLevels, coerceSettingValue, composeSettings, createDrawingLinkGroup, createInstrumentDrawings, cycleColor, decodeClipboardPayload, distToEllipse, distToLine, distToPolyline, distToRect, distToSegment, drawingSettingsSchema, drawingShortcuts, drawingShownOnInterval, drawingToolAccent, drawingToolIcon, drawingToolIconIds, encodeClipboardPayload, extendSegment, fixedRangeVolumeProfileAnalysis, formatRatio, gannLabel, getDrawingTool, hasDrawingTool, iconSprite, iconSvg, iconUse, instrumentDrawingsKey, keyToDrawingAction, layoutIconPath, levelColor, matchDrawingShortcut, memoryDrawingStore, migrateDrawings, migrateUnscopedDrawings, pressureWidth, rdpSimplify, readDrawingSetting, readDrawingSettings, rectOf, registerBuiltinDrawingTools, registerDrawingTool, registeredDrawingTools, sanitizeDrawing, sortByZIndex, studyInputTarget, systemClipboard, toolCursor, webStorageDrawingStore };