@invinite-org/chartlang-compiler 1.2.0 → 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 +254 -0
- package/dist/analysis/extractAlertConditions.js.map +1 -1
- package/dist/analysis/extractCapabilities.js.map +1 -1
- package/dist/analysis/extractDependencyGraph.js.map +1 -1
- package/dist/analysis/extractInputs.js.map +1 -1
- package/dist/analysis/extractMaxLookback.d.ts +2 -1
- package/dist/analysis/extractMaxLookback.d.ts.map +1 -1
- package/dist/analysis/extractMaxLookback.js +90 -6
- package/dist/analysis/extractMaxLookback.js.map +1 -1
- package/dist/analysis/extractRequestedIntervals.d.ts +43 -1
- package/dist/analysis/extractRequestedIntervals.d.ts.map +1 -1
- package/dist/analysis/extractRequestedIntervals.js +95 -10
- package/dist/analysis/extractRequestedIntervals.js.map +1 -1
- package/dist/analysis/extractRequiresIntervals.js.map +1 -1
- package/dist/analysis/forbiddenConstructs.d.ts.map +1 -1
- package/dist/analysis/forbiddenConstructs.js +2 -41
- package/dist/analysis/forbiddenConstructs.js.map +1 -1
- package/dist/analysis/index.d.ts +3 -1
- package/dist/analysis/index.d.ts.map +1 -1
- package/dist/analysis/index.js +2 -1
- package/dist/analysis/index.js.map +1 -1
- package/dist/analysis/loopBounds.d.ts +91 -0
- package/dist/analysis/loopBounds.d.ts.map +1 -0
- package/dist/analysis/loopBounds.js +132 -0
- package/dist/analysis/loopBounds.js.map +1 -0
- package/dist/analysis/resolveIndexBound.d.ts +73 -0
- package/dist/analysis/resolveIndexBound.d.ts.map +1 -0
- package/dist/analysis/resolveIndexBound.js +336 -0
- package/dist/analysis/resolveIndexBound.js.map +1 -0
- package/dist/analysis/statefulCallInLoop.js.map +1 -1
- package/dist/analysis/structuralChecks.js.map +1 -1
- package/dist/analysis/validateLowerTfIntervals.js.map +1 -1
- package/dist/analysis/validateSecurityExpr.d.ts +25 -0
- package/dist/analysis/validateSecurityExpr.d.ts.map +1 -0
- package/dist/analysis/validateSecurityExpr.js +154 -0
- package/dist/analysis/validateSecurityExpr.js.map +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +13 -3
- package/dist/api.js.map +1 -1
- package/dist/bundle.js.map +1 -1
- package/dist/dependency/index.js.map +1 -1
- package/dist/dependency/resolveProducer.js.map +1 -1
- package/dist/diagnostics.d.ts +4 -2
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +2 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +7 -0
- package/dist/manifest.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +91 -14
- package/dist/program.js.map +1 -1
- package/dist/transformers/callsiteIdInjection.d.ts +21 -0
- package/dist/transformers/callsiteIdInjection.d.ts.map +1 -1
- package/dist/transformers/callsiteIdInjection.js +26 -3
- package/dist/transformers/callsiteIdInjection.js.map +1 -1
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/plotKindFromCallsite.js.map +1 -1
- package/dist/transformers/resolveCallee.d.ts +21 -0
- package/dist/transformers/resolveCallee.d.ts.map +1 -1
- package/dist/transformers/resolveCallee.js +14 -1
- package/dist/transformers/resolveCallee.js.map +1 -1
- package/dist/transformers/rewriteDependencyAccessors.js.map +1 -1
- package/dist/typesEmit.js.map +1 -1
- package/package.json +2 -2
package/dist/program.js
CHANGED
|
@@ -73,18 +73,54 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
73
73
|
readonly ohlc4: Price;
|
|
74
74
|
readonly hlcc4: Price;
|
|
75
75
|
readonly viewport?: BarViewport;
|
|
76
|
+
point(offset: number, price: Price): WorldPoint;
|
|
76
77
|
};
|
|
77
78
|
export type Series<T> = {
|
|
78
79
|
readonly current: T;
|
|
79
80
|
readonly [n: number]: T;
|
|
80
81
|
readonly length: number;
|
|
81
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* A bar price field — both a scalar \`Price\` (\`bar.close * 2\`,
|
|
85
|
+
* \`plot(bar.close)\`, \`ta.ema(bar.close, 12)\`) and an indexable
|
|
86
|
+
* \`Series<Price>\` (\`bar.close[1]\`). Mirrors core's \`PriceSeries\`.
|
|
87
|
+
*/
|
|
88
|
+
export type PriceSeries = Price & Series<Price>;
|
|
89
|
+
/** Volume counterpart of \`PriceSeries\`. Mirrors core's \`VolumeSeries\`. */
|
|
90
|
+
export type VolumeSeries = Volume & Series<Volume>;
|
|
91
|
+
/**
|
|
92
|
+
* A user-allocated, writable, indexable number series — the value half of
|
|
93
|
+
* \`state.series(init)\`. Both a writable scalar slot (\`s.value = x\`) and
|
|
94
|
+
* an indexable \`Series<number>\` (\`s[1]\`, \`s.current\`, \`+s\`). Mirrors
|
|
95
|
+
* core's \`NumberSeriesSlot\`.
|
|
96
|
+
*/
|
|
97
|
+
export type NumberSeriesSlot = MutableSlot<number> & Series<number>;
|
|
98
|
+
/**
|
|
99
|
+
* The \`compute\`-facing bar (\`ComputeContext.bar\`): like \`Bar\` but the
|
|
100
|
+
* OHLCV + derived fields are indexable \`PriceSeries\` / \`VolumeSeries\`.
|
|
101
|
+
* Mirrors core's \`BarSeries\`.
|
|
102
|
+
*/
|
|
103
|
+
export type BarSeries = Omit<
|
|
104
|
+
Bar,
|
|
105
|
+
"open" | "high" | "low" | "close" | "volume" | "hl2" | "hlc3" | "ohlc4" | "hlcc4"
|
|
106
|
+
> & {
|
|
107
|
+
readonly open: PriceSeries;
|
|
108
|
+
readonly high: PriceSeries;
|
|
109
|
+
readonly low: PriceSeries;
|
|
110
|
+
readonly close: PriceSeries;
|
|
111
|
+
readonly volume: VolumeSeries;
|
|
112
|
+
readonly hl2: PriceSeries;
|
|
113
|
+
readonly hlc3: PriceSeries;
|
|
114
|
+
readonly ohlc4: PriceSeries;
|
|
115
|
+
readonly hlcc4: PriceSeries;
|
|
116
|
+
};
|
|
82
117
|
/**
|
|
83
118
|
* A \`ta.*\` source-position argument. The runtime
|
|
84
119
|
* (\`packages/runtime/src/ta/lib/sourceValue.ts\`) accepts either a
|
|
85
120
|
* series reference or a scalar; the script-author surface mirrors
|
|
86
|
-
* that contract so \`ta.ema(bar.close, 12)\`
|
|
87
|
-
* \`ta.ema(other, 12)\` (series) both typecheck.
|
|
121
|
+
* that contract so \`ta.ema(bar.close, 12)\` and
|
|
122
|
+
* \`ta.ema(other, 12)\` (series) both typecheck — \`bar.close\` is now a
|
|
123
|
+
* \`PriceSeries\` (\`Price & Series<Price>\`), assignable as both.
|
|
88
124
|
*/
|
|
89
125
|
export type ScalarOrSeries = Series<number> | number;
|
|
90
126
|
export type SmaOpts = Readonly<{ offset?: number }>;
|
|
@@ -103,6 +139,8 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
103
139
|
export type CrossunderOpts = Readonly<{ offset?: number }>;
|
|
104
140
|
export type HighestOpts = Readonly<{ offset?: number }>;
|
|
105
141
|
export type LowestOpts = Readonly<{ offset?: number }>;
|
|
142
|
+
export type HighestbarsOpts = Readonly<{ offset?: number }>;
|
|
143
|
+
export type LowestbarsOpts = Readonly<{ offset?: number }>;
|
|
106
144
|
export type ChangeOpts = Readonly<{ length?: number; offset?: number }>;
|
|
107
145
|
export type PlotLineStyle = "line" | "step" | "dashed" | "circles" | "cross";
|
|
108
146
|
export type WmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
@@ -598,6 +636,12 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
598
636
|
nz(value: number, replacement?: number): number;
|
|
599
637
|
highest(source: ScalarOrSeries, length: number, opts?: HighestOpts): Series<number>;
|
|
600
638
|
lowest(source: ScalarOrSeries, length: number, opts?: LowestOpts): Series<number>;
|
|
639
|
+
highestbars(
|
|
640
|
+
source: ScalarOrSeries,
|
|
641
|
+
length: number,
|
|
642
|
+
opts?: HighestbarsOpts,
|
|
643
|
+
): Series<number>;
|
|
644
|
+
lowestbars(source: ScalarOrSeries, length: number, opts?: LowestbarsOpts): Series<number>;
|
|
601
645
|
change(source: ScalarOrSeries, opts?: ChangeOpts): Series<number>;
|
|
602
646
|
valuewhen(
|
|
603
647
|
condition: Series<boolean>,
|
|
@@ -778,6 +822,7 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
778
822
|
lineStyle?: LineStyle;
|
|
779
823
|
pane?: "overlay" | "new" | string;
|
|
780
824
|
style?: PlotOptsStyle;
|
|
825
|
+
z?: number;
|
|
781
826
|
}>;
|
|
782
827
|
export type HLineOpts = Readonly<{
|
|
783
828
|
color?: Color;
|
|
@@ -957,6 +1002,7 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
957
1002
|
int(init: number): MutableSlot<number>;
|
|
958
1003
|
bool(init: boolean): MutableSlot<boolean>;
|
|
959
1004
|
string(init: string): MutableSlot<string>;
|
|
1005
|
+
series(init: number): NumberSeriesSlot;
|
|
960
1006
|
tick: Readonly<{
|
|
961
1007
|
float(init: number): MutableSlot<number>;
|
|
962
1008
|
int(init: number): MutableSlot<number>;
|
|
@@ -1021,10 +1067,17 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1021
1067
|
readonly symbol: Series<string>;
|
|
1022
1068
|
readonly interval: Series<string>;
|
|
1023
1069
|
}>;
|
|
1024
|
-
export type
|
|
1070
|
+
export type SecurityExpr = (bar: SecurityBar) => Series<number> | number;
|
|
1071
|
+
// Declared as an interface (not a Readonly object type) so the two
|
|
1072
|
+
// security overloads survive. Readonly is a homomorphic mapped type, and
|
|
1073
|
+
// mapping over a member with multiple call signatures collapses it to a
|
|
1074
|
+
// single signature — which made the expression form fail type-check with
|
|
1075
|
+
// TS2554 ("Expected 1 arguments, but got 2").
|
|
1076
|
+
export interface RequestNamespace {
|
|
1025
1077
|
security(opts: RequestSecurityOpts): SecurityBar;
|
|
1078
|
+
security(opts: RequestSecurityOpts, expr: SecurityExpr): Series<number>;
|
|
1026
1079
|
lowerTf(opts: RequestLowerTfOpts): Series<ReadonlyArray<Bar>>;
|
|
1027
|
-
}
|
|
1080
|
+
}
|
|
1028
1081
|
export const request: RequestNamespace;
|
|
1029
1082
|
export function intervalToSeconds(d: IntervalDescriptor): number;
|
|
1030
1083
|
export type OutputDeclaration = Readonly<{
|
|
@@ -1036,6 +1089,11 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1036
1089
|
readonly kind: PlotKind;
|
|
1037
1090
|
readonly title?: string;
|
|
1038
1091
|
}>;
|
|
1092
|
+
export type SecurityExpressionDescriptor = Readonly<{
|
|
1093
|
+
readonly slotId: string;
|
|
1094
|
+
readonly interval: string;
|
|
1095
|
+
readonly paramName: string;
|
|
1096
|
+
}>;
|
|
1039
1097
|
export type DependencyDeclaration = Readonly<{
|
|
1040
1098
|
readonly localId: string;
|
|
1041
1099
|
readonly producerName: string;
|
|
@@ -1067,6 +1125,7 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1067
1125
|
readonly dependencies?: ReadonlyArray<DependencyDeclaration>;
|
|
1068
1126
|
readonly outputs?: ReadonlyArray<OutputDeclaration>;
|
|
1069
1127
|
readonly plots?: ReadonlyArray<PlotSlotDescriptor>;
|
|
1128
|
+
readonly securityExpressions?: ReadonlyArray<SecurityExpressionDescriptor>;
|
|
1070
1129
|
readonly exportName?: string;
|
|
1071
1130
|
readonly siblings?: ReadonlyArray<ScriptManifest>;
|
|
1072
1131
|
readonly isDrawn?: boolean;
|
|
@@ -1099,29 +1158,35 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1099
1158
|
WorldPoint,
|
|
1100
1159
|
WorldPoint,
|
|
1101
1160
|
];
|
|
1102
|
-
|
|
1161
|
+
// Render-order mixin — intersected into every \`draw.*\` opts bag in
|
|
1162
|
+
// lockstep with core's \`drawingStyle.ts\` \`ZOrdered\`. \`z\` is a
|
|
1163
|
+
// presentation-only render-order key (default 0, higher on top); it is
|
|
1164
|
+
// a type/contract addition only, so the shim just surfaces the optional
|
|
1165
|
+
// field for type-checking.
|
|
1166
|
+
export type ZOrdered = Readonly<{ z?: number }>;
|
|
1167
|
+
export type LineDrawStyle = ZOrdered & Readonly<{
|
|
1103
1168
|
color?: Color;
|
|
1104
1169
|
lineWidth?: number;
|
|
1105
1170
|
lineStyle?: LineStyle;
|
|
1106
1171
|
extendLeft?: boolean;
|
|
1107
1172
|
extendRight?: boolean;
|
|
1108
1173
|
}>;
|
|
1109
|
-
export type ShapeStyle = Readonly<{
|
|
1174
|
+
export type ShapeStyle = ZOrdered & Readonly<{
|
|
1110
1175
|
stroke?: Color;
|
|
1111
1176
|
fill?: Color;
|
|
1112
1177
|
lineWidth?: number;
|
|
1113
1178
|
lineStyle?: LineStyle;
|
|
1114
1179
|
fillAlpha?: number;
|
|
1115
1180
|
}>;
|
|
1116
|
-
export type HighlighterStyle = Readonly<{
|
|
1181
|
+
export type HighlighterStyle = ZOrdered & Readonly<{
|
|
1117
1182
|
color: Color;
|
|
1118
1183
|
alpha: number;
|
|
1119
1184
|
}>;
|
|
1120
|
-
export type BrushStyle = Readonly<{
|
|
1185
|
+
export type BrushStyle = ZOrdered & Readonly<{
|
|
1121
1186
|
stroke: Color;
|
|
1122
1187
|
fill: Color;
|
|
1123
1188
|
}>;
|
|
1124
|
-
export type TextOpts = Readonly<{
|
|
1189
|
+
export type TextOpts = ZOrdered & Readonly<{
|
|
1125
1190
|
color?: Color;
|
|
1126
1191
|
size?: "tiny" | "small" | "normal" | "large" | "huge";
|
|
1127
1192
|
halign?: "left" | "center" | "right";
|
|
@@ -1129,26 +1194,33 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1129
1194
|
bgColor?: Color;
|
|
1130
1195
|
}>;
|
|
1131
1196
|
export type ArrowOpts = LineDrawStyle & Readonly<{ label?: string }>;
|
|
1132
|
-
export type ArrowMarkerOpts = Readonly<{
|
|
1197
|
+
export type ArrowMarkerOpts = ZOrdered & Readonly<{
|
|
1133
1198
|
color?: Color;
|
|
1134
1199
|
text?: string;
|
|
1135
1200
|
}>;
|
|
1136
1201
|
export type PathOpts = LineDrawStyle & Readonly<{ closed?: boolean }>;
|
|
1137
|
-
export type
|
|
1202
|
+
export type FillBetweenStyle = ZOrdered & Readonly<{
|
|
1203
|
+
color?: Color;
|
|
1204
|
+
lineWidth?: number;
|
|
1205
|
+
lineStyle?: LineStyle;
|
|
1206
|
+
fill?: Color;
|
|
1207
|
+
fillAlpha?: number;
|
|
1208
|
+
}>;
|
|
1209
|
+
export type FibOpts = ZOrdered & Readonly<{
|
|
1138
1210
|
levels?: ReadonlyArray<number>;
|
|
1139
1211
|
showLabels?: boolean;
|
|
1140
1212
|
color?: Color;
|
|
1141
1213
|
extendLeft?: boolean;
|
|
1142
1214
|
extendRight?: boolean;
|
|
1143
1215
|
}>;
|
|
1144
|
-
export type RegressionTrendOpts = Readonly<{
|
|
1216
|
+
export type RegressionTrendOpts = ZOrdered & Readonly<{
|
|
1145
1217
|
source?: "close" | "open" | "high" | "low" | "hl2" | "hlc3" | "ohlc4" | "hlcc4";
|
|
1146
1218
|
stdevMultiplier?: number;
|
|
1147
1219
|
showUpperBand?: boolean;
|
|
1148
1220
|
showLowerBand?: boolean;
|
|
1149
1221
|
color?: Color;
|
|
1150
1222
|
}>;
|
|
1151
|
-
export type FrameOpts = Readonly<{
|
|
1223
|
+
export type FrameOpts = ZOrdered & Readonly<{
|
|
1152
1224
|
label?: string;
|
|
1153
1225
|
bgColor?: Color;
|
|
1154
1226
|
}>;
|
|
@@ -1197,6 +1269,11 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1197
1269
|
circle(centre: WorldPoint, radiusAnchor: WorldPoint, opts?: ShapeStyle): DrawingHandle;
|
|
1198
1270
|
ellipse(a: WorldPoint, b: WorldPoint, opts?: ShapeStyle): DrawingHandle;
|
|
1199
1271
|
path(anchors: ReadonlyArray<WorldPoint>, opts?: PathOpts): DrawingHandle;
|
|
1272
|
+
fillBetween(
|
|
1273
|
+
edgeA: ReadonlyArray<WorldPoint>,
|
|
1274
|
+
edgeB: ReadonlyArray<WorldPoint>,
|
|
1275
|
+
opts?: FillBetweenStyle,
|
|
1276
|
+
): DrawingHandle;
|
|
1200
1277
|
marker(
|
|
1201
1278
|
anchor: WorldPoint,
|
|
1202
1279
|
opts?: TextOpts & Readonly<{ text?: string; value?: number }>,
|
|
@@ -1270,7 +1347,7 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1270
1347
|
};
|
|
1271
1348
|
export const draw: DrawNamespace;
|
|
1272
1349
|
export type ComputeContext = {
|
|
1273
|
-
readonly bar:
|
|
1350
|
+
readonly bar: BarSeries;
|
|
1274
1351
|
readonly inputs: Readonly<Record<string, unknown>>;
|
|
1275
1352
|
readonly ta: TaNamespace;
|
|
1276
1353
|
readonly plot: typeof plot;
|
package/dist/program.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAE3D;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AACP,CAAC;AAED,SAAS,aAAa,CAAC,CAAS;IAC5B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACtD,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 ts from \"typescript\";\n\n/**\n * Virtual on-disk path the in-memory `@invinite-org/chartlang-core` ambient\n * declaration file is served from. Kept stable so the analysis passes can\n * detect callee declarations coming from core (vs. user-shadowed names).\n *\n * @since 0.1\n * @example\n * import { CORE_MODULE_PATH } from \"@invinite-org/chartlang-compiler/program\";\n * void CORE_MODULE_PATH;\n */\nexport const CORE_MODULE_PATH = \"/__chartlang__/core.d.ts\";\n\n/**\n * Ambient `.d.ts` shim covering the exact `@invinite-org/chartlang-core`\n * surface the compiler needs for symbol resolution. Lives in-memory so the\n * compiler is deterministic and host-machine independent — no on-disk\n * resolution of `workspace:*` packages required.\n *\n * The shim mirrors the runtime types; it does NOT carry the throw-sentinel\n * bodies the real callable holes ship. That doesn't matter — the compiler\n * only does static analysis; it never executes script source.\n */\nconst CORE_AMBIENT_SHIM = `\ndeclare module \"@invinite-org/chartlang-core\" {\n export type Time = number;\n export type Price = number;\n export type Volume = number;\n export type Color = string;\n export type GradientStop = Readonly<{ at: number; color: Color }>;\n export type LineStyle = \"solid\" | \"dashed\" | \"dotted\";\n export type AlertSeverity = \"info\" | \"warning\" | \"critical\";\n export type CapabilityId = \"indicators\" | \"drawings\" | \"alerts\" | \"alertConditions\";\n export type IntervalDescriptor = Readonly<{\n readonly value: string;\n readonly label: string;\n readonly group: string;\n readonly intervalSeconds?: number;\n }>;\n export type ValueFormat = \"price\" | \"volume\" | \"percent\" | \"compact\";\n export type ScaleAxis = \"price\" | \"left\" | \"right\" | \"new\";\n export type DrawingCounts = {\n readonly lines: number;\n readonly labels: number;\n readonly boxes: number;\n readonly polylines: number;\n readonly other: number;\n };\n export type ScriptOverrides = Readonly<{\n maxBarsBack?: number;\n format?: ValueFormat;\n precision?: number;\n scale?: ScaleAxis;\n requiresIntervals?: ReadonlyArray<string>;\n shortName?: string;\n }>;\n export type BarViewport = Readonly<{\n readonly fromTime: Time;\n readonly toTime: Time;\n }>;\n export type Bar = {\n readonly time: Time;\n readonly open: Price;\n readonly high: Price;\n readonly low: Price;\n readonly close: Price;\n readonly volume: Volume;\n readonly symbol: string;\n readonly interval: string;\n readonly hl2: Price;\n readonly hlc3: Price;\n readonly ohlc4: Price;\n readonly hlcc4: Price;\n readonly viewport?: BarViewport;\n point(offset: number, price: Price): WorldPoint;\n };\n export type Series<T> = {\n readonly current: T;\n readonly [n: number]: T;\n readonly length: number;\n };\n /**\n * A bar price field — both a scalar \\`Price\\` (\\`bar.close * 2\\`,\n * \\`plot(bar.close)\\`, \\`ta.ema(bar.close, 12)\\`) and an indexable\n * \\`Series<Price>\\` (\\`bar.close[1]\\`). Mirrors core's \\`PriceSeries\\`.\n */\n export type PriceSeries = Price & Series<Price>;\n /** Volume counterpart of \\`PriceSeries\\`. Mirrors core's \\`VolumeSeries\\`. */\n export type VolumeSeries = Volume & Series<Volume>;\n /**\n * A user-allocated, writable, indexable number series — the value half of\n * \\`state.series(init)\\`. Both a writable scalar slot (\\`s.value = x\\`) and\n * an indexable \\`Series<number>\\` (\\`s[1]\\`, \\`s.current\\`, \\`+s\\`). Mirrors\n * core's \\`NumberSeriesSlot\\`.\n */\n export type NumberSeriesSlot = MutableSlot<number> & Series<number>;\n /**\n * The \\`compute\\`-facing bar (\\`ComputeContext.bar\\`): like \\`Bar\\` but the\n * OHLCV + derived fields are indexable \\`PriceSeries\\` / \\`VolumeSeries\\`.\n * Mirrors core's \\`BarSeries\\`.\n */\n export type BarSeries = Omit<\n Bar,\n \"open\" | \"high\" | \"low\" | \"close\" | \"volume\" | \"hl2\" | \"hlc3\" | \"ohlc4\" | \"hlcc4\"\n > & {\n readonly open: PriceSeries;\n readonly high: PriceSeries;\n readonly low: PriceSeries;\n readonly close: PriceSeries;\n readonly volume: VolumeSeries;\n readonly hl2: PriceSeries;\n readonly hlc3: PriceSeries;\n readonly ohlc4: PriceSeries;\n readonly hlcc4: PriceSeries;\n };\n /**\n * A \\`ta.*\\` source-position argument. The runtime\n * (\\`packages/runtime/src/ta/lib/sourceValue.ts\\`) accepts either a\n * series reference or a scalar; the script-author surface mirrors\n * that contract so \\`ta.ema(bar.close, 12)\\` and\n * \\`ta.ema(other, 12)\\` (series) both typecheck — \\`bar.close\\` is now a\n * \\`PriceSeries\\` (\\`Price & Series<Price>\\`), assignable as both.\n */\n export type ScalarOrSeries = Series<number> | number;\n export type SmaOpts = Readonly<{ offset?: number }>;\n export type EmaOpts = Readonly<{ offset?: number }>;\n export type StdevOpts = Readonly<{ biased?: boolean; offset?: number }>;\n export type BbOpts = Readonly<{ multiplier?: number; offset?: number }>;\n export type RsiOpts = Readonly<{ offset?: number }>;\n export type MacdOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type AtrOpts = Readonly<{ offset?: number }>;\n export type CrossoverOpts = Readonly<{ offset?: number }>;\n export type CrossunderOpts = Readonly<{ offset?: number }>;\n export type HighestOpts = Readonly<{ offset?: number }>;\n export type LowestOpts = Readonly<{ offset?: number }>;\n export type HighestbarsOpts = Readonly<{ offset?: number }>;\n export type LowestbarsOpts = Readonly<{ offset?: number }>;\n export type ChangeOpts = Readonly<{ length?: number; offset?: number }>;\n export type PlotLineStyle = \"line\" | \"step\" | \"dashed\" | \"circles\" | \"cross\";\n export type WmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type VwmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type HmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type SmmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type DemaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type TemaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type KamaOpts = Readonly<{\n length?: number;\n fastLength?: number;\n slowLength?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type AlmaOpts = Readonly<{\n offset?: number;\n sigma?: number;\n barShift?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type LsmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type McginleyOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type MaTypeNoVolume = \"sma\" | \"ema\" | \"wma\" | \"smma\";\n export type MaRibbonOpts = Readonly<{\n lengths?: ReadonlyArray<number>;\n maType?: MaTypeNoVolume;\n offset?: number;\n outputs?: Readonly<Record<string, { lineStyle?: PlotLineStyle }>>;\n }>;\n export type MaRibbonResult = Readonly<Record<string, Series<number>>>;\n export type AoOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type CmoOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type MomentumOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type RocOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type CciOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type StochOpts = Readonly<{\n kLength?: number;\n kSmoothing?: number;\n dLength?: number;\n offset?: number;\n }>;\n export type WilliamsROpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type StochResult = Readonly<{\n k: Series<number>;\n d: Series<number>;\n }>;\n export type StochRsiOpts = Readonly<{\n rsiLength?: number;\n stochLength?: number;\n kSmoothing?: number;\n dSmoothing?: number;\n offset?: number;\n }>;\n export type StochRsiResult = Readonly<{\n k: Series<number>;\n d: Series<number>;\n }>;\n export type UltimateOscOpts = Readonly<{\n shortLength?: number;\n mediumLength?: number;\n longLength?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type CoppockOpts = Readonly<{\n roc1Length?: number;\n roc2Length?: number;\n wmaLength?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type PpoOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type PpoResult = Readonly<{\n ppo: Series<number>;\n signal: Series<number>;\n hist: Series<number>;\n }>;\n export type DpoOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type ConnorsRsiOpts = Readonly<{\n rsiLength?: number;\n streakLength?: number;\n rocLength?: number;\n offset?: number;\n }>;\n export type KstOpts = Readonly<{\n roc1Length?: number;\n roc2Length?: number;\n roc3Length?: number;\n roc4Length?: number;\n roc1Smooth?: number;\n roc2Smooth?: number;\n roc3Smooth?: number;\n roc4Smooth?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type KstResult = Readonly<{\n kst: Series<number>;\n signal: Series<number>;\n }>;\n export type FisherOpts = Readonly<{ offset?: number }>;\n export type FisherResult = Readonly<{\n fisher: Series<number>;\n trigger: Series<number>;\n }>;\n export type KlingerOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type KlingerResult = Readonly<{\n klinger: Series<number>;\n signal: Series<number>;\n }>;\n export type RvgiOpts = Readonly<{\n length?: number;\n offset?: number;\n }>;\n export type RvgiResult = Readonly<{\n rvgi: Series<number>;\n signal: Series<number>;\n }>;\n export type AroonOpts = Readonly<{\n offset?: number;\n outputs?: Readonly<Record<\"up\" | \"down\", { lineStyle?: PlotLineStyle }>>;\n }>;\n export type AroonOscOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type VolOpts = Readonly<{ offset?: number }>;\n export type VwapOpts = Readonly<{\n source?: \"hlc3\" | \"close\" | \"hl2\" | \"ohlc4\" | \"hlcc4\";\n offset?: number;\n }>;\n export type AnchoredVwapOpts = Readonly<{\n source?: \"hlc3\" | \"close\" | \"hl2\" | \"ohlc4\" | \"hlcc4\";\n offset?: number;\n }>;\n export type VisibleRangeVolumeProfileOpts = Readonly<{\n rowSize?: number;\n valueAreaPct?: number;\n offset?: number;\n bucketColor?: string;\n }>;\n export type VisibleRangeVolumeProfileResult = Readonly<{\n poc: Series<number>;\n valHigh: Series<number>;\n valLow: Series<number>;\n }>;\n export type AnchoredVolumeProfileOpts = Readonly<{\n anchor: Time;\n rowSize?: number;\n valueAreaPct?: number;\n offset?: number;\n bucketColor?: string;\n }>;\n export type SessionVolumeProfileOpts = Readonly<{\n rowSize?: number;\n valueAreaPct?: number;\n offset?: number;\n bucketColor?: string;\n sessionStart?: Time;\n }>;\n export type SessionVolumeProfileResult = Readonly<{\n poc: Series<number>;\n valHigh: Series<number>;\n valLow: Series<number>;\n buckets: ReadonlyArray<Readonly<{ price: number; volume: number; color?: string }>>;\n }>;\n export type FixedRangeVolumeProfileOpts = Readonly<{\n from: Time;\n to: Time;\n rowSize?: number;\n valueAreaPct?: number;\n offset?: number;\n bucketColor?: string;\n }>;\n export type FixedRangeVolumeProfileResult = Readonly<{\n poc: Series<number>;\n valHigh: Series<number>;\n valLow: Series<number>;\n buckets: ReadonlyArray<Readonly<{ price: number; volume: number; color?: string }>>;\n }>;\n export type AnchoredVolumeProfileResult = Readonly<{\n poc: Series<number>;\n valHigh: Series<number>;\n valLow: Series<number>;\n buckets: ReadonlyArray<Readonly<{ price: number; volume: number; color?: string }>>;\n }>;\n export type ObvOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type AdlOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type BopOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type CmfOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type ChaikinOscOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n offset?: number;\n }>;\n export type MfiOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type NetVolumeOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type PvoOpts = Readonly<{\n fastLength?: number;\n slowLength?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type PvoResult = Readonly<{\n pvo: Series<number>;\n signal: Series<number>;\n hist: Series<number>;\n }>;\n export type PvtOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type EomOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type NviOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type PviOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type PsarOpts = Readonly<{\n accelerationStart?: number;\n accelerationStep?: number;\n accelerationMax?: number;\n offset?: number;\n }>;\n export type PsarResult = Readonly<{\n sar: Series<number>;\n direction: Series<number>;\n }>;\n export type SupertrendOpts = Readonly<{\n length?: number;\n multiplier?: number;\n offset?: number;\n }>;\n export type SupertrendResult = Readonly<{\n line: Series<number>;\n direction: Series<number>;\n }>;\n export type ChandelierOpts = Readonly<{\n length?: number;\n multiplier?: number;\n offset?: number;\n }>;\n export type ChandelierResult = Readonly<{\n long: Series<number>;\n short: Series<number>;\n }>;\n export type ChandeKrollStopOpts = Readonly<{\n length?: number;\n multiplier?: number;\n smoothingLength?: number;\n offset?: number;\n }>;\n export type ChandeKrollStopResult = Readonly<{\n long: Series<number>;\n short: Series<number>;\n }>;\n export type WilliamsFractalOpts = Readonly<{\n length?: number;\n offset?: number;\n }>;\n export type WilliamsFractalResult = Readonly<{\n up: Series<number>;\n down: Series<number>;\n }>;\n export type ZigZagOpts = Readonly<{\n deviation?: number;\n depth?: number;\n offset?: number;\n }>;\n export type ZigZagResult = Readonly<{\n value: Series<number>;\n direction: Series<number>;\n }>;\n export type PivotsHighLowOpts = Readonly<{\n leftLength?: number;\n rightLength?: number;\n offset?: number;\n }>;\n export type PivotsHighLowResult = Readonly<{\n high: Series<number>;\n low: Series<number>;\n }>;\n export type PivotsStandardSystem = \"classic\" | \"fibonacci\" | \"camarilla\" | \"woodie\";\n export type PivotsStandardOpts = Readonly<{\n system?: PivotsStandardSystem;\n offset?: number;\n }>;\n export type PivotsStandardResult = Readonly<{\n pp: Series<number>;\n r1: Series<number>;\n s1: Series<number>;\n r2: Series<number>;\n s2: Series<number>;\n r3: Series<number>;\n s3: Series<number>;\n }>;\n export type VolatilityStopOpts = Readonly<{\n length?: number;\n multiplier?: number;\n offset?: number;\n }>;\n export type VolatilityStopResult = Readonly<{\n value: Series<number>;\n direction: Series<number>;\n }>;\n export type BbPercentBOpts = Readonly<{\n multiplier?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type BbwOpts = Readonly<{\n multiplier?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type DonchianOpts = Readonly<{\n offset?: number;\n outputs?: Readonly<\n Record<\"upper\" | \"middle\" | \"lower\", { lineStyle?: PlotLineStyle }>\n >;\n }>;\n export type DonchianResult = Readonly<{\n upper: Series<number>;\n middle: Series<number>;\n lower: Series<number>;\n }>;\n export type KeltnerOpts = Readonly<{\n length?: number;\n multiplier?: number;\n maType?: MaTypeNoVolume;\n offset?: number;\n outputs?: Readonly<\n Record<\"upper\" | \"middle\" | \"lower\", { lineStyle?: PlotLineStyle }>\n >;\n }>;\n export type KeltnerResult = Readonly<{\n upper: Series<number>;\n middle: Series<number>;\n lower: Series<number>;\n }>;\n export type EnvelopeOpts = Readonly<{\n length?: number;\n percent?: number;\n maType?: MaTypeNoVolume;\n offset?: number;\n }>;\n export type EnvelopeResult = Readonly<{\n upper: Series<number>;\n middle: Series<number>;\n lower: Series<number>;\n }>;\n export type ChopOpts = Readonly<{\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type HvOpts = Readonly<{\n annualisationFactor?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type RviOpts = Readonly<{\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type MassIndexOpts = Readonly<{\n emaLength?: number;\n sumLength?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type AroonResult = Readonly<{\n up: Series<number>;\n down: Series<number>;\n }>;\n export type BbResult = Readonly<{\n upper: Series<number>;\n middle: Series<number>;\n lower: Series<number>;\n }>;\n export type MacdResult = Readonly<{\n macd: Series<number>;\n signal: Series<number>;\n hist: Series<number>;\n }>;\n export type AdxOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type DmiOpts = Readonly<{\n offset?: number;\n outputs?: Readonly<\n Record<\"plusDi\" | \"minusDi\", { lineStyle?: PlotLineStyle }>\n >;\n }>;\n export type DmiResult = Readonly<{\n plusDi: Series<number>;\n minusDi: Series<number>;\n }>;\n export type TrixOpts = Readonly<{ offset?: number; signalLength?: number }>;\n export type TrixResult = Readonly<{\n trix: Series<number>;\n signal: Series<number>;\n }>;\n export type VortexOpts = Readonly<{ offset?: number }>;\n export type VortexResult = Readonly<{\n plus: Series<number>;\n minus: Series<number>;\n }>;\n export type TrendStrengthIndexOpts = Readonly<{\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type IchimokuOpts = Readonly<{\n conversionLength?: number;\n baseLength?: number;\n leadingSpanBLength?: number;\n displacement?: number;\n offset?: number;\n outputs?: Readonly<\n Record<\n \"tenkan\" | \"kijun\" | \"senkouA\" | \"senkouB\" | \"chikou\",\n { lineStyle?: PlotLineStyle }\n >\n >;\n }>;\n export type IchimokuResult = Readonly<{\n tenkan: Series<number>;\n kijun: Series<number>;\n senkouA: Series<number>;\n senkouB: Series<number>;\n chikou: Series<number>;\n }>;\n export type MedianOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type AdrOpts = Readonly<{\n length?: number;\n offset?: number;\n lineStyle?: PlotLineStyle;\n }>;\n export type UlcerIndexOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;\n export type PmoOpts = Readonly<{\n length?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type PmoResult = Readonly<{\n pmo: Series<number>;\n signal: Series<number>;\n }>;\n export type SmiOpts = Readonly<{\n kLength?: number;\n dLength?: number;\n smoothLength?: number;\n offset?: number;\n }>;\n export type SmiResult = Readonly<{\n smi: Series<number>;\n signal: Series<number>;\n }>;\n export type TsiOpts = Readonly<{\n shortLength?: number;\n longLength?: number;\n signalLength?: number;\n offset?: number;\n }>;\n export type TsiResult = Readonly<{\n tsi: Series<number>;\n signal: Series<number>;\n }>;\n export type ValuewhenOpts = Readonly<{ offset?: number }>;\n export type BarssinceOpts = Readonly<{ offset?: number }>;\n export type TaNamespace = {\n sma(source: ScalarOrSeries, length: number, opts?: SmaOpts): Series<number>;\n ema(source: ScalarOrSeries, length: number, opts?: EmaOpts): Series<number>;\n stdev(source: ScalarOrSeries, length: number, opts?: StdevOpts): Series<number>;\n bb(source: ScalarOrSeries, length: number, opts?: BbOpts): BbResult;\n rsi(source: ScalarOrSeries, length: number, opts?: RsiOpts): Series<number>;\n macd(source: ScalarOrSeries, opts?: MacdOpts): MacdResult;\n atr(length: number, opts?: AtrOpts): Series<number>;\n crossover(\n a: ScalarOrSeries,\n b: ScalarOrSeries,\n opts?: CrossoverOpts,\n ): Series<boolean>;\n crossunder(\n a: ScalarOrSeries,\n b: ScalarOrSeries,\n opts?: CrossunderOpts,\n ): Series<boolean>;\n nz(value: number, replacement?: number): number;\n highest(source: ScalarOrSeries, length: number, opts?: HighestOpts): Series<number>;\n lowest(source: ScalarOrSeries, length: number, opts?: LowestOpts): Series<number>;\n highestbars(\n source: ScalarOrSeries,\n length: number,\n opts?: HighestbarsOpts,\n ): Series<number>;\n lowestbars(source: ScalarOrSeries, length: number, opts?: LowestbarsOpts): Series<number>;\n change(source: ScalarOrSeries, opts?: ChangeOpts): Series<number>;\n valuewhen(\n condition: Series<boolean>,\n source: ScalarOrSeries,\n occurrence?: number,\n opts?: ValuewhenOpts,\n ): Series<number>;\n barssince(condition: Series<boolean>, opts?: BarssinceOpts): Series<number>;\n wma(source: ScalarOrSeries, length: number, opts?: WmaOpts): Series<number>;\n vwma(source: ScalarOrSeries, length: number, opts?: VwmaOpts): Series<number>;\n hma(source: ScalarOrSeries, length: number, opts?: HmaOpts): Series<number>;\n smma(source: ScalarOrSeries, length: number, opts?: SmmaOpts): Series<number>;\n dema(source: ScalarOrSeries, length: number, opts?: DemaOpts): Series<number>;\n tema(source: ScalarOrSeries, length: number, opts?: TemaOpts): Series<number>;\n kama(source: ScalarOrSeries, opts?: KamaOpts): Series<number>;\n alma(source: ScalarOrSeries, length: number, opts?: AlmaOpts): Series<number>;\n lsma(source: ScalarOrSeries, length: number, opts?: LsmaOpts): Series<number>;\n mcginley(source: ScalarOrSeries, length: number, opts?: McginleyOpts): Series<number>;\n maRibbon(source: ScalarOrSeries, opts?: MaRibbonOpts): MaRibbonResult;\n ao(opts?: AoOpts): Series<number>;\n cmo(source: ScalarOrSeries, length: number, opts?: CmoOpts): Series<number>;\n momentum(source: ScalarOrSeries, length: number, opts?: MomentumOpts): Series<number>;\n roc(source: ScalarOrSeries, length: number, opts?: RocOpts): Series<number>;\n cci(source: ScalarOrSeries, length: number, opts?: CciOpts): Series<number>;\n stoch(opts?: StochOpts): StochResult;\n stochRsi(source: ScalarOrSeries, opts?: StochRsiOpts): StochRsiResult;\n ultimateOsc(opts?: UltimateOscOpts): Series<number>;\n coppock(source: ScalarOrSeries, opts?: CoppockOpts): Series<number>;\n williamsR(length: number, opts?: WilliamsROpts): Series<number>;\n aroon(length: number, opts?: AroonOpts): AroonResult;\n aroonOsc(length: number, opts?: AroonOscOpts): Series<number>;\n median(source: ScalarOrSeries, length: number, opts?: MedianOpts): Series<number>;\n adr(opts?: AdrOpts): Series<number>;\n ulcerIndex(\n source: ScalarOrSeries,\n length: number,\n opts?: UlcerIndexOpts,\n ): Series<number>;\n pmo(source: ScalarOrSeries, opts?: PmoOpts): PmoResult;\n smi(opts?: SmiOpts): SmiResult;\n tsi(source: ScalarOrSeries, opts?: TsiOpts): TsiResult;\n vol(opts?: VolOpts): Series<number>;\n vwap(opts?: VwapOpts): Series<number>;\n anchoredVwap(anchorTime: number, opts?: AnchoredVwapOpts): Series<number>;\n anchoredVolumeProfile(opts: AnchoredVolumeProfileOpts): AnchoredVolumeProfileResult;\n fixedRangeVolumeProfile(opts: FixedRangeVolumeProfileOpts): FixedRangeVolumeProfileResult;\n sessionVolumeProfile(opts?: SessionVolumeProfileOpts): SessionVolumeProfileResult;\n visibleRangeVolumeProfile(\n opts?: VisibleRangeVolumeProfileOpts,\n ): VisibleRangeVolumeProfileResult;\n obv(opts?: ObvOpts): Series<number>;\n adl(opts?: AdlOpts): Series<number>;\n bop(opts?: BopOpts): Series<number>;\n cmf(length: number, opts?: CmfOpts): Series<number>;\n chaikinOsc(opts?: ChaikinOscOpts): Series<number>;\n mfi(length: number, opts?: MfiOpts): Series<number>;\n netVolume(opts?: NetVolumeOpts): Series<number>;\n pvo(opts?: PvoOpts): PvoResult;\n pvt(opts?: PvtOpts): Series<number>;\n eom(length: number, opts?: EomOpts): Series<number>;\n nvi(opts?: NviOpts): Series<number>;\n pvi(opts?: PviOpts): Series<number>;\n psar(opts?: PsarOpts): PsarResult;\n supertrend(opts?: SupertrendOpts): SupertrendResult;\n chandelier(opts?: ChandelierOpts): ChandelierResult;\n chandeKrollStop(opts?: ChandeKrollStopOpts): ChandeKrollStopResult;\n williamsFractal(opts?: WilliamsFractalOpts): WilliamsFractalResult;\n zigZag(opts?: ZigZagOpts): ZigZagResult;\n pivotsHighLow(opts?: PivotsHighLowOpts): PivotsHighLowResult;\n pivotsStandard(opts?: PivotsStandardOpts): PivotsStandardResult;\n volatilityStop(opts?: VolatilityStopOpts): VolatilityStopResult;\n bbPercentB(\n source: ScalarOrSeries,\n length: number,\n opts?: BbPercentBOpts,\n ): Series<number>;\n bbw(source: ScalarOrSeries, length: number, opts?: BbwOpts): Series<number>;\n donchian(length: number, opts?: DonchianOpts): DonchianResult;\n keltner(opts?: KeltnerOpts): KeltnerResult;\n envelope(source: ScalarOrSeries, opts?: EnvelopeOpts): EnvelopeResult;\n chop(length: number, opts?: ChopOpts): Series<number>;\n historicalVolatility(\n source: ScalarOrSeries,\n length: number,\n opts?: HvOpts,\n ): Series<number>;\n rvi(source: ScalarOrSeries, length: number, opts?: RviOpts): Series<number>;\n massIndex(opts?: MassIndexOpts): Series<number>;\n ppo(source: ScalarOrSeries, opts?: PpoOpts): PpoResult;\n dpo(source: ScalarOrSeries, length: number, opts?: DpoOpts): Series<number>;\n connorsRsi(source: ScalarOrSeries, opts?: ConnorsRsiOpts): Series<number>;\n kst(source: ScalarOrSeries, opts?: KstOpts): KstResult;\n fisher(length: number, opts?: FisherOpts): FisherResult;\n klinger(opts?: KlingerOpts): KlingerResult;\n rvgi(opts?: RvgiOpts): RvgiResult;\n adx(length: number, opts?: AdxOpts): Series<number>;\n dmi(length: number, opts?: DmiOpts): DmiResult;\n trix(source: ScalarOrSeries, length: number, opts?: TrixOpts): TrixResult;\n vortex(length: number, opts?: VortexOpts): VortexResult;\n trendStrengthIndex(\n source: ScalarOrSeries,\n length: number,\n opts?: TrendStrengthIndexOpts,\n ): Series<number>;\n ichimoku(opts?: IchimokuOpts): IchimokuResult;\n };\n export const ta: TaNamespace;\n export type PlotKind =\n | \"line\"\n | \"step-line\"\n | \"horizontal-line\"\n | \"histogram\"\n | \"area\"\n | \"filled-band\"\n | \"label\"\n | \"marker\"\n | \"shape\"\n | \"character\"\n | \"arrow\"\n | \"candle-override\"\n | \"bar-override\"\n | \"bg-color\"\n | \"bar-color\"\n | \"horizontal-histogram\";\n export type PlotGlyphShape =\n | \"circle\"\n | \"triangle-up\"\n | \"triangle-down\"\n | \"square\"\n | \"diamond\";\n export type PlotShapeGlyph = PlotGlyphShape | \"cross\" | \"xcross\" | \"flag\";\n export type PlotLocation = \"above\" | \"below\" | \"absolute\";\n export type HorizontalHistogramBucket = Readonly<{\n readonly price: number;\n readonly volume: number;\n readonly color?: Color;\n }>;\n export type PlotOptsStyle =\n | { readonly kind: \"line\" }\n | { readonly kind: \"step-line\" }\n | { readonly kind: \"horizontal-line\" }\n | { readonly kind: \"histogram\"; readonly baseline?: number }\n | {\n readonly kind: \"marker\";\n readonly shape: PlotGlyphShape;\n readonly size: number;\n }\n | {\n readonly kind: \"shape\";\n readonly shape: PlotShapeGlyph;\n readonly size: number;\n readonly location?: PlotLocation;\n }\n | {\n readonly kind: \"character\";\n readonly char: string;\n readonly size: number;\n readonly location?: PlotLocation;\n }\n | { readonly kind: \"arrow\"; readonly direction: \"up\" | \"down\"; readonly size: number }\n | {\n readonly kind: \"candle-override\";\n readonly bull: Color;\n readonly bear: Color;\n readonly doji?: Color;\n }\n | { readonly kind: \"bar-override\"; readonly color: Color }\n | { readonly kind: \"bg-color\"; readonly color: Color; readonly transp?: number }\n | { readonly kind: \"bar-color\"; readonly color: Color }\n | {\n readonly kind: \"horizontal-histogram\";\n readonly buckets: ReadonlyArray<HorizontalHistogramBucket>;\n };\n export type PlotOpts = Readonly<{\n color?: Color;\n title?: string;\n lineWidth?: number;\n lineStyle?: LineStyle;\n pane?: \"overlay\" | \"new\" | string;\n style?: PlotOptsStyle;\n z?: number;\n }>;\n export type HLineOpts = Readonly<{\n color?: Color;\n title?: string;\n lineWidth?: number;\n lineStyle?: LineStyle;\n pane?: \"overlay\" | \"new\" | string;\n }>;\n export function plot(value: number | Series<number>, opts?: PlotOpts): void;\n export function hline(price: number, opts?: HLineOpts): void;\n export type JsonValue =\n | null\n | boolean\n | number\n | string\n | ReadonlyArray<JsonValue>\n | { readonly [k: string]: JsonValue };\n export type StreamSnapshot = Readonly<{\n interval: string;\n headIndex: number;\n filled: number;\n buffers: Readonly<{\n time: ReadonlyArray<number | null>;\n open: ReadonlyArray<number | null>;\n high: ReadonlyArray<number | null>;\n low: ReadonlyArray<number | null>;\n close: ReadonlyArray<number | null>;\n volume: ReadonlyArray<number | null>;\n }>;\n }>;\n export type RunnerSnapshot = Readonly<{\n slots: Readonly<Record<string, JsonValue>>;\n }>;\n export type StateSnapshot = Readonly<{\n lastBarTime: number;\n streams: Readonly<Record<string, StreamSnapshot>>;\n savedAt: number;\n snapshotVersion: 1;\n primary: RunnerSnapshot;\n siblings?: Readonly<Record<string, RunnerSnapshot>>;\n dependencies?: Readonly<Record<string, RunnerSnapshot>>;\n }>;\n export type StateStoreKey = Readonly<{\n scriptHash: string;\n compilerVersion: string;\n apiVersion: 1;\n capabilitiesHash: string;\n symbol: string;\n mainInterval: string;\n requestedIntervals: ReadonlyArray<string>;\n }>;\n export type AlertOpts = Readonly<{\n severity?: AlertSeverity;\n meta?: Readonly<Record<string, JsonValue>>;\n }>;\n export function alert(message: string, opts?: AlertOpts): void;\n export type LogLevel = \"info\" | \"warn\" | \"error\";\n export type RuntimeNamespace = Readonly<{\n log: Readonly<{\n info(message: string, meta?: Readonly<Record<string, JsonValue>>): void;\n warn(message: string, meta?: Readonly<Record<string, JsonValue>>): void;\n error(message: string, meta?: Readonly<Record<string, JsonValue>>): void;\n }>;\n error(message: string): never;\n }>;\n export const runtime: RuntimeNamespace;\n export function fromGradient(t: number, stops: ReadonlyArray<GradientStop>): Color;\n export function withAlpha(c: Color, alpha: number): Color;\n export function rgb(r: number, g: number, b: number, alpha?: number): Color;\n export function hsl(h: number, s: number, l: number, alpha?: number): Color;\n export const color: Readonly<{\n aqua: Color;\n black: Color;\n blue: Color;\n fuchsia: Color;\n gray: Color;\n green: Color;\n lime: Color;\n maroon: Color;\n navy: Color;\n olive: Color;\n orange: Color;\n purple: Color;\n red: Color;\n silver: Color;\n teal: Color;\n white: Color;\n yellow: Color;\n fromGradient: typeof fromGradient;\n withAlpha: typeof withAlpha;\n rgb: typeof rgb;\n hsl: typeof hsl;\n }>;\n export type InputKind =\n | \"int\"\n | \"float\"\n | \"bool\"\n | \"string\"\n | \"enum\"\n | \"color\"\n | \"source\"\n | \"time\"\n | \"price\"\n | \"symbol\"\n | \"interval\"\n | \"external-series\";\n export type SourceField =\n | \"open\"\n | \"high\"\n | \"low\"\n | \"close\"\n | \"hl2\"\n | \"hlc3\"\n | \"ohlc4\"\n | \"hlcc4\";\n export type Schema<T> = Readonly<{ kind: \"external-series-schema\"; __brand?: T }>;\n type NumericInputOpts = Readonly<{ min?: number; max?: number; step?: number }>;\n type CommonInputDescriptor<K extends InputKind, T> = Readonly<{\n kind: K;\n defaultValue: T;\n title?: string;\n }>;\n export type IntDescriptor = CommonInputDescriptor<\"int\", number> & NumericInputOpts;\n export type FloatDescriptor = CommonInputDescriptor<\"float\", number> & NumericInputOpts;\n export type BoolDescriptor = CommonInputDescriptor<\"bool\", boolean>;\n export type StringDescriptor = CommonInputDescriptor<\"string\", string> & Readonly<{ multiline?: boolean }>;\n export type EnumDescriptor<T extends string> = CommonInputDescriptor<\"enum\", T> & Readonly<{ options: ReadonlyArray<T> }>;\n export type ColorDescriptor = CommonInputDescriptor<\"color\", Color>;\n export type SourceDescriptor = CommonInputDescriptor<\"source\", SourceField>;\n export type TimeDescriptor = CommonInputDescriptor<\"time\", number> & Readonly<{ pickFromChart?: boolean }>;\n export type PriceDescriptor = CommonInputDescriptor<\"price\", number>;\n export type SymbolDescriptor = CommonInputDescriptor<\"symbol\", string>;\n export type IntervalDescriptorInput = CommonInputDescriptor<\"interval\", string>;\n export type ExternalSeriesDescriptor<T> = Readonly<{\n kind: \"external-series\";\n name: string;\n schema: Schema<T>;\n title?: string;\n }>;\n export type InputDescriptor<T> =\n | IntDescriptor\n | FloatDescriptor\n | BoolDescriptor\n | StringDescriptor\n | EnumDescriptor<string>\n | ColorDescriptor\n | SourceDescriptor\n | TimeDescriptor\n | PriceDescriptor\n | SymbolDescriptor\n | IntervalDescriptorInput\n | ExternalSeriesDescriptor<T>;\n export const input: Readonly<{\n int(defaultValue: number, opts?: NumericInputOpts & Readonly<{ title?: string }>): IntDescriptor;\n float(defaultValue: number, opts?: NumericInputOpts & Readonly<{ title?: string }>): FloatDescriptor;\n bool(defaultValue: boolean, opts?: Readonly<{ title?: string }>): BoolDescriptor;\n string(defaultValue: string, opts?: Readonly<{ title?: string; multiline?: boolean }>): StringDescriptor;\n enum<T extends string>(\n defaultValue: T,\n options: ReadonlyArray<T>,\n opts?: Readonly<{ title?: string }>,\n ): EnumDescriptor<T>;\n color(defaultValue: Color, opts?: Readonly<{ title?: string }>): ColorDescriptor;\n source(defaultValue: SourceField, opts?: Readonly<{ title?: string }>): SourceDescriptor;\n time(defaultValue: Time, opts?: Readonly<{ title?: string; pickFromChart?: boolean }>): TimeDescriptor;\n price(defaultValue: Price, opts?: Readonly<{ title?: string }>): PriceDescriptor;\n symbol(defaultValue: string, opts?: Readonly<{ title?: string }>): SymbolDescriptor;\n interval(defaultValue: string, opts?: Readonly<{ title?: string }>): IntervalDescriptorInput;\n externalSeries<T>(args: Readonly<{ name: string; schema: Schema<T>; title?: string }>): ExternalSeriesDescriptor<T>;\n }>;\n export type InputSchema = Readonly<Record<string, InputDescriptor<unknown>>>;\n export type MutableSlot<T> = {\n value: T;\n };\n export type StateNamespace = Readonly<{\n float(init: number): MutableSlot<number>;\n int(init: number): MutableSlot<number>;\n bool(init: boolean): MutableSlot<boolean>;\n string(init: string): MutableSlot<string>;\n series(init: number): NumberSeriesSlot;\n tick: Readonly<{\n float(init: number): MutableSlot<number>;\n int(init: number): MutableSlot<number>;\n bool(init: boolean): MutableSlot<boolean>;\n string(init: string): MutableSlot<string>;\n }>;\n }>;\n export const state: StateNamespace;\n export type BarStateView = {\n readonly isfirst: boolean;\n readonly islast: boolean;\n readonly isnew: boolean;\n readonly ishistory: boolean;\n readonly isrealtime: boolean;\n readonly isconfirmed: boolean;\n };\n export const barstate: BarStateView;\n export type SymbolType =\n | \"equity\"\n | \"futures\"\n | \"forex\"\n | \"crypto\"\n | \"index\"\n | \"fund\"\n | \"bond\"\n | \"commodity\"\n | \"custom\";\n export type SymInfoView = {\n readonly ticker: string;\n readonly type: SymbolType;\n readonly mintick: number;\n readonly currency: string;\n readonly basecurrency: string;\n readonly exchange: string;\n readonly timezone: string;\n readonly session: string;\n readonly meta: Readonly<Record<string, JsonValue>>;\n };\n export const syminfo: SymInfoView;\n export type TimeframeView = {\n readonly period: string;\n readonly isintraday: boolean;\n readonly isdaily: boolean;\n readonly isweekly: boolean;\n readonly ismonthly: boolean;\n readonly inSeconds: number;\n };\n export const timeframe: TimeframeView;\n export type RequestSecurityOpts = Readonly<{ interval: string }>;\n export type RequestLowerTfOpts = Readonly<{ interval: string }>;\n export type SecurityBar = Readonly<{\n readonly time: Series<Time>;\n readonly open: Series<Price>;\n readonly high: Series<Price>;\n readonly low: Series<Price>;\n readonly close: Series<Price>;\n readonly volume: Series<Volume>;\n readonly hl2: Series<Price>;\n readonly hlc3: Series<Price>;\n readonly ohlc4: Series<Price>;\n readonly hlcc4: Series<Price>;\n readonly symbol: Series<string>;\n readonly interval: Series<string>;\n }>;\n export type SecurityExpr = (bar: SecurityBar) => Series<number> | number;\n // Declared as an interface (not a Readonly object type) so the two\n // security overloads survive. Readonly is a homomorphic mapped type, and\n // mapping over a member with multiple call signatures collapses it to a\n // single signature — which made the expression form fail type-check with\n // TS2554 (\"Expected 1 arguments, but got 2\").\n export interface RequestNamespace {\n security(opts: RequestSecurityOpts): SecurityBar;\n security(opts: RequestSecurityOpts, expr: SecurityExpr): Series<number>;\n lowerTf(opts: RequestLowerTfOpts): Series<ReadonlyArray<Bar>>;\n }\n export const request: RequestNamespace;\n export function intervalToSeconds(d: IntervalDescriptor): number;\n export type OutputDeclaration = Readonly<{\n readonly title: string;\n readonly kind: \"series-number\";\n }>;\n export type PlotSlotDescriptor = Readonly<{\n readonly slotId: string;\n readonly kind: PlotKind;\n readonly title?: string;\n }>;\n export type SecurityExpressionDescriptor = Readonly<{\n readonly slotId: string;\n readonly interval: string;\n readonly paramName: string;\n }>;\n export 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 export type ScriptManifest = {\n readonly apiVersion: 1;\n readonly kind: \"indicator\" | \"drawing\" | \"alert\" | \"alertCondition\";\n readonly name: string;\n readonly inputs: InputSchema;\n readonly capabilities: ReadonlyArray<CapabilityId>;\n readonly requestedIntervals: ReadonlyArray<string>;\n readonly userPickableInterval: boolean;\n readonly seriesCapacities: Readonly<Record<string, number>>;\n readonly maxLookback: number;\n readonly overlay?: boolean;\n readonly maxDrawings?: DrawingCounts;\n readonly maxBarsBack?: number;\n readonly format?: ValueFormat;\n readonly precision?: number;\n readonly scale?: ScaleAxis;\n readonly shortName?: string;\n readonly requiresIntervals?: ReadonlyArray<string>;\n readonly alertConditions?: ReadonlyArray<AlertConditionDefinition>;\n readonly dependencies?: ReadonlyArray<DependencyDeclaration>;\n readonly outputs?: ReadonlyArray<OutputDeclaration>;\n readonly plots?: ReadonlyArray<PlotSlotDescriptor>;\n readonly securityExpressions?: ReadonlyArray<SecurityExpressionDescriptor>;\n readonly exportName?: string;\n readonly siblings?: ReadonlyArray<ScriptManifest>;\n readonly isDrawn?: boolean;\n };\n export type AlertConditionDescriptor = Readonly<{\n title: string;\n description: string;\n defaultMessage: string;\n }>;\n export type AlertConditionDefinition = AlertConditionDescriptor & Readonly<{ id: string }>;\n export type Time = number;\n export type Price = number;\n export type WorldPoint = { readonly time: Time; readonly price: Price };\n export type AnchorPair = readonly [WorldPoint, WorldPoint];\n export type AnchorTriple = readonly [WorldPoint, WorldPoint, WorldPoint];\n export type AnchorQuad = readonly [WorldPoint, WorldPoint, WorldPoint, WorldPoint];\n export type AnchorQuint = readonly [\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n ];\n export type AnchorHept = readonly [\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n WorldPoint,\n ];\n // Render-order mixin — intersected into every \\`draw.*\\` opts bag in\n // lockstep with core's \\`drawingStyle.ts\\` \\`ZOrdered\\`. \\`z\\` is a\n // presentation-only render-order key (default 0, higher on top); it is\n // a type/contract addition only, so the shim just surfaces the optional\n // field for type-checking.\n export type ZOrdered = Readonly<{ z?: number }>;\n export type LineDrawStyle = ZOrdered & Readonly<{\n color?: Color;\n lineWidth?: number;\n lineStyle?: LineStyle;\n extendLeft?: boolean;\n extendRight?: boolean;\n }>;\n export type ShapeStyle = ZOrdered & Readonly<{\n stroke?: Color;\n fill?: Color;\n lineWidth?: number;\n lineStyle?: LineStyle;\n fillAlpha?: number;\n }>;\n export type HighlighterStyle = ZOrdered & Readonly<{\n color: Color;\n alpha: number;\n }>;\n export type BrushStyle = ZOrdered & Readonly<{\n stroke: Color;\n fill: Color;\n }>;\n export type TextOpts = ZOrdered & Readonly<{\n color?: Color;\n size?: \"tiny\" | \"small\" | \"normal\" | \"large\" | \"huge\";\n halign?: \"left\" | \"center\" | \"right\";\n valign?: \"top\" | \"middle\" | \"bottom\";\n bgColor?: Color;\n }>;\n export type ArrowOpts = LineDrawStyle & Readonly<{ label?: string }>;\n export type ArrowMarkerOpts = ZOrdered & Readonly<{\n color?: Color;\n text?: string;\n }>;\n export type PathOpts = LineDrawStyle & Readonly<{ closed?: boolean }>;\n export type FillBetweenStyle = ZOrdered & Readonly<{\n color?: Color;\n lineWidth?: number;\n lineStyle?: LineStyle;\n fill?: Color;\n fillAlpha?: number;\n }>;\n export type FibOpts = ZOrdered & Readonly<{\n levels?: ReadonlyArray<number>;\n showLabels?: boolean;\n color?: Color;\n extendLeft?: boolean;\n extendRight?: boolean;\n }>;\n export type RegressionTrendOpts = ZOrdered & Readonly<{\n source?: \"close\" | \"open\" | \"high\" | \"low\" | \"hl2\" | \"hlc3\" | \"ohlc4\" | \"hlcc4\";\n stdevMultiplier?: number;\n showUpperBand?: boolean;\n showLowerBand?: boolean;\n color?: Color;\n }>;\n export type FrameOpts = ZOrdered & Readonly<{\n label?: string;\n bgColor?: Color;\n }>;\n export type TablePosition =\n | \"top-left\" | \"top-center\" | \"top-right\"\n | \"middle-left\" | \"middle-center\" | \"middle-right\"\n | \"bottom-left\" | \"bottom-center\" | \"bottom-right\";\n export type TableCell = Readonly<{\n text: string;\n bgColor?: Color;\n textColor?: Color;\n textHalign?: \"left\" | \"center\" | \"right\";\n textValign?: \"top\" | \"middle\" | \"bottom\";\n textSize?: \"tiny\" | \"small\" | \"normal\" | \"large\" | \"huge\";\n }>;\n export type TableOpts = Readonly<{\n position: TablePosition;\n cells: ReadonlyArray<ReadonlyArray<TableCell>>;\n borderColor?: Color;\n borderWidth?: number;\n frame?: Readonly<{ color: Color; width: number }>;\n }>;\n export type DrawingHandle = Readonly<{\n readonly id: string;\n update(patch: Readonly<Record<string, unknown>>): void;\n remove(): void;\n }>;\n // Phase-3 draw surface — every kind listed in\n // \\`packages/core/src/draw/draw.ts:DrawNamespace\\`. The shim must\n // stay in lockstep; missing methods make valid scripts fail the\n // semantic-typecheck gate added in PLAN §5.2 step 1.\n export type DrawNamespace = {\n // Lines / Rays\n line(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n horizontalLine(price: Price, opts?: LineDrawStyle): DrawingHandle;\n horizontalRay(anchor: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n verticalLine(time: Time, opts?: LineDrawStyle): DrawingHandle;\n crossLine(anchor: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n trendAngle(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n // Boxes A\n rectangle(a: WorldPoint, b: WorldPoint, opts?: ShapeStyle): DrawingHandle;\n rotatedRectangle(anchors: AnchorQuad, opts?: ShapeStyle): DrawingHandle;\n triangle(anchors: AnchorTriple, opts?: ShapeStyle): DrawingHandle;\n polyline(anchors: ReadonlyArray<WorldPoint>, opts?: LineDrawStyle): DrawingHandle;\n // Boxes B\n circle(centre: WorldPoint, radiusAnchor: WorldPoint, opts?: ShapeStyle): DrawingHandle;\n ellipse(a: WorldPoint, b: WorldPoint, opts?: ShapeStyle): DrawingHandle;\n path(anchors: ReadonlyArray<WorldPoint>, opts?: PathOpts): DrawingHandle;\n fillBetween(\n edgeA: ReadonlyArray<WorldPoint>,\n edgeB: ReadonlyArray<WorldPoint>,\n opts?: FillBetweenStyle,\n ): DrawingHandle;\n marker(\n anchor: WorldPoint,\n opts?: TextOpts & Readonly<{ text?: string; value?: number }>,\n ): DrawingHandle;\n // Curves\n arc(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n curve(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n doubleCurve(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n // Freehand\n pen(anchors: ReadonlyArray<WorldPoint>, opts?: LineDrawStyle): DrawingHandle;\n highlighter(anchors: ReadonlyArray<WorldPoint>, opts: HighlighterStyle): DrawingHandle;\n brush(anchors: ReadonlyArray<WorldPoint>, opts: BrushStyle): DrawingHandle;\n // Annotations\n text(anchor: WorldPoint, body: string, opts?: TextOpts): DrawingHandle;\n arrow(a: WorldPoint, b: WorldPoint, opts?: ArrowOpts): DrawingHandle;\n arrowMarker(anchor: WorldPoint, opts?: ArrowMarkerOpts): DrawingHandle;\n arrowMarkUp(anchor: WorldPoint, opts?: ArrowMarkerOpts): DrawingHandle;\n arrowMarkDown(anchor: WorldPoint, opts?: ArrowMarkerOpts): DrawingHandle;\n // Channels\n trendChannel(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n flatTopBottom(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n disjointChannel(anchors: AnchorQuad, opts?: LineDrawStyle): DrawingHandle;\n regressionTrend(a: WorldPoint, b: WorldPoint, opts?: RegressionTrendOpts): DrawingHandle;\n // Fibonacci A\n fibRetracement(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibTrendExtension(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;\n fibChannel(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;\n fibTimeZone(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibWedge(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;\n // Fibonacci B\n fibSpeedFan(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibSpeedArcs(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibSpiral(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibCircles(a: WorldPoint, b: WorldPoint, opts?: FibOpts): DrawingHandle;\n fibTrendTime(anchors: AnchorTriple, opts?: FibOpts): DrawingHandle;\n // Gann\n gannBox(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n gannSquareFixed(anchor: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n gannSquare(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n gannFan(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n // Pitchforks\n pitchfork(\n anchors: AnchorTriple,\n opts?: LineDrawStyle & Readonly<{\n variant?: \"standard\" | \"schiff\" | \"modifiedSchiff\" | \"inside\";\n }>,\n ): DrawingHandle;\n pitchfan(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n // Harmonic Patterns\n xabcdPattern(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n cypherPattern(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n headAndShoulders(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n abcdPattern(anchors: AnchorQuad, opts?: LineDrawStyle): DrawingHandle;\n trianglePattern(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n threeDrivesPattern(anchors: AnchorHept, opts?: LineDrawStyle): DrawingHandle;\n // Elliott Waves\n elliottImpulseWave(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n elliottCorrectionWave(anchors: AnchorTriple, opts?: LineDrawStyle): DrawingHandle;\n elliottTriangleWave(anchors: AnchorQuint, opts?: LineDrawStyle): DrawingHandle;\n elliottDoubleCombo(anchors: AnchorHept, opts?: LineDrawStyle): DrawingHandle;\n elliottTripleCombo(anchors: AnchorHept, opts?: LineDrawStyle): DrawingHandle;\n // Cycles\n cyclicLines(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n timeCycles(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n sineLine(a: WorldPoint, b: WorldPoint, opts?: LineDrawStyle): DrawingHandle;\n // Containers\n group(childHandleIds: ReadonlyArray<string>): DrawingHandle;\n frame(a: WorldPoint, b: WorldPoint, opts?: FrameOpts): DrawingHandle;\n // Viewport overlays\n table(opts: TableOpts): DrawingHandle;\n };\n export const draw: DrawNamespace;\n export type ComputeContext = {\n readonly bar: BarSeries;\n readonly inputs: Readonly<Record<string, unknown>>;\n readonly ta: TaNamespace;\n readonly plot: typeof plot;\n readonly hline: typeof hline;\n readonly alert: typeof alert;\n readonly draw: DrawNamespace;\n readonly state: StateNamespace;\n readonly barstate: BarStateView;\n readonly syminfo: SymInfoView;\n readonly timeframe: TimeframeView;\n readonly request: RequestNamespace;\n readonly runtime: RuntimeNamespace;\n readonly signal?: (conditionId: string, fired: boolean) => void;\n };\n export type ComputeFn = (ctx: ComputeContext) => void;\n export type CompiledScriptObject = {\n readonly manifest: ScriptManifest;\n readonly compute: ComputeFn;\n readonly output: (name: string) => Series<number>;\n readonly withInputs: (\n overrides: Readonly<Record<string, unknown>>,\n ) => CompiledScriptObject;\n };\n export type CompiledScriptBundle = Readonly<{\n readonly primary: CompiledScriptObject;\n readonly siblings: ReadonlyArray<{\n readonly exportName: string;\n readonly compiled: CompiledScriptObject;\n }>;\n readonly dependencies: ReadonlyArray<{\n readonly localId: string;\n readonly compiled: CompiledScriptObject;\n readonly inputOverrides?: Readonly<Record<string, unknown>>;\n }>;\n }>;\n export function isCompiledScriptBundle(\n v: CompiledScriptObject | CompiledScriptBundle,\n ): v is CompiledScriptBundle;\n export type DefineIndicatorOpts = Readonly<{\n name: string;\n apiVersion: 1;\n overlay?: boolean;\n inputs?: InputSchema;\n compute: ComputeFn;\n maxDrawings?: DrawingCounts;\n outputs?: ReadonlyArray<OutputDeclaration>;\n }> & ScriptOverrides;\n export type DefineAlertOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n compute: ComputeFn;\n }> & Omit<ScriptOverrides, \"scale\" | \"format\" | \"precision\">;\n export type DefineAlertConditionOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n conditions: Readonly<Record<string, AlertConditionDescriptor>>;\n compute: ComputeFn;\n }>;\n export type DefineDrawingOpts = Readonly<{\n name: string;\n apiVersion: 1;\n inputs?: InputSchema;\n compute: ComputeFn;\n maxDrawings?: DrawingCounts;\n }> & Omit<ScriptOverrides, \"maxBarsBack\" | \"scale\">;\n export function defineIndicator(opts: DefineIndicatorOpts): CompiledScriptObject;\n export function defineAlert(opts: DefineAlertOpts): CompiledScriptObject;\n export function defineAlertCondition(opts: DefineAlertConditionOpts): CompiledScriptObject;\n export function defineDrawing(opts: DefineDrawingOpts): CompiledScriptObject;\n export type StatefulPrimitiveEntry = Readonly<{ name: string; slot: boolean }>;\n export const STATEFUL_PRIMITIVES: ReadonlySet<StatefulPrimitiveEntry>;\n export const STATEFUL_PRIMITIVES_BY_NAME: ReadonlyMap<string, StatefulPrimitiveEntry>;\n}\n\ndeclare module \"@invinite-org/chartlang-core/time\" {\n import type { Time } from \"@invinite-org/chartlang-core\";\n export type SessionType = \"regular\" | \"extended\";\n export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n export type SessionBounds = Readonly<{ startMs: number; endMs: number }>;\n export const session: Readonly<{\n regular(tz: string, t: Time): SessionBounds | null;\n extended(tz: string, t: Time): SessionBounds | null;\n isOpen(tz: string, t: Time, type: SessionType): boolean;\n }>;\n export function weekday(tz: string, t: Time): Weekday;\n export function nyDayKey(t: Time): string;\n export function nySessionBounds(t: Time): SessionBounds;\n export function weekKey(tz: string, t: Time): string;\n}\n`;\n\n/**\n * The compiler options the compiler pins for every script. ES2022 target,\n * Bundler module resolution, strict mode, no DOM. Scripts that depend on\n * browser globals fail the `forbiddenConstructs` pass on the global access\n * itself; the `lib` setting keeps the typechecker from accepting them in the\n * first place.\n *\n * @since 0.1\n * @example\n * import { COMPILER_OPTIONS } from \"@invinite-org/chartlang-compiler/program\";\n * void COMPILER_OPTIONS;\n */\nexport const COMPILER_OPTIONS: ts.CompilerOptions = {\n target: ts.ScriptTarget.ES2022,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n strict: true,\n noEmit: true,\n lib: [\"lib.es2022.d.ts\"],\n skipLibCheck: true,\n esModuleInterop: true,\n isolatedModules: true,\n verbatimModuleSyntax: false,\n allowJs: false,\n};\n\n/**\n * The return shape of `createProgramForSource`. Callers use `sourceFile` for\n * AST walks, `checker` for symbol resolution, and `program` as the root\n * handle when they need diagnostics from `tsc` itself (not used in Phase 1,\n * but kept on the type so Task 3 can plug in `program.getSemanticDiagnostics`\n * without an API change).\n *\n * @since 0.1\n * @example\n * // const { sourceFile, checker } = createProgramForSource(src, opts);\n * const shape: { sourceFile: unknown; checker: unknown; program: unknown } = {\n * sourceFile: null,\n * checker: null,\n * program: null,\n * };\n * void shape;\n */\nexport type ProgramForSource = Readonly<{\n program: ts.Program;\n sourceFile: ts.SourceFile;\n checker: ts.TypeChecker;\n}>;\n\n/**\n * Build a single-file TypeScript program for an in-memory `.chart.ts`\n * source. The synthetic file lives at `sourcePath` (POSIX, as the user\n * would write it); imports of `@invinite-org/chartlang-core` resolve\n * against the in-memory ambient shim. Returns the source file and a\n * configured type checker — the caller never sees the underlying compiler\n * host plumbing.\n *\n * @since 0.1\n * @example\n * // const { sourceFile, checker } = createProgramForSource(\n * // 'export default defineIndicator({ name: \"x\", apiVersion: 1, compute: () => {} });',\n * // { sourcePath: \"demo.chart.ts\" },\n * // );\n * const fn: typeof createProgramForSource = createProgramForSource;\n * void fn;\n */\nexport function createProgramForSource(\n source: string,\n opts: {\n readonly sourcePath: string;\n readonly chartImports?: ReadonlyArray<string>;\n },\n): ProgramForSource {\n const sourcePath = normalisePath(opts.sourcePath);\n const sourceFile = ts.createSourceFile(\n sourcePath,\n source,\n ts.ScriptTarget.ES2022,\n true,\n ts.ScriptKind.TS,\n );\n const shimFile = ts.createSourceFile(\n CORE_MODULE_PATH,\n CORE_AMBIENT_SHIM,\n ts.ScriptTarget.ES2022,\n true,\n ts.ScriptKind.TS,\n );\n\n // Synthesise an ambient declaration for every `.chart` / `.chart.ts`\n // import the caller pre-scanned. Each module exports a default\n // `CompiledScriptObject` so consumer-side typecheck passes; the\n // analysis pass walks the real `ProducerSnapshot` for output-title\n // validation (see `extractDependencyGraph.ts`).\n const chartImports = opts.chartImports ?? [];\n const chartShimPath = \"/__chartlang__/chart-imports.d.ts\";\n const VIRTUAL_FILE_SET = new Set<string>([sourcePath, CORE_MODULE_PATH]);\n let chartShimFile: ts.SourceFile | undefined;\n if (chartImports.length > 0) {\n VIRTUAL_FILE_SET.add(chartShimPath);\n const body = chartImports\n .map(\n (specifier) => `\ndeclare module ${JSON.stringify(specifier)} {\n import type { CompiledScriptObject } from \"@invinite-org/chartlang-core\";\n const value: CompiledScriptObject;\n export default value;\n}`,\n )\n .join(\"\\n\");\n chartShimFile = ts.createSourceFile(\n chartShimPath,\n body,\n ts.ScriptTarget.ES2022,\n true,\n ts.ScriptKind.TS,\n );\n }\n\n const fallbackHost = ts.createCompilerHost(COMPILER_OPTIONS, true);\n\n const host: ts.CompilerHost = {\n ...fallbackHost,\n getSourceFile(\n fileName,\n languageVersionOrOptions,\n onError,\n shouldCreateNewSourceFile,\n ): ts.SourceFile | undefined {\n if (fileName === sourcePath) return sourceFile;\n if (fileName === CORE_MODULE_PATH) return shimFile;\n if (fileName === chartShimPath && chartShimFile !== undefined) {\n return chartShimFile;\n }\n return fallbackHost.getSourceFile(\n fileName,\n languageVersionOrOptions,\n onError,\n shouldCreateNewSourceFile,\n );\n },\n fileExists(fileName) {\n return VIRTUAL_FILE_SET.has(fileName) || fallbackHost.fileExists(fileName);\n },\n };\n\n const rootNames: string[] = [sourcePath, CORE_MODULE_PATH];\n if (chartShimFile !== undefined) rootNames.push(chartShimPath);\n const program = ts.createProgram({\n rootNames,\n options: COMPILER_OPTIONS,\n host,\n });\n return Object.freeze({\n program,\n sourceFile,\n checker: program.getTypeChecker(),\n });\n}\n\nfunction normalisePath(p: string): string {\n return p.replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\");\n}\n"]}
|
|
@@ -20,6 +20,27 @@ export type InjectCallsiteIdsResult = Readonly<{
|
|
|
20
20
|
transformed: ts.SourceFile;
|
|
21
21
|
diagnostics: ReadonlyArray<CompileDiagnostic>;
|
|
22
22
|
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Mint the callsite slot id for a single call expression. The format is
|
|
25
|
+
* load-bearing — `<sourcePath>:<line>:<col>#<callIndex>` (§5.5), with 1-based
|
|
26
|
+
* line/column read from the call's start position in the **input** source
|
|
27
|
+
* file. `callIndex` is hardcoded to `0` for hand-written code (Phase 1
|
|
28
|
+
* reserves non-zero for future macros).
|
|
29
|
+
*
|
|
30
|
+
* Shared by `injectCallsiteIds` (which injects the literal as the leading
|
|
31
|
+
* argument) and the `request.security` expression analyser (which records
|
|
32
|
+
* the same id in `manifest.securityExpressions[*].slotId`) so the two never
|
|
33
|
+
* drift.
|
|
34
|
+
*
|
|
35
|
+
* @since 0.7
|
|
36
|
+
* @stable
|
|
37
|
+
* @example
|
|
38
|
+
* // const slotId = callsiteIdFor(sourceFile, callNode, "demo.chart.ts");
|
|
39
|
+
* // slotId === "demo.chart.ts:5:13#0"
|
|
40
|
+
* const fn: typeof callsiteIdFor = callsiteIdFor;
|
|
41
|
+
* void fn;
|
|
42
|
+
*/
|
|
43
|
+
export declare function callsiteIdFor(sourceFile: ts.SourceFile, call: ts.CallExpression, sourcePath: string): string;
|
|
23
44
|
/**
|
|
24
45
|
* Inject a `__slot` string-literal first argument into every stateful
|
|
25
46
|
* primitive call. Slot id format:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callsiteIdInjection.d.ts","sourceRoot":"","sources":["../../src/transformers/callsiteIdInjection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,KAAK,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAI7E;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC3C,WAAW,EAAE,EAAE,CAAC,UAAU,CAAC;IAC3B,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACjD,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAC7B,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE;IACF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACrE,QAAQ,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC;IACpD,QAAQ,CAAC,SAAS,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC7C,GACF,uBAAuB,
|
|
1
|
+
{"version":3,"file":"callsiteIdInjection.d.ts","sourceRoot":"","sources":["../../src/transformers/callsiteIdInjection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,KAAK,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAI7E;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC3C,WAAW,EAAE,EAAE,CAAC,UAAU,CAAC;IAC3B,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACjD,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CACzB,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,IAAI,EAAE,EAAE,CAAC,cAAc,EACvB,UAAU,EAAE,MAAM,GACnB,MAAM,CAIR;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAC7B,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE;IACF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACrE,QAAQ,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC;IACpD,QAAQ,CAAC,SAAS,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC7C,GACF,uBAAuB,CAiGzB"}
|
|
@@ -4,6 +4,31 @@ import ts from "typescript";
|
|
|
4
4
|
import { createDiagnostic } from "../diagnostics.js";
|
|
5
5
|
import { plotKindFromCallsite, readLiteralTitle } from "./plotKindFromCallsite.js";
|
|
6
6
|
import { resolveCalleeName, resolveCoreSymbolForElementAccess } from "./resolveCallee.js";
|
|
7
|
+
/**
|
|
8
|
+
* Mint the callsite slot id for a single call expression. The format is
|
|
9
|
+
* load-bearing — `<sourcePath>:<line>:<col>#<callIndex>` (§5.5), with 1-based
|
|
10
|
+
* line/column read from the call's start position in the **input** source
|
|
11
|
+
* file. `callIndex` is hardcoded to `0` for hand-written code (Phase 1
|
|
12
|
+
* reserves non-zero for future macros).
|
|
13
|
+
*
|
|
14
|
+
* Shared by `injectCallsiteIds` (which injects the literal as the leading
|
|
15
|
+
* argument) and the `request.security` expression analyser (which records
|
|
16
|
+
* the same id in `manifest.securityExpressions[*].slotId`) so the two never
|
|
17
|
+
* drift.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.7
|
|
20
|
+
* @stable
|
|
21
|
+
* @example
|
|
22
|
+
* // const slotId = callsiteIdFor(sourceFile, callNode, "demo.chart.ts");
|
|
23
|
+
* // slotId === "demo.chart.ts:5:13#0"
|
|
24
|
+
* const fn: typeof callsiteIdFor = callsiteIdFor;
|
|
25
|
+
* void fn;
|
|
26
|
+
*/
|
|
27
|
+
export function callsiteIdFor(sourceFile, call, sourcePath) {
|
|
28
|
+
const start = call.getStart(sourceFile);
|
|
29
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(start);
|
|
30
|
+
return `${sourcePath}:${line + 1}:${character + 1}#0`;
|
|
31
|
+
}
|
|
7
32
|
/**
|
|
8
33
|
* Inject a `__slot` string-literal first argument into every stateful
|
|
9
34
|
* primitive call. Slot id format:
|
|
@@ -53,9 +78,7 @@ export function injectCallsiteIds(sourceFile, checker, opts) {
|
|
|
53
78
|
const calleeName = resolveCalleeName(node, checker);
|
|
54
79
|
const entry = calleeName === null ? undefined : statefulByName.get(calleeName);
|
|
55
80
|
if (entry?.slot) {
|
|
56
|
-
const
|
|
57
|
-
const { line, character } = sourceFile.getLineAndCharacterOfPosition(start);
|
|
58
|
-
const slotId = `${sourcePath}:${line + 1}:${character + 1}#0`;
|
|
81
|
+
const slotId = callsiteIdFor(sourceFile, node, sourcePath);
|
|
59
82
|
const existing = slotsSeen.get(slotId);
|
|
60
83
|
if (existing !== undefined) {
|
|
61
84
|
diagnostics.push(createDiagnostic({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callsiteIdInjection.js","sourceRoot":"","sources":["../../src/transformers/callsiteIdInjection.ts"],"names":[],"mapp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CAAC,CACjB,CAAC;oBAClC,MAAM,gBAAgB,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,CAAgB;wBAC/D,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC;wBACtC,GAAG,gBAAgB;qBACtB,CAAC,CAAC;oBACH,MAAM,aAAa,GAAG,EAAE,CAAC,SAAS,CAC9B,IAAI,CAAC,UAAU,EACf,KAAK,EACL,EAAE,CAAC,YAAY,CACD,CAAC;oBACnB,OAAO,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAClC,IAAI,EACJ,aAAa,EACb,IAAI,CAAC,aAAa,EAClB,gBAAgB,CACnB,CAAC;gBACN,CAAC;YACL,CAAC;YACD,OAAO,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACnD,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,YAAY,CAAkB,CAAC;IACjF,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,CAAC,OAAO,EAAE,CAAC;IACjB,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,WAAW;QACX,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;KAClD,CAAC,CAAC;AACP,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 { PlotSlotDescriptor, StatefulPrimitiveEntry } from \"@invinite-org/chartlang-core\";\nimport ts from \"typescript\";\n\nimport { type CompileDiagnostic, createDiagnostic } from \"../diagnostics.js\";\nimport { plotKindFromCallsite, readLiteralTitle } from \"./plotKindFromCallsite.js\";\nimport { resolveCalleeName, resolveCoreSymbolForElementAccess } from \"./resolveCallee.js\";\n\n/**\n * Output of `injectCallsiteIds` — the rewritten source file plus any\n * diagnostics produced during the rewrite. Only `callsite-id-conflict`\n * surfaces here; every other transformer-related check lives in the\n * `analysis/` modules.\n *\n * @since 0.1\n * @example\n * // const { transformed, diagnostics } = injectCallsiteIds(src, checker, opts);\n * const shape: { transformed: unknown; diagnostics: ReadonlyArray<unknown> } = {\n * transformed: null,\n * diagnostics: [],\n * };\n * void shape;\n */\nexport type InjectCallsiteIdsResult = Readonly<{\n transformed: ts.SourceFile;\n diagnostics: ReadonlyArray<CompileDiagnostic>;\n}>;\n\n/**\n * Mint the callsite slot id for a single call expression. The format is\n * load-bearing — `<sourcePath>:<line>:<col>#<callIndex>` (§5.5), with 1-based\n * line/column read from the call's start position in the **input** source\n * file. `callIndex` is hardcoded to `0` for hand-written code (Phase 1\n * reserves non-zero for future macros).\n *\n * Shared by `injectCallsiteIds` (which injects the literal as the leading\n * argument) and the `request.security` expression analyser (which records\n * the same id in `manifest.securityExpressions[*].slotId`) so the two never\n * drift.\n *\n * @since 0.7\n * @stable\n * @example\n * // const slotId = callsiteIdFor(sourceFile, callNode, \"demo.chart.ts\");\n * // slotId === \"demo.chart.ts:5:13#0\"\n * const fn: typeof callsiteIdFor = callsiteIdFor;\n * void fn;\n */\nexport function callsiteIdFor(\n sourceFile: ts.SourceFile,\n call: ts.CallExpression,\n sourcePath: string,\n): string {\n const start = call.getStart(sourceFile);\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(start);\n return `${sourcePath}:${line + 1}:${character + 1}#0`;\n}\n\n/**\n * Inject a `__slot` string-literal first argument into every stateful\n * primitive call. Slot id format:\n * `<sourcePath>:<line>:<col>#<callIndex>`. `callIndex` is hardcoded to `0`\n * for hand-written code (Phase 1 reserves non-zero for future macros).\n *\n * The transformer is a pure rewrite — input nodes are never mutated. Lines\n * and columns are 1-based and read from the **input** source file before\n * any rewrite happens. Duplicate ids at the same `(line, col)` (impossible\n * in hand-written TS but reachable by future macros) trigger a\n * `callsite-id-conflict` diagnostic; only the first call at the duplicated\n * position gets the slot.\n *\n * @since 0.1\n * @example\n * // Input: ta.ema(close, 20)\n * // Output: ta.ema(\"demo.chart.ts:5:13#0\", close, 20)\n * const fn: typeof injectCallsiteIds = injectCallsiteIds;\n * void fn;\n */\nexport function injectCallsiteIds(\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n opts: {\n readonly sourcePath: string;\n readonly statefulByName: ReadonlyMap<string, StatefulPrimitiveEntry>;\n readonly slotsSeen?: Map<string, ts.CallExpression>;\n readonly plotSlots?: PlotSlotDescriptor[];\n },\n): InjectCallsiteIdsResult {\n const { sourcePath, statefulByName } = opts;\n const plotSlots = opts.plotSlots;\n const slotsSeen = opts.slotsSeen ?? new Map<string, ts.CallExpression>();\n const diagnostics: CompileDiagnostic[] = [];\n\n const factory: ts.TransformerFactory<ts.SourceFile> = (context) => {\n const visit: ts.Visitor = (node) => {\n if (ts.isCallExpression(node)) {\n // Element-access calls (`ta[\"ema\"](...)`, `alert?.[chan](...)`)\n // bypass slot-id injection because the property name is not\n // statically known. Detecting these explicitly turns the\n // silent-state-corruption footgun into a compile-time error.\n if (ts.isElementAccessExpression(node.expression)) {\n const coreName = resolveCoreSymbolForElementAccess(node.expression, checker);\n if (coreName !== null) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"stateful-call-element-access\",\n message: `Element-access calls on the \\`${coreName}\\` namespace bypass callsite-id injection. Use the property-access form (\\`${coreName}.<name>(...)\\`).`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n return ts.visitEachChild(node, visit, context);\n }\n }\n const calleeName = resolveCalleeName(node, checker);\n const entry = calleeName === null ? undefined : statefulByName.get(calleeName);\n if (entry?.slot) {\n const slotId = callsiteIdFor(sourceFile, node, sourcePath);\n const existing = slotsSeen.get(slotId);\n if (existing !== undefined) {\n diagnostics.push(\n createDiagnostic({\n severity: \"error\",\n code: \"callsite-id-conflict\",\n message: `Two stateful calls share the same slot id \"${slotId}\".`,\n file: sourcePath,\n node,\n sourceFile,\n }),\n );\n return ts.visitEachChild(node, visit, context);\n }\n slotsSeen.set(slotId, node);\n if (\n plotSlots !== undefined &&\n (calleeName === \"plot\" || calleeName === \"hline\")\n ) {\n const optsArg = node.arguments[1];\n // best-effort dynamic-kind fallback: a callsite whose\n // `style` is non-literal is still listed as \"line\".\n const kind = plotKindFromCallsite(calleeName, optsArg) ?? \"line\";\n const title = readLiteralTitle(optsArg);\n plotSlots.push(\n Object.freeze({\n slotId,\n kind,\n ...(title === undefined ? {} : { title }),\n }),\n );\n }\n const visitedArguments = node.arguments.map((argument) =>\n ts.visitNode(argument, visit, ts.isExpression),\n ) as ReadonlyArray<ts.Expression>;\n const updatedArguments = ts.factory.createNodeArray<ts.Expression>([\n ts.factory.createStringLiteral(slotId),\n ...visitedArguments,\n ]);\n const visitedCallee = ts.visitNode(\n node.expression,\n visit,\n ts.isExpression,\n ) as ts.Expression;\n return ts.factory.updateCallExpression(\n node,\n visitedCallee,\n node.typeArguments,\n updatedArguments,\n );\n }\n }\n return ts.visitEachChild(node, visit, context);\n };\n return (file) => ts.visitNode(file, visit, ts.isSourceFile) as ts.SourceFile;\n };\n\n const result = ts.transform(sourceFile, [factory]);\n const transformed = result.transformed[0];\n result.dispose();\n return Object.freeze({\n transformed,\n diagnostics: Object.freeze(diagnostics.slice()),\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,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 { resolveCalleeName } from \"./resolveCallee.js\";\nexport { injectCallsiteIds } from \"./callsiteIdInjection.js\";\nexport type { InjectCallsiteIdsResult } from \"./callsiteIdInjection.js\";\nexport { rewriteDependencyAccessors } from \"./rewriteDependencyAccessors.js\";\nexport type { RewriteDependencyAccessorsResult } from \"./rewriteDependencyAccessors.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plotKindFromCallsite.js","sourceRoot":"","sources":["../../src/transformers/plotKindFromCallsite.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAG/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,UAAU,GAA0B,IAAI,GAAG,CAAW;IACxD,MAAM;IACN,WAAW;IACX,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,aAAa;IACb,OAAO;IACP,QAAQ;IACR,OAAO;IACP,WAAW;IACX,OAAO;IACP,iBAAiB;IACjB,cAAc;IACd,UAAU;IACV,WAAW;IACX,sBAAsB;CACzB,CAAC,CAAC;AAEH,SAAS,UAAU,CAAC,KAAa;IAC7B,OAAQ,UAAkC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,YAAY,CACjB,GAA+B,EAC/B,IAAY;IAEZ,KAAK,MAAM,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;QACpC,IACI,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC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AS,CAAC;IAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC;IACpC,OAAO,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9D,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 { PlotKind } from \"@invinite-org/chartlang-core\";\nimport ts from \"typescript\";\n\nconst PLOT_KINDS: ReadonlySet<PlotKind> = new Set<PlotKind>([\n \"line\",\n \"step-line\",\n \"horizontal-line\",\n \"histogram\",\n \"area\",\n \"filled-band\",\n \"label\",\n \"marker\",\n \"shape\",\n \"character\",\n \"arrow\",\n \"candle-override\",\n \"bar-override\",\n \"bg-color\",\n \"bar-color\",\n \"horizontal-histogram\",\n]);\n\nfunction isPlotKind(value: string): value is PlotKind {\n return (PLOT_KINDS as ReadonlySet<string>).has(value);\n}\n\nfunction findProperty(\n obj: ts.ObjectLiteralExpression,\n name: string,\n): ts.PropertyAssignment | undefined {\n for (const property of obj.properties) {\n if (\n ts.isPropertyAssignment(property) &&\n ts.isIdentifier(property.name) &&\n property.name.text === name\n ) {\n return property;\n }\n }\n return undefined;\n}\n\n/**\n * Derive the statically-known {@link PlotKind} for a plotting callsite from\n * its callee name and opts argument. The chartlang plot surface has no\n * `plot.*` member API — the kind is selected at the callsite via the opts\n * object literal's `style.kind` property (mirrored by the runtime's\n * `buildStyle`). Returns:\n *\n * - `\"horizontal-line\"` for `hline`.\n * - `\"line\"` for a bare `plot` with no `style` (no opts, opts without\n * `style`, or a non-object opts).\n * - the literal `style.kind` value for `plot(x, { style: { kind: \"<lit>\" } })`\n * when it is a string literal naming a `PlotKind` member.\n * - `undefined` when the kind is not statically determinable: a dynamic\n * `style` (`{ style: someVar }`), a dynamic `kind` (`{ style: { kind:\n * someVar } }`), or a string literal that is not a `PlotKind` member.\n * The caller falls back to `\"line\"` (best-effort) so the slot is still\n * listed.\n *\n * @since 0.8\n * @example\n * // const kind = plotKindFromCallsite(\"plot\", optsObjectLiteralNode);\n * // kind === \"histogram\" | \"line\" | undefined | ...\n * const fn: typeof plotKindFromCallsite = plotKindFromCallsite;\n * void fn;\n */\nexport function plotKindFromCallsite(\n calleeName: string,\n optsArg: ts.Expression | undefined,\n): PlotKind | undefined {\n if (calleeName === \"hline\") return \"horizontal-line\";\n if (calleeName !== \"plot\") return undefined;\n if (optsArg === undefined || !ts.isObjectLiteralExpression(optsArg)) return \"line\";\n const styleProp = findProperty(optsArg, \"style\");\n if (styleProp === undefined) return \"line\";\n const style = styleProp.initializer;\n if (!ts.isObjectLiteralExpression(style)) return undefined;\n const kindProp = findProperty(style, \"kind\");\n if (kindProp === undefined) return undefined;\n const kind = kindProp.initializer;\n if (!ts.isStringLiteral(kind)) return undefined;\n return isPlotKind(kind.text) ? kind.text : undefined;\n}\n\n/**\n * Read a string-literal `title` from a plotting callsite's opts object\n * literal. Returns `undefined` for a missing, dynamic, or non-string\n * `title` so the manifest omits the field rather than recording a\n * placeholder.\n *\n * @since 0.8\n * @example\n * // const title = readLiteralTitle(optsObjectLiteralNode);\n * // title === \"Vol\" | undefined\n * const fn: typeof readLiteralTitle = readLiteralTitle;\n * void fn;\n */\nexport function readLiteralTitle(optsArg: ts.Expression | undefined): string | undefined {\n if (optsArg === undefined || !ts.isObjectLiteralExpression(optsArg)) return undefined;\n const titleProp = findProperty(optsArg, \"title\");\n if (titleProp === undefined) return undefined;\n const title = titleProp.initializer;\n return ts.isStringLiteral(title) ? title.text : undefined;\n}\n"]}
|
|
@@ -36,4 +36,25 @@ export declare function resolveCalleeName(node: ts.CallExpression, checker: ts.T
|
|
|
36
36
|
* void fn;
|
|
37
37
|
*/
|
|
38
38
|
export declare function resolveCoreSymbolForElementAccess(node: ts.ElementAccessExpression, checker: ts.TypeChecker): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Return the canonical core-export name for `identifier`, or `null` if
|
|
41
|
+
* the identifier does not resolve to a `@invinite-org/chartlang-core`
|
|
42
|
+
* symbol. Renamed imports (`import { ta as TA } from "core"; TA.ema(...)`)
|
|
43
|
+
* map back to their export name (`"ta"`) so the resulting slot-id
|
|
44
|
+
* matches what `STATEFUL_PRIMITIVES` expects.
|
|
45
|
+
*
|
|
46
|
+
* Reused by the `request.security` expression capture check
|
|
47
|
+
* (`validateSecurityExpr`) to decide whether a free identifier inside the
|
|
48
|
+
* HTF callback resolves to the ambient `ta` / `inputs` namespaces (allowed)
|
|
49
|
+
* versus an outer-scope binding (rejected).
|
|
50
|
+
*
|
|
51
|
+
* @since 0.7
|
|
52
|
+
* @stable
|
|
53
|
+
* @example
|
|
54
|
+
* // const name = resolveCoreSymbolName(checker, identifier);
|
|
55
|
+
* // name === "ta" | "inputs" | null
|
|
56
|
+
* const fn: typeof resolveCoreSymbolName = resolveCoreSymbolName;
|
|
57
|
+
* void fn;
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveCoreSymbolName(checker: ts.TypeChecker, identifier: ts.Identifier): string | null;
|
|
39
60
|
//# sourceMappingURL=resolveCallee.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveCallee.d.ts","sourceRoot":"","sources":["../../src/transformers/resolveCallee.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,MAAM,GAAG,IAAI,CAWjG;AAkBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iCAAiC,CAC7C,IAAI,EAAE,EAAE,CAAC,uBAAuB,EAChC,OAAO,EAAE,EAAE,CAAC,WAAW,GACxB,MAAM,GAAG,IAAI,CAIf"}
|
|
1
|
+
{"version":3,"file":"resolveCallee.d.ts","sourceRoot":"","sources":["../../src/transformers/resolveCallee.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,MAAM,GAAG,IAAI,CAWjG;AAkBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iCAAiC,CAC7C,IAAI,EAAE,EAAE,CAAC,uBAAuB,EAChC,OAAO,EAAE,EAAE,CAAC,WAAW,GACxB,MAAM,GAAG,IAAI,CAIf;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,UAAU,EAAE,EAAE,CAAC,UAAU,GAC1B,MAAM,GAAG,IAAI,CA2Cf"}
|
|
@@ -76,8 +76,21 @@ export function resolveCoreSymbolForElementAccess(node, checker) {
|
|
|
76
76
|
* symbol. Renamed imports (`import { ta as TA } from "core"; TA.ema(...)`)
|
|
77
77
|
* map back to their export name (`"ta"`) so the resulting slot-id
|
|
78
78
|
* matches what `STATEFUL_PRIMITIVES` expects.
|
|
79
|
+
*
|
|
80
|
+
* Reused by the `request.security` expression capture check
|
|
81
|
+
* (`validateSecurityExpr`) to decide whether a free identifier inside the
|
|
82
|
+
* HTF callback resolves to the ambient `ta` / `inputs` namespaces (allowed)
|
|
83
|
+
* versus an outer-scope binding (rejected).
|
|
84
|
+
*
|
|
85
|
+
* @since 0.7
|
|
86
|
+
* @stable
|
|
87
|
+
* @example
|
|
88
|
+
* // const name = resolveCoreSymbolName(checker, identifier);
|
|
89
|
+
* // name === "ta" | "inputs" | null
|
|
90
|
+
* const fn: typeof resolveCoreSymbolName = resolveCoreSymbolName;
|
|
91
|
+
* void fn;
|
|
79
92
|
*/
|
|
80
|
-
function resolveCoreSymbolName(checker, identifier) {
|
|
93
|
+
export function resolveCoreSymbolName(checker, identifier) {
|
|
81
94
|
const localSymbol = checker.getSymbolAtLocation(identifier);
|
|
82
95
|
if (!localSymbol)
|
|
83
96
|
return null;
|