@invinite-org/chartlang-compiler 1.3.0 → 1.4.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/analysis/extractDependencyGraph.d.ts.map +1 -1
  3. package/dist/analysis/extractDependencyGraph.js +9 -1
  4. package/dist/analysis/extractDependencyGraph.js.map +1 -1
  5. package/dist/analysis/extractInputs.d.ts.map +1 -1
  6. package/dist/analysis/extractInputs.js +2 -0
  7. package/dist/analysis/extractInputs.js.map +1 -1
  8. package/dist/analysis/extractRequestedIntervals.d.ts +29 -9
  9. package/dist/analysis/extractRequestedIntervals.d.ts.map +1 -1
  10. package/dist/analysis/extractRequestedIntervals.js +173 -42
  11. package/dist/analysis/extractRequestedIntervals.js.map +1 -1
  12. package/dist/analysis/index.d.ts +1 -0
  13. package/dist/analysis/index.d.ts.map +1 -1
  14. package/dist/analysis/index.js +1 -0
  15. package/dist/analysis/index.js.map +1 -1
  16. package/dist/analysis/stateArrayCapacity.d.ts +58 -0
  17. package/dist/analysis/stateArrayCapacity.d.ts.map +1 -0
  18. package/dist/analysis/stateArrayCapacity.js +108 -0
  19. package/dist/analysis/stateArrayCapacity.js.map +1 -0
  20. package/dist/api.d.ts.map +1 -1
  21. package/dist/api.js +12 -3
  22. package/dist/api.js.map +1 -1
  23. package/dist/diagnostics.d.ts +6 -2
  24. package/dist/diagnostics.d.ts.map +1 -1
  25. package/dist/diagnostics.js.map +1 -1
  26. package/dist/manifest.d.ts +2 -1
  27. package/dist/manifest.d.ts.map +1 -1
  28. package/dist/manifest.js +4 -0
  29. package/dist/manifest.js.map +1 -1
  30. package/dist/program.d.ts.map +1 -1
  31. package/dist/program.js +57 -1
  32. package/dist/program.js.map +1 -1
  33. package/dist/transformers/callsiteIdInjection.d.ts.map +1 -1
  34. package/dist/transformers/callsiteIdInjection.js +8 -1
  35. package/dist/transformers/callsiteIdInjection.js.map +1 -1
  36. package/dist/transformers/plotKindFromCallsite.d.ts +3 -0
  37. package/dist/transformers/plotKindFromCallsite.d.ts.map +1 -1
  38. package/dist/transformers/plotKindFromCallsite.js +7 -0
  39. package/dist/transformers/plotKindFromCallsite.js.map +1 -1
  40. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAgB/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAAC,IAwB7B;IACG,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9D,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1E,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACrE,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAChD,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAU,CAChE,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,MAAkC,CAAC;IACxD,MAAM,iBAAiB,GACnB,IAAI,CAAC,iBAAiB,KAAK,SAAS;QAChC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC,CAAC;IACxD,MAAM,eAAe,GACjB,IAAI,CAAC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C;QACtE,GAAG,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC;QAC7D,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC;QACvD,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;QAC7C,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QACzC,GAAG,CAAC,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC;QACrE,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;QACzE,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QAChE,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,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 {\n AlertConditionDefinition,\n CapabilityId,\n DependencyDeclaration,\n OutputDeclaration,\n PlotSlotDescriptor,\n ScriptManifest,\n SecurityExpressionDescriptor,\n} from \"@invinite-org/chartlang-core\";\n\ntype ValueFormat = \"price\" | \"volume\" | \"percent\" | \"compact\";\ntype ScaleAxis = \"price\" | \"left\" | \"right\" | \"new\";\ntype ManifestInputDescriptors = Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n\n/**\n * Build a recursively-frozen `ScriptManifest` from the compiler's\n * extraction passes. Every array, every nested record, and the outer\n * object itself are frozen so the runtime can structurally clone the\n * manifest without worrying about post-build mutation.\n *\n * @since 0.1\n * @example\n * // const manifest = buildManifest({\n * // name: \"EMA(20)\", kind: \"indicator\",\n * // capabilities: [\"alerts\", \"indicators\"],\n * // requestedIntervals: [], userPickableInterval: false,\n * // seriesCapacities: {}, maxLookback: 0, inputs: {},\n * // });\n * const fn: typeof buildManifest = buildManifest;\n * void fn;\n */\nexport function buildManifest(args: {\n readonly name: string;\n readonly kind: \"indicator\" | \"drawing\" | \"alert\" | \"alertCondition\";\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 inputs: ManifestInputDescriptors;\n readonly overlay?: boolean;\n readonly maxBarsBack?: number;\n readonly format?: ValueFormat;\n readonly precision?: number;\n readonly scale?: ScaleAxis;\n readonly requiresIntervals?: ReadonlyArray<string>;\n readonly shortName?: 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 isDrawn?: boolean;\n readonly siblings?: ReadonlyArray<ScriptManifest>;\n}): ScriptManifest {\n const capabilities = Object.freeze(args.capabilities.slice());\n const requestedIntervals = Object.freeze(args.requestedIntervals.slice());\n const seriesCapacities = Object.freeze({ ...args.seriesCapacities });\n const inputEntries = Object.entries(args.inputs).map(\n ([key, value]) => [key, Object.freeze({ ...value })] as const,\n );\n const inputs = Object.freeze(Object.fromEntries(inputEntries));\n const scriptInputs = inputs as ScriptManifest[\"inputs\"];\n const requiresIntervals =\n args.requiresIntervals === undefined\n ? undefined\n : Object.freeze(args.requiresIntervals.slice());\n const alertConditions =\n args.alertConditions === undefined\n ? undefined\n : Object.freeze(\n args.alertConditions.map((condition) =>\n Object.freeze({\n id: condition.id,\n title: condition.title,\n description: condition.description,\n defaultMessage: condition.defaultMessage,\n }),\n ),\n );\n const dependencies =\n args.dependencies === undefined || args.dependencies.length === 0\n ? undefined\n : Object.freeze(\n args.dependencies.map((dep) =>\n Object.freeze({\n localId: dep.localId,\n producerName: dep.producerName,\n producerSourcePath: dep.producerSourcePath,\n producerExportName: dep.producerExportName,\n effectiveInputs: Object.freeze({ ...dep.effectiveInputs }),\n outputs: Object.freeze(\n dep.outputs.map((o) =>\n Object.freeze({ title: o.title, kind: o.kind }),\n ),\n ),\n isDrawn: dep.isDrawn,\n }),\n ),\n );\n const outputs =\n args.outputs === undefined || args.outputs.length === 0\n ? undefined\n : Object.freeze(\n args.outputs.map((o) => Object.freeze({ title: o.title, kind: o.kind })),\n );\n const plots =\n args.plots === undefined || args.plots.length === 0\n ? undefined\n : Object.freeze(args.plots.map((s) => Object.freeze({ ...s })));\n const securityExpressions =\n args.securityExpressions === undefined || args.securityExpressions.length === 0\n ? undefined\n : Object.freeze(\n args.securityExpressions\n .slice()\n .sort((a, b) => a.slotId.localeCompare(b.slotId))\n .map((s) => Object.freeze({ ...s })),\n );\n const siblings =\n args.siblings === undefined || args.siblings.length === 0\n ? undefined\n : Object.freeze(args.siblings.slice());\n return Object.freeze({\n apiVersion: 1 as const,\n kind: args.kind,\n name: args.name,\n inputs: scriptInputs,\n capabilities,\n requestedIntervals,\n userPickableInterval: args.userPickableInterval,\n seriesCapacities,\n maxLookback: args.maxLookback,\n ...(args.overlay === undefined ? {} : { overlay: args.overlay }),\n ...(args.maxBarsBack === undefined ? {} : { maxBarsBack: args.maxBarsBack }),\n ...(args.format === undefined ? {} : { format: args.format }),\n ...(args.precision === undefined ? {} : { precision: args.precision }),\n ...(args.scale === undefined ? {} : { scale: args.scale }),\n ...(requiresIntervals === undefined ? {} : { requiresIntervals }),\n ...(args.shortName === undefined ? {} : { shortName: args.shortName }),\n ...(alertConditions === undefined ? {} : { alertConditions }),\n ...(dependencies === undefined ? {} : { dependencies }),\n ...(outputs === undefined ? {} : { outputs }),\n ...(plots === undefined ? {} : { plots }),\n ...(securityExpressions === undefined ? {} : { securityExpressions }),\n ...(args.exportName === undefined ? {} : { exportName: args.exportName }),\n ...(args.isDrawn === undefined ? {} : { isDrawn: args.isDrawn }),\n ...(siblings === undefined ? {} : { siblings }),\n });\n}\n"]}
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAiB/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAAC,IAyB7B;IACG,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9D,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1E,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACrE,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAChD,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAU,CAChE,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,MAAkC,CAAC;IACxD,MA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,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;QACzE,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QAChE,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,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 {\n AlertConditionDefinition,\n CapabilityId,\n DependencyDeclaration,\n OutputDeclaration,\n PlotSlotDescriptor,\n RequestedFeed,\n ScriptManifest,\n SecurityExpressionDescriptor,\n} from \"@invinite-org/chartlang-core\";\n\ntype ValueFormat = \"price\" | \"volume\" | \"percent\" | \"compact\";\ntype ScaleAxis = \"price\" | \"left\" | \"right\" | \"new\";\ntype ManifestInputDescriptors = Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n\n/**\n * Build a recursively-frozen `ScriptManifest` from the compiler's\n * extraction passes. Every array, every nested record, and the outer\n * object itself are frozen so the runtime can structurally clone the\n * manifest without worrying about post-build mutation.\n *\n * @since 0.1\n * @example\n * // const manifest = buildManifest({\n * // name: \"EMA(20)\", kind: \"indicator\",\n * // capabilities: [\"alerts\", \"indicators\"],\n * // requestedIntervals: [], userPickableInterval: false,\n * // seriesCapacities: {}, maxLookback: 0, inputs: {},\n * // });\n * const fn: typeof buildManifest = buildManifest;\n * void fn;\n */\nexport function buildManifest(args: {\n readonly name: string;\n readonly kind: \"indicator\" | \"drawing\" | \"alert\" | \"alertCondition\";\n readonly capabilities: ReadonlyArray<CapabilityId>;\n readonly requestedIntervals: ReadonlyArray<string>;\n readonly requestedFeeds?: ReadonlyArray<RequestedFeed>;\n readonly userPickableInterval: boolean;\n readonly seriesCapacities: Readonly<Record<string, number>>;\n readonly maxLookback: number;\n readonly inputs: ManifestInputDescriptors;\n readonly overlay?: boolean;\n readonly maxBarsBack?: number;\n readonly format?: ValueFormat;\n readonly precision?: number;\n readonly scale?: ScaleAxis;\n readonly requiresIntervals?: ReadonlyArray<string>;\n readonly shortName?: 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 isDrawn?: boolean;\n readonly siblings?: ReadonlyArray<ScriptManifest>;\n}): ScriptManifest {\n const capabilities = Object.freeze(args.capabilities.slice());\n const requestedIntervals = Object.freeze(args.requestedIntervals.slice());\n const seriesCapacities = Object.freeze({ ...args.seriesCapacities });\n const inputEntries = Object.entries(args.inputs).map(\n ([key, value]) => [key, Object.freeze({ ...value })] as const,\n );\n const inputs = Object.freeze(Object.fromEntries(inputEntries));\n const scriptInputs = inputs as ScriptManifest[\"inputs\"];\n const requiresIntervals =\n args.requiresIntervals === undefined\n ? undefined\n : Object.freeze(args.requiresIntervals.slice());\n const alertConditions =\n args.alertConditions === undefined\n ? undefined\n : Object.freeze(\n args.alertConditions.map((condition) =>\n Object.freeze({\n id: condition.id,\n title: condition.title,\n description: condition.description,\n defaultMessage: condition.defaultMessage,\n }),\n ),\n );\n const dependencies =\n args.dependencies === undefined || args.dependencies.length === 0\n ? undefined\n : Object.freeze(\n args.dependencies.map((dep) =>\n Object.freeze({\n localId: dep.localId,\n producerName: dep.producerName,\n producerSourcePath: dep.producerSourcePath,\n producerExportName: dep.producerExportName,\n effectiveInputs: Object.freeze({ ...dep.effectiveInputs }),\n outputs: Object.freeze(\n dep.outputs.map((o) =>\n Object.freeze({ title: o.title, kind: o.kind }),\n ),\n ),\n isDrawn: dep.isDrawn,\n }),\n ),\n );\n const outputs =\n args.outputs === undefined || args.outputs.length === 0\n ? undefined\n : Object.freeze(\n args.outputs.map((o) => Object.freeze({ title: o.title, kind: o.kind })),\n );\n const plots =\n args.plots === undefined || args.plots.length === 0\n ? undefined\n : Object.freeze(args.plots.map((s) => Object.freeze({ ...s })));\n const securityExpressions =\n args.securityExpressions === undefined || args.securityExpressions.length === 0\n ? undefined\n : Object.freeze(\n args.securityExpressions\n .slice()\n .sort((a, b) => a.slotId.localeCompare(b.slotId))\n .map((s) => Object.freeze({ ...s })),\n );\n const requestedFeeds =\n args.requestedFeeds === undefined || args.requestedFeeds.length === 0\n ? undefined\n : Object.freeze(args.requestedFeeds.map((f) => Object.freeze({ ...f })));\n const siblings =\n args.siblings === undefined || args.siblings.length === 0\n ? undefined\n : Object.freeze(args.siblings.slice());\n return Object.freeze({\n apiVersion: 1 as const,\n kind: args.kind,\n name: args.name,\n inputs: scriptInputs,\n capabilities,\n requestedIntervals,\n userPickableInterval: args.userPickableInterval,\n seriesCapacities,\n maxLookback: args.maxLookback,\n ...(args.overlay === undefined ? {} : { overlay: args.overlay }),\n ...(args.maxBarsBack === undefined ? {} : { maxBarsBack: args.maxBarsBack }),\n ...(args.format === undefined ? {} : { format: args.format }),\n ...(args.precision === undefined ? {} : { precision: args.precision }),\n ...(args.scale === undefined ? {} : { scale: args.scale }),\n ...(requiresIntervals === undefined ? {} : { requiresIntervals }),\n ...(args.shortName === undefined ? {} : { shortName: args.shortName }),\n ...(alertConditions === undefined ? {} : { alertConditions }),\n ...(dependencies === undefined ? {} : { dependencies }),\n ...(outputs === undefined ? {} : { outputs }),\n ...(plots === undefined ? {} : { plots }),\n ...(securityExpressions === undefined ? {} : { securityExpressions }),\n ...(requestedFeeds === undefined ? {} : { requestedFeeds }),\n ...(args.exportName === undefined ? {} : { exportName: args.exportName }),\n ...(args.isDrawn === undefined ? {} : { isDrawn: args.isDrawn }),\n ...(siblings === undefined ? {} : { siblings }),\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAu5C3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,eAYjC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACpC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;IACpB,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;IAC1B,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;CAC3B,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IACF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACjD,GACF,gBAAgB,CAsFlB"}
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AA+8C3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,eAYjC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACpC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;IACpB,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;IAC1B,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;CAC3B,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IACF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACjD,GACF,gBAAgB,CAsFlB"}
package/dist/program.js CHANGED
@@ -831,8 +831,17 @@ declare module "@invinite-org/chartlang-core" {
831
831
  lineStyle?: LineStyle;
832
832
  pane?: "overlay" | "new" | string;
833
833
  }>;
