@orangecharts/wrun-chart-host 0.3.0 → 0.4.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 (50) hide show
  1. package/README.md +11 -5
  2. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +133 -0
  3. package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
  4. package/dist/host-env.d.ts +8 -6
  5. package/dist/host-ports.types.d.ts +7 -22
  6. package/dist/index.d.ts +10 -0
  7. package/dist/index.js +10 -0
  8. package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
  9. package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
  10. package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
  11. package/dist/utility/chart/indicator-run-interval.util.js +268 -0
  12. package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
  13. package/dist/utility/chart/window-geometry.leaf.js +391 -0
  14. package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
  15. package/dist/utility/chart/window-owner.leaf.js +24 -0
  16. package/dist/utility/html-escape.leaf.d.ts +11 -0
  17. package/dist/utility/html-escape.leaf.js +20 -0
  18. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +43 -15
  19. package/dist/utility/wrun/sources/lanes/option_daily.js +78 -20
  20. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +14 -10
  21. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +5 -4
  22. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +22 -3
  23. package/dist/utility/wrun/sources/opra-option-lanes.util.js +38 -7
  24. package/dist/utility/wrun/sources/registry.js +31 -1
  25. package/dist/utility/wrun/sources/row-lane-registry.js +5 -5
  26. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +49 -0
  27. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +74 -18
  28. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +49 -0
  29. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +57 -47
  30. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +36 -4
  31. package/dist/utility/wrun/sources/row-lanes/option_surface.js +6 -12
  32. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +37 -3
  33. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +128 -2
  34. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +233 -51
  35. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +0 -8
  36. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +26 -24
  37. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +85 -104
  38. package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +29 -10
  39. package/dist/utility/wrun/wrun-opra-stats.leaf.js +29 -10
  40. package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
  41. package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
  42. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +377 -0
  43. package/dist/utility/wrun/wrun-panel-mount.util.js +2251 -0
  44. package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
  45. package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
  46. package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
  47. package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
  48. package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
  49. package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
  50. package/package.json +1 -1
