oakscriptjs 0.15.3 → 0.16.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.
- package/dist/cjs/check/format.d.ts.map +1 -1
- package/dist/cjs/check/format.js +5 -0
- package/dist/cjs/check/format.js.map +2 -2
- package/dist/cjs/check/harness.d.ts +24 -0
- package/dist/cjs/check/harness.d.ts.map +1 -1
- package/dist/cjs/check/harness.js +33 -0
- package/dist/cjs/check/harness.js.map +2 -2
- package/dist/cjs/check/index.d.ts +9 -0
- package/dist/cjs/check/index.d.ts.map +1 -1
- package/dist/cjs/check/index.js +7 -0
- package/dist/cjs/check/index.js.map +2 -2
- package/dist/cjs/color/index.d.ts.map +1 -1
- package/dist/cjs/color/index.js +19 -2
- package/dist/cjs/color/index.js.map +2 -2
- package/dist/cjs/color/parse.d.ts +8 -6
- package/dist/cjs/color/parse.d.ts.map +1 -1
- package/dist/cjs/color/parse.js +15 -2
- package/dist/cjs/color/parse.js.map +2 -2
- package/dist/cjs/drawing/registry.d.ts +68 -0
- package/dist/cjs/drawing/registry.d.ts.map +1 -1
- package/dist/cjs/drawing/registry.js +99 -9
- package/dist/cjs/drawing/registry.js.map +2 -2
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/runtime/series.d.ts +16 -0
- package/dist/cjs/runtime/series.d.ts.map +1 -1
- package/dist/cjs/runtime/series.js +19 -2
- package/dist/cjs/runtime/series.js.map +2 -2
- package/dist/cjs/script/closure-writes.d.ts +16 -0
- package/dist/cjs/script/closure-writes.d.ts.map +1 -0
- package/dist/cjs/script/closure-writes.js +435 -0
- package/dist/cjs/script/closure-writes.js.map +7 -0
- package/dist/cjs/script/globals.d.ts +2 -0
- package/dist/cjs/script/globals.d.ts.map +1 -1
- package/dist/cjs/script/globals.js.map +1 -1
- package/dist/cjs/script/incremental.d.ts +140 -0
- package/dist/cjs/script/incremental.d.ts.map +1 -0
- package/dist/cjs/script/incremental.js +142 -0
- package/dist/cjs/script/incremental.js.map +7 -0
- package/dist/cjs/script/index.d.ts +116 -31
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +471 -25
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/str/numberformat.d.ts.map +1 -1
- package/dist/cjs/str/numberformat.js +23 -0
- package/dist/cjs/str/numberformat.js.map +2 -2
- package/dist/cjs/strategy/index.d.ts +8 -0
- package/dist/cjs/strategy/index.d.ts.map +1 -1
- package/dist/cjs/strategy/index.js.map +1 -1
- package/dist/cjs/ta/running-sum.d.ts.map +1 -1
- package/dist/cjs/ta/running-sum.js +72 -3
- package/dist/cjs/ta/running-sum.js.map +2 -2
- package/dist/cjs/ta/step.d.ts +476 -0
- package/dist/cjs/ta/step.d.ts.map +1 -0
- package/dist/cjs/ta/step.js +1000 -0
- package/dist/cjs/ta/step.js.map +7 -0
- package/dist/cjs/ta-series.d.ts +1 -1
- package/dist/cjs/ta-series.js +3 -3
- package/dist/cjs/ta-series.js.map +1 -1
- package/dist/esm/check/format.d.ts.map +1 -1
- package/dist/esm/check/format.js +5 -0
- package/dist/esm/check/format.js.map +1 -1
- package/dist/esm/check/harness.d.ts +24 -0
- package/dist/esm/check/harness.d.ts.map +1 -1
- package/dist/esm/check/harness.js +40 -6
- package/dist/esm/check/harness.js.map +1 -1
- package/dist/esm/check/index.d.ts +9 -0
- package/dist/esm/check/index.d.ts.map +1 -1
- package/dist/esm/check/index.js +11 -1
- package/dist/esm/check/index.js.map +1 -1
- package/dist/esm/color/index.d.ts.map +1 -1
- package/dist/esm/color/index.js +23 -3
- package/dist/esm/color/index.js.map +1 -1
- package/dist/esm/color/parse.d.ts +8 -6
- package/dist/esm/color/parse.d.ts.map +1 -1
- package/dist/esm/color/parse.js +19 -2
- package/dist/esm/color/parse.js.map +1 -1
- package/dist/esm/drawing/registry.d.ts +68 -0
- package/dist/esm/drawing/registry.d.ts.map +1 -1
- package/dist/esm/drawing/registry.js +156 -10
- package/dist/esm/drawing/registry.js.map +1 -1
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/runtime/series.d.ts +16 -0
- package/dist/esm/runtime/series.d.ts.map +1 -1
- package/dist/esm/runtime/series.js +21 -1
- package/dist/esm/runtime/series.js.map +1 -1
- package/dist/esm/script/closure-writes.d.ts +16 -0
- package/dist/esm/script/closure-writes.d.ts.map +1 -0
- package/dist/esm/script/closure-writes.js +323 -0
- package/dist/esm/script/closure-writes.js.map +1 -0
- package/dist/esm/script/globals.d.ts +2 -0
- package/dist/esm/script/globals.d.ts.map +1 -1
- package/dist/esm/script/globals.js.map +1 -1
- package/dist/esm/script/incremental.d.ts +140 -0
- package/dist/esm/script/incremental.d.ts.map +1 -0
- package/dist/esm/script/incremental.js +173 -0
- package/dist/esm/script/incremental.js.map +1 -0
- package/dist/esm/script/index.d.ts +116 -31
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +561 -24
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/str/numberformat.d.ts.map +1 -1
- package/dist/esm/str/numberformat.js +30 -0
- package/dist/esm/str/numberformat.js.map +1 -1
- package/dist/esm/strategy/index.d.ts +8 -0
- package/dist/esm/strategy/index.d.ts.map +1 -1
- package/dist/esm/ta/running-sum.d.ts.map +1 -1
- package/dist/esm/ta/running-sum.js +79 -4
- package/dist/esm/ta/running-sum.js.map +1 -1
- package/dist/esm/ta/step.d.ts +476 -0
- package/dist/esm/ta/step.d.ts.map +1 -0
- package/dist/esm/ta/step.js +1089 -0
- package/dist/esm/ta/step.js.map +1 -0
- package/dist/esm/ta-series.d.ts +1 -1
- package/dist/esm/ta-series.js +4 -4
- package/package.json +1 -1
- package/skills/oakscript/SKILL.md +2 -2
- package/skills/oakscript/reference/check.md +5 -0
- package/skills/oakscript/reference/errors.md +0 -1
- package/skills/oakscript/reference/pine-differences.md +1 -2
- package/skills/oakscript/reference/plotting.md +5 -7
- package/skills/oakscript/reference/script-structure.md +6 -0
- package/src/check/format.ts +7 -0
- package/src/check/harness.ts +57 -0
- package/src/check/index.ts +16 -0
- package/src/color/index.ts +22 -3
- package/src/color/parse.ts +28 -3
- package/src/drawing/registry.ts +172 -10
- package/src/index.ts +9 -2
- package/src/runtime/series.ts +33 -1
- package/src/script/closure-writes.ts +279 -0
- package/src/script/globals.ts +2 -0
- package/src/script/incremental.ts +246 -0
- package/src/script/index.ts +695 -26
- package/src/str/numberformat.ts +29 -0
- package/src/strategy/index.ts +8 -0
- package/src/ta/running-sum.ts +78 -3
- package/src/ta/step.ts +1145 -0
- package/src/ta-series.ts +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/check/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Checks a script source: runs it like a host (a declaration run on zero bars, then a run on bars) and\n * returns a report an agent or a host can act on: what the script declares (inputs, outputs, strategy), what its outputs\n * contain (values, warm-up, ranges, signal counts, trades), warnings for the mistakes that give no error (an empty plot,\n * a signal on every bar or never, an input that changes nothing...), and the result of a spec (the expected inputs,\n * outputs and signals) and of a reference (expected values per bar). The `oakscript check` command prints it.\n *\n * ```ts\n * import { checkScript } from 'oakscriptjs/check';\n * const report = checkScript(source, { spec: { overlay: true, outputs: ['Fast', 'Slow'] } });\n * report.ok; report.errors; report.warnings; report.spec?.items;\n * ```\n *\n * @module check\n */\nimport type { Bar } from '../types/index.js';\nimport type { ScriptRunResult } from '../script/index.js';\nimport type { InputConfig } from '../runtime/types.js';\nimport {\n compileScript,\n inferTimeframe,\n runScript,\n syntheticBars,\n timeframeSeconds,\n type ScriptRun,\n type TestChartOptions,\n} from './harness.js';\nimport { runChecks, signalBars, type CheckContext, type CheckItem } from './checks.js';\nimport { validateSpec } from './spec.js';\n\nexport { validateSpec, specJsonSchema, SPEC_FIELDS, SPEC_FILE_FIELDS } from './spec.js';\nexport { runChecks, signalBars, type CheckContext, type CheckItem, type CheckPlot, type CheckSignal, type SignalBars } from './checks.js';\nexport { formatReport, assertCheck } from './format.js';\n\nexport {\n compileScript,\n inferTimeframe,\n rewriteImports,\n runScript,\n scriptArguments,\n syntheticBars,\n testChart,\n timeframeSeconds,\n LIBRARY_PARAMETER,\n SCRIPT_GLOBALS,\n SCRIPT_PREFIX,\n SCRIPT_SUFFIX,\n TestEngine,\n wrapSource,\n type RunScriptOptions,\n type ScriptRun,\n type TestChartOptions,\n} from './harness.js';\n\n// \u2500\u2500 Spec, reference and report types \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Expected count of a signal (a shape, character, arrow, alert condition, background or bar colour) over the bars. */\nexport interface SignalSpec {\n /** At least this many bars with the signal. */\n min?: number;\n /** At most this many bars with the signal. */\n max?: number;\n /** At least this share of the bars (0 to 1). */\n minShare?: number;\n /** At most this share of the bars (0 to 1). */\n maxShare?: number;\n}\n\n/** Expected values of a plot. */\nexport interface PlotSpec {\n /** Every value is at least this. */\n min?: number;\n /** Every value is at most this. */\n max?: number;\n /** The first value comes at this bar index or before (the warm-up). */\n warmup?: number;\n}\n\n/** Expected input: the keys are compared when given. */\nexport interface InputSpec {\n type?: InputConfig['type'];\n defval?: unknown;\n title?: string;\n min?: number;\n max?: number;\n options?: string[];\n}\n\n/**\n * What the user asked for, written before the script: each given entry is checked. Inputs, plots and signals are\n * found by id or title (case insensitive).\n */\nexport interface CheckSpec {\n kind?: 'indicator' | 'strategy';\n title?: string;\n overlay?: boolean;\n /** Inputs that must exist, with the expected type, default... */\n inputs?: Record<string, InputSpec>;\n /** Outputs that must exist (a title, or a title and a kind: plot, shape, char, arrow, candle, bar, hline, bgcolor, barcolor, alertcondition). */\n outputs?: Array<string | { title: string; kind?: string }>;\n /** Value checks per plot. */\n plots?: Record<string, PlotSpec>;\n /** Count checks per signal. */\n signals?: Record<string, SignalSpec>;\n /** Number of closed trades of a strategy. */\n trades?: { min?: number; max?: number };\n}\n\n/** Expected values per bar, e.g. the outputs of the Pine script a port follows, on the same bars. */\nexport interface CheckReference {\n /** Bar times (UNIX seconds). */\n times: number[];\n /** Expected values per plot id or title, aligned with `times` (NaN or null: na). */\n columns: Record<string, Array<number | null>>;\n /** Equal when |a - b| <= tolerance * max(1, |a|, |b|) (default 1e-10), or both na. */\n tolerance?: number;\n /** A column without a plot of that id or title is listed as ignored instead of failing (a chart export holds other columns). */\n ignoreUnknown?: boolean;\n}\n\n/** A run on edge-case bars (`scenarios: true`): a short history, daily bars, flat prices, no volume, a gap. */\nexport interface CheckScenario {\n name: string;\n description: string;\n timeframe: string;\n bars: () => Bar[];\n}\n\nexport interface CheckOptions extends TestChartOptions {\n /** Bars of the run (default: 1,500 deterministic synthetic bars of the timeframe). */\n bars?: Bar[];\n /** Input values by id (default: the defaults). */\n inputs?: Record<string, unknown>;\n spec?: CheckSpec;\n reference?: CheckReference;\n /** Compiles the source (default: `new Function`; the CLI compiles with the file name for error lines). */\n compile?: (source: string) => () => void;\n /** Wraps each run (the CLI stops a run that takes too long). */\n run?: <T>(fn: () => T) => T;\n /** File name of the source, to read the error lines from the stack (`<file>:line:column`). */\n filename?: string;\n /** Re-run with each input changed to find inputs that change no output (default true). */\n inputSweep?: boolean;\n /** Behaviour checks: called with the outputs of the run per bar (see {@link CheckContext}); their results join the spec items. */\n checks?: (t: CheckContext) => void;\n /** Also run on the edge-case bars of {@link SCENARIOS} (or the given ones): their errors fail the check. */\n scenarios?: boolean | CheckScenario[];\n}\n\nexport type CheckStage = 'syntax' | 'types' | 'declaration' | 'run' | 'timeout' | 'spec' | 'reference' | 'scenario';\n\nexport interface CheckError {\n stage: CheckStage;\n message: string;\n line?: number;\n column?: number;\n /** TypeScript error code (stage \"types\"). */\n code?: string;\n}\n\nexport interface CheckWarning {\n code:\n | 'empty-plot'\n | 'constant-plot'\n | 'late-start'\n | 'signal-never'\n | 'signal-everywhere'\n | 'one-colour'\n | 'unused-input'\n | 'input-error'\n | 'no-trades'\n | 'no-output';\n message: string;\n /** Output or input title (or id). */\n target?: string;\n}\n\nexport interface PlotSummary {\n id: string;\n title: string;\n /** Bars with a value (not na). */\n values: number;\n /** Bar index of the first value (-1: none). */\n firstBar: number;\n min: number | null;\n max: number | null;\n /** Values of the last 5 bars (null: na). */\n last: Array<number | null>;\n /** Distinct per-bar colours (0: the plot colour is the same on every bar). */\n colours: number;\n}\n\nexport interface SignalSummary {\n kind: 'shape' | 'char' | 'arrow' | 'alertcondition' | 'bgcolor' | 'barcolor';\n id: string;\n title: string;\n /** Bars with the signal. */\n count: number;\n /** count / number of bars. */\n share: number;\n firstBar: number;\n lastBar: number;\n}\n\nexport interface TradeSummary {\n entry: string;\n direction: 'long' | 'short';\n entryBar: number;\n entryPrice: number;\n exitBar: number | null;\n exitPrice: number | null;\n profit: number;\n}\n\nexport interface CheckReport {\n /** No error, no failed spec or reference check. Warnings do not change it. */\n ok: boolean;\n bars: { count: number; first: number | null; last: number | null; timeframe: string; synthetic: boolean };\n errors: CheckError[];\n warnings: CheckWarning[];\n declaration?: {\n kind: 'indicator' | 'strategy';\n title: string;\n shortTitle?: string;\n overlay: boolean;\n inputs: Array<Pick<InputConfig, 'id' | 'type' | 'defval' | 'title' | 'min' | 'max' | 'options'>>;\n outputs: Array<{ kind: string; id: string; title: string }>;\n strategy?: Record<string, unknown>;\n };\n plots: PlotSummary[];\n signals: SignalSummary[];\n drawings: { labels: number; lines: number; boxes: number; tables: number; polylines: number; linefills: number };\n /** alert() calls of the script (all bars). */\n alertCalls: number;\n strategy?: { closedTrades: number; openTrade: boolean; netProfit: number; wins: number; first: TradeSummary[] };\n /** Spec items and behaviour checks. */\n spec?: { passed: number; failed: number; items: CheckItem[] };\n reference?: Array<{\n column: string;\n output?: string;\n /** No plot of this id or title, and `ignoreUnknown` is set. */\n ignored?: boolean;\n equal: number;\n total: number;\n firstMismatch?: { bar: number; time: number; expected: number | null; actual: number | null };\n }>;\n /** Runs on edge-case bars: their errors (also in `errors`, stage \"scenario\") and the plots with no value the main run does not have. */\n scenarios?: Array<{ name: string; description: string; bars: number; errors: CheckError[]; warnings: CheckWarning[] }>;\n}\n\n// \u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst lower = (s: string | undefined): string => (s ?? '').trim().toLowerCase();\n\n/** Line and column of a script error, from `error.scriptLine` or the `<filename>:line:column` frames of its stack. */\nexport function errorLocation(error: unknown, filename?: string): { line?: number; column?: number } {\n const e = error as { scriptLine?: number; scriptColumn?: number; stack?: string } | undefined;\n if (e && typeof e.scriptLine === 'number') return { line: e.scriptLine, column: e.scriptColumn };\n if (!filename || typeof e?.stack !== 'string') return {};\n const name = filename.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const m = new RegExp(`${name}:(\\\\d+)(?::(\\\\d+))?`).exec(e.stack);\n return m ? { line: Number(m[1]), column: m[2] ? Number(m[2]) : undefined } : {};\n}\n\nfunction messageOf(error: unknown): string {\n // an error of another realm (the time limit of the CLI) is not `instanceof Error`\n const e = error as { name?: unknown; message?: unknown } | null;\n if (e && typeof e === 'object' && typeof e.message === 'string') {\n return `${!e.name || e.name === 'Error' ? '' : `${String(e.name)}: `}${e.message}`;\n }\n return String(error);\n}\n\nfunction isTimeout(error: unknown): boolean {\n return /Script execution timed out/i.test(messageOf(error));\n}\n\n/** An input value different from the default, valid for the input (undefined: not tried). */\nfunction alternative(input: InputConfig): unknown {\n const inRange = (v: number) => (input.min === undefined || v >= input.min) && (input.max === undefined || v <= input.max);\n switch (input.type) {\n case 'int': {\n const d = Number(input.defval);\n return [d + 1, d - 1, d * 2, d + 10].find((v) => Number.isFinite(v) && v !== d && inRange(v));\n }\n case 'float': {\n const d = Number(input.defval);\n return [d * 1.5, d + 1, d / 2, d - 1].find((v) => Number.isFinite(v) && v !== d && inRange(v));\n }\n case 'bool':\n return !input.defval;\n case 'string':\n return input.options?.find((o) => o !== input.defval);\n case 'source':\n return input.defval === 'open' ? 'close' : 'open';\n case 'color':\n return input.defval === '#123456' ? '#654321' : '#123456';\n default:\n return undefined;\n }\n}\n\n/** Everything a run draws or signals, to compare two runs. */\nfunction fingerprint(run: ScriptRunResult, engine: ScriptRun['engine']): string {\n return JSON.stringify([run.result, engine ? [engine.closed, engine.openTradeNow] : null]);\n}\n\nfunction findByName<T extends { id: string; title?: string }>(items: T[], name: string): T | undefined {\n const n = lower(name);\n return items.find((x) => lower(x.id) === n) ?? items.find((x) => lower(x.title) === n);\n}\n\n// \u2500\u2500 Report parts \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction summarizePlots(run: ScriptRunResult, bars: Bar[]): PlotSummary[] {\n const index = new Map(bars.map((b, i) => [b.time, i]));\n return run.plotConfig.map((p) => {\n const points = (run.result.plots[p.id] ?? []) as Array<{ time: number; value: number; color?: string }>;\n const byTime = new Map(points.map((pt) => [pt.time, pt.value]));\n let min = Infinity;\n let max = -Infinity;\n const colours = new Set<string>();\n for (const pt of points) {\n if (pt.value < min) min = pt.value;\n if (pt.value > max) max = pt.value;\n if (pt.color !== undefined) colours.add(String(pt.color));\n }\n return {\n id: p.id,\n title: p.title ?? p.id,\n values: points.length,\n firstBar: points.length ? (index.get(points[0]!.time) ?? -1) : -1,\n min: points.length ? min : null,\n max: points.length ? max : null,\n last: bars.slice(-5).map((b) => byTime.get(b.time) ?? null),\n colours: colours.size,\n };\n });\n}\n\nfunction summarizeSignals(run: ScriptRunResult, bars: Bar[]): SignalSummary[] {\n const n = Math.max(1, bars.length);\n return signalBars(run, bars).map((x) => ({\n kind: x.kind,\n id: x.id,\n title: x.title,\n count: x.bars.length,\n share: x.bars.length / n,\n firstBar: x.bars[0] ?? -1,\n lastBar: x.bars[x.bars.length - 1] ?? -1,\n }));\n}\n\nfunction summarizeStrategy(engine: NonNullable<ScriptRun['engine']>): NonNullable<CheckReport['strategy']> {\n const trades = engine.closed;\n const first = trades.slice(0, 3).map(\n (t): TradeSummary => ({\n entry: t.entry_id,\n direction: t.size >= 0 ? 'long' : 'short',\n entryBar: t.entry_bar_index,\n entryPrice: t.entry_price,\n exitBar: t.exit_bar_index ?? null,\n exitPrice: t.exit_price ?? null,\n profit: t.profit,\n })\n );\n return {\n closedTrades: trades.length,\n openTrade: engine.openTradeNow !== null,\n netProfit: trades.reduce((s, t) => s + t.profit, 0),\n wins: trades.filter((t) => t.profit > 0).length,\n first,\n };\n}\n\nfunction warningsOf(report: CheckReport, bars: Bar[]): CheckWarning[] {\n const w: CheckWarning[] = [];\n const n = bars.length;\n const outputs = report.declaration?.outputs ?? [];\n const drawings = Object.values(report.drawings).reduce((a, b) => a + b, 0);\n if (!outputs.length && !drawings && !report.strategy && !report.alertCalls) {\n w.push({ code: 'no-output', message: 'The script declares no output (plot, shape, colour, drawing, alert): it shows nothing.' });\n }\n for (const p of report.plots) {\n if (p.values === 0) {\n w.push({\n code: 'empty-plot',\n target: p.title,\n message: `Plot \"${p.title}\" has no value on any bar (na everywhere): a ta.* Series returned from a bar loop, a division by zero, a NaN input or a length longer than the bars?`,\n });\n continue;\n }\n if (p.values > 1 && p.min === p.max) {\n w.push({ code: 'constant-plot', target: p.title, message: `Plot \"${p.title}\" has the same value (${p.min}) on every bar: check that it is meant (a level is an hline()).` });\n }\n if (n >= 20 && p.firstBar > n / 2) {\n w.push({ code: 'late-start', target: p.title, message: `Plot \"${p.title}\" starts on bar ${p.firstBar} of ${n}: a long warm-up (long lengths, or a higher timeframe).` });\n }\n if (p.colours === 1 && p.values >= 20) {\n w.push({ code: 'one-colour', target: p.title, message: `Plot \"${p.title}\" has per-bar colours but the same colour on every bar: is the colour condition ever false?` });\n }\n }\n if (n >= 20) {\n for (const s of report.signals) {\n if (s.count === 0) {\n w.push({ code: 'signal-never', target: s.title, message: `${s.kind} \"${s.title}\" is never true on the ${n} bars: check the condition (or test on more bars).` });\n } else if (s.share > 0.5 && s.kind !== 'bgcolor' && s.kind !== 'barcolor') {\n w.push({\n code: 'signal-everywhere',\n target: s.title,\n message: `${s.kind} \"${s.title}\" is true on ${Math.round(s.share * 100)} % of the bars: a Series used as a JavaScript boolean (always true), or a condition that is not a cross?`,\n });\n }\n }\n }\n if (report.strategy && report.strategy.closedTrades === 0 && !report.strategy.openTrade) {\n w.push({ code: 'no-trades', message: `The strategy makes no trade on the ${n} bars: check the entry conditions (plot them with plotshape) and where the orders are placed.` });\n }\n return w;\n}\n\nfunction checkSpec(spec: CheckSpec, report: CheckReport, run: ScriptRunResult | undefined): NonNullable<CheckReport['spec']> {\n const items: NonNullable<CheckReport['spec']>['items'] = [];\n const item = (check: string, ok: boolean, expected?: unknown, actual?: unknown) => items.push({ check, ok, expected, actual });\n const d = report.declaration;\n if (spec.kind !== undefined) item('kind', d?.kind === spec.kind, spec.kind, d?.kind);\n if (spec.title !== undefined) item('title', d?.title === spec.title, spec.title, d?.title);\n if (spec.overlay !== undefined) item('overlay', d?.overlay === spec.overlay, spec.overlay, d?.overlay);\n const inputs = run?.inputConfig ?? [];\n for (const [name, want] of Object.entries(spec.inputs ?? {})) {\n const got = findByName(inputs, name);\n if (!got) {\n item(`input \"${name}\" exists`, false, name, inputs.map((i) => i.id));\n continue;\n }\n for (const key of ['type', 'defval', 'title', 'min', 'max', 'options'] as const) {\n if (want[key] === undefined) continue;\n item(`input \"${name}\" ${key}`, JSON.stringify(got[key]) === JSON.stringify(want[key]), want[key], got[key]);\n }\n }\n const all = [\n ...(d?.outputs ?? []),\n ...(run?.hlineConfig ?? []).map((h) => ({ kind: 'hline', id: h.id, title: h.title ?? h.id })),\n ...(run?.barColorConfig ?? []).map((b) => ({ kind: b.kind, id: b.id, title: b.title ?? b.id })),\n ...(run?.alertConfig ?? []).map((a) => ({ kind: 'alertcondition', id: a.id, title: a.title ?? a.id })),\n ];\n for (const o of spec.outputs ?? []) {\n const { title, kind } = typeof o === 'string' ? { title: o, kind: undefined } : o;\n const got = all.filter((x) => lower(x.title) === lower(title) || lower(x.id) === lower(title));\n const match = kind ? got.find((x) => x.kind === kind) : got[0];\n item(`output \"${title}\"${kind ? ` (${kind})` : ''} exists`, !!match, kind ? `${kind} \"${title}\"` : title, got.length ? got.map((x) => `${x.kind} \"${x.title}\"`) : all.map((x) => `${x.kind} \"${x.title}\"`));\n }\n for (const [name, want] of Object.entries(spec.plots ?? {})) {\n const p = findByName(report.plots, name);\n if (!p) {\n item(`plot \"${name}\" exists`, false, name, report.plots.map((x) => x.title));\n continue;\n }\n if (want.min !== undefined) item(`plot \"${name}\" min`, p.min !== null && p.min >= want.min, `>= ${want.min}`, p.min);\n if (want.max !== undefined) item(`plot \"${name}\" max`, p.max !== null && p.max <= want.max, `<= ${want.max}`, p.max);\n if (want.warmup !== undefined) item(`plot \"${name}\" first value`, p.firstBar >= 0 && p.firstBar <= want.warmup, `bar <= ${want.warmup}`, p.firstBar);\n }\n for (const [name, want] of Object.entries(spec.signals ?? {})) {\n const s = findByName(report.signals, name);\n if (!s) {\n item(`signal \"${name}\" exists`, false, name, report.signals.map((x) => x.title));\n continue;\n }\n if (want.min !== undefined) item(`signal \"${name}\" count`, s.count >= want.min, `>= ${want.min}`, s.count);\n if (want.max !== undefined) item(`signal \"${name}\" count`, s.count <= want.max, `<= ${want.max}`, s.count);\n if (want.minShare !== undefined) item(`signal \"${name}\" share`, s.share >= want.minShare, `>= ${want.minShare}`, Number(s.share.toFixed(4)));\n if (want.maxShare !== undefined) item(`signal \"${name}\" share`, s.share <= want.maxShare, `<= ${want.maxShare}`, Number(s.share.toFixed(4)));\n }\n if (spec.trades) {\n const t = report.strategy?.closedTrades;\n if (t === undefined) item('trades', false, 'a strategy', d?.kind);\n else {\n if (spec.trades.min !== undefined) item('closed trades', t >= spec.trades.min, `>= ${spec.trades.min}`, t);\n if (spec.trades.max !== undefined) item('closed trades', t <= spec.trades.max, `<= ${spec.trades.max}`, t);\n }\n }\n const failed = items.filter((i) => !i.ok).length;\n return { passed: items.length - failed, failed, items };\n}\n\nfunction checkReference(ref: CheckReference, run: ScriptRunResult, bars: Bar[]): NonNullable<CheckReport['reference']> {\n const tol = ref.tolerance ?? 1e-10;\n const index = new Map(bars.map((b, i) => [b.time, i]));\n const na = (v: number | null | undefined) => v === null || v === undefined || Number.isNaN(v);\n return Object.entries(ref.columns).map(([column, expected]) => {\n const plot = findByName(\n run.plotConfig.map((p) => ({ id: p.id, title: p.title ?? p.id })),\n column\n );\n if (!plot) return ref.ignoreUnknown ? { column, ignored: true, equal: 0, total: 0 } : { column, equal: 0, total: expected.length };\n const values = new Map(((run.result.plots[plot.id] ?? []) as Array<{ time: number; value: number }>).map((p) => [p.time, p.value]));\n let equal = 0;\n let total = 0;\n let firstMismatch: { bar: number; time: number; expected: number | null; actual: number | null } | undefined;\n ref.times.forEach((time, k) => {\n const bar = index.get(time);\n if (bar === undefined) return;\n total++;\n const e = expected[k];\n const a = values.get(time);\n const same = na(e) && na(a) ? true : na(e) || na(a) ? false : Math.abs(a! - e!) <= tol * Math.max(1, Math.abs(a!), Math.abs(e!));\n if (same) equal++;\n else firstMismatch ??= { bar, time, expected: na(e) ? null : e!, actual: na(a) ? null : a! };\n });\n return { column, output: plot.title, equal, total, ...(firstMismatch ? { firstMismatch } : {}) };\n });\n}\n\n// \u2500\u2500 checkScript \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Default number of synthetic bars of a check. */\nexport const CHECK_BARS = 1500;\n\nconst HOUR = 3600;\n\n/** The edge-case bars of `scenarios: true`. */\nexport const SCENARIOS: readonly CheckScenario[] = [\n { name: 'short', description: '30 hourly bars (a short history)', timeframe: '60', bars: () => syntheticBars(30) },\n { name: 'daily', description: '800 daily bars', timeframe: 'D', bars: () => syntheticBars(800, 86400) },\n { name: 'minute', description: '1,000 one-minute bars', timeframe: '1', bars: () => syntheticBars(1000, 60) },\n {\n name: 'flat',\n description: '200 bars with the same price and no volume (zero ranges)',\n timeframe: '60',\n bars: () => syntheticBars(200).map((b) => ({ ...b, open: 100, high: 100, low: 100, close: 100, volume: 0 })),\n },\n {\n name: 'no-volume',\n description: '500 bars without volume (na)',\n timeframe: '60',\n bars: () => syntheticBars(500).map((b) => ({ ...b, volume: NaN })),\n },\n {\n name: 'gap',\n description: '500 hourly bars with a 3-day gap in the middle',\n timeframe: '60',\n bars: () => syntheticBars(500).map((b, i) => (i >= 250 ? { ...b, time: b.time + 72 * HOUR } : b)),\n },\n];\n\n/**\n * Checks a script source (the body of a script, as a host runs it): compiles it, runs it on zero bars (the\n * declarations) and on the bars, and reports its declarations, outputs, warnings and the spec / reference results.\n * Never throws for a script error: the errors are in the report.\n */\nexport function checkScript(source: string, options: CheckOptions = {}): CheckReport {\n const timeframe = options.timeframe ?? (options.bars ? inferTimeframe(options.bars) : '60');\n const step = timeframeSeconds(timeframe) || 3600;\n const bars = options.bars ?? syntheticBars(CHECK_BARS, step);\n const inputs = options.inputs ?? {};\n const wrap = options.run ?? (<T>(fn: () => T) => fn());\n const runOptions = { ...options, timeframe };\n const report: CheckReport = {\n ok: false,\n bars: { count: bars.length, first: bars[0]?.time ?? null, last: bars[bars.length - 1]?.time ?? null, timeframe, synthetic: !options.bars },\n errors: [],\n warnings: [],\n plots: [],\n signals: [],\n drawings: { labels: 0, lines: 0, boxes: 0, tables: 0, polylines: 0, linefills: 0 },\n alertCalls: 0,\n };\n const fail = (stage: CheckStage, error: unknown) =>\n report.errors.push({ stage: isTimeout(error) ? 'timeout' : stage, message: messageOf(error), ...errorLocation(error, options.filename) });\n // a misspelt key would be skipped and the check would pass without checking it\n if (options.spec) for (const message of validateSpec(options.spec)) report.errors.push({ stage: 'spec', message });\n\n // compile once to report syntax errors apart from the run errors\n try {\n (options.compile ?? compileScript)(source);\n } catch (e) {\n fail('syntax', e);\n return finish();\n }\n\n let main: ScriptRun | undefined;\n try {\n const decl = wrap(() => runScript(source, [], inputs, runOptions)).run;\n report.declaration = {\n kind: decl.strategyConfig ? 'strategy' : 'indicator',\n title: decl.metadata.title,\n ...(decl.metadata.shortTitle ? { shortTitle: decl.metadata.shortTitle } : {}),\n overlay: decl.metadata.overlay,\n inputs: decl.inputConfig.map(({ id, type, defval, title, min, max, options: opts }) => ({\n id,\n type,\n defval,\n ...(title !== undefined ? { title } : {}),\n ...(min !== undefined ? { min } : {}),\n ...(max !== undefined ? { max } : {}),\n ...(opts !== undefined ? { options: opts } : {}),\n })),\n outputs: decl.outputs.map((o) => ({ kind: o.kind, id: o.id, title: o.title ?? o.id })),\n ...(decl.strategyConfig ? { strategy: { ...decl.strategyConfig } } : {}),\n };\n } catch (e) {\n fail('declaration', e);\n return finish();\n }\n\n try {\n main = wrap(() => runScript(source, bars, inputs, runOptions));\n } catch (e) {\n fail('run', e);\n return finish();\n }\n\n const run = main.run;\n const r = run.result;\n report.plots = summarizePlots(run, bars);\n report.signals = summarizeSignals(run, bars);\n report.drawings = {\n labels: r.labels?.length ?? 0,\n lines: r.lines?.length ?? 0,\n boxes: r.boxes?.length ?? 0,\n tables: r.tables?.length ?? 0,\n polylines: r.polylines?.length ?? 0,\n linefills: r.linefills?.length ?? 0,\n };\n report.alertCalls = (r as { alertCalls?: unknown[] }).alertCalls?.length ?? 0;\n if (main.engine) report.strategy = summarizeStrategy(main.engine);\n report.warnings = warningsOf(report, bars);\n\n if (options.inputSweep !== false) {\n const base = fingerprint(run, main.engine);\n for (const input of run.inputConfig) {\n const value = alternative(input);\n if (value === undefined) continue;\n try {\n const other = wrap(() => runScript(source, bars, { ...inputs, [input.id]: value }, runOptions));\n if (fingerprint(other.run, other.engine) === base) {\n report.warnings.push({\n code: 'unused-input',\n target: input.title ?? input.id,\n message: `Input \"${input.title ?? input.id}\" changes no output (tried ${JSON.stringify(value)} instead of ${JSON.stringify(input.defval)}): is its value used?`,\n });\n }\n } catch (e) {\n report.warnings.push({\n code: 'input-error',\n target: input.title ?? input.id,\n message: `Input \"${input.title ?? input.id}\" = ${JSON.stringify(value)} stops the script: ${messageOf(e)}`,\n });\n }\n }\n }\n\n if (options.spec) report.spec = checkSpec(options.spec, report, run);\n if (options.checks) {\n const trades = main.engine?.closed ?? [];\n const items = wrapChecks(() => runChecks(options.checks!, run, bars, inputs, trades));\n const spec = (report.spec ??= { passed: 0, failed: 0, items: [] });\n spec.items.push(...items);\n spec.failed = spec.items.filter((i) => !i.ok).length;\n spec.passed = spec.items.length - spec.failed;\n }\n if (options.reference) report.reference = checkReference(options.reference, run, bars);\n if (options.scenarios) runScenarios(options.scenarios === true ? SCENARIOS : options.scenarios);\n return finish();\n\n function wrapChecks(fn: () => CheckItem[]): CheckItem[] {\n try {\n return wrap(fn);\n } catch (e) {\n return [{ check: 'checks (stopped)', ok: false, actual: messageOf(e) }];\n }\n }\n\n function runScenarios(list: readonly CheckScenario[]): void {\n const known = new Set(report.warnings.map((w) => `${w.code}:${w.target ?? ''}`));\n report.scenarios = list.map((sc) => {\n const b = sc.bars();\n const r = checkScript(source, {\n ...options,\n bars: b,\n timeframe: sc.timeframe,\n spec: undefined,\n reference: undefined,\n checks: undefined,\n scenarios: false,\n inputSweep: false,\n });\n for (const e of r.errors) report.errors.push({ ...e, stage: 'scenario', message: `[${sc.name}: ${sc.description}] ${e.message}` });\n return {\n name: sc.name,\n description: sc.description,\n bars: b.length,\n errors: r.errors,\n // only the na that leaks through (a division by a zero range...): other warnings follow from the bars\n warnings: r.warnings.filter((w) => w.code === 'empty-plot' && !known.has(`${w.code}:${w.target ?? ''}`)),\n };\n });\n }\n\n function finish(): CheckReport {\n if (options.spec && !report.spec) report.spec = checkSpec(options.spec, report, main?.run);\n report.ok =\n report.errors.length === 0 &&\n (report.spec?.failed ?? 0) === 0 &&\n (report.reference ?? []).every((c) => c.ignored || (c.equal === c.total && c.output !== undefined));\n return report;\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,qBAQO;AACP,oBAAyE;AACzE,kBAA6B;AAE7B,IAAAA,eAA4E;AAC5E,IAAAC,iBAA4H;AAC5H,oBAA0C;AAE1C,IAAAC,kBAkBO;AAwMP,MAAM,QAAQ,CAAC,OAAmC,KAAK,IAAI,KAAK,EAAE,YAAY;AAGvE,SAAS,c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;AAAA,QACL,MAAM,GAAG;AAAA,QACT,aAAa,GAAG;AAAA,QAChB,MAAM,EAAE;AAAA,QACR,QAAQA,GAAE;AAAA;AAAA,QAEV,UAAUA,GAAE,SAAS,OAAO,CAAC,MAAM,EAAE,SAAS,gBAAgB,CAAC,MAAM,IAAI,GAAG,EAAE,IAAI,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC;AAAA,MACzG;AAAA,IACF,CAAC;AAAA,EACH;AAEA,WAAS,SAAsB;AAC7B,QAAI,QAAQ,QAAQ,CAAC,OAAO,KAAM,QAAO,OAAO,UAAU,QAAQ,MAAM,QAAQ,MAAM,GAAG;AACzF,WAAO,KACL,OAAO,OAAO,WAAW,MACxB,OAAO,MAAM,UAAU,OAAO,MAC9B,OAAO,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,WAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,MAAU;AACpG,WAAO;AAAA,EACT;AACF;",
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Checks a script source: runs it like a host (a declaration run on zero bars, then a run on bars) and\n * returns a report an agent or a host can act on: what the script declares (inputs, outputs, strategy), what its outputs\n * contain (values, warm-up, ranges, signal counts, trades), warnings for the mistakes that give no error (an empty plot,\n * a signal on every bar or never, an input that changes nothing...), and the result of a spec (the expected inputs,\n * outputs and signals) and of a reference (expected values per bar). The `oakscript check` command prints it.\n *\n * ```ts\n * import { checkScript } from 'oakscriptjs/check';\n * const report = checkScript(source, { spec: { overlay: true, outputs: ['Fast', 'Slow'] } });\n * report.ok; report.errors; report.warnings; report.spec?.items;\n * ```\n *\n * @module check\n */\nimport type { Bar } from '../types/index.js';\nimport type { ScriptRunResult } from '../script/index.js';\nimport type { InputConfig } from '../runtime/types.js';\nimport {\n compileScript,\n inferTimeframe,\n runScript,\n incrementalReason,\n syntheticBars,\n timeframeSeconds,\n type ScriptRun,\n type TestChartOptions,\n} from './harness.js';\nimport { runChecks, signalBars, type CheckContext, type CheckItem } from './checks.js';\nimport { validateSpec } from './spec.js';\n\nexport { validateSpec, specJsonSchema, SPEC_FIELDS, SPEC_FILE_FIELDS } from './spec.js';\nexport { runChecks, signalBars, type CheckContext, type CheckItem, type CheckPlot, type CheckSignal, type SignalBars } from './checks.js';\nexport { formatReport, assertCheck } from './format.js';\n\nexport {\n compileScript,\n inferTimeframe,\n rewriteImports,\n runScript,\n scriptArguments,\n syntheticBars,\n testChart,\n timeframeSeconds,\n LIBRARY_PARAMETER,\n SCRIPT_GLOBALS,\n SCRIPT_PREFIX,\n SCRIPT_SUFFIX,\n TestEngine,\n wrapSource,\n type RunScriptOptions,\n type ScriptRun,\n type TestChartOptions,\n} from './harness.js';\n\n// \u2500\u2500 Spec, reference and report types \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Expected count of a signal (a shape, character, arrow, alert condition, background or bar colour) over the bars. */\nexport interface SignalSpec {\n /** At least this many bars with the signal. */\n min?: number;\n /** At most this many bars with the signal. */\n max?: number;\n /** At least this share of the bars (0 to 1). */\n minShare?: number;\n /** At most this share of the bars (0 to 1). */\n maxShare?: number;\n}\n\n/** Expected values of a plot. */\nexport interface PlotSpec {\n /** Every value is at least this. */\n min?: number;\n /** Every value is at most this. */\n max?: number;\n /** The first value comes at this bar index or before (the warm-up). */\n warmup?: number;\n}\n\n/** Expected input: the keys are compared when given. */\nexport interface InputSpec {\n type?: InputConfig['type'];\n defval?: unknown;\n title?: string;\n min?: number;\n max?: number;\n options?: string[];\n}\n\n/**\n * What the user asked for, written before the script: each given entry is checked. Inputs, plots and signals are\n * found by id or title (case insensitive).\n */\nexport interface CheckSpec {\n kind?: 'indicator' | 'strategy';\n title?: string;\n overlay?: boolean;\n /** Inputs that must exist, with the expected type, default... */\n inputs?: Record<string, InputSpec>;\n /** Outputs that must exist (a title, or a title and a kind: plot, shape, char, arrow, candle, bar, hline, bgcolor, barcolor, alertcondition). */\n outputs?: Array<string | { title: string; kind?: string }>;\n /** Value checks per plot. */\n plots?: Record<string, PlotSpec>;\n /** Count checks per signal. */\n signals?: Record<string, SignalSpec>;\n /** Number of closed trades of a strategy. */\n trades?: { min?: number; max?: number };\n}\n\n/** Expected values per bar, e.g. the outputs of the Pine script a port follows, on the same bars. */\nexport interface CheckReference {\n /** Bar times (UNIX seconds). */\n times: number[];\n /** Expected values per plot id or title, aligned with `times` (NaN or null: na). */\n columns: Record<string, Array<number | null>>;\n /** Equal when |a - b| <= tolerance * max(1, |a|, |b|) (default 1e-10), or both na. */\n tolerance?: number;\n /** A column without a plot of that id or title is listed as ignored instead of failing (a chart export holds other columns). */\n ignoreUnknown?: boolean;\n}\n\n/** A run on edge-case bars (`scenarios: true`): a short history, daily bars, flat prices, no volume, a gap. */\nexport interface CheckScenario {\n name: string;\n description: string;\n timeframe: string;\n bars: () => Bar[];\n}\n\nexport interface CheckOptions extends TestChartOptions {\n /** Bars of the run (default: 1,500 deterministic synthetic bars of the timeframe). */\n bars?: Bar[];\n /** Input values by id (default: the defaults). */\n inputs?: Record<string, unknown>;\n spec?: CheckSpec;\n reference?: CheckReference;\n /** Compiles the source (default: `new Function`; the CLI compiles with the file name for error lines). */\n compile?: (source: string) => () => void;\n /** Wraps each run (the CLI stops a run that takes too long). */\n run?: <T>(fn: () => T) => T;\n /** File name of the source, to read the error lines from the stack (`<file>:line:column`). */\n filename?: string;\n /** Re-run with each input changed to find inputs that change no output (default true). */\n inputSweep?: boolean;\n /** Behaviour checks: called with the outputs of the run per bar (see {@link CheckContext}); their results join the spec items. */\n checks?: (t: CheckContext) => void;\n /** Also run on the edge-case bars of {@link SCENARIOS} (or the given ones): their errors fail the check. */\n scenarios?: boolean | CheckScenario[];\n}\n\nexport type CheckStage = 'syntax' | 'types' | 'declaration' | 'run' | 'timeout' | 'spec' | 'reference' | 'scenario';\n\nexport interface CheckError {\n stage: CheckStage;\n message: string;\n line?: number;\n column?: number;\n /** TypeScript error code (stage \"types\"). */\n code?: string;\n}\n\nexport interface CheckWarning {\n code:\n | 'empty-plot'\n | 'constant-plot'\n | 'late-start'\n | 'signal-never'\n | 'signal-everywhere'\n | 'one-colour'\n | 'unused-input'\n | 'input-error'\n | 'no-trades'\n | 'no-output';\n message: string;\n /** Output or input title (or id). */\n target?: string;\n}\n\nexport interface PlotSummary {\n id: string;\n title: string;\n /** Bars with a value (not na). */\n values: number;\n /** Bar index of the first value (-1: none). */\n firstBar: number;\n min: number | null;\n max: number | null;\n /** Values of the last 5 bars (null: na). */\n last: Array<number | null>;\n /** Distinct per-bar colours (0: the plot colour is the same on every bar). */\n colours: number;\n}\n\nexport interface SignalSummary {\n kind: 'shape' | 'char' | 'arrow' | 'alertcondition' | 'bgcolor' | 'barcolor';\n id: string;\n title: string;\n /** Bars with the signal. */\n count: number;\n /** count / number of bars. */\n share: number;\n firstBar: number;\n lastBar: number;\n}\n\nexport interface TradeSummary {\n entry: string;\n direction: 'long' | 'short';\n entryBar: number;\n entryPrice: number;\n exitBar: number | null;\n exitPrice: number | null;\n profit: number;\n}\n\nexport interface CheckReport {\n /** No error, no failed spec or reference check. Warnings do not change it. */\n ok: boolean;\n bars: { count: number; first: number | null; last: number | null; timeframe: string; synthetic: boolean };\n errors: CheckError[];\n warnings: CheckWarning[];\n declaration?: {\n kind: 'indicator' | 'strategy';\n title: string;\n shortTitle?: string;\n overlay: boolean;\n inputs: Array<Pick<InputConfig, 'id' | 'type' | 'defval' | 'title' | 'min' | 'max' | 'options'>>;\n outputs: Array<{ kind: string; id: string; title: string }>;\n strategy?: Record<string, unknown>;\n };\n plots: PlotSummary[];\n signals: SignalSummary[];\n drawings: { labels: number; lines: number; boxes: number; tables: number; polylines: number; linefills: number };\n /** alert() calls of the script (all bars). */\n alertCalls: number;\n /**\n * Live updates on a chart that runs the script with createScriptRun (#196): resumed (the newest bars only) or full\n * runs, with the reason (state outside persist(), drawings in two blocks, request.security...). Not a warning: the\n * results are the same.\n */\n liveUpdates?: { resumed: boolean; reason: string | null };\n strategy?: { closedTrades: number; openTrade: boolean; netProfit: number; wins: number; first: TradeSummary[] };\n /** Spec items and behaviour checks. */\n spec?: { passed: number; failed: number; items: CheckItem[] };\n reference?: Array<{\n column: string;\n output?: string;\n /** No plot of this id or title, and `ignoreUnknown` is set. */\n ignored?: boolean;\n equal: number;\n total: number;\n firstMismatch?: { bar: number; time: number; expected: number | null; actual: number | null };\n }>;\n /** Runs on edge-case bars: their errors (also in `errors`, stage \"scenario\") and the plots with no value the main run does not have. */\n scenarios?: Array<{ name: string; description: string; bars: number; errors: CheckError[]; warnings: CheckWarning[] }>;\n}\n\n// \u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst lower = (s: string | undefined): string => (s ?? '').trim().toLowerCase();\n\n/** Line and column of a script error, from `error.scriptLine` or the `<filename>:line:column` frames of its stack. */\nexport function errorLocation(error: unknown, filename?: string): { line?: number; column?: number } {\n const e = error as { scriptLine?: number; scriptColumn?: number; stack?: string } | undefined;\n if (e && typeof e.scriptLine === 'number') return { line: e.scriptLine, column: e.scriptColumn };\n if (!filename || typeof e?.stack !== 'string') return {};\n const name = filename.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const m = new RegExp(`${name}:(\\\\d+)(?::(\\\\d+))?`).exec(e.stack);\n return m ? { line: Number(m[1]), column: m[2] ? Number(m[2]) : undefined } : {};\n}\n\nfunction messageOf(error: unknown): string {\n // an error of another realm (the time limit of the CLI) is not `instanceof Error`\n const e = error as { name?: unknown; message?: unknown } | null;\n if (e && typeof e === 'object' && typeof e.message === 'string') {\n return `${!e.name || e.name === 'Error' ? '' : `${String(e.name)}: `}${e.message}`;\n }\n return String(error);\n}\n\nfunction isTimeout(error: unknown): boolean {\n return /Script execution timed out/i.test(messageOf(error));\n}\n\n/** An input value different from the default, valid for the input (undefined: not tried). */\nfunction alternative(input: InputConfig): unknown {\n const inRange = (v: number) => (input.min === undefined || v >= input.min) && (input.max === undefined || v <= input.max);\n switch (input.type) {\n case 'int': {\n const d = Number(input.defval);\n return [d + 1, d - 1, d * 2, d + 10].find((v) => Number.isFinite(v) && v !== d && inRange(v));\n }\n case 'float': {\n const d = Number(input.defval);\n return [d * 1.5, d + 1, d / 2, d - 1].find((v) => Number.isFinite(v) && v !== d && inRange(v));\n }\n case 'bool':\n return !input.defval;\n case 'string':\n return input.options?.find((o) => o !== input.defval);\n case 'source':\n return input.defval === 'open' ? 'close' : 'open';\n case 'color':\n return input.defval === '#123456' ? '#654321' : '#123456';\n default:\n return undefined;\n }\n}\n\n/** Everything a run draws or signals, to compare two runs. */\nfunction fingerprint(run: ScriptRunResult, engine: ScriptRun['engine']): string {\n return JSON.stringify([run.result, engine ? [engine.closed, engine.openTradeNow] : null]);\n}\n\nfunction findByName<T extends { id: string; title?: string }>(items: T[], name: string): T | undefined {\n const n = lower(name);\n return items.find((x) => lower(x.id) === n) ?? items.find((x) => lower(x.title) === n);\n}\n\n// \u2500\u2500 Report parts \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction summarizePlots(run: ScriptRunResult, bars: Bar[]): PlotSummary[] {\n const index = new Map(bars.map((b, i) => [b.time, i]));\n return run.plotConfig.map((p) => {\n const points = (run.result.plots[p.id] ?? []) as Array<{ time: number; value: number; color?: string }>;\n const byTime = new Map(points.map((pt) => [pt.time, pt.value]));\n let min = Infinity;\n let max = -Infinity;\n const colours = new Set<string>();\n for (const pt of points) {\n if (pt.value < min) min = pt.value;\n if (pt.value > max) max = pt.value;\n if (pt.color !== undefined) colours.add(String(pt.color));\n }\n return {\n id: p.id,\n title: p.title ?? p.id,\n values: points.length,\n firstBar: points.length ? (index.get(points[0]!.time) ?? -1) : -1,\n min: points.length ? min : null,\n max: points.length ? max : null,\n last: bars.slice(-5).map((b) => byTime.get(b.time) ?? null),\n colours: colours.size,\n };\n });\n}\n\nfunction summarizeSignals(run: ScriptRunResult, bars: Bar[]): SignalSummary[] {\n const n = Math.max(1, bars.length);\n return signalBars(run, bars).map((x) => ({\n kind: x.kind,\n id: x.id,\n title: x.title,\n count: x.bars.length,\n share: x.bars.length / n,\n firstBar: x.bars[0] ?? -1,\n lastBar: x.bars[x.bars.length - 1] ?? -1,\n }));\n}\n\nfunction summarizeStrategy(engine: NonNullable<ScriptRun['engine']>): NonNullable<CheckReport['strategy']> {\n const trades = engine.closed;\n const first = trades.slice(0, 3).map(\n (t): TradeSummary => ({\n entry: t.entry_id,\n direction: t.size >= 0 ? 'long' : 'short',\n entryBar: t.entry_bar_index,\n entryPrice: t.entry_price,\n exitBar: t.exit_bar_index ?? null,\n exitPrice: t.exit_price ?? null,\n profit: t.profit,\n })\n );\n return {\n closedTrades: trades.length,\n openTrade: engine.openTradeNow !== null,\n netProfit: trades.reduce((s, t) => s + t.profit, 0),\n wins: trades.filter((t) => t.profit > 0).length,\n first,\n };\n}\n\nfunction warningsOf(report: CheckReport, bars: Bar[]): CheckWarning[] {\n const w: CheckWarning[] = [];\n const n = bars.length;\n const outputs = report.declaration?.outputs ?? [];\n const drawings = Object.values(report.drawings).reduce((a, b) => a + b, 0);\n if (!outputs.length && !drawings && !report.strategy && !report.alertCalls) {\n w.push({ code: 'no-output', message: 'The script declares no output (plot, shape, colour, drawing, alert): it shows nothing.' });\n }\n for (const p of report.plots) {\n if (p.values === 0) {\n w.push({\n code: 'empty-plot',\n target: p.title,\n message: `Plot \"${p.title}\" has no value on any bar (na everywhere): a ta.* Series returned from a bar loop, a division by zero, a NaN input or a length longer than the bars?`,\n });\n continue;\n }\n if (p.values > 1 && p.min === p.max) {\n w.push({ code: 'constant-plot', target: p.title, message: `Plot \"${p.title}\" has the same value (${p.min}) on every bar: check that it is meant (a level is an hline()).` });\n }\n if (n >= 20 && p.firstBar > n / 2) {\n w.push({ code: 'late-start', target: p.title, message: `Plot \"${p.title}\" starts on bar ${p.firstBar} of ${n}: a long warm-up (long lengths, or a higher timeframe).` });\n }\n if (p.colours === 1 && p.values >= 20) {\n w.push({ code: 'one-colour', target: p.title, message: `Plot \"${p.title}\" has per-bar colours but the same colour on every bar: is the colour condition ever false?` });\n }\n }\n if (n >= 20) {\n for (const s of report.signals) {\n if (s.count === 0) {\n w.push({ code: 'signal-never', target: s.title, message: `${s.kind} \"${s.title}\" is never true on the ${n} bars: check the condition (or test on more bars).` });\n } else if (s.share > 0.5 && s.kind !== 'bgcolor' && s.kind !== 'barcolor') {\n w.push({\n code: 'signal-everywhere',\n target: s.title,\n message: `${s.kind} \"${s.title}\" is true on ${Math.round(s.share * 100)} % of the bars: a Series used as a JavaScript boolean (always true), or a condition that is not a cross?`,\n });\n }\n }\n }\n if (report.strategy && report.strategy.closedTrades === 0 && !report.strategy.openTrade) {\n w.push({ code: 'no-trades', message: `The strategy makes no trade on the ${n} bars: check the entry conditions (plot them with plotshape) and where the orders are placed.` });\n }\n return w;\n}\n\nfunction checkSpec(spec: CheckSpec, report: CheckReport, run: ScriptRunResult | undefined): NonNullable<CheckReport['spec']> {\n const items: NonNullable<CheckReport['spec']>['items'] = [];\n const item = (check: string, ok: boolean, expected?: unknown, actual?: unknown) => items.push({ check, ok, expected, actual });\n const d = report.declaration;\n if (spec.kind !== undefined) item('kind', d?.kind === spec.kind, spec.kind, d?.kind);\n if (spec.title !== undefined) item('title', d?.title === spec.title, spec.title, d?.title);\n if (spec.overlay !== undefined) item('overlay', d?.overlay === spec.overlay, spec.overlay, d?.overlay);\n const inputs = run?.inputConfig ?? [];\n for (const [name, want] of Object.entries(spec.inputs ?? {})) {\n const got = findByName(inputs, name);\n if (!got) {\n item(`input \"${name}\" exists`, false, name, inputs.map((i) => i.id));\n continue;\n }\n for (const key of ['type', 'defval', 'title', 'min', 'max', 'options'] as const) {\n if (want[key] === undefined) continue;\n item(`input \"${name}\" ${key}`, JSON.stringify(got[key]) === JSON.stringify(want[key]), want[key], got[key]);\n }\n }\n const all = [\n ...(d?.outputs ?? []),\n ...(run?.hlineConfig ?? []).map((h) => ({ kind: 'hline', id: h.id, title: h.title ?? h.id })),\n ...(run?.barColorConfig ?? []).map((b) => ({ kind: b.kind, id: b.id, title: b.title ?? b.id })),\n ...(run?.alertConfig ?? []).map((a) => ({ kind: 'alertcondition', id: a.id, title: a.title ?? a.id })),\n ];\n for (const o of spec.outputs ?? []) {\n const { title, kind } = typeof o === 'string' ? { title: o, kind: undefined } : o;\n const got = all.filter((x) => lower(x.title) === lower(title) || lower(x.id) === lower(title));\n const match = kind ? got.find((x) => x.kind === kind) : got[0];\n item(`output \"${title}\"${kind ? ` (${kind})` : ''} exists`, !!match, kind ? `${kind} \"${title}\"` : title, got.length ? got.map((x) => `${x.kind} \"${x.title}\"`) : all.map((x) => `${x.kind} \"${x.title}\"`));\n }\n for (const [name, want] of Object.entries(spec.plots ?? {})) {\n const p = findByName(report.plots, name);\n if (!p) {\n item(`plot \"${name}\" exists`, false, name, report.plots.map((x) => x.title));\n continue;\n }\n if (want.min !== undefined) item(`plot \"${name}\" min`, p.min !== null && p.min >= want.min, `>= ${want.min}`, p.min);\n if (want.max !== undefined) item(`plot \"${name}\" max`, p.max !== null && p.max <= want.max, `<= ${want.max}`, p.max);\n if (want.warmup !== undefined) item(`plot \"${name}\" first value`, p.firstBar >= 0 && p.firstBar <= want.warmup, `bar <= ${want.warmup}`, p.firstBar);\n }\n for (const [name, want] of Object.entries(spec.signals ?? {})) {\n const s = findByName(report.signals, name);\n if (!s) {\n item(`signal \"${name}\" exists`, false, name, report.signals.map((x) => x.title));\n continue;\n }\n if (want.min !== undefined) item(`signal \"${name}\" count`, s.count >= want.min, `>= ${want.min}`, s.count);\n if (want.max !== undefined) item(`signal \"${name}\" count`, s.count <= want.max, `<= ${want.max}`, s.count);\n if (want.minShare !== undefined) item(`signal \"${name}\" share`, s.share >= want.minShare, `>= ${want.minShare}`, Number(s.share.toFixed(4)));\n if (want.maxShare !== undefined) item(`signal \"${name}\" share`, s.share <= want.maxShare, `<= ${want.maxShare}`, Number(s.share.toFixed(4)));\n }\n if (spec.trades) {\n const t = report.strategy?.closedTrades;\n if (t === undefined) item('trades', false, 'a strategy', d?.kind);\n else {\n if (spec.trades.min !== undefined) item('closed trades', t >= spec.trades.min, `>= ${spec.trades.min}`, t);\n if (spec.trades.max !== undefined) item('closed trades', t <= spec.trades.max, `<= ${spec.trades.max}`, t);\n }\n }\n const failed = items.filter((i) => !i.ok).length;\n return { passed: items.length - failed, failed, items };\n}\n\nfunction checkReference(ref: CheckReference, run: ScriptRunResult, bars: Bar[]): NonNullable<CheckReport['reference']> {\n const tol = ref.tolerance ?? 1e-10;\n const index = new Map(bars.map((b, i) => [b.time, i]));\n const na = (v: number | null | undefined) => v === null || v === undefined || Number.isNaN(v);\n return Object.entries(ref.columns).map(([column, expected]) => {\n const plot = findByName(\n run.plotConfig.map((p) => ({ id: p.id, title: p.title ?? p.id })),\n column\n );\n if (!plot) return ref.ignoreUnknown ? { column, ignored: true, equal: 0, total: 0 } : { column, equal: 0, total: expected.length };\n const values = new Map(((run.result.plots[plot.id] ?? []) as Array<{ time: number; value: number }>).map((p) => [p.time, p.value]));\n let equal = 0;\n let total = 0;\n let firstMismatch: { bar: number; time: number; expected: number | null; actual: number | null } | undefined;\n ref.times.forEach((time, k) => {\n const bar = index.get(time);\n if (bar === undefined) return;\n total++;\n const e = expected[k];\n const a = values.get(time);\n const same = na(e) && na(a) ? true : na(e) || na(a) ? false : Math.abs(a! - e!) <= tol * Math.max(1, Math.abs(a!), Math.abs(e!));\n if (same) equal++;\n else firstMismatch ??= { bar, time, expected: na(e) ? null : e!, actual: na(a) ? null : a! };\n });\n return { column, output: plot.title, equal, total, ...(firstMismatch ? { firstMismatch } : {}) };\n });\n}\n\n// \u2500\u2500 checkScript \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/** Default number of synthetic bars of a check. */\nexport const CHECK_BARS = 1500;\n\nconst HOUR = 3600;\n\n/** The edge-case bars of `scenarios: true`. */\nexport const SCENARIOS: readonly CheckScenario[] = [\n { name: 'short', description: '30 hourly bars (a short history)', timeframe: '60', bars: () => syntheticBars(30) },\n { name: 'daily', description: '800 daily bars', timeframe: 'D', bars: () => syntheticBars(800, 86400) },\n { name: 'minute', description: '1,000 one-minute bars', timeframe: '1', bars: () => syntheticBars(1000, 60) },\n {\n name: 'flat',\n description: '200 bars with the same price and no volume (zero ranges)',\n timeframe: '60',\n bars: () => syntheticBars(200).map((b) => ({ ...b, open: 100, high: 100, low: 100, close: 100, volume: 0 })),\n },\n {\n name: 'no-volume',\n description: '500 bars without volume (na)',\n timeframe: '60',\n bars: () => syntheticBars(500).map((b) => ({ ...b, volume: NaN })),\n },\n {\n name: 'gap',\n description: '500 hourly bars with a 3-day gap in the middle',\n timeframe: '60',\n bars: () => syntheticBars(500).map((b, i) => (i >= 250 ? { ...b, time: b.time + 72 * HOUR } : b)),\n },\n];\n\n/**\n * Checks a script source (the body of a script, as a host runs it): compiles it, runs it on zero bars (the\n * declarations) and on the bars, and reports its declarations, outputs, warnings and the spec / reference results.\n * Never throws for a script error: the errors are in the report.\n */\nexport function checkScript(source: string, options: CheckOptions = {}): CheckReport {\n const timeframe = options.timeframe ?? (options.bars ? inferTimeframe(options.bars) : '60');\n const step = timeframeSeconds(timeframe) || 3600;\n const bars = options.bars ?? syntheticBars(CHECK_BARS, step);\n const inputs = options.inputs ?? {};\n const wrap = options.run ?? (<T>(fn: () => T) => fn());\n const runOptions = { ...options, timeframe };\n const report: CheckReport = {\n ok: false,\n bars: { count: bars.length, first: bars[0]?.time ?? null, last: bars[bars.length - 1]?.time ?? null, timeframe, synthetic: !options.bars },\n errors: [],\n warnings: [],\n plots: [],\n signals: [],\n drawings: { labels: 0, lines: 0, boxes: 0, tables: 0, polylines: 0, linefills: 0 },\n alertCalls: 0,\n };\n const fail = (stage: CheckStage, error: unknown) =>\n report.errors.push({ stage: isTimeout(error) ? 'timeout' : stage, message: messageOf(error), ...errorLocation(error, options.filename) });\n // a misspelt key would be skipped and the check would pass without checking it\n if (options.spec) for (const message of validateSpec(options.spec)) report.errors.push({ stage: 'spec', message });\n\n // compile once to report syntax errors apart from the run errors\n try {\n (options.compile ?? compileScript)(source);\n } catch (e) {\n fail('syntax', e);\n return finish();\n }\n\n let main: ScriptRun | undefined;\n try {\n const decl = wrap(() => runScript(source, [], inputs, runOptions)).run;\n report.declaration = {\n kind: decl.strategyConfig ? 'strategy' : 'indicator',\n title: decl.metadata.title,\n ...(decl.metadata.shortTitle ? { shortTitle: decl.metadata.shortTitle } : {}),\n overlay: decl.metadata.overlay,\n inputs: decl.inputConfig.map(({ id, type, defval, title, min, max, options: opts }) => ({\n id,\n type,\n defval,\n ...(title !== undefined ? { title } : {}),\n ...(min !== undefined ? { min } : {}),\n ...(max !== undefined ? { max } : {}),\n ...(opts !== undefined ? { options: opts } : {}),\n })),\n outputs: decl.outputs.map((o) => ({ kind: o.kind, id: o.id, title: o.title ?? o.id })),\n ...(decl.strategyConfig ? { strategy: { ...decl.strategyConfig } } : {}),\n };\n } catch (e) {\n fail('declaration', e);\n return finish();\n }\n\n try {\n main = wrap(() => runScript(source, bars, inputs, runOptions));\n } catch (e) {\n fail('run', e);\n return finish();\n }\n\n const run = main.run;\n const r = run.result;\n report.plots = summarizePlots(run, bars);\n report.signals = summarizeSignals(run, bars);\n report.drawings = {\n labels: r.labels?.length ?? 0,\n lines: r.lines?.length ?? 0,\n boxes: r.boxes?.length ?? 0,\n tables: r.tables?.length ?? 0,\n polylines: r.polylines?.length ?? 0,\n linefills: r.linefills?.length ?? 0,\n };\n report.alertCalls = (r as { alertCalls?: unknown[] }).alertCalls?.length ?? 0;\n if (main.engine) report.strategy = summarizeStrategy(main.engine);\n report.warnings = warningsOf(report, bars);\n // a live chart (createScriptRun) calculates only the newest bars of a script whose state the runtime keeps (#196)\n if (!main.engine) {\n try {\n const reason = wrap(() => incrementalReason(source, bars, inputs, runOptions));\n report.liveUpdates = { resumed: reason === null, reason };\n } catch {\n // the main run already reports the errors of the script\n }\n }\n\n if (options.inputSweep !== false) {\n const base = fingerprint(run, main.engine);\n for (const input of run.inputConfig) {\n const value = alternative(input);\n if (value === undefined) continue;\n try {\n const other = wrap(() => runScript(source, bars, { ...inputs, [input.id]: value }, runOptions));\n if (fingerprint(other.run, other.engine) === base) {\n report.warnings.push({\n code: 'unused-input',\n target: input.title ?? input.id,\n message: `Input \"${input.title ?? input.id}\" changes no output (tried ${JSON.stringify(value)} instead of ${JSON.stringify(input.defval)}): is its value used?`,\n });\n }\n } catch (e) {\n report.warnings.push({\n code: 'input-error',\n target: input.title ?? input.id,\n message: `Input \"${input.title ?? input.id}\" = ${JSON.stringify(value)} stops the script: ${messageOf(e)}`,\n });\n }\n }\n }\n\n if (options.spec) report.spec = checkSpec(options.spec, report, run);\n if (options.checks) {\n const trades = main.engine?.closed ?? [];\n const items = wrapChecks(() => runChecks(options.checks!, run, bars, inputs, trades));\n const spec = (report.spec ??= { passed: 0, failed: 0, items: [] });\n spec.items.push(...items);\n spec.failed = spec.items.filter((i) => !i.ok).length;\n spec.passed = spec.items.length - spec.failed;\n }\n if (options.reference) report.reference = checkReference(options.reference, run, bars);\n if (options.scenarios) runScenarios(options.scenarios === true ? SCENARIOS : options.scenarios);\n return finish();\n\n function wrapChecks(fn: () => CheckItem[]): CheckItem[] {\n try {\n return wrap(fn);\n } catch (e) {\n return [{ check: 'checks (stopped)', ok: false, actual: messageOf(e) }];\n }\n }\n\n function runScenarios(list: readonly CheckScenario[]): void {\n const known = new Set(report.warnings.map((w) => `${w.code}:${w.target ?? ''}`));\n report.scenarios = list.map((sc) => {\n const b = sc.bars();\n const r = checkScript(source, {\n ...options,\n bars: b,\n timeframe: sc.timeframe,\n spec: undefined,\n reference: undefined,\n checks: undefined,\n scenarios: false,\n inputSweep: false,\n });\n for (const e of r.errors) report.errors.push({ ...e, stage: 'scenario', message: `[${sc.name}: ${sc.description}] ${e.message}` });\n return {\n name: sc.name,\n description: sc.description,\n bars: b.length,\n errors: r.errors,\n // only the na that leaks through (a division by a zero range...): other warnings follow from the bars\n warnings: r.warnings.filter((w) => w.code === 'empty-plot' && !known.has(`${w.code}:${w.target ?? ''}`)),\n };\n });\n }\n\n function finish(): CheckReport {\n if (options.spec && !report.spec) report.spec = checkSpec(options.spec, report, main?.run);\n report.ok =\n report.errors.length === 0 &&\n (report.spec?.failed ?? 0) === 0 &&\n (report.reference ?? []).every((c) => c.ignored || (c.equal === c.total && c.output !== undefined));\n return report;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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d.ts","sourceRoot":"","sources":["../../../src/color/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAcrF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAUvG;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CASnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/color/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAcrF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAUvG;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CASnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,KA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AO,MAAM,KAAK,YAAY,CAAC;AAE/B;;;GAGG;AACH,eAAO,MAAM,MAAM,YAAY,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,KAAK,GACf,MAAM,CA+BR;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,CAAC"}
|
package/dist/cjs/color/index.js
CHANGED
|
@@ -68,9 +68,26 @@ function from_hex(hex, transp) {
|
|
|
68
68
|
}
|
|
69
69
|
function new_color(baseColor, transp) {
|
|
70
70
|
if (baseColor === null || baseColor === void 0) return rgb(0, 0, 0, transp);
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
if (typeof baseColor !== "string") {
|
|
72
|
+
const rgba = (0, import_parse.parseColor)(baseColor);
|
|
73
|
+
return rgb(rgba.r, rgba.g, rgba.b, transp);
|
|
74
|
+
}
|
|
75
|
+
let byTransp = newColors.get(baseColor);
|
|
76
|
+
if (byTransp === void 0) {
|
|
77
|
+
if (newColors.size >= NEW_COLORS_KEPT) newColors.clear();
|
|
78
|
+
newColors.set(baseColor, byTransp = /* @__PURE__ */ new Map());
|
|
79
|
+
}
|
|
80
|
+
let text = byTransp.get(transp);
|
|
81
|
+
if (text === void 0) {
|
|
82
|
+
const rgba = (0, import_parse.parseColor)(baseColor);
|
|
83
|
+
text = rgb(rgba.r, rgba.g, rgba.b, transp);
|
|
84
|
+
if (byTransp.size >= NEW_COLORS_KEPT) byTransp.clear();
|
|
85
|
+
byTransp.set(transp, text);
|
|
86
|
+
}
|
|
87
|
+
return text;
|
|
73
88
|
}
|
|
89
|
+
const newColors = /* @__PURE__ */ new Map();
|
|
90
|
+
const NEW_COLORS_KEPT = 1024;
|
|
74
91
|
function r(clr) {
|
|
75
92
|
return (0, import_parse.parseColor)(clr).r;
|
|
76
93
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/color/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Color namespace\n * Mirrors PineScript's color.* functions for color creation and manipulation.\n *\n * @remarks\n * All color functions in this namespace follow PineScript v6 API specifications.\n * Colors are represented as RGB or RGBA strings.\n * Transparency values range from 0 (fully opaque) to 100 (fully transparent).\n *\n * @version 6\n */\n\nimport type { color, int, float, simple_int, simple_float } from '../types/index.js';\nimport { alphaByte, parseColor } from './parse.js';\n\n/** Channel of color.rgb: na is 0, a fraction is truncated. */\nconst channel = (v: number): int =>\n v === null || v === undefined || Number.isNaN(v) ? 0 : Math.max(0, Math.min(255, Math.trunc(v)));\n\n/**\n * Alpha (0-1) of a transparency given to color.rgb / color.new: na is fully transparent, clamped to 0..100.\n * `1 - t / 100` as in PineScript: `color.new(c, 90)` has the alpha byte 25 (0.09999999999999998 * 255 rounded).\n */\nconst alphaOf = (transp: number): float =>\n transp === null || Number.isNaN(transp) ? 0 : 1 - Math.max(0, Math.min(100, transp)) / 100;\n\n/**\n * Creates a color from RGB values with optional transparency.\n *\n * @param red - Red component (0-255, values are clamped)\n * @param green - Green component (0-255, values are clamped)\n * @param blue - Blue component (0-255, values are clamped)\n * @param transp - Optional transparency (0-100). 0 = opaque, 100 = fully transparent\n * @returns Color string in rgb() or rgba() format\n *\n * @remarks\n * - RGB values are automatically clamped to the 0-255 range\n * - Transparency of 0 or omitted results in rgb() format\n * - Transparency > 0 results in rgba() format\n * - Transparency is converted to alpha channel (0-1 range)\n *\n * PineScript rules:\n * - an `na` channel is 0; a fractional channel is truncated (127.6 is 127)\n * - the transparency is clamped to 0..100 (140 is fully transparent, -5 is opaque); an `na` transparency is fully\n * transparent\n *\n * @example\n * ```typescript\n * color.rgb(255, 0, 0) // Returns: \"rgb(255, 0, 0)\" - Red\n * color.rgb(0, 255, 0, 50) // Returns: \"rgba(0, 255, 0, 0.5)\" - Semi-transparent green\n * color.rgb(300, 0, 0) // Returns: \"rgb(255, 0, 0)\" - Clamped to 255\n * ```\n */\nexport function rgb(red: simple_int, green: simple_int, blue: simple_int, transp?: simple_float): string {\n const r = channel(red);\n const g = channel(green);\n const b = channel(blue);\n const a = transp !== undefined ? alphaOf(transp) : 1;\n\n if (a === 1) {\n return `rgb(${r}, ${g}, ${b})`;\n }\n return `rgba(${r}, ${g}, ${b}, ${a})`;\n}\n\n/**\n * Creates a color from a hexadecimal string with optional transparency.\n *\n * @param hex - Hex color string (with or without '#' prefix, e.g., \"#FF0000\" or \"FF0000\")\n * @param transp - Optional transparency (0-100). 0 = opaque, 100 = fully transparent\n * @returns Color string in rgb() or rgba() format\n *\n * @remarks\n * - Accepts hex strings with or without '#' prefix\n * - Case-insensitive (accepts both \"FF0000\" and \"ff0000\")\n * - Must be 6 characters (excluding '#')\n * - Format: RRGGBB where each component is 00-FF\n *\n * @example\n * ```typescript\n * color.from_hex(\"#FF0000\") // Returns: \"rgb(255, 0, 0)\" - Red\n * color.from_hex(\"00FF00\", 50) // Returns: \"rgba(0, 255, 0, 0.5)\" - Semi-transparent green\n * color.from_hex(\"#0000FF\") // Returns: \"rgb(0, 0, 255)\" - Blue\n * color.from_hex(\"FFA500\") // Returns: \"rgb(255, 165, 0)\" - Orange\n * ```\n */\nexport function from_hex(hex: string, transp?: simple_float): string {\n // Remove # if present\n hex = hex.replace('#', '');\n\n const r = parseInt(hex.substring(0, 2), 16);\n const g = parseInt(hex.substring(2, 4), 16);\n const b = parseInt(hex.substring(4, 6), 16);\n\n return rgb(r, g, b, transp);\n}\n\n/**\n * Creates a new color with modified transparency, preserving RGB components.\n *\n * @param baseColor - The base color to modify\n * @param transp - New transparency value (0-100). 0 = opaque, 100 = fully transparent\n * @returns New color with updated transparency\n *\n * @remarks\n * - Preserves the RGB values from the base color\n * - Replaces the transparency with the new value\n * - Useful for creating semi-transparent versions of existing colors\n * - PineScript clamps the transparency to 0..100 (`color.new(c, 140)` is fully transparent, `color.new(c, -5)` is\n * opaque); an `na` transparency is fully transparent (measured: the colour is not na, its RGB is kept)\n * - an `na` colour (null / undefined) gives black with the new transparency: `color.new(na, 30)` is\n * `rgba(0, 0, 0, 0.7)`, as PineScript does for an na colour variable (measured, #150). In PineScript, the constant\n * `color.new(color(na), 30)` is computed at compile time and stays na; a JS function cannot tell the two apart.\n *\n * @example\n * ```typescript\n * const red = color.rgb(255, 0, 0)\n * color.new_color(red, 50) // Returns: \"rgba(255, 0, 0, 0.5)\" - Semi-transparent red\n * color.new_color(red, 0) // Returns: \"rgb(255, 0, 0)\" - Fully opaque\n * color.new_color(red, 100) // Returns: \"rgba(255, 0, 0, 0)\" - Fully transparent\n * ```\n */\nexport function new_color(baseColor: color | null | undefined, transp: simple_float): string {\n if (baseColor === null || baseColor === undefined) return rgb(0, 0, 0, transp); // na colour: black\n // Parse the color and apply transparency\n const rgba = parseColor(baseColor);\n return rgb(rgba.r, rgba.g, rgba.b, transp);\n}\n\n/**\n * Extracts the red component from a color.\n *\n * @param clr - The color to extract from\n * @returns Red component value (0-255)\n *\n * @example\n * ```typescript\n * color.r(color.rgb(255, 128, 64)) // Returns: 255\n * color.r(color.from_hex(\"#FF0000\")) // Returns: 255\n * color.r(color.from_hex(\"#FFA500\")) // Returns: 255 (orange)\n * ```\n */\nexport function r(clr: color): int {\n return parseColor(clr).r;\n}\n\n/**\n * Extracts the green component from a color.\n *\n * @param clr - The color to extract from\n * @returns Green component value (0-255)\n *\n * @example\n * ```typescript\n * color.g(color.rgb(255, 128, 64)) // Returns: 128\n * color.g(color.from_hex(\"#00FF00\")) // Returns: 255\n * color.g(color.from_hex(\"#FFA500\")) // Returns: 165 (orange)\n * ```\n */\nexport function g(clr: color): int {\n return parseColor(clr).g;\n}\n\n/**\n * Extracts the blue component from a color.\n *\n * @param clr - The color to extract from\n * @returns Blue component value (0-255)\n *\n * @example\n * ```typescript\n * color.b(color.rgb(255, 128, 64)) // Returns: 64\n * color.b(color.from_hex(\"#0000FF\")) // Returns: 255\n * color.b(color.from_hex(\"#FFA500\")) // Returns: 0 (orange)\n * ```\n */\nexport function b(clr: color): int {\n return parseColor(clr).b;\n}\n\n/**\n * Extracts the transparency component from a color.\n *\n * @param clr - The color to extract from\n * @returns Transparency value (0-100). 0 = fully opaque, 100 = fully transparent\n *\n * @remarks\n * - Returns 0 for colors without transparency (rgb format)\n * - Converts alpha channel (0-1) to transparency (0-100)\n * - PineScript stores the alpha as a byte (0-255) and returns an integer transparency:\n * `color.t(color.new(c, 33.3))` is 33\n * - an `na` colour (null / undefined) is fully transparent: 100\n *\n * @example\n * ```typescript\n * color.t(color.rgb(255, 0, 0)) // Returns: 0 (opaque)\n * color.t(color.rgb(255, 0, 0, 50)) // Returns: 50\n * color.t(color.rgb(255, 0, 0, 100)) // Returns: 100 (fully transparent)\n * ```\n */\nexport function t(clr: color | null | undefined): float {\n if (clr === null || clr === undefined) return 100;\n return Math.round((1 - alphaByte(parseColor(clr).a) / 255) * 100);\n}\n\n// Predefined color constants of PineScript v6.\n// PineScript v5 differs for red (#FF5252), teal (#00897B) and yellow (#FFEB3B).\n/**\n * Aqua/Cyan color constant\n * @constant {string} #00BCD4 - RGB(0, 188, 212)\n */\nexport const aqua = '#00BCD4';\n\n/**\n * Black color constant\n * @constant {string} #363A45 - RGB(54, 58, 69)\n */\nexport const black = '#363A45';\n\n/**\n * Blue color constant\n * @constant {string} #2962FF - RGB(41, 98, 255)\n */\nexport const blue = '#2962FF';\n\n/**\n * Fuchsia/Magenta color constant\n * @constant {string} #E040FB - RGB(224, 64, 251)\n */\nexport const fuchsia = '#E040FB';\n\n/**\n * Gray color constant\n * @constant {string} #787B86 - RGB(120, 123, 134)\n */\nexport const gray = '#787B86';\n\n/**\n * Green color constant (same as lime)\n * @constant {string} #4CAF50 - RGB(76, 175, 80)\n */\nexport const green = '#4CAF50';\n\n/**\n * Lime color constant (same as green)\n * @constant {string} #00E676 - RGB(0, 230, 118)\n */\nexport const lime = '#00E676';\n\n/**\n * Maroon color constant\n * @constant {string} #880E4F - RGB(136, 14, 79)\n */\nexport const maroon = '#880E4F';\n\n/**\n * Navy color constant\n * @constant {string} #311B92 - RGB(49, 27, 146)\n */\nexport const navy = '#311B92';\n\n/**\n * Olive color constant\n * @constant {string} #808000 - RGB(128, 128, 0)\n */\nexport const olive = '#808000';\n\n/**\n * Orange color constant\n * @constant {string} #FF9800 - RGB(255, 152, 0)\n */\nexport const orange = '#FF9800';\n\n/**\n * Purple color constant\n * @constant {string} #9C27B0 - RGB(156, 39, 176)\n */\nexport const purple = '#9C27B0';\n\n/**\n * Red color constant\n * @constant {string} #F23645 - RGB(242, 54, 69)\n */\nexport const red = '#F23645';\n\n/**\n * Silver color constant\n * @constant {string} #B2B5BE - RGB(178, 181, 190)\n */\nexport const silver = '#B2B5BE';\n\n/**\n * Teal color constant\n * @constant {string} #089981 - RGB(8, 153, 129)\n */\nexport const teal = '#089981';\n\n/**\n * White color constant\n * @constant {string} #FFFFFF - RGB(255, 255, 255)\n */\nexport const white = '#FFFFFF';\n\n/**\n * Yellow color constant\n * @constant {string} #FDD835 - RGB(253, 216, 53)\n */\nexport const yellow = '#FDD835';\n\n/**\n * Creates a color from a gradient based on value position.\n *\n * @param value - Value to calculate position-dependent color\n * @param bottom_value - Bottom position value corresponding to bottom_color\n * @param top_value - Top position value corresponding to top_color\n * @param bottom_color - Bottom position color\n * @param top_color - Top position color\n * @returns Color calculated from linear gradient\n *\n * @remarks\n * PineScript rules:\n * - If value <= bottom_value, returns bottom_color; else if value >= top_value, returns top_color\n * - An inverted range (bottom_value > top_value) returns bottom_color, wherever the value is\n * - Otherwise the colours are mixed with their transparency (premultiplied alpha, alpha as a byte); the RGB channels\n * and the alpha are truncated. PineScript's float rounding order is not known: a channel can differ by 1 when the\n * exact result is an integer (same RGB at both ends)\n * - An na value or bottom_value / top_value, or bottom_value == top_value, gives a fully transparent colour\n * - An na colour counts as fully transparent\n * - Works with rgb(), rgba() and hex (#RRGGBB, #RRGGBBAA) colours\n *\n * @example\n * ```typescript\n * // Value at middle of range gets middle color\n * const midColor = color.from_gradient(50, 0, 100,\n * color.rgb(255, 0, 0), // Red at bottom\n * color.rgb(0, 255, 0) // Green at top\n * ); // Returns color between red and green\n *\n * // Value at extremes\n * const lowColor = color.from_gradient(-10, 0, 100, red, green); // Returns red\n * const highColor = color.from_gradient(150, 0, 100, red, green); // Returns green\n * ```\n */\nexport function from_gradient(\n value: float,\n bottom_value: float,\n top_value: float,\n bottom_color: color,\n top_color: color\n): string {\n const transparent = 'rgba(0, 0, 0, 0)';\n if ([value, bottom_value, top_value].some((v) => v === null || v === undefined || Number.isNaN(v)) || bottom_value === top_value) {\n return transparent;\n }\n const k =\n value <= bottom_value || bottom_value > top_value\n ? 0\n : value >= top_value\n ? 1\n : (value - bottom_value) / (top_value - bottom_value);\n // alpha as a byte (0-255), as PineScript stores it; an na colour (null / undefined, or 'transparent', the\n // library's form of na) is fully transparent\n const rgba = (c: color) => {\n if (c === null || c === undefined || (typeof c === 'string' && c.trim().toLowerCase() === 'transparent')) return { r: 0, g: 0, b: 0, a: 0 };\n const p = parseColor(c);\n return { r: p.r, g: p.g, b: p.b, a: alphaByte(p.a) };\n };\n const c1 = rgba(bottom_color);\n const c2 = rgba(top_color);\n const a = c1.a * (1 - k) + c2.a * k;\n if (a === 0) return transparent;\n // PineScript order (bit for bit, #146): premultiplied channels ((alpha / 255) * channel) * weight, divided by the\n // byte-alpha mix / 255, truncated. At an end (k = 0 / 1) this is floor(x * a / a): the end colour or one unit less.\n const scale = a / 255;\n const w1 = c1.a / 255;\n const w2 = c2.a / 255;\n const mix = (x1: number, x2: number) => Math.floor(((w1 * x1) * (1 - k) + (w2 * x2) * k) / scale);\n const [r, g, b] = [mix(c1.r, c2.r), mix(c1.g, c2.g), mix(c1.b, c2.b)];\n const alpha = Math.floor(a);\n return alpha === 255 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${alpha / 255})`;\n}\n\n/**\n * Alias for new_color function.\n * Creates a new color with specified transparency from an existing color.\n *\n * @param baseColor - The base color\n * @param transp - Transparency value (0-100). 0 = fully opaque, 100 = fully transparent\n * @returns New color with applied transparency\n *\n * @remarks\n * This is an alias for `new_color()` to match PineScript's `color.new()` syntax.\n *\n * @example\n * ```typescript\n * const redColor = color.rgb(255, 0, 0);\n * const transparentRed = color.new(redColor, 50); // 50% transparent red\n * ```\n */\nexport { new_color as new };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,mBAAsC;AAGtC,MAAM,UAAU,CAAC,MACf,MAAM,QAAQ,MAAM,UAAa,OAAO,MAAM,CAAC,IAAI,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC;AAMjG,MAAM,UAAU,CAAC,WACf,WAAW,QAAQ,OAAO,MAAM,MAAM,IAAI,IAAI,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,MAAM,CAAC,IAAI;AA6BlF,SAAS,IAAIA,MAAiBC,QAAmBC,OAAkB,QAA+B;AACvG,QAAMC,KAAI,QAAQH,IAAG;AACrB,QAAMI,KAAI,QAAQH,MAAK;AACvB,QAAMI,KAAI,QAAQH,KAAI;AACtB,QAAM,IAAI,WAAW,SAAY,QAAQ,MAAM,IAAI;AAEnD,MAAI,MAAM,GAAG;AACX,WAAO,OAAOC,EAAC,KAAKC,EAAC,KAAKC,EAAC;AAAA,EAC7B;AACA,SAAO,QAAQF,EAAC,KAAKC,EAAC,KAAKC,EAAC,KAAK,CAAC;AACpC;AAuBO,SAAS,SAAS,KAAa,QAA+B;AAEnE,QAAM,IAAI,QAAQ,KAAK,EAAE;AAEzB,QAAMF,KAAI,SAAS,IAAI,UAAU,GAAG,CAAC,GAAG,EAAE;AAC1C,QAAMC,KAAI,SAAS,IAAI,UAAU,GAAG,CAAC,GAAG,EAAE;AAC1C,QAAMC,KAAI,SAAS,IAAI,UAAU,GAAG,CAAC,GAAG,EAAE;AAE1C,SAAO,IAAIF,IAAGC,IAAGC,IAAG,MAAM;AAC5B;AA2BO,SAAS,UAAU,WAAqC,QAA8B;AAC3F,MAAI,cAAc,QAAQ,cAAc,OAAW,QAAO,IAAI,GAAG,GAAG,GAAG,MAAM;
|
|
4
|
+
"sourcesContent": ["/**\n * Color namespace\n * Mirrors PineScript's color.* functions for color creation and manipulation.\n *\n * @remarks\n * All color functions in this namespace follow PineScript v6 API specifications.\n * Colors are represented as RGB or RGBA strings.\n * Transparency values range from 0 (fully opaque) to 100 (fully transparent).\n *\n * @version 6\n */\n\nimport type { color, int, float, simple_int, simple_float } from '../types/index.js';\nimport { alphaByte, parseColor } from './parse.js';\n\n/** Channel of color.rgb: na is 0, a fraction is truncated. */\nconst channel = (v: number): int =>\n v === null || v === undefined || Number.isNaN(v) ? 0 : Math.max(0, Math.min(255, Math.trunc(v)));\n\n/**\n * Alpha (0-1) of a transparency given to color.rgb / color.new: na is fully transparent, clamped to 0..100.\n * `1 - t / 100` as in PineScript: `color.new(c, 90)` has the alpha byte 25 (0.09999999999999998 * 255 rounded).\n */\nconst alphaOf = (transp: number): float =>\n transp === null || Number.isNaN(transp) ? 0 : 1 - Math.max(0, Math.min(100, transp)) / 100;\n\n/**\n * Creates a color from RGB values with optional transparency.\n *\n * @param red - Red component (0-255, values are clamped)\n * @param green - Green component (0-255, values are clamped)\n * @param blue - Blue component (0-255, values are clamped)\n * @param transp - Optional transparency (0-100). 0 = opaque, 100 = fully transparent\n * @returns Color string in rgb() or rgba() format\n *\n * @remarks\n * - RGB values are automatically clamped to the 0-255 range\n * - Transparency of 0 or omitted results in rgb() format\n * - Transparency > 0 results in rgba() format\n * - Transparency is converted to alpha channel (0-1 range)\n *\n * PineScript rules:\n * - an `na` channel is 0; a fractional channel is truncated (127.6 is 127)\n * - the transparency is clamped to 0..100 (140 is fully transparent, -5 is opaque); an `na` transparency is fully\n * transparent\n *\n * @example\n * ```typescript\n * color.rgb(255, 0, 0) // Returns: \"rgb(255, 0, 0)\" - Red\n * color.rgb(0, 255, 0, 50) // Returns: \"rgba(0, 255, 0, 0.5)\" - Semi-transparent green\n * color.rgb(300, 0, 0) // Returns: \"rgb(255, 0, 0)\" - Clamped to 255\n * ```\n */\nexport function rgb(red: simple_int, green: simple_int, blue: simple_int, transp?: simple_float): string {\n const r = channel(red);\n const g = channel(green);\n const b = channel(blue);\n const a = transp !== undefined ? alphaOf(transp) : 1;\n\n if (a === 1) {\n return `rgb(${r}, ${g}, ${b})`;\n }\n return `rgba(${r}, ${g}, ${b}, ${a})`;\n}\n\n/**\n * Creates a color from a hexadecimal string with optional transparency.\n *\n * @param hex - Hex color string (with or without '#' prefix, e.g., \"#FF0000\" or \"FF0000\")\n * @param transp - Optional transparency (0-100). 0 = opaque, 100 = fully transparent\n * @returns Color string in rgb() or rgba() format\n *\n * @remarks\n * - Accepts hex strings with or without '#' prefix\n * - Case-insensitive (accepts both \"FF0000\" and \"ff0000\")\n * - Must be 6 characters (excluding '#')\n * - Format: RRGGBB where each component is 00-FF\n *\n * @example\n * ```typescript\n * color.from_hex(\"#FF0000\") // Returns: \"rgb(255, 0, 0)\" - Red\n * color.from_hex(\"00FF00\", 50) // Returns: \"rgba(0, 255, 0, 0.5)\" - Semi-transparent green\n * color.from_hex(\"#0000FF\") // Returns: \"rgb(0, 0, 255)\" - Blue\n * color.from_hex(\"FFA500\") // Returns: \"rgb(255, 165, 0)\" - Orange\n * ```\n */\nexport function from_hex(hex: string, transp?: simple_float): string {\n // Remove # if present\n hex = hex.replace('#', '');\n\n const r = parseInt(hex.substring(0, 2), 16);\n const g = parseInt(hex.substring(2, 4), 16);\n const b = parseInt(hex.substring(4, 6), 16);\n\n return rgb(r, g, b, transp);\n}\n\n/**\n * Creates a new color with modified transparency, preserving RGB components.\n *\n * @param baseColor - The base color to modify\n * @param transp - New transparency value (0-100). 0 = opaque, 100 = fully transparent\n * @returns New color with updated transparency\n *\n * @remarks\n * - Preserves the RGB values from the base color\n * - Replaces the transparency with the new value\n * - Useful for creating semi-transparent versions of existing colors\n * - PineScript clamps the transparency to 0..100 (`color.new(c, 140)` is fully transparent, `color.new(c, -5)` is\n * opaque); an `na` transparency is fully transparent (measured: the colour is not na, its RGB is kept)\n * - an `na` colour (null / undefined) gives black with the new transparency: `color.new(na, 30)` is\n * `rgba(0, 0, 0, 0.7)`, as PineScript does for an na colour variable (measured, #150). In PineScript, the constant\n * `color.new(color(na), 30)` is computed at compile time and stays na; a JS function cannot tell the two apart.\n *\n * @example\n * ```typescript\n * const red = color.rgb(255, 0, 0)\n * color.new_color(red, 50) // Returns: \"rgba(255, 0, 0, 0.5)\" - Semi-transparent red\n * color.new_color(red, 0) // Returns: \"rgb(255, 0, 0)\" - Fully opaque\n * color.new_color(red, 100) // Returns: \"rgba(255, 0, 0, 0)\" - Fully transparent\n * ```\n */\nexport function new_color(baseColor: color | null | undefined, transp: simple_float): string {\n if (baseColor === null || baseColor === undefined) return rgb(0, 0, 0, transp); // na colour: black\n if (typeof baseColor !== 'string') {\n const rgba = parseColor(baseColor);\n return rgb(rgba.r, rgba.g, rgba.b, transp);\n }\n // The same colour with the same transparency on every bar and every run: the text is made once.\n let byTransp = newColors.get(baseColor);\n if (byTransp === undefined) {\n if (newColors.size >= NEW_COLORS_KEPT) newColors.clear();\n newColors.set(baseColor, (byTransp = new Map()));\n }\n let text = byTransp.get(transp);\n if (text === undefined) {\n const rgba = parseColor(baseColor);\n text = rgb(rgba.r, rgba.g, rgba.b, transp);\n if (byTransp.size >= NEW_COLORS_KEPT) byTransp.clear();\n byTransp.set(transp, text);\n }\n return text;\n}\n\n/** color.new results by base colour, then transparency. */\nconst newColors = new Map<string, Map<number, string>>();\nconst NEW_COLORS_KEPT = 1024;\n\n/**\n * Extracts the red component from a color.\n *\n * @param clr - The color to extract from\n * @returns Red component value (0-255)\n *\n * @example\n * ```typescript\n * color.r(color.rgb(255, 128, 64)) // Returns: 255\n * color.r(color.from_hex(\"#FF0000\")) // Returns: 255\n * color.r(color.from_hex(\"#FFA500\")) // Returns: 255 (orange)\n * ```\n */\nexport function r(clr: color): int {\n return parseColor(clr).r;\n}\n\n/**\n * Extracts the green component from a color.\n *\n * @param clr - The color to extract from\n * @returns Green component value (0-255)\n *\n * @example\n * ```typescript\n * color.g(color.rgb(255, 128, 64)) // Returns: 128\n * color.g(color.from_hex(\"#00FF00\")) // Returns: 255\n * color.g(color.from_hex(\"#FFA500\")) // Returns: 165 (orange)\n * ```\n */\nexport function g(clr: color): int {\n return parseColor(clr).g;\n}\n\n/**\n * Extracts the blue component from a color.\n *\n * @param clr - The color to extract from\n * @returns Blue component value (0-255)\n *\n * @example\n * ```typescript\n * color.b(color.rgb(255, 128, 64)) // Returns: 64\n * color.b(color.from_hex(\"#0000FF\")) // Returns: 255\n * color.b(color.from_hex(\"#FFA500\")) // Returns: 0 (orange)\n * ```\n */\nexport function b(clr: color): int {\n return parseColor(clr).b;\n}\n\n/**\n * Extracts the transparency component from a color.\n *\n * @param clr - The color to extract from\n * @returns Transparency value (0-100). 0 = fully opaque, 100 = fully transparent\n *\n * @remarks\n * - Returns 0 for colors without transparency (rgb format)\n * - Converts alpha channel (0-1) to transparency (0-100)\n * - PineScript stores the alpha as a byte (0-255) and returns an integer transparency:\n * `color.t(color.new(c, 33.3))` is 33\n * - an `na` colour (null / undefined) is fully transparent: 100\n *\n * @example\n * ```typescript\n * color.t(color.rgb(255, 0, 0)) // Returns: 0 (opaque)\n * color.t(color.rgb(255, 0, 0, 50)) // Returns: 50\n * color.t(color.rgb(255, 0, 0, 100)) // Returns: 100 (fully transparent)\n * ```\n */\nexport function t(clr: color | null | undefined): float {\n if (clr === null || clr === undefined) return 100;\n return Math.round((1 - alphaByte(parseColor(clr).a) / 255) * 100);\n}\n\n// Predefined color constants of PineScript v6.\n// PineScript v5 differs for red (#FF5252), teal (#00897B) and yellow (#FFEB3B).\n/**\n * Aqua/Cyan color constant\n * @constant {string} #00BCD4 - RGB(0, 188, 212)\n */\nexport const aqua = '#00BCD4';\n\n/**\n * Black color constant\n * @constant {string} #363A45 - RGB(54, 58, 69)\n */\nexport const black = '#363A45';\n\n/**\n * Blue color constant\n * @constant {string} #2962FF - RGB(41, 98, 255)\n */\nexport const blue = '#2962FF';\n\n/**\n * Fuchsia/Magenta color constant\n * @constant {string} #E040FB - RGB(224, 64, 251)\n */\nexport const fuchsia = '#E040FB';\n\n/**\n * Gray color constant\n * @constant {string} #787B86 - RGB(120, 123, 134)\n */\nexport const gray = '#787B86';\n\n/**\n * Green color constant (same as lime)\n * @constant {string} #4CAF50 - RGB(76, 175, 80)\n */\nexport const green = '#4CAF50';\n\n/**\n * Lime color constant (same as green)\n * @constant {string} #00E676 - RGB(0, 230, 118)\n */\nexport const lime = '#00E676';\n\n/**\n * Maroon color constant\n * @constant {string} #880E4F - RGB(136, 14, 79)\n */\nexport const maroon = '#880E4F';\n\n/**\n * Navy color constant\n * @constant {string} #311B92 - RGB(49, 27, 146)\n */\nexport const navy = '#311B92';\n\n/**\n * Olive color constant\n * @constant {string} #808000 - RGB(128, 128, 0)\n */\nexport const olive = '#808000';\n\n/**\n * Orange color constant\n * @constant {string} #FF9800 - RGB(255, 152, 0)\n */\nexport const orange = '#FF9800';\n\n/**\n * Purple color constant\n * @constant {string} #9C27B0 - RGB(156, 39, 176)\n */\nexport const purple = '#9C27B0';\n\n/**\n * Red color constant\n * @constant {string} #F23645 - RGB(242, 54, 69)\n */\nexport const red = '#F23645';\n\n/**\n * Silver color constant\n * @constant {string} #B2B5BE - RGB(178, 181, 190)\n */\nexport const silver = '#B2B5BE';\n\n/**\n * Teal color constant\n * @constant {string} #089981 - RGB(8, 153, 129)\n */\nexport const teal = '#089981';\n\n/**\n * White color constant\n * @constant {string} #FFFFFF - RGB(255, 255, 255)\n */\nexport const white = '#FFFFFF';\n\n/**\n * Yellow color constant\n * @constant {string} #FDD835 - RGB(253, 216, 53)\n */\nexport const yellow = '#FDD835';\n\n/**\n * Creates a color from a gradient based on value position.\n *\n * @param value - Value to calculate position-dependent color\n * @param bottom_value - Bottom position value corresponding to bottom_color\n * @param top_value - Top position value corresponding to top_color\n * @param bottom_color - Bottom position color\n * @param top_color - Top position color\n * @returns Color calculated from linear gradient\n *\n * @remarks\n * PineScript rules:\n * - If value <= bottom_value, returns bottom_color; else if value >= top_value, returns top_color\n * - An inverted range (bottom_value > top_value) returns bottom_color, wherever the value is\n * - Otherwise the colours are mixed with their transparency (premultiplied alpha, alpha as a byte); the RGB channels\n * and the alpha are truncated. PineScript's float rounding order is not known: a channel can differ by 1 when the\n * exact result is an integer (same RGB at both ends)\n * - An na value or bottom_value / top_value, or bottom_value == top_value, gives a fully transparent colour\n * - An na colour counts as fully transparent\n * - Works with rgb(), rgba() and hex (#RRGGBB, #RRGGBBAA) colours\n *\n * @example\n * ```typescript\n * // Value at middle of range gets middle color\n * const midColor = color.from_gradient(50, 0, 100,\n * color.rgb(255, 0, 0), // Red at bottom\n * color.rgb(0, 255, 0) // Green at top\n * ); // Returns color between red and green\n *\n * // Value at extremes\n * const lowColor = color.from_gradient(-10, 0, 100, red, green); // Returns red\n * const highColor = color.from_gradient(150, 0, 100, red, green); // Returns green\n * ```\n */\nexport function from_gradient(\n value: float,\n bottom_value: float,\n top_value: float,\n bottom_color: color,\n top_color: color\n): string {\n const transparent = 'rgba(0, 0, 0, 0)';\n if ([value, bottom_value, top_value].some((v) => v === null || v === undefined || Number.isNaN(v)) || bottom_value === top_value) {\n return transparent;\n }\n const k =\n value <= bottom_value || bottom_value > top_value\n ? 0\n : value >= top_value\n ? 1\n : (value - bottom_value) / (top_value - bottom_value);\n // alpha as a byte (0-255), as PineScript stores it; an na colour (null / undefined, or 'transparent', the\n // library's form of na) is fully transparent\n const rgba = (c: color) => {\n if (c === null || c === undefined || (typeof c === 'string' && c.trim().toLowerCase() === 'transparent')) return { r: 0, g: 0, b: 0, a: 0 };\n const p = parseColor(c);\n return { r: p.r, g: p.g, b: p.b, a: alphaByte(p.a) };\n };\n const c1 = rgba(bottom_color);\n const c2 = rgba(top_color);\n const a = c1.a * (1 - k) + c2.a * k;\n if (a === 0) return transparent;\n // PineScript order (bit for bit, #146): premultiplied channels ((alpha / 255) * channel) * weight, divided by the\n // byte-alpha mix / 255, truncated. At an end (k = 0 / 1) this is floor(x * a / a): the end colour or one unit less.\n const scale = a / 255;\n const w1 = c1.a / 255;\n const w2 = c2.a / 255;\n const mix = (x1: number, x2: number) => Math.floor(((w1 * x1) * (1 - k) + (w2 * x2) * k) / scale);\n const [r, g, b] = [mix(c1.r, c2.r), mix(c1.g, c2.g), mix(c1.b, c2.b)];\n const alpha = Math.floor(a);\n return alpha === 255 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${alpha / 255})`;\n}\n\n/**\n * Alias for new_color function.\n * Creates a new color with specified transparency from an existing color.\n *\n * @param baseColor - The base color\n * @param transp - Transparency value (0-100). 0 = fully opaque, 100 = fully transparent\n * @returns New color with applied transparency\n *\n * @remarks\n * This is an alias for `new_color()` to match PineScript's `color.new()` syntax.\n *\n * @example\n * ```typescript\n * const redColor = color.rgb(255, 0, 0);\n * const transparentRed = color.new(redColor, 50); // 50% transparent red\n * ```\n */\nexport { new_color as new };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,mBAAsC;AAGtC,MAAM,UAAU,CAAC,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2
2
|
* Colour parsing shared by the color namespace and input.color (internal, not part of the public API).
|
|
3
3
|
*/
|
|
4
4
|
import type { color, int, float } from '../types/index.js';
|
|
5
|
+
export interface ParsedColor {
|
|
6
|
+
readonly r: int;
|
|
7
|
+
readonly g: int;
|
|
8
|
+
readonly b: int;
|
|
9
|
+
readonly a: float;
|
|
10
|
+
}
|
|
5
11
|
/**
|
|
6
12
|
* Parses a colour string to its channels (0-255) and alpha (0-1).
|
|
7
13
|
* Hex: #RRGGBB, #RRGGBBAA (PineScript literals), #RGB, #RGBA; rgb() / rgba(). Anything else is opaque black.
|
|
14
|
+
* The result is shared between calls: do not change it.
|
|
8
15
|
*/
|
|
9
|
-
export declare function parseColor(clr: color):
|
|
10
|
-
r: int;
|
|
11
|
-
g: int;
|
|
12
|
-
b: int;
|
|
13
|
-
a: float;
|
|
14
|
-
};
|
|
16
|
+
export declare function parseColor(clr: color): ParsedColor;
|
|
15
17
|
/** Alpha byte (0-255) of an alpha (0-1), as PineScript stores it. */
|
|
16
18
|
export declare const alphaByte: (a: float) => int;
|
|
17
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/color/parse.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE3D
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/color/parse.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IAChB,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IAChB,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;IAChB,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC;CACnB;AAQD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,KAAK,GAAG,WAAW,CASlD;AAwBD,qEAAqE;AACrE,eAAO,MAAM,SAAS,GAAI,GAAG,KAAK,KAAG,GAA0B,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,CAStD"}
|
package/dist/cjs/color/parse.js
CHANGED
|
@@ -23,8 +23,21 @@ __export(parse_exports, {
|
|
|
23
23
|
parseColor: () => parseColor
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(parse_exports);
|
|
26
|
+
const BLACK = { r: 0, g: 0, b: 0, a: 1 };
|
|
27
|
+
const parsed = /* @__PURE__ */ new Map();
|
|
28
|
+
const PARSED_KEPT = 4096;
|
|
26
29
|
function parseColor(clr) {
|
|
27
|
-
if (typeof clr
|
|
30
|
+
if (typeof clr !== "string") return BLACK;
|
|
31
|
+
let p = parsed.get(clr);
|
|
32
|
+
if (p === void 0) {
|
|
33
|
+
p = parseText(clr);
|
|
34
|
+
if (parsed.size >= PARSED_KEPT) parsed.clear();
|
|
35
|
+
parsed.set(clr, p);
|
|
36
|
+
}
|
|
37
|
+
return p;
|
|
38
|
+
}
|
|
39
|
+
function parseText(clr) {
|
|
40
|
+
{
|
|
28
41
|
const hex = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(clr.trim());
|
|
29
42
|
if (hex) {
|
|
30
43
|
let digits = hex[1];
|
|
@@ -42,7 +55,7 @@ function parseColor(clr) {
|
|
|
42
55
|
};
|
|
43
56
|
}
|
|
44
57
|
}
|
|
45
|
-
return
|
|
58
|
+
return BLACK;
|
|
46
59
|
}
|
|
47
60
|
const alphaByte = (a) => Math.round(a * 255);
|
|
48
61
|
function inputColorDefault(defval) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/color/parse.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Colour parsing shared by the color namespace and input.color (internal, not part of the public API).\n */\n\nimport type { color, int, float } from '../types/index.js';\n\n/**\n * Parses a colour string to its channels (0-255) and alpha (0-1).\n * Hex: #RRGGBB, #RRGGBBAA (PineScript literals), #RGB, #RGBA; rgb() / rgba(). Anything else is opaque black.\n */\nexport function parseColor(clr: color): {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * Colour parsing shared by the color namespace and input.color (internal, not part of the public API).\n */\n\nimport type { color, int, float } from '../types/index.js';\n\nexport interface ParsedColor {\n readonly r: int;\n readonly g: int;\n readonly b: int;\n readonly a: float;\n}\n\nconst BLACK: ParsedColor = { r: 0, g: 0, b: 0, a: 1 };\n\n/** Parsed colours by text: a script reads the same few colours on every bar, and again on each run. */\nconst parsed = new Map<string, ParsedColor>();\nconst PARSED_KEPT = 4096;\n\n/**\n * Parses a colour string to its channels (0-255) and alpha (0-1).\n * Hex: #RRGGBB, #RRGGBBAA (PineScript literals), #RGB, #RGBA; rgb() / rgba(). Anything else is opaque black.\n * The result is shared between calls: do not change it.\n */\nexport function parseColor(clr: color): ParsedColor {\n if (typeof clr !== 'string') return BLACK;\n let p = parsed.get(clr);\n if (p === undefined) {\n p = parseText(clr);\n if (parsed.size >= PARSED_KEPT) parsed.clear();\n parsed.set(clr, p);\n }\n return p;\n}\n\nfunction parseText(clr: string): ParsedColor {\n {\n const hex = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(clr.trim());\n if (hex) {\n let digits = hex[1]!;\n if (digits.length <= 4) digits = [...digits].map((c) => c + c).join('');\n const byte = (k: number) => parseInt(digits.slice(k, k + 2), 16);\n return { r: byte(0), g: byte(2), b: byte(4), a: digits.length === 8 ? byte(6) / 255 : 1 };\n }\n const match = clr.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*([\\d.]+))?\\)/);\n if (match) {\n return {\n r: parseInt(match[1]!),\n g: parseInt(match[2]!),\n b: parseInt(match[3]!),\n a: match[4] ? parseFloat(match[4]) : 1,\n };\n }\n }\n return BLACK;\n}\n\n/** Alpha byte (0-255) of an alpha (0-1), as PineScript stores it. */\nexport const alphaByte = (a: float): int => Math.round(a * 255);\n\n/**\n * The colour a script receives for the default of `input.color(defval)`.\n *\n * PineScript rules (measured):\n * - the default is stored with an alpha of 2 decimals: a `color.new(c, t)` / `color.rgb(r, g, b, t)` default keeps\n * `(100 - trunc(t)) / 100` (90 gives 0.1, 9.9 gives 0.91), a hex literal `#RRGGBBAA` keeps `round(AA / 255, 2)`\n * - the input value is then the alpha byte `round(255 * alpha)`: `color.new(c, 90)` as an input default has the\n * byte 26, where `color.new(c, 90)` in the script has 25\n *\n * A default whose alpha byte does not change is returned unchanged.\n */\nexport function inputColorDefault(defval: color): color {\n if (typeof defval !== 'string') return defval;\n const p = parseColor(defval);\n const hex = defval.trim().startsWith('#');\n // rgba() from color.new / color.rgb: alpha = 1 - t / 100, so alpha * 100 = 100 - t (float noise removed first)\n const stored = hex ? Math.round(p.a * 100) / 100 : Math.ceil(Math.round(p.a * 100 * 1e6) / 1e6) / 100;\n const byte = alphaByte(stored);\n if (byte === alphaByte(p.a)) return defval;\n return byte === 255 ? `rgb(${p.r}, ${p.g}, ${p.b})` : `rgba(${p.r}, ${p.g}, ${p.b}, ${byte / 255})`;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,MAAM,QAAqB,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AAGpD,MAAM,SAAS,oBAAI,IAAyB;AAC5C,MAAM,cAAc;AAOb,SAAS,WAAW,KAAyB;AAClD,MAAI,OAAO,QAAQ,SAAU,QAAO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AM,KAAK,KAAK,KAAK,MAAM,EAAE,IAAI,MAAM,GAAG,IAAI,GAAG,IAAI;AAClG,QAAM,OAAO,UAAU,MAAM;AAC7B,MAAI,SAAS,UAAU,EAAE,CAAC,EAAG,QAAO;AACpC,SAAO,SAAS,MAAM,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,MAAM,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG;AAClG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -48,6 +48,9 @@
|
|
|
48
48
|
* The script API (`executeScript`) resets the registry at the start of every run and applies the
|
|
49
49
|
* `max_*_count` values of `indicator()`. Outside a script run the registry is global to the module.
|
|
50
50
|
*
|
|
51
|
+
* A port with its own bar loop resumes a live update with {@link saveDrawingCheckpoint} (at the end of the last
|
|
52
|
+
* confirmed bar) and {@link restoreDrawingCheckpoint} (before the forming bar is calculated again).
|
|
53
|
+
*
|
|
51
54
|
* @module drawing/registry
|
|
52
55
|
*/
|
|
53
56
|
import type { Box, Label, Line, Linefill, Polyline, Table } from '../types/index.js';
|
|
@@ -72,6 +75,17 @@ export type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill' | 'ta
|
|
|
72
75
|
export declare class Stamped {
|
|
73
76
|
constructor(obj: object);
|
|
74
77
|
}
|
|
78
|
+
/** True for a drawing object of the registry (a line, a label, a box, a polyline, a linefill or a table). */
|
|
79
|
+
export declare function isDrawingObject(value: unknown): boolean;
|
|
80
|
+
/** Hooks of an incremental script run (#196, set by the script runtime during a run only). @internal */
|
|
81
|
+
export interface DrawingRunHooks {
|
|
82
|
+
/** A drawing function read or changed the registry or an object */
|
|
83
|
+
access(): void;
|
|
84
|
+
/** A creation: the object of the previous run to use instead of `obj` (its fields are set to those of `obj`) */
|
|
85
|
+
reuse(kind: DrawingKind, obj: object): object | null;
|
|
86
|
+
}
|
|
87
|
+
/** @internal */
|
|
88
|
+
export declare function setDrawingRunHooks(hooks: DrawingRunHooks | null): void;
|
|
75
89
|
/** The `var` records of a run: a reset starts new ones, a nested run saves and puts back those of its run. */
|
|
76
90
|
interface Holds {
|
|
77
91
|
/** The records of the objects whose private record belongs to another run */
|
|
@@ -79,6 +93,10 @@ interface Holds {
|
|
|
79
93
|
/** Records made in the run. None: no object has one, nothing to look up for each object the maximum count may
|
|
80
94
|
* delete */
|
|
81
95
|
records: number;
|
|
96
|
+
/** The {@link varDrawing} variables made in the run: a checkpoint puts their objects back with the records */
|
|
97
|
+
readonly variables: Array<{
|
|
98
|
+
current: object | undefined;
|
|
99
|
+
}>;
|
|
82
100
|
}
|
|
83
101
|
/** What the `var` variables of a run did with an object. */
|
|
84
102
|
interface HoldRecord {
|
|
@@ -188,6 +206,56 @@ export interface DrawingState {
|
|
|
188
206
|
}
|
|
189
207
|
/** Saves the registry of the current run before a nested run (an intrabar run of a strategy). */
|
|
190
208
|
export declare function saveDrawingState(): DrawingState;
|
|
209
|
+
/**
|
|
210
|
+
* The registry and the state of its objects at the end of a bar (see {@link saveDrawingCheckpoint}): the live objects,
|
|
211
|
+
* the fields of each one (arrays, maps and plain objects copied; other drawing objects kept as references), their `var`
|
|
212
|
+
* records, the objects of the {@link varDrawing} variables, and the counters. Its fields are internal.
|
|
213
|
+
*/
|
|
214
|
+
export interface DrawingCheckpoint {
|
|
215
|
+
state: DrawingState;
|
|
216
|
+
fields: Map<object, Record<string, unknown>>;
|
|
217
|
+
records: Map<object, {
|
|
218
|
+
count: number;
|
|
219
|
+
heldAt: number | undefined;
|
|
220
|
+
releasedAt: number | undefined;
|
|
221
|
+
} | null>;
|
|
222
|
+
/** The object of each variable of the run, in the order they were made */
|
|
223
|
+
variables: Array<object | undefined>;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* The drawings at the end of a bar, for a live update of a study with its own bar loop: save it at the end of the last
|
|
227
|
+
* confirmed bar, and put it back with {@link restoreDrawingCheckpoint} before the forming bar is calculated again. The
|
|
228
|
+
* drawings then are those of a full run on the same bars: the objects created, changed or deleted on the forming bar
|
|
229
|
+
* are undone, the objects keep their identity and creation order, and the maximum counts, the `var` holds (also of
|
|
230
|
+
* {@link varDrawing} variables), the linefills and the rules of the last bar ({@link setDrawingBar}) go on as in a full
|
|
231
|
+
* run. The incremental script runs use it too (#196, #203).
|
|
232
|
+
*
|
|
233
|
+
* The checkpoint holds the whole registry of the study: other studies on the same chart may reset and use the registry
|
|
234
|
+
* between two updates, putting it back makes it the study's again (call it where a full run calls
|
|
235
|
+
* {@link resetDrawings}). The study keeps its own variables (the objects it refers to, its arrays of objects) with the
|
|
236
|
+
* checkpoint and puts them back as plain values.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* // full run: resetDrawings({ line: 500 }) ... for each bar i: setDrawingBar(i, i === n - 1); draw(i);
|
|
241
|
+
* // and after the bar n - 2: checkpoint = saveDrawingCheckpoint()
|
|
242
|
+
* // live update of the forming bar n - 1 (or new bars after it):
|
|
243
|
+
* restoreDrawingCheckpoint(checkpoint);
|
|
244
|
+
* for (let i = n - 1; i < bars.length; i++) {
|
|
245
|
+
* setDrawingBar(i, i === bars.length - 1);
|
|
246
|
+
* draw(i);
|
|
247
|
+
* if (i === bars.length - 2) checkpoint = saveDrawingCheckpoint();
|
|
248
|
+
* }
|
|
249
|
+
* setDrawingBar(null);
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
export declare function saveDrawingCheckpoint(): DrawingCheckpoint;
|
|
253
|
+
/**
|
|
254
|
+
* Puts back a {@link saveDrawingCheckpoint}: the registry becomes the one of the checkpoint, the objects alive then get
|
|
255
|
+
* their fields and `var` records back, the variables their objects. It can be put back again later (on each update of
|
|
256
|
+
* the forming bar).
|
|
257
|
+
*/
|
|
258
|
+
export declare function restoreDrawingCheckpoint(cp: DrawingCheckpoint): void;
|
|
191
259
|
/** Puts back the registry saved by {@link saveDrawingState} after the nested run. */
|
|
192
260
|
export declare function restoreDrawingState(s: DrawingState): void;
|
|
193
261
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/drawing/registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/drawing/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAErF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAEvF,UAAU,YAAY;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAIpC,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AA0FhG;;;;;GAKG;AACH,qBAAa,OAAO;gBACN,GAAG,EAAE,MAAM;CAGxB;AAoBD,6GAA6G;AAC7G,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEvD;AAED,wGAAwG;AACxG,MAAM,WAAW,eAAe;IAC9B,mEAAmE;IACnE,MAAM,IAAI,IAAI,CAAC;IACf,gHAAgH;IAChH,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAA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