834
+ export type BgColorOpts = Readonly<{
835
+ transp?: number;
836
+ title?: string;
837
+ }>;
838
+ export type BarColorOpts = Readonly<{
839
+ title?: string;
840
+ }>;
834
841
  export function plot(value: number | Series<number>, opts?: PlotOpts): void;
835
842
  export function hline(price: number, opts?: HLineOpts): void;
843
+ export function bgcolor(color: Color, opts?: BgColorOpts): void;
844
+ export function barcolor(color: Color, opts?: BarColorOpts): void;
836
845
  export type JsonValue =
837
846
  | null
838
847
  | boolean
@@ -928,6 +937,7 @@ declare module "@invinite-org/chartlang-core" {
928
937
  | "price"
929
938
  | "symbol"
930
939
  | "interval"
940
+ | "session"
931
941
  | "external-series";
932
942
  export type SourceField =
933
943
  | "open"
@@ -956,6 +966,7 @@ declare module "@invinite-org/chartlang-core" {
956
966
  export type PriceDescriptor = CommonInputDescriptor<"price", number>;
957
967
  export type SymbolDescriptor = CommonInputDescriptor<"symbol", string>;
958
968
  export type IntervalDescriptorInput = CommonInputDescriptor<"interval", string>;
969
+ export type SessionDescriptor = CommonInputDescriptor<"session", string>;
959
970
  export type ExternalSeriesDescriptor<T> = Readonly<{
960
971
  kind: "external-series";
961
972
  name: string;
@@ -974,6 +985,7 @@ declare module "@invinite-org/chartlang-core" {
974
985
  | PriceDescriptor
975
986
  | SymbolDescriptor
976
987
  | IntervalDescriptorInput
988
+ | SessionDescriptor
977
989
  | ExternalSeriesDescriptor<T>;
978
990
  export const input: Readonly<{
979
991
  int(defaultValue: number, opts?: NumericInputOpts & Readonly<{ title?: string }>): IntDescriptor;
@@ -991,18 +1003,28 @@ declare module "@invinite-org/chartlang-core" {
991
1003
  price(defaultValue: Price, opts?: Readonly<{ title?: string }>): PriceDescriptor;
992
1004
  symbol(defaultValue: string, opts?: Readonly<{ title?: string }>): SymbolDescriptor;
993
1005
  interval(defaultValue: string, opts?: Readonly<{ title?: string }>): IntervalDescriptorInput;
1006
+ session(defaultValue: string, opts?: Readonly<{ title?: string }>): SessionDescriptor;
994
1007
  externalSeries<T>(args: Readonly<{ name: string; schema: Schema<T>; title?: string }>): ExternalSeriesDescriptor<T>;
995
1008
  }>;
996
1009
  export type InputSchema = Readonly<Record<string, InputDescriptor<unknown>>>;
997
1010
  export type MutableSlot<T> = {
998
1011
  value: T;
999
1012
  };
1013
+ export type MutableArraySlot<T> = {
1014
+ push(value: T): void;
1015
+ get(n: number): T;
1016
+ last(): T;
1017
+ clear(): void;
1018
+ readonly size: number;
1019
+ readonly capacity: number;
1020
+ };
1000
1021
  export type StateNamespace = Readonly<{
1001
1022
  float(init: number): MutableSlot<number>;
1002
1023
  int(init: number): MutableSlot<number>;
1003
1024
  bool(init: boolean): MutableSlot<boolean>;
1004
1025
  string(init: string): MutableSlot<string>;
1005
1026
  series(init: number): NumberSeriesSlot;
1027
+ array<T>(capacity: number): MutableArraySlot<T>;
1006
1028
  tick: Readonly<{
1007
1029
  float(init: number): MutableSlot<number>;
1008
1030
  int(init: number): MutableSlot<number>;
@@ -1051,7 +1073,31 @@ declare module "@invinite-org/chartlang-core" {
1051
1073
  readonly inSeconds: number;
1052
1074
  };
1053
1075
  export const timeframe: TimeframeView;
1054
- export type RequestSecurityOpts = Readonly<{ interval: string }>;
1076
+ export type TimeNamespace = Readonly<{
1077
+ year(t: Time, tz?: string): number;
1078
+ month(t: Time, tz?: string): number;
1079
+ dayofmonth(t: Time, tz?: string): number;
1080
+ dayofweek(t: Time, tz?: string): number;
1081
+ hour(t: Time, tz?: string): number;
1082
+ minute(t: Time, tz?: string): number;
1083
+ second(t: Time, tz?: string): number;
1084
+ timestamp(
1085
+ year: number,
1086
+ month: number,
1087
+ day: number,
1088
+ hour?: number,
1089
+ minute?: number,
1090
+ second?: number,
1091
+ tz?: string,
1092
+ ): Time;
1093
+ timeClose(t: Time, tz?: string): Time;
1094
+ }>;
1095
+ export const time: TimeNamespace;
1096
+ export type SessionNamespace = Readonly<{
1097
+ isOpen(t: Time, spec: string, tz?: string): boolean;
1098
+ }>;
1099
+ export const session: SessionNamespace;
1100
+ export type RequestSecurityOpts = Readonly<{ symbol?: string; interval: string }>;
1055
1101
  export type RequestLowerTfOpts = Readonly<{ interval: string }>;
1056
1102
  export type SecurityBar = Readonly<{
1057
1103
  readonly time: Series<Time>;
@@ -1091,9 +1137,14 @@ declare module "@invinite-org/chartlang-core" {
1091
1137
  }>;
1092
1138
  export type SecurityExpressionDescriptor = Readonly<{
1093
1139
  readonly slotId: string;
1140
+ readonly symbol?: string;
1094
1141
  readonly interval: string;
1095
1142
  readonly paramName: string;
1096
1143
  }>;
1144
+ export type RequestedFeed = Readonly<{
1145
+ readonly symbol?: string;
1146
+ readonly interval: string;
1147
+ }>;
1097
1148
  export type DependencyDeclaration = Readonly<{
1098
1149
  readonly localId: string;
1099
1150
  readonly producerName: string;
@@ -1126,6 +1177,7 @@ declare module "@invinite-org/chartlang-core" {
1126
1177
  readonly outputs?: ReadonlyArray<OutputDeclaration>;
1127
1178
  readonly plots?: ReadonlyArray<PlotSlotDescriptor>;
1128
1179
  readonly securityExpressions?: ReadonlyArray<SecurityExpressionDescriptor>;
1180
+ readonly requestedFeeds?: ReadonlyArray<RequestedFeed>;
1129
1181
  readonly exportName?: string;
1130
1182
  readonly siblings?: ReadonlyArray<ScriptManifest>;
1131
1183
  readonly isDrawn?: boolean;
@@ -1352,12 +1404,16 @@ declare module "@invinite-org/chartlang-core" {
1352
1404
  readonly ta: TaNamespace;
1353
1405
  readonly plot: typeof plot;
1354
1406
  readonly hline: typeof hline;
1407
+ readonly bgcolor: typeof bgcolor;
1408
+ readonly barcolor: typeof barcolor;
1355
1409
  readonly alert: typeof alert;
1356
1410
  readonly draw: DrawNamespace;
1357
1411
  readonly state: StateNamespace;
1358
1412
  readonly barstate: BarStateView;
1359
1413
  readonly syminfo: SymInfoView;
1360
1414
  readonly timeframe: TimeframeView;
1415
+ readonly time: TimeNamespace;
1416
+ readonly session: SessionNamespace;
1361
1417
  readonly request: RequestNamespace;
1362
1418
  readonly runtime: RuntimeNamespace;
1363
1419
  readonly signal?: (conditionId: string, fired: boolean) => void;
@@ -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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AAc,EAAE;KACpC,CAAC,CAAC;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"]}
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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Aa,CAAC;QAC7B,SAAS;QACT,OAAO,EAAE,gBAAgB;QACzB,IAAI;KACP,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,OAAO;QACP,UAAU;QACV,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE;KACpC,CAAC,CAAC;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 type BgColorOpts = Readonly<{\n transp?: number;\n title?: string;\n }>;\n export type BarColorOpts = Readonly<{\n title?: string;\n }>;\n export function plot(value: number | Series<number>, opts?: PlotOpts): void;\n export function hline(price: number, opts?: HLineOpts): void;\n export function bgcolor(color: Color, opts?: BgColorOpts): void;\n export function barcolor(color: Color, opts?: BarColorOpts): 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 | \"session\"\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 SessionDescriptor = CommonInputDescriptor<\"session\", 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 | SessionDescriptor\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 session(defaultValue: string, opts?: Readonly<{ title?: string }>): SessionDescriptor;\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 MutableArraySlot<T> = {\n push(value: T): void;\n get(n: number): T;\n last(): T;\n clear(): void;\n readonly size: number;\n readonly capacity: number;\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 array<T>(capacity: number): MutableArraySlot<T>;\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 TimeNamespace = Readonly<{\n year(t: Time, tz?: string): number;\n month(t: Time, tz?: string): number;\n dayofmonth(t: Time, tz?: string): number;\n dayofweek(t: Time, tz?: string): number;\n hour(t: Time, tz?: string): number;\n minute(t: Time, tz?: string): number;\n second(t: Time, tz?: string): number;\n timestamp(\n year: number,\n month: number,\n day: number,\n hour?: number,\n minute?: number,\n second?: number,\n tz?: string,\n ): Time;\n timeClose(t: Time, tz?: string): Time;\n }>;\n export const time: TimeNamespace;\n export type SessionNamespace = Readonly<{\n isOpen(t: Time, spec: string, tz?: string): boolean;\n }>;\n export const session: SessionNamespace;\n export type RequestSecurityOpts = Readonly<{ symbol?: string; 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 symbol?: string;\n readonly interval: string;\n readonly paramName: string;\n }>;\n export type RequestedFeed = Readonly<{\n readonly symbol?: string;\n readonly interval: 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 requestedFeeds?: ReadonlyArray<RequestedFeed>;\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 bgcolor: typeof bgcolor;\n readonly barcolor: typeof barcolor;\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 time: TimeNamespace;\n readonly session: SessionNamespace;\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"]}
@@ -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,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"}
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,CAwGzB"}
@@ -93,7 +93,14 @@ export function injectCallsiteIds(sourceFile, checker, opts) {
93
93
  }
94
94
  slotsSeen.set(slotId, node);
95
95
  if (plotSlots !== undefined &&
96
- (calleeName === "plot" || calleeName === "hline")) {
96
+ (calleeName === "plot" ||
97
+ calleeName === "hline" ||
98
+ calleeName === "bgcolor" ||
99
+ calleeName === "barcolor")) {
100
+ // `bgcolor`/`barcolor`'s opts is `arguments[1]` (color
101
+ // is `arguments[0]`) — the same index as `plot`'s opts,
102
+ // so `plotKindFromCallsite` / `readLiteralTitle` read
103
+ // the right node without a callee-specific offset.
97
104
  const optsArg = node.arguments[1];
98
105
  // best-effort dynamic-kind fallback: a callsite whose
99
106
  // `style` is non-literal is still listed as "line".