/** * Inputs, resolved once at load, `compiled-program.md` 2.6 and 5.1. * * Input resolution and the substitution of every `{ "input": ... }` reference * happen **once, before step 1 of bar 0**, so the declarations in `outputs` and * anything built from them exist before the first bar runs. Step 5 writes * already resolved values into slots and resolves nothing. * * **A value that fails validation is a refusal, not a fallback.** The host's * value is used when it passes and the declared default when the host supplies * none, and a supplied value that fails is OS6019 and the program does not run. * Falling back to the default would be a settings dialog that silently ignores * what a user typed, which is worse than one that says the value is out of * range. * * **An input value is never absent.** `input()` cannot declare `none` as a * default, because the default's type is what fixes the input's type. */ import type { Diagnostic } from '../diagnostics/index.js'; import type { CompiledInput, CompiledProgram, Constant, Field } from './types.js'; import type { Value } from './values/index.js'; export interface ResolvedInput { readonly key: string; readonly slot: number; /** The bar field a `"source"` input selected, which step 5 reads per bar. */ readonly field: string | undefined; /** The effective value, for every other kind. */ readonly value: Value; } export type InputResult = { readonly ok: true; readonly inputs: readonly ResolvedInput[]; } | { readonly ok: false; readonly diagnostic: Diagnostic; }; /** A host's own conversion for a `"time"` input, which needs the chart's zone. */ export type TimeResolver = (text: string) => number | null; /** What a stored value is worth to a declared input: the value, or the rule it breaks. */ export type SettingCheck = { readonly ok: true; readonly value: Value; readonly field: string | undefined; } | { readonly ok: false; readonly refusal: string; }; /** The value a constant pool entry denotes. */ export declare function constantValue(entry: Constant): Value; export declare function resolveInputs(program: CompiledProgram, settings: Readonly>, resolveTime: TimeResolver): InputResult; /** * What the engine will run with for one stored value, or the rule it breaks. * * **This is exported because the question is asked outside the engine as well.** * A chart builds the settings dialog and the declared shape of a study before * anything is loaded, so it has to know what a stored value is worth before the * run that would refuse it exists. A second copy of these rules in an adapter * would be the same fact written in two files, and the two would answer * differently the first time either was edited: the chart adapter had its own * idea of an unusable value, and handed out a precision an input's own `max` * forbade while the engine beside it refused the same map with OS6019. * * `resolveTime` is optional, and leaving it out narrows exactly one answer. A * `"time"` input's string is read by the host's own conversion, which is the * host's to supply, so a caller with none takes a string on trust and leaves * that half to the load. Every other kind is decided here. */ export declare function checkSetting(declared: CompiledInput, supplied: unknown, resolveTime?: TimeResolver): SettingCheck; /** * A declaration field with its `{ "input": key }` reference substituted. * * Every field of `meta`, of `meta.strategy` and of every declaration in * `outputs` may hold the reference, and it is gone before bar 0. */ export declare function fieldValue(field: Field, inputs: readonly ResolvedInput[]): Value; export declare function utcTime(text: string): number | null; //# sourceMappingURL=inputs.d.ts.map