/** * Another instrument's bars: the one thing a study needs that the chart's own * bars cannot answer. * * Everything else this adapter maps is computed from bars the chart already * holds, this included where the read is of the chart's own instrument: the * engine folds those itself and this is never asked. A read of **another** * instrument is different, and the difference is the whole of this file. * * **The engine asks once and synchronously; the chart answers later.** A * request's identity is fixed before bar 0 (`compiled-program.md` 2.16), so the * engine settles the whole set at load and asks the host for each one there and * then. A chart's transport is a promise. So the two are joined by a station * that lives in the study instance's own store: the engine's question is * answered from what the station holds now, which on the first pass is nothing, * and the answer for a read nobody has fetched yet is `pending`. The read is * absent, `req.isReady` is false, the rest of the study keeps drawing, and that * is exactly what `stdlib.md` 15.5 describes. * * **The lifecycle is what has a transport, and it runs after the first * calculation.** A chart computes a study once before it attaches its * lifecycle, so a station that waited for a transport before answering would * refuse the study at load rather than draw it while the bars arrive. Instead * the first calculation records what it was asked for, the lifecycle brings the * transport and fetches it, and the recompute it then asks for is the one that * has the bars. A study is drawn twice and never refused for a fetch that had * not happened yet. * * **A range is a floor, never a promise.** What the host is asked for is the * chart's own span, extended back by the read's `warmup` in requested bars and * forward to the end of the bucket the newest chart bar is inside, and then * quantised to bucket boundaries. Quantising is what stops a fetch per bar: the * range a chart asks for is then the same range for every bar inside one * requested bar, and it widens once when a bucket closes. A host that serves * less gets a read that is absent for longer, never a wrong number. * * **What was fetched keeps serving while the next fetch is in flight.** The * alternative is a line that breaks every time a bucket closes, which looks like * a defect in the study rather than a refresh in the transport. The first fetch * has nothing to serve and is the only one that reads as pending. * * **A failure is the host's own words.** A transport that rejects is OS6009 * carrying the message it rejected with, which is the one the chart writes when * a host registered no provider at all: `req.error(read)` then says so in the * script, the data status says so to the user, and the study keeps drawing * everything that does not depend on the read. */ import type { RequestProvider } from '../../core/engine/index.js'; import type { ChartBar, ChartStore } from './contract.js'; import type { ChartAttachContext } from './surfaces.js'; export declare class Station { private readonly entries; /** What the last calculation asked about, keyed the same way. */ private readonly wanted; private transport; private closed; private unsubscribe; /** * The provider the engine is loaded with, bound to the bars on screen. * * Asking for one is the start of a round: the engine is about to ask about * every read this program makes, so what was wanted before this moment is * what the previous program wanted. A setting that names a different * instrument would otherwise leave the old one being fetched for as long as * the study lives, and reported on. */ provider(bars: readonly ChartBar[]): RequestProvider; /** * The range each read needs, against the bars as they now stand. * * A calculation that reused the held engine never asked the provider * anything, so nothing would notice that the newest chart bar has moved into * the next requested bucket. This is what notices: it widens what is wanted, * and the fetch that follows asks for the recompute that reads it. An answer * is never spliced into a run that is already past the bars it would have * changed, which is `host-interface.md` 5.3. */ extend(bars: readonly ChartBar[]): void; /** * After a calculation: start what is missing and say where the study stands. * * It is the end of the calculation rather than the middle of it because a * fetch that resolves asks for a recompute, and asking for one from inside the * calculation it would replace is a loop waiting to be written. */ settle(): void; /** The lifecycle, with the transport the first calculation did not have. */ open(ctx: ChartAttachContext): void; /** * The lifecycle is over: nothing in flight may write anything again. * * What was fetched is kept. A chart runs the lifecycle again after a settings * change, and throwing the bars away there would put a network round trip * behind moving a slider. A fetch that was in flight is marked as not in * flight, so a station that is opened again starts it rather than waiting for * an answer whose callback has been told to do nothing. */ close(): void; /** Every read the host refused, tried again from the beginning. */ private again; private pump; private fetch; /** An answer, once the transport has one. */ private landed; private refused; private failed; /** Where the study's own data stands, in the four words the chart has. */ private status; } /** The station this instance holds, created by whichever half arrives first. */ export declare function stationIn(store: ChartStore): Station; /** The station this instance holds, when it has one. */ export declare function stationOf(store: ChartStore): Station | undefined; //# sourceMappingURL=requests.d.ts.map