@invinite-org/chartlang-compiler 1.2.1 → 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.
- package/CHANGELOG.md +310 -0
- package/dist/analysis/extractDependencyGraph.d.ts.map +1 -1
- package/dist/analysis/extractDependencyGraph.js +9 -1
- package/dist/analysis/extractDependencyGraph.js.map +1 -1
- package/dist/analysis/extractInputs.d.ts.map +1 -1
- package/dist/analysis/extractInputs.js +2 -0
- package/dist/analysis/extractInputs.js.map +1 -1
- package/dist/analysis/extractMaxLookback.d.ts +2 -1
- package/dist/analysis/extractMaxLookback.d.ts.map +1 -1
- package/dist/analysis/extractMaxLookback.js +90 -6
- package/dist/analysis/extractMaxLookback.js.map +1 -1
- package/dist/analysis/extractRequestedIntervals.d.ts +63 -1
- package/dist/analysis/extractRequestedIntervals.d.ts.map +1 -1
- package/dist/analysis/extractRequestedIntervals.js +245 -29
- package/dist/analysis/extractRequestedIntervals.js.map +1 -1
- package/dist/analysis/forbiddenConstructs.d.ts.map +1 -1
- package/dist/analysis/forbiddenConstructs.js +2 -41
- package/dist/analysis/forbiddenConstructs.js.map +1 -1
- package/dist/analysis/index.d.ts +4 -1
- package/dist/analysis/index.d.ts.map +1 -1
- package/dist/analysis/index.js +3 -1
- package/dist/analysis/index.js.map +1 -1
- package/dist/analysis/loopBounds.d.ts +91 -0
- package/dist/analysis/loopBounds.d.ts.map +1 -0
- package/dist/analysis/loopBounds.js +132 -0
- package/dist/analysis/loopBounds.js.map +1 -0
- package/dist/analysis/resolveIndexBound.d.ts +73 -0
- package/dist/analysis/resolveIndexBound.d.ts.map +1 -0
- package/dist/analysis/resolveIndexBound.js +336 -0
- package/dist/analysis/resolveIndexBound.js.map +1 -0
- package/dist/analysis/stateArrayCapacity.d.ts +58 -0
- package/dist/analysis/stateArrayCapacity.d.ts.map +1 -0
- package/dist/analysis/stateArrayCapacity.js +108 -0
- package/dist/analysis/stateArrayCapacity.js.map +1 -0
- package/dist/analysis/validateSecurityExpr.d.ts +25 -0
- package/dist/analysis/validateSecurityExpr.d.ts.map +1 -0
- package/dist/analysis/validateSecurityExpr.js +154 -0
- package/dist/analysis/validateSecurityExpr.js.map +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +22 -3
- package/dist/api.js.map +1 -1
- package/dist/diagnostics.d.ts +8 -2
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/manifest.d.ts +3 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +11 -0
- package/dist/manifest.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +148 -15
- package/dist/program.js.map +1 -1
- package/dist/transformers/callsiteIdInjection.d.ts +21 -0
- package/dist/transformers/callsiteIdInjection.d.ts.map +1 -1
- package/dist/transformers/callsiteIdInjection.js +34 -4
- package/dist/transformers/callsiteIdInjection.js.map +1 -1
- package/dist/transformers/plotKindFromCallsite.d.ts +3 -0
- package/dist/transformers/plotKindFromCallsite.d.ts.map +1 -1
- package/dist/transformers/plotKindFromCallsite.js +7 -0
- package/dist/transformers/plotKindFromCallsite.js.map +1 -1
- package/dist/transformers/resolveCallee.d.ts +21 -0
- package/dist/transformers/resolveCallee.d.ts.map +1 -1
- package/dist/transformers/resolveCallee.js +14 -1
- package/dist/transformers/resolveCallee.js.map +1 -1
- package/package.json +2 -2
package/dist/diagnostics.d.ts
CHANGED
|
@@ -9,13 +9,19 @@ import type ts from "typescript";
|
|
|
9
9
|
* `multiple-default-exports`, `non-const-define-binding`, and the six
|
|
10
10
|
* `dep-*` codes for indicator-composition analysis (plus
|
|
11
11
|
* `duplicate-output-title` for clashing `plot(value, { title })`
|
|
12
|
-
* declarations in the same script).
|
|
12
|
+
* declarations in the same script). The HTF-expression feature adds
|
|
13
|
+
* `request-security-expr-captures-local` for an out-of-subset reference
|
|
14
|
+
* inside a `request.security({ interval }, (bar) => …)` callback. The
|
|
15
|
+
* `state.array` feature adds `state-array-capacity-not-literal` and
|
|
16
|
+
* `state-array-capacity-exceeds-max` for the capacity-literal guard. The
|
|
17
|
+
* multi-symbol feature adds `request-security-symbol-not-literal` for a
|
|
18
|
+
* non-literal `request.security({ symbol })` opt.
|
|
13
19
|
*
|
|
14
20
|
* @since 0.1
|
|
15
21
|
* @example
|
|
16
22
|
* const code: CompileDiagnosticCode = "unbounded-loop";
|
|
17
23
|
*/
|
|
18
|
-
export type CompileDiagnosticCode = "unbounded-loop" | "recursion-not-allowed" | "hostile-global" | "stateful-call-inside-loop" | "stateful-call-element-access" | "request-security-interval-not-literal" | "dynamic-series-index" | "callsite-id-conflict" | "missing-default-export" | "api-version-mismatch" | "input-default-not-literal" | "unknown-input-kind" | "multiple-input-interval" | "requires-intervals-not-literal" | "alert-condition-not-literal" | "alert-condition-field-not-literal" | "lower-tf-not-lower" | "request-lower-tf-interval-not-literal" | "type-error" | "multiple-default-exports" | "non-const-define-binding" | "dep-cycle" | "dep-unknown-output" | "dep-invalid-input-override" | "dep-dynamic" | "dep-output-not-titled" | "duplicate-output-title";
|
|
24
|
+
export type CompileDiagnosticCode = "unbounded-loop" | "recursion-not-allowed" | "hostile-global" | "stateful-call-inside-loop" | "stateful-call-element-access" | "request-security-interval-not-literal" | "dynamic-series-index" | "callsite-id-conflict" | "missing-default-export" | "api-version-mismatch" | "input-default-not-literal" | "unknown-input-kind" | "multiple-input-interval" | "requires-intervals-not-literal" | "alert-condition-not-literal" | "alert-condition-field-not-literal" | "lower-tf-not-lower" | "request-lower-tf-interval-not-literal" | "type-error" | "multiple-default-exports" | "non-const-define-binding" | "dep-cycle" | "dep-unknown-output" | "dep-invalid-input-override" | "dep-dynamic" | "dep-output-not-titled" | "duplicate-output-title" | "request-security-expr-captures-local" | "state-array-capacity-not-literal" | "state-array-capacity-exceeds-max" | "request-security-symbol-not-literal";
|
|
19
25
|
/**
|
|
20
26
|
* Single diagnostic the compiler emits while transforming or analysing a
|
|
21
27
|
* `.chart.ts` source. The shape is intentionally small — file/line/column and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,qBAAqB,GAC3B,gBAAgB,GAChB,uBAAuB,GACvB,gBAAgB,GAChB,2BAA2B,GAC3B,8BAA8B,GAC9B,uCAAuC,GACvC,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,sBAAsB,GACtB,2BAA2B,GAC3B,oBAAoB,GACpB,yBAAyB,GACzB,gCAAgC,GAChC,6BAA6B,GAC7B,mCAAmC,GACnC,oBAAoB,GACpB,uCAAuC,GACvC,YAAY,GACZ,0BAA0B,GAC1B,0BAA0B,GAC1B,WAAW,GACX,oBAAoB,GACpB,4BAA4B,GAC5B,aAAa,GACb,uBAAuB,GACvB,wBAAwB,GACxB,sCAAsC,GACtC,kCAAkC,GAClC,kCAAkC,GAClC,qCAAqC,CAAC;AAE5C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC5B,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACnC,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;IACnC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACrC,GAAG,iBAAiB,CAoBpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAsBhG"}
|
package/dist/diagnostics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAwF/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAQhC;IACG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACjF,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACxC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC;IAC5E,MAAM,IAAI,GAAG;QACT,QAAQ;QACR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P,MAAM,EAAE,CAAC;SACZ,CAAC,CAAC;IACP,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,6BAA6B,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACjF,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,KAAK,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE;QAC3C,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,IAAI,GAAG,CAAC;QACd,MAAM,EAAE,SAAS,GAAG,CAAC;KACxB,CAAC,CAAC;AACP,CAAC;AAED,SAAS,wBAAwB,CAAC,OAA2C;IACzE,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,MAAM,KAAK,GAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,KAAK,GAA6C,IAAI,CAAC;IAC7D,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3B,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 ts from \"typescript\";\n\n/**\n * Stable identifier for every diagnostic the compiler can emit. New codes are\n * added at the end; existing codes never change meaning so consumer-side\n * filtering stays compatible across versions.\n *\n * Phase 1 ships eight emittable codes plus Phase 4's\n * `request.security` and input-extraction codes. Phase 7 adds\n * `multiple-default-exports`, `non-const-define-binding`, and the six\n * `dep-*` codes for indicator-composition analysis (plus\n * `duplicate-output-title` for clashing `plot(value, { title })`\n * declarations in the same script). The HTF-expression feature adds\n * `request-security-expr-captures-local` for an out-of-subset reference\n * inside a `request.security({ interval }, (bar) => …)` callback. The\n * `state.array` feature adds `state-array-capacity-not-literal` and\n * `state-array-capacity-exceeds-max` for the capacity-literal guard. The\n * multi-symbol feature adds `request-security-symbol-not-literal` for a\n * non-literal `request.security({ symbol })` opt.\n *\n * @since 0.1\n * @example\n * const code: CompileDiagnosticCode = \"unbounded-loop\";\n */\nexport type CompileDiagnosticCode =\n | \"unbounded-loop\"\n | \"recursion-not-allowed\"\n | \"hostile-global\"\n | \"stateful-call-inside-loop\"\n | \"stateful-call-element-access\"\n | \"request-security-interval-not-literal\"\n | \"dynamic-series-index\"\n | \"callsite-id-conflict\"\n | \"missing-default-export\"\n | \"api-version-mismatch\"\n | \"input-default-not-literal\"\n | \"unknown-input-kind\"\n | \"multiple-input-interval\"\n | \"requires-intervals-not-literal\"\n | \"alert-condition-not-literal\"\n | \"alert-condition-field-not-literal\"\n | \"lower-tf-not-lower\"\n | \"request-lower-tf-interval-not-literal\"\n | \"type-error\"\n | \"multiple-default-exports\"\n | \"non-const-define-binding\"\n | \"dep-cycle\"\n | \"dep-unknown-output\"\n | \"dep-invalid-input-override\"\n | \"dep-dynamic\"\n | \"dep-output-not-titled\"\n | \"duplicate-output-title\"\n | \"request-security-expr-captures-local\"\n | \"state-array-capacity-not-literal\"\n | \"state-array-capacity-exceeds-max\"\n | \"request-security-symbol-not-literal\";\n\n/**\n * Single diagnostic the compiler emits while transforming or analysing a\n * `.chart.ts` source. The shape is intentionally small — file/line/column and\n * a stable code — so callers (CLI, editor, host) can format errors uniformly.\n *\n * `severity` distinguishes hard errors (abort `compile`) from warnings\n * (surface to the user but still produce a manifest).\n *\n * @since 0.1\n * @example\n * const d: CompileDiagnostic = {\n * severity: \"error\",\n * code: \"unbounded-loop\",\n * message: \"while loops are not allowed\",\n * file: \"demo.chart.ts\",\n * line: 5,\n * column: 1,\n * };\n */\nexport type CompileDiagnostic = {\n readonly severity: \"error\" | \"warning\";\n readonly code: CompileDiagnosticCode;\n readonly message: string;\n readonly file: string;\n readonly line: number;\n readonly column: number;\n readonly nodeText?: string;\n};\n\n/**\n * Build a frozen `CompileDiagnostic` from a TypeScript node. Reads the node's\n * starting position against the supplied source file, converts to 1-based\n * line/column, and truncates the source snippet to a single line so terminal\n * output stays compact.\n *\n * @since 0.1\n * @example\n * // Inside an analysis pass:\n * // diagnostics.push(createDiagnostic({\n * // severity: \"error\", code: \"unbounded-loop\",\n * // message: \"while loops are not allowed\",\n * // file: sourcePath, node, sourceFile,\n * // }));\n * const fake = { severity: \"error\" as const };\n * void fake;\n */\nexport function createDiagnostic(args: {\n readonly severity: \"error\" | \"warning\";\n readonly code: CompileDiagnosticCode;\n readonly message: string;\n readonly file: string;\n readonly node: ts.Node;\n readonly sourceFile: ts.SourceFile;\n readonly includeSnippet?: boolean;\n}): CompileDiagnostic {\n const { severity, code, message, file, node, sourceFile, includeSnippet } = args;\n const start = node.getStart(sourceFile);\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(start);\n const base = {\n severity,\n code,\n message,\n file,\n line: line + 1,\n column: character + 1,\n };\n if (includeSnippet) {\n const text = node.getText(sourceFile);\n const newlineIndex = text.indexOf(\"\\n\");\n const firstLine = newlineIndex === -1 ? text : text.slice(0, newlineIndex);\n const snippet = firstLine.length > 80 ? `${firstLine.slice(0, 77)}...` : firstLine;\n return Object.freeze({ ...base, nodeText: snippet });\n }\n return Object.freeze(base);\n}\n\n/**\n * Build a frozen `CompileDiagnostic` from a raw TypeScript `ts.Diagnostic`.\n * Used by the `compile()` pipeline to surface semantic type-checker errors\n * (TS2322, TS2345, …) under the `type-error` code. Carries the original\n * `TS<code>` numeric prefix in the message so editor consumers can route\n * to the TypeScript documentation if they want.\n *\n * Diagnostics without a `file` (global-scope, project-shape) are mapped to\n * the script's `sourcePath` at line/column `1:1` so callers always get a\n * stable location they can attribute to the user's source. The message is\n * flattened across `DiagnosticMessageChain` nodes.\n *\n * @since 0.7\n * @example\n * // const compileDiagnostic = mapTsDiagnostic(tsDiagnostic, \"demo.chart.ts\");\n * const fn: typeof mapTsDiagnostic = mapTsDiagnostic;\n * void fn;\n */\nexport function mapTsDiagnostic(diagnostic: ts.Diagnostic, sourcePath: string): CompileDiagnostic {\n const message = flattenDiagnosticMessage(diagnostic.messageText);\n const file = diagnostic.file;\n if (file === undefined || diagnostic.start === undefined) {\n return Object.freeze({\n severity: \"error\",\n code: \"type-error\",\n message: `TS${diagnostic.code}: ${message}`,\n file: sourcePath,\n line: 1,\n column: 1,\n });\n }\n const { line, character } = file.getLineAndCharacterOfPosition(diagnostic.start);\n return Object.freeze({\n severity: \"error\",\n code: \"type-error\",\n message: `TS${diagnostic.code}: ${message}`,\n file: sourcePath,\n line: line + 1,\n column: character + 1,\n });\n}\n\nfunction flattenDiagnosticMessage(message: string | ts.DiagnosticMessageChain): string {\n if (typeof message === \"string\") return message;\n const parts: string[] = [message.messageText];\n const next = message.next;\n if (next === undefined) return parts.join(\" \");\n const queue: ReadonlyArray<ts.DiagnosticMessageChain> = next;\n for (const chain of queue) {\n parts.push(flattenDiagnosticMessage(chain));\n }\n return parts.join(\" \");\n}\n"]}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AlertConditionDefinition, CapabilityId, DependencyDeclaration, OutputDeclaration, PlotSlotDescriptor, ScriptManifest } from "@invinite-org/chartlang-core";
|
|
1
|
+
import type { AlertConditionDefinition, CapabilityId, DependencyDeclaration, OutputDeclaration, PlotSlotDescriptor, RequestedFeed, ScriptManifest, SecurityExpressionDescriptor } from "@invinite-org/chartlang-core";
|
|
2
2
|
type ValueFormat = "price" | "volume" | "percent" | "compact";
|
|
3
3
|
type ScaleAxis = "price" | "left" | "right" | "new";
|
|
4
4
|
type ManifestInputDescriptors = Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
@@ -24,6 +24,7 @@ export declare function buildManifest(args: {
|
|
|
24
24
|
readonly kind: "indicator" | "drawing" | "alert" | "alertCondition";
|
|
25
25
|
readonly capabilities: ReadonlyArray<CapabilityId>;
|
|
26
26
|
readonly requestedIntervals: ReadonlyArray<string>;
|
|
27
|
+
readonly requestedFeeds?: ReadonlyArray<RequestedFeed>;
|
|
27
28
|
readonly userPickableInterval: boolean;
|
|
28
29
|
readonly seriesCapacities: Readonly<Record<string, number>>;
|
|
29
30
|
readonly maxLookback: number;
|
|
@@ -39,6 +40,7 @@ export declare function buildManifest(args: {
|
|
|
39
40
|
readonly dependencies?: ReadonlyArray<DependencyDeclaration>;
|
|
40
41
|
readonly outputs?: ReadonlyArray<OutputDeclaration>;
|
|
41
42
|
readonly plots?: ReadonlyArray<PlotSlotDescriptor>;
|
|
43
|
+
readonly securityExpressions?: ReadonlyArray<SecurityExpressionDescriptor>;
|
|
42
44
|
readonly exportName?: string;
|
|
43
45
|
readonly isDrawn?: boolean;
|
|
44
46
|
readonly siblings?: ReadonlyArray<ScriptManifest>;
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,wBAAwB,EACxB,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,wBAAwB,EACxB,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,4BAA4B,EAC/B,MAAM,8BAA8B,CAAC;AAEtC,KAAK,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAC9D,KAAK,SAAS,GAAG,OAAO,GAAG,MAA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;IACnE,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACnD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,aAAa,CAAC,4BAA4B,CAAC,CAAC;IAC3E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACrD,GAAG,cAAc,CAoGjB"}
|
package/dist/manifest.js
CHANGED
|
@@ -52,6 +52,15 @@ export function buildManifest(args) {
|
|
|
52
52
|
const plots = args.plots === undefined || args.plots.length === 0
|
|
53
53
|
? undefined
|
|
54
54
|
: Object.freeze(args.plots.map((s) => Object.freeze({ ...s })));
|
|
55
|
+
const securityExpressions = args.securityExpressions === undefined || args.securityExpressions.length === 0
|
|
56
|
+
? undefined
|
|
57
|
+
: Object.freeze(args.securityExpressions
|
|
58
|
+
.slice()
|
|
59
|
+
.sort((a, b) => a.slotId.localeCompare(b.slotId))
|
|
60
|
+
.map((s) => Object.freeze({ ...s })));
|
|
61
|
+
const requestedFeeds = args.requestedFeeds === undefined || args.requestedFeeds.length === 0
|
|
62
|
+
? undefined
|
|
63
|
+
: Object.freeze(args.requestedFeeds.map((f) => Object.freeze({ ...f })));
|
|
55
64
|
const siblings = args.siblings === undefined || args.siblings.length === 0
|
|
56
65
|
? undefined
|
|
57
66
|
: Object.freeze(args.siblings.slice());
|
|
@@ -76,6 +85,8 @@ export function buildManifest(args) {
|
|
|
76
85
|
...(dependencies === undefined ? {} : { dependencies }),
|
|
77
86
|
...(outputs === undefined ? {} : { outputs }),
|
|
78
87
|
...(plots === undefined ? {} : { plots }),
|
|
88
|
+
...(securityExpressions === undefined ? {} : { securityExpressions }),
|
|
89
|
+
...(requestedFeeds === undefined ? {} : { requestedFeeds }),
|
|
79
90
|
...(args.exportName === undefined ? {} : { exportName: args.exportName }),
|
|
80
91
|
...(args.isDrawn === undefined ? {} : { isDrawn: args.isDrawn }),
|
|
81
92
|
...(siblings === undefined ? {} : { siblings }),
|
package/dist/manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAe/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAAC,IAuB7B;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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AAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QACzC,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} 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 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 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 ...(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,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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,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC;QAC3D,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 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"]}
|
package/dist/program.d.ts.map
CHANGED
|
@@ -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;
|
|
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
|
@@ -73,18 +73,54 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
73
73
|
readonly ohlc4: Price;
|
|
74
74
|
readonly hlcc4: Price;
|
|
75
75
|
readonly viewport?: BarViewport;
|
|
76
|
+
point(offset: number, price: Price): WorldPoint;
|
|
76
77
|
};
|
|
77
78
|
export type Series<T> = {
|
|
78
79
|
readonly current: T;
|
|
79
80
|
readonly [n: number]: T;
|
|
80
81
|
readonly length: number;
|
|
81
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* A bar price field — both a scalar \`Price\` (\`bar.close * 2\`,
|
|
85
|
+
* \`plot(bar.close)\`, \`ta.ema(bar.close, 12)\`) and an indexable
|
|
86
|
+
* \`Series<Price>\` (\`bar.close[1]\`). Mirrors core's \`PriceSeries\`.
|
|
87
|
+
*/
|
|
88
|
+
export type PriceSeries = Price & Series<Price>;
|
|
89
|
+
/** Volume counterpart of \`PriceSeries\`. Mirrors core's \`VolumeSeries\`. */
|
|
90
|
+
export type VolumeSeries = Volume & Series<Volume>;
|
|
91
|
+
/**
|
|
92
|
+
* A user-allocated, writable, indexable number series — the value half of
|
|
93
|
+
* \`state.series(init)\`. Both a writable scalar slot (\`s.value = x\`) and
|
|
94
|
+
* an indexable \`Series<number>\` (\`s[1]\`, \`s.current\`, \`+s\`). Mirrors
|
|
95
|
+
* core's \`NumberSeriesSlot\`.
|
|
96
|
+
*/
|
|
97
|
+
export type NumberSeriesSlot = MutableSlot<number> & Series<number>;
|
|
98
|
+
/**
|
|
99
|
+
* The \`compute\`-facing bar (\`ComputeContext.bar\`): like \`Bar\` but the
|
|
100
|
+
* OHLCV + derived fields are indexable \`PriceSeries\` / \`VolumeSeries\`.
|
|
101
|
+
* Mirrors core's \`BarSeries\`.
|
|
102
|
+
*/
|
|
103
|
+
export type BarSeries = Omit<
|
|
104
|
+
Bar,
|
|
105
|
+
"open" | "high" | "low" | "close" | "volume" | "hl2" | "hlc3" | "ohlc4" | "hlcc4"
|
|
106
|
+
> & {
|
|
107
|
+
readonly open: PriceSeries;
|
|
108
|
+
readonly high: PriceSeries;
|
|
109
|
+
readonly low: PriceSeries;
|
|
110
|
+
readonly close: PriceSeries;
|
|
111
|
+
readonly volume: VolumeSeries;
|
|
112
|
+
readonly hl2: PriceSeries;
|
|
113
|
+
readonly hlc3: PriceSeries;
|
|
114
|
+
readonly ohlc4: PriceSeries;
|
|
115
|
+
readonly hlcc4: PriceSeries;
|
|
116
|
+
};
|
|
82
117
|
/**
|
|
83
118
|
* A \`ta.*\` source-position argument. The runtime
|
|
84
119
|
* (\`packages/runtime/src/ta/lib/sourceValue.ts\`) accepts either a
|
|
85
120
|
* series reference or a scalar; the script-author surface mirrors
|
|
86
|
-
* that contract so \`ta.ema(bar.close, 12)\`
|
|
87
|
-
* \`ta.ema(other, 12)\` (series) both typecheck.
|
|
121
|
+
* that contract so \`ta.ema(bar.close, 12)\` and
|
|
122
|
+
* \`ta.ema(other, 12)\` (series) both typecheck — \`bar.close\` is now a
|
|
123
|
+
* \`PriceSeries\` (\`Price & Series<Price>\`), assignable as both.
|
|
88
124
|
*/
|
|
89
125
|
export type ScalarOrSeries = Series<number> | number;
|
|
90
126
|
export type SmaOpts = Readonly<{ offset?: number }>;
|
|
@@ -103,6 +139,8 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
103
139
|
export type CrossunderOpts = Readonly<{ offset?: number }>;
|
|
104
140
|
export type HighestOpts = Readonly<{ offset?: number }>;
|
|
105
141
|
export type LowestOpts = Readonly<{ offset?: number }>;
|
|
142
|
+
export type HighestbarsOpts = Readonly<{ offset?: number }>;
|
|
143
|
+
export type LowestbarsOpts = Readonly<{ offset?: number }>;
|
|
106
144
|
export type ChangeOpts = Readonly<{ length?: number; offset?: number }>;
|
|
107
145
|
export type PlotLineStyle = "line" | "step" | "dashed" | "circles" | "cross";
|
|
108
146
|
export type WmaOpts = Readonly<{ offset?: number; lineStyle?: PlotLineStyle }>;
|
|
@@ -598,6 +636,12 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
598
636
|
nz(value: number, replacement?: number): number;
|
|
599
637
|
highest(source: ScalarOrSeries, length: number, opts?: HighestOpts): Series<number>;
|
|
600
638
|
lowest(source: ScalarOrSeries, length: number, opts?: LowestOpts): Series<number>;
|
|
639
|
+
highestbars(
|
|
640
|
+
source: ScalarOrSeries,
|
|
641
|
+
length: number,
|
|
642
|
+
opts?: HighestbarsOpts,
|
|
643
|
+
): Series<number>;
|
|
644
|
+
lowestbars(source: ScalarOrSeries, length: number, opts?: LowestbarsOpts): Series<number>;
|
|
601
645
|
change(source: ScalarOrSeries, opts?: ChangeOpts): Series<number>;
|
|
602
646
|
valuewhen(
|
|
603
647
|
condition: Series<boolean>,
|
|
@@ -778,6 +822,7 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
778
822
|
lineStyle?: LineStyle;
|
|
779
823
|
pane?: "overlay" | "new" | string;
|
|
780
824
|
style?: PlotOptsStyle;
|
|
825
|
+
z?: number;
|
|
781
826
|
}>;
|
|
782
827
|
export type HLineOpts = Readonly<{
|
|
783
828
|
color?: Color;
|
|
@@ -786,8 +831,17 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
786
831
|
lineStyle?: LineStyle;
|
|
787
832
|
pane?: "overlay" | "new" | string;
|
|
788
833
|
}>;
|
|
834
|
+
export type BgColorOpts = Readonly<{
|
|
835
|
+
transp?: number;
|
|
836
|
+
title?: string;
|
|
837
|
+
}>;
|
|
838
|
+
export type BarColorOpts = Readonly<{
|
|
839
|
+
title?: string;
|
|
840
|
+
}>;
|
|
789
841
|
export function plot(value: number | Series<number>, opts?: PlotOpts): void;
|
|
790
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;
|
|
791
845
|
export type JsonValue =
|
|
792
846
|
| null
|
|
793
847
|
| boolean
|
|
@@ -883,6 +937,7 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
883
937
|
| "price"
|
|
884
938
|
| "symbol"
|
|
885
939
|
| "interval"
|
|
940
|
+
| "session"
|
|
886
941
|
| "external-series";
|
|
887
942
|
export type SourceField =
|
|
888
943
|
| "open"
|
|
@@ -911,6 +966,7 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
911
966
|
export type PriceDescriptor = CommonInputDescriptor<"price", number>;
|
|
912
967
|
export type SymbolDescriptor = CommonInputDescriptor<"symbol", string>;
|
|
913
968
|
export type IntervalDescriptorInput = CommonInputDescriptor<"interval", string>;
|
|
969
|
+
export type SessionDescriptor = CommonInputDescriptor<"session", string>;
|
|
914
970
|
export type ExternalSeriesDescriptor<T> = Readonly<{
|
|
915
971
|
kind: "external-series";
|
|
916
972
|
name: string;
|
|
@@ -929,6 +985,7 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
929
985
|
| PriceDescriptor
|
|
930
986
|
| SymbolDescriptor
|
|
931
987
|
| IntervalDescriptorInput
|
|
988
|
+
| SessionDescriptor
|
|
932
989
|
| ExternalSeriesDescriptor<T>;
|
|
933
990
|
export const input: Readonly<{
|
|
934
991
|
int(defaultValue: number, opts?: NumericInputOpts & Readonly<{ title?: string }>): IntDescriptor;
|
|
@@ -946,17 +1003,28 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
946
1003
|
price(defaultValue: Price, opts?: Readonly<{ title?: string }>): PriceDescriptor;
|
|
947
1004
|
symbol(defaultValue: string, opts?: Readonly<{ title?: string }>): SymbolDescriptor;
|
|
948
1005
|
interval(defaultValue: string, opts?: Readonly<{ title?: string }>): IntervalDescriptorInput;
|
|
1006
|
+
session(defaultValue: string, opts?: Readonly<{ title?: string }>): SessionDescriptor;
|
|
949
1007
|
externalSeries<T>(args: Readonly<{ name: string; schema: Schema<T>; title?: string }>): ExternalSeriesDescriptor<T>;
|
|
950
1008
|
}>;
|
|
951
1009
|
export type InputSchema = Readonly<Record<string, InputDescriptor<unknown>>>;
|
|
952
1010
|
export type MutableSlot<T> = {
|
|
953
1011
|
value: T;
|
|
954
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
|
+
};
|
|
955
1021
|
export type StateNamespace = Readonly<{
|
|
956
1022
|
float(init: number): MutableSlot<number>;
|
|
957
1023
|
int(init: number): MutableSlot<number>;
|
|
958
1024
|
bool(init: boolean): MutableSlot<boolean>;
|
|
959
1025
|
string(init: string): MutableSlot<string>;
|
|
1026
|
+
series(init: number): NumberSeriesSlot;
|
|
1027
|
+
array<T>(capacity: number): MutableArraySlot<T>;
|
|
960
1028
|
tick: Readonly<{
|
|
961
1029
|
float(init: number): MutableSlot<number>;
|
|
962
1030
|
int(init: number): MutableSlot<number>;
|
|
@@ -1005,7 +1073,31 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1005
1073
|
readonly inSeconds: number;
|
|
1006
1074
|
};
|
|
1007
1075
|
export const timeframe: TimeframeView;
|
|
1008
|
-
export type
|
|
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 }>;
|
|
1009
1101
|
export type RequestLowerTfOpts = Readonly<{ interval: string }>;
|
|
1010
1102
|
export type SecurityBar = Readonly<{
|
|
1011
1103
|
readonly time: Series<Time>;
|
|
@@ -1021,10 +1113,17 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1021
1113
|
readonly symbol: Series<string>;
|
|
1022
1114
|
readonly interval: Series<string>;
|
|
1023
1115
|
}>;
|
|
1024
|
-
export type
|
|
1116
|
+
export type SecurityExpr = (bar: SecurityBar) => Series<number> | number;
|
|
1117
|
+
// Declared as an interface (not a Readonly object type) so the two
|
|
1118
|
+
// security overloads survive. Readonly is a homomorphic mapped type, and
|
|
1119
|
+
// mapping over a member with multiple call signatures collapses it to a
|
|
1120
|
+
// single signature — which made the expression form fail type-check with
|
|
1121
|
+
// TS2554 ("Expected 1 arguments, but got 2").
|
|
1122
|
+
export interface RequestNamespace {
|
|
1025
1123
|
security(opts: RequestSecurityOpts): SecurityBar;
|
|
1124
|
+
security(opts: RequestSecurityOpts, expr: SecurityExpr): Series<number>;
|
|
1026
1125
|
lowerTf(opts: RequestLowerTfOpts): Series<ReadonlyArray<Bar>>;
|
|
1027
|
-
}
|
|
1126
|
+
}
|
|
1028
1127
|
export const request: RequestNamespace;
|
|
1029
1128
|
export function intervalToSeconds(d: IntervalDescriptor): number;
|
|
1030
1129
|
export type OutputDeclaration = Readonly<{
|
|
@@ -1036,6 +1135,16 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1036
1135
|
readonly kind: PlotKind;
|
|
1037
1136
|
readonly title?: string;
|
|
1038
1137
|
}>;
|
|
1138
|
+
export type SecurityExpressionDescriptor = Readonly<{
|
|
1139
|
+
readonly slotId: string;
|
|
1140
|
+
readonly symbol?: string;
|
|
1141
|
+
readonly interval: string;
|
|
1142
|
+
readonly paramName: string;
|
|
1143
|
+
}>;
|
|
1144
|
+
export type RequestedFeed = Readonly<{
|
|
1145
|
+
readonly symbol?: string;
|
|
1146
|
+
readonly interval: string;
|
|
1147
|
+
}>;
|
|
1039
1148
|
export type DependencyDeclaration = Readonly<{
|
|
1040
1149
|
readonly localId: string;
|
|
1041
1150
|
readonly producerName: string;
|
|
@@ -1067,6 +1176,8 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1067
1176
|
readonly dependencies?: ReadonlyArray<DependencyDeclaration>;
|
|
1068
1177
|
readonly outputs?: ReadonlyArray<OutputDeclaration>;
|
|
1069
1178
|
readonly plots?: ReadonlyArray<PlotSlotDescriptor>;
|
|
1179
|
+
readonly securityExpressions?: ReadonlyArray<SecurityExpressionDescriptor>;
|
|
1180
|
+
readonly requestedFeeds?: ReadonlyArray<RequestedFeed>;
|
|
1070
1181
|
readonly exportName?: string;
|
|
1071
1182
|
readonly siblings?: ReadonlyArray<ScriptManifest>;
|
|
1072
1183
|
readonly isDrawn?: boolean;
|
|
@@ -1099,29 +1210,35 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1099
1210
|
WorldPoint,
|
|
1100
1211
|
WorldPoint,
|
|
1101
1212
|
];
|
|
1102
|
-
|
|
1213
|
+
// Render-order mixin — intersected into every \`draw.*\` opts bag in
|
|
1214
|
+
// lockstep with core's \`drawingStyle.ts\` \`ZOrdered\`. \`z\` is a
|
|
1215
|
+
// presentation-only render-order key (default 0, higher on top); it is
|
|
1216
|
+
// a type/contract addition only, so the shim just surfaces the optional
|
|
1217
|
+
// field for type-checking.
|
|
1218
|
+
export type ZOrdered = Readonly<{ z?: number }>;
|
|
1219
|
+
export type LineDrawStyle = ZOrdered & Readonly<{
|
|
1103
1220
|
color?: Color;
|
|
1104
1221
|
lineWidth?: number;
|
|
1105
1222
|
lineStyle?: LineStyle;
|
|
1106
1223
|
extendLeft?: boolean;
|
|
1107
1224
|
extendRight?: boolean;
|
|
1108
1225
|
}>;
|
|
1109
|
-
export type ShapeStyle = Readonly<{
|
|
1226
|
+
export type ShapeStyle = ZOrdered & Readonly<{
|
|
1110
1227
|
stroke?: Color;
|
|
1111
1228
|
fill?: Color;
|
|
1112
1229
|
lineWidth?: number;
|
|
1113
1230
|
lineStyle?: LineStyle;
|
|
1114
1231
|
fillAlpha?: number;
|
|
1115
1232
|
}>;
|
|
1116
|
-
export type HighlighterStyle = Readonly<{
|
|
1233
|
+
export type HighlighterStyle = ZOrdered & Readonly<{
|
|
1117
1234
|
color: Color;
|
|
1118
1235
|
alpha: number;
|
|
1119
1236
|
}>;
|
|
1120
|
-
export type BrushStyle = Readonly<{
|
|
1237
|
+
export type BrushStyle = ZOrdered & Readonly<{
|
|
1121
1238
|
stroke: Color;
|
|
1122
1239
|
fill: Color;
|
|
1123
1240
|
}>;
|
|
1124
|
-
export type TextOpts = Readonly<{
|
|
1241
|
+
export type TextOpts = ZOrdered & Readonly<{
|
|
1125
1242
|
color?: Color;
|
|
1126
1243
|
size?: "tiny" | "small" | "normal" | "large" | "huge";
|
|
1127
1244
|
halign?: "left" | "center" | "right";
|
|
@@ -1129,26 +1246,33 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1129
1246
|
bgColor?: Color;
|
|
1130
1247
|
}>;
|
|
1131
1248
|
export type ArrowOpts = LineDrawStyle & Readonly<{ label?: string }>;
|
|
1132
|
-
export type ArrowMarkerOpts = Readonly<{
|
|
1249
|
+
export type ArrowMarkerOpts = ZOrdered & Readonly<{
|
|
1133
1250
|
color?: Color;
|
|
1134
1251
|
text?: string;
|
|
1135
1252
|
}>;
|
|
1136
1253
|
export type PathOpts = LineDrawStyle & Readonly<{ closed?: boolean }>;
|
|
1137
|
-
export type
|
|
1254
|
+
export type FillBetweenStyle = ZOrdered & Readonly<{
|
|
1255
|
+
color?: Color;
|
|
1256
|
+
lineWidth?: number;
|
|
1257
|
+
lineStyle?: LineStyle;
|
|
1258
|
+
fill?: Color;
|
|
1259
|
+
fillAlpha?: number;
|
|
1260
|
+
}>;
|
|
1261
|
+
export type FibOpts = ZOrdered & Readonly<{
|
|
1138
1262
|
levels?: ReadonlyArray<number>;
|
|
1139
1263
|
showLabels?: boolean;
|
|
1140
1264
|
color?: Color;
|
|
1141
1265
|
extendLeft?: boolean;
|
|
1142
1266
|
extendRight?: boolean;
|
|
1143
1267
|
}>;
|
|
1144
|
-
export type RegressionTrendOpts = Readonly<{
|
|
1268
|
+
export type RegressionTrendOpts = ZOrdered & Readonly<{
|
|
1145
1269
|
source?: "close" | "open" | "high" | "low" | "hl2" | "hlc3" | "ohlc4" | "hlcc4";
|
|
1146
1270
|
stdevMultiplier?: number;
|
|
1147
1271
|
showUpperBand?: boolean;
|
|
1148
1272
|
showLowerBand?: boolean;
|
|
1149
1273
|
color?: Color;
|
|
1150
1274
|
}>;
|
|
1151
|
-
export type FrameOpts = Readonly<{
|
|
1275
|
+
export type FrameOpts = ZOrdered & Readonly<{
|
|
1152
1276
|
label?: string;
|
|
1153
1277
|
bgColor?: Color;
|
|
1154
1278
|
}>;
|
|
@@ -1197,6 +1321,11 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1197
1321
|
circle(centre: WorldPoint, radiusAnchor: WorldPoint, opts?: ShapeStyle): DrawingHandle;
|
|
1198
1322
|
ellipse(a: WorldPoint, b: WorldPoint, opts?: ShapeStyle): DrawingHandle;
|
|
1199
1323
|
path(anchors: ReadonlyArray<WorldPoint>, opts?: PathOpts): DrawingHandle;
|
|
1324
|
+
fillBetween(
|
|
1325
|
+
edgeA: ReadonlyArray<WorldPoint>,
|
|
1326
|
+
edgeB: ReadonlyArray<WorldPoint>,
|
|
1327
|
+
opts?: FillBetweenStyle,
|
|
1328
|
+
): DrawingHandle;
|
|
1200
1329
|
marker(
|
|
1201
1330
|
anchor: WorldPoint,
|
|
1202
1331
|
opts?: TextOpts & Readonly<{ text?: string; value?: number }>,
|
|
@@ -1270,17 +1399,21 @@ declare module "@invinite-org/chartlang-core" {
|
|
|
1270
1399
|
};
|
|
1271
1400
|
export const draw: DrawNamespace;
|
|
1272
1401
|
export type ComputeContext = {
|
|
1273
|
-
readonly bar:
|
|
1402
|
+
readonly bar: BarSeries;
|
|
1274
1403
|
readonly inputs: Readonly<Record<string, unknown>>;
|
|
1275
1404
|
readonly ta: TaNamespace;
|
|
1276
1405
|
readonly plot: typeof plot;
|
|
1277
1406
|
readonly hline: typeof hline;
|
|
1407
|
+
readonly bgcolor: typeof bgcolor;
|
|
1408
|
+
readonly barcolor: typeof barcolor;
|
|
1278
1409
|
readonly alert: typeof alert;
|
|
1279
1410
|
readonly draw: DrawNamespace;
|
|
1280
1411
|
readonly state: StateNamespace;
|
|
1281
1412
|
readonly barstate: BarStateView;
|
|
1282
1413
|
readonly syminfo: SymInfoView;
|
|
1283
1414
|
readonly timeframe: TimeframeView;
|
|
1415
|
+
readonly time: TimeNamespace;
|
|
1416
|
+
readonly session: SessionNamespace;
|
|
1284
1417
|
readonly request: RequestNamespace;
|
|
1285
1418
|
readonly runtime: RuntimeNamespace;
|
|
1286
1419
|
readonly signal?: (conditionId: string, fired: boolean) => void;
|