@@ -0,0 +1,391 @@
1
+ /**
2
+ * Window geometry: how the owner's panes share a window cell (window-cell.util).
3
+ *
4
+ * A leaf with no app import: window-geometry.util re-exports every name here and adds the one entry that reads the
5
+ * cell's owner (`reconcileWindowGeometry`, through the cell readers, whose draft windows are reactive). The child
6
+ * mount (wrun-panel-mount.util) reads the plan, the saved split and the owner reconcile, and it moves into the wrun
7
+ * chart-host package, which titan's constants may not reach: the engine minimum comes from the titan constants pin
8
+ * (titan-constants.pin, which a spec compares with the installed engine's). The reader's hold and the reversal stay
9
+ * beside the owner reconcile: the three share the one map of held windows.
10
+ *
11
+ * A window is a chart cell whose candle pane the window host hid
12
+ * (useWrunWindowCell, through the pane-only main helper) so the owner's
13
+ * child panes (`::panel:*`, `::series:*`) and, for a lower-only package, the
14
+ * owner's own offchart pane fill the whole cell. The engine carves a pane's
15
+ * height at addOverlay only and, with main hidden, splits the visible panes
16
+ * evenly; neither knows a table from a time series. This module is the ONE
17
+ * place that decides the window's weights (planWindowWeights) and the ONE
18
+ * writer that applies them to already-mounted panes (reconcileWindowOwnerGeometry, the cell entry's step)
19
+ * through the same height path the offchart restore uses (meta.gridHeight +
20
+ * settings.gridHeight + updateSettings + resizeCanvasOnce).
21
+ *
22
+ * Rule (plan section 2.2): tables at their content height (panelGridHeight)
23
+ * but all tables together at most WINDOW_TABLES_MAX_TOTAL of the cell;
24
+ * chart-shaped panels ('chart') and time panes ('time': the lower series pane
25
+ * or an offchart owner) split the remainder equally; everything normalized to
26
+ * sum 1; no pane under the engine minimum (MIN_GRID_HEIGHT_ALLOWED): when the
27
+ * base rule leaves panes under it they are pinned at the minimum and the
28
+ * largest pane absorbs the difference (cascading to the next largest when the
29
+ * largest cannot). More panes than the minimum allows (n x min > 1, eight
30
+ * panes and up) can satisfy no engine carve: the plan is the even split then,
31
+ * which is what the engine falls back to on its own.
32
+ *
33
+ * Main is never written here: the host owns hide and restore, and the
34
+ * reconcile writes only while main is hidden, so a visible candle pane is
35
+ * never squeezed by sum-1 weights. A cell without a flagged owner never gets
36
+ * a write (isWindowCell gates the entry).
37
+ *
38
+ * The reader's own split outranks the plan. The reconcile runs at the end of
39
+ * EVERY run of the owner (the child mount calls it on each live tick), so a
40
+ * plan that re-asserts itself there undoes a splitter drag within one tick.
41
+ * A drag in a window (the engine's `resize-grids`, which nothing else emits)
42
+ * is a hold (holdWindowPaneHeights): the dragged heights become the panes'
43
+ * requests and the reconcile writes no weight while the same panes are
44
+ * mounted. A pane joining or leaving, a re-mounted pane, the reversal and a
45
+ * rebuilt engine all end the hold, and the plan applies again.
46
+ *
47
+ * The hold is memory; the split outlives it in the document. The hold hands
48
+ * back the dragged weights keyed relative to the owner (`self`, `panel:<name>`,
49
+ * `series:<name>`), the host writes them to the OWNER row as
50
+ * `settings.wrunWindowSplit` (window-cell.util; the children have no rows),
51
+ * and savedWindowSplit reads them back only while they name exactly the
52
+ * mounted panes: the child mount asks for them (no flash of the plan after a
53
+ * reload) and the reconcile, when nothing is held, takes them as the plan. So
54
+ * a re-mount over the same pane ids keeps the reader's split (their intent
55
+ * outranks the plan), a pane joining or leaving makes the split stop matching
56
+ * and the plan applies, and Show chart deletes it with the flag.
57
+ */
58
+ import { PANEL_CHART_GRID_HEIGHT, panelGridHeight } from './om-panel.util.js';
59
+ import { MIN_GRID_HEIGHT_ALLOWED } from './titan-constants.pin.js';
60
+ import { WRUN_WINDOW_SPLIT_SETTING } from './window-owner.leaf.js';
61
+ import { wrunChildOverlayParentId } from '../wrun/wrun-child-overlay-id.util.js';
62
+ /** The split key of a window pane: `self` for the owner, a child's id past `<owner>::`. */
63
+ export function windowSplitKeyOf(paneId) {
64
+ const parent = wrunChildOverlayParentId(paneId);
65
+ return parent === null ? 'self' : paneId.slice(parent.length + 2);
66
+ }
67
+ /** A record of at least one finite positive weight: the only shape the split reader and writer accept. */
68
+ export function isWindowSplit(value) {
69
+ if (value === null || typeof value !== 'object' || Array.isArray(value))
70
+ return false;
71
+ const weights = Object.values(value);
72
+ return (weights.length > 0 && weights.every((weight) => typeof weight === 'number' && Number.isFinite(weight) && weight > 0));
73
+ }
74
+ /** The engine's pane minimum: a carve under it is refused. */
75
+ export const WINDOW_PANE_MIN_GRID_HEIGHT = MIN_GRID_HEIGHT_ALLOWED;
76
+ /** All tables of a window together take at most half the cell. */
77
+ export const WINDOW_TABLES_MAX_TOTAL = 0.5;
78
+ /** Heights closer than this are the same height: the in-place refresh rule's
79
+ * tolerance (samePanelPane) and the reconcile's write threshold. */
80
+ export const WINDOW_GRID_HEIGHT_TOLERANCE = 0.005;
81
+ /** panelGridHeight reads the panel's kind only. */
82
+ const TABLE_PANEL = { kind: 'table' };
83
+ const WEIGHT_DECIMALS = 4;
84
+ function roundWeight(value) {
85
+ const scale = 10 ** WEIGHT_DECIMALS;
86
+ return Math.round(value * scale) / scale;
87
+ }
88
+ /** Round every weight to 4 decimals; the rounding remainder rides the largest pane so the set sums to 1. */
89
+ function roundWeightsToOne(weights) {
90
+ const rounded = weights.map(roundWeight);
91
+ const sum = rounded.reduce((total, weight) => total + weight, 0);
92
+ const largest = rounded.reduce((best, weight, at) => (weight > rounded[best] ? at : best), 0);
93
+ rounded[largest] = roundWeight(rounded[largest] + (1 - sum));
94
+ return rounded;
95
+ }
96
+ /** Pin every pane under the minimum at the minimum; the largest absorbs the
97
+ * deficit, the next largest what the largest cannot give without dropping
98
+ * under the minimum itself. Only called when n x min <= 1: the panes above
99
+ * the minimum then always hold enough slack, so one pass settles. */
100
+ function applyFloor(weights) {
101
+ const out = [...weights];
102
+ const min = WINDOW_PANE_MIN_GRID_HEIGHT;
103
+ const epsilon = 1e-9;
104
+ let deficit = 0;
105
+ const pinned = new Set();
106
+ out.forEach((weight, at) => {
107
+ if (weight < min - epsilon) {
108
+ deficit += min - weight;
109
+ out[at] = min;
110
+ pinned.add(at);
111
+ }
112
+ });
113
+ if (deficit <= epsilon)
114
+ return out;
115
+ const donors = out
116
+ .map((weight, at) => ({ weight, at }))
117
+ .filter(({ at }) => !pinned.has(at))
118
+ .sort((a, b) => b.weight - a.weight);
119
+ for (const donor of donors) {
120
+ if (deficit <= epsilon)
121
+ break;
122
+ const give = Math.min(deficit, out[donor.at] - min);
123
+ if (give <= 0)
124
+ continue;
125
+ out[donor.at] -= give;
126
+ deficit -= give;
127
+ }
128
+ return out;
129
+ }
130
+ /**
131
+ * The window's weights for a pane set, in the given order. Pure: the same
132
+ * panes and canvas height always plan the same weights (the reconcile's
133
+ * idempotence and the first mount's no-flash both rest on that).
134
+ */
135
+ export function planWindowWeights(panes, canvasHeightPx) {
136
+ const count = panes.length;
137
+ if (count === 0)
138
+ return [];
139
+ let weights;
140
+ if (count * WINDOW_PANE_MIN_GRID_HEIGHT > 1 + 1e-9) {
141
+ // No plan satisfies the engine minimum: the even split, the engine's own fallback.
142
+ weights = panes.map(() => 1 / count);
143
+ }
144
+ else {
145
+ const tableAt = panes.map((pane) => pane.kind === 'table');
146
+ const tableRaw = panes.map((pane) => pane.kind === 'table' ? panelGridHeight(TABLE_PANEL, Math.max(0, pane.rows ?? 0), canvasHeightPx) : 0);
147
+ const tableTotal = tableRaw.reduce((sum, weight) => sum + weight, 0);
148
+ const others = tableAt.filter((isTable) => !isTable).length;
149
+ if (others === 0) {
150
+ // Tables only: they are the whole cell.
151
+ weights = tableRaw.map((weight) => weight / tableTotal);
152
+ }
153
+ else {
154
+ const tablesShare = Math.min(tableTotal, WINDOW_TABLES_MAX_TOTAL);
155
+ const otherShare = (1 - tablesShare) / others;
156
+ weights = panes.map((pane, at) => pane.kind === 'table' ? (tableRaw[at] * tablesShare) / tableTotal : otherShare);
157
+ }
158
+ weights = applyFloor(weights);
159
+ }
160
+ const rounded = roundWeightsToOne(weights);
161
+ return panes.map((pane, at) => ({ id: pane.id, gridHeight: rounded[at] }));
162
+ }
163
+ /** The body rows of a table pane (a mounted meta or an addOverlay config):
164
+ * its one decorator row's grid minus the header; undefined when unreadable. */
165
+ export function tableRowCountOf(pane) {
166
+ const rows = (pane.rawData ?? pane.data);
167
+ if (!Array.isArray(rows))
168
+ return undefined;
169
+ const payload = rows[0]?.[1];
170
+ const grid = payload?.data;
171
+ return Array.isArray(grid) ? Math.max(0, grid.length - 1) : undefined;
172
+ }
173
+ /** Whether a mounted meta occupies its own band in the window: an offchart
174
+ * pane of the owner (the owner itself or one of its children), not pane
175
+ * hidden, not hosted inside another pane. */
176
+ function isWindowPaneMeta(meta, ownerId) {
177
+ if (meta.type !== 'offchart' || meta.isPaneHidden === true || meta.hostPaneId)
178
+ return false;
179
+ return meta.id === ownerId || wrunChildOverlayParentId(meta.id) === ownerId;
180
+ }
181
+ /** The owner's mounted window pane metas, in stack order. */
182
+ function windowPaneMetas(metadata, ownerId) {
183
+ return metadata.filter((meta) => isWindowPaneMeta(meta, ownerId));
184
+ }
185
+ /** A window pane meta as the planner reads it. */
186
+ function windowPaneOf(meta, ownerId) {
187
+ if (meta.id === ownerId || meta.id.includes('::series:'))
188
+ return { id: meta.id, kind: 'time' };
189
+ if (meta.plot === 'table')
190
+ return { id: meta.id, kind: 'table', rows: tableRowCountOf(meta) };
191
+ return { id: meta.id, kind: 'chart' };
192
+ }
193
+ /** The owner's mounted window panes, in stack order, classified for the planner. */
194
+ export function mountedWindowPanes(metadata, ownerId) {
195
+ return windowPaneMetas(metadata, ownerId).map((meta) => windowPaneOf(meta, ownerId));
196
+ }
197
+ /** Whether the candle pane is hidden on this engine: the window layout is in force. */
198
+ export function isMainPaneHidden(metadata) {
199
+ const main = metadata.find((meta) => meta.id === 'main') ?? metadata[0];
200
+ return main?.isPaneHidden === true;
201
+ }
202
+ /** Engine to its held window. Weak: a rebuilt engine starts on the plan. */
203
+ const windowHolds = new WeakMap();
204
+ /** Whether the reader's split still stands: a hold for this owner over exactly
205
+ * the pane metas mounted now. Anything else (a pane joined, left or was
206
+ * re-mounted) ends the hold. */
207
+ function isWindowHeld(tc, ownerId, metas) {
208
+ const hold = windowHolds.get(tc);
209
+ if (!hold)
210
+ return false;
211
+ if (hold.ownerId === ownerId && hold.panes.size === metas.length && metas.every((meta) => hold.panes.has(meta))) {
212
+ return true;
213
+ }
214
+ windowHolds.delete(tc);
215
+ return false;
216
+ }
217
+ /**
218
+ * The reader dragged a splitter in a window (the engine's `resize-grids`):
219
+ * the heights on the engine are theirs now. They become the panes' requests
220
+ * (under a hidden main the engine re-splits the stack from
221
+ * `settings.gridHeight` on every pane add, removal, collapse and focus exit,
222
+ * so a request left at the plan would undo the drag there), and the plan
223
+ * stands down: reconcileWindowOwnerGeometry writes no weight until the pane
224
+ * set changes. No engine call: the drag already laid the panes out, and this
225
+ * runs on every drag move. Silent on a normal chart (main visible) and for an
226
+ * owner without a pane. Returns the held weights as the window's split
227
+ * (WindowSplit: keyed relative to the owner, normalized to 1, rounded), the
228
+ * value the host writes to the owner row; undefined when nothing is held, or
229
+ * when a held pane has no usable height yet (nothing worth saving).
230
+ */
231
+ export function holdWindowPaneHeights(tc, ownerId) {
232
+ if (!tc || tc.isDestroyed)
233
+ return undefined;
234
+ if (!isMainPaneHidden(tc.metadata))
235
+ return undefined;
236
+ const metas = windowPaneMetas(tc.metadata, ownerId);
237
+ if (metas.length === 0)
238
+ return undefined;
239
+ const heights = [];
240
+ for (const meta of metas) {
241
+ const height = meta.gridHeight;
242
+ if (typeof height !== 'number' || !Number.isFinite(height) || height <= 0)
243
+ continue;
244
+ const settings = (meta.settings ??= {});
245
+ if (settings.gridHeight !== height)
246
+ settings.gridHeight = height;
247
+ heights.push(height);
248
+ }
249
+ windowHolds.set(tc, { ownerId, panes: new Set(metas) });
250
+ if (heights.length !== metas.length)
251
+ return undefined;
252
+ const total = heights.reduce((sum, height) => sum + height, 0);
253
+ const weights = roundWeightsToOne(heights.map((height) => height / total));
254
+ return Object.fromEntries(metas.map((meta, at) => [windowSplitKeyOf(meta.id), weights[at]]));
255
+ }
256
+ /**
257
+ * The reader's saved split for the panes mounted now: the owner's
258
+ * `settings.wrunWindowSplit` read back as weights in the panes' order, only
259
+ * when its key set equals the mounted pane set exactly (renormalized to 1,
260
+ * the engine minimum applied, rounded like the plan). Anything else is
261
+ * undefined and the plan applies: a split saved over other panes (one joined
262
+ * or left since), a malformed value, or more panes than the minimum allows
263
+ * (no split satisfies the engine then; the plan is the even split). Pure.
264
+ */
265
+ export function savedWindowSplit(ownerSettings, panes) {
266
+ const saved = ownerSettings?.[WRUN_WINDOW_SPLIT_SETTING];
267
+ if (!isWindowSplit(saved) || panes.length === 0)
268
+ return undefined;
269
+ if (panes.length * WINDOW_PANE_MIN_GRID_HEIGHT > 1 + 1e-9)
270
+ return undefined;
271
+ const keys = panes.map((pane) => windowSplitKeyOf(pane.id));
272
+ if (new Set(keys).size !== keys.length || Object.keys(saved).length !== keys.length)
273
+ return undefined;
274
+ if (!keys.every((key) => Object.prototype.hasOwnProperty.call(saved, key)))
275
+ return undefined;
276
+ const raw = keys.map((key) => saved[key]);
277
+ const total = raw.reduce((sum, weight) => sum + weight, 0);
278
+ const weights = roundWeightsToOne(applyFloor(raw.map((weight) => weight / total)));
279
+ return panes.map((pane, at) => ({ id: pane.id, gridHeight: weights[at] }));
280
+ }
281
+ /**
282
+ * Apply the window plan to the OWNER's already-mounted panes: every pane whose
283
+ * engine height is off the plan by WINDOW_GRID_HEIGHT_TOLERANCE or more takes
284
+ * the planned height through the offchart height path, then one resize.
285
+ * Writes nothing while the candle pane is visible (the host hides it first;
286
+ * sum-1 weights beside a visible main would squeeze the candles), and no
287
+ * weight while the reader's own split holds (holdWindowPaneHeights). With
288
+ * nothing held, the reader's saved split (savedWindowSplit over the owner's
289
+ * engine copy, patched in step with the row) is the plan while it names
290
+ * exactly the mounted panes; else the planner's. Main itself is never
291
+ * written. Returns whether anything was written.
292
+ */
293
+ export function reconcileWindowOwnerGeometry(tc, ownerId, canvasHeightPx) {
294
+ if (!tc || tc.isDestroyed || typeof tc.updateSettings !== 'function')
295
+ return false;
296
+ if (!isMainPaneHidden(tc.metadata)) {
297
+ // The window layout is not in force: no hold outlives it.
298
+ windowHolds.delete(tc);
299
+ return false;
300
+ }
301
+ const metas = windowPaneMetas(tc.metadata, ownerId);
302
+ const height = canvasHeightPx ?? tc.canvasChartController?.canvasElement?.clientHeight;
303
+ let plan = [];
304
+ if (metas.length > 0 && !isWindowHeld(tc, ownerId, metas)) {
305
+ const panes = metas.map((meta) => windowPaneOf(meta, ownerId));
306
+ const owner = tc.metadata.find((candidate) => candidate.id === ownerId);
307
+ plan = savedWindowSplit(owner?.settings, panes) ?? planWindowWeights(panes, height);
308
+ }
309
+ let written = false;
310
+ for (const { id, gridHeight } of plan) {
311
+ const meta = tc.metadata.find((candidate) => candidate.id === id);
312
+ if (!meta)
313
+ continue;
314
+ const current = meta.gridHeight;
315
+ if (typeof current === 'number' && Math.abs(current - gridHeight) < WINDOW_GRID_HEIGHT_TOLERANCE)
316
+ continue;
317
+ meta.gridHeight = gridHeight;
318
+ meta.settings = { ...(meta.settings ?? {}), gridHeight };
319
+ void tc.updateSettings(id, { gridHeight });
320
+ written = true;
321
+ }
322
+ // The pinned engine floors a hidden main back to its minimum when the panes
323
+ // sum to 1 (overflow correction), and onchart furniture (volume, the owner's
324
+ // price plots, high/low marks) then paints in that ghost band. Pin it at 0:
325
+ // the layout reads the meta height, the section stays display:none.
326
+ const main = tc.metadata.find((candidate) => candidate.id === 'main') ?? tc.metadata[0];
327
+ if (main && main.isPaneHidden === true && main.gridHeight !== 0) {
328
+ main.gridHeight = 0;
329
+ main.settings = { ...(main.settings ?? {}), gridHeight: 0 };
330
+ written = true;
331
+ }
332
+ if (written)
333
+ tc.resizeCanvasOnce?.();
334
+ return written;
335
+ }
336
+ /**
337
+ * The reversal (Show chart): every pane the owner mounted goes back to the
338
+ * height a normal chart mounts it at (plan section 2.2): chart-shaped panels
339
+ * and time panes at PANEL_CHART_GRID_HEIGHT, a table at its content height.
340
+ * Writes only once the candle pane is visible again (the host releases main
341
+ * first), so the engine carves the panes out of main the way a fresh mount
342
+ * would. Keyed by the owner id because the flag is already off by then.
343
+ * Returns whether anything was written.
344
+ */
345
+ export function restoreNormalOwnerGeometry(tc, ownerId, canvasHeightPx) {
346
+ if (!tc || tc.isDestroyed || typeof tc.updateSettings !== 'function')
347
+ return false;
348
+ if (isMainPaneHidden(tc.metadata))
349
+ return false;
350
+ // Back to a chart: the reader's window split ends with the window.
351
+ windowHolds.delete(tc);
352
+ const panes = mountedWindowPanes(tc.metadata, ownerId);
353
+ if (panes.length === 0)
354
+ return false;
355
+ const height = canvasHeightPx ?? tc.canvasChartController?.canvasElement?.clientHeight;
356
+ let written = false;
357
+ for (const pane of panes) {
358
+ const meta = tc.metadata.find((candidate) => candidate.id === pane.id);
359
+ if (!meta)
360
+ continue;
361
+ const gridHeight = pane.kind === 'table'
362
+ ? panelGridHeight(TABLE_PANEL, Math.max(0, pane.rows ?? 0), height)
363
+ : PANEL_CHART_GRID_HEIGHT;
364
+ const current = meta.gridHeight;
365
+ if (typeof current === 'number' && Math.abs(current - gridHeight) < WINDOW_GRID_HEIGHT_TOLERANCE)
366
+ continue;
367
+ meta.gridHeight = gridHeight;
368
+ meta.settings = { ...(meta.settings ?? {}), gridHeight };
369
+ void tc.updateSettings(pane.id, { gridHeight });
370
+ written = true;
371
+ }
372
+ // The engine's togglePane('main', true) redistributed evenly (main two
373
+ // shares); the children just went back to their fixed heights, so main
374
+ // takes the rest of the cell, never under the engine minimum and never a
375
+ // sum above 1 that would clip the stack.
376
+ const main = tc.metadata.find((candidate) => candidate.id === 'main') ?? tc.metadata[0];
377
+ if (main && main.isPaneHidden !== true) {
378
+ const offchart = tc.metadata
379
+ .filter((meta) => meta !== main && meta.type === 'offchart' && meta.isPaneHidden !== true && !meta.hostPaneId)
380
+ .reduce((total, meta) => total + (typeof meta.gridHeight === 'number' ? meta.gridHeight : 0), 0);
381
+ const share = Math.max(WINDOW_PANE_MIN_GRID_HEIGHT, Math.round((1 - offchart) * 10000) / 10000);
382
+ if (typeof main.gridHeight !== 'number' || Math.abs(main.gridHeight - share) >= WINDOW_GRID_HEIGHT_TOLERANCE) {
383
+ main.gridHeight = share;
384
+ main.settings = { ...(main.settings ?? {}), gridHeight: share };
385
+ written = true;
386
+ }
387
+ }
388
+ if (written)
389
+ tc.resizeCanvasOnce?.();
390
+ return written;
391
+ }
@@ -0,0 +1,19 @@
1
+ /** The owner flag's settings key (persisted: `settingsToSave`, indicator.constants). */
2
+ export declare const WRUN_WINDOW_SETTING = "wrunWindow";
3
+ /**
4
+ * The saved split's settings key (persisted beside the flag): the reader's
5
+ * splitter drag in a window as pane weights keyed relative to the owner
6
+ * (`self`, `panel:<name>`, `series:<name>`), rounded to 4 decimals, summing
7
+ * to 1. Written by the window host through the store's setWrunWindowSplit,
8
+ * read by window-geometry.util (savedWindowSplit) only while it names exactly
9
+ * the mounted panes, deleted with the flag (Show chart), stripped wherever
10
+ * the flag is.
11
+ */
12
+ export declare const WRUN_WINDOW_SPLIT_SETTING = "wrunWindowSplit";
13
+ /** An overlay as the window rules read it: its id and its settings bag. */
14
+ export type WindowOwnerOverlay = {
15
+ id?: unknown;
16
+ settings?: Record<string, unknown> | null;
17
+ } | null | undefined;
18
+ /** A wrun Indicator overlay (registry, draft or hosted lane) that carries the owner flag. */
19
+ export declare function isWrunWindowOwner(overlay: WindowOwnerOverlay): boolean;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The window owner rule of window-cell.util.ts (which re-exports every name here and reads them for the rest of the
3
+ * window contract) as a leaf with no app import: the owner flag's settings key, the saved split's settings key and
4
+ * the owner test. The child mount (wrun-panel-mount.util) and the window geometry leaf read them, and they move into
5
+ * the wrun chart-host package, which the cell readers' reactive draft windows (draft-window.util) may not reach.
6
+ */
7
+ import { isWrunPackageOverlaySettings } from '../wrun/wrun-overlay-identity.util.js';
8
+ /** The owner flag's settings key (persisted: `settingsToSave`, indicator.constants). */
9
+ export const WRUN_WINDOW_SETTING = 'wrunWindow';
10
+ /**
11
+ * The saved split's settings key (persisted beside the flag): the reader's
12
+ * splitter drag in a window as pane weights keyed relative to the owner
13
+ * (`self`, `panel:<name>`, `series:<name>`), rounded to 4 decimals, summing
14
+ * to 1. Written by the window host through the store's setWrunWindowSplit,
15
+ * read by window-geometry.util (savedWindowSplit) only while it names exactly
16
+ * the mounted panes, deleted with the flag (Show chart), stripped wherever
17
+ * the flag is.
18
+ */
19
+ export const WRUN_WINDOW_SPLIT_SETTING = 'wrunWindowSplit';
20
+ /** A wrun Indicator overlay (registry, draft or hosted lane) that carries the owner flag. */
21
+ export function isWrunWindowOwner(overlay) {
22
+ const settings = overlay?.settings;
23
+ return !!settings && settings[WRUN_WINDOW_SETTING] === true && isWrunPackageOverlaySettings(settings);
24
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The HTML escape of html-sanitizer.ts (which re-exports it) as a leaf with no import: the child mount
3
+ * (wrun-panel-mount.util) escapes its legend titles with it, and it moves into the wrun chart-host package, which the
4
+ * sanitizer's DOMPurify and app environment may not reach.
5
+ */
6
+ /**
7
+ * Escape a string for safe interpolation into HTML text or double-quoted
8
+ * attribute context. Use this when building HTML strings with template literals
9
+ * that later reach a v-html / innerHTML sink.
10
+ */
11
+ export declare function escapeHtml(input: unknown): string;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The HTML escape of html-sanitizer.ts (which re-exports it) as a leaf with no import: the child mount
3
+ * (wrun-panel-mount.util) escapes its legend titles with it, and it moves into the wrun chart-host package, which the
4
+ * sanitizer's DOMPurify and app environment may not reach.
5
+ */
6
+ /**
7
+ * Escape a string for safe interpolation into HTML text or double-quoted
8
+ * attribute context. Use this when building HTML strings with template literals
9
+ * that later reach a v-html / innerHTML sink.
10
+ */
11
+ export function escapeHtml(input) {
12
+ if (input === null || input === undefined)
13
+ return '';
14
+ return String(input)
15
+ .replace(/&/g, '&amp;')
16
+ .replace(/</g, '&lt;')
17
+ .replace(/>/g, '&gt;')
18
+ .replace(/"/g, '&quot;')
19
+ .replace(/'/g, '&#39;');
20
+ }
@@ -1,30 +1,58 @@
1
1
  /**
2
- * The `option_daily` lane (UW-PARITY source S5a): the chart underlying's daily options statistics (US listed options,
3
- * OPRA) as 31 scalars, a daily join (`input("iv30", option_daily.atm_iv_30d, { missing: "nan" })`): the underlying as
2
+ * The `option_daily` lane (UW-PARITY source S5a, OPTIONS-PORT P5): the daily options statistics of the chart's options
3
+ * chain as 31 scalars, a daily join (`input("iv30", option_daily.atm_iv_30d, { missing: "nan" })`): the underlying as
4
4
  * a symbol code, its price, the at-the-money IV at nine tenors, the 30-day 25-delta risk reversal, call and put
5
5
  * volume, premium and open interest, the net exposures, the walls, the gamma flip and magnet, the front expiry's max
6
- * pain and implied move, and the contracts counted (wrun-opra-stats.leaf).
6
+ * pain and implied move, and the contracts counted (wrun-opra-stats.leaf, its units per plane).
7
7
  *
8
- * It reads OPTION_UNDERLYING_STATS DAY rows by coin through `K_OPTION_UNDERLYING_STATS_DAY` (om's fetch type
9
- * `option_underlying_stats_day`) and its worker twin. A DAY row is stamped at its New York session date's UTC
10
- * midnight and written after that session's close, so the daily `last` landing lands it on the first chart bar of
11
- * that UTC day and carries it across the day; the day before's row stands until the session's row is written
12
- * (`lookbackDays` 7 keeps it in the ask after a holiday weekend). Not `global`: it follows the chart's underlying,
13
- * read on the OPRA plane's native-rows path (`nativeRows` with a daily join), so the index-mode stock chart serves it.
8
+ * It reads OPTION_UNDERLYING_STATS DAY rows through `K_OPTION_UNDERLYING_STATS_DAY` (om's fetch type
9
+ * `option_underlying_stats_day`) and its worker twin. A DAY row is stamped at its session date's UTC midnight and
10
+ * written after that session closes, so the daily `last` landing lands it on the first chart bar of that UTC day and
11
+ * carries it across the day; the day before's row stands until the session's row is written (`lookbackDays` 7 keeps
12
+ * it in the ask after a holiday weekend).
13
+ *
14
+ * A CHAIN lane (`chain`): the chain is the one chain resolver's (opra-option-lanes.util `resolveWrunLaneChainChart`
15
+ * then `decideWrunLaneChain`, the decision `options_chain` and `option_surface` read), per input, and its plane is per
16
+ * instance: OPRA's rules on a US stock or OPRA contract chart, CME's on a CME futures chart (a continuous chart reads
17
+ * its lead contract, and a live session rebuilds once the lead rolls: `acquisitionMoved`), none on a crypto chain. On
18
+ * the OPRA plane (`ctx.opraPlane`, the planner's verdict) the chain is the plane's own by coin
19
+ * (`wrunLaneOpraPlaneChain`): the read goes by coin with no chain directory read, as it always went, so a stock listing
20
+ * no options or a directory that does not answer refuses nothing before the read. Each input reads ONE book, decided
21
+ * when the run plans (`auto`: the chain's default book) and named in the acquisition off OPRA. It rides the
22
+ * native-rows path on every plane (`nativeRows`), so the index-mode stock chart serves it too.
14
23
  *
15
24
  * Refused by name before any fetch: `opra-official-only:option_daily` for a package that may not read US options, a
16
- * chart that names no underlying, and `protocol-pending:OPTION_UNDERLYING_STATS` until the protocol release. An
17
- * underlying with no row in the window answers empty: the empty-answer rule speaks for it.
25
+ * chart that names no underlying, `protocol-pending:OPTION_UNDERLYING_STATS` until the protocol release, a chart whose
26
+ * options a known stop keeps off the OPRA plane (`options-stopped`), a chart with no option chain (the options chain's
27
+ * `no-chain`), the CME display wall for a package that is not OpenMarket's own and a venue or book outside its words.
28
+ * The planner drops an input that declared `missing: "nan"` or `"zero"` instead of the stop's and the no-chain refusal
29
+ * (a note names the feed). An underlying with no row in the window answers empty: the empty-answer rule speaks for it.
18
30
  */
19
- import { type WrunPollLane, type WrunPollLaneContext, type WrunPollLaneExtras } from '../wrun-poll-lane.types.js';
31
+ import { type WrunPollLane, type WrunPollLaneContext, type WrunPollLaneExtras, type WrunPollLaneSource } from '../wrun-poll-lane.types.js';
32
+ import { type WrunLaneChain } from '../opra-option-lanes.util.js';
20
33
  /** The lane key (the refusal record's feed words, `wrun.refusal.feed.optionDaily`). */
21
34
  export declare const WRUN_OPTION_DAILY_LANE_KEY = "option_daily";
22
35
  /** The days before the chart window the ask opens: a session's row is written after its close, so the newest row
23
36
  * standing at the window's head can be a few days old (a weekend, a holiday). */
24
37
  export declare const WRUN_OPTION_DAILY_LOOKBACK_DAYS = 7;
25
38
  /**
26
- * One input against the chart: its underlying (the chart's coin, upper case), then the protocol gate. Shared with
27
- * `option_stats_10m`, which reads the same underlying at ten minutes.
39
+ * An input's acquisition, the chain it reads as the ask's fields (the acquisition key: the class, the plane its
40
+ * exchange names, the exchange, the underlying, the book and the grain): `coin`, the chain's underlying (the OPRA
41
+ * ticker, the CME futures contract, a crypto venue's root coin: the key the plane files its rows under), and
42
+ * `statsExchange` always; `statsBook`, the ONE book the run decided, on every plane but OPRA (an OPRA read stays by
43
+ * coin with no symbol: contract C1); `statsContinuous` for a CME chain read off a continuous alias
44
+ * (`wrunOptionStatsAcquisitionMoved` reads it).
45
+ */
46
+ export declare function wrunOptionStatsExtras(chain: WrunLaneChain): Record<string, unknown>;
47
+ /** Whether an acquisition no longer names the chain the lane would plan now (D12): a CME chain read off a continuous
48
+ * alias whose lead contract rolled since the run planned it (`wrunLaneChainLeadMoved`). A live session holding it
49
+ * rebuilds, so no ask, cache or buffer joins the old contract's statistics to the new one's. */
50
+ export declare function wrunOptionStatsAcquisitionMoved(acquisition: Readonly<Record<string, unknown>>): boolean;
51
+ /**
52
+ * One input against the chart: a chart that names no underlying refused by name, the protocol gate, then the chain
53
+ * (the run's one resolution of the chart, `statsChartOf`: on the OPRA plane the plane's own by coin, no directory read)
54
+ * and the input's `venue` and `book` decided by the one chain resolver; its refusals are the options chain's own.
55
+ * Shared with `option_stats_10m`, which reads the same chain at ten minutes.
28
56
  */
29
- export declare function planWrunOptionStatsInput(ctx: WrunPollLaneContext, feed: string, series: string): Promise<WrunPollLaneExtras>;
57
+ export declare function planWrunOptionStatsInput(source: WrunPollLaneSource, ctx: WrunPollLaneContext, feed: string, series: string): Promise<WrunPollLaneExtras>;
30
58
  export declare const lane: WrunPollLane;