@invinite-org/chartlang-core 1.1.0 → 1.2.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/CHANGELOG.md +232 -0
- package/README.md +2 -1
- package/dist/alert/alert.d.ts +1 -1
- package/dist/alert/alert.js +1 -1
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert/index.js.map +1 -1
- package/dist/color/colorHelpers.js.map +1 -1
- package/dist/color/index.js.map +1 -1
- package/dist/color/parseColor.js.map +1 -1
- package/dist/define/defineAlert.js.map +1 -1
- package/dist/define/defineAlertCondition.js.map +1 -1
- package/dist/define/defineDrawing.d.ts +2 -2
- package/dist/define/defineDrawing.js +2 -2
- package/dist/define/defineDrawing.js.map +1 -1
- package/dist/define/defineIndicator.js.map +1 -1
- package/dist/define/depAccessorSentinel.js.map +1 -1
- package/dist/define/dependency.js.map +1 -1
- package/dist/define/index.js.map +1 -1
- package/dist/define/overrides.js.map +1 -1
- package/dist/draw/buckets.d.ts.map +1 -1
- package/dist/draw/buckets.js +1 -0
- package/dist/draw/buckets.js.map +1 -1
- package/dist/draw/draw.d.ts +10 -4
- package/dist/draw/draw.d.ts.map +1 -1
- package/dist/draw/draw.js +1 -2
- package/dist/draw/draw.js.map +1 -1
- package/dist/draw/drawingKind.d.ts +9 -9
- package/dist/draw/drawingKind.d.ts.map +1 -1
- package/dist/draw/drawingKind.js +5 -3
- package/dist/draw/drawingKind.js.map +1 -1
- package/dist/draw/drawingState.d.ts +32 -8
- package/dist/draw/drawingState.d.ts.map +1 -1
- package/dist/draw/drawingState.js.map +1 -1
- package/dist/draw/drawingStyle.d.ts +53 -10
- package/dist/draw/drawingStyle.d.ts.map +1 -1
- package/dist/draw/drawingStyle.js.map +1 -1
- package/dist/draw/handle.js.map +1 -1
- package/dist/draw/index.d.ts +2 -2
- package/dist/draw/index.d.ts.map +1 -1
- package/dist/draw/index.js.map +1 -1
- package/dist/draw/table.d.ts +1 -1
- package/dist/draw/table.js.map +1 -1
- package/dist/draw/worldPoint.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/input/index.js.map +1 -1
- package/dist/input/input.js.map +1 -1
- package/dist/input/inputDescriptor.js.map +1 -1
- package/dist/interval/intervalToSeconds.js.map +1 -1
- package/dist/plot/index.js.map +1 -1
- package/dist/plot/plot.d.ts +16 -1
- package/dist/plot/plot.d.ts.map +1 -1
- package/dist/plot/plot.js +1 -1
- package/dist/plot/plot.js.map +1 -1
- package/dist/request/index.d.ts +1 -1
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js.map +1 -1
- package/dist/request/request.d.ts +82 -20
- package/dist/request/request.d.ts.map +1 -1
- package/dist/request/request.js +27 -26
- package/dist/request/request.js.map +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/state/index.js.map +1 -1
- package/dist/state/mutableSlot.js.map +1 -1
- package/dist/state/snapshot.d.ts +5 -5
- package/dist/state/snapshot.js.map +1 -1
- package/dist/state/state.d.ts +17 -0
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +18 -0
- package/dist/state/state.js.map +1 -1
- package/dist/statefulPrimitives.d.ts +10 -6
- package/dist/statefulPrimitives.d.ts.map +1 -1
- package/dist/statefulPrimitives.js +18 -6
- package/dist/statefulPrimitives.js.map +1 -1
- package/dist/ta/index.js.map +1 -1
- package/dist/ta/ta.d.ts +79 -48
- package/dist/ta/ta.d.ts.map +1 -1
- package/dist/ta/ta.js +6 -0
- package/dist/ta/ta.js.map +1 -1
- package/dist/time/_lib/dateTimeFormatCache.js.map +1 -1
- package/dist/time/index.js.map +1 -1
- package/dist/time/nyDayKey.js +2 -2
- package/dist/time/nyDayKey.js.map +1 -1
- package/dist/time/session.js.map +1 -1
- package/dist/time/sessionBoundaries.js +2 -2
- package/dist/time/sessionBoundaries.js.map +1 -1
- package/dist/time/types.js.map +1 -1
- package/dist/time/weekKey.js.map +1 -1
- package/dist/time/weekday.js.map +1 -1
- package/dist/types.d.ts +167 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/views/barstate.js.map +1 -1
- package/dist/views/index.js.map +1 -1
- package/dist/views/syminfo.js.map +1 -1
- package/dist/views/timeframe.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,237 @@
|
|
|
1
1
|
# @invinite-org/chartlang-core
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 850ae21: Add `bar.point(offset, price)` — index authoring sugar for anchoring drawings
|
|
8
|
+
by bar offset instead of an absolute timestamp.
|
|
9
|
+
|
|
10
|
+
`bar.point` resolves the offset to the existing time-based `WorldPoint`
|
|
11
|
+
(`{ time, price }`) at compute time, so it composes directly with every
|
|
12
|
+
`draw.*` anchor argument and introduces no new wire format or anchor union:
|
|
13
|
+
|
|
14
|
+
- `bar.point(0, price)` — the current bar.
|
|
15
|
+
- `bar.point(-n, price)` — `n` bars back, using the real historical timestamp
|
|
16
|
+
from the runtime's time ring buffer (`NaN` time past retained history; never
|
|
17
|
+
throws).
|
|
18
|
+
- `bar.point(n, price)` — a future bar, with the time extrapolated from the
|
|
19
|
+
median recent bar spacing (falling back to the parsed bar interval when
|
|
20
|
+
fewer than two bars are retained).
|
|
21
|
+
|
|
22
|
+
The compiler's max-lookback analysis now counts a negative integer-literal
|
|
23
|
+
`bar.point(-n, …)` offset toward `maxLookback` exactly like a `series[n]`
|
|
24
|
+
lookback, so the runtime sizes the time buffer deeply enough; positive (future)
|
|
25
|
+
offsets and dynamic offsets contribute no extra depth. The recogniser peels
|
|
26
|
+
parentheses, so the converter's emitted form `bar.point(-(n), …)` is sized
|
|
27
|
+
identically to a hand-written `bar.point(-n, …)` (without it, a converted
|
|
28
|
+
historical tracking line sized its buffer to 0 and resolved to a NaN anchor).
|
|
29
|
+
|
|
30
|
+
The Pine v6 converter now lowers `bar_index` drawing anchors to
|
|
31
|
+
`bar.point(<signed offset>, <price>)` and drops the dead `__BAR_INTERVAL_MS`
|
|
32
|
+
sentinel and its `bar.time ± (N * __BAR_INTERVAL_MS)` arithmetic — future
|
|
33
|
+
anchors resolve at runtime instead of needing a host-supplied bar interval.
|
|
34
|
+
|
|
35
|
+
- ca19e20: Bidirectional plot `offset` — negative offsets shift a plotted series left.
|
|
36
|
+
|
|
37
|
+
`offset` becomes a presentation-only **display shift** in bars with the
|
|
38
|
+
fixed sign convention `+n` = right (future), `−n` = left (past); the
|
|
39
|
+
numeric series value is unshifted. This replaces the old value-read model
|
|
40
|
+
(where a positive offset made `series.current` read the value N bars ago
|
|
41
|
+
and a negative offset resolved to `NaN`). The `*Opts` `offset` JSDoc (and
|
|
42
|
+
ALMA's `barShift`) now describe both directions and drop the old
|
|
43
|
+
"negative ⇒ NaN" wording (`AlmaOpts.offset`, the Gaussian-centre
|
|
44
|
+
position, is unchanged).
|
|
45
|
+
|
|
46
|
+
`PlotEmission` gains an optional presentation field `xShift?: number`
|
|
47
|
+
(signed integer bars; omitted/`0` ≡ no shift, so a no-shift emission is
|
|
48
|
+
byte-identical to today). `validateEmission` rejects a non-integer
|
|
49
|
+
`xShift`. The compiler no longer counts `offset` toward `maxLookback`
|
|
50
|
+
(the value is no longer read from a deeper slot). The runtime threads the
|
|
51
|
+
declared offset onto the emission as `xShift` (reading a
|
|
52
|
+
`WeakMap<Series, number>` offset tag set by `makeShiftedSeriesView`; ALMA
|
|
53
|
+
tags `opts.barShift`) and stops the old value-read shift so
|
|
54
|
+
`series.current` is unshifted; the reference adapter renders it by
|
|
55
|
+
projecting `xShift` onto the x-axis (extending the viewport for
|
|
56
|
+
future-shifted points).
|
|
57
|
+
|
|
58
|
+
The Pine converter now maps `plot(<ta.* call>, offset=N)` onto the
|
|
59
|
+
emitted `ta.*` call's `offset` opt (signed, both directions); a plot
|
|
60
|
+
whose value is not a direct `ta.*` call drops the offset and emits the
|
|
61
|
+
new `plot-offset-needs-ta-call` warning, and a plot-level offset
|
|
62
|
+
replacing the ta call's own `offset=` emits `plot-offset-overrides-ta-offset`.
|
|
63
|
+
|
|
64
|
+
The conformance harness's `plot-field` assertion gains an `xShift` field,
|
|
65
|
+
and a new scenario pins both shift directions plus the unshifted value
|
|
66
|
+
series.
|
|
67
|
+
|
|
68
|
+
- 6235ad7: Make the compute bar's OHLCV + derived fields directly indexable as a series.
|
|
69
|
+
|
|
70
|
+
`bar.close`, `bar.open`, `bar.high`, `bar.low`, `bar.volume`, and the derived
|
|
71
|
+
`bar.hl2` / `bar.hlc3` / `bar.ohlc4` / `bar.hlcc4` are now `PriceSeries` /
|
|
72
|
+
`VolumeSeries` (`number & Series<number>`) on the bar passed to `compute`
|
|
73
|
+
(`ComputeContext.bar`, typed as the new `BarSeries`). Each field is **both** a
|
|
74
|
+
scalar — `bar.close * 2`, `plot(bar.close)`, `ta.ema(bar.close, 20)` keep
|
|
75
|
+
working unchanged — **and** an indexable series, so a script can read prior
|
|
76
|
+
bars directly:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const sma5 =
|
|
80
|
+
(bar.close[0] + bar.close[1] + bar.close[2] + bar.close[3] + bar.close[4]) /
|
|
81
|
+
5;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This removes the `ta.ema(bar.close, 1)` identity-trick that scripts previously
|
|
85
|
+
needed to "republish" a scalar price as an indexable `Series`.
|
|
86
|
+
|
|
87
|
+
The adapter-supplied candle type `Bar` (and `request.lowerTf` intrabar bars) is
|
|
88
|
+
unchanged — it stays scalar OHLCV; only the streaming `compute` bar gains the
|
|
89
|
+
series shape. `request.security`'s higher-timeframe bar remains the separate
|
|
90
|
+
`SecurityBar`.
|
|
91
|
+
|
|
92
|
+
Migration note: because the field is now an object, `Number.isFinite(bar.close)`
|
|
93
|
+
is always `false` (it does not coerce) and `bar.close === 42` is `false` (object
|
|
94
|
+
vs number). Use `bar.close.current` or `+bar.close` in those raw-number
|
|
95
|
+
contexts. `bar.point(0, bar.close)` continues to work — the runtime coerces the
|
|
96
|
+
anchor price to a scalar.
|
|
97
|
+
|
|
98
|
+
- 3bf391a: Add the `draw.fillBetween(edgeA, edgeB, opts?)` drawing primitive — a
|
|
99
|
+
native filled ribbon between two edges (the closed polygon `edgeA`
|
|
100
|
+
forward then `edgeB` reversed). It is the chartlang equivalent of Pine's
|
|
101
|
+
`linefill.new(line1, line2, color)` / `fill(plot1, plot2)`. The
|
|
102
|
+
pine-converter now lowers static two-line `linefill.new` to it instead of
|
|
103
|
+
approximating with `draw.rotatedRectangle`, retiring the
|
|
104
|
+
`linefill-rotatedrect-approximated` diagnostic.
|
|
105
|
+
- 8086003: Add an optional presentation-only `z` (render-order / z-index) option to
|
|
106
|
+
`plot()` and every `draw.*` primitive. Default `0`; higher renders on
|
|
107
|
+
top, ties fall back to the existing group + declaration order. Finite
|
|
108
|
+
numbers only. Affects stacking only — values, alerts, and `state.*` are
|
|
109
|
+
unchanged.
|
|
110
|
+
|
|
111
|
+
Adapter kit: `PlotEmission` and `DrawingEmission` gain the matching
|
|
112
|
+
presentation-only `z?: number` wire field, validated by
|
|
113
|
+
`validateEmission` as a finite number (NaN / ±Infinity rejected;
|
|
114
|
+
fractional and negative allowed). Omitted/`0` stays byte-identical to a
|
|
115
|
+
pre-feature emission, so existing goldens and conformance hashes are
|
|
116
|
+
untouched.
|
|
117
|
+
|
|
118
|
+
Runtime: `plotImpl` reads `opts.z`, and the drawing-emit path
|
|
119
|
+
(`createDrawingHandle`) lifts `z` out of `state.style` — into a shallow
|
|
120
|
+
clone with `z` removed, where the per-kind `draw.*` impls fold the opts
|
|
121
|
+
bag — and threads it onto the top-level `PlotEmission.z` /
|
|
122
|
+
`DrawingEmission.z` with the same omit-when-`0` conditional spread used
|
|
123
|
+
for `xShift`. `z` is persisted **beside** the drawing slot's `state`
|
|
124
|
+
(never inside `DrawingState`), so an `update` retains the last value. A
|
|
125
|
+
no-`z` plot or drawing emits no `z` key — byte-identical to the
|
|
126
|
+
pre-feature baseline. `draw.table` / `draw.group` do not carry `z` in
|
|
127
|
+
v1.
|
|
128
|
+
|
|
129
|
+
Pine converter: `explicit_plot_zorder` is now a recognized no-op instead
|
|
130
|
+
of an unmapped warning. chartlang already layers marks by declaration
|
|
131
|
+
order within their group (the normative ordering contract), which is
|
|
132
|
+
exactly what Pine's `explicit_plot_zorder=true` makes authoritative — so
|
|
133
|
+
the flag is satisfied by default and needs no chartlang option.
|
|
134
|
+
`mapDeclarationArgs` no longer raises `indicator-arg-not-mapped` for it;
|
|
135
|
+
instead it emits a single `explicit-plot-zorder-default` info note
|
|
136
|
+
(covering both `explicit_plot_zorder=true` and the Pine-default
|
|
137
|
+
`=false`). The converter still never _emits_ a numeric `z` — Pine has no
|
|
138
|
+
per-element z source construct. Other unmapped `indicator(...)` args
|
|
139
|
+
(`timeframe`, etc.) keep warning.
|
|
140
|
+
|
|
141
|
+
Compiler: the ambient `@invinite-org/chartlang-core` `.d.ts` shim gains a
|
|
142
|
+
`ZOrdered { z?: number }` mixin intersected into `PlotOpts` and every
|
|
143
|
+
`draw.*` option type (mirroring core's `drawingStyle.ts`), so a compiled
|
|
144
|
+
script's `plot(value, { z })` **and** `draw.*(…, { z })` type-check (the
|
|
145
|
+
shim stays in lockstep with core).
|
|
146
|
+
|
|
147
|
+
Conformance: a new `z-order` scenario pins the plot `z` →
|
|
148
|
+
`PlotEmission.z` wire contract — a `plot(value, { z: -1 })` emits
|
|
149
|
+
`z: -1`, a no-`z` plot omits the field (omit-when-`0` byte-identity), and
|
|
150
|
+
a value-hash proves `z` never transforms the series. The `plot-field`
|
|
151
|
+
assertion's `field` union widens to also accept `"z"`.
|
|
152
|
+
|
|
153
|
+
- 073f41b: Add the higher-timeframe expression/callback overload to `request.security`.
|
|
154
|
+
Alongside the existing data form `request.security({ interval })` →
|
|
155
|
+
`SecurityBar`, scripts can now write `request.security({ interval }, (bar) =>
|
|
156
|
+
…)` → `Series<number>`, where the callback runs on the **higher-timeframe
|
|
157
|
+
clock** — `request.security({ interval: "1W" }, (bar) => ta.ema(bar.close, 20))`
|
|
158
|
+
is a true weekly EMA(20) (20 weekly bars), not 20 main bars of a weekly-stepped
|
|
159
|
+
series. The result is aligned no-lookahead down to the main timeline.
|
|
160
|
+
|
|
161
|
+
- **core** — the `SecurityExpr` callback type (re-exported from the package
|
|
162
|
+
root), the second `security` overload, and the shared `statefulPrimitives`
|
|
163
|
+
entry annotated as covering both arities.
|
|
164
|
+
- **compiler** — records one `SecurityExpressionDescriptor { slotId, interval,
|
|
165
|
+
paramName }` per expression callsite in `manifest.securityExpressions`
|
|
166
|
+
(sorted by `slotId`, omitted for the data-only form), and validates each
|
|
167
|
+
callback against the allowed subset — its `bar` parameter and body locals,
|
|
168
|
+
the ambient `ta` / `inputs`, safe `Math.*` globals, and literals — rejecting
|
|
169
|
+
any captured outer binding with the new
|
|
170
|
+
`request-security-expr-captures-local` diagnostic.
|
|
171
|
+
- **runtime** — mounts one `SecurityExprRunner` per manifest entry: the
|
|
172
|
+
callback is captured lazily on the first main compute, driven once per HTF bar
|
|
173
|
+
close through a dedicated fold `StreamState` so `ta.*` accumulate on the HTF
|
|
174
|
+
clock, and one sampled value per HTF bar feeds a per-slot output buffer that
|
|
175
|
+
`request.security(opts, expr)` returns aligned no-lookahead to the main
|
|
176
|
+
timeline. Capability / interval / stream fallbacks return an all-NaN series
|
|
177
|
+
with a deduped diagnostic.
|
|
178
|
+
- **host-worker / host-quickjs** — boot the expression form unchanged; the
|
|
179
|
+
`__manifest` sidecar already carries `securityExpressions`.
|
|
180
|
+
- **pine-converter** — Pine's `request.security(sym, "D", ta.ema(close, 9))`
|
|
181
|
+
now lowers to the chartlang callback form
|
|
182
|
+
`request.security({ interval: "1d" }, (bar) => ta.ema(bar.close, 9))` (a bare
|
|
183
|
+
OHLCV third arg keeps lowering to the data form).
|
|
184
|
+
- **conformance** — new scenarios prove the weekly expression value differs
|
|
185
|
+
from a same-length main-timeframe EMA, plus the `multiTimeframe: false` NaN
|
|
186
|
+
fallback.
|
|
187
|
+
|
|
188
|
+
- 5a9c24d: Add `state.series(init)` — a writable, indexable user series. Store an
|
|
189
|
+
arbitrary value each bar (`s.value = expr`) and read its history N bars
|
|
190
|
+
back (`s[1]`). Number-coercible (`+s`, `s.current`) and usable as a `ta.*`
|
|
191
|
+
source. The Pine converter lowers a history-indexed `var` to it.
|
|
192
|
+
- 08c536c: Add the `ta.highestbars` / `ta.lowestbars` primitives plus the cross-package
|
|
193
|
+
wiring that makes them usable as drawing anchors and Pine-converter targets.
|
|
194
|
+
|
|
195
|
+
- **core / runtime:** `ta.highestbars(source, length, opts?)` and
|
|
196
|
+
`ta.lowestbars(source, length, opts?)` return the bar OFFSET (≤ 0) to the
|
|
197
|
+
highest / lowest `source` value over the trailing `length` bars (window
|
|
198
|
+
INCLUDES the current bar). `0` → current bar is the extreme; `-k` → the
|
|
199
|
+
extreme occurred `k` bars ago. Ties resolve to the most recent bar; NaN
|
|
200
|
+
inputs are skipped; warmup is `length − 1` bars; tick-mode replays the
|
|
201
|
+
in-progress head as the offset-0 candidate. Registered in
|
|
202
|
+
`STATEFUL_PRIMITIVES` (now 174 entries) and `TA_REGISTRY` (now 96 entries).
|
|
203
|
+
- **compiler:** a literal-length `ta.highestbars` / `ta.lowestbars` call
|
|
204
|
+
contributes `length − 1` toward `maxLookback`, so the runtime sizes the time
|
|
205
|
+
ring buffer deep enough for a `bar.point(<that offset>, …)` anchor to resolve.
|
|
206
|
+
A non-literal length contributes 0.
|
|
207
|
+
- **pine-converter:** `ta.highestbars` / `ta.lowestbars` now map to the real
|
|
208
|
+
chartlang primitives (previously lossy passthroughs to `ta.highest` /
|
|
209
|
+
`ta.lowest`). **Behavior change:** a DYNAMIC `bar_index + <non-literal>`
|
|
210
|
+
drawing-x anchor no longer raises the hard `requires-bar-interval` error —
|
|
211
|
+
the offset is resolved by `bar.point` at runtime sign-agnostically (a
|
|
212
|
+
negative runtime offset, e.g. what `ta.highestbars` returns, resolves to the
|
|
213
|
+
historical timestamp via the time buffer). Only the literal `bar_index + N`
|
|
214
|
+
future case still requires a bar interval.
|
|
215
|
+
- **conformance:** new `TA_HIGHEST_LOWEST_BARS_SCENARIO` export pins both
|
|
216
|
+
primitives end-to-end through the compiler + runtime over the bundled
|
|
217
|
+
`goldenBars.json` fixture, and is added to `ALL_SCENARIOS`.
|
|
218
|
+
|
|
219
|
+
### Patch Changes
|
|
220
|
+
|
|
221
|
+
- 850ae21: Expand the `request.security` / `request.lowerTf` JSDoc into narrative
|
|
222
|
+
descriptions with realistic examples (higher-timeframe `SecurityBar` reads
|
|
223
|
+
and lower-timeframe contained-bar arrays), and cross-link both generated
|
|
224
|
+
primitive pages to the multi-timeframe guide via their `seeAlso` entry in
|
|
225
|
+
`genPhase4Docs.ts`. The auto-generated `docs/primitives/request/*.md` pages
|
|
226
|
+
and the hover registry were regenerated from the new JSDoc — no runtime
|
|
227
|
+
behaviour change.
|
|
228
|
+
|
|
229
|
+
## 1.1.1
|
|
230
|
+
|
|
231
|
+
### Patch Changes
|
|
232
|
+
|
|
233
|
+
- 71ea0a5: Inline original TypeScript sources into emitted `.js.map` files (`inlineSources: true`). Published sourcemaps no longer reference missing `../src/*.ts` files, fixing "points to missing source files" warnings in downstream bundlers (e.g. Vite).
|
|
234
|
+
|
|
3
235
|
## 1.1.0
|
|
4
236
|
|
|
5
237
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -19,7 +19,8 @@ pnpm add @invinite-org/chartlang-core
|
|
|
19
19
|
- Stateful slots: `state.float`, `int`, `bool`, `string`, plus
|
|
20
20
|
`state.tick.*` for tick-persistent `varip` semantics.
|
|
21
21
|
- Views: `barstate`, `syminfo`, `timeframe`.
|
|
22
|
-
- Secondary stream: `request.security({ interval })`
|
|
22
|
+
- Secondary stream: `request.security({ interval })` (data) and
|
|
23
|
+
`request.security({ interval }, (bar) => …)` (HTF expression) typed surface.
|
|
23
24
|
- Emissions: `plot`, `hline`, `alert`, and the 61-kind `draw.*` namespace.
|
|
24
25
|
- Registry: `STATEFUL_PRIMITIVES` for compiler slot-id injection.
|
|
25
26
|
- Indicator composition (Phase 7): `CompiledScriptObject.output(title)` /
|
package/dist/alert/alert.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type AlertOpts = Readonly<{
|
|
|
17
17
|
}>;
|
|
18
18
|
/**
|
|
19
19
|
* Compile-time callable hole for `alert(message, opts?)`. The compiler
|
|
20
|
-
* rewrites every callsite
|
|
20
|
+
* rewrites every callsite to dispatch to the runtime; calling this
|
|
21
21
|
* outside the runtime throws the sentinel.
|
|
22
22
|
*
|
|
23
23
|
* @since 0.1
|
package/dist/alert/alert.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// See the LICENSE file in the repo root for full license text.
|
|
3
3
|
/**
|
|
4
4
|
* Compile-time callable hole for `alert(message, opts?)`. The compiler
|
|
5
|
-
* rewrites every callsite
|
|
5
|
+
* rewrites every callsite to dispatch to the runtime; calling this
|
|
6
6
|
* outside the runtime throws the sentinel.
|
|
7
7
|
*
|
|
8
8
|
* @since 0.1
|
package/dist/alert/alert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../src/alert/alert.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAqB/D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,KAAiB;IACrD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AAC7D,CAAC"}
|
|
1
|
+
{"version":3,"file":"alert.js","sourceRoot":"","sources":["../../src/alert/alert.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAqB/D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,KAAiB;IACrD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { AlertSeverity, JsonValue } from \"../types.js\";\n\n/**\n * Styling and metadata options accepted by `alert(...)`. `severity` defaults\n * to `\"info\"`; `meta` is round-tripped to the host as a JSON-serialisable\n * payload.\n *\n * @since 0.1\n * @example\n * const opts: AlertOpts = {\n * severity: \"warning\",\n * meta: { reason: \"crossover\", strength: 0.42 },\n * };\n */\nexport type AlertOpts = Readonly<{\n severity?: AlertSeverity;\n meta?: Readonly<Record<string, JsonValue>>;\n}>;\n\n/**\n * Compile-time callable hole for `alert(message, opts?)`. The compiler\n * rewrites every callsite to dispatch to the runtime; calling this\n * outside the runtime throws the sentinel.\n *\n * @since 0.1\n * @stable\n * @example\n * // Inside a compiled `compute`:\n * // alert(\"EMA crossed\", { severity: \"info\" });\n * import { alert } from \"@invinite-org/chartlang-core\";\n * try { alert(\"noop\"); } catch {}\n */\nexport function alert(_message: string, _opts?: AlertOpts): void {\n throw new Error(\"alert called outside compiled runtime\");\n}\n"]}
|
package/dist/alert/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/alert/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/alert/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,cAAc,YAAY,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nexport * from \"./alert.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorHelpers.js","sourceRoot":"","sources":["../../src/color/colorHelpers.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+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YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;AACjF,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { Color } from \"../types.js\";\nimport { parseColor } from \"./parseColor.js\";\n\n/**\n * Gradient color stop for `color.fromGradient`.\n *\n * @since 0.5\n * @stable\n * @example\n * const stop: GradientStop = { at: 0, color: \"#0000ff\" };\n * void stop;\n */\nexport type GradientStop = Readonly<{ at: number; color: Color }>;\n\nconst TRANSPARENT_BLACK = \"rgba(0, 0, 0, 0)\";\n\nfunction clampUnit(value: number): number {\n if (Number.isNaN(value)) return 0;\n return Math.min(1, Math.max(0, value));\n}\n\nfunction clampByte(value: number): number {\n if (Number.isNaN(value)) return 0;\n return Math.min(255, Math.max(0, Math.floor(value)));\n}\n\nfunction clampHue(value: number): number {\n if (Number.isNaN(value)) return 0;\n return Math.min(359.999, Math.max(0, value));\n}\n\nfunction clampPercent(value: number): number {\n if (Number.isNaN(value)) return 0;\n return Math.min(100, Math.max(0, value));\n}\n\nfunction formatNumber(value: number): string {\n const rounded = Math.round(value * 1000) / 1000;\n return String(rounded);\n}\n\nfunction emitRgb(r: number, g: number, b: number, alpha: number): Color {\n if (alpha >= 1) return `rgb(${r}, ${g}, ${b})`;\n return `rgba(${r}, ${g}, ${b}, ${formatNumber(alpha)})`;\n}\n\nfunction emitRgba(r: number, g: number, b: number, alpha: number): Color {\n return `rgba(${r}, ${g}, ${b}, ${formatNumber(alpha)})`;\n}\n\n/**\n * Dynamic color from a normalised position. `t` is clamped to `[0, 1]`;\n * out-of-range maps to the boundary stop. Stops must be pre-sorted by `at`\n * ascending. Empty stops return transparent black.\n *\n * Pine's `color.from_gradient`.\n *\n * @since 0.5\n * @stable\n * @example\n * // const blue = \"#0000ff\";\n * // const red = \"#ff0000\";\n * // color.fromGradient(0.5, [{ at: 0, color: blue }, { at: 1, color: red }]);\n */\nexport function fromGradient(t: number, stops: ReadonlyArray<GradientStop>): Color {\n const first = stops[0];\n if (first === undefined) return TRANSPARENT_BLACK;\n if (stops.length === 1 || Number.isNaN(t)) return first.color;\n\n const position = clampUnit(t);\n if (position <= first.at) return first.color;\n const last = stops[stops.length - 1];\n if (position >= last.at) return last.color;\n\n let previous = first;\n let next = last;\n for (let i = 1; i < stops.length; i += 1) {\n const candidate = stops[i];\n if (position <= candidate.at) {\n next = candidate;\n break;\n }\n previous = candidate;\n }\n\n const left = parseColor(previous.color);\n const right = parseColor(next.color);\n if (left === null || right === null) return previous.color;\n const ratio = (position - previous.at) / (next.at - previous.at);\n const alpha = left.a + (right.a - left.a) * ratio;\n return emitRgb(\n clampByte(left.r + (right.r - left.r) * ratio),\n clampByte(left.g + (right.g - left.g) * ratio),\n clampByte(left.b + (right.b - left.b) * ratio),\n clampUnit(alpha),\n );\n}\n\n/**\n * Override an existing color's alpha channel. `alpha` is clamped to\n * `[0, 1]`. NaN returns the input color unchanged. Pine's `color.new(c,\n * transp)` analogue using direct alpha.\n *\n * @since 0.5\n * @stable\n * @example\n * const c = withAlpha(\"#ff0000\", 0.5);\n * void c;\n */\nexport function withAlpha(c: Color, alpha: number): Color {\n if (Number.isNaN(alpha)) return c;\n const parsed = parseColor(c);\n if (parsed === null) return c;\n return emitRgba(parsed.r, parsed.g, parsed.b, clampUnit(alpha));\n}\n\n/**\n * Construct a color from RGB(A) components. Each component is clamped to\n * `[0, 255]`; alpha defaults to `1`. NaN components clamp to `0`.\n *\n * @since 0.5\n * @stable\n * @example\n * const red = rgb(255, 0, 0);\n * void red;\n */\nexport function rgb(r: number, g: number, b: number, alpha?: number): Color {\n const red = clampByte(r);\n const green = clampByte(g);\n const blue = clampByte(b);\n if (alpha === undefined) return `rgb(${red}, ${green}, ${blue})`;\n return emitRgba(red, green, blue, clampUnit(alpha));\n}\n\n/**\n * Construct a color from HSL(A) components. `h` is clamped to `[0, 360)`;\n * `s` and `l` are clamped to `[0, 100]`. Alpha defaults to `1`. NaN\n * components clamp to `0`.\n *\n * @since 0.5\n * @stable\n * @example\n * const red = hsl(0, 100, 50);\n * void red;\n */\nexport function hsl(h: number, s: number, l: number, alpha?: number): Color {\n const hue = formatNumber(clampHue(h));\n const sat = formatNumber(clampPercent(s));\n const light = formatNumber(clampPercent(l));\n if (alpha === undefined) return `hsl(${hue}, ${sat}%, ${light}%)`;\n return `hsla(${hue}, ${sat}%, ${light}%, ${formatNumber(clampUnit(alpha))})`;\n}\n"]}
|
package/dist/color/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/color/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGtE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/B,GAAG,aAAa;IAChB,YAAY;IACZ,SAAS;IACT,GAAG;IACH,GAAG;CACN,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/color/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGtE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/B,GAAG,aAAa;IAChB,YAAY;IACZ,SAAS;IACT,GAAG;IACH,GAAG;CACN,CAAC,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport { fromGradient, hsl, rgb, withAlpha } from \"./colorHelpers.js\";\nimport { COLOR_PALETTE } from \"./parseColor.js\";\n\nexport { fromGradient, hsl, rgb, withAlpha } from \"./colorHelpers.js\";\nexport type { GradientStop } from \"./colorHelpers.js\";\n\n/**\n * Pine-style color namespace. Includes the named palette plus dynamic\n * helpers for compute-time colors.\n *\n * @since 0.5\n * @stable\n * @example\n * const c = color.withAlpha(color.red, 0.5);\n * void c;\n */\nexport const color = Object.freeze({\n ...COLOR_PALETTE,\n fromGradient,\n withAlpha,\n rgb,\n hsl,\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseColor.js","sourceRoot":"","sources":["../../src/color/parseColor.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;CACpB,CAAC,CAAC;AAIH,MAAM,SAAS,GAAG,mBAAmB,CAAC;AACtC,MAAM,QAAQ,GAAG,mBAAmB,CAAC;A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C,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IAClF,CAAC;IAED,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,QAAQ,EAAE,CAAC;QACX,MAAM,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QACtE,OAAO,EAAE,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { Color } from \"../types.js\";\n\n/**\n * Pine-style named palette values accepted by the color parser and exposed\n * through the `color` namespace.\n *\n * @internal\n * @since 0.5\n * @example\n * const red = COLOR_PALETTE.red;\n * void red;\n */\nexport const COLOR_PALETTE = Object.freeze({\n aqua: \"#00ffff\",\n black: \"#000000\",\n blue: \"#0000ff\",\n fuchsia: \"#ff00ff\",\n gray: \"#808080\",\n green: \"#008000\",\n lime: \"#00ff00\",\n maroon: \"#800000\",\n navy: \"#000080\",\n olive: \"#808000\",\n orange: \"#ffa500\",\n purple: \"#800080\",\n red: \"#ff0000\",\n silver: \"#c0c0c0\",\n teal: \"#008080\",\n white: \"#ffffff\",\n yellow: \"#ffff00\",\n});\n\ntype PaletteName = keyof typeof COLOR_PALETTE;\n\nconst HEX_SHORT = /^#([0-9a-f]{3})$/i;\nconst HEX_LONG = /^#([0-9a-f]{6})$/i;\nconst RGB = /^rgba?\\(\\s*([^,\\s]+)\\s*,\\s*([^,\\s]+)\\s*,\\s*([^,\\s]+)(?:\\s*,\\s*([^,\\s]+))?\\s*\\)$/i;\nconst HSL = /^hsla?\\(\\s*([^,\\s]+)\\s*,\\s*([^,\\s%]+)%\\s*,\\s*([^,\\s%]+)%(?:\\s*,\\s*([^,\\s]+))?\\s*\\)$/i;\n\nfunction isPaletteName(value: string): value is PaletteName {\n return Object.prototype.hasOwnProperty.call(COLOR_PALETTE, value);\n}\n\nfunction clampByte(value: number): number {\n return Math.min(255, Math.max(0, Math.floor(value)));\n}\n\nfunction clampRoundedByte(value: number): number {\n return Math.min(255, Math.max(0, Math.round(value)));\n}\n\nfunction clampUnit(value: number): number {\n return Math.min(1, Math.max(0, value));\n}\n\nfunction parseNumber(value: string): number | null {\n const parsed = Number(value);\n if (Number.isNaN(parsed)) return null;\n return parsed;\n}\n\nfunction hslToRgb(h: number, s: number, l: number): Readonly<{ r: number; g: number; b: number }> {\n const hue = Math.min(359.999, Math.max(0, h)) / 360;\n const sat = Math.min(100, Math.max(0, s)) / 100;\n const light = Math.min(100, Math.max(0, l)) / 100;\n\n if (sat === 0) {\n const gray = clampRoundedByte(light * 255);\n return { r: gray, g: gray, b: gray };\n }\n\n const q = light < 0.5 ? light * (1 + sat) : light + sat - light * sat;\n const p = 2 * light - q;\n const channel = (t: number): number => {\n let adjusted = t;\n if (adjusted < 0) adjusted += 1;\n if (adjusted > 1) adjusted -= 1;\n if (adjusted < 1 / 6) return p + (q - p) * 6 * adjusted;\n if (adjusted < 1 / 2) return q;\n if (adjusted < 2 / 3) return p + (q - p) * (2 / 3 - adjusted) * 6;\n return p;\n };\n\n return {\n r: clampRoundedByte(channel(hue + 1 / 3) * 255),\n g: clampRoundedByte(channel(hue) * 255),\n b: clampRoundedByte(channel(hue - 1 / 3) * 255),\n };\n}\n\n/**\n * Parse the CSS color forms chartlang emits: `#rgb`, `#rrggbb`,\n * `rgb(...)`, `rgba(...)`, `hsl(...)`, `hsla(...)`, and the named palette.\n * Returns `null` for unparseable input.\n *\n * @internal\n * @since 0.5\n * @example\n * const parsed = parseColor(\"#ff0000\");\n * void parsed;\n */\nexport function parseColor(\n c: Color,\n): Readonly<{ r: number; g: number; b: number; a: number }> | null {\n const value = c.trim().toLowerCase();\n if (isPaletteName(value)) return parseColor(COLOR_PALETTE[value]);\n\n const shortHex = HEX_SHORT.exec(value);\n if (shortHex) {\n const hex = shortHex[1];\n return {\n r: Number.parseInt(`${hex[0]}${hex[0]}`, 16),\n g: Number.parseInt(`${hex[1]}${hex[1]}`, 16),\n b: Number.parseInt(`${hex[2]}${hex[2]}`, 16),\n a: 1,\n };\n }\n\n const longHex = HEX_LONG.exec(value);\n if (longHex) {\n const hex = longHex[1];\n return {\n r: Number.parseInt(hex.slice(0, 2), 16),\n g: Number.parseInt(hex.slice(2, 4), 16),\n b: Number.parseInt(hex.slice(4, 6), 16),\n a: 1,\n };\n }\n\n const rgbMatch = RGB.exec(value);\n if (rgbMatch) {\n const r = parseNumber(rgbMatch[1]);\n const g = parseNumber(rgbMatch[2]);\n const b = parseNumber(rgbMatch[3]);\n const a = rgbMatch[4] === undefined ? 1 : parseNumber(rgbMatch[4]);\n if (r === null || g === null || b === null || a === null) return null;\n return { r: clampByte(r), g: clampByte(g), b: clampByte(b), a: clampUnit(a) };\n }\n\n const hslMatch = HSL.exec(value);\n if (hslMatch) {\n const h = parseNumber(hslMatch[1]);\n const s = parseNumber(hslMatch[2]);\n const l = parseNumber(hslMatch[3]);\n const a = hslMatch[4] === undefined ? 1 : parseNumber(hslMatch[4]);\n if (h === null || s === null || l === null || a === null) return null;\n return { ...hslToRgb(h, s, l), a: clampUnit(a) };\n }\n\n return null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineAlert.js","sourceRoot":"","sources":["../../src/define/defineAlert.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AA0BtE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,WAAW,CAAC,IAAqB;IAC7C,MAAM,YAAY,GAA4B,MAAM,CAAC,MAAM,CAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpF,MAAM,kBAAkB,GAA0B,MAAM,CAAC,MAAM,CAAW,EAAE,CAAC,CAAC;IAC9E,MAAM,gBAAgB,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG;QACT,UAAU,EAAE,CAAU;QACtB,IAAI,EAAE,OAAgB;QACtB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;QACzB,YAAY;QACZ,kBAAkB;QAClB,oBAAoB,EAAE,KAAK;QAC3B,gBAAgB;QAChB,WAAW,EAAE,CAAC;KACjB,CAAC;IACF,MAAM,QAAQ,GAAG;QACb,GAAG,IAAI;QACP,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5E,GAAG,CAAC,IAAI,CAAC,iBAAiB,KAAK,SAAS;YACpC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;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E,GAAG,CAAC,IAAI,CAAC,iBAAiB,KAAK,SAAS;YACpC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACpD,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;KACzE,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAChB,0BAA0B,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,OAAO;KACxB,CAAC,CACL,CAAC;AACN,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { CompiledScriptObject, ComputeFn, InputSchema } from \"../types.js\";\nimport { attachDepAccessorSentinels } from \"./depAccessorSentinel.js\";\nimport type { ScriptOverrides } from \"./overrides.js\";\n\ntype AlertOverrides = Omit<ScriptOverrides, \"scale\" | \"format\" | \"precision\">;\n\n/**\n * Author-supplied options the script passes to `defineAlert(...)`. Same shape\n * as `DefineIndicatorOpts` minus the indicator-only `overlay` flag — alert\n * scripts have no plot output.\n *\n * @since 0.1\n * @example\n * const opts: DefineAlertOpts = {\n * name: \"RSI overbought\",\n * apiVersion: 1,\n * compute: () => {},\n * };\n */\nexport type DefineAlertOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n compute: ComputeFn;\n}> &\n AlertOverrides;\n\n/**\n * Construct a Phase-1 alert script object. Returns a frozen\n * `CompiledScriptObject` whose `manifest.kind` is `\"alert\"` and whose\n * declared `capabilities` is `[\"alerts\"]`. Same compile-time override\n * semantics as `defineIndicator`.\n *\n * @since 0.1\n * @example\n * ```ts\n * import { defineAlert } from \"@invinite-org/chartlang-core\";\n *\n * export default defineAlert({\n * name: \"RSI > 70\",\n * apiVersion: 1,\n * compute: ({ alert }) => { alert(\"overbought\"); },\n * });\n * ```\n */\nexport function defineAlert(opts: DefineAlertOpts): CompiledScriptObject {\n const capabilities: ReadonlyArray<\"alerts\"> = Object.freeze<[\"alerts\"]>([\"alerts\"]);\n const requestedIntervals: ReadonlyArray<string> = Object.freeze<string[]>([]);\n const seriesCapacities: Readonly<Record<string, number>> = Object.freeze({});\n const base = {\n apiVersion: 1 as const,\n kind: \"alert\" as const,\n name: opts.name,\n inputs: opts.inputs ?? {},\n capabilities,\n requestedIntervals,\n userPickableInterval: false,\n seriesCapacities,\n maxLookback: 0,\n };\n const manifest = {\n ...base,\n ...(opts.maxBarsBack === undefined ? {} : { maxBarsBack: opts.maxBarsBack }),\n ...(opts.requiresIntervals === undefined\n ? {}\n : { requiresIntervals: opts.requiresIntervals }),\n ...(opts.shortName === undefined ? {} : { shortName: opts.shortName }),\n };\n return Object.freeze(\n attachDepAccessorSentinels({\n manifest: Object.freeze(manifest),\n compute: opts.compute,\n }),\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineAlertCondition.js","sourceRoot":"","sources":["../../src/define/defineAlertCondition.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAU/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AA+BtE,SAAS,eAAe,CACpB,EAAU,EACV,UAAoC;IAEpC,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,EAAE;QACF,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,cAAc,EAAE,UAAU,CAAC,cAAc;KAC5C,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAA8B;IAC/D,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CACjC,MAAM,CAAC,OAAO,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAA8B;IAC/D,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CACjC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAC7F,CAAC;IACF,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAmC,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC1F,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAW,EAAE,CAAC,CAAC;IACvD,MAAM,gBAAgB,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7E,MAAM,QAAQ,GAAmB,MAAM,CAAC,MAAM,CAAC;QAC3C,UAAU,EAAE,CAAC;QACb,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;QACzB,YAAY;QACZ,kBAAkB;QAClB,oBAAoB,EAAE,KAAK;QAC3B,gBAAgB;QAChB,WAAW,EAAE,CAAC;QACd,eAAe;KAClB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type {\n AlertConditionDescriptor,\n AlertConditionDefinition,\n CompiledScriptObject,\n ComputeFn,\n InputSchema,\n ScriptManifest,\n} from \"../types.js\";\nimport { attachDepAccessorSentinels } from \"./depAccessorSentinel.js\";\n\n/**\n * Author-supplied options for `defineAlertCondition(...)`. Mirrors\n * `DefineAlertOpts` plus the `conditions` map.\n *\n * @since 0.5\n * @stable\n * @example\n * const opts: DefineAlertConditionOpts = {\n * name: \"EMA cross\",\n * apiVersion: 1,\n * conditions: {\n * up: {\n * title: \"Up\",\n * description: \"Close > EMA\",\n * defaultMessage: \"{{ticker}} up\",\n * },\n * },\n * compute: () => {},\n * };\n * void opts;\n */\nexport type DefineAlertConditionOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n conditions: Readonly<Record<string, AlertConditionDescriptor>>;\n compute: ComputeFn;\n}>;\n\nfunction freezeCondition(\n id: string,\n descriptor: AlertConditionDescriptor,\n): AlertConditionDefinition {\n return Object.freeze({\n id,\n title: descriptor.title,\n description: descriptor.description,\n defaultMessage: descriptor.defaultMessage,\n });\n}\n\n/**\n * Construct a Phase-5 alert-condition script. Returns a frozen\n * `CompiledScriptObject` whose `manifest.kind` is `\"alertCondition\"`.\n *\n * @since 0.5\n * @stable\n * @example\n * ```ts\n * import { defineAlertCondition, input, ta } from \"@invinite-org/chartlang-core\";\n *\n * export default defineAlertCondition({\n * name: \"EMA cross\",\n * apiVersion: 1,\n * inputs: { length: input.int(20) },\n * conditions: {\n * up: {\n * title: \"Up\",\n * description: \"Close > EMA\",\n * defaultMessage: \"{{ticker}} up\",\n * },\n * down: {\n * title: \"Down\",\n * description: \"Close < EMA\",\n * defaultMessage: \"{{ticker}} down\",\n * },\n * },\n * compute({ bar, ta, inputs, signal }) {\n * const ema = ta.ema(bar.close, inputs.length as number);\n * signal?.(\"up\", ta.crossover(bar.close, ema).current);\n * signal?.(\"down\", ta.crossunder(bar.close, ema).current);\n * },\n * });\n * ```\n */\nexport function defineAlertCondition(opts: DefineAlertConditionOpts): CompiledScriptObject {\n const alertConditions = Object.freeze(\n Object.entries(opts.conditions).map(([id, descriptor]) => freezeCondition(id, descriptor)),\n );\n const capabilities = Object.freeze<ReadonlyArray<\"alertConditions\">>([\"alertConditions\"]);\n const requestedIntervals = Object.freeze<string[]>([]);\n const seriesCapacities: Readonly<Record<string, number>> = Object.freeze({});\n const manifest: ScriptManifest = Object.freeze({\n apiVersion: 1,\n kind: \"alertCondition\",\n name: opts.name,\n inputs: opts.inputs ?? {},\n capabilities,\n requestedIntervals,\n userPickableInterval: false,\n seriesCapacities,\n maxLookback: 0,\n alertConditions,\n });\n return Object.freeze(attachDepAccessorSentinels({ manifest, compute: opts.compute }));\n}\n"]}
|
|
@@ -30,13 +30,13 @@ export type DefineDrawingOpts = Readonly<{
|
|
|
30
30
|
* and drawing scripts identically at the per-bar level — the
|
|
31
31
|
* discriminator is a host-side hint the editor uses to distinguish
|
|
32
32
|
* drawing scripts from indicator scripts in the script-picker UI
|
|
33
|
-
|
|
33
|
+
*.
|
|
34
34
|
*
|
|
35
35
|
* `compute({ bar, draw, inputs, ... })` runs per bar; emit drawings via
|
|
36
36
|
* the `draw.*` namespace. Each `draw.<kind>(...)` returns a
|
|
37
37
|
* {@link DrawingHandle} the script can `update(...)` or `remove()`
|
|
38
38
|
* across bars. Phase 4 layers an interactive-anchor-picker UI on top of
|
|
39
|
-
* this constructor
|
|
39
|
+
* this constructor; Phase 3 ships the constructor
|
|
40
40
|
* with fixed anchors so the runtime path can be exercised.
|
|
41
41
|
*
|
|
42
42
|
* @since 0.3
|
|
@@ -8,13 +8,13 @@ import { attachDepAccessorSentinels } from "./depAccessorSentinel.js";
|
|
|
8
8
|
* and drawing scripts identically at the per-bar level — the
|
|
9
9
|
* discriminator is a host-side hint the editor uses to distinguish
|
|
10
10
|
* drawing scripts from indicator scripts in the script-picker UI
|
|
11
|
-
|
|
11
|
+
*.
|
|
12
12
|
*
|
|
13
13
|
* `compute({ bar, draw, inputs, ... })` runs per bar; emit drawings via
|
|
14
14
|
* the `draw.*` namespace. Each `draw.<kind>(...)` returns a
|
|
15
15
|
* {@link DrawingHandle} the script can `update(...)` or `remove()`
|
|
16
16
|
* across bars. Phase 4 layers an interactive-anchor-picker UI on top of
|
|
17
|
-
* this constructor
|
|
17
|
+
* this constructor; Phase 3 ships the constructor
|
|
18
18
|
* with fixed anchors so the runtime path can be exercised.
|
|
19
19
|
*
|
|
20
20
|
* @since 0.3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineDrawing.js","sourceRoot":"","sources":["../../src/define/defineDrawing.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AA6BtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,aAAa,CAAC,IAAuB;IACjD,MAAM,YAAY,GAA8B,MAAM,CAAC,MAAM,CAAe,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1F,MAAM,kBAAkB,GAA0B,MAAM,CAAC,MAAM,CAAW,EAAE,CAAC,CAAC;IAC9E,MAAM,gBAAgB,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG;QACT,UAAU,EAAE,CAAU;QACtB,IAAI,EAAE,SAAkB;QACxB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;QACzB,YAAY;QACZ,kBAAkB;QAClB,oBAAoB,EAAE,KAAK;QAC3B,gBAAgB;QAChB,WAAW,EAAE,CAAC;KACjB,CAAC;IACF,MAAM,QAAQ,GAAG;QACb,GAAG,IAAI;QACP,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5E,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7D,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAA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AAoB,EAAE,KAAK;QAC3B,gBAAgB;QAChB,WAAW,EAAE,CAAC;KACjB,CAAC;IACF,MAAM,QAAQ,GAAG;QACb,GAAG,IAAI;QACP,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5E,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7D,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;QACtE,GAAG,CAAC,IAAI,CAAC,iBAAiB,KAAK,SAAS;YACpC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACpD,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;KACzE,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAChB,0BAA0B,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,OAAO;KACxB,CAAC,CACL,CAAC;AACN,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { CompiledScriptObject, ComputeFn, DrawingCounts, InputSchema } from \"../types.js\";\nimport { attachDepAccessorSentinels } from \"./depAccessorSentinel.js\";\nimport type { ScriptOverrides } from \"./overrides.js\";\n\ntype DrawingOverrides = Omit<ScriptOverrides, \"maxBarsBack\" | \"scale\">;\n\n/**\n * Author-supplied options the script passes to `defineDrawing(...)`. Same\n * shape as `DefineAlertOpts` (no indicator-only `overlay` flag) plus the\n * Phase-3 `maxDrawings` per-bucket cap from `DefineIndicatorOpts`.\n *\n * @since 0.3\n * @stable\n * @example\n * const opts: DefineDrawingOpts = {\n * name: \"Interactive Fib Retracement\",\n * apiVersion: 1,\n * compute: () => {},\n * };\n */\nexport type DefineDrawingOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n compute: ComputeFn;\n /** Per-bucket cap on `draw.*` emissions per bar. @since 0.3 */\n maxDrawings?: DrawingCounts;\n}> &\n DrawingOverrides;\n\n/**\n * Construct a Phase-3 drawing script object. Mirrors `defineIndicator`\n * structurally; only `manifest.kind` (`\"drawing\"`) and the declared\n * `capabilities` (`[\"drawings\"]`) differ. The runtime treats indicator\n * and drawing scripts identically at the per-bar level — the\n * discriminator is a host-side hint the editor uses to distinguish\n * drawing scripts from indicator scripts in the script-picker UI\n *.\n *\n * `compute({ bar, draw, inputs, ... })` runs per bar; emit drawings via\n * the `draw.*` namespace. Each `draw.<kind>(...)` returns a\n * {@link DrawingHandle} the script can `update(...)` or `remove()`\n * across bars. Phase 4 layers an interactive-anchor-picker UI on top of\n * this constructor; Phase 3 ships the constructor\n * with fixed anchors so the runtime path can be exercised.\n *\n * @since 0.3\n * @stable\n * @example\n * ```ts\n * import { defineDrawing } from \"@invinite-org/chartlang-core\";\n *\n * export default defineDrawing({\n * name: \"Interactive Fib Retracement\",\n * apiVersion: 1,\n * compute: ({ draw }) => {\n * draw.fibRetracement(\n * { time: 1_700_000_000_000, price: 100 },\n * { time: 1_700_086_400_000, price: 110 },\n * );\n * },\n * });\n * ```\n */\nexport function defineDrawing(opts: DefineDrawingOpts): CompiledScriptObject {\n const capabilities: ReadonlyArray<\"drawings\"> = Object.freeze<[\"drawings\"]>([\"drawings\"]);\n const requestedIntervals: ReadonlyArray<string> = Object.freeze<string[]>([]);\n const seriesCapacities: Readonly<Record<string, number>> = Object.freeze({});\n const base = {\n apiVersion: 1 as const,\n kind: \"drawing\" as const,\n name: opts.name,\n inputs: opts.inputs ?? {},\n capabilities,\n requestedIntervals,\n userPickableInterval: false,\n seriesCapacities,\n maxLookback: 0,\n };\n const manifest = {\n ...base,\n ...(opts.maxDrawings === undefined ? {} : { maxDrawings: opts.maxDrawings }),\n ...(opts.format === undefined ? {} : { format: opts.format }),\n ...(opts.precision === undefined ? {} : { precision: opts.precision }),\n ...(opts.requiresIntervals === undefined\n ? {}\n : { requiresIntervals: opts.requiresIntervals }),\n ...(opts.shortName === undefined ? {} : { shortName: opts.shortName }),\n };\n return Object.freeze(\n attachDepAccessorSentinels({\n manifest: Object.freeze(manifest),\n compute: opts.compute,\n }),\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineIndicator.js","sourceRoot":"","sources":["../../src/define/defineIndicator.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAyCtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,eAAe,CAAC,IAAyB;IACrD,MAAM,YAAY,GAAgC,MAAM,CAAC,MAAM,CAAiB,CAAC,YAAY,CAAC,CAAC,CAAC;IAChG,MAAM,kBAAkB,GAA0B,MAAM,CAAC,MAAM,CAAW,EAAE,CAAC,CAAC;IAC9E,MAAM,gBAAgB,GAAqC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG;QACT,UAAU,EAAE,CAAU;QACtB,IAAI,EAAE,WAAoB;QAC1B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;QACzB,YAAY;QACZ,kBAAkB;QAClB,oBAAoB,EAAE,KAAK;QAC3B,gBAAgB;QAChB,WAAW,EAAE,CAAC;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;AACN,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { CompiledScriptObject, ComputeFn, DrawingCounts, InputSchema } from \"../types.js\";\nimport { attachDepAccessorSentinels } from \"./depAccessorSentinel.js\";\nimport type { OutputDeclaration } from \"./dependency.js\";\nimport type { ScriptOverrides } from \"./overrides.js\";\n\n/**\n * Author-supplied options the script passes to `defineIndicator(...)`. The\n * compiler reads this object's static shape to build the script's manifest;\n * any field can be overridden at compile time via the AST transform.\n *\n * `maxDrawings` (Phase 3 / §10 / §4.1) caps the per-bucket `draw.*`\n * emission rate per bar. Omit to default to the adapter's cap.\n *\n * @since 0.1\n * @example\n * const opts: DefineIndicatorOpts = {\n * name: \"demo\",\n * apiVersion: 1,\n * compute: () => {},\n * };\n */\nexport type DefineIndicatorOpts = Readonly<{\n name: string;\n apiVersion: 1;\n overlay?: boolean;\n inputs?: InputSchema;\n compute: ComputeFn;\n /** Per-bucket cap on `draw.*` emissions per bar. @since 0.3 */\n maxDrawings?: DrawingCounts;\n /**\n * Titled outputs this producer exposes for `<binding>.output(...)`\n * consumption. Injected by the compiler from the producer's\n * `plot(value, { title })` calls so the runtime object is\n * self-describing — hosts read `manifest.outputs` to allocate the\n * dep-output ring buffer. Hand-authored scripts omit it; absent\n * `outputs` keeps the emitted manifest byte-identical to a script\n * with no titled plots. @since 0.7\n */\n outputs?: ReadonlyArray<OutputDeclaration>;\n}> &\n ScriptOverrides;\n\n/**\n * Construct a Phase-1 indicator script object. Returns a frozen\n * `CompiledScriptObject` with a default manifest the compiler later overrides\n * (extracts `capabilities` from primitive usage, `maxLookback` from\n * `series[N]` reads). The defaults let the constructor work in unit tests\n * before the compiler runs.\n *\n * @since 0.1\n * @example\n * ```ts\n * import { defineIndicator } from \"@invinite-org/chartlang-core\";\n *\n * export default defineIndicator({\n * name: \"EMA(20)\",\n * apiVersion: 1,\n * compute: ({ bar, plot }) => { plot(bar.close); },\n * });\n * ```\n */\nexport function defineIndicator(opts: DefineIndicatorOpts): CompiledScriptObject {\n const capabilities: ReadonlyArray<\"indicators\"> = Object.freeze<[\"indicators\"]>([\"indicators\"]);\n const requestedIntervals: ReadonlyArray<string> = Object.freeze<string[]>([]);\n const seriesCapacities: Readonly<Record<string, number>> = Object.freeze({});\n const base = {\n apiVersion: 1 as const,\n kind: \"indicator\" as const,\n name: opts.name,\n inputs: opts.inputs ?? {},\n capabilities,\n requestedIntervals,\n userPickableInterval: false,\n seriesCapacities,\n maxLookback: 0,\n };\n const manifest = {\n ...base,\n ...(opts.overlay === undefined ? {} : { overlay: opts.overlay }),\n ...(opts.maxDrawings === undefined ? {} : { maxDrawings: opts.maxDrawings }),\n ...(opts.maxBarsBack === undefined ? {} : { maxBarsBack: opts.maxBarsBack }),\n ...(opts.format === undefined ? {} : { format: opts.format }),\n ...(opts.precision === undefined ? {} : { precision: opts.precision }),\n ...(opts.scale === undefined ? {} : { scale: opts.scale }),\n ...(opts.requiresIntervals === undefined\n ? {}\n : { requiresIntervals: opts.requiresIntervals }),\n ...(opts.shortName === undefined ? {} : { shortName: opts.shortName }),\n ...(opts.outputs === undefined ? {} : { outputs: opts.outputs }),\n };\n return Object.freeze(\n attachDepAccessorSentinels({\n manifest: Object.freeze(manifest),\n compute: opts.compute,\n }),\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depAccessorSentinel.js","sourceRoot":"","sources":["../../src/define/depAccessorSentinel.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAS,EAAE;IACvD,MAAM,IAAI,KAAK,CACX,GAAG,IAAI,uGAAuG,CACjH,CAAC;AACN,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACtC,IAAgE,EAC5C,EAAE,CAAC,CAAC;IACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,MAAM,EAAE,CAAC,IAAY,EAAkB,EAAE,CAAC,mBAAmB,CAAC,WAAW,IAAI,IAAI,CAAC;IAClF,UAAU,EAAE,GAAyB,EAAE,CAAC,mBAAmB,CAAC,YAAY,CAAC;CAC5E,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"depAccessorSentinel.js","sourceRoot":"","sources":["../../src/define/depAccessorSentinel.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAS,EAAE;IACvD,MAAM,IAAI,KAAK,CACX,GAAG,IAAI,uGAAuG,CACjH,CAAC;AACN,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACtC,IAAgE,EAC5C,EAAE,CAAC,CAAC;IACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,MAAM,EAAE,CAAC,IAAY,EAAkB,EAAE,CAAC,mBAAmB,CAAC,WAAW,IAAI,IAAI,CAAC;IAClF,UAAU,EAAE,GAAyB,EAAE,CAAC,mBAAmB,CAAC,YAAY,CAAC;CAC5E,CAAC,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { CompiledScriptObject, ComputeFn, ScriptManifest, Series } from \"../types.js\";\n\n/**\n * Sentinel thrown when `output` / `withInputs` are called outside the\n * compiler-rewritten bundle path. The Phase-7 compiler statically\n * replaces every consumer-side `.output(\"title\")` call site with a\n * synthesised `__chartlang_depOutput(...)` runtime call, and every\n * `.withInputs({...})` chain with a folded dep manifest, so these\n * bodies are unreachable when the bundle is loaded normally. Hand-\n * running an un-compiled script in a unit test hits the sentinel,\n * which is the desired failure.\n *\n * @since 0.7\n * @stable\n * @example\n * try {\n * depAccessorSentinel(\"output(\\\"line\\\")\");\n * } catch (err) {\n * void (err as Error).message;\n * }\n */\nexport const depAccessorSentinel = (name: string): never => {\n throw new Error(\n `${name} can only be called on a compiled chartlang indicator binding inside another indicator's compute body`,\n );\n};\n\n/**\n * Attach the {@link depAccessorSentinel}-backed `output` /\n * `withInputs` accessors to a `{ manifest, compute }` pair so the\n * `defineIndicator` / `defineAlert` / `defineDrawing` /\n * `defineAlertCondition` constructors return a complete\n * {@link CompiledScriptObject}. The compiler rewrites both accessors\n * to static dep lookups at bundle time — the throwing bodies only\n * fire when an un-compiled module is invoked directly.\n *\n * @since 0.7\n * @stable\n * @example\n * declare const manifest: ScriptManifest;\n * declare const compute: ComputeFn;\n * const cs: CompiledScriptObject = attachDepAccessorSentinels({\n * manifest,\n * compute,\n * });\n * void cs;\n */\nexport const attachDepAccessorSentinels = (\n base: Readonly<{ manifest: ScriptManifest; compute: ComputeFn }>,\n): CompiledScriptObject => ({\n manifest: base.manifest,\n compute: base.compute,\n output: (name: string): Series<number> => depAccessorSentinel(`output(\"${name}\")`),\n withInputs: (): CompiledScriptObject => depAccessorSentinel(\"withInputs\"),\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency.js","sourceRoot":"","sources":["../../src/define/dependency.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D"}
|
|
1
|
+
{"version":3,"file":"dependency.js","sourceRoot":"","sources":["../../src/define/dependency.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { JsonValue } from \"../types.js\";\n\n/**\n * One titled output a script exposes for consumption by other\n * indicators. Derived from the producer's `plot(value, { title })`\n * calls during compile. `title` is the key consumers reference via\n * `<binding>.output(\"title\")`.\n *\n * @since 0.7\n * @stable\n * @example\n * const out: OutputDeclaration = {\n * title: \"line\",\n * kind: \"series-number\",\n * };\n * void out;\n */\nexport type OutputDeclaration = Readonly<{\n readonly title: string;\n readonly kind: \"series-number\";\n}>;\n\n/**\n * One node in a script's compiled dependency graph. Emitted by the\n * compiler's `extractDependencyGraph` pass (Task 2) and consumed by\n * the runtime's dep executor (Task 4).\n *\n * `localId` is the JavaScript binding name the consumer used —\n * `const trend = baseTrend.withInputs(...)` produces\n * `localId: \"trend\"`. Stable across script edits as long as the\n * binding name is stable.\n *\n * `producerSourcePath` is the POSIX path the compiler resolved for\n * the producer. Same-file deps use the consumer's `sourcePath`.\n *\n * `effectiveInputs` is the merge of producer defaults + every\n * `.withInputs(...)` chained on the binding, JSON-serialised.\n *\n * `outputs` mirrors the producer's `ScriptManifest.outputs` so the\n * runtime can validate consumer `.output(\"...\")` calls at mount time.\n *\n * @since 0.7\n * @stable\n * @example\n * const dep: DependencyDeclaration = {\n * localId: \"fastTrend\",\n * producerName: \"Base Trend\",\n * producerSourcePath: \"trend-confirmation.chart.ts\",\n * producerExportName: \"default\",\n * effectiveInputs: { length: 20 },\n * outputs: [{ title: \"line\", kind: \"series-number\" }],\n * isDrawn: false,\n * };\n * void dep;\n */\nexport type DependencyDeclaration = Readonly<{\n readonly localId: string;\n readonly producerName: string;\n readonly producerSourcePath: string;\n readonly producerExportName: string;\n readonly effectiveInputs: Readonly<Record<string, JsonValue>>;\n readonly outputs: ReadonlyArray<OutputDeclaration>;\n readonly isDrawn: boolean;\n}>;\n"]}
|
package/dist/define/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/define/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/define/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nexport * from \"./defineIndicator.js\";\nexport * from \"./defineAlert.js\";\nexport * from \"./defineAlertCondition.js\";\nexport * from \"./defineDrawing.js\";\nexport type { DependencyDeclaration, OutputDeclaration } from \"./dependency.js\";\nexport type { ScaleAxis, ScriptOverrides, ValueFormat } from \"./overrides.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../src/define/overrides.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D"}
|
|
1
|
+
{"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../src/define/overrides.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\n/**\n * Value-format hint the adapter uses for axis-label rendering. PLAN §4.1.\n * `\"price\"` formats with the symbol's quote-currency rules; `\"volume\"` uses\n * K/M/B compact notation; `\"percent\"` appends `%`; `\"compact\"` falls back to\n * K/M/B for generic non-volume values.\n *\n * @since 0.4\n * @stable\n * @example\n * const f: ValueFormat = \"percent\";\n * void f;\n */\nexport type ValueFormat = \"price\" | \"volume\" | \"percent\" | \"compact\";\n\n/**\n * Scale axis the indicator should bind to. PLAN §4.1.\n *\n * - `\"price\"` — overlay on the main price pane.\n * - `\"left\"` / `\"right\"` — sub-pane axis side.\n * - `\"new\"` — request a fresh sub-pane keyed by the script id.\n *\n * @since 0.4\n * @stable\n * @example\n * const s: ScaleAxis = \"right\";\n * void s;\n */\nexport type ScaleAxis = \"price\" | \"left\" | \"right\" | \"new\";\n\n/**\n * Author-supplied display + budget overrides. Every field is optional;\n * missing fields fall back to adapter defaults.\n *\n * @since 0.4\n * @stable\n * @example\n * const o: ScriptOverrides = {\n * shortName: \"EMA(20)\",\n * precision: 4,\n * format: \"price\",\n * };\n * void o;\n */\nexport type ScriptOverrides = Readonly<{\n /**\n * Max bars of historical lookback the script needs. `0` keeps the\n * runtime default. Pine `max_bars_back` parity.\n *\n * @since 0.4\n * @example\n * const v: ScriptOverrides[\"maxBarsBack\"] = 100;\n * void v;\n */\n maxBarsBack?: number;\n /**\n * Value-formatting hint for axis labels + cursor read-out.\n *\n * @since 0.4\n * @example\n * const v: ScriptOverrides[\"format\"] = \"price\";\n * void v;\n */\n format?: ValueFormat;\n /**\n * Decimal precision the adapter renders the indicator at. `0`-`10`;\n * `undefined` follows the symbol's default precision.\n *\n * @since 0.4\n * @example\n * const v: ScriptOverrides[\"precision\"] = 2;\n * void v;\n */\n precision?: number;\n /**\n * Scale-axis binding. Defaults to `\"price\"` for overlay indicators and\n * `\"right\"` for sub-pane indicators.\n *\n * @since 0.4\n * @example\n * const v: ScriptOverrides[\"scale\"] = \"right\";\n * void v;\n */\n scale?: ScaleAxis;\n /**\n * Intervals the script requires the adapter to ship in\n * `Capabilities.intervals`.\n *\n * @since 0.4\n * @example\n * const v: ScriptOverrides[\"requiresIntervals\"] = [\"1D\"];\n * void v;\n */\n requiresIntervals?: ReadonlyArray<string>;\n /**\n * Compact display label for legend chips. Defaults to truncated `name`.\n *\n * @since 0.4\n * @example\n * const v: ScriptOverrides[\"shortName\"] = \"EMA\";\n * void v;\n */\n shortName?: string;\n}>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buckets.d.ts","sourceRoot":"","sources":["../../src/draw/buckets.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"buckets.d.ts","sourceRoot":"","sources":["../../src/draw/buckets.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE,aAAa,CAmE9D,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,CAM1D"}
|
package/dist/draw/buckets.js
CHANGED
package/dist/draw/buckets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buckets.js","sourceRoot":"","sources":["../../src/draw/buckets.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAsB/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,WAAW,GAA4C,IAAI,GAAG,CAGzE;IACE,CAAC,MAAM,EAAE,OAAO,CAAC;IACjB,CAAC,iBAAiB,EAAE,OAAO,CAAC;IAC5B,CAAC,gBAAgB,EAAE,OAAO,CAAC;IAC3B,CAAC,eAAe,EAAE,OAAO,CAAC;IAC1B,CAAC,YAAY,EAAE,OAAO,CAAC;IACvB,CAAC,aAAa,EAAE,OAAO,CAAC;IACxB,CAAC,WAAW,EAAE,OAAO,CAAC;IACt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AC,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CAAC,IAAiB;IACvC,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,wCAAwC,IAAI,GAAG,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n\nimport type { DrawingKind } from \"./drawingKind.js\";\n\n/**\n * Canonical bucket name a {@link DrawingKind} maps to under the\n * `DrawingCounts` 5-bag budget (`{ lines, labels, boxes, polylines,\n * other }`). The adapter-kit `Capabilities.maxDrawingsPerScript` and\n * the script-side `ScriptManifest.maxDrawings?` both pin the same five\n * bucket names. The runtime budget enforcer counts emissions per\n * bucket and drops the overflow with `drawing-budget-exceeded`.\n *\n * @formula bucket = KIND_BUCKET.get(kind)\n * @anchors kind: DrawingKind → bucket: \"lines\"|\"labels\"|\"boxes\"|\"polylines\"|\"other\"\n * @since 0.3\n * @stable\n * @example\n * const b: DrawingBucket = \"lines\";\n * void b;\n */\nexport type DrawingBucket = \"lines\" | \"labels\" | \"boxes\" | \"polylines\" | \"other\";\n\n/**\n * Per-kind bucket assignment. Pinned table; every entry of\n * {@link DrawingKind} appears exactly once (asserted by\n * `buckets.test.ts`).\n *\n * Mapping rationale (Phase-3 task README §\"Architecture Decisions\"):\n * lines/rays/horizontalLine/verticalLine/crossLine/trendAngle → `lines`;\n * rectangle/rotatedRectangle/triangle/circle/ellipse → `boxes`;\n * path/polyline/curves/freehand/channels/pitchforks/patterns/elliott →\n * `polylines`; text/arrow/arrowMarker/arrowMarkUp/arrowMarkDown +\n * marker → `labels`; fib / gann / cycles / containers / table → `other`.\n *\n * @formula bucket = KIND_BUCKET.get(kind)\n * @anchors kind: DrawingKind → bucket: \"lines\"|\"labels\"|\"boxes\"|\"polylines\"|\"other\"\n * @since 0.3\n * @stable\n * @example\n * import { KIND_BUCKET } from \"@invinite-org/chartlang-core\";\n * const b = KIND_BUCKET.get(\"fib-retracement\"); // \"other\"\n * void b;\n */\nexport const KIND_BUCKET: ReadonlyMap<DrawingKind, DrawingBucket> = new Map<\n DrawingKind,\n DrawingBucket\n>([\n [\"line\", \"lines\"],\n [\"horizontal-line\", \"lines\"],\n [\"horizontal-ray\", \"lines\"],\n [\"vertical-line\", \"lines\"],\n [\"cross-line\", \"lines\"],\n [\"trend-angle\", \"lines\"],\n [\"rectangle\", \"boxes\"],\n [\"rotated-rectangle\", \"boxes\"],\n [\"triangle\", \"boxes\"],\n [\"polyline\", \"polylines\"],\n [\"circle\", \"boxes\"],\n [\"ellipse\", \"boxes\"],\n [\"path\", \"polylines\"],\n [\"fill-between\", \"polylines\"],\n [\"marker\", \"labels\"],\n [\"arc\", \"polylines\"],\n [\"curve\", \"polylines\"],\n [\"double-curve\", \"polylines\"],\n [\"pen\", \"polylines\"],\n [\"highlighter\", \"polylines\"],\n [\"brush\", \"polylines\"],\n [\"text\", \"labels\"],\n [\"arrow\", \"labels\"],\n [\"arrow-marker\", \"labels\"],\n [\"arrow-mark-up\", \"labels\"],\n [\"arrow-mark-down\", \"labels\"],\n [\"trend-channel\", \"polylines\"],\n [\"flat-top-bottom\", \"polylines\"],\n [\"disjoint-channel\", \"polylines\"],\n [\"regression-trend\", \"polylines\"],\n [\"fib-retracement\", \"other\"],\n [\"fib-trend-extension\", \"other\"],\n [\"fib-channel\", \"other\"],\n [\"fib-time-zone\", \"other\"],\n [\"fib-wedge\", \"other\"],\n [\"fib-speed-fan\", \"other\"],\n [\"fib-speed-arcs\", \"other\"],\n [\"fib-spiral\", \"other\"],\n [\"fib-circles\", \"other\"],\n [\"fib-trend-time\", \"other\"],\n [\"gann-box\", \"other\"],\n [\"gann-square-fixed\", \"other\"],\n [\"gann-square\", \"other\"],\n [\"gann-fan\", \"other\"],\n [\"pitchfork\", \"polylines\"],\n [\"pitchfan\", \"polylines\"],\n [\"xabcd-pattern\", \"polylines\"],\n [\"cypher-pattern\", \"polylines\"],\n [\"head-and-shoulders\", \"polylines\"],\n [\"abcd-pattern\", \"polylines\"],\n [\"triangle-pattern\", \"polylines\"],\n [\"three-drives-pattern\", \"polylines\"],\n [\"elliott-impulse-wave\", \"polylines\"],\n [\"elliott-correction-wave\", \"polylines\"],\n [\"elliott-triangle-wave\", \"polylines\"],\n [\"elliott-double-combo\", \"polylines\"],\n [\"elliott-triple-combo\", \"polylines\"],\n [\"cyclic-lines\", \"other\"],\n [\"time-cycles\", \"other\"],\n [\"sine-line\", \"other\"],\n [\"group\", \"other\"],\n [\"frame\", \"other\"],\n [\"table\", \"other\"],\n]);\n\n/**\n * Return the {@link DrawingBucket} for a given {@link DrawingKind}.\n * Throws if the kind is not in the map — covers the defensive branch\n * for callers that pass an unverified string (e.g. a future kind\n * round-tripped from the wire before its bucket entry lands).\n *\n * @formula bucket = KIND_BUCKET.get(kind)\n * @anchors kind: DrawingKind → bucket: \"lines\"|\"labels\"|\"boxes\"|\"polylines\"|\"other\"\n * @since 0.3\n * @stable\n * @example\n * import { bucketFor } from \"@invinite-org/chartlang-core\";\n * const bucket = bucketFor(\"rectangle\"); // \"boxes\"\n * void bucket;\n */\nexport function bucketFor(kind: DrawingKind): DrawingBucket {\n const bucket = KIND_BUCKET.get(kind);\n if (bucket === undefined) {\n throw new Error(`No bucket assigned for drawing kind '${kind}'`);\n }\n return bucket;\n}\n"]}
|
package/dist/draw/draw.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Price, Time } from "../types.js";
|
|
2
|
-
import type { ArrowMarkerOpts, ArrowOpts, BrushStyle, FibOpts, FrameOpts, HighlighterStyle, LineDrawStyle, PathOpts, RegressionTrendOpts, ShapeStyle, TextOpts } from "./drawingStyle.js";
|
|
2
|
+
import type { ArrowMarkerOpts, ArrowOpts, BrushStyle, FibOpts, FillBetweenStyle, FrameOpts, HighlighterStyle, LineDrawStyle, PathOpts, RegressionTrendOpts, ShapeStyle, TextOpts } from "./drawingStyle.js";
|
|
3
3
|
import type { DrawingHandle } from "./handle.js";
|
|
4
4
|
import type { TableOpts } from "./table.js";
|
|
5
5
|
import type { AnchorHept, AnchorQuad, AnchorQuint, AnchorTriple, WorldPoint } from "./worldPoint.js";
|
|
@@ -8,7 +8,7 @@ import type { AnchorHept, AnchorQuad, AnchorQuint, AnchorTriple, WorldPoint } fr
|
|
|
8
8
|
* calls — the compiler injects a callsite slot id so the runtime can
|
|
9
9
|
* track the per-handle `DrawingState` across bars — and returns a
|
|
10
10
|
* {@link DrawingHandle}. Adapters that omit a kind degrade silently
|
|
11
|
-
* with `unsupported-drawing-kind
|
|
11
|
+
* with `unsupported-drawing-kind`; excess emissions
|
|
12
12
|
* drop with `drawing-budget-exceeded` once the per-script bucket is
|
|
13
13
|
* full.
|
|
14
14
|
*
|
|
@@ -47,6 +47,13 @@ export type DrawNamespace = {
|
|
|
47
47
|
circle(centre: WorldPoint, radiusAnchor: WorldPoint, opts?: ShapeStyle): DrawingHandle;
|
|
48
48
|
ellipse(a: WorldPoint, b: WorldPoint, opts?: ShapeStyle): DrawingHandle;
|
|
49
49
|
path(anchors: ReadonlyArray<WorldPoint>, opts?: PathOpts): DrawingHandle;
|
|
50
|
+
/**
|
|
51
|
+
* Fill the ribbon between two edges. Each edge is a list of world
|
|
52
|
+
* anchors; the filled region is the closed polygon `edgeA` forward
|
|
53
|
+
* then `edgeB` reversed. The native equivalent of Pine
|
|
54
|
+
* `linefill.new(line1, line2, color)` / `fill(plot1, plot2)`.
|
|
55
|
+
*/
|
|
56
|
+
fillBetween(edgeA: ReadonlyArray<WorldPoint>, edgeB: ReadonlyArray<WorldPoint>, opts?: FillBetweenStyle): DrawingHandle;
|
|
50
57
|
marker(anchor: WorldPoint, opts?: TextOpts & {
|
|
51
58
|
readonly text?: string;
|
|
52
59
|
readonly value?: number;
|
|
@@ -109,8 +116,7 @@ export type DrawNamespace = {
|
|
|
109
116
|
* convention as the `plot` / `hline` / `alert` stubs in
|
|
110
117
|
* `plot/plot.ts:plot` / `alert/alert.ts:alert`. The runtime swaps this
|
|
111
118
|
* stub for the real namespace at boot per the
|
|
112
|
-
* `@invinite-org/chartlang-runtime` `primitives.ts` seam
|
|
113
|
-
* §5.5).
|
|
119
|
+
* `@invinite-org/chartlang-runtime` `primitives.ts` seam.
|
|
114
120
|
*
|
|
115
121
|
* @formula N/A — namespace surface; per-method runtime impl in Tasks 5–18
|
|
116
122
|
* @anchors per-method — see the per-kind state shapes in `drawingState.ts`
|