@invinite-org/chartlang-runtime 1.1.1 → 1.3.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 +307 -0
- package/dist/barPoint.d.ts +20 -0
- package/dist/barPoint.d.ts.map +1 -0
- package/dist/barPoint.js +72 -0
- package/dist/barPoint.js.map +1 -0
- package/dist/bufferSnapshot.d.ts +102 -0
- package/dist/bufferSnapshot.d.ts.map +1 -0
- package/dist/bufferSnapshot.js +119 -0
- package/dist/bufferSnapshot.js.map +1 -0
- package/dist/buildComputeContext.d.ts.map +1 -1
- package/dist/buildComputeContext.js +6 -1
- package/dist/buildComputeContext.js.map +1 -1
- package/dist/createScriptRunner.d.ts +6 -3
- package/dist/createScriptRunner.d.ts.map +1 -1
- package/dist/createScriptRunner.js +65 -11
- package/dist/createScriptRunner.js.map +1 -1
- package/dist/dep/DepRunner.d.ts +7 -0
- package/dist/dep/DepRunner.d.ts.map +1 -1
- package/dist/dep/DepRunner.js +4 -0
- package/dist/dep/DepRunner.js.map +1 -1
- package/dist/emit/barcolor.d.ts +44 -0
- package/dist/emit/barcolor.d.ts.map +1 -0
- package/dist/emit/barcolor.js +40 -0
- package/dist/emit/barcolor.js.map +1 -0
- package/dist/emit/bgcolor.d.ts +44 -0
- package/dist/emit/bgcolor.d.ts.map +1 -0
- package/dist/emit/bgcolor.js +45 -0
- package/dist/emit/bgcolor.js.map +1 -0
- package/dist/emit/draw/boxes/fillBetween.d.ts +45 -0
- package/dist/emit/draw/boxes/fillBetween.d.ts.map +1 -0
- package/dist/emit/draw/boxes/fillBetween.js +36 -0
- package/dist/emit/draw/boxes/fillBetween.js.map +1 -0
- package/dist/emit/draw/handle.d.ts +9 -0
- package/dist/emit/draw/handle.d.ts.map +1 -1
- package/dist/emit/draw/handle.js +65 -10
- package/dist/emit/draw/handle.js.map +1 -1
- package/dist/emit/draw/namespace.d.ts +4 -3
- package/dist/emit/draw/namespace.d.ts.map +1 -1
- package/dist/emit/draw/namespace.js +6 -3
- package/dist/emit/draw/namespace.js.map +1 -1
- package/dist/emit/index.d.ts +2 -0
- package/dist/emit/index.d.ts.map +1 -1
- package/dist/emit/index.js +2 -0
- package/dist/emit/index.js.map +1 -1
- package/dist/emit/plot.d.ts +30 -1
- package/dist/emit/plot.d.ts.map +1 -1
- package/dist/emit/plot.js +45 -1
- package/dist/emit/plot.js.map +1 -1
- package/dist/execution/dispose.d.ts.map +1 -1
- package/dist/execution/dispose.js +18 -0
- package/dist/execution/dispose.js.map +1 -1
- package/dist/execution/runComputeStep.d.ts.map +1 -1
- package/dist/execution/runComputeStep.js +12 -1
- package/dist/execution/runComputeStep.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inputs/resolveInputs.js +1 -0
- package/dist/inputs/resolveInputs.js.map +1 -1
- package/dist/persistentStateStore.runtime.d.ts.map +1 -1
- package/dist/persistentStateStore.runtime.js +26 -7
- package/dist/persistentStateStore.runtime.js.map +1 -1
- package/dist/primitives.d.ts +1 -1
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +7 -1
- package/dist/primitives.js.map +1 -1
- package/dist/request/index.d.ts +2 -1
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js +2 -1
- package/dist/request/index.js.map +1 -1
- package/dist/request/lowerTf.d.ts.map +1 -1
- package/dist/request/lowerTf.js +6 -0
- package/dist/request/lowerTf.js.map +1 -1
- package/dist/request/requestNamespace.d.ts.map +1 -1
- package/dist/request/requestNamespace.js +30 -3
- package/dist/request/requestNamespace.js.map +1 -1
- package/dist/request/security.d.ts +40 -4
- package/dist/request/security.d.ts.map +1 -1
- package/dist/request/security.js +114 -40
- package/dist/request/security.js.map +1 -1
- package/dist/request/securityExprRunner.d.ts +137 -0
- package/dist/request/securityExprRunner.d.ts.map +1 -0
- package/dist/request/securityExprRunner.js +253 -0
- package/dist/request/securityExprRunner.js.map +1 -0
- package/dist/request/streamBars.d.ts +14 -1
- package/dist/request/streamBars.d.ts.map +1 -1
- package/dist/request/streamBars.js +39 -1
- package/dist/request/streamBars.js.map +1 -1
- package/dist/ringBuffer.d.ts +19 -0
- package/dist/ringBuffer.d.ts.map +1 -1
- package/dist/ringBuffer.js +23 -0
- package/dist/ringBuffer.js.map +1 -1
- package/dist/runtimeContext.d.ts +90 -5
- package/dist/runtimeContext.d.ts.map +1 -1
- package/dist/runtimeContext.js.map +1 -1
- package/dist/seriesView.d.ts +42 -17
- package/dist/seriesView.d.ts.map +1 -1
- package/dist/seriesView.js +65 -42
- package/dist/seriesView.js.map +1 -1
- package/dist/state/arrayPersistence.d.ts +48 -0
- package/dist/state/arrayPersistence.d.ts.map +1 -0
- package/dist/state/arrayPersistence.js +88 -0
- package/dist/state/arrayPersistence.js.map +1 -0
- package/dist/state/arrayStateSlot.d.ts +78 -0
- package/dist/state/arrayStateSlot.d.ts.map +1 -0
- package/dist/state/arrayStateSlot.js +116 -0
- package/dist/state/arrayStateSlot.js.map +1 -0
- package/dist/state/index.d.ts +4 -1
- package/dist/state/index.d.ts.map +1 -1
- package/dist/state/index.js +4 -1
- package/dist/state/index.js.map +1 -1
- package/dist/state/lifecycle.d.ts +68 -0
- package/dist/state/lifecycle.d.ts.map +1 -1
- package/dist/state/lifecycle.js +89 -0
- package/dist/state/lifecycle.js.map +1 -1
- package/dist/state/seriesPersistence.d.ts +48 -0
- package/dist/state/seriesPersistence.d.ts.map +1 -0
- package/dist/state/seriesPersistence.js +87 -0
- package/dist/state/seriesPersistence.js.map +1 -0
- package/dist/state/seriesSlot.d.ts +105 -0
- package/dist/state/seriesSlot.d.ts.map +1 -0
- package/dist/state/seriesSlot.js +123 -0
- package/dist/state/seriesSlot.js.map +1 -0
- package/dist/state/stateNamespace.d.ts.map +1 -1
- package/dist/state/stateNamespace.js +55 -0
- package/dist/state/stateNamespace.js.map +1 -1
- package/dist/streamState.d.ts +25 -19
- package/dist/streamState.d.ts.map +1 -1
- package/dist/streamState.js +40 -66
- package/dist/streamState.js.map +1 -1
- package/dist/ta/adx.d.ts +3 -2
- package/dist/ta/adx.d.ts.map +1 -1
- package/dist/ta/adx.js +3 -2
- package/dist/ta/adx.js.map +1 -1
- package/dist/ta/alma.d.ts +6 -4
- package/dist/ta/alma.d.ts.map +1 -1
- package/dist/ta/alma.js +19 -6
- package/dist/ta/alma.js.map +1 -1
- package/dist/ta/atr.d.ts +3 -2
- package/dist/ta/atr.d.ts.map +1 -1
- package/dist/ta/atr.js +3 -2
- package/dist/ta/atr.js.map +1 -1
- package/dist/ta/bb.d.ts +3 -2
- package/dist/ta/bb.d.ts.map +1 -1
- package/dist/ta/bb.js +3 -2
- package/dist/ta/bb.js.map +1 -1
- package/dist/ta/chaikinOsc.d.ts +3 -2
- package/dist/ta/chaikinOsc.d.ts.map +1 -1
- package/dist/ta/chaikinOsc.js +3 -2
- package/dist/ta/chaikinOsc.js.map +1 -1
- package/dist/ta/crossover.d.ts +3 -2
- package/dist/ta/crossover.d.ts.map +1 -1
- package/dist/ta/crossover.js +3 -2
- package/dist/ta/crossover.js.map +1 -1
- package/dist/ta/crossunder.d.ts +3 -2
- package/dist/ta/crossunder.d.ts.map +1 -1
- package/dist/ta/crossunder.js +3 -2
- package/dist/ta/crossunder.js.map +1 -1
- package/dist/ta/dmi.d.ts +4 -3
- package/dist/ta/dmi.d.ts.map +1 -1
- package/dist/ta/dmi.js +4 -3
- package/dist/ta/dmi.js.map +1 -1
- package/dist/ta/ema.d.ts +3 -2
- package/dist/ta/ema.d.ts.map +1 -1
- package/dist/ta/ema.js +3 -2
- package/dist/ta/ema.js.map +1 -1
- package/dist/ta/eom.d.ts +3 -1
- package/dist/ta/eom.d.ts.map +1 -1
- package/dist/ta/eom.js +3 -1
- package/dist/ta/eom.js.map +1 -1
- package/dist/ta/highestbars.d.ts +25 -0
- package/dist/ta/highestbars.d.ts.map +1 -0
- package/dist/ta/highestbars.js +106 -0
- package/dist/ta/highestbars.js.map +1 -0
- package/dist/ta/historicalVolatility.d.ts +3 -2
- package/dist/ta/historicalVolatility.d.ts.map +1 -1
- package/dist/ta/historicalVolatility.js +3 -2
- package/dist/ta/historicalVolatility.js.map +1 -1
- package/dist/ta/ichimoku.d.ts +3 -1
- package/dist/ta/ichimoku.d.ts.map +1 -1
- package/dist/ta/ichimoku.js +3 -1
- package/dist/ta/ichimoku.js.map +1 -1
- package/dist/ta/lowestbars.d.ts +25 -0
- package/dist/ta/lowestbars.d.ts.map +1 -0
- package/dist/ta/lowestbars.js +102 -0
- package/dist/ta/lowestbars.js.map +1 -0
- package/dist/ta/macd.d.ts +3 -2
- package/dist/ta/macd.d.ts.map +1 -1
- package/dist/ta/macd.js +3 -2
- package/dist/ta/macd.js.map +1 -1
- package/dist/ta/massIndex.d.ts +3 -2
- package/dist/ta/massIndex.d.ts.map +1 -1
- package/dist/ta/massIndex.js +3 -2
- package/dist/ta/massIndex.js.map +1 -1
- package/dist/ta/mfi.d.ts +3 -1
- package/dist/ta/mfi.d.ts.map +1 -1
- package/dist/ta/mfi.js +3 -1
- package/dist/ta/mfi.js.map +1 -1
- package/dist/ta/netVolume.d.ts +3 -1
- package/dist/ta/netVolume.d.ts.map +1 -1
- package/dist/ta/netVolume.js +3 -1
- package/dist/ta/netVolume.js.map +1 -1
- package/dist/ta/nvi.d.ts +3 -1
- package/dist/ta/nvi.d.ts.map +1 -1
- package/dist/ta/nvi.js +3 -1
- package/dist/ta/nvi.js.map +1 -1
- package/dist/ta/persistence.d.ts.map +1 -1
- package/dist/ta/persistence.js +1 -40
- package/dist/ta/persistence.js.map +1 -1
- package/dist/ta/ppo.d.ts +3 -2
- package/dist/ta/ppo.d.ts.map +1 -1
- package/dist/ta/ppo.js +3 -2
- package/dist/ta/ppo.js.map +1 -1
- package/dist/ta/pvi.d.ts +3 -1
- package/dist/ta/pvi.d.ts.map +1 -1
- package/dist/ta/pvi.js +3 -1
- package/dist/ta/pvi.js.map +1 -1
- package/dist/ta/pvo.d.ts +3 -1
- package/dist/ta/pvo.d.ts.map +1 -1
- package/dist/ta/pvo.js +3 -1
- package/dist/ta/pvo.js.map +1 -1
- package/dist/ta/pvt.d.ts +3 -1
- package/dist/ta/pvt.d.ts.map +1 -1
- package/dist/ta/pvt.js +3 -1
- package/dist/ta/pvt.js.map +1 -1
- package/dist/ta/registry.d.ts +7 -1
- package/dist/ta/registry.d.ts.map +1 -1
- package/dist/ta/registry.js +4 -0
- package/dist/ta/registry.js.map +1 -1
- package/dist/ta/rsi.d.ts +3 -2
- package/dist/ta/rsi.d.ts.map +1 -1
- package/dist/ta/rsi.js +3 -2
- package/dist/ta/rsi.js.map +1 -1
- package/dist/ta/rvi.d.ts +3 -2
- package/dist/ta/rvi.d.ts.map +1 -1
- package/dist/ta/rvi.js +3 -2
- package/dist/ta/rvi.js.map +1 -1
- package/dist/ta/sessionVolumeProfile.d.ts.map +1 -1
- package/dist/ta/sessionVolumeProfile.js +1 -17
- package/dist/ta/sessionVolumeProfile.js.map +1 -1
- package/dist/ta/sma.d.ts +6 -3
- package/dist/ta/sma.d.ts.map +1 -1
- package/dist/ta/sma.js +6 -3
- package/dist/ta/sma.js.map +1 -1
- package/dist/ta/stdev.d.ts +3 -2
- package/dist/ta/stdev.d.ts.map +1 -1
- package/dist/ta/stdev.js +3 -2
- package/dist/ta/stdev.js.map +1 -1
- package/dist/ta/trendStrengthIndex.d.ts +3 -2
- package/dist/ta/trendStrengthIndex.d.ts.map +1 -1
- package/dist/ta/trendStrengthIndex.js +3 -2
- package/dist/ta/trendStrengthIndex.js.map +1 -1
- package/dist/ta/trix.d.ts +4 -3
- package/dist/ta/trix.d.ts.map +1 -1
- package/dist/ta/trix.js +4 -3
- package/dist/ta/trix.js.map +1 -1
- package/dist/ta/vortex.d.ts +3 -2
- package/dist/ta/vortex.d.ts.map +1 -1
- package/dist/ta/vortex.js +3 -2
- package/dist/ta/vortex.js.map +1 -1
- package/dist/time-accessors/civil.d.ts +73 -0
- package/dist/time-accessors/civil.d.ts.map +1 -0
- package/dist/time-accessors/civil.js +105 -0
- package/dist/time-accessors/civil.js.map +1 -0
- package/dist/time-accessors/index.d.ts +8 -0
- package/dist/time-accessors/index.d.ts.map +1 -0
- package/dist/time-accessors/index.js +9 -0
- package/dist/time-accessors/index.js.map +1 -0
- package/dist/time-accessors/sessionAccessors.d.ts +50 -0
- package/dist/time-accessors/sessionAccessors.d.ts.map +1 -0
- package/dist/time-accessors/sessionAccessors.js +79 -0
- package/dist/time-accessors/sessionAccessors.js.map +1 -0
- package/dist/time-accessors/sessionWindow.d.ts +17 -0
- package/dist/time-accessors/sessionWindow.d.ts.map +1 -0
- package/dist/time-accessors/sessionWindow.js +41 -0
- package/dist/time-accessors/sessionWindow.js.map +1 -0
- package/dist/time-accessors/timeAccessors.d.ts +54 -0
- package/dist/time-accessors/timeAccessors.d.ts.map +1 -0
- package/dist/time-accessors/timeAccessors.js +132 -0
- package/dist/time-accessors/timeAccessors.js.map +1 -0
- package/dist/time-accessors/tzDiagnostic.d.ts +17 -0
- package/dist/time-accessors/tzDiagnostic.d.ts.map +1 -0
- package/dist/time-accessors/tzDiagnostic.js +34 -0
- package/dist/time-accessors/tzDiagnostic.js.map +1 -0
- package/dist/time-accessors/tzOffset.d.ts +31 -0
- package/dist/time-accessors/tzOffset.d.ts.map +1 -0
- package/dist/time-accessors/tzOffset.js +67 -0
- package/dist/time-accessors/tzOffset.js.map +1 -0
- package/package.json +3 -3
- package/dist/ta/lib/applyOffset.d.ts +0 -19
- package/dist/ta/lib/applyOffset.d.ts.map +0 -1
- package/dist/ta/lib/applyOffset.js +0 -38
- package/dist/ta/lib/applyOffset.js.map +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
|
+
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import { ACTIVE_RUNTIME_CONTEXT } from "../runtimeContext.js";
|
|
4
|
+
import { plotImpl } from "./plot.js";
|
|
5
|
+
const OUTSIDE_CTX_MESSAGE = "barcolor called outside an active script step";
|
|
6
|
+
/**
|
|
7
|
+
* Lower a `barcolor(color, opts?)` call to the `PlotOpts` a verbose
|
|
8
|
+
* `plot(NaN, { style: { kind: "bar-color", color }, title })` would carry. The
|
|
9
|
+
* static `bar-color` style still carries the color (fallback for adapters
|
|
10
|
+
* that ignore the dynamic channel); the live per-bar color is additionally
|
|
11
|
+
* routed to {@link plotImpl}'s `dynamicColor` arg so it rides the wire as
|
|
12
|
+
* `PlotEmission.colorValue`. The `bar-color` style carries no transparency, so
|
|
13
|
+
* only `title` is spread conditionally (omitted ⇒ absent on the wire).
|
|
14
|
+
*/
|
|
15
|
+
function barColorOpts(color, opts) {
|
|
16
|
+
return {
|
|
17
|
+
style: { kind: "bar-color", color },
|
|
18
|
+
...(opts.title === undefined ? {} : { title: opts.title }),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Implementation signature for {@link barcolor}. Branches on
|
|
23
|
+
* `typeof arg1 === "string"` to dispatch the script-facing vs
|
|
24
|
+
* compiler-injected overload.
|
|
25
|
+
*
|
|
26
|
+
* @since 1.4
|
|
27
|
+
* @example
|
|
28
|
+
* // const fn: typeof barcolor = barcolor;
|
|
29
|
+
* // void fn;
|
|
30
|
+
*/
|
|
31
|
+
export function barcolor(arg1, arg2, arg3) {
|
|
32
|
+
if (typeof arg1 !== "string" || typeof arg2 !== "string") {
|
|
33
|
+
throw new Error(OUTSIDE_CTX_MESSAGE);
|
|
34
|
+
}
|
|
35
|
+
const ctx = ACTIVE_RUNTIME_CONTEXT.current;
|
|
36
|
+
if (!ctx)
|
|
37
|
+
throw new Error(OUTSIDE_CTX_MESSAGE);
|
|
38
|
+
plotImpl(ctx, arg1, Number.NaN, barColorOpts(arg2, arg3 ?? {}), arg2);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=barcolor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barcolor.js","sourceRoot":"","sources":["../../src/emit/barcolor.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,mBAAmB,GAAG,+CAA+C,CAAC;AAE5E;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,KAAY,EAAE,IAAkB;IAClD,OAAO;QACH,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE;QACnC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;KAC7D,CAAC;AACN,CAAC;AA4CD;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CACpB,IAAoB,EACpB,IAA2B,EAC3B,IAAmB;IAEnB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,GAAG,GAAG,sBAAsB,CAAC,OAAO,CAAC;IAC3C,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC/C,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AAC1E,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 { BarColorOpts, Color, PlotOpts } from \"@invinite-org/chartlang-core\";\n\nimport { ACTIVE_RUNTIME_CONTEXT } from \"../runtimeContext.js\";\nimport { plotImpl } from \"./plot.js\";\n\nconst OUTSIDE_CTX_MESSAGE = \"barcolor called outside an active script step\";\n\n/**\n * Lower a `barcolor(color, opts?)` call to the `PlotOpts` a verbose\n * `plot(NaN, { style: { kind: \"bar-color\", color }, title })` would carry. The\n * static `bar-color` style still carries the color (fallback for adapters\n * that ignore the dynamic channel); the live per-bar color is additionally\n * routed to {@link plotImpl}'s `dynamicColor` arg so it rides the wire as\n * `PlotEmission.colorValue`. The `bar-color` style carries no transparency, so\n * only `title` is spread conditionally (omitted ⇒ absent on the wire).\n */\nfunction barColorOpts(color: Color, opts: BarColorOpts): PlotOpts {\n return {\n style: { kind: \"bar-color\", color },\n ...(opts.title === undefined ? {} : { title: opts.title }),\n };\n}\n\n/**\n * Tint the candle / bar for the current bar — the runtime impl of the\n * Pine-ergonomic `barcolor` alias (script-facing overload).\n *\n * Same dual-signature contract as {@link plot}: scripts call\n * `barcolor(color, opts?)`; the compiler's callsite-id transformer rewrites\n * every call to `barcolor(slotId, color, opts?)` (the sibling overload).\n * Direct invocation without a slot id throws the sentinel error.\n *\n * `barcolor` is Pine-ergonomic sugar — it builds the `bar-color` `PlotStyle`\n * and dispatches to the shared {@link plotImpl} with `value = NaN` (→ wire\n * `value: null`). The per-bar color rides the wire as\n * `PlotEmission.colorValue` (the dynamic-color channel), so a single call\n * recolors every bar by that bar's evaluated color; the static `style.color`\n * remains the fallback. Adapters that do not declare the `bar-color`\n * capability drop it with `unsupported-plot-kind`.\n *\n * @since 1.4\n * @example\n * import { defineIndicator, barcolor } from \"@invinite-org/chartlang-core\";\n * export default defineIndicator({\n * name: \"Tint\",\n * apiVersion: 1,\n * compute({ bar }) {\n * barcolor(bar.close > bar.open ? \"#16a34a\" : \"#dc2626\");\n * },\n * });\n */\nexport function barcolor(color: Color, opts?: BarColorOpts): void;\n/**\n * Tint the candle / bar for the current bar (compiler-injected overload).\n * The callsite-id transformer rewrites script-side `barcolor(color, opts?)`\n * into `barcolor(slotId, color, opts?)`.\n *\n * @since 1.4\n * @example\n * // Internal — the compiler rewrites every script callsite, e.g.\n * // `barcolor(\"#000\")` becomes `barcolor(\"demo.chart.ts:5:9#0\", \"#000\")`.\n * // const fn: typeof barcolor = barcolor;\n * // void fn;\n */\nexport function barcolor(slotId: string, color: Color, opts?: BarColorOpts): void;\n/**\n * Implementation signature for {@link barcolor}. Branches on\n * `typeof arg1 === \"string\"` to dispatch the script-facing vs\n * compiler-injected overload.\n *\n * @since 1.4\n * @example\n * // const fn: typeof barcolor = barcolor;\n * // void fn;\n */\nexport function barcolor(\n arg1: string | Color,\n arg2?: Color | BarColorOpts,\n arg3?: BarColorOpts,\n): void {\n if (typeof arg1 !== \"string\" || typeof arg2 !== \"string\") {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (!ctx) throw new Error(OUTSIDE_CTX_MESSAGE);\n plotImpl(ctx, arg1, Number.NaN, barColorOpts(arg2, arg3 ?? {}), arg2);\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { BgColorOpts, Color } from "@invinite-org/chartlang-core";
|
|
2
|
+
/**
|
|
3
|
+
* Paint the pane background for the current bar — the runtime impl of the
|
|
4
|
+
* Pine-ergonomic `bgcolor` alias (script-facing overload).
|
|
5
|
+
*
|
|
6
|
+
* Same dual-signature contract as {@link plot}: scripts call
|
|
7
|
+
* `bgcolor(color, opts?)`; the compiler's callsite-id transformer rewrites
|
|
8
|
+
* every call to `bgcolor(slotId, color, opts?)` (the sibling overload).
|
|
9
|
+
* Direct invocation without a slot id throws the sentinel error.
|
|
10
|
+
*
|
|
11
|
+
* `bgcolor` is Pine-ergonomic sugar — it builds the `bg-color` `PlotStyle`
|
|
12
|
+
* and dispatches to the shared {@link plotImpl} with `value = NaN` (→ wire
|
|
13
|
+
* `value: null`). The per-bar color rides the wire as
|
|
14
|
+
* `PlotEmission.colorValue` (the dynamic-color channel), so a single call
|
|
15
|
+
* recolors every bar by that bar's evaluated color; the static `style.color`
|
|
16
|
+
* remains the fallback. Adapters that do not declare the `bg-color`
|
|
17
|
+
* capability drop it with `unsupported-plot-kind`.
|
|
18
|
+
*
|
|
19
|
+
* @since 1.4
|
|
20
|
+
* @example
|
|
21
|
+
* import { defineIndicator, bgcolor } from "@invinite-org/chartlang-core";
|
|
22
|
+
* export default defineIndicator({
|
|
23
|
+
* name: "Heat",
|
|
24
|
+
* apiVersion: 1,
|
|
25
|
+
* compute({ bar }) {
|
|
26
|
+
* bgcolor(bar.close > bar.open ? "#16a34a" : "#dc2626", { transp: 80 });
|
|
27
|
+
* },
|
|
28
|
+
* });
|
|
29
|
+
*/
|
|
30
|
+
export declare function bgcolor(color: Color, opts?: BgColorOpts): void;
|
|
31
|
+
/**
|
|
32
|
+
* Paint the pane background for the current bar (compiler-injected overload).
|
|
33
|
+
* The callsite-id transformer rewrites script-side `bgcolor(color, opts?)`
|
|
34
|
+
* into `bgcolor(slotId, color, opts?)`.
|
|
35
|
+
*
|
|
36
|
+
* @since 1.4
|
|
37
|
+
* @example
|
|
38
|
+
* // Internal — the compiler rewrites every script callsite, e.g.
|
|
39
|
+
* // `bgcolor("#000")` becomes `bgcolor("demo.chart.ts:5:9#0", "#000")`.
|
|
40
|
+
* // const fn: typeof bgcolor = bgcolor;
|
|
41
|
+
* // void fn;
|
|
42
|
+
*/
|
|
43
|
+
export declare function bgcolor(slotId: string, color: Color, opts?: BgColorOpts): void;
|
|
44
|
+
//# sourceMappingURL=bgcolor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bgcolor.d.ts","sourceRoot":"","sources":["../../src/emit/bgcolor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAY,MAAM,8BAA8B,CAAC;AA4BjF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;AAChE;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
|
+
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import { ACTIVE_RUNTIME_CONTEXT } from "../runtimeContext.js";
|
|
4
|
+
import { plotImpl } from "./plot.js";
|
|
5
|
+
const OUTSIDE_CTX_MESSAGE = "bgcolor called outside an active script step";
|
|
6
|
+
/**
|
|
7
|
+
* Lower a `bgcolor(color, opts?)` call to the `PlotOpts` a verbose
|
|
8
|
+
* `plot(NaN, { style: { kind: "bg-color", color, transp }, title })` would
|
|
9
|
+
* carry. The static `bg-color` style still carries the color (fallback for
|
|
10
|
+
* adapters that ignore the dynamic channel); the live per-bar color is
|
|
11
|
+
* additionally routed to {@link plotImpl}'s `dynamicColor` arg so it rides
|
|
12
|
+
* the wire as `PlotEmission.colorValue`. `transp` / `title` are spread
|
|
13
|
+
* conditionally (omitted ⇒ absent on the wire), matching the author style arm
|
|
14
|
+
* and `exactOptionalPropertyTypes`.
|
|
15
|
+
*/
|
|
16
|
+
function bgColorOpts(color, opts) {
|
|
17
|
+
return {
|
|
18
|
+
style: {
|
|
19
|
+
kind: "bg-color",
|
|
20
|
+
color,
|
|
21
|
+
...(opts.transp === undefined ? {} : { transp: opts.transp }),
|
|
22
|
+
},
|
|
23
|
+
...(opts.title === undefined ? {} : { title: opts.title }),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Implementation signature for {@link bgcolor}. Branches on
|
|
28
|
+
* `typeof arg1 === "string"` to dispatch the script-facing vs
|
|
29
|
+
* compiler-injected overload.
|
|
30
|
+
*
|
|
31
|
+
* @since 1.4
|
|
32
|
+
* @example
|
|
33
|
+
* // const fn: typeof bgcolor = bgcolor;
|
|
34
|
+
* // void fn;
|
|
35
|
+
*/
|
|
36
|
+
export function bgcolor(arg1, arg2, arg3) {
|
|
37
|
+
if (typeof arg1 !== "string" || typeof arg2 !== "string") {
|
|
38
|
+
throw new Error(OUTSIDE_CTX_MESSAGE);
|
|
39
|
+
}
|
|
40
|
+
const ctx = ACTIVE_RUNTIME_CONTEXT.current;
|
|
41
|
+
if (!ctx)
|
|
42
|
+
throw new Error(OUTSIDE_CTX_MESSAGE);
|
|
43
|
+
plotImpl(ctx, arg1, Number.NaN, bgColorOpts(arg2, arg3 ?? {}), arg2);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=bgcolor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bgcolor.js","sourceRoot":"","sources":["../../src/emit/bgcolor.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,mBAAmB,GAAG,8CAA8C,CAAC;AAE3E;;;;;;;;;GASG;AACH,SAAS,WAAW,CAAC,KAAY,EAAE,IAAiB;IAChD,OAAO;QACH,KAAK,EAAE;YACH,IAAI,EAAE,UAAU;YAChB,KAAK;YACL,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;SAChE;QACD,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;KAC7D,CAAC;AACN,CAAC;AA4CD;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CACnB,IAAoB,EACpB,IAA0B,EAC1B,IAAkB;IAElB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,GAAG,GAAG,sBAAsB,CAAC,OAAO,CAAC;IAC3C,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAC/C,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AACzE,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 { BgColorOpts, Color, PlotOpts } from \"@invinite-org/chartlang-core\";\n\nimport { ACTIVE_RUNTIME_CONTEXT } from \"../runtimeContext.js\";\nimport { plotImpl } from \"./plot.js\";\n\nconst OUTSIDE_CTX_MESSAGE = \"bgcolor called outside an active script step\";\n\n/**\n * Lower a `bgcolor(color, opts?)` call to the `PlotOpts` a verbose\n * `plot(NaN, { style: { kind: \"bg-color\", color, transp }, title })` would\n * carry. The static `bg-color` style still carries the color (fallback for\n * adapters that ignore the dynamic channel); the live per-bar color is\n * additionally routed to {@link plotImpl}'s `dynamicColor` arg so it rides\n * the wire as `PlotEmission.colorValue`. `transp` / `title` are spread\n * conditionally (omitted ⇒ absent on the wire), matching the author style arm\n * and `exactOptionalPropertyTypes`.\n */\nfunction bgColorOpts(color: Color, opts: BgColorOpts): PlotOpts {\n return {\n style: {\n kind: \"bg-color\",\n color,\n ...(opts.transp === undefined ? {} : { transp: opts.transp }),\n },\n ...(opts.title === undefined ? {} : { title: opts.title }),\n };\n}\n\n/**\n * Paint the pane background for the current bar — the runtime impl of the\n * Pine-ergonomic `bgcolor` alias (script-facing overload).\n *\n * Same dual-signature contract as {@link plot}: scripts call\n * `bgcolor(color, opts?)`; the compiler's callsite-id transformer rewrites\n * every call to `bgcolor(slotId, color, opts?)` (the sibling overload).\n * Direct invocation without a slot id throws the sentinel error.\n *\n * `bgcolor` is Pine-ergonomic sugar — it builds the `bg-color` `PlotStyle`\n * and dispatches to the shared {@link plotImpl} with `value = NaN` (→ wire\n * `value: null`). The per-bar color rides the wire as\n * `PlotEmission.colorValue` (the dynamic-color channel), so a single call\n * recolors every bar by that bar's evaluated color; the static `style.color`\n * remains the fallback. Adapters that do not declare the `bg-color`\n * capability drop it with `unsupported-plot-kind`.\n *\n * @since 1.4\n * @example\n * import { defineIndicator, bgcolor } from \"@invinite-org/chartlang-core\";\n * export default defineIndicator({\n * name: \"Heat\",\n * apiVersion: 1,\n * compute({ bar }) {\n * bgcolor(bar.close > bar.open ? \"#16a34a\" : \"#dc2626\", { transp: 80 });\n * },\n * });\n */\nexport function bgcolor(color: Color, opts?: BgColorOpts): void;\n/**\n * Paint the pane background for the current bar (compiler-injected overload).\n * The callsite-id transformer rewrites script-side `bgcolor(color, opts?)`\n * into `bgcolor(slotId, color, opts?)`.\n *\n * @since 1.4\n * @example\n * // Internal — the compiler rewrites every script callsite, e.g.\n * // `bgcolor(\"#000\")` becomes `bgcolor(\"demo.chart.ts:5:9#0\", \"#000\")`.\n * // const fn: typeof bgcolor = bgcolor;\n * // void fn;\n */\nexport function bgcolor(slotId: string, color: Color, opts?: BgColorOpts): void;\n/**\n * Implementation signature for {@link bgcolor}. Branches on\n * `typeof arg1 === \"string\"` to dispatch the script-facing vs\n * compiler-injected overload.\n *\n * @since 1.4\n * @example\n * // const fn: typeof bgcolor = bgcolor;\n * // void fn;\n */\nexport function bgcolor(\n arg1: string | Color,\n arg2?: Color | BgColorOpts,\n arg3?: BgColorOpts,\n): void {\n if (typeof arg1 !== \"string\" || typeof arg2 !== \"string\") {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (!ctx) throw new Error(OUTSIDE_CTX_MESSAGE);\n plotImpl(ctx, arg1, Number.NaN, bgColorOpts(arg2, arg3 ?? {}), arg2);\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { DrawingHandle, FillBetweenStyle, WorldPoint } from "@invinite-org/chartlang-core";
|
|
2
|
+
/**
|
|
3
|
+
* Fill the ribbon between two edges. The native equivalent of Pine
|
|
4
|
+
* `linefill.new(line1, line2, color)` and `fill(plot1, plot2, color)`.
|
|
5
|
+
* The filled region is the closed polygon `edgeA` forward then `edgeB`
|
|
6
|
+
* reversed; the two edges need not share x-coordinates or length.
|
|
7
|
+
*
|
|
8
|
+
* @anchors `edgeA`, `edgeB` — two `WorldPoint` lists (the band edges)
|
|
9
|
+
* @anchorCount variable — each edge needs 2..10000 finite anchors
|
|
10
|
+
* @bucket polylines
|
|
11
|
+
* @warmup none — guard warmup in-script: an edge with fewer than 2 finite
|
|
12
|
+
* anchors (empty, single-point, or a `NaN` coordinate) is dropped with a
|
|
13
|
+
* `malformed-emission` diagnostic, so accumulate then gate on `length >= 2`
|
|
14
|
+
* as the example does.
|
|
15
|
+
* @since 0.4
|
|
16
|
+
* @stable
|
|
17
|
+
* @example
|
|
18
|
+
* import { type WorldPoint, defineIndicator } from "@invinite-org/chartlang-core";
|
|
19
|
+
* const top: WorldPoint[] = [];
|
|
20
|
+
* const bottom: WorldPoint[] = [];
|
|
21
|
+
* export default defineIndicator({
|
|
22
|
+
* name: "draw.fillBetween demo",
|
|
23
|
+
* apiVersion: 1,
|
|
24
|
+
* compute({ bar, draw }) {
|
|
25
|
+
* top.push({ time: bar.time, price: bar.high });
|
|
26
|
+
* bottom.push({ time: bar.time, price: bar.low });
|
|
27
|
+
* if (top.length >= 2) {
|
|
28
|
+
* draw.fillBetween(top, bottom, { fill: "#3b82f6", fillAlpha: 0.2 });
|
|
29
|
+
* }
|
|
30
|
+
* },
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
33
|
+
export declare function fillBetween(edgeA: ReadonlyArray<WorldPoint>, edgeB: ReadonlyArray<WorldPoint>, opts?: FillBetweenStyle): DrawingHandle;
|
|
34
|
+
/**
|
|
35
|
+
* Compiler-injected overload.
|
|
36
|
+
*
|
|
37
|
+
* @since 0.4
|
|
38
|
+
* @stable
|
|
39
|
+
* @example
|
|
40
|
+
* // Internal — the compiler rewrites every script callsite.
|
|
41
|
+
* // const fn: typeof fillBetween = fillBetween;
|
|
42
|
+
* // void fn;
|
|
43
|
+
*/
|
|
44
|
+
export declare function fillBetween(slotId: string, edgeA: ReadonlyArray<WorldPoint>, edgeB: ReadonlyArray<WorldPoint>, opts?: FillBetweenStyle): DrawingHandle;
|
|
45
|
+
//# sourceMappingURL=fillBetween.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fillBetween.d.ts","sourceRoot":"","sources":["../../../../src/emit/draw/boxes/fillBetween.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,aAAa,EAEb,gBAAgB,EAChB,UAAU,EACb,MAAM,8BAA8B,CAAC;AAqBtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,WAAW,CACvB,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,EAChC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,EAChC,IAAI,CAAC,EAAE,gBAAgB,GACxB,aAAa,CAAC;AACjB;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACvB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,EAChC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,EAChC,IAAI,CAAC,EAAE,gBAAgB,GACxB,aAAa,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
|
+
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
import { ACTIVE_RUNTIME_CONTEXT } from "../../../runtimeContext.js";
|
|
4
|
+
import { createDrawingHandle } from "../handle.js";
|
|
5
|
+
import { nextSubId } from "../subIdAllocator.js";
|
|
6
|
+
const OUTSIDE_CTX_MESSAGE = "draw.fillBetween called outside an active script step";
|
|
7
|
+
function fillBetweenImpl(slotId, edgeA, edgeB, opts) {
|
|
8
|
+
const ctx = ACTIVE_RUNTIME_CONTEXT.current;
|
|
9
|
+
if (ctx === null)
|
|
10
|
+
throw new Error(OUTSIDE_CTX_MESSAGE);
|
|
11
|
+
const subId = nextSubId(ctx, slotId);
|
|
12
|
+
const state = { kind: "fill-between", edgeA, edgeB, style: opts };
|
|
13
|
+
return createDrawingHandle(slotId, subId, "fill-between", state);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Implementation signature for {@link fillBetween}. Branches on
|
|
17
|
+
* `typeof arg1 === "string"` to dispatch the script-facing vs
|
|
18
|
+
* compiler-injected overload.
|
|
19
|
+
*
|
|
20
|
+
* @since 0.4
|
|
21
|
+
* @stable
|
|
22
|
+
* @example
|
|
23
|
+
* // const fn: typeof fillBetween = fillBetween;
|
|
24
|
+
* // void fn;
|
|
25
|
+
*/
|
|
26
|
+
export function fillBetween(arg1, arg2, arg3, arg4) {
|
|
27
|
+
if (typeof arg1 !== "string" ||
|
|
28
|
+
arg2 === undefined ||
|
|
29
|
+
!Array.isArray(arg2) ||
|
|
30
|
+
arg3 === undefined ||
|
|
31
|
+
!Array.isArray(arg3)) {
|
|
32
|
+
throw new Error(OUTSIDE_CTX_MESSAGE);
|
|
33
|
+
}
|
|
34
|
+
return fillBetweenImpl(arg1, arg2, arg3, arg4 ?? {});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=fillBetween.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fillBetween.js","sourceRoot":"","sources":["../../../../src/emit/draw/boxes/fillBetween.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAS/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,mBAAmB,GAAG,uDAAuD,CAAC;AAEpF,SAAS,eAAe,CACpB,MAAc,EACd,KAAgC,EAChC,KAAgC,EAChC,IAAsB;IAEtB,MAAM,GAAG,GAAG,sBAAsB,CAAC,OAAO,CAAC;IAC3C,IAAI,GAAG,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,KAAK,GAAqB,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACpF,OAAO,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;AACrE,CAAC;AAsDD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CACvB,IAAwC,EACxC,IAAgC,EAChC,IAAmD,EACnD,IAAuB;IAEvB,IACI,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,SAAS;QAClB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACpB,IAAI,KAAK,SAAS;QAClB,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EACtB,CAAC;QACC,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,IAAiC,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AACtF,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 DrawingHandle,\n FillBetweenState,\n FillBetweenStyle,\n WorldPoint,\n} from \"@invinite-org/chartlang-core\";\n\nimport { ACTIVE_RUNTIME_CONTEXT } from \"../../../runtimeContext.js\";\nimport { createDrawingHandle } from \"../handle.js\";\nimport { nextSubId } from \"../subIdAllocator.js\";\n\nconst OUTSIDE_CTX_MESSAGE = \"draw.fillBetween called outside an active script step\";\n\nfunction fillBetweenImpl(\n slotId: string,\n edgeA: ReadonlyArray<WorldPoint>,\n edgeB: ReadonlyArray<WorldPoint>,\n opts: FillBetweenStyle,\n): DrawingHandle {\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (ctx === null) throw new Error(OUTSIDE_CTX_MESSAGE);\n const subId = nextSubId(ctx, slotId);\n const state: FillBetweenState = { kind: \"fill-between\", edgeA, edgeB, style: opts };\n return createDrawingHandle(slotId, subId, \"fill-between\", state);\n}\n\n/**\n * Fill the ribbon between two edges. The native equivalent of Pine\n * `linefill.new(line1, line2, color)` and `fill(plot1, plot2, color)`.\n * The filled region is the closed polygon `edgeA` forward then `edgeB`\n * reversed; the two edges need not share x-coordinates or length.\n *\n * @anchors `edgeA`, `edgeB` — two `WorldPoint` lists (the band edges)\n * @anchorCount variable — each edge needs 2..10000 finite anchors\n * @bucket polylines\n * @warmup none — guard warmup in-script: an edge with fewer than 2 finite\n * anchors (empty, single-point, or a `NaN` coordinate) is dropped with a\n * `malformed-emission` diagnostic, so accumulate then gate on `length >= 2`\n * as the example does.\n * @since 0.4\n * @stable\n * @example\n * import { type WorldPoint, defineIndicator } from \"@invinite-org/chartlang-core\";\n * const top: WorldPoint[] = [];\n * const bottom: WorldPoint[] = [];\n * export default defineIndicator({\n * name: \"draw.fillBetween demo\",\n * apiVersion: 1,\n * compute({ bar, draw }) {\n * top.push({ time: bar.time, price: bar.high });\n * bottom.push({ time: bar.time, price: bar.low });\n * if (top.length >= 2) {\n * draw.fillBetween(top, bottom, { fill: \"#3b82f6\", fillAlpha: 0.2 });\n * }\n * },\n * });\n */\nexport function fillBetween(\n edgeA: ReadonlyArray<WorldPoint>,\n edgeB: ReadonlyArray<WorldPoint>,\n opts?: FillBetweenStyle,\n): DrawingHandle;\n/**\n * Compiler-injected overload.\n *\n * @since 0.4\n * @stable\n * @example\n * // Internal — the compiler rewrites every script callsite.\n * // const fn: typeof fillBetween = fillBetween;\n * // void fn;\n */\nexport function fillBetween(\n slotId: string,\n edgeA: ReadonlyArray<WorldPoint>,\n edgeB: ReadonlyArray<WorldPoint>,\n opts?: FillBetweenStyle,\n): DrawingHandle;\n/**\n * Implementation signature for {@link fillBetween}. Branches on\n * `typeof arg1 === \"string\"` to dispatch the script-facing vs\n * compiler-injected overload.\n *\n * @since 0.4\n * @stable\n * @example\n * // const fn: typeof fillBetween = fillBetween;\n * // void fn;\n */\nexport function fillBetween(\n arg1: string | ReadonlyArray<WorldPoint>,\n arg2?: ReadonlyArray<WorldPoint>,\n arg3?: ReadonlyArray<WorldPoint> | FillBetweenStyle,\n arg4?: FillBetweenStyle,\n): DrawingHandle {\n if (\n typeof arg1 !== \"string\" ||\n arg2 === undefined ||\n !Array.isArray(arg2) ||\n arg3 === undefined ||\n !Array.isArray(arg3)\n ) {\n throw new Error(OUTSIDE_CTX_MESSAGE);\n }\n return fillBetweenImpl(arg1, arg2, arg3 as ReadonlyArray<WorldPoint>, arg4 ?? {});\n}\n"]}
|
|
@@ -14,6 +14,15 @@ import type { DrawingHandle, DrawingKind, DrawingState } from "@invinite-org/cha
|
|
|
14
14
|
*
|
|
15
15
|
* The handle's `id` is `slotId#subId` — stable across bars.
|
|
16
16
|
*
|
|
17
|
+
* `z` is the presentation-only render-order key the `draw.*` opts bag
|
|
18
|
+
* carried (core's `ZOrdered` mixin) folded into `state.style`. It is
|
|
19
|
+
* {@link splitZ | lifted out} of `state.style` so it rides the wire as
|
|
20
|
+
* the top-level {@link DrawingEmission.z} field, **never** inside
|
|
21
|
+
* `DrawingState` (Task 3 forbids `z` in `state`), and is persisted on
|
|
22
|
+
* the slot. An `update` that does not re-specify a non-zero `z` retains
|
|
23
|
+
* the last value; a re-specified non-zero `z` overrides; `remove`
|
|
24
|
+
* carries the last-known `z`.
|
|
25
|
+
*
|
|
17
26
|
* @since 0.3
|
|
18
27
|
* @stable
|
|
19
28
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../../src/emit/draw/handle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../../../src/emit/draw/handle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAyE7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,WAAW,EACjB,YAAY,EAAE,YAAY,GAC3B,aAAa,CAoEf"}
|
package/dist/emit/draw/handle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
2
|
// See the LICENSE file in the repo root for full license text.
|
|
3
|
-
import { ACTIVE_RUNTIME_CONTEXT } from "../../runtimeContext.js";
|
|
3
|
+
import { ACTIVE_RUNTIME_CONTEXT, } from "../../runtimeContext.js";
|
|
4
4
|
import { pushDrawing } from "./pushDrawing.js";
|
|
5
5
|
const OUTSIDE_CTX_MESSAGE = "draw called outside an active script step";
|
|
6
6
|
function mergeState(prev, patch) {
|
|
@@ -13,7 +13,34 @@ function mergeState(prev, patch) {
|
|
|
13
13
|
// discriminants stay pinned to `prev.kind`.
|
|
14
14
|
return { ...prev, ...patch, kind: prev.kind };
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Lift the presentation-only `z` (render-order key) **out** of a
|
|
18
|
+
* drawing's `state.style` and hand it back to the caller, returning a
|
|
19
|
+
* state with `z` removed from a **shallow clone** of `style` (the
|
|
20
|
+
* caller's style object is never mutated). Every `draw.*` option bag
|
|
21
|
+
* carries `z` via core's `ZOrdered` mixin, and the per-kind impls fold
|
|
22
|
+
* that bag into `state.style`, so `z` arrives nested at `state.style.z`.
|
|
23
|
+
* `z` is a **top-level** `DrawingEmission` field, not part of
|
|
24
|
+
* `DrawingState`, so it must not ride the wire inside `state` — strip it
|
|
25
|
+
* here. Returns `z: 0` (the omit-when-`0` default) for states with no
|
|
26
|
+
* `style` (e.g. `group`) or no `z`, leaving the state object **untouched**
|
|
27
|
+
* in that case so a no-`z` drawing stays byte-identical to the
|
|
28
|
+
* pre-feature baseline.
|
|
29
|
+
*/
|
|
30
|
+
function splitZ(state) {
|
|
31
|
+
if (!("style" in state) || state.style === undefined) {
|
|
32
|
+
return { state, z: 0 };
|
|
33
|
+
}
|
|
34
|
+
const style = state.style;
|
|
35
|
+
if (style.z === undefined) {
|
|
36
|
+
return { state, z: 0 };
|
|
37
|
+
}
|
|
38
|
+
// Shallow-clone style with `z` removed — never mutate the caller's
|
|
39
|
+
// object. `rest` is z-free, so the wire `state.style` carries no `z`.
|
|
40
|
+
const { z, ...rest } = style;
|
|
41
|
+
return { state: { ...state, style: rest }, z };
|
|
42
|
+
}
|
|
43
|
+
function emit(ctx, handleId, kind, op, state, z) {
|
|
17
44
|
pushDrawing(ctx, {
|
|
18
45
|
kind: "drawing",
|
|
19
46
|
handleId,
|
|
@@ -22,6 +49,10 @@ function emit(ctx, handleId, kind, op, state) {
|
|
|
22
49
|
state,
|
|
23
50
|
bar: ctx.barIndex(),
|
|
24
51
|
time: ctx.stream.bar.time,
|
|
52
|
+
// `z` is presentation-only and top-level (never inside `state`);
|
|
53
|
+
// omit it when `0` so a no-`z` drawing is byte-identical to the
|
|
54
|
+
// pre-feature baseline — mirrors `PlotEmission.xShift` / `.z`.
|
|
55
|
+
...(z === 0 ? {} : { z }),
|
|
25
56
|
});
|
|
26
57
|
}
|
|
27
58
|
/**
|
|
@@ -39,6 +70,15 @@ function emit(ctx, handleId, kind, op, state) {
|
|
|
39
70
|
*
|
|
40
71
|
* The handle's `id` is `slotId#subId` — stable across bars.
|
|
41
72
|
*
|
|
73
|
+
* `z` is the presentation-only render-order key the `draw.*` opts bag
|
|
74
|
+
* carried (core's `ZOrdered` mixin) folded into `state.style`. It is
|
|
75
|
+
* {@link splitZ | lifted out} of `state.style` so it rides the wire as
|
|
76
|
+
* the top-level {@link DrawingEmission.z} field, **never** inside
|
|
77
|
+
* `DrawingState` (Task 3 forbids `z` in `state`), and is persisted on
|
|
78
|
+
* the slot. An `update` that does not re-specify a non-zero `z` retains
|
|
79
|
+
* the last value; a re-specified non-zero `z` overrides; `remove`
|
|
80
|
+
* carries the last-known `z`.
|
|
81
|
+
*
|
|
42
82
|
* @since 0.3
|
|
43
83
|
* @stable
|
|
44
84
|
* @example
|
|
@@ -64,23 +104,30 @@ export function createDrawingHandle(slotId, subId, kind, initialState) {
|
|
|
64
104
|
throw new Error(OUTSIDE_CTX_MESSAGE);
|
|
65
105
|
const handleId = `${slotId}#${subId}`;
|
|
66
106
|
const existing = ctx.drawingSlots.get(handleId);
|
|
107
|
+
// Lift `z` out of `state.style` so it rides the emission top-level,
|
|
108
|
+
// not inside `DrawingState`. The remaining `style` (z removed) is
|
|
109
|
+
// what persists in the slot.
|
|
110
|
+
const initial = splitZ(initialState);
|
|
67
111
|
let slot;
|
|
68
112
|
let op;
|
|
69
113
|
if (existing === undefined) {
|
|
70
|
-
slot = { handleId, kind, state:
|
|
114
|
+
slot = { handleId, kind, state: initial.state, z: initial.z, removed: false };
|
|
71
115
|
ctx.drawingSlots.set(handleId, slot);
|
|
72
116
|
op = "create";
|
|
73
117
|
}
|
|
74
118
|
else {
|
|
75
119
|
// Cross-bar re-entry. Merge initialState into the existing slot
|
|
76
120
|
// (script-author may pass new anchors / style); resurrect if it
|
|
77
|
-
// was previously removed.
|
|
78
|
-
|
|
121
|
+
// was previously removed. A re-specified `z` (non-default)
|
|
122
|
+
// overrides the retained one; an omitted/`0` `z` keeps the last.
|
|
123
|
+
existing.state = mergeState(existing.state, initial.state);
|
|
124
|
+
if (initial.z !== 0)
|
|
125
|
+
existing.z = initial.z;
|
|
79
126
|
existing.removed = false;
|
|
80
127
|
slot = existing;
|
|
81
128
|
op = "update";
|
|
82
129
|
}
|
|
83
|
-
emit(ctx, handleId, kind, op, slot.state);
|
|
130
|
+
emit(ctx, handleId, kind, op, slot.state, slot.z);
|
|
84
131
|
return {
|
|
85
132
|
id: handleId,
|
|
86
133
|
update(patch) {
|
|
@@ -95,8 +142,15 @@ export function createDrawingHandle(slotId, subId, kind, initialState) {
|
|
|
95
142
|
const s = liveCtx.drawingSlots.get(handleId);
|
|
96
143
|
if (s === undefined || s.removed)
|
|
97
144
|
return;
|
|
98
|
-
|
|
99
|
-
|
|
145
|
+
// A patch may re-specify `z` inside `style`; split it out so
|
|
146
|
+
// it never merges into `state.style`. A re-specified
|
|
147
|
+
// non-default `z` overrides; an omitted/`0` `z` retains the
|
|
148
|
+
// slot's last value.
|
|
149
|
+
const split = splitZ(mergeState(s.state, patch));
|
|
150
|
+
s.state = split.state;
|
|
151
|
+
if (split.z !== 0)
|
|
152
|
+
s.z = split.z;
|
|
153
|
+
emit(liveCtx, handleId, kind, "update", s.state, s.z);
|
|
100
154
|
},
|
|
101
155
|
remove() {
|
|
102
156
|
const liveCtx = ACTIVE_RUNTIME_CONTEXT.current;
|
|
@@ -109,9 +163,10 @@ export function createDrawingHandle(slotId, subId, kind, initialState) {
|
|
|
109
163
|
// mid-run, so a previously-created handle's "remove" always
|
|
110
164
|
// reaches `pushDrawing`. The slot stays flagged even if a
|
|
111
165
|
// future drop path swallows the emission — a removed handle
|
|
112
|
-
// must never re-emit.
|
|
166
|
+
// must never re-emit. `remove` carries the last-known `z`
|
|
167
|
+
// (harmless — no render).
|
|
113
168
|
s.removed = true;
|
|
114
|
-
emit(liveCtx, handleId, kind, "remove", s.state);
|
|
169
|
+
emit(liveCtx, handleId, kind, "remove", s.state, s.z);
|
|
115
170
|
},
|
|
116
171
|
};
|
|
117
172
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../../../src/emit/draw/handle.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,mBAAmB,GAAG,2CAA2C,CAAC;AAExE,SAAS,UAAU,CAAC,IAAkB,EAAE,KAA4B;IAChE,4DAA4D;IAC5D,kEAAkE;IAClE,kEAAkE;IAClE,+DAA+D;IAC/D,iEAAiE;IACjE,iEAAiE;IACjE,4CAA4C;IAC5C,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAkB,CAAC;AAClE,CAAC;AAED,SAAS,IAAI,CACT,GAAmB,EACnB,QAAgB,EAChB,IAAiB,EACjB,EAAkC,EAClC,KAAmB;IAEnB,WAAW,CAAC,GAAG,EAAE;QACb,IAAI,EAAE,SAAS;QACf,QAAQ;QACR,WAAW,EAAE,IAAI;QACjB,EAAE;QACF,KAAK;QACL,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;QACnB,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI;KAC5B,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,mBAAmB,CAC/B,MAAc,EACd,KAAa,EACb,IAAiB,EACjB,YAA0B;IAE1B,MAAM,GAAG,GAAG,sBAAsB,CAAC,OAAO,CAAC;IAC3C,IAAI,GAAG,KAAK,IAAI;QAAE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;gBAAE,OAAO;YACzC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACrC,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC;QACD,MAAM;YACF,MAAM,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAC;YAC/C,IAAI,OAAO,KAAK,IAAI;gBAAE,OAAO;YAC7B,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC7C,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO;gBAAE,OAAO;YACzC,uDAAuD;YACvD,4DAA4D;YAC5D,0DAA0D;YAC1D,4DAA4D;YAC5D,sBAAsB;YACtB,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC;KACJ,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 { DrawingHandle, DrawingKind, DrawingState } from \"@invinite-org/chartlang-core\";\n\nimport { ACTIVE_RUNTIME_CONTEXT, type RuntimeContext } from \"../../runtimeContext.js\";\nimport { pushDrawing } from \"./pushDrawing.js\";\n\nconst OUTSIDE_CTX_MESSAGE = \"draw called outside an active script step\";\n\nfunction mergeState(prev: DrawingState, patch: Partial<DrawingState>): DrawingState {\n // Spread the patch over `prev` and force `kind` back to the\n // previous variant. A cross-variant patch from a script is a type\n // error at the script's callsite — the runtime defends against it\n // here so the runtime cannot accidentally emit a drift between\n // `drawingKind` and `state.kind`. The cast is safe because every\n // variant of `DrawingState` shares the shape `{ kind, ... }` and\n // discriminants stay pinned to `prev.kind`.\n return { ...prev, ...patch, kind: prev.kind } as DrawingState;\n}\n\nfunction emit(\n ctx: RuntimeContext,\n handleId: string,\n kind: DrawingKind,\n op: \"create\" | \"update\" | \"remove\",\n state: DrawingState,\n): void {\n pushDrawing(ctx, {\n kind: \"drawing\",\n handleId,\n drawingKind: kind,\n op,\n state,\n bar: ctx.barIndex(),\n time: ctx.stream.bar.time,\n });\n}\n\n/**\n * Construct a {@link DrawingHandle} for `slotId#subId` in the active\n * runtime context. Allocates the slot in `ctx.drawingSlots` on the\n * first call (`op: \"create\"`); subsequent calls at the same callsite\n * across bars find the existing slot and emit `op: \"update\"` with the\n * full merged state.\n *\n * `update(patch)` merges the patch with the current slot state and\n * re-emits the FULL merged state under `op: \"update\"`. `remove()`\n * emits one final `op: \"remove\"` with the\n * last-known state and flags the slot `removed: true`; subsequent\n * `update` / `remove` calls on the returned handle are no-ops.\n *\n * The handle's `id` is `slotId#subId` — stable across bars.\n *\n * @since 0.3\n * @stable\n * @example\n * // import {\n * // createDrawingHandle,\n * // } from \"@invinite-org/chartlang-runtime\";\n * // const h = createDrawingHandle(\n * // \"demo.chart.ts:5:13#0\",\n * // 0,\n * // \"line\",\n * // {\n * // kind: \"line\",\n * // anchors: [{ time: 0, price: 0 }, { time: 1, price: 1 }],\n * // style: {},\n * // },\n * // );\n * // h.update({ style: { color: \"#3b82f6\" } });\n * // h.remove();\n */\nexport function createDrawingHandle(\n slotId: string,\n subId: number,\n kind: DrawingKind,\n initialState: DrawingState,\n): DrawingHandle {\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (ctx === null) throw new Error(OUTSIDE_CTX_MESSAGE);\n\n const handleId = `${slotId}#${subId}`;\n const existing = ctx.drawingSlots.get(handleId);\n\n let slot: { handleId: string; kind: DrawingKind; state: DrawingState; removed: boolean };\n let op: \"create\" | \"update\";\n if (existing === undefined) {\n slot = { handleId, kind, state: initialState, removed: false };\n ctx.drawingSlots.set(handleId, slot);\n op = \"create\";\n } else {\n // Cross-bar re-entry. Merge initialState into the existing slot\n // (script-author may pass new anchors / style); resurrect if it\n // was previously removed.\n existing.state = mergeState(existing.state, initialState);\n existing.removed = false;\n slot = existing;\n op = \"update\";\n }\n\n emit(ctx, handleId, kind, op, slot.state);\n\n return {\n id: handleId,\n update(patch: Partial<DrawingState>): void {\n // `ACTIVE_RUNTIME_CONTEXT.current` can be null when the\n // host calls `handle.update(...)` outside a compute step\n // (e.g. from an async callback). Drop silently in that\n // case — the handle's slot still persists and the next\n // in-step `update` will fire.\n const liveCtx = ACTIVE_RUNTIME_CONTEXT.current;\n if (liveCtx === null) return;\n const s = liveCtx.drawingSlots.get(handleId);\n if (s === undefined || s.removed) return;\n s.state = mergeState(s.state, patch);\n emit(liveCtx, handleId, kind, \"update\", s.state);\n },\n remove(): void {\n const liveCtx = ACTIVE_RUNTIME_CONTEXT.current;\n if (liveCtx === null) return;\n const s = liveCtx.drawingSlots.get(handleId);\n if (s === undefined || s.removed) return;\n // Flag-before-emit is safe: capabilities are invariant\n // mid-run, so a previously-created handle's \"remove\" always\n // reaches `pushDrawing`. The slot stays flagged even if a\n // future drop path swallows the emission — a removed handle\n // must never re-emit.\n s.removed = true;\n emit(liveCtx, handleId, kind, \"remove\", s.state);\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../../../src/emit/draw/handle.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,OAAO,EACH,sBAAsB,GAGzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,mBAAmB,GAAG,2CAA2C,CAAC;AAExE,SAAS,UAAU,CAAC,IAAkB,EAAE,KAA4B;IAChE,4DAA4D;IAC5D,kEAAkE;IAClE,kEAAkE;IAClE,+DAA+D;IAC/D,iEAAiE;IACjE,iEAAiE;IACjE,4CAA4C;IAC5C,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,EAAE,I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0BAA0B;YAC1B,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;KACJ,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 { DrawingHandle, DrawingKind, DrawingState } from \"@invinite-org/chartlang-core\";\n\nimport {\n ACTIVE_RUNTIME_CONTEXT,\n type DrawingSlot,\n type RuntimeContext,\n} from \"../../runtimeContext.js\";\nimport { pushDrawing } from \"./pushDrawing.js\";\n\nconst OUTSIDE_CTX_MESSAGE = \"draw called outside an active script step\";\n\nfunction mergeState(prev: DrawingState, patch: Partial<DrawingState>): DrawingState {\n // Spread the patch over `prev` and force `kind` back to the\n // previous variant. A cross-variant patch from a script is a type\n // error at the script's callsite — the runtime defends against it\n // here so the runtime cannot accidentally emit a drift between\n // `drawingKind` and `state.kind`. The cast is safe because every\n // variant of `DrawingState` shares the shape `{ kind, ... }` and\n // discriminants stay pinned to `prev.kind`.\n return { ...prev, ...patch, kind: prev.kind } as DrawingState;\n}\n\n/**\n * Lift the presentation-only `z` (render-order key) **out** of a\n * drawing's `state.style` and hand it back to the caller, returning a\n * state with `z` removed from a **shallow clone** of `style` (the\n * caller's style object is never mutated). Every `draw.*` option bag\n * carries `z` via core's `ZOrdered` mixin, and the per-kind impls fold\n * that bag into `state.style`, so `z` arrives nested at `state.style.z`.\n * `z` is a **top-level** `DrawingEmission` field, not part of\n * `DrawingState`, so it must not ride the wire inside `state` — strip it\n * here. Returns `z: 0` (the omit-when-`0` default) for states with no\n * `style` (e.g. `group`) or no `z`, leaving the state object **untouched**\n * in that case so a no-`z` drawing stays byte-identical to the\n * pre-feature baseline.\n */\nfunction splitZ(state: DrawingState): { state: DrawingState; z: number } {\n if (!(\"style\" in state) || state.style === undefined) {\n return { state, z: 0 };\n }\n const style: { z?: number } = state.style;\n if (style.z === undefined) {\n return { state, z: 0 };\n }\n // Shallow-clone style with `z` removed — never mutate the caller's\n // object. `rest` is z-free, so the wire `state.style` carries no `z`.\n const { z, ...rest } = style;\n return { state: { ...state, style: rest } as DrawingState, z };\n}\n\nfunction emit(\n ctx: RuntimeContext,\n handleId: string,\n kind: DrawingKind,\n op: \"create\" | \"update\" | \"remove\",\n state: DrawingState,\n z: number,\n): void {\n pushDrawing(ctx, {\n kind: \"drawing\",\n handleId,\n drawingKind: kind,\n op,\n state,\n bar: ctx.barIndex(),\n time: ctx.stream.bar.time,\n // `z` is presentation-only and top-level (never inside `state`);\n // omit it when `0` so a no-`z` drawing is byte-identical to the\n // pre-feature baseline — mirrors `PlotEmission.xShift` / `.z`.\n ...(z === 0 ? {} : { z }),\n });\n}\n\n/**\n * Construct a {@link DrawingHandle} for `slotId#subId` in the active\n * runtime context. Allocates the slot in `ctx.drawingSlots` on the\n * first call (`op: \"create\"`); subsequent calls at the same callsite\n * across bars find the existing slot and emit `op: \"update\"` with the\n * full merged state.\n *\n * `update(patch)` merges the patch with the current slot state and\n * re-emits the FULL merged state under `op: \"update\"`. `remove()`\n * emits one final `op: \"remove\"` with the\n * last-known state and flags the slot `removed: true`; subsequent\n * `update` / `remove` calls on the returned handle are no-ops.\n *\n * The handle's `id` is `slotId#subId` — stable across bars.\n *\n * `z` is the presentation-only render-order key the `draw.*` opts bag\n * carried (core's `ZOrdered` mixin) folded into `state.style`. It is\n * {@link splitZ | lifted out} of `state.style` so it rides the wire as\n * the top-level {@link DrawingEmission.z} field, **never** inside\n * `DrawingState` (Task 3 forbids `z` in `state`), and is persisted on\n * the slot. An `update` that does not re-specify a non-zero `z` retains\n * the last value; a re-specified non-zero `z` overrides; `remove`\n * carries the last-known `z`.\n *\n * @since 0.3\n * @stable\n * @example\n * // import {\n * // createDrawingHandle,\n * // } from \"@invinite-org/chartlang-runtime\";\n * // const h = createDrawingHandle(\n * // \"demo.chart.ts:5:13#0\",\n * // 0,\n * // \"line\",\n * // {\n * // kind: \"line\",\n * // anchors: [{ time: 0, price: 0 }, { time: 1, price: 1 }],\n * // style: {},\n * // },\n * // );\n * // h.update({ style: { color: \"#3b82f6\" } });\n * // h.remove();\n */\nexport function createDrawingHandle(\n slotId: string,\n subId: number,\n kind: DrawingKind,\n initialState: DrawingState,\n): DrawingHandle {\n const ctx = ACTIVE_RUNTIME_CONTEXT.current;\n if (ctx === null) throw new Error(OUTSIDE_CTX_MESSAGE);\n\n const handleId = `${slotId}#${subId}`;\n const existing = ctx.drawingSlots.get(handleId);\n\n // Lift `z` out of `state.style` so it rides the emission top-level,\n // not inside `DrawingState`. The remaining `style` (z removed) is\n // what persists in the slot.\n const initial = splitZ(initialState);\n\n let slot: DrawingSlot;\n let op: \"create\" | \"update\";\n if (existing === undefined) {\n slot = { handleId, kind, state: initial.state, z: initial.z, removed: false };\n ctx.drawingSlots.set(handleId, slot);\n op = \"create\";\n } else {\n // Cross-bar re-entry. Merge initialState into the existing slot\n // (script-author may pass new anchors / style); resurrect if it\n // was previously removed. A re-specified `z` (non-default)\n // overrides the retained one; an omitted/`0` `z` keeps the last.\n existing.state = mergeState(existing.state, initial.state);\n if (initial.z !== 0) existing.z = initial.z;\n existing.removed = false;\n slot = existing;\n op = \"update\";\n }\n\n emit(ctx, handleId, kind, op, slot.state, slot.z);\n\n return {\n id: handleId,\n update(patch: Partial<DrawingState>): void {\n // `ACTIVE_RUNTIME_CONTEXT.current` can be null when the\n // host calls `handle.update(...)` outside a compute step\n // (e.g. from an async callback). Drop silently in that\n // case — the handle's slot still persists and the next\n // in-step `update` will fire.\n const liveCtx = ACTIVE_RUNTIME_CONTEXT.current;\n if (liveCtx === null) return;\n const s = liveCtx.drawingSlots.get(handleId);\n if (s === undefined || s.removed) return;\n // A patch may re-specify `z` inside `style`; split it out so\n // it never merges into `state.style`. A re-specified\n // non-default `z` overrides; an omitted/`0` `z` retains the\n // slot's last value.\n const split = splitZ(mergeState(s.state, patch));\n s.state = split.state;\n if (split.z !== 0) s.z = split.z;\n emit(liveCtx, handleId, kind, \"update\", s.state, s.z);\n },\n remove(): void {\n const liveCtx = ACTIVE_RUNTIME_CONTEXT.current;\n if (liveCtx === null) return;\n const s = liveCtx.drawingSlots.get(handleId);\n if (s === undefined || s.removed) return;\n // Flag-before-emit is safe: capabilities are invariant\n // mid-run, so a previously-created handle's \"remove\" always\n // reaches `pushDrawing`. The slot stays flagged even if a\n // future drop path swallows the emission — a removed handle\n // must never re-emit. `remove` carries the last-known `z`\n // (harmless — no render).\n s.removed = true;\n emit(liveCtx, handleId, kind, \"remove\", s.state, s.z);\n },\n };\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { DrawNamespace } from "@invinite-org/chartlang-core";
|
|
2
2
|
/**
|
|
3
|
-
* Runtime `draw` namespace.
|
|
4
|
-
*
|
|
5
|
-
* Phase 5
|
|
3
|
+
* Runtime `draw` namespace. Every one of the 63 `DrawingKind`s has a
|
|
4
|
+
* real per-kind impl wired into `KIND_IMPLS` (Task 18 brought the count
|
|
5
|
+
* to 61; Phase 5 added the viewport-anchored `table` kind; the
|
|
6
|
+
* fill-between feature added `fill-between`).
|
|
6
7
|
* the Proxy's `else` branch (fall-through to the core throwing-stub
|
|
7
8
|
* Proxy) is dead code at runtime — kept as defence-in-depth for
|
|
8
9
|
* unknown property access (e.g. JS code accessing a property name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/emit/draw/namespace.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/emit/draw/namespace.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAuJlE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,cAAc,EAAE,aAe3B,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { arrowMarker } from "./annotations/arrowMarker.js";
|
|
|
8
8
|
import { text } from "./annotations/text.js";
|
|
9
9
|
import { circle } from "./boxes/circle.js";
|
|
10
10
|
import { ellipse } from "./boxes/ellipse.js";
|
|
11
|
+
import { fillBetween } from "./boxes/fillBetween.js";
|
|
11
12
|
import { marker } from "./boxes/marker.js";
|
|
12
13
|
import { path } from "./boxes/path.js";
|
|
13
14
|
import { polyline } from "./boxes/polyline.js";
|
|
@@ -80,6 +81,7 @@ const KIND_IMPLS = {
|
|
|
80
81
|
circle,
|
|
81
82
|
ellipse,
|
|
82
83
|
path,
|
|
84
|
+
fillBetween,
|
|
83
85
|
marker,
|
|
84
86
|
// Task 8 — Curves
|
|
85
87
|
arc,
|
|
@@ -145,9 +147,10 @@ const KIND_IMPLS = {
|
|
|
145
147
|
};
|
|
146
148
|
const IMPL_KIND_NAMES = new Set(Object.keys(KIND_IMPLS));
|
|
147
149
|
/**
|
|
148
|
-
* Runtime `draw` namespace.
|
|
149
|
-
*
|
|
150
|
-
* Phase 5
|
|
150
|
+
* Runtime `draw` namespace. Every one of the 63 `DrawingKind`s has a
|
|
151
|
+
* real per-kind impl wired into `KIND_IMPLS` (Task 18 brought the count
|
|
152
|
+
* to 61; Phase 5 added the viewport-anchored `table` kind; the
|
|
153
|
+
* fill-between feature added `fill-between`).
|
|
151
154
|
* the Proxy's `else` branch (fall-through to the core throwing-stub
|
|
152
155
|
* Proxy) is dead code at runtime — kept as defence-in-depth for
|
|
153
156
|
* unknown property access (e.g. JS code accessing a property name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../src/emit/draw/namespace.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,IAAI,IAAI,cAAc,EAAE,MAAM,8BAA8B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,UAAU;IACV,WAAW;IACX,QAAQ;IACR,wBAAwB;IACxB,WAAW;IACX,YAAY;IACZ,SAAS;IACT,UAAU;IACV,YAAY;IACZ,iBAAiB;IACjB,OAAO;IACP,eAAe;IACf,UAAU;IACV,OAAO;IACP,uBAAuB;IACvB,SAAS;IACT,QAAQ;IACR,8BAA8B;IAC9B,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,WAAW;IACX,eAAe;IACf,kBAAkB;IAClB,0BAA0B;IAC1B,kBAAkB;IAClB,qBAAqB;IACrB,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;IACnB,WAAW;IACX,UAAU;IACV,QAAQ;IACR,uBAAuB;IACvB,KAAK;IACL,KAAK;IACL,8BAA8B;IAC9B,KAAK;CACC,CAAC;AAEX,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB,IAAI,KAAK,CAAC,UAAsC,EAAE;IAC3F,GAAG,CAAC,MAAM,EAAE,QAAQ;QAChB,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9B,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACzC,CAAC;QACD,uDAAuD;QACvD,yDAAyD;QACzD,8DAA8D;QAC9D,wDAAwD;QACxD,8DAA8D;QAC9D,4DAA4D;QAC5D,kCAAkC;QAClC,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;CACJ,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 { DrawNamespace } from \"@invinite-org/chartlang-core\";\nimport { draw as CORE_DRAW_STUB } from \"@invinite-org/chartlang-core\";\n\nimport { arrow } from \"./annotations/arrow.js\";\nimport { arrowMarkDown } from \"./annotations/arrowMarkDown.js\";\nimport { arrowMarkUp } from \"./annotations/arrowMarkUp.js\";\nimport { arrowMarker } from \"./annotations/arrowMarker.js\";\nimport { text } from \"./annotations/text.js\";\nimport { circle } from \"./boxes/circle.js\";\nimport { ellipse } from \"./boxes/ellipse.js\";\nimport { marker } from \"./boxes/marker.js\";\nimport { path } from \"./boxes/path.js\";\nimport { polyline } from \"./boxes/polyline.js\";\nimport { rectangle } from \"./boxes/rectangle.js\";\nimport { rotatedRectangle } from \"./boxes/rotatedRectangle.js\";\nimport { triangle } from \"./boxes/triangle.js\";\nimport { disjointChannel } from \"./channels/disjointChannel.js\";\nimport { flatTopBottom } from \"./channels/flatTopBottom.js\";\nimport { regressionTrend } from \"./channels/regressionTrend.js\";\nimport { trendChannel } from \"./channels/trendChannel.js\";\nimport { frame } from \"./containers/frame.js\";\nimport { group } from \"./containers/group.js\";\nimport { arc } from \"./curves/arc.js\";\nimport { brush } from \"./curves/brush.js\";\nimport { curve } from \"./curves/curve.js\";\nimport { doubleCurve } from \"./curves/doubleCurve.js\";\nimport { highlighter } from \"./curves/highlighter.js\";\nimport { pen } from \"./curves/pen.js\";\nimport { cyclicLines } from \"./cycles/cyclicLines.js\";\nimport { sineLine } from \"./cycles/sineLine.js\";\nimport { timeCycles } from \"./cycles/timeCycles.js\";\nimport { elliottCorrectionWave } from \"./elliott/elliottCorrectionWave.js\";\nimport { elliottDoubleCombo } from \"./elliott/elliottDoubleCombo.js\";\nimport { elliottImpulseWave } from \"./elliott/elliottImpulseWave.js\";\nimport { elliottTriangleWave } from \"./elliott/elliottTriangleWave.js\";\nimport { elliottTripleCombo } from \"./elliott/elliottTripleCombo.js\";\nimport { fibChannel } from \"./fibA/fibChannel.js\";\nimport { fibRetracement } from \"./fibA/fibRetracement.js\";\nimport { fibTimeZone } from \"./fibA/fibTimeZone.js\";\nimport { fibTrendExtension } from \"./fibA/fibTrendExtension.js\";\nimport { fibWedge } from \"./fibA/fibWedge.js\";\nimport { fibCircles } from \"./fibB/fibCircles.js\";\nimport { fibSpeedArcs } from \"./fibB/fibSpeedArcs.js\";\nimport { fibSpeedFan } from \"./fibB/fibSpeedFan.js\";\nimport { fibSpiral } from \"./fibB/fibSpiral.js\";\nimport { fibTrendTime } from \"./fibB/fibTrendTime.js\";\nimport { gannBox } from \"./gann/gannBox.js\";\nimport { gannFan } from \"./gann/gannFan.js\";\nimport { gannSquare } from \"./gann/gannSquare.js\";\nimport { gannSquareFixed } from \"./gann/gannSquareFixed.js\";\nimport { crossLine } from \"./lines/crossLine.js\";\nimport { horizontalLine } from \"./lines/horizontalLine.js\";\nimport { horizontalRay } from \"./lines/horizontalRay.js\";\nimport { line } from \"./lines/line.js\";\nimport { trendAngle } from \"./lines/trendAngle.js\";\nimport { verticalLine } from \"./lines/verticalLine.js\";\nimport { abcdPattern } from \"./patterns/abcdPattern.js\";\nimport { cypherPattern } from \"./patterns/cypherPattern.js\";\nimport { headAndShoulders } from \"./patterns/headAndShoulders.js\";\nimport { threeDrivesPattern } from \"./patterns/threeDrivesPattern.js\";\nimport { trianglePattern } from \"./patterns/trianglePattern.js\";\nimport { xabcdPattern } from \"./patterns/xabcdPattern.js\";\nimport { pitchfan } from \"./pitchforks/pitchfan.js\";\nimport { pitchfork } from \"./pitchforks/pitchfork.js\";\nimport { table } from \"./table/table.js\";\n\nconst KIND_IMPLS = {\n // Task 5 — Lines/Rays\n line,\n horizontalLine,\n horizontalRay,\n verticalLine,\n crossLine,\n trendAngle,\n // Task 6 — Boxes A\n rectangle,\n rotatedRectangle,\n triangle,\n polyline,\n // Task 7 — Boxes B\n circle,\n ellipse,\n path,\n marker,\n // Task 8 — Curves\n arc,\n curve,\n doubleCurve,\n // Task 8 — Freehand\n pen,\n highlighter,\n brush,\n // Task 9 — Annotations\n text,\n arrow,\n arrowMarker,\n arrowMarkUp,\n arrowMarkDown,\n // Task 10 — Channels\n trendChannel,\n flatTopBottom,\n disjointChannel,\n regressionTrend,\n // Task 11 — Fibonacci A\n fibRetracement,\n fibTrendExtension,\n fibChannel,\n fibTimeZone,\n fibWedge,\n // Task 12 — Fibonacci B\n fibSpeedFan,\n fibSpeedArcs,\n fibSpiral,\n fibCircles,\n fibTrendTime,\n // Task 13 — Gann\n gannBox,\n gannSquareFixed,\n gannSquare,\n gannFan,\n // Task 14 — Pitchforks\n pitchfork,\n pitchfan,\n // Task 15 — Harmonic Patterns\n xabcdPattern,\n cypherPattern,\n headAndShoulders,\n abcdPattern,\n trianglePattern,\n threeDrivesPattern,\n // Task 16 — Elliott Waves\n elliottImpulseWave,\n elliottCorrectionWave,\n elliottTriangleWave,\n elliottDoubleCombo,\n elliottTripleCombo,\n // Task 17 — Cycles\n cyclicLines,\n timeCycles,\n sineLine,\n // Task 18 — Containers\n group,\n frame,\n // Phase 5 — Viewport overlays\n table,\n} as const;\n\nconst IMPL_KIND_NAMES: ReadonlySet<string> = new Set(Object.keys(KIND_IMPLS));\n\n/**\n * Runtime `draw` namespace. After Task 18 every one of the 61\n * `DrawingKind`s has a real per-kind impl wired into `KIND_IMPLS`;\n * Phase 5 adds the viewport-anchored `table` kind.\n * the Proxy's `else` branch (fall-through to the core throwing-stub\n * Proxy) is dead code at runtime — kept as defence-in-depth for\n * unknown property access (e.g. JS code accessing a property name\n * outside the `DrawNamespace` type surface).\n *\n * Each per-kind impl is the compiler-injected overload — the\n * dispatch branches on `typeof arg1 === \"string\"` to discriminate the\n * slot-id-prefixed compiler form from the bare script-facing form\n * which always throws. This is the Phase-3 swap seam for the\n * `primitives.ts:draw` re-export, mirroring how `TA_REGISTRY` swaps\n * in Phase 2.\n *\n * @since 0.3\n * @stable\n * @example\n * import { draw } from \"@invinite-org/chartlang-runtime\";\n * // type S = typeof draw;\n * void draw;\n */\nexport const DRAW_NAMESPACE: DrawNamespace = new Proxy(KIND_IMPLS as unknown as DrawNamespace, {\n get(target, property): unknown {\n const name = String(property);\n if (IMPL_KIND_NAMES.has(name)) {\n return Reflect.get(target, property);\n }\n // After Task 18 every `DrawingKind` has a real impl in\n // `KIND_IMPLS` so this branch is unreachable through the\n // `DrawNamespace` type surface — it stays as defence-in-depth\n // for non-kind property access (e.g. JS code that reads\n // `draw[\"foo\"]` through a typed-erased view). Falling through\n // to core's throwing-stub keeps the failure mode consistent\n // with the pre-Task-18 behaviour.\n return Reflect.get(CORE_DRAW_STUB, property);\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../src/emit/draw/namespace.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,IAAI,IAAI,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC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AAK,CAAC,UAAsC,EAAE;IAC3F,GAAG,CAAC,MAAM,EAAE,QAAQ;QAChB,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9B,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACzC,CAAC;QACD,uDAAuD;QACvD,yDAAyD;QACzD,8DAA8D;QAC9D,wDAAwD;QACxD,8DAA8D;QAC9D,4DAA4D;QAC5D,kCAAkC;QAClC,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;CACJ,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 { DrawNamespace } from \"@invinite-org/chartlang-core\";\nimport { draw as CORE_DRAW_STUB } from \"@invinite-org/chartlang-core\";\n\nimport { arrow } from \"./annotations/arrow.js\";\nimport { arrowMarkDown } from \"./annotations/arrowMarkDown.js\";\nimport { arrowMarkUp } from \"./annotations/arrowMarkUp.js\";\nimport { arrowMarker } from \"./annotations/arrowMarker.js\";\nimport { text } from \"./annotations/text.js\";\nimport { circle } from \"./boxes/circle.js\";\nimport { ellipse } from \"./boxes/ellipse.js\";\nimport { fillBetween } from \"./boxes/fillBetween.js\";\nimport { marker } from \"./boxes/marker.js\";\nimport { path } from \"./boxes/path.js\";\nimport { polyline } from \"./boxes/polyline.js\";\nimport { rectangle } from \"./boxes/rectangle.js\";\nimport { rotatedRectangle } from \"./boxes/rotatedRectangle.js\";\nimport { triangle } from \"./boxes/triangle.js\";\nimport { disjointChannel } from \"./channels/disjointChannel.js\";\nimport { flatTopBottom } from \"./channels/flatTopBottom.js\";\nimport { regressionTrend } from \"./channels/regressionTrend.js\";\nimport { trendChannel } from \"./channels/trendChannel.js\";\nimport { frame } from \"./containers/frame.js\";\nimport { group } from \"./containers/group.js\";\nimport { arc } from \"./curves/arc.js\";\nimport { brush } from \"./curves/brush.js\";\nimport { curve } from \"./curves/curve.js\";\nimport { doubleCurve } from \"./curves/doubleCurve.js\";\nimport { highlighter } from \"./curves/highlighter.js\";\nimport { pen } from \"./curves/pen.js\";\nimport { cyclicLines } from \"./cycles/cyclicLines.js\";\nimport { sineLine } from \"./cycles/sineLine.js\";\nimport { timeCycles } from \"./cycles/timeCycles.js\";\nimport { elliottCorrectionWave } from \"./elliott/elliottCorrectionWave.js\";\nimport { elliottDoubleCombo } from \"./elliott/elliottDoubleCombo.js\";\nimport { elliottImpulseWave } from \"./elliott/elliottImpulseWave.js\";\nimport { elliottTriangleWave } from \"./elliott/elliottTriangleWave.js\";\nimport { elliottTripleCombo } from \"./elliott/elliottTripleCombo.js\";\nimport { fibChannel } from \"./fibA/fibChannel.js\";\nimport { fibRetracement } from \"./fibA/fibRetracement.js\";\nimport { fibTimeZone } from \"./fibA/fibTimeZone.js\";\nimport { fibTrendExtension } from \"./fibA/fibTrendExtension.js\";\nimport { fibWedge } from \"./fibA/fibWedge.js\";\nimport { fibCircles } from \"./fibB/fibCircles.js\";\nimport { fibSpeedArcs } from \"./fibB/fibSpeedArcs.js\";\nimport { fibSpeedFan } from \"./fibB/fibSpeedFan.js\";\nimport { fibSpiral } from \"./fibB/fibSpiral.js\";\nimport { fibTrendTime } from \"./fibB/fibTrendTime.js\";\nimport { gannBox } from \"./gann/gannBox.js\";\nimport { gannFan } from \"./gann/gannFan.js\";\nimport { gannSquare } from \"./gann/gannSquare.js\";\nimport { gannSquareFixed } from \"./gann/gannSquareFixed.js\";\nimport { crossLine } from \"./lines/crossLine.js\";\nimport { horizontalLine } from \"./lines/horizontalLine.js\";\nimport { horizontalRay } from \"./lines/horizontalRay.js\";\nimport { line } from \"./lines/line.js\";\nimport { trendAngle } from \"./lines/trendAngle.js\";\nimport { verticalLine } from \"./lines/verticalLine.js\";\nimport { abcdPattern } from \"./patterns/abcdPattern.js\";\nimport { cypherPattern } from \"./patterns/cypherPattern.js\";\nimport { headAndShoulders } from \"./patterns/headAndShoulders.js\";\nimport { threeDrivesPattern } from \"./patterns/threeDrivesPattern.js\";\nimport { trianglePattern } from \"./patterns/trianglePattern.js\";\nimport { xabcdPattern } from \"./patterns/xabcdPattern.js\";\nimport { pitchfan } from \"./pitchforks/pitchfan.js\";\nimport { pitchfork } from \"./pitchforks/pitchfork.js\";\nimport { table } from \"./table/table.js\";\n\nconst KIND_IMPLS = {\n // Task 5 — Lines/Rays\n line,\n horizontalLine,\n horizontalRay,\n verticalLine,\n crossLine,\n trendAngle,\n // Task 6 — Boxes A\n rectangle,\n rotatedRectangle,\n triangle,\n polyline,\n // Task 7 — Boxes B\n circle,\n ellipse,\n path,\n fillBetween,\n marker,\n // Task 8 — Curves\n arc,\n curve,\n doubleCurve,\n // Task 8 — Freehand\n pen,\n highlighter,\n brush,\n // Task 9 — Annotations\n text,\n arrow,\n arrowMarker,\n arrowMarkUp,\n arrowMarkDown,\n // Task 10 — Channels\n trendChannel,\n flatTopBottom,\n disjointChannel,\n regressionTrend,\n // Task 11 — Fibonacci A\n fibRetracement,\n fibTrendExtension,\n fibChannel,\n fibTimeZone,\n fibWedge,\n // Task 12 — Fibonacci B\n fibSpeedFan,\n fibSpeedArcs,\n fibSpiral,\n fibCircles,\n fibTrendTime,\n // Task 13 — Gann\n gannBox,\n gannSquareFixed,\n gannSquare,\n gannFan,\n // Task 14 — Pitchforks\n pitchfork,\n pitchfan,\n // Task 15 — Harmonic Patterns\n xabcdPattern,\n cypherPattern,\n headAndShoulders,\n abcdPattern,\n trianglePattern,\n threeDrivesPattern,\n // Task 16 — Elliott Waves\n elliottImpulseWave,\n elliottCorrectionWave,\n elliottTriangleWave,\n elliottDoubleCombo,\n elliottTripleCombo,\n // Task 17 — Cycles\n cyclicLines,\n timeCycles,\n sineLine,\n // Task 18 — Containers\n group,\n frame,\n // Phase 5 — Viewport overlays\n table,\n} as const;\n\nconst IMPL_KIND_NAMES: ReadonlySet<string> = new Set(Object.keys(KIND_IMPLS));\n\n/**\n * Runtime `draw` namespace. Every one of the 63 `DrawingKind`s has a\n * real per-kind impl wired into `KIND_IMPLS` (Task 18 brought the count\n * to 61; Phase 5 added the viewport-anchored `table` kind; the\n * fill-between feature added `fill-between`).\n * the Proxy's `else` branch (fall-through to the core throwing-stub\n * Proxy) is dead code at runtime — kept as defence-in-depth for\n * unknown property access (e.g. JS code accessing a property name\n * outside the `DrawNamespace` type surface).\n *\n * Each per-kind impl is the compiler-injected overload — the\n * dispatch branches on `typeof arg1 === \"string\"` to discriminate the\n * slot-id-prefixed compiler form from the bare script-facing form\n * which always throws. This is the Phase-3 swap seam for the\n * `primitives.ts:draw` re-export, mirroring how `TA_REGISTRY` swaps\n * in Phase 2.\n *\n * @since 0.3\n * @stable\n * @example\n * import { draw } from \"@invinite-org/chartlang-runtime\";\n * // type S = typeof draw;\n * void draw;\n */\nexport const DRAW_NAMESPACE: DrawNamespace = new Proxy(KIND_IMPLS as unknown as DrawNamespace, {\n get(target, property): unknown {\n const name = String(property);\n if (IMPL_KIND_NAMES.has(name)) {\n return Reflect.get(target, property);\n }\n // After Task 18 every `DrawingKind` has a real impl in\n // `KIND_IMPLS` so this branch is unreachable through the\n // `DrawNamespace` type surface — it stays as defence-in-depth\n // for non-kind property access (e.g. JS code that reads\n // `draw[\"foo\"]` through a typed-erased view). Falling through\n // to core's throwing-stub keeps the failure mode consistent\n // with the pre-Task-18 behaviour.\n return Reflect.get(CORE_DRAW_STUB, property);\n },\n});\n"]}
|
package/dist/emit/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { alert } from "./alert.js";
|
|
2
2
|
export { emitAlertCondition } from "./alertConditionEmission.js";
|
|
3
3
|
export { applyPlotOverride } from "./applyPlotOverride.js";
|
|
4
|
+
export { barcolor } from "./barcolor.js";
|
|
5
|
+
export { bgcolor } from "./bgcolor.js";
|
|
4
6
|
export { createDrawingHandle, draw, nextSubId, pushDrawing, resetSubIdCounters, } from "./draw/index.js";
|
|
5
7
|
export { pushAlert, pushAlertCondition, pushDiagnostic, pushLog, pushPlot, } from "./emissionsQueue.js";
|
|
6
8
|
export { hashStringStable } from "./hash.js";
|
package/dist/emit/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/emit/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACH,mBAAmB,EACnB,IAAI,EACJ,SAAS,EACT,WAAW,EACX,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,QAAQ,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/emit/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACH,mBAAmB,EACnB,IAAI,EACJ,SAAS,EACT,WAAW,EACX,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,QAAQ,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/emit/index.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
export { alert } from "./alert.js";
|
|
4
4
|
export { emitAlertCondition } from "./alertConditionEmission.js";
|
|
5
5
|
export { applyPlotOverride } from "./applyPlotOverride.js";
|
|
6
|
+
export { barcolor } from "./barcolor.js";
|
|
7
|
+
export { bgcolor } from "./bgcolor.js";
|
|
6
8
|
export { createDrawingHandle, draw, nextSubId, pushDrawing, resetSubIdCounters, } from "./draw/index.js";
|
|
7
9
|
export { pushAlert, pushAlertCondition, pushDiagnostic, pushLog, pushPlot, } from "./emissionsQueue.js";
|
|
8
10
|
export { hashStringStable } from "./hash.js";